/*
 * app.css — custom rules that Tailwind utilities cannot express.
 * All layout, spacing, colour, and typography utilities live in
 * index.html as Tailwind classes. Only genuinely custom rules live here.
 */

/* Prevent any element from triggering horizontal body scroll */
html, body { overflow-x: clip; }

/* ── Drop zone ────────────────────────────────────────────────────────── */
#drop-zone {
  border: 2px dashed #e0daf7;
  transition: border-color 0.2s, background-color 0.2s;
}
#drop-zone:hover,
#drop-zone.drag-over {
  border-color: #6650c4;
  background-color: #ede9ff;
}

/* ── Thread list ──────────────────────────────────────────────────────── */

.color-group {
  margin-bottom: 20px;
}

.color-group-name {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #7b6faa;
  border-bottom: 1px solid #e0daf7;
  padding-bottom: 6px;
  margin-bottom: 8px;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.color-group-name:hover {
  color: #6650c4;
}
.color-group-count {
  font-size: 0.65rem;
  font-weight: 600;
  background: #ede9ff;
  color: #6650c4;
  padding: 1px 5px;
  border-radius: 8px;
  letter-spacing: 0;
  margin-left: 4px;
  text-transform: none;
}

.thread-card {
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  margin-bottom: 6px;
  background: #f8f5ff;
  border: 1px solid #e0daf7;
  overflow: hidden;
}

/* Main row — swatch, pip, info, badges, shades toggle */
.thread-card-main {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.thread-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(0, 0, 0, 0.12);
}

.zone-pip {
  width: 6px;
  height: 32px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Primary: DMC / Anchor reference number — most important in the shop */
.thread-ref {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a1534;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Secondary anchor number shown inline after the DMC number */
.thread-anchor {
  font-weight: 400;
  font-size: 0.8rem;
  color: #7b6faa;
}

/* Thread name — secondary, sits below the reference number */
.thread-name {
  font-size: 0.78rem;
  color: #7b6faa;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Coverage percentage badge — sits below thread name inside the text block */
.thread-usage {
  display: inline-block;
  font-size: 0.68rem;
  background: #ede9ff;
  color: #6650c4;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  font-weight: 600;
  margin-top: 4px;
}

/* Skein count badge — shown when piece dimensions are set */
.thread-skeins {
  font-size: 0.72rem;
  background: #dbeafe;
  color: #1e40af;
  padding: 3px 7px;
  border-radius: 12px;
  white-space: nowrap;
  font-weight: 600;
  flex-shrink: 0;
}
.thread-skeins:empty {
  display: none;
}

/* Match quality dot — colour indicates how close the match is */
.match-badge {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.match-good { background: #d1fae5; color: #065f46; }
.match-fair { background: #fef3c7; color: #92400e; }
.match-poor { background: #fee2e2; color: #991b1b; }

/* ── Brand toggle tabs (results section) ────────────────────────────── */
.brand-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.brand-tab-active {
  background: #6650c4;
  color: #ffffff;
  border-color: #6650c4;
}
.brand-tab-inactive {
  background: #f8f5ff;
  color: #7b6faa;
  border-color: #e0daf7;
}
.brand-tab-inactive:hover {
  background: #ede9ff;
  color: #6650c4;
  border-color: #6650c4;
}
.brand-tab-count {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  line-height: 1.4;
}
.brand-tab-active   .brand-tab-count { background: rgba(255,255,255,0.22); color: #fff; }
.brand-tab-inactive .brand-tab-count { background: #ede9ff; color: #6650c4; }

/* ── Brand badge — shown on each thread card ────────────────────────── */
.brand-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 4px;
  line-height: 1.5;
}
.brand-badge-dmc    { background: #ede9ff; color: #3d3280; }
.brand-badge-anchor { background: #e8ede5; color: #3d5030; }

/* ── Mixed-brand notice ───────────────────────────────────────────────── */
.brand-notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.82rem;
  color: #78350f;
  line-height: 1.5;
}
.brand-notice-icon {
  flex-shrink: 0;
  font-weight: 900;
  font-size: 1rem;
  margin-top: 1px;
}

/* ── Key grid ─────────────────────────────────────────────────────────── */
.key-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px 16px;
}

.key-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: #1a1534;
}

.key-swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  position: relative;
}

/* ── View-mode toggle buttons ─────────────────────────────────────────── */
.zone-btn-active {
  background-color: #6650c4;
  color: #ffffff;
}
.zone-btn-inactive {
  background-color: #ffffff;
  color: #7b6faa;
}
.zone-btn-inactive:hover {
  background-color: #ede9ff;
  color: #6650c4;
}

/* ── Canvases ─────────────────────────────────────────────────────────── */
canvas {
  max-width: 100%;
  display: block;
}

/* ── Skein estimator panel ────────────────────────────────────────────── */
.skein-panel {
  border: 1px solid #e0daf7;
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 8px;
  background: #ffffff;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.skein-panel-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7b6faa;
  align-self: center;
  flex-shrink: 0;
}

.skein-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.skein-field label {
  font-size: 0.72rem;
  color: #7b6faa;
}

.skein-field input,
.skein-field select {
  border: 1px solid #e0daf7;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.82rem;
  background: #f8f5ff;
  color: #1a1534;
  outline: none;
}

.skein-field input:focus,
.skein-field select:focus {
  border-color: #6650c4;
}

.skein-field input {
  width: 72px;
}

/* ── Shopping list ────────────────────────────────────────────────────── */
.shopping-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #e0daf7;
  background: #f8f5ff;
  margin-bottom: 6px;
}

.shopping-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(0, 0, 0, 0.12);
}

.shopping-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.shopping-ref {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1a1534;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shopping-name {
  font-size: 0.76rem;
  color: #7b6faa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shopping-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  flex-shrink: 0;
}

.shopping-count-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: #6650c4;
  line-height: 1;
}

.shopping-count-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #7b6faa;
  margin-top: 1px;
}

/* ── Password gate ─────────────────────────────────────────────────────── */
@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}
.gate-shake { animation: gate-shake 0.45s ease-in-out; }

/* ── Converter direction buttons — full-width stacked, generous tap target ── */
.conv-dir-btn {
  min-height: 52px;
  display: block;
}

/* ── Related shades dropdown — expands below each thread card ───────────── */

/* Small chevron toggle button — sits at the far right of the card main row */
.thread-shades-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid #e0daf7;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7b6faa;
  padding: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.thread-shades-btn svg {
  transition: transform 0.2s;
}
.thread-shades-btn:hover {
  background: #ede9ff;
  color: #6650c4;
  border-color: #9880d8;
}
.thread-shades-btn-open {
  background: #ede9ff;
  color: #6650c4;
  border-color: #9880d8;
}
.thread-shades-btn-open svg {
  transform: rotate(180deg);
}

/* Collapsible panel that appears below the main card row */
.thread-shades-panel {
  border-top: 1px solid #e0daf7;
  background: #f5f1ec;
  padding: 10px 12px 12px;
}

.thread-shades-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7b6faa;
  margin-bottom: 7px;
}

.thread-shades-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Individual shade chip: circle swatch + code + name + direction tag */
.shade-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #e0daf7;
  flex: 1;
  min-width: 110px;
}

/* Highlighted chip for the currently-matched thread */
.shade-chip-current {
  border-color: #6650c4;
  background: #fdf6ef;
  box-shadow: 0 0 0 1px #6650c4;
}

.shade-chip-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(0,0,0,0.12);
}

.shade-chip-code {
  font-size: 0.78rem;
  font-weight: 700;
  color: #1a1534;
  white-space: nowrap;
  line-height: 1.2;
}

.shade-chip-name {
  font-size: 0.68rem;
  color: #7b6faa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.shade-chip-tag {
  font-size: 0.62rem;
  font-weight: 600;
  color: #6650c4;
  margin-top: 1px;
}

/* End-of-range placeholder — shown when no darker/lighter shade exists */
.shade-chip-empty {
  border: 1.5px dashed #d0c8c0;
  background: #f8f5ff;
  opacity: 0.6;
}
.shade-chip-swatch-empty {
  border: 1.5px dashed #c0b8b0;
  background: transparent;
}
.shade-chip-code-empty {
  color: #9a8f87;
  font-weight: 500;
  font-style: italic;
}

