* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        sans-serif;
    user-select: none;
}

body {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f5f5f7;
}

/* ========= TOP BAR ========= */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 1px solid #e5e5e5;
    background: #ffffff;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logo-mark {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: linear-gradient(135deg, #3b82f6, #a855f7);
}

.logo-text {
    font-weight: 700;
    letter-spacing: 0.06em;
    font-size: 1rem;
    text-transform: uppercase;
    color: #1f2933;
}

.hint {
    font-size: 0.9rem;
    color: #6b7280;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-size: 0.85rem;
}

.toolbar-item {
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
}

.toolbar-item:hover {
    background: #f3f4f6;
}

.toolbar-item.view-toggle {
  position: relative;
}

.view-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.25);
  padding: 6px;
  display: none;
  z-index: 20;
  min-width: 140px;
}

.view-toggle.open .view-menu {
  display: block;
}

.view-option {
  width: 100%;
  border: none;
  background: transparent;
  padding: 6px 10px;
  border-radius: 8px;
  text-align: left;
  font-size: 0.85rem;
  cursor: pointer;
  color: #4b5563;
}

.view-option:hover {
  background: #f3f4f6;
  color: #111827;
}

.view-option,
.view-option-check,
.view-option-check span {
  user-select: none;
}

.view-subtitle {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  padding: 4px 8px 2px;
}

/* highlight active value mode */
.view-option.active {
  background: #e5e7eb;
  color: #111827;
  font-weight: 600;
}

/* hide colour names when toggle off */
body.names-hidden .name {
  display: none;
}


/* default view is your current style; we’ll just be explicit */
body.view-default .swatch {
  padding: 40px 10px 30px;
}

/* compact view: shorter columns + slightly smaller text */
body.view-compact .swatch {
  padding: 22px 10px 18px;
}

body.view-compact .hex {
  font-size: 1.4rem;
}

body.view-compact .name {
  font-size: 0.8rem;
  opacity: 0.85;
}

.view-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 6px;
}

/* Checkbox row */
.view-option-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-option-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

/* DARK NAVBAR THEME */
body.theme-dark .topbar {
  background: #111827;
  border-bottom-color: #1f2937;
  color: #e5e7eb;
}

body.theme-dark .logo-text {
  color: #e5e7eb;
}

body.theme-dark .hint {
  color: #9ca3af;
}

body.theme-dark .toolbar-item {
  color: #e5e7eb;
}

body.theme-dark .toolbar-item:hover {
  background: #1f2937;
}


/* ========= PALETTE ========= */
.palette {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(100vh - 48px);
}

.swatch {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    text-align: center;
    cursor: pointer;
    padding: 40px 10px 30px;
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s;
    overflow: hidden;
}

.swatch:hover {
    transform: translateY(-4px);
    filter: brightness(1.03);
    box-shadow: 0 18px 35px rgba(15, 23, 42, 0.45);
    z-index: 1;
}

.hex {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
    transition: opacity 0.12s ease, filter 0.12s ease;
}

.name {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.95;
    transition: opacity 0.12s ease, filter 0.12s ease;
}

.index-tag {
    position: absolute;
    top: 10px;
    left: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.85;
}

/* ========= SWATCH ACTIONS ON HOVER ========= */
.swatch-actions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    gap: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
}

.swatch:hover .swatch-actions {
    opacity: 1;
    pointer-events: auto;
}

.swatch:hover .hex,
.swatch:hover .name {
    opacity: 0.2;
    filter: blur(1px);
}

.action-btn {
    padding: 6px 10px;
    border-radius: 999px;
    border: none;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.35);
    color: #f9fafb;
    backdrop-filter: blur(6px);
    white-space: nowrap;
}

.action-btn.light {
    background: rgba(255, 255, 255, 0.7);
    color: #111827;
}

.action-btn:active {
    transform: translateY(1px);
}

/* ========= TOAST ========= */
.toast {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.96);
    color: #f9fafb;
    font-size: 0.85rem;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 50;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* ========= SHADES MODAL ========= */
.shades-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 60;
}

.shades-modal.show {
    display: flex;
}

.shades-dialog {
    background: #ffffff;
    border-radius: 16px;
    padding: 16px 18px 14px;
    width: min(480px, 100% - 32px);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 22px 45px rgba(15, 23, 42, 0.5);
}

.shades-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.shades-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #111827;
}

.shades-close {
    border: none;
    background: transparent;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    color: #6b7280;
}

.shades-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.shade-item {
    display: flex;
    align-items: center;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    font-size: 0.8rem;
}

.shade-swatch {
    width: 44px;
    height: 28px;
    flex-shrink: 0;
}

.shade-info {
    flex: 1;
    padding: 0 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shade-hex {
    font-weight: 600;
}

.shade-label {
    color: #6b7280;
}

@media (max-width: 800px) {
    .palette {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 520px) {
    .palette {
        grid-template-columns: repeat(2, 1fr);
    }

    .hex {
        font-size: 1.4rem;
    }
}


/* ================================
   FULL-PAGE LIST MODE
   ================================ */

body.layout-list .palette {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 48px);
}

body.layout-list .swatch {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0;
}

/* Move the index slightly up */
body.layout-list .index-tag {
  position: absolute;
  top: 12px;
  left: 16px;
}

/* Tweak text sizes */
body.layout-list .hex {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

body.layout-list .name {
  font-size: 1rem;
  opacity: 0.85;
}


/* ========= SAVED PALETTES MODAL ========= */

.saved-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
}

.saved-modal.show {
  display: flex;
}

.saved-dialog {
  background: #ffffff;
  border-radius: 16px;
  padding: 16px 18px 14px;
  width: min(520px, 100% - 32px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 22px 45px rgba(15, 23, 42, 0.5);
}

.saved-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.saved-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #111827;
}

.saved-close {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  color: #6b7280;
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  overflow-y: auto;
  padding-right: 4px;
}

.saved-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: background 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.saved-item:hover {
  background: #f9fafb;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}

.saved-preview {
  display: flex;
  width: 120px;
  height: 28px;
  border-radius: 8px;
  overflow: hidden;
  margin-right: 10px;
}

.saved-preview-swatch {
  flex: 1;
}

.saved-meta {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: #4b5563;
}

.saved-meta span:first-child {
  font-weight: 600;
  color: #111827;
}

.saved-footer {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.saved-clear {
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  padding: 6px 12px;
  font-size: 0.8rem;
  background: #f9fafb;
  cursor: pointer;
}

.saved-clear:hover {
  background: #f3f4f6;
}