/* ── Shade panel header + mode toggle ───────────────────────────────────── */
.shade-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}
.shade-panel-header .thread-shades-label {
  margin-bottom: 0;
}
.shade-mode-toggle {
  display: flex;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid #e0daf7;
  flex-shrink: 0;
}
.shade-mode-btn {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 3px 7px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}
.shade-mode-btn-active   { background: #6650c4; color: #ffffff; }
.shade-mode-btn-inactive { background: transparent; color: #7b6faa; }
.shade-mode-btn-inactive:hover { background: #ede9ff; color: #6650c4; }

/* Dark mode overrides for shade mode toggle */
.dark .shade-mode-toggle { border-color: #3d3632; }
.dark .shade-mode-btn-inactive { color: #a09590; }
.dark .shade-mode-btn-inactive:hover { background: #1a1040; color: #9880d8; }

/* ── Converter result cards ─────────────────────────────────────────────── */

/*
 * Default (mobile): each card stacks vertically —
 *   FROM thread → arrow → TO thread → badge
 * At sm (640 px+): switches to a single horizontal row.
 */
.conv-result-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid #e0daf7;
}
.conv-result-card:last-child { border-bottom: none; }
.conv-result-card-error { background: #fff8f8; }

@media (min-width: 640px) {
  .conv-result-card {
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
}

/* Swatch circle */
.conv-result-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(0, 0, 0, 0.10);
}
.conv-result-swatch-empty {
  border: 2px dashed #d0c8c0;
  background: transparent;
}

/* Thread block (swatch + text) */
.conv-result-thread {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
@media (min-width: 640px) {
  .conv-result-thread { flex: 1; }
}

.conv-result-info { min-width: 0; }

.conv-result-code {
  font-family: ui-monospace, 'Courier New', monospace;
  font-size: 0.875rem;
  font-weight: 700;
  color: #1a1534;
  line-height: 1.25;
  white-space: nowrap;
}

.conv-result-name {
  font-size: 0.72rem;
  color: #7b6faa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

/* Arrow separator */
.conv-result-arrow {
  font-size: 0.9rem;
  color: #9a8f87;
  font-weight: 600;
  flex-shrink: 0;
  /* Indent on mobile so it sits under the code text, not the swatch */
  padding-left: 40px;
}
@media (min-width: 640px) {
  .conv-result-arrow { padding-left: 0; }
}

/* Badge wrapper — pushes to the right on desktop */
.conv-result-badge-wrap { flex-shrink: 0; }

/* Not-found message */
.conv-result-notfound {
  font-size: 0.8rem;
  color: #dc2626;
  padding-left: 40px;
}
@media (min-width: 640px) {
  .conv-result-notfound { padding-left: 0; flex: 1; }
}

/* Match quality badges */
.conv-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.conv-badge-official { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.conv-badge-good     { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.conv-badge-fair     { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.conv-badge-poor     { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

/* ── Project complexity preset cards ────────────────────────────────────── */
.preset-btn-active {
  border-color: #6650c4;
  background: #fff;
  box-shadow: 0 0 0 1px #6650c4;
}
.preset-btn-inactive {
  border-color: #e0daf7;
  background: #fff;
}
.preset-btn-inactive:hover {
  border-color: #9880d8;
  background: #f8f5ff;
}

/* ═══════════════════════════════════════════════════════════════════════
   DARK MODE
   Activated by adding the `dark` class to <html> via theme.js.
   An inline <head> script applies the saved preference immediately
   so there is no flash of light mode on page load.
   Default is always light (warm cream). User choice saved to localStorage.
══════════════════════════════════════════════════════════════════════ */

/* ── Core palette — overrides Tailwind @theme CSS variables ─────────── */
/* These make all Tailwind utility classes (bg-canvas, text-ink, etc.)
   automatically switch in dark mode without touching any HTML. */
html.dark {
  --color-canvas:      #1a1530;
  --color-surface:     #231e42;
  --color-rim:         #3a3464;
  --color-ink:         #ede8ff;
  --color-muted:       #9880cc;
  --color-brand-light: #1e1840;
  /* --color-brand (#6650c4) intentionally unchanged — works on both */
}

/* bg-white toolbar buttons (Save PDF, Print) — switch to surface in dark */
.dark .bg-white {
  background-color: var(--color-surface);
}

/* ── Drop zone ────────────────────────────────────────────────────────── */
.dark #drop-zone {
  border-color: var(--color-rim);
}
.dark #drop-zone:hover,
.dark #drop-zone.drag-over {
  border-color: var(--color-brand);
  background-color: var(--color-brand-light);
}

/* ── Zone / mode toggle buttons ──────────────────────────────────────── */
.dark .zone-btn-inactive {
  background-color: var(--color-surface);
  color: var(--color-muted);
}
.dark .zone-btn-inactive:hover {
  background-color: var(--color-brand-light);
  color: var(--color-brand);
}

/* ── Brand tabs ──────────────────────────────────────────────────────── */
.dark .brand-tab-inactive {
  background: var(--color-surface);
  color: var(--color-muted);
  border-color: var(--color-rim);
}
.dark .brand-tab-inactive:hover {
  background: var(--color-brand-light);
  color: var(--color-brand);
  border-color: var(--color-brand);
}

/* ── Thread list ──────────────────────────────────────────────────────── */
.dark .color-group-name {
  color: var(--color-muted);
  border-bottom-color: var(--color-rim);
}
.dark .color-group-name:hover { color: var(--color-brand); }

.dark .thread-card {
  background: var(--color-surface);
  border-color: var(--color-rim);
}
.dark .thread-ref  { color: var(--color-ink); }
.dark .thread-name { color: var(--color-muted); }
.dark .thread-anchor { color: var(--color-muted); }

/* Swatch circle borders — black rgba looks invisible on dark bg */
.dark .thread-swatch { border-color: rgba(255, 255, 255, 0.14); }

/* Coverage badge — uses brand colours, stays warm */
.dark .thread-usage {
  background: var(--color-brand-light);
  color: #9880d8;
}

/* Skein count badge (blue) */
.dark .thread-skeins {
  background: #1e3052;
  color: #93c5fd;
}

/* Match quality badges */
.dark .match-good { background: #052e16; color: #86efac; }
.dark .match-fair { background: #431407; color: #fcd34d; }
.dark .match-poor { background: #450a0a; color: #fca5a5; }

/* Brand badges */
.dark .brand-badge-dmc    { background: #1e1840; color: #9880d8; }
.dark .brand-badge-anchor { background: #1a2818; color: #86a878; }

/* Mixed-brand warning notice */
.dark .brand-notice {
  background: #2c1e08;
  border-color: #78350f;
  color: #fcd34d;
}

/* ── Shade dropdown ──────────────────────────────────────────────────── */
.dark .thread-shades-btn {
  border-color: var(--color-rim);
  color: var(--color-muted);
}
.dark .thread-shades-btn:hover,
.dark .thread-shades-btn-open {
  background: var(--color-brand-light);
  color: #9880d8;
  border-color: #2e2060;
}
.dark .thread-shades-panel {
  background: #201c19;
  border-top-color: var(--color-rim);
}
.dark .thread-shades-label { color: var(--color-muted); }

.dark .shade-chip {
  background: var(--color-surface);
  border-color: var(--color-rim);
}
.dark .shade-chip-current {
  background: #2a1e14;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 1px var(--color-brand);
}
.dark .shade-chip-swatch { border-color: rgba(255, 255, 255, 0.14); }
.dark .shade-chip-code   { color: var(--color-ink); }
.dark .shade-chip-name   { color: var(--color-muted); }
.dark .shade-chip-tag    { color: #9880d8; }
.dark .shade-chip-empty  {
  border-color: #4a4440;
  background: #1e1a17;
}
.dark .shade-chip-swatch-empty { border-color: #4a4440; }
.dark .shade-chip-code-empty   { color: var(--color-muted); }

/* ── Skein estimator ──────────────────────────────────────────────────── */
.dark .skein-panel {
  background: var(--color-surface);
  border-color: var(--color-rim);
}
.dark .skein-panel-label { color: var(--color-muted); }
.dark .skein-field label { color: var(--color-muted); }
.dark .skein-field input,
.dark .skein-field select {
  background: var(--color-canvas);
  border-color: var(--color-rim);
  color: var(--color-ink);
}
.dark .skein-field input:focus,
.dark .skein-field select:focus { border-color: var(--color-brand); }

/* ── Shopping list ────────────────────────────────────────────────────── */
.dark .shopping-row {
  background: var(--color-surface);
  border-color: var(--color-rim);
}
.dark .shopping-swatch { border-color: rgba(255, 255, 255, 0.14); }
.dark .shopping-ref    { color: var(--color-ink); }
.dark .shopping-name   { color: var(--color-muted); }

/* ── Zone map key ─────────────────────────────────────────────────────── */
.dark .key-item   { color: var(--color-ink); }
.dark .key-swatch { border-color: rgba(255, 255, 255, 0.12); }

/* ── Preset complexity cards ──────────────────────────────────────────── */
.dark .preset-btn-active {
  background: var(--color-surface);
  border-color: var(--color-brand);
  box-shadow: 0 0 0 1px var(--color-brand);
}
.dark .preset-btn-inactive {
  background: var(--color-surface);
  border-color: var(--color-rim);
}
.dark .preset-btn-inactive:hover {
  border-color: #2e2060;
  background: var(--color-surface);
}

/* ── Converter result cards ──────────────────────────────────────────── */
.dark .conv-result-card         { border-bottom-color: var(--color-rim); }
.dark .conv-result-card-error   { background: #2a1414; }
.dark .conv-result-code         { color: var(--color-ink); }
.dark .conv-result-name         { color: var(--color-muted); }
.dark .conv-result-arrow        { color: var(--color-muted); }
.dark .conv-result-notfound     { color: #fca5a5; }
.dark .conv-result-swatch       { border-color: rgba(255, 255, 255, 0.14); }
.dark .conv-result-swatch-empty { border-color: #4a4440; }

/* Converter match badges */
.dark .conv-badge-official { background: #052e16; color: #86efac; border-color: #166534; }
.dark .conv-badge-good     { background: #052e16; color: #86efac; border-color: #166534; }
.dark .conv-badge-fair     { background: #431407; color: #fcd34d; border-color: #78350f; }
.dark .conv-badge-poor     { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }

/* ═══════════════════════════════════════════════════════════════════════
   GUIDED TOUR
   First-visit tooltip tour. Highlight ring on target elements;
   a floating card with Next / Skip buttons.
   Controlled by tour.js.
══════════════════════════════════════════════════════════════════════ */

/* Glowing brand-coloured ring on the highlighted element */
.tour-highlight {
  position: relative;
  z-index: 1001;
  border-radius: 8px;
  box-shadow: 0 0 0 3px #6650c4, 0 0 0 7px rgba(139, 94, 60, 0.2);
  animation: tour-glow 2s ease-in-out infinite;
}
@keyframes tour-glow {
  0%, 100% { box-shadow: 0 0 0 3px #6650c4, 0 0 0 7px  rgba(139, 94, 60, 0.15); }
  50%       { box-shadow: 0 0 0 4px #6650c4, 0 0 0 12px rgba(139, 94, 60, 0.35); }
}

/* Welcome-step backdrop — softly dims the page */
#tour-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.55);
  z-index: 1998;
  cursor: pointer; /* clicking outside closes the tour */
}

/* Tooltip card */
#tour-tooltip {
  position: fixed;
  z-index: 2000;
  background: #ffffff;
  border: 1.5px solid #e0daf7;
  border-radius: 14px;
  padding: 18px 20px 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  pointer-events: all;
  transition: top 0.28s ease, left 0.28s ease;
}
.dark #tour-tooltip {
  background: #272320;
  border-color: #3d3632;
}

#tour-step-num {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6650c4;
}

#tour-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1a1534;
  margin: 6px 0 8px;
  line-height: 1.3;
}
.dark #tour-title { color: #ede8e3; }

#tour-body {
  font-size: 0.875rem;
  color: #7b6faa;
  line-height: 1.65;
  margin: 0 0 16px;
}
.dark #tour-body { color: #a09590; }

#tour-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#tour-skip {
  font-size: 0.78rem;
  color: #7b6faa;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s;
}
#tour-skip:hover          { color: #1a1534; }
.dark #tour-skip          { color: #a09590; }
.dark #tour-skip:hover    { color: #ede8e3; }

#tour-next {
  background: #6650c4;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 9px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
#tour-next:hover { opacity: 0.88; }

/* Tour button in the header */
.tour-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid #e0daf7;
  background: transparent;
  color: #7b6faa;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.tour-header-btn:hover {
  background: #ede9ff;
  color: #6650c4;
  border-color: #9880d8;
}
.dark .tour-header-btn {
  border-color: #3d3632;
  color: #a09590;
}
.dark .tour-header-btn:hover {
  background: #1a1040;
  color: #9880d8;
  border-color: #2e2060;
}

/* Theme toggle button */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  border: 1px solid #e0daf7;
  background: transparent;
  color: #7b6faa;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.theme-toggle-btn:hover {
  background: #ede9ff;
  color: #6650c4;
  border-color: #9880d8;
}
.dark .theme-toggle-btn {
  border-color: #3d3632;
  color: #a09590;
}
.dark .theme-toggle-btn:hover {
  background: #1a1040;
  color: #9880d8;
  border-color: #2e2060;
}

/* ═══════════════════════════════════════════════════════════════════════
   SITE NAVIGATION — consistent across homepage + tool pages
   Replaces the old simple header on tool pages.
════════════════════════════════════════════════════════════════════════ */

.site-nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-rim);
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-wordmark {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--color-ink);
}
.site-nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}
.nav-link {
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 400;
  color: var(--color-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.nav-link:hover {
  background: var(--color-brand-light);
  color: var(--color-dark-brown);
  text-decoration: none;
}
.nav-link.active {
  background: var(--color-brand-light);
  color: var(--color-dark-brown);
  font-weight: 700;
}

@media (max-width: 600px) {
  .site-nav-links { display: none; }
  .brand-wordmark { font-size: 15px; }
  /* Hide "Open the toolkit" CTA — combined nav width exceeds narrow phones */
  .nav-cta-btn { display: none; }
}
.dark .site-nav { background: var(--color-surface); border-color: var(--color-rim); }

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE NAVIGATION — hamburger menu, shown only on phones
   ══════════════════════════════════════════════════════════════════════ */

/* Hamburger button — hidden on desktop */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  border: 1px solid var(--color-rim);
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.mobile-menu-btn:hover { background: var(--color-brand-light); color: var(--color-brand); border-color: var(--color-brand); }
.dark .mobile-menu-btn { border-color: #3d3632; color: #a09590; }
.dark .mobile-menu-btn:hover { background: #1a1040; color: #9880d8; border-color: #2e2060; }

@media (max-width: 600px) {
  .mobile-menu-btn { display: inline-flex; }
}

/* Drop-down panel */
.mobile-menu {
  display: none;
  position: absolute; /* inside position:sticky nav — drops from the nav bottom */
  top: 100%;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-rim);
  border-bottom: 1px solid var(--color-rim);
  box-shadow: 0 8px 24px -4px rgba(50, 40, 120, 0.12);
  z-index: 49;
  padding: 8px;
}
.mobile-menu.mobile-menu-open { display: block; }
/* Never show on desktop, regardless of JS state */
@media (min-width: 601px) { .mobile-menu { display: none !important; } }

.mobile-nav-link {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  color: var(--color-ink);
  text-decoration: none;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.005em;
}
.mobile-nav-link:hover { background: var(--color-brand-light); color: var(--color-brand); }
.mobile-nav-link.active { background: var(--color-brand-light); color: var(--color-brand); font-weight: 700; }
.dark .mobile-menu { background: var(--color-surface); border-color: var(--color-rim); box-shadow: 0 8px 24px -4px rgba(0,0,0,0.4); }
.dark .mobile-nav-link { color: var(--color-ink); }
.dark .mobile-nav-link:hover,
.dark .mobile-nav-link.active { background: var(--color-brand-light); color: #9880d8; }
.dark .brand-wordmark { color: var(--color-ink); }
.dark .nav-link { color: var(--color-muted); }
.dark .nav-link:hover { background: var(--color-brand-light); color: #9880d8; }
.dark .nav-link.active { background: var(--color-brand-light); color: #9880d8; }

/* ═══════════════════════════════════════════════════════════════════════
   STITCH DIVIDER — running thread with needle, sits between sections
════════════════════════════════════════════════════════════════════════ */

.stitch-divider {
  position: relative;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.stitch-divider svg {
  width: 100%;
  height: 100%;
  display: block;
  color: var(--color-brand);
  opacity: 0.5;
}
.stitch-divider.before-blush {
  background: linear-gradient(to bottom, var(--color-canvas) 50%, #ede9ff 50%);
}
.stitch-divider.after-blush {
  background: linear-gradient(to bottom, #ede9ff 50%, var(--color-canvas) 50%);
}
.dark .stitch-divider svg { opacity: 0.3; }
.dark .stitch-divider.before-blush {
  background: linear-gradient(to bottom, var(--color-canvas) 50%, var(--color-brand-light) 50%);
}
.dark .stitch-divider.after-blush {
  background: linear-gradient(to bottom, var(--color-brand-light) 50%, var(--color-canvas) 50%);
}

/* ═══════════════════════════════════════════════════════════════════════
   TOOL PAGE HEADER — eyebrow + page title above the tool sections
════════════════════════════════════════════════════════════════════════ */

.tool-page-intro {
  padding: 32px 0 8px;
}
.tool-eyebrow {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-brand);
  margin-bottom: 10px;
}
.tool-page-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--color-ink);
  line-height: 1.25;
  margin: 0 0 8px;
}
.dark .tool-page-title { color: var(--color-ink); }

/* Section headings on tool pages — Playfair Display per brand guidelines */
.tool-section-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--color-ink);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
/* Step number badges — force line-height to 1 so the digit sits
   perfectly centred inside the circle (flex alignment alone is not
   enough when the font's natural line-height is > 1). */
.tool-section-title > span.rounded-full { line-height: 1; }
.dark .tool-section-title { color: var(--color-ink); }

/* ═══════════════════════════════════════════════════════════════════════
   HOMEPAGE — hero, tool cards, how it works, footer
════════════════════════════════════════════════════════════════════════ */

.hp-body { background: var(--color-canvas); }

/* Container */
.hp-container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Hero */
.hp-hero {
  padding: 72px 0 80px;
  position: relative;
  overflow: hidden;
}
.hp-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(800px 400px at 90% 10%, rgba(144,128,200,0.14), transparent 60%),
    radial-gradient(600px 350px at 5% 90%, rgba(196,122,133,0.07), transparent 60%);
  pointer-events: none;
}
.hp-hero-copy {
  position: relative;
}
.hp-eyebrow {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-brand);
  margin-bottom: 20px;
}
.hp-hero h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(36px, 5vw, 58px);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--color-ink);
  margin: 0 0 20px;
}
.hp-hero h1 em {
  font-style: italic;
  font-weight: 400;
  color: var(--color-brand);
}
.hp-hero-lede {
  font-size: 17px;
  line-height: 1.65;
  color: var(--color-muted);
  max-width: 520px;
  margin-bottom: 36px;
}
.hp-hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}
.hp-hero-trust {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.hp-trust-stat strong {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 20px;
  font-weight: 500;
  color: var(--color-ink);
  margin-right: 5px;
}
.hp-trust-stat span {
  font-size: 12px;
  color: var(--color-muted);
}
.hp-trust-divider {
  width: 1px;
  height: 20px;
  background: var(--color-rim);
}

/* Buttons (homepage) */
.hp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  border-radius: 8px;
  font-family: 'Lato', 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
  text-decoration: none;
}
.hp-btn:active { transform: translateY(1px); }
.hp-btn-primary {
  background: var(--color-brand);
  color: #fff;
  border-color: var(--color-brand);
}
.hp-btn-primary:hover { background: #3d3280; border-color: #3d3280; text-decoration: none; }
.hp-btn-secondary {
  background: transparent;
  color: var(--color-brand);
  border-color: var(--color-brand);
}
.hp-btn-secondary:hover { background: var(--color-brand-light); text-decoration: none; }

/* Section heading */
.hp-section { padding: 80px 0; }
.hp-section-head { margin-bottom: 40px; }
.hp-section-head h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--color-ink);
  margin: 0 0 10px;
  line-height: 1.25;
}
.hp-section-head h2 em { font-style: italic; font-weight: 400; color: var(--color-brand); }
.hp-section-head p {
  font-size: 15px;
  color: var(--color-muted);
  max-width: 560px;
  line-height: 1.65;
}

/* Tool cards grid — 2×2 on desktop, single column on mobile */
.hp-tools-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
@media (max-width: 640px) { .hp-tools-grid { grid-template-columns: 1fr; } }

.hp-tool-card {
  background: var(--color-surface);
  border: 1px solid var(--color-rim);
  border-radius: 12px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  text-decoration: none;
  color: inherit;
  min-height: 300px;
}
.hp-tool-card.available { cursor: pointer; }
.hp-tool-card.available:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 40px -24px rgba(70,50,150,0.22);
  border-color: #9080c8;
  text-decoration: none;
}
.hp-tool-card.soon {
  background: transparent;
  border-style: dashed;
}
.hp-tool-icon {
  width: 52px; height: 52px;
  background: var(--color-brand-light);
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.hp-tool-card.soon .hp-tool-icon { background: #f5e8eb; }
.hp-tool-name {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.hp-tool-name h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 19px;
  font-weight: 500;
  color: var(--color-ink);
  margin: 0;
}
.hp-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
}
.hp-tag-live { background: #ede9ff; color: #6650c4; }
.hp-tag-soon { background: #f0edf8; color: #7b6faa; }
.hp-tool-desc {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--color-muted);
  flex-grow: 1;
}
.hp-tool-features {
  list-style: none;
  padding: 0; margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--color-muted);
}
.hp-tool-features li {
  display: flex;
  align-items: center;
  gap: 7px;
}
.hp-tool-features li::before {
  content: "";
  width: 5px; height: 5px;
  background: #9080c8;
  border-radius: 50%;
  flex-shrink: 0;
}
.hp-tool-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--color-rim);
}
.hp-tool-link {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-brand);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.01em;
}
.hp-tool-link .hp-arrow { transition: transform 0.2s; }
.hp-tool-card.available:hover .hp-arrow { transform: translateX(4px); }
.hp-tool-meta { font-size: 11px; color: var(--color-muted); }
/* Stack footer items on small cards */
@media (max-width: 640px) {
  .hp-tool-footer { flex-direction: column; align-items: flex-start; gap: 4px; }
}

/* ── Two-column section heads — collapse to single column on mobile ── */
.hp-section-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}
@media (max-width: 700px) {
  .hp-section-2col { grid-template-columns: 1fr; gap: 12px; }
}

/* How it works */
.hp-howitworks {
  background: var(--color-brand-light);
  padding: 80px 0;
  position: relative;
}
.hp-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  position: relative;
  margin-top: 40px;
}
.hp-steps::before {
  content: "";
  position: absolute;
  top: 38px;
  left: 16.66%; right: 16.66%;
  border-top: 1.5px dashed #9080c8;
  z-index: 0;
}
@media (max-width: 700px) {
  .hp-steps { grid-template-columns: 1fr; gap: 20px; }
  .hp-steps::before { display: none; }
}
.hp-step {
  position: relative;
  z-index: 1;
  text-align: center;
}
.hp-step-num {
  width: 76px; height: 76px;
  background: var(--color-canvas);
  border: 1.5px solid #9080c8;
  border-radius: 50%;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 28px;
  font-weight: 500;
  font-style: italic;
  color: var(--color-brand);
  box-shadow: 0 4px 14px -6px rgba(50,40,120,0.12);
}
.hp-step h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 17px;
  font-weight: 500;
  color: var(--color-ink);
  margin: 0 0 8px;
}
.hp-step p {
  font-size: 13.5px;
  color: var(--color-muted);
  line-height: 1.6;
  max-width: 260px;
  margin: 0 auto;
}

/* CTA strip */
.hp-cta-strip {
  background: var(--color-brand);
  padding: 72px 0;
  position: relative;
  overflow: hidden;
}
.hp-cta-strip::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(500px 280px at 10% 50%, rgba(144,128,200,0.3), transparent 60%);
}
.hp-cta-inner {
  position: relative;
  text-align: center;
}
.hp-cta-strip h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 500;
  color: var(--color-brand-light);
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}
.hp-cta-strip h2 em { font-style: italic; color: #fff; }
.hp-cta-strip p {
  color: var(--color-brand-light);
  opacity: 0.85;
  font-size: 15px;
  margin-bottom: 28px;
}
.hp-cta-strip .hp-btn-primary {
  background: var(--color-brand-light);
  color: #3d3280;
  border-color: var(--color-brand-light);
}
.hp-cta-strip .hp-btn-primary:hover { background: #fff; border-color: #fff; }

/* Footer */
.hp-footer {
  background: var(--color-canvas);
  border-top: 1px solid var(--color-rim);
  padding: 48px 0 28px;
}
.hp-footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 32px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}
.hp-footer-brand p {
  font-size: 13px;
  color: var(--color-muted);
  margin-top: 10px;
  max-width: 260px;
  line-height: 1.6;
}
.hp-footer-links h4 {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-brand);
  margin-bottom: 12px;
}
.hp-footer-links ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 7px; }
.hp-footer-links a { font-size: 13px; color: var(--color-muted); text-decoration: none; }
.hp-footer-links a:hover { color: var(--color-brand); }
.hp-footer-bottom {
  border-top: 1px solid var(--color-rim);
  padding-top: 20px;
  font-size: 12px;
  color: var(--color-muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.hp-footer-quote {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  color: var(--color-brand);
  font-size: 13px;
}

/* Dark mode for homepage */
.dark .hp-tool-card {
  background: var(--color-surface);
  border-color: var(--color-rim);
}
.dark .hp-tool-name h3 { color: var(--color-ink); }
.dark .hp-tool-footer { border-color: var(--color-rim); }
.dark .hp-howitworks { background: var(--color-brand-light); }
.dark .hp-step-num { background: var(--color-surface); border-color: #2e2060; }
.dark .hp-step h3 { color: var(--color-ink); }
.dark .hp-footer { background: var(--color-canvas); border-color: var(--color-rim); }
.dark .hp-footer-bottom { border-color: var(--color-rim); }

/* ── Badge colour updates ─────────────────────────────────────────── */
.brand-badge-dmc    { background: #ede9ff; color: #3d3280; }
.brand-badge-anchor { background: #e8ede5; color: #3d5030; }
.dark .brand-badge-dmc    { background: #1e1840; color: #9880d8; }
.dark .brand-badge-anchor { background: #1a2818; color: #86a878; }

/* Dark mode homepage tags */
.dark .hp-tag-live { background: #1e1840; color: #9880d8; }
.dark .hp-tag-soon { background: #231e42; color: #9880cc; }

/* ── Homepage hero layout (two-column with demo card) ─────────────────── */
.hp-hero-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
  max-width: 100%;
}
@media (max-width: 860px) {
  .hp-hero-inner { grid-template-columns: 1fr; }
  .demo-card { display: none; }
}

/* ── Demo card ─────────────────────────────────────────────────────────── */
.demo-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px -16px rgba(70,50,150,0.18), 0 4px 16px -4px rgba(70,50,150,0.10);
  overflow: hidden;
  max-width: 440px;
  width: 100%;
}
.demo-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #e0daf7;
  padding: 0 16px;
  gap: 2px;
}
.demo-tab {
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  color: #7b6faa;
  display: flex;
  align-items: center;
  gap: 6px;
}
.demo-tab-active {
  color: #6650c4;
  border-bottom-color: #6650c4;
}
.demo-tab-inactive { color: #7b6faa; }
.demo-live-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #16a34a;
  display: flex;
  align-items: center;
  gap: 5px;
}
.demo-live-dot {
  width: 7px; height: 7px;
  background: #22c55e;
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.demo-body { padding: 16px; }
.demo-match-layout {
  display: flex;
  gap: 14px;
}
.demo-canvas-wrap {
  position: relative;
  flex-shrink: 0;
  cursor: crosshair;
  border-radius: 10px;
  overflow: hidden;
  width: 160px; height: 160px;
}
#demo-paint {
  width: 160px; height: 160px;
  display: block;
  border-radius: 10px;
}
.demo-cursor-ring {
  position: absolute;
  width: 24px; height: 24px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
  transition: left 0.08s, top 0.08s;
}
.demo-results-panel { flex: 1; min-width: 0; }
.demo-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.demo-panel-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #7b6faa;
}
.demo-hex-chip {
  font-size: 10px;
  font-weight: 700;
  font-family: monospace;
  background: #ede9ff;
  color: #3d3280;
  padding: 2px 8px;
  border-radius: 20px;
}
.demo-result-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f0ecff;
}
.demo-result-row:last-child { border-bottom: none; }
.demo-swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(0,0,0,0.08);
}
.demo-result-info { flex: 1; min-width: 0; }
.demo-result-code {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #1a1534;
  line-height: 1.2;
}
.demo-result-name {
  display: block;
  font-size: 10px;
  color: #7b6faa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.demo-badge-dmc {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: #ede9ff;
  color: #6650c4;
  padding: 2px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}
.demo-result-pct {
  font-size: 11px;
  font-weight: 700;
  color: #6650c4;
  flex-shrink: 0;
  min-width: 28px;
  text-align: right;
}
.demo-hint {
  font-size: 11px;
  color: #7b6faa;
  text-align: center;
  padding: 18px 8px 4px;
  line-height: 1.5;
}
.demo-hint-footer {
  font-size: 10px;
  color: #7b6faa;
  text-align: center;
  padding: 10px 16px 14px;
  border-top: 1px solid #f0ecff;
  margin-top: 6px;
}

/* ── Starter palettes section ──────────────────────────────────────────── */
.hp-palettes { padding: 80px 0; }
.hp-palettes-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 32px;
}
@media (max-width: 900px) { .hp-palettes-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .hp-palettes-grid { grid-template-columns: 1fr; } }
.hp-palette-card {
  background: #fff;
  border: 1px solid #e0daf7;
  border-radius: 12px;
  padding: 16px;
  cursor: default;
}
.hp-palette-swatches {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.hp-palette-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.07);
  flex-shrink: 0;
}
.hp-palette-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 14px;
  font-weight: 500;
  color: #1a1534;
  margin: 0 0 4px;
}
.hp-palette-meta {
  font-size: 11px;
  color: #7b6faa;
}

/* ── Thread-spool background motif ─────────────────────────────────────── */
.hp-spool-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.hp-spool-bg svg {
  position: absolute;
  right: -40px;
  top: 50%;
  transform: translateY(-50%);
  height: 90%;
  width: auto;
  opacity: 0.12;
}
.hp-howitworks > .hp-container { position: relative; z-index: 1; }

/* Dark mode additions */
.dark .demo-card { background: #231e42; box-shadow: 0 24px 64px -16px rgba(0,0,0,0.5); }
.dark .demo-tabs { border-bottom-color: #3a3464; }
.dark .demo-result-row { border-bottom-color: #2e2a50; }
.dark .demo-result-code { color: #ede8ff; }
.dark .demo-panel-label { color: #9880cc; }
.dark .demo-result-name { color: #9880cc; }
.dark .demo-hex-chip { background: #1e1840; color: #9880d8; }
.dark .hp-palette-card { background: #231e42; border-color: #3a3464; }
.dark .hp-palette-name { color: #ede8ff; }
.dark .hp-palette-meta { color: #9880cc; }

/* ══════════════════════════════════════════════════════════════════════════
   PALETTE BUILDER
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Editor layout ─────────────────────────────────────────────────────── */
.pb-editor-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.pb-editor-cols {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
  min-width: 0;
}
/* Grid children default to min-width: auto — override so they shrink on mobile */
.pb-editor-cols > * { min-width: 0; }

@media (max-width: 880px) {
  .pb-editor-cols { grid-template-columns: 1fr; }
}

.pb-palette-panel {
  position: sticky;
  top: 72px; /* below fixed nav */
}

/* ── Palette name input ────────────────────────────────────────────────── */
.pb-name-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #e0daf7;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Playfair Display', serif;
  background: var(--color-canvas);
  color: var(--color-ink);
  outline: none;
  transition: border-color 0.15s;
}
.pb-name-input:focus { border-color: #6650c4; }

/* ── Notes textarea ────────────────────────────────────────────────────── */
.pb-notes-textarea {
  width: 100%;
  border: 1px solid #e0daf7;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-family: 'Lato', sans-serif;
  background: var(--color-canvas);
  color: var(--color-ink);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
  display: block;
  margin-bottom: 10px;
}
.pb-notes-textarea:focus { border-color: #6650c4; }

/* ── Section toggle button ─────────────────────────────────────────────── */
.pb-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: inherit;
  gap: 8px;
  margin-bottom: 2px;
}

/* ── Drop zone (palette builder) ───────────────────────────────────────── */
.pb-drop-zone {
  border: 2px dashed #e0daf7;
  border-radius: 10px;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  text-align: center;
  color: var(--color-muted);
  transition: border-color 0.2s, background-color 0.2s;
  background: var(--color-canvas);
}
.pb-drop-zone:hover,
.pb-drop-zone.drag-over {
  border-color: #6650c4;
  background-color: #ede9ff;
}
.pb-drop-label { font-size: 0.875rem; }
.pb-drop-hint  { font-size: 0.75rem; opacity: 0.7; }

/* ── Moodboard grid ────────────────────────────────────────────────────── */
.pb-moodboard {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.pb-moodboard-cell {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid #e0daf7;
  height: 200px;
}
.pb-moodboard-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pb-moodboard-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(26,21,52,0.65);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.pb-moodboard-cell:hover .pb-moodboard-remove { opacity: 1; }
.pb-moodboard-extract-btn {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(102,80,196,0.92);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.pb-moodboard-cell:hover .pb-moodboard-extract-btn { opacity: 1; }
.pb-moodboard-add {
  height: 120px;
  border: 2px dashed #e0daf7;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  color: var(--color-muted);
  font-size: 0.75rem;
  transition: border-color 0.2s, background 0.2s;
}
.pb-moodboard-add:hover { border-color: #6650c4; background: #ede9ff; color: #6650c4; }

/* ── Extract chips ─────────────────────────────────────────────────────── */
.pb-extract-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pb-extract-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--color-surface);
  border: 1.5px solid #e0daf7;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.78rem;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.pb-extract-chip.selected,
.pb-extract-chip:has(input:checked) {
  border-color: #6650c4;
  background: #ede9ff;
}
.pb-extract-chip.already-added {
  opacity: 0.5;
  pointer-events: none;
}
.pb-extract-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}
.pb-extract-code { font-weight: 700; color: var(--color-ink); flex-shrink: 0; }
.pb-extract-name { color: var(--color-muted); max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Palette list card ─────────────────────────────────────────────────── */
.pb-palette-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid #e0daf7;
  background: var(--color-surface);
  margin-bottom: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pb-palette-card:hover { border-color: #9080c8; box-shadow: 0 2px 12px rgba(102,80,196,0.08); }

.pb-palette-thumbs {
  display: flex;
  flex-direction: column;   /* images stacked top-to-bottom, left-aligned */
  gap: 4px;
  flex-shrink: 0;
  align-items: flex-start;
}
.pb-palette-thumb {
  width: 72px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e0daf7;
  display: block;
}
.pb-palette-thumb-placeholder {
  width: 72px;
  height: 56px;
  border-radius: 6px;
  border: 1px solid #e0daf7;
  background: #ede9ff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9080c8;
  flex-shrink: 0;
}

.pb-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.pb-card-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.pb-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-ink);
  font-family: 'Playfair Display', serif;
}
.pb-card-brand {
  font-size: 0.7rem;
  font-weight: 700;
  background: #ede9ff;
  color: #3d3280;
  border-radius: 4px;
  padding: 1px 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pb-card-notes {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin: 0 0 6px;
  line-height: 1.4;
}
.pb-card-meta {
  font-size: 0.72rem;
  color: var(--color-muted);
  margin-top: 6px;
}
.pb-no-threads {
  font-size: 0.72rem;
  color: var(--color-muted);
  font-style: italic;
}

/* Footer row: Open button on the left, trash on the right */
.pb-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 12px;
}

/* "+N more" text after swatch dots when there are extra threads */
.pb-swatch-more {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-muted);
  align-self: center;
  margin-left: 2px;
  white-space: nowrap;
}

.pb-swatch-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.pb-swatch-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.pb-card-actions { display: none; }  /* superseded by .pb-card-footer */

/* ── Thread rows (inside palette) ──────────────────────────────────────── */
.pb-thread-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #e0daf7;
  flex-wrap: wrap;
}
.pb-thread-row:last-child { border-bottom: none; }
.pb-thread-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
  display: inline-block;
}
.pb-thread-brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pb-brand-dmc    { background: #ede9ff; color: #3d3280; }
.pb-brand-anchor { background: #e8ede5; color: #3d5a35; }
.pb-brand-both   { background: #ede9ff; color: #3d3280; }

.pb-thread-code  { font-size: 0.85rem; font-weight: 700; color: var(--color-ink); flex-shrink: 0; }
.pb-thread-name  { font-size: 0.75rem; color: var(--color-muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-thread-dist  { font-size: 0.68rem; padding: 1px 5px; border-radius: 4px; flex-shrink: 0; }
.pb-thread-note-input {
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  font-size: 0.72rem;
  color: var(--color-muted);
  padding: 2px 5px;
  width: 100%;
  font-family: 'Lato', sans-serif;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.pb-thread-note-input:hover  { border-color: #e0daf7; }
.pb-thread-note-input:focus  { border-color: #6650c4; background: #f8f5ff; }
.pb-thread-remove {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid #e0daf7;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.pb-thread-remove:hover { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

/* ── Search results ────────────────────────────────────────────────────── */
.pb-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #e0daf7;
}
.pb-search-row:last-child { border-bottom: none; }

/* ── Empty states ──────────────────────────────────────────────────────── */
.pb-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  text-align: center;
  gap: 8px;
}
.pb-empty-title { font-size: 0.95rem; font-weight: 600; color: var(--color-ink); }
.pb-empty-body  { font-size: 0.82rem; color: var(--color-muted); }
.pb-empty-threads { font-size: 0.82rem; color: var(--color-muted); font-style: italic; padding: 12px 0; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.pb-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #6650c4;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: 'Lato', sans-serif;
  white-space: nowrap;
}
.pb-btn-primary:hover { opacity: 0.88; }

.pb-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--color-surface);
  color: var(--color-ink);
  border: 1px solid #e0daf7;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: 'Lato', sans-serif;
}
.pb-btn-secondary:hover { border-color: #6650c4; background: #ede9ff; }

.pb-btn-ghost {
  background: none;
  border: none;
  color: #6650c4;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 5px;
  font-family: 'Lato', sans-serif;
}
.pb-btn-ghost:hover { background: #ede9ff; }

.pb-btn-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid #e0daf7;
  border-radius: 7px;
  color: var(--color-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: 'Lato', sans-serif;
}
.pb-btn-back:hover { border-color: #6650c4; color: #6650c4; }

.pb-btn-open {
  background: #6650c4;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Lato', sans-serif;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.pb-btn-open:hover { opacity: 0.85; }

.pb-btn-delete {
  background: none;
  border: 1px solid #e0daf7;
  border-radius: 7px;
  padding: 5px 8px;
  color: var(--color-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.pb-btn-delete:hover { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

.pb-btn-add {
  margin-left: auto;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #6650c4;
  color: #fff;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}
.pb-btn-add:hover   { opacity: 0.85; }
.pb-btn-added       { background: #d1fae5; color: #065f46; cursor: default; font-size: 0.8rem; }
.pb-btn-add:disabled { cursor: default; }

/* ── Input error state ─────────────────────────────────────────────────── */
.pb-input-error { border-color: #f87171 !important; }

/* ── Start modal ───────────────────────────────────────────────────────── */
.pb-modal-card {
  background: var(--color-surface);
  border: 1px solid #e0daf7;
  border-radius: 16px;
  padding: 32px 28px;
  width: 100%;
  max-width: 480px;
  margin: 0 16px;
  box-shadow: 0 24px 64px rgba(70,50,150,0.18);
}
.pb-modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  color: var(--color-ink);
  margin: 0 0 20px;
}
.pb-modal-input {
  width: 100%;
  border: 1px solid #e0daf7;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.9rem;
  background: var(--color-canvas);
  color: var(--color-ink);
  outline: none;
  font-family: 'Lato', sans-serif;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.pb-modal-input:focus { border-color: #6650c4; }

.pb-start-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 420px) { .pb-start-choices { grid-template-columns: 1fr; } }

/* Reduce section padding on narrow phones so content has more room */
@media (max-width: 480px) {
  #pb-mode-browse section,
  #pb-mode-images section,
  #pb-list-section > section {
    padding: 14px !important;
  }
  .pb-cover-row { flex-direction: column; align-items: stretch; }
}

.pb-start-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
  background: var(--color-canvas);
  border: 2px solid #e0daf7;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  font-family: 'Lato', sans-serif;
  color: var(--color-ink);
}
.pb-start-choice:hover { border-color: #6650c4; background: #f4f0ff; }
.pb-start-choice-featured { border-color: #6650c4; background: #ede9ff; }

.pb-start-choice-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-ink);
}
.pb-start-choice-desc {
  font-size: 0.75rem;
  color: var(--color-muted);
  line-height: 1.4;
}

.pb-modal-cancel {
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 4px;
  font-family: 'Lato', sans-serif;
}
.pb-modal-cancel:hover { color: var(--color-ink); }

/* ── Homepage palette CTA link ─────────────────────────────────────────── */
.hp-palette-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6650c4;
  text-decoration: none;
  margin-top: 8px;
  transition: opacity 0.15s;
}
.hp-palette-cta:hover { opacity: 0.75; }

/* ── Dark mode overrides ───────────────────────────────────────────────── */
.dark .pb-name-input,
.dark .pb-notes-textarea,
.dark .pb-modal-input   { border-color: var(--color-rim); background: var(--color-canvas); color: var(--color-ink); }
.dark .pb-name-input:focus,
.dark .pb-notes-textarea:focus,
.dark .pb-modal-input:focus { border-color: var(--color-brand); }

.dark .pb-drop-zone     { border-color: var(--color-rim); background: var(--color-canvas); }
.dark .pb-drop-zone:hover,
.dark .pb-drop-zone.drag-over { border-color: var(--color-brand); background: var(--color-brand-light); }

.dark .pb-moodboard-add { border-color: var(--color-rim); }
.dark .pb-moodboard-add:hover { border-color: var(--color-brand); background: var(--color-brand-light); }
.dark .pb-moodboard-cell { border-color: var(--color-rim); }

.dark .pb-palette-card  { background: var(--color-surface); border-color: var(--color-rim); }
.dark .pb-palette-card:hover { border-color: #5040a0; }
.dark .pb-palette-thumb { border-color: var(--color-rim); }
.dark .pb-palette-thumb-placeholder { border-color: var(--color-rim); background: var(--color-brand-light); color: #9880d8; }

.dark .pb-extract-chip  { background: var(--color-surface); border-color: var(--color-rim); }
.dark .pb-extract-chip.selected,
.dark .pb-extract-chip:has(input:checked) { border-color: var(--color-brand); background: var(--color-brand-light); }

.dark .pb-thread-row    { border-bottom-color: var(--color-rim); }
.dark .pb-search-row    { border-bottom-color: var(--color-rim); }
.dark .pb-thread-note-input:focus { background: var(--color-brand-light); }

.dark .pb-btn-secondary { background: var(--color-surface); border-color: var(--color-rim); color: var(--color-ink); }
.dark .pb-btn-secondary:hover { border-color: var(--color-brand); background: var(--color-brand-light); }
.dark .pb-btn-back      { border-color: var(--color-rim); }
.dark .pb-btn-back:hover { border-color: var(--color-brand); }
.dark .pb-btn-delete    { border-color: var(--color-rim); }

.dark .pb-modal-card    { background: var(--color-surface); border-color: var(--color-rim); box-shadow: 0 24px 64px rgba(0,0,0,0.45); }
.dark .pb-start-choice  { background: var(--color-canvas); border-color: var(--color-rim); }
.dark .pb-start-choice:hover { background: var(--color-brand-light); border-color: var(--color-brand); }
.dark .pb-start-choice-featured { border-color: var(--color-brand); background: var(--color-brand-light); }

.dark .pb-card-brand    { background: var(--color-brand-light); color: #9880d8; }
.dark .pb-brand-dmc     { background: var(--color-brand-light); color: #9880d8; }
.dark .pb-brand-anchor  { background: #1e2e1a; color: #7ab870; }

/* ── Palette aside (sticky right column — hidden on mobile) ─────────────── */
.pb-palette-aside { min-width: 0; }
@media (max-width: 880px) { .pb-palette-aside { display: none; } }

/* ── Moodboard done badge ───────────────────────────────────────────────── */
.pb-moodboard-done {
  position: absolute;
  bottom: 7px;
  left: 7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #059669;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  pointer-events: none;
}

/* ── Extract panel header ───────────────────────────────────────────────── */
.pb-extract-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.pb-extract-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-ink);
}
.pb-extract-hint {
  font-size: 0.75rem;
  color: var(--color-muted);
  font-weight: 400;
}

/* ── Thread overlap / in-palette badges ────────────────────────────────── */
.pb-overlap-badge {
  font-size: 0.6rem;
  padding: 2px 6px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 4px;
  font-weight: 700;
  flex-shrink: 0;
  white-space: nowrap;
}
.pb-in-palette-badge {
  font-size: 0.6rem;
  padding: 2px 6px;
  background: #d1fae5;
  color: #065f46;
  border-radius: 4px;
  font-weight: 700;
  flex-shrink: 0;
  white-space: nowrap;
}
.pb-extract-chip-overlap {
  border-color: #f59e0b !important;
  background: #fffbeb !important;
}
.dark .pb-extract-chip-overlap {
  border-color: #d97706 !important;
  background: #1c1204 !important;
}

/* ── Colour family filter bar ───────────────────────────────────────────── */
.pb-family-filter {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 6px;
  margin-bottom: 14px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  /* Explicit width constraint so overflow-x: auto has a boundary to scroll within */
  min-width: 0;
  max-width: 100%;
}
.pb-family-filter::-webkit-scrollbar { display: none; }

.pb-family-chip {
  flex-shrink: 0;
  padding: 5px 13px;
  border-radius: 20px;
  border: 1px solid #e0daf7;
  background: var(--color-surface);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}
.pb-family-chip:hover { border-color: #6650c4; color: #6650c4; background: #f4f0ff; }
.pb-family-chip-active { border-color: #6650c4; background: #ede9ff; color: #3d3280; }

/* ── Browse tabs (DMC / Anchor) ─────────────────────────────────────────── */
.pb-browse-tab-btn {
  padding: 7px 20px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: 'Lato', sans-serif;
}
.pb-browse-tab-active   { background: #6650c4; color: #fff; border: 1.5px solid #6650c4; }
.pb-browse-tab-inactive { background: var(--color-canvas); color: var(--color-muted); border: 1.5px solid #e0daf7; }
.pb-browse-tab-inactive:hover { border-color: #6650c4; color: #6650c4; }

/* ── Swatch grid container ──────────────────────────────────────────────── */
.pb-swatch-grid-container {
  max-height: 460px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: #e0daf7 transparent;
}
.pb-swatch-grid-container::-webkit-scrollbar { width: 5px; }
.pb-swatch-grid-container::-webkit-scrollbar-track { background: transparent; }
.pb-swatch-grid-container::-webkit-scrollbar-thumb { background: #e0daf7; border-radius: 3px; }

/* ── Swatch family section ──────────────────────────────────────────────── */
.pb-swatch-family-section {
  margin-bottom: 18px;
}
.pb-swatch-family-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-muted);
  margin: 0 0 8px 0;
}

/* ── Swatch row (wrapping flex of swatch tiles) ─────────────────────────── */
.pb-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* ── Individual swatch tile ─────────────────────────────────────────────── */
.pb-swatch-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 46px;
  padding: 5px 3px 4px;
  border: 1.5px solid #e0daf7;
  border-radius: 8px;
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  outline: none;
}
.pb-swatch-tile:hover {
  border-color: #6650c4;
  background: #f4f0ff;
  transform: translateY(-1px);
}
.pb-swatch-tile:focus-visible { border-color: #6650c4; box-shadow: 0 0 0 2px rgba(102,80,196,0.25); }
.pb-swatch-tile.in-palette {
  border-color: #6650c4;
  background: #ede9ff;
}
.pb-swatch-tile.in-palette .pb-swatch-circle::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(102,80,196,0.35);
}

.pb-swatch-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--sc, #ccc);
  border: 1.5px solid rgba(0,0,0,0.09);
  flex-shrink: 0;
  position: relative;
}

.pb-swatch-code {
  font-size: 0.58rem;
  color: var(--color-muted);
  text-align: center;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 40px;
}

/* ── Mobile cart FAB ────────────────────────────────────────────────────── */
.pb-cart-fab {
  position: fixed;
  bottom: 24px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #6650c4;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 7000;
  box-shadow: 0 4px 18px rgba(102,80,196,0.40);
  transition: opacity 0.15s, transform 0.15s;
}
.pb-cart-fab:hover { opacity: 0.88; transform: scale(1.05); }
@media (min-width: 768px) { .pb-cart-fab { display: none !important; } }

.pb-cart-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 10px;
  background: #c47a85;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #f8f5ff;
  box-sizing: border-box;
}

/* ── Mobile cart overlay ────────────────────────────────────────────────── */
.pb-cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,21,52,0.45);
  z-index: 7100;
}
@media (min-width: 768px) { .pb-cart-overlay { display: none !important; } }

/* ── Mobile cart drawer ─────────────────────────────────────────────────── */
.pb-cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(340px, 92vw);
  background: var(--color-canvas);
  z-index: 7200;
  display: flex;
  flex-direction: column;
  box-shadow: -6px 0 28px rgba(0,0,0,0.16);
  transform: translateX(100%);
  transition: transform 0.27s cubic-bezier(0.4, 0, 0.2, 1);
}
.pb-cart-drawer.pb-cart-open { transform: translateX(0); }
@media (min-width: 768px) { .pb-cart-drawer { display: none !important; } }

.pb-cart-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--color-rim);
  flex-shrink: 0;
}
.pb-cart-header h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-ink);
  flex: 1;
  margin: 0;
}
.pb-cart-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--color-rim);
  background: var(--color-surface);
  cursor: pointer;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.pb-cart-close:hover { border-color: #6650c4; color: #6650c4; }

.pb-cart-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 24px;
}

/* ── Dark mode — new components ─────────────────────────────────────────── */
.dark .pb-family-chip         { border-color: var(--color-rim); background: var(--color-surface); }
.dark .pb-family-chip:hover   { border-color: var(--color-brand); color: var(--color-brand); background: var(--color-brand-light); }
.dark .pb-family-chip-active  { border-color: var(--color-brand); background: var(--color-brand-light); color: #c0b0f0; }

.dark .pb-browse-tab-active   { background: var(--color-brand); color: #fff; border-color: var(--color-brand); }
.dark .pb-browse-tab-inactive { background: var(--color-canvas); border-color: var(--color-rim); color: var(--color-muted); }

.dark .pb-swatch-tile         { border-color: var(--color-rim); background: var(--color-surface); }
.dark .pb-swatch-tile:hover   { border-color: var(--color-brand); background: var(--color-brand-light); }
.dark .pb-swatch-tile.in-palette { border-color: var(--color-brand); background: var(--color-brand-light); }

.dark .pb-swatch-grid-container::-webkit-scrollbar-thumb { background: var(--color-rim); }

.dark .pb-overlap-badge    { background: #3d2800; color: #fcd34d; }
.dark .pb-in-palette-badge { background: #022c22; color: #6ee7b7; }

.dark .pb-cart-badge  { border-color: var(--color-canvas); }
.dark .pb-cart-drawer { background: var(--color-canvas); box-shadow: -6px 0 28px rgba(0,0,0,0.45); }
.dark .pb-cart-header { border-bottom-color: var(--color-rim); }
.dark .pb-cart-close  { background: var(--color-surface); border-color: var(--color-rim); }
.dark .pb-moodboard-cell { border-color: var(--color-rim); }

/* ── Palette swatch preview (square tiles above thread list) ─────────────── */
.pb-palette-swatch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.pb-palette-swatch-sq {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 1.5px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  padding: 0;
  transition: transform 0.12s, box-shadow 0.12s;
}
/* Red ✕ overlay on hover — indicates the swatch can be removed */
.pb-palette-swatch-sq::after {
  content: '✕';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  background: rgba(153, 27, 27, 0.55);
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.pb-palette-swatch-sq:hover { transform: scale(1.12); box-shadow: 0 2px 6px rgba(0,0,0,0.18); z-index: 1; }
.pb-palette-swatch-sq:hover::after { opacity: 1; }

/* ── Browse mode sort toggle ─────────────────────────────────────────────── */
.pb-sort-toggle {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid #e0daf7;
  background: var(--color-canvas);
  color: var(--color-muted);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  font-family: 'Lato', sans-serif;
  white-space: nowrap;
}
.pb-sort-toggle:hover  { border-color: #6650c4; color: #6650c4; }
.pb-sort-toggle.active { border-color: #6650c4; background: #ede9ff; color: #3d3280; }

.dark .pb-sort-toggle        { border-color: var(--color-rim); background: var(--color-canvas); color: var(--color-muted); }
.dark .pb-sort-toggle:hover  { border-color: var(--color-brand); color: var(--color-brand); }
.dark .pb-sort-toggle.active { border-color: var(--color-brand); background: var(--color-brand-light); color: #c0b0f0; }

/* ── Browse mode cover image upload ─────────────────────────────────────── */
.pb-cover-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pb-cover-upload {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 14px;
  border: 1.5px dashed #e0daf7;
  border-radius: 10px;
  cursor: pointer;
  color: var(--color-muted);
  background: var(--color-canvas);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  flex: 1;
}
.pb-cover-upload:hover { border-color: #6650c4; background: #f4f0ff; color: #6650c4; }

.pb-cover-preview {
  position: relative;
  flex-shrink: 0;
  width: 80px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid #e0daf7;
}
.pb-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pb-cover-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(26,21,52,0.65);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.pb-cover-preview:hover .pb-cover-remove { opacity: 1; }

.dark .pb-cover-upload   { border-color: var(--color-rim); background: var(--color-canvas); }
.dark .pb-cover-upload:hover { border-color: var(--color-brand); background: var(--color-brand-light); color: var(--color-brand); }
.dark .pb-cover-preview  { border-color: var(--color-rim); }


/* ═══════════════════════════════════════════════════════════════════════
   MY STASH — thread ownership tool
   Reuses .pb-swatch-tile/.pb-family-filter/.pb-browse-tab-btn from
   the Palette Builder. New rules cover: owned-tile indicator, stats bar,
   controls row, view filter, and the cross-tool ownership badge.
═══════════════════════════════════════════════════════════════════════ */

/* ── Owned swatch tile state ─────────────────────────────────────────── */
.stash-tile-owned {
  border-color: #16a34a !important;
  border-width: 2px !important;
}
/* Green ✓ badge in the top-right corner of owned tiles */
.stash-tile-owned::after {
  content: '✓';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #16a34a;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Cross-tool owned badge (appears next to thread code in lists) ─────── */
.stash-owned-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #15803d;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.4;
  flex-shrink: 0;
  vertical-align: middle;
}
.dark .stash-owned-badge {
  color: #4ade80;
  background: rgba(22, 163, 74, 0.15);
  border-color: rgba(22, 163, 74, 0.3);
}

/* ── Stats bar ──────────────────────────────────────────────────────── */
.stash-stats-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.stash-stat {
  flex: 1 1 130px;
  min-width: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-rim);
  border-radius: 12px;
  padding: 14px 16px;
}
.stash-stat-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.stash-stat-brand {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-brand);
}
.stash-stat-count {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-ink);
}
.stash-stat-pct {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-left: auto;
}
.stash-stat-track {
  height: 6px;
  background: var(--color-rim);
  border-radius: 3px;
  overflow: hidden;
}
.stash-stat-fill {
  height: 100%;
  background: #16a34a;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ── Controls row ───────────────────────────────────────────────────── */
.stash-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.stash-search-wrap {
  position: relative;
  flex: 1 1 120px;
  min-width: 0;
  max-width: 280px;
}
.stash-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted);
  pointer-events: none;
}
.stash-search-input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  border: 1.5px solid var(--color-rim);
  border-radius: 8px;
  font-size: 0.8125rem;
  background: var(--color-canvas);
  color: var(--color-ink);
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}
.stash-search-input:focus { border-color: var(--color-brand); }
.dark .stash-search-input { background: var(--color-surface); border-color: var(--color-rim); }

/* ── View filter (All / Owned / Missing) ─────────────────────────────── */
.stash-view-filter {
  display: flex;
  border: 1.5px solid var(--color-rim);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 1;
  min-width: 0;
}
@media (max-width: 480px) {
  .stash-controls { flex-wrap: wrap; }
  .stash-search-wrap { flex: 1 1 100%; max-width: 100%; order: 1; }
  .stash-view-filter { flex: 1 1 auto; order: 2; }
  .stash-action-btn  { order: 3; }
}
.stash-view-btn {
  flex: 1;           /* equal-width segments */
  text-align: center;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  background: var(--color-canvas);
  color: var(--color-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.stash-view-btn + .stash-view-btn { border-left: 1.5px solid var(--color-rim); }
.stash-view-btn:hover { background: var(--color-brand-light); color: var(--color-brand); }
.stash-view-btn-active {
  background: var(--color-brand);
  color: #fff;
}
.stash-view-btn-active:hover { background: var(--color-brand); color: #fff; }
.dark .stash-view-btn          { background: var(--color-surface); }
.dark .stash-view-btn:hover    { background: var(--color-brand-light); color: var(--color-brand); }

/* ── Drawer filter bar ───────────────────────────────────────────────── */
.stash-drawer-filter-bar {
  padding: 0 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--color-rim);
  margin-bottom: 4px;
}
/* Search fill full width inside drawer (overrides stash-search-wrap max-width) */
.stash-drawer-search-full {
  max-width: 100%;
  flex: 1 1 auto;
}

/* ── Action buttons ──────────────────────────────────────────────────── */
.stash-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-muted);
  background: var(--color-surface);
  border: 1.5px solid var(--color-rim);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.stash-action-btn:hover { color: var(--color-brand); border-color: var(--color-brand); }
.dark .stash-action-btn { background: var(--color-canvas); }

/* ── Import panel ────────────────────────────────────────────────────── */
.stash-import-panel {
  margin-top: 12px;
  padding: 14px;
  background: var(--color-brand-light);
  border: 1px solid var(--color-rim);
  border-radius: 10px;
}
.stash-import-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--color-rim);
  border-radius: 8px;
  font-size: 0.8125rem;
  background: var(--color-surface);
  color: var(--color-ink);
  resize: vertical;
  font-family: monospace;
  box-sizing: border-box;
  outline: none;
}
.stash-import-textarea:focus { border-color: var(--color-brand); }

/* ── Thread Drawer ───────────────────────────────────────────────────── */

/* Clickable header bar */
.stash-drawer-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: var(--color-ink);
  gap: 8px;
  text-align: left;
}
.stash-drawer-header:hover { background: var(--color-brand-light); border-radius: 12px; }
.stash-drawer-header:hover .stash-drawer-title { color: var(--color-brand); }

.stash-drawer-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-ink);
  transition: color 0.15s;
}

.stash-drawer-count-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-brand);
  background: var(--color-brand-light);
  border-radius: 999px;
  border: 1px solid var(--color-rim);
}

/* Swatch strip */
.stash-drawer-swatches {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  padding: 0 18px 14px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.stash-drawer-swatches::-webkit-scrollbar { height: 4px; }
.stash-drawer-swatches::-webkit-scrollbar-thumb { background: var(--color-rim); border-radius: 2px; }

.stash-drawer-swatch-sq {
  display: inline-block;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.08);
}

/* Thread list — max-height prevents page-bump when threads are added */
.stash-drawer-list {
  padding: 0 12px 16px;
  max-height: 360px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.stash-drawer-list::-webkit-scrollbar { width: 4px; }
.stash-drawer-list::-webkit-scrollbar-thumb { background: var(--color-rim); border-radius: 2px; }

.stash-drawer-empty {
  font-size: 0.8125rem;
  color: var(--color-muted);
  padding: 12px 6px;
  text-align: center;
}

.stash-drawer-brand-section {
  margin-bottom: 12px;
}
.stash-drawer-brand-section:last-child { margin-bottom: 0; }

.stash-drawer-brand-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 4px;
  margin-bottom: 2px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  font: inherit;
  text-align: left;
  color: inherit;
}
.stash-drawer-brand-header:hover { background: var(--color-brand-light); }

.stash-brand-chevron {
  margin-left: auto;
  color: var(--color-muted);
  transition: transform 0.18s;
  flex-shrink: 0;
}
.stash-drawer-brand-section.collapsed .stash-brand-chevron {
  transform: rotate(-90deg);
}
.stash-drawer-brand-section.collapsed .stash-drawer-rows {
  display: none;
}

.stash-drawer-brand-label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-brand);
}

.stash-drawer-brand-count {
  font-size: 0.7rem;
  color: var(--color-muted);
}

.stash-drawer-rows {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.stash-drawer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  transition: background 0.1s;
}
.stash-drawer-row:hover { background: var(--color-brand-light); }

.stash-drawer-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.stash-drawer-badge {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  line-height: 1.4;
}
.stash-drawer-badge-dmc    { background: #ede9ff; color: #6650c4; }
.stash-drawer-badge-anchor { background: #fef3c7; color: #92400e; }

.stash-drawer-code {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-ink);
  min-width: 3.5rem;
  flex-shrink: 0;
}

.stash-drawer-name {
  font-size: 0.75rem;
  color: var(--color-muted);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stash-drawer-remove {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  opacity: 0;
  transition: opacity 0.1s, background 0.1s, color 0.1s;
  padding: 0;
}
.stash-drawer-row:hover .stash-drawer-remove { opacity: 1; }
.stash-drawer-remove:hover { background: #fee2e2; color: #dc2626; }

/* Dark mode */
.dark .stash-drawer-header:hover { background: var(--color-brand-light); }
.dark .stash-drawer-badge-dmc    { background: #2a1e6e; color: #a78bfa; }
.dark .stash-drawer-badge-anchor { background: #3b2a00; color: #fbbf24; }
.dark .stash-drawer-row:hover    { background: var(--color-brand-light); }
.dark .stash-drawer-remove:hover { background: rgba(220,38,38,0.2); color: #f87171; }

/* ── Clear button ────────────────────────────────────────────────────── */
.stash-clear-btn {
  font-size: 0.75rem;
  color: var(--color-muted);
  background: none;
  border: 1px solid var(--color-rim);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.stash-clear-btn:hover { color: #dc2626; border-color: #fca5a5; }

/* ── Privacy notice bar ───────────────────────────────────────────────── */
.privacy-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-rim);
  box-shadow: 0 -2px 12px rgba(70, 50, 150, 0.08);
  font-size: 0.8125rem;
  color: var(--color-muted);
  font-family: inherit;
  animation: privacySlideUp 0.3s ease-out;
}
@keyframes privacySlideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.privacy-bar-icon {
  flex-shrink: 0;
  color: #6650c4;
  opacity: 0.7;
}
.privacy-bar-text {
  flex: 1;
  margin: 0;
  line-height: 1.5;
}
.privacy-bar-link {
  color: #6650c4;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
  margin-left: 6px;
}
.privacy-bar-link:hover { text-decoration: underline; }
.privacy-bar-dismiss {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  transition: background 0.15s, color 0.15s;
  padding: 0;
  font-family: inherit;
}
.privacy-bar-dismiss:hover { background: var(--color-brand-light); color: #6650c4; }

.dark .privacy-bar { box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.3); }
.dark .privacy-bar-link { color: #a78bfa; }
.dark .privacy-bar-dismiss:hover { color: #a78bfa; }

/* ── Tool-page footer (injected on non-homepage pages) ────────────────── */
.tool-footer {
  border-top: 1px solid var(--color-rim);
  padding: 18px 24px;
  margin-top: 40px;
}
.tool-footer-inner {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8125rem;
  color: var(--color-muted);
  flex-wrap: wrap;
}
.tool-footer-link {
  color: var(--color-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.tool-footer-link:hover { color: #6650c4; }
.dark .tool-footer-link:hover { color: #a78bfa; }

/* ── Privacy page — dark mode summary card ────────────────────────────── */
.dark .privacy-summary-card {
  background: var(--color-brand-light) !important;
  border-color: #4a3a8a !important;
}
.dark .privacy-summary-card p { color: #c4b8f0 !important; }
.dark .stash-clear-btn:hover { color: #f87171; border-color: #7f1d1d; }
