/*
 * Browser support note — flex gap
 * ─────────────────────────────────
 * gap on flex containers requires Safari 14.1+ (released April 2021).
 * Safari ≤14.0 is not officially supported; no margin-based fallbacks are
 * provided for the 20+ flex-gap usages throughout this file.
 * If a margin fallback is ever needed, wrap the gap declaration in:
 *   @supports (gap: 0) { .rule { gap: Xpx; } }
 * and add margin/padding equivalents to the base rule.
 */
:root {
  /* Chart symbols: the PDF's symbol font (symbol-glyphs.js registers it). */
  --font-symbol: "CrossStitchSymbols", monospace;
  --accent: #B85C38;
  --accent-hover: #944526;
  --accent-light: #F4DDCF;
  --accent-border: #E8B89A;
  --text-primary: #1B1814;
  --text-secondary: #5C5448;
  --text-tertiary: #6F6757;   /* 4.5:1 or better on every light surface (was #8A8270, 3.6 to 3.8) */
  --border: #E5DCCB;
  --border-subtle: #EFE7D6;
  --surface: #ffffff;
  --surface-secondary: #FBF8F3;
  --surface-tertiary: #EFE7D6;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);

  /* ════════════════════════════════════════════════════════════════
     Workshop visual direction tokens (UX-12).
     Source of truth: reports/showcase/_workshop.css
     Workshop is the sole theme — the Phase 0 --ws-* aliases were
     removed in Phase 8 once every consumer had migrated to the
     canonical names above (--accent / --surface / --text-primary /
     --text-secondary / --radius-sm / --shadow-sm) and the canonical
     names below.
     ════════════════════════════════════════════════════════════════ */

  /* Workshop colour — light (non-conflicting; canonical names) */
  --line:              #E5DCCB;
  --line-2:            #D8CDB6;
  --text-muted:        #8A8270;
  --text-on-accent:    #FFFFFF;     /* 4.54:1 on --accent (the cream it was, #FFF8F0, is 4.31) */
  --accent-2:          #944526;
  --accent-soft:       #F4DDCF;
  --accent-ink:        #5C2A14;
  --accent-text:       #944526;     /* the accent as TEXT on the page or a tinted chip: 5.1:1 on --accent-soft, 6.7:1 on white */
  --success-text:      #3F6A31;     /* the success green as text on --success-soft or the page: 4.8:1 or better */
  --success:           #4F7D3F;     /* sage */
  --success-soft:      #DEE7D2;
  --warning:           #C0883A;     /* amber */
  --warning-soft:      #F2E2BE;
  --danger:            #A53D3D;     /* brick */
  --danger-soft:       #F1D2D2;
  --tint-thread:       #E9DCC2;
  --tint-fabric:       #EDE3D0;
  --radius-pill:       999px;

  /* Workshop type scale */
  --font-ui:  'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --text-xs:  11px;
  --text-sm:  12px;
  --text-md:  13px;
  --text-lg:  14px;
  --text-xl:  17px;
  --text-h:   22px;
  --text-hero: 28px;

  /* Workshop spacing scale */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px;

  /* Workshop motion */
  --motion-fast: 120ms ease-out;
  --motion:      160ms ease-out;
  --motion-slow: 220ms ease-out;

  /* Workshop raised/lg shadows. */
  --shadow:    0 2px 8px rgba(60,40,20,.08);
  --shadow-lg: 0 12px 28px rgba(60,40,20,.14);

  /* Polish pass — small token additions.
     --radius-xs: matches the kbd-hint / chip rounding already in use.
     --app-header-height: single source of truth for sticky offsets.
     --z-* scale: semantic stacking context, mirrors the values that
     were previously hardcoded across components. */
  --radius-xs: 4px;
  /* Total height of .tb-topbar, including the top safe-area inset it now
     reserves. header.js overwrites this with the measured height once the
     header mounts (see the ResizeObserver there) — this value is the
     pre-JS fallback, and the two must describe the same box. */
  --app-header-height: 48px;
  /* Shared UI transition list — see the note beside the input/button rules.
     Deliberately enumerates properties instead of using `all`. */
  --transition-ui: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
  --transition-ui-fast: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease, opacity 0.12s ease, transform 0.12s ease;
  --z-base:       1;
  --z-sticky:    100;
  --z-dropdown:  400;
  --z-fab:       450;
  --z-action-bar: 500;
  --z-backdrop:  900;
  --z-modal:    1000;
  --z-toast:    1100;
  --z-coachmark: 1200;
}

[data-theme="dark"] {
  /* Workshop colour — dark (UX-12 Phase 2). Overrides every chrome token
     consumed across the app so swapping data-theme="dark" on <html>
     re-skins the entire surface without touching component CSS. */

  /* Legacy names (consumed everywhere) flipped to dark Workshop values. */
  --accent:            #E2865B;     /* terracotta — lifted for dark */
  --accent-hover:      #F0A07A;
  --accent-light:      #3A2418;     /* dark accent-soft */
  --accent-border:     #6E3A22;
  --text-primary:      #F4EFE7;     /* warm parchment */
  --text-secondary:    #B6AC9C;
  --text-tertiary:     #9D9383;     /* 4.8:1 or better on every dark surface (was #847B6C, 3.6 to 4.2) */
  --border:            #3A352E;
  --border-subtle:     #2A2724;
  --surface:           #1C1A18;     /* raised body */
  --surface-secondary: #14120F;     /* page background */
  --surface-tertiary:  #2A2724;     /* lifted cards */
  --shadow-sm:         0 1px 2px rgba(0,0,0,.32);
  --shadow-md:         0 4px 12px rgba(0,0,0,.42);

  /* Workshop canonical tokens. */
  --line:              #3A352E;
  --line-2:            #4B4339;
  --text-muted:        #847B6C;
  --text-on-accent:    #1B1410;
  --accent-2:          #F0A07A;
  --accent-soft:       #3A2418;
  --accent-ink:        #F4DDCF;
  --accent-text:       var(--accent);
  --success-text:      var(--success);
  --success:           #88B077;
  --success-soft:      #2C3A24;
  --warning:           #E6B069;
  --warning-soft:      #3A2E16;
  --danger:            #E07474;
  --danger-soft:       #3E1F1F;
  --tint-thread:       #2E281D;
  --tint-fabric:       #322B1F;

  --shadow:    0 2px 8px rgba(0,0,0,.42);
  --shadow-lg: 0 12px 28px rgba(0,0,0,.55);

  color-scheme: dark;
}
*{box-sizing:border-box;margin:0;padding:0;}
html{height:100%;}
body{font-family:'Inter',system-ui,-apple-system,sans-serif;background:var(--surface-secondary);color:var(--text-primary);height:100%;display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;overscroll-behavior:none;}
/* Touch surface hardening: prevent the page from rubber-banding /
   pull-to-refreshing while a finger is on the canvas, and silence the
   blue tap-highlight that flashes on every button on iOS.
   NOTE (Safari): overscroll-behavior is not supported on Safari <16 — the
   body will still rubber-band vertically on older iOS. There is no pure-CSS
   equivalent; pages that need hard scroll-lock (e.g. the tracker canvas) add
   touch-action:none at the element level instead. */
@supports (padding: max(0px)) {
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}
#root{flex:1;display:flex;flex-direction:column;min-height:0;}
/* --transition-ui (declared on :root) is an explicit property list replacing
   `transition: all`. `all` makes the engine evaluate every animatable
   property — including layout-affecting ones like width/height/padding — on
   every style recalculation, for every control on the page. The list is a
   superset of what these controls actually animate, so nothing looks
   different. */
input[type=range]{accent-color:var(--accent); transition: var(--transition-ui);}
input[type=checkbox]{accent-color:var(--accent); transition: var(--transition-ui);}
input, select { transition: var(--transition-ui); }
button{font-family:inherit; transition: var(--transition-ui);}
/* Touch browsers latch :hover on after a tap and keep it until the user taps
   elsewhere, so without this guard every button a user pressed stayed visibly
   dimmed. :active is left unguarded — it behaves correctly on touch and is
   the press feedback. */
@media (hover: hover) and (pointer: fine) {
  button:hover { filter: brightness(0.97); }
  .tb-page-btn:hover{filter:none;background:var(--surface-tertiary);}
  .home-btn--primary:hover { background: var(--accent-hover); }
  .home-btn--secondary:hover { background: var(--surface-secondary); }
}
button:active { filter: brightness(0.94); }
select{font-family:inherit}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }   /* the accent, not the pale --accent-border: a focus ring needs 3:1 against the page */
*:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}
*:focus:not(:focus-visible){outline:none;}
::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}

.card {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Background-pick mode: pulses the source-image card so the user knows
   where to click. Paired with an in-card banner explaining the action. */
.card--pickBg {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.18), var(--shadow-sm);
  animation: card-pickbg-pulse 1.6s ease-in-out infinite;
}
@keyframes card-pickbg-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.18), var(--shadow-sm); }
  50%      { box-shadow: 0 0 0 6px rgba(251, 146, 60, 0.28), var(--shadow-sm); }
}
@media (prefers-reduced-motion: reduce) {
  .card--pickBg { animation: none; }
}

.upload-area {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.upload-area svg {
  color: var(--text-tertiary);
  transition: all 0.2s ease;
}
@media (hover: hover){
.upload-area:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(184, 92, 56, 0.08);
}
}
@media (hover: hover){
.upload-area:hover svg {
  color: var(--accent);
  transform: none;
}
}

.tab-button {
  padding: 8px 16px;
  font-size: 13px;
  background: transparent;
  border: none;
  cursor: pointer;
  margin-bottom: -2px;
  transition: all 0.2s ease;
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  padding: 4px 0;
}
@media (hover: hover){
.nav-link:hover {
  color: var(--accent);
  text-decoration: underline;
}
}

.tracker-photo-viewer { background: color-mix(in srgb, var(--text-primary) 86%, transparent); }
.tracker-photo-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  padding: 24px;
  width: 90%;
  max-width: min(90vw, 400px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
/* Phase 5 — bottom-sheet modal variant. Defaults to a normal centred
   modal on desktop (so the styles are no-ops) and re-anchors to the
   bottom of the viewport on mobile, with a small drag-handle bar.
   Used by SessionConfigModal so "Start session" is reachable
   one-handed on phones. */
.sheet-handle{
  width:36px;height:4px;border-radius:2px;background:var(--border);
  margin:-8px auto 12px;
}
@media(max-width:899px){
  .modal-overlay--sheet{align-items:flex-end;}
  .modal-content--sheet{
    width:100%;max-width:100%;
    border-bottom-left-radius:0;border-bottom-right-radius:0;
    border-bottom:none;
    padding:16px 18px calc(20px + env(safe-area-inset-bottom,0px));
    animation:sheet-slide-up 0.22s ease-out;
  }
  @keyframes sheet-slide-up{from{transform:translateY(100%);}to{transform:translateY(0);}}
}
/* .modal-box, .modal-header, .modal-title — used by ConvertPaletteModal and other
   class-based modals. Without these the modal renders transparent and unstyled. */
.modal-box {
  background: var(--surface, #fff);
  border-radius: var(--radius-xl, 12px);
  border: 1px solid var(--border, #E5DCCB);
  box-shadow: var(--shadow-md, 0 20px 60px rgba(0,0,0,0.3));
  overflow: hidden;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border, #E5DCCB);
  background: var(--surface, #fff);
}
.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}
.modal-close {
  float: right;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-tertiary);
}

/* ════════════════════════════════════════════════════════════════
   Overlay primitive (UX-12 Phase 3) — components/Overlay.js.
   Three variants: dialog (centred), sheet (bottom on phone),
   drawer (edge-anchored). Built on top of the same scrim that
   .modal-overlay used so the visual tone matches existing modals
   while migrations are in flight.
   ════════════════════════════════════════════════════════════════ */
.overlay-scrim {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: overlay-scrim-fade var(--motion, 160ms) ease-out;
}
.overlay-scrim--sheet { align-items: flex-end; padding: 0; }
.overlay-scrim--drawer { padding: 0; }
.overlay-scrim--drawer.overlay-scrim--left  { justify-content: flex-start; }
.overlay-scrim--drawer.overlay-scrim--right { justify-content: flex-end; }

.overlay-panel {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg, 0 20px 60px rgba(0,0,0,0.3));
  max-height: calc(100dvh - 32px);
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  outline: none;
  animation: overlay-panel-pop var(--motion, 160ms) ease-out;
}
.overlay-panel--dialog { max-width: min(90vw, 560px); }

.overlay-panel--sheet {
  max-width: 100%;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  animation: overlay-sheet-slide-up var(--motion-slow, 220ms) ease-out;
}

.overlay-panel--drawer {
  max-height: 100dvh;
  height: 100dvh;
  max-width: min(420px, 92vw);
  border-radius: 0;
  border-top: none;
  border-bottom: none;
}
.overlay-panel--drawer.overlay-panel--left  { border-left: none;  animation: overlay-drawer-in-left  var(--motion-slow, 220ms) ease-out; }
.overlay-panel--drawer.overlay-panel--right { border-right: none; animation: overlay-drawer-in-right var(--motion-slow, 220ms) ease-out; }

.overlay-title {
  margin: 0;
  padding: 16px 20px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.overlay-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1 1 auto;
  color: var(--text-primary);
}
.overlay-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  flex: 0 0 auto;
  background: var(--surface);
}
.overlay-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md, 8px);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--motion-fast, 120ms) ease-out;
}
@media (hover: hover){.overlay-close:hover { background: var(--surface-tertiary); color: var(--text-primary); }}
.overlay-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@keyframes overlay-scrim-fade {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes overlay-panel-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes overlay-sheet-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes overlay-drawer-in-right {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes overlay-drawer-in-left {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .overlay-scrim, .overlay-panel,
  .overlay-panel--sheet, .overlay-panel--drawer {
    animation: none;
  }
}

@media (max-width: 599px) {
  /* Dialog variant adopts a small bottom-attached look on narrow phones
     so it feels native and reaches the safe-area without the user
     needing to opt into variant="sheet". */
  .overlay-scrim--dialog { align-items: flex-end; padding: 0; }
  .overlay-panel--dialog {
    max-width: 100%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* Half stitch animations */
@keyframes hs-scale-in {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.hs-scale-in {
  animation: hs-scale-in 150ms ease-out both;
}

/* ═══ UNIFIED TWO-ROW TOOLBAR ═══ */
/* Top bar */
/* Every page ships viewport-fit=cover, so on a notched device the area
   behind the status bar is ours to paint — and was, with the logo and nav
   row sitting under the notch. Reserve the inset as padding and grow the
   box by the same amount, so the 48px of usable chrome is preserved and
   --app-header-height (below) stays the true total height. */
.tb-topbar{background:var(--surface);border-bottom:1px solid var(--border);position:sticky;top:0;z-index:100;height:48px;}
@supports (padding: max(0px)){
  .tb-topbar{
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(48px + env(safe-area-inset-top, 0px));
  }
}
.tb-topbar-inner{max-width:1300px;margin:0 auto;padding:0 16px;height:100%;display:flex;align-items:center;gap:4px;}
.tb-logo{font-weight:800;font-size:15px;color:var(--text-primary);cursor:pointer;white-space:nowrap;margin-right:12px;letter-spacing:-0.3px;text-decoration:none;flex-shrink:0;font-family:inherit;display:inline-flex;align-items:center;gap:0;}
@media (hover: hover){.tb-logo:hover{filter:none;color:var(--text-primary);}}
.tb-logo .tb-logo-dot{color:var(--accent);transition:color var(--motion-fast);}
@media (hover: hover){.tb-logo:hover .tb-logo-dot{color:var(--accent-hover);}}
.tb-page-btn{display:flex;align-items:center;gap:4px;padding:4px 10px;font-size:12px;font-weight:500;border:0.5px solid var(--border);border-radius:var(--radius-md);background:var(--surface);color:var(--text-primary);cursor:pointer;white-space:nowrap;flex-shrink:0;position:relative;font-family:inherit;}
.tb-page-dropdown{position:absolute;top:calc(100% + 4px);left:0;min-width:160px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-md);z-index:201;padding:4px 0;}
.tb-page-dropdown-item{display:block;width:100%;padding:7px 14px;font-size:12px;font-weight:400;text-align:left;background:transparent;border:none;cursor:pointer;color:var(--text-primary);font-family:inherit;}
@media (hover: hover){.tb-page-dropdown-item:hover{filter:none;background:var(--surface-tertiary);}}
.tb-page-dropdown-item--on{font-weight:600;color:var(--accent);}
.tb-hgap{flex:1;}
.tb-sep{width:1px;height:18px;background:var(--border);margin:0 8px;flex-shrink:0;}
.tb-nav-link{font-size:12px;font-weight:500;color:var(--text-secondary);cursor:pointer;background:none;border:none;padding:4px 6px;white-space:nowrap;text-decoration:none;flex-shrink:0;font-family:inherit;}
@media (hover: hover){.tb-nav-link:hover{filter:none;color:var(--accent);}}
.tb-action-btn{padding:4px 12px;font-size:12px;font-weight:500;border-radius:var(--radius-md);border:0.5px solid var(--border);background:var(--surface);color:var(--text-secondary);cursor:pointer;white-space:nowrap;flex-shrink:0;font-family:inherit;}
.tb-action-btn+.tb-action-btn{margin-left:4px;}
@media (hover: hover){.tb-action-btn:hover{filter:none;background:var(--surface-tertiary);}}
.tb-action-btn--green{background:var(--accent);color:var(--surface);border-color:var(--accent);}
@media (hover: hover){.tb-action-btn--green:hover{background:var(--accent-hover);filter:none;}}
.tb-action-btn--orange{background:var(--accent);color:var(--surface);border-color:var(--accent);}
@media (hover: hover){.tb-action-btn--orange:hover{background:var(--accent-hover);filter:none;}}
/* Tool strip */
.tb-strip{background:var(--surface-tertiary);border-bottom:1px solid var(--border);position:sticky;top:var(--app-header-height, 48px);z-index:99;height:38px;overflow:visible;}
.tb-strip--sel{background:var(--surface-tertiary);border-bottom:1px solid var(--border);height:auto;overflow:visible;}
.tb-strip-inner{max-width:1300px;margin:0 auto;padding:0 16px;height:100%;display:flex;align-items:center;gap:3px;overflow:visible;}
.tb-sdiv{width:1px;height:20px;background:var(--border);flex-shrink:0;margin:0 2px;}
.tb-grp{display:flex;gap:1px;background:var(--surface);border:0.5px solid var(--border);border-radius:7px;padding:2px;flex-shrink:0;}
/* ── Proposal-B: Pill toolbar ── */
.toolbar-row{display:flex;flex-direction:column;position:sticky;top:var(--app-header-height, 48px);z-index:99;background:var(--surface-secondary);border-bottom:1px solid var(--border);flex-shrink:0;}
.pill-row{height:52px;display:flex;align-items:center;justify-content:center;}
.swatch-strip-row{height:52px;display:flex;align-items:center;justify-content:center;gap:3px;border-top:1px solid var(--border);background:var(--surface);padding:0 12px;overflow:visible;}
.pill{display:inline-flex;align-items:center;gap:2px;background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:4px;box-shadow:var(--shadow-md);max-width:calc(100vw - 40px);overflow:visible;}
.pill .tb-grp{background:transparent;border:none;padding:0;gap:1px;}
.pill .tb-sdiv{width:1px;height:22px;background:var(--border);flex-shrink:0;margin:0 3px;}
.pill .tb-btn{height:36px;border-radius:9px;font-size:12px;font-weight:500;}
@media (hover: hover){.pill .tb-btn:hover{filter:none;background:var(--surface-tertiary);color:var(--text-primary);}}
.pill .tb-btn.tb-btn--green{background:var(--accent);color:var(--surface);font-weight:600;box-shadow:0 2px 6px rgba(184, 92, 56,0.3);}
.pill .tb-btn.tb-btn--on{background:var(--surface-tertiary);color:var(--text-primary);font-weight:600;box-shadow:none;}
.pill .tb-btn.tb-btn--blue{background:var(--accent-light);color:var(--accent);font-weight:600;}
.pill .tb-btn.tb-btn--red{background:var(--danger-soft);color:var(--danger);font-weight:600;}
.pill .tb-flex{display:none;}
.swatch-scroll-inner{display:flex;gap:3px;overflow-x:auto;flex:1;min-width:0;scrollbar-width:thin;scrollbar-color:var(--border) transparent;}
.tb-swatch-scroll-btn{flex-shrink:0;width:24px;height:36px;display:flex;align-items:center;justify-content:center;border:0.5px solid var(--border);border-radius:var(--radius-sm);background:var(--surface);color:var(--text-secondary);cursor:pointer;line-height:1;font-family:inherit;padding:0;}
@media (hover: hover){.tb-swatch-scroll-btn:hover{background:var(--surface-tertiary);}}
.tb-more-panel{position:absolute;top:calc(100% + 4px);right:0;min-width:240px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-md);z-index:300;padding:8px 0;}
.tb-more-panel__section{padding:6px 12px 8px;}
.tb-more-panel__section+.tb-more-panel__section{border-top:1px solid var(--border);}
.tb-more-panel__section--cleanup{padding:4px 12px 8px;}
/* ── Canvas + right-panel layout ── */
.cs-main{display:flex;align-items:flex-start;flex:1;min-height:0;overflow:hidden;}
.canvas-area{flex:1;min-width:0;min-height:0;overflow:auto;}

/* Tracker chart viewport height.
   This was an inline max-height of 600px on the scroller, so no media query
   could reach it: a tablet with 1300 CSS px of height, or a desktop, showed
   the chart through exactly the same letterbox as a 727px phone.

   Phones keep 600px, which is already most of their screen. Taller screens get
   a viewport-relative height instead, and the max(600px, ...) floor means this
   rule can only ever *add* chart — never take any away from a layout that
   works today. The 300px subtraction covers the topbar, info strip and mode
   row above the chart; the 1000px ceiling stops a very tall window turning the
   chart into a canvas taller than the tile logic ever needs.
   The .is-drawer pair is specificity (0,2,0), so it wins over both base rules
   without needing !important. */
.tracker-chart-scroll{ max-height:600px; }
.tracker-chart-scroll.is-drawer{ max-height:340px; }
@media (min-height: 800px){
  .tracker-chart-scroll{ max-height:max(600px, min(100dvh - 300px, 1000px)); }
  .tracker-chart-scroll.is-drawer{ max-height:340px; }
}
.materials-cols{display:grid;grid-template-columns:minmax(0,3fr) minmax(0,2fr);gap:16px;align-items:start;}
@media(max-width:599px){.materials-cols{grid-template-columns:1fr;}}
.rpanel{width:280px;background:var(--surface);border-left:1px solid var(--border);flex-shrink:0;position:sticky;top:128px;max-height:calc(100vh - 128px);overflow-y:auto;align-self:flex-start;transition:width 0.18s ease;}
.rpanel--collapsed{width:44px;}
.rpanel-drawer-header{display:none;}
.rpanel--collapsed .rp-tabs{padding:4px!important;}
.rpanel--collapsed .rp-tabs > span{display:none;}
.rpanel-collapse-btn{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border:1px solid var(--border);border-radius:6px;background:var(--surface);color:var(--text-secondary);cursor:pointer;flex-shrink:0;padding:0;}
@media (hover: hover){.rpanel-collapse-btn:hover{background:var(--surface-tertiary);color:var(--accent);}}
.rpanel-collapse-btn svg{width:16px;height:16px;}
@media(prefers-reduced-motion:reduce){.rpanel{transition:none;}}
.rp-tabs{display:flex;border-bottom:1px solid var(--border);position:sticky;top:0;background:var(--surface);z-index:10;}
.rp-tab{flex:1;padding:8px 0;font-size:11px;font-weight:600;border:none;background:none;cursor:pointer;color:var(--text-tertiary);border-bottom:2px solid transparent;font-family:inherit;}
.rp-tab--on{color:var(--accent);border-bottom-color:var(--accent);}
.rp-tab-content{flex:1;overflow-y:auto;}
.fab-undo{display:none;}

/* ── Tracker left sidebar (toolbar-rework phase 1) ──
   Persistent panel on >=900px, drawer overlay on <900px (phase 5).
   Mirrors .rpanel structure. */
.tracker-hamburger{
  display:inline-flex;align-items:center;justify-content:center;
  width:36px;height:32px;margin-right:8px;
  border:1px solid var(--border);border-radius:8px;background:var(--surface);
  color:var(--text-secondary);cursor:pointer;font-size:18px;
  transition:background 0.15s ease,color 0.15s ease;
  flex-shrink:0;
}
@media (hover: hover){.tracker-hamburger:hover{background:var(--surface-tertiary);color:var(--accent);}}
.tracker-hamburger[aria-expanded="true"]{background:var(--accent-light);color:var(--accent);border-color:var(--accent-border);}

.lpanel{
  /* Bottom-sheet across all viewports — opens above the canvas instead of
     stealing horizontal screen real estate from the left. */
  position:fixed;left:0;right:0;bottom:0;top:auto;
  width:100%;max-width:100%;max-height:70dvh;
  background:var(--surface);border-top:1px solid var(--border);border-right:none;
  border-radius:16px 16px 0 0;
  z-index:1000;
  box-shadow:0 -4px 16px rgba(0,0,0,0.12);
  overflow-y:auto;
  display:flex;flex-direction:column;
  animation:lpanel-slide-up 0.22s ease-out;
}
@keyframes lpanel-slide-up{from{transform:translateY(100%);}to{transform:translateY(0);}}
@media(prefers-reduced-motion:reduce){.lpanel{animation:none;}}
.lp-tabs{
  display:flex;border-bottom:1px solid var(--border);
  position:sticky;top:0;background:var(--surface);z-index:10;
}
.lp-tab{
  flex:1;padding:10px 0;font-size:12px;font-weight:600;
  border:none;background:none;cursor:pointer;color:var(--text-tertiary);
  border-bottom:2px solid transparent;font-family:inherit;
}
.lp-tab--on{color:var(--accent);border-bottom-color:var(--accent);}
.lp-close{
  width:36px;border:none;background:none;cursor:pointer;
  color:var(--text-tertiary);font-size:18px;line-height:1;
  display:inline-flex;align-items:center;justify-content:center;
}
@media (hover: hover){.lp-close:hover{color:var(--accent);}}
/* Pad the bottom of the lpanel scroll area so content isn't hidden behind
   the iOS home indicator in bottom-sheet mode. env() is 0 on desktop. */
.lp-tab-content{flex:1;overflow-y:auto;padding-bottom:env(safe-area-inset-bottom,0px);}
.lp-section{padding:12px 14px;border-bottom:1px solid var(--border-subtle);}
.lp-heading{
  font-size:11px;font-weight:700;letter-spacing:0.05em;
  text-transform:uppercase;color:var(--text-tertiary);margin-bottom:6px;
}
.lp-btn{
  padding:4px 10px;border:1px solid var(--border);border-radius:6px;
  background:var(--surface);color:var(--text-secondary);cursor:pointer;
  font-size:12px;font-weight:600;font-family:inherit;
  display:inline-flex;align-items:center;justify-content:center;gap:4px;
  min-height:28px;
}
@media (hover: hover){.lp-btn:hover{background:var(--surface-tertiary);color:var(--accent);}}
.lp-btn--ghost{background:transparent;}
.lp-btn--primary{background:var(--accent);color:var(--surface);border-color:var(--accent);}
@media (hover: hover){.lp-btn--primary:hover{background:var(--accent-hover);color:var(--surface);}}
.lp-btn--danger{background:var(--danger);color:var(--surface);border-color:var(--danger);}
@media (hover: hover){.lp-btn--danger:hover{background:var(--danger);color:var(--surface);}}
.lp-segmented{
  display:inline-flex;border:1px solid var(--border);border-radius:6px;
  overflow:hidden;background:var(--surface-secondary);
}
.lp-seg{
  flex:1;padding:4px 8px;border:none;background:none;cursor:pointer;
  font-size:11px;font-weight:600;color:var(--text-secondary);
  font-family:inherit;border-right:1px solid var(--border);min-height:28px;
}
.lp-seg:last-child{border-right:none;}
.lp-seg--on{background:var(--accent);color:var(--surface);}
@media (hover: hover){.lp-seg:hover:not(.lp-seg--on){background:var(--surface-tertiary);}}

@media(max-width:899px){
  /* Mobile bottom-sheet inherits the base styles; backdrop handled below. */
}
/* Phase 5 — desktop hides the mobile-only Legend tab + section. */
.lp-tab--mobile-only,.lp-section--mobile-only{display:none;}
/* Backdrop scrim behind the bottom-sheet lpanel — applies at all viewports
   now that the lpanel opens as an overlay everywhere. Tap to close. */
.lpanel-backdrop{
  position:fixed;inset:0;z-index:999;background:rgba(15,23,42,0.45);
  backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);
  animation:lpanel-fade-in 0.18s ease-out;
}
@keyframes lpanel-fade-in{from{opacity:0;}to{opacity:1;}}
@media(prefers-reduced-motion:reduce){.lpanel-backdrop{animation:none;}}
/* I3 (audit) — at desktop the lpanel docks as a left side-pane (320px wide,
   full height) so users can keep settings open beside the canvas. When the
   palette is open (.cs-main--palette-open) the canvas wrapper is shifted right
   to clear it so the row/column ruler is never hidden behind the panel. The
   backdrop scrim is suppressed on desktop so the chart stays clickable.

   1024px is the docked/overlay boundary for the whole lpanel system — the
   ESC handler, the orientation-change effect and the wide/narrow mode
   persistence keys in tracker-app.js all key off (max-width: 1023px). Change
   them together or not at all. */
@media(min-width:1024px){
  .cs-main{transition:margin-left var(--motion,0.18s ease);}
  /* The docked panel is 320px wide, so the canvas clears exactly that much.
     Nothing else writes margin-left on .cs-main at this breakpoint any more —
     the project rail that used to reserve 220px (56px collapsed) was removed,
     and its collapsed-state rule outranked this one, which is what let the
     panel overlap the chart. Keep it that way: any new .cs-main margin rule
     needs to lose to this one while the panel is open. */
  .cs-main.cs-main--palette-open{margin-left:320px;}
  .lpanel{
    /* Below the app header, so the logo and the Create, Edit and Track tabs stay reachable (TRACK-06). */
    left:0;right:auto;top:var(--app-header-height, 48px);bottom:0;
    width:320px;max-width:320px;max-height:calc(100vh - var(--app-header-height, 48px));
    border-radius:0;border-right:1px solid var(--border);border-top:none;
    box-shadow:2px 0 12px rgba(0,0,0,0.08);
    animation:lpanel-slide-right 0.22s ease-out;
    /* Push panel content past the iOS landscape notch on the left. */
    padding-left:env(safe-area-inset-left,0px);
  }
  @keyframes lpanel-slide-right{from{transform:translateX(-100%);}to{transform:translateX(0);}}
  .lpanel-backdrop{display:none;}
}
@media(max-width:899px){
  /* Phase 5 — show the Legend tab + section only on mobile. */
  .lp-tab--mobile-only{display:inline-flex;}
  .lp-section--mobile-only{display:flex;}
  /* The Tracker's palette legend lives in the lpanel on mobile. Only the
     Creator renders .rpanel, and it needs it as a bottom drawer (see the
     max-width:899px drawer block further down) — never hide it here. */
  /* Phase 5 — touch-friendly hit targets inside the lpanel. */
  .lp-btn,.lp-tab,.lp-seg{min-height:44px;}
}
@media(pointer:coarse){.fab-undo{display:flex;position:fixed;bottom:60px;left:16px;width:48px;height:48px;border-radius:50%;border:none;background:var(--accent);color:var(--surface);font-size:20px;align-items:center;justify-content:center;box-shadow:0 2px 8px rgba(0,0,0,0.2);z-index:400;cursor:pointer;touch-action:manipulation;}}
.tb-btn{display:inline-flex;align-items:center;gap:3px;padding:3px 8px;font-size:11px;font-weight:400;border:none;border-radius:5px;background:transparent;color:var(--text-secondary);cursor:pointer;white-space:nowrap;line-height:1.4;font-family:inherit;}
@media (hover: hover){.tb-btn:hover{filter:none;background:var(--surface-tertiary);color:var(--text-primary);}}
.tb-btn--on{background:var(--surface);color:var(--text-primary);font-weight:600;box-shadow:var(--shadow-sm);}
.tb-btn--mod-active{outline:2px solid var(--warning);outline-offset:-1px;}
.tb-btn--green{background:var(--accent);color:var(--surface);font-weight:600;}
.tb-btn--blue{background:var(--accent-light);color:var(--accent);font-weight:600;}
.tb-btn--red{background:var(--danger-soft);color:var(--danger);font-weight:600;}
.tb-flex{flex:1;}
.tb-zoom-grp{display:flex;align-items:center;gap:4px;flex-shrink:0;}
@media(pointer:coarse){.tb-desktop-only{display:none!important;}}
.tb-zoom-lbl{font-size:11px;color:var(--text-tertiary);}
.tb-zoom-pct{font-size:11px;min-width:28px;color:var(--text-secondary);}
.tb-fit-btn{padding:2px 7px;font-size:11px;border:0.5px solid var(--border);border-radius:5px;background:var(--surface);cursor:pointer;color:var(--text-secondary);font-family:inherit;}
@media (hover: hover){.tb-fit-btn:hover{filter:none;background:var(--surface-tertiary);}}
.tb-overflow-wrap{position:relative;flex-shrink:0;}
.tb-drop-wrap{position:relative;flex-shrink:0;}
.tb-drop-btn{display:inline-flex;align-items:center;gap:3px;}
.tb-drop-arrow{font-size:8px;opacity:0.6;margin-left:1px;}
.tb-dropdown{display:none;position:absolute;top:calc(100% + 6px);left:0;min-width:150px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-md);z-index:500;padding:4px 0;}
.tb-dropdown::before{content:'';position:absolute;top:-8px;left:0;right:0;height:8px;}
.tb-drop-wrap:hover .tb-dropdown,.tb-drop-wrap:focus-within .tb-dropdown,.tb-drop-wrap--open .tb-dropdown{display:block;}
@media (pointer:coarse){.tb-drop-wrap:hover .tb-dropdown{display:none;}.tb-drop-wrap--open .tb-dropdown,.tb-drop-wrap:focus-within .tb-dropdown{display:block;}}
.tb-drop-item{display:flex;align-items:center;gap:6px;padding:6px 12px;font-size:12px;color:var(--text-primary);cursor:pointer;border:none;background:transparent;width:100%;text-align:left;font-family:inherit;}
@media (hover: hover){.tb-drop-item:hover{background:var(--surface-tertiary);}}
.tb-drop-item--on{font-weight:600;color:var(--accent);background:var(--surface-tertiary);}
.tb-overflow-btn{width:28px;height:26px;display:flex;align-items:center;justify-content:center;border:0.5px solid var(--border);border-radius:var(--radius-md);background:var(--surface);color:var(--text-secondary);cursor:pointer;font-size:14px;font-weight:700;letter-spacing:1px;line-height:1;font-family:inherit;}
@media (hover: hover){.tb-overflow-btn:hover{filter:none;background:var(--surface-tertiary);}}
.tb-overflow-menu{position:absolute;top:calc(100% + 4px);right:0;min-width:210px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-md);z-index:200;padding:6px 0;}
.tb-ovf-lbl{padding:4px 14px 2px;font-size:10px;font-weight:600;color:var(--text-tertiary);text-transform:uppercase;letter-spacing:0.05em;display:block;}
.tb-ovf-item{display:flex;align-items:center;gap:8px;padding:6px 14px;font-size:12px;color:var(--text-primary);cursor:pointer;border:none;background:transparent;width:100%;text-align:left;font-family:inherit;}
@media (hover: hover){.tb-ovf-item:hover{filter:none;background:var(--surface-tertiary);}}
.tb-ovf-item--on{font-weight:600;color:var(--accent);}
.tb-ovf-sep{height:1px;background:var(--border);margin:4px 0;}
/* Progress bar (track mode) */
.tb-progress{background:var(--surface);border-bottom:0.5px solid var(--border);padding:4px 20px;}
.tb-progress-inner{max-width:1300px;margin:0 auto;display:flex;align-items:center;gap:10px;}
.tb-progress-txt{font-size:11px;font-weight:600;color:var(--text-primary);white-space:nowrap;flex-shrink:0;}
.tb-progress-bar{flex:1;height:4px;background:var(--border);border-radius:2px;overflow:hidden;display:flex;}
.tb-progress-fill{height:100%;background:var(--accent);border-radius:2px;transition:width 0.3s ease;}
.tb-progress-fill--done{background:var(--success);}
.tb-progress-rem{font-size:11px;color:var(--text-secondary);white-space:nowrap;flex-shrink:0;}
/* Status bar (below canvas) */
.tb-status{padding:4px 16px;font-size:11px;color:var(--text-secondary);background:var(--surface-secondary);border-top:0.5px solid var(--border);}
/* Collapse hidden groups */
.tb-hidden{display:none!important;}
.creator-palette-chip{touch-action:manipulation;-webkit-tap-highlight-color:transparent;}
.creator-palette-chip-remove{display:inline-flex;align-items:center;justify-content:center;}

/* ═══ STAGE 3: UNIFIED NAVIGATION ═══ */
/* App-section tabs (Create / Track / Stash) — Figma-style underline indicator */
/* The tab row is as tall as the bar so the active underline sits on the bar's edge at any size.
   The rules are written .tb-app-nav .tb-app-tab (two classes) on purpose: the tabs are <a>, and the
   dark theme's `html.pref-dark a { color: var(--accent) }` out-ranked a single class and painted every
   tab in the accent colour, so the active one could not be told apart. Inactive tabs are
   --text-secondary and the active one is accent text with the underline, in both themes. */
.tb-app-nav{display:flex;align-items:stretch;align-self:stretch;gap:2px;margin-left:4px;flex-shrink:0;}
.tb-app-nav .tb-app-tab{display:inline-flex;align-items:center;font-size:13px;font-weight:500;color:var(--text-secondary);text-decoration:none;padding:0 14px;border-radius:var(--radius-md);border:none;background:transparent;cursor:pointer;white-space:nowrap;font-family:inherit;transition:all 0.12s;position:relative;}
@media (hover: hover){.tb-app-nav .tb-app-tab:hover{background:var(--surface-tertiary);color:var(--text-primary);filter:none;}}
.tb-app-nav .tb-app-tab:focus-visible{outline:2px solid var(--accent);outline-offset:-2px;}
.tb-app-nav .tb-app-tab--active{background:transparent;color:var(--accent-text);font-weight:600;}
.tb-app-nav .tb-app-tab--active::after{content:'';position:absolute;bottom:0;left:12px;right:12px;height:2px;background:var(--accent);border-radius:2px;}
/* Portrait tablets (iPad Mini is 768px): the top bar measures ~856px, and
   left alone it widened the layout viewport past the screen, so the
   Creator's fixed bottom drawer sat below the visible area. Use the same
   scroll-the-row approach as phones (see the max-width:599px block below);
   dropdowns go position:fixed so the clip on .tb-topbar doesn't cut them. */
@media (min-width: 600px) and (max-width: 899px) {
  .tb-topbar{overflow:hidden;}
  .tb-topbar-inner{overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain;}
  .tb-topbar-inner::-webkit-scrollbar{display:none;}
  .tb-topbar-inner > *{flex-shrink:0;}
  /* The row has to fit 768px with the File menu on screen: tighter tabs, an icon-only Help, and the
     logo's gap closed up. (It scrolls as a last resort, but it should never need to.) */
  .tb-topbar-inner{padding:0 12px;}
  .tb-logo{margin-right:4px;}
  .tb-app-nav .tb-app-tab{padding:0 10px;}
  .tb-help-btn-label{display:none;}
  .tb-topbar .tb-proj-switcher__menu{position:fixed;left:8px;right:8px;top:calc(var(--app-header-height, 48px) + 6px);max-width:none;width:auto;}
  .tb-page-dropdown{position:fixed;top:calc(var(--app-header-height, 48px) + 6px);}
  .tb-topbar .sync-popover{position:fixed;top:calc(var(--app-header-height, 48px) + 8px);right:8px;}
}
/* Responsive: compact nav tabs on narrow screens */
@media (max-width: 599px) {
  .tb-app-nav{gap:0;margin-left:2px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;}
  .tb-app-nav::-webkit-scrollbar{display:none;}
  .tb-app-nav .tb-app-tab{font-size:11px;padding:0 8px;}
  .tb-app-nav .tb-app-tab--active::after{left:6px;right:6px;}
  /* The row's contents intrinsically measure ~640px at 393px wide. It used to
     be clipped by .tb-topbar{overflow:hidden} below, which silently put the
     tail of the row — the File menu, and part of Help — permanently
     off-screen with no way to reach them. Scroll the row instead of hiding
     it. The clip on the parent stays, so this never reaches the document and
     cannot re-expand the layout viewport. */
  .tb-topbar-inner{padding:0 8px;gap:2px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain;}
  .tb-topbar-inner::-webkit-scrollbar{display:none;}
  .tb-topbar-inner > *{flex-shrink:0;}
  .tb-logo{font-size:13px;}
  .tb-hgap{display:none;}
  /* Badge is completely off-screen at mobile — hide it to prevent horizontal overflow */
  .tb-proj-badge{display:none;}
  .tb-page-btn{font-size:11px;padding:4px 8px;}
  .tb-sep{margin:0 2px;}
  /* Clip the topbar's overflow so the header doesn't cause page-level horizontal scroll.
     Dropdowns that need to escape the clip use position:fixed below. */
  .tb-topbar{overflow:hidden;}
  .tb-proj-switcher__menu{position:fixed;left:8px;right:8px;top:calc(var(--app-header-height, 48px) + 6px);max-width:none;width:auto;}
  .tb-page-dropdown{position:fixed;top:calc(var(--app-header-height, 48px) + 6px);}
  /* Allow pill to scroll horizontally as fallback rather than clip */
  .pill{overflow-x:auto;scrollbar-width:none;}
  .pill::-webkit-scrollbar{display:none;}
  /* Manager filter bar: full-width search */
  .mgr-filter-bar input{max-width:100%;}
}
@media (max-width: 399px) {
  .tb-app-nav .tb-app-tab{font-size:10px;padding:0 6px;}
  .tb-logo{display:none;}
}
/* Sidebar action bar: always visible above mobile drawer */
@media (pointer: coarse), (max-width: 899px) {
  .rpanel .sidebar-actions{position:sticky;bottom:0;z-index:11;box-shadow:0 -2px 8px rgba(0,0,0,0.06);}
}

/* Active project badge */
.tb-proj-badge{display:flex;align-items:center;gap:6px;padding:3px 10px;border-radius:20px;background:var(--accent-light);border:1px solid var(--accent-border);flex-shrink:1;min-width:0;max-width:260px;overflow:hidden;}
.tb-proj-badge-name{font-size:11px;font-weight:600;color:var(--accent-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;background:none;border:none;padding:0;font-family:inherit;cursor:default;}
.tb-proj-badge-name--editable{cursor:text;border-bottom:1px dashed transparent;transition:border-color 0.15s;}
@media (hover: hover){.tb-proj-badge-name--editable:hover{border-bottom-color:var(--accent);}}
.tb-proj-badge-input{font-size:11px;font-weight:600;color:var(--accent);border:1px solid var(--accent);border-radius:4px;padding:1px 4px;outline:none;background:var(--surface);width:160px;max-width:30vw;font-family:inherit;}
.tb-proj-badge-pct{font-size:10px;font-weight:500;color:var(--success-text);flex-shrink:0;background:var(--success-soft);padding:1px 5px;border-radius:8px;white-space:nowrap;}
.tb-proj-badge-saved{background:transparent;color:var(--success-text);font-weight:600;font-size:10px;padding:0 4px;display:inline-flex;align-items:center;gap:3px;}

/* Stash status badges (Thread Organiser) */
.stash-badge{font-size:10px;font-weight:600;padding:2px 7px;border-radius:10px;white-space:nowrap;flex-shrink:0;}
.stash-badge--in{color:var(--accent);background:var(--accent-light);border:1px solid var(--accent-border);}
.stash-badge--out{color:var(--text-tertiary);background:var(--surface-secondary);border:1px solid var(--border);}

/* Active project context bar (below the topbar) */
.tb-context-bar{background:var(--surface-secondary);border-bottom:1px solid var(--border);padding:0 20px;height:36px;display:flex;align-items:center;gap:12px;}
.tb-context-bar-inner{max-width:1300px;margin:0 auto;width:100%;display:flex;align-items:center;gap:10px;}
.tb-context-name{font-size:12px;font-weight:600;color:var(--text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;flex-shrink:1;}
.tb-context-name--editable{cursor:text;border-bottom:1px dashed transparent;transition:border-color 0.15s;}
@media (hover: hover){.tb-context-name--editable:hover{border-bottom-color:var(--text-secondary);}}
.tb-context-name-input{font-size:12px;font-weight:600;color:var(--text-primary);border:1px solid var(--accent);border-radius:4px;padding:1px 4px;outline:none;background:var(--surface);width:220px;max-width:40vw;}
.tb-context-meta{font-size:11px;color:var(--text-secondary);white-space:nowrap;flex-shrink:0;}
.tb-context-pct{display:inline-flex;align-items:center;gap:5px;flex-shrink:0;}
.tb-context-pct-bar{width:60px;height:4px;background:var(--border);border-radius:2px;overflow:hidden;}
.tb-context-pct-fill{height:100%;background:var(--accent);border-radius:2px;transition:width 0.3s ease;}
.tb-context-pct-lbl{font-size:11px;color:var(--accent);font-weight:600;white-space:nowrap;}

/* ═════════════════════════════════════════════════════════
   HOME SCREEN — Dashboard Hub
   ═════════════════════════════════════════════════════════ */
.home-screen {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px;
  animation: home-fadein 200ms ease;
}
@keyframes home-fadein { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 599px) { .home-screen { padding: 16px; } }

/* Greeting */
.home-greeting {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
}

/* Stats row */
.home-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.home-stats-row--narrow { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 599px) {
  .home-stats-row { grid-template-columns: repeat(2, 1fr); }
}
.home-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 16px 12px;
  text-align: center;
}
.home-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.home-stat-value--accent { color: var(--accent); }
.home-stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Hero card */
.home-hero-card {
  border: 2px solid var(--accent);
  border-radius: var(--radius-xl);
  background: var(--surface);
  padding: 16px;
  margin-bottom: 20px;
}
.home-hero-inner { display: flex; gap: 16px; align-items: flex-start; }
@media (max-width: 399px) {
  .home-hero-inner { flex-direction: column; }
}
.home-hero-thumb { flex-shrink: 0; }
.home-hero-thumb-img {
  width: 64px; height: 64px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
}
.home-hero-thumb-placeholder {
  width: 64px; height: 64px;
  border-radius: 8px;
  background: var(--border);
}
.home-hero-content { flex: 1; min-width: 0; }
.home-hero-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}
.home-hero-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}
.home-hero-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.home-hero-progress-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.home-hero-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}
.home-hero-progress-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}
.home-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 399px) {
  .home-hero-actions { flex-direction: column; }
  .home-hero-actions .home-btn { width: 100%; }
}

/* Buttons */
.home-btn {
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
}
.home-btn--primary {
  background: var(--accent);
  color: var(--surface);
  border: none;
}
.home-btn--secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

/* Start New + Recent panels */
.home-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.home-panels--full { grid-template-columns: 1fr; }
@media (max-width: 599px) {
  .home-panels { grid-template-columns: 1fr; }
}
.home-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  padding: 16px;
}
.home-panel-header {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.home-panel-list { display: flex; flex-direction: column; }

/* Action rows (Start New) */
.home-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: inherit;
  text-align: left;
  width: 100%;
  border-radius: var(--radius-sm);
  transition: background-color 150ms ease;
}
@media (hover: hover){.home-action-row:hover { background: var(--surface-tertiary); }}
.home-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Recent rows */
.home-recent-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  text-align: left;
  border-radius: var(--radius-sm);
  transition: background-color 150ms ease;
}
@media (hover: hover){.home-recent-row:hover { background: var(--surface-tertiary); }}
.home-recent-swatch { flex-shrink: 0; }
.home-recent-swatch-img {
  width: 24px; height: 24px;
  border-radius: 4px;
  object-fit: cover;
  display: block;
}
.home-recent-swatch-placeholder {
  width: 24px; height: 24px;
  border-radius: 4px;
  background: var(--border);
}
.home-recent-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.home-recent-progress {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.home-recent-progress--done { color: var(--accent); font-weight: 600; }

.home-view-all {
  background: none;
  border: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  padding: 8px 4px 0;
  text-align: left;
  font-family: inherit;
}
@media (hover: hover){.home-view-all:hover { text-decoration: underline; }}

.home-empty-msg {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 16px 8px;
}
.home-empty-state {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 12px 0 24px;
}

/* Stash alert bar */
.home-stash-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--warning);
  background: var(--warning-soft);
  border-radius: var(--radius-xl);
  padding: 12px 16px;
  margin-bottom: 20px;
}
.home-stash-alert-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-primary);
}
.home-stash-alert-link {
  background: none;
  border: none;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  padding: 0;
  font-family: inherit;
}
@media (hover: hover){.home-stash-alert-link:hover { text-decoration: underline; }}
.tb-context-actions{display:flex;gap:4px;flex-shrink:0;margin-left:auto;}
.tb-context-btn{padding:3px 9px;font-size:11px;font-weight:500;border-radius:5px;border:0.5px solid var(--border);background:var(--surface);color:var(--text-secondary);cursor:pointer;white-space:nowrap;font-family:inherit;}
@media (hover: hover){.tb-context-btn:hover{background:var(--surface-tertiary);filter:none;}}
.tb-context-btn--primary{background:var(--accent);color:var(--surface);border-color:var(--accent);}
@media (hover: hover){.tb-context-btn--primary:hover{background:var(--accent-hover);filter:none;}}
/* I6 (audit) — mode-jump pill prominence: slightly larger padding +
   bolder weight + icon gap so the cross-mode button reads as the
   primary cross-surface affordance per UX-12 plan-c-header-switcher. */
.tb-context-btn--mode{padding:5px 12px;font-size:12px;font-weight:600;display:inline-flex;align-items:center;gap:5px;}
.tb-context-btn--mode svg{width:14px;height:14px;}

/* Page fade-in */
@keyframes cs-fadein{from{opacity:0;transform:translateY(4px);}to{opacity:1;transform:translateY(0);}}
@keyframes toast-in{from{opacity:0;transform:translateY(10px) scale(0.95);}to{opacity:1;transform:translateY(0) scale(1);}}
@keyframes cs-spin{to{transform:rotate(360deg);}}
/* backwards, not both: a fill-mode that keeps transform:translateY(0) after
   the fade makes this the containing block for position:fixed children, and
   the Creator's bottom drawer then sat below the fold of the page. */
.cs-page-content{animation:cs-fadein 0.18s ease-out backwards;flex:1;display:flex;flex-direction:column;min-height:0;}
.preview-spinner{animation:cs-spin 900ms linear infinite;}
@media (prefers-reduced-motion: reduce){
  .cs-page-content{animation:none;}
  .preview-spinner{animation:none;}
  *{animation-duration:0.01ms!important;animation-iteration-count:1!important;transition-duration:0.01ms!important;}
}

/* ═══ Stats: Mini Stats Bar ═══ */
.mini-stats-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  background: var(--surface-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 2px;
}
.mini-stats-wrapper .mini-stats-bar {
  border-radius: 8px 8px 0 0;
  margin-bottom: 0;
}
.mini-stats-text {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mini-today {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.mini-streak {
  font-size: 11px;
  color: var(--accent-ink);
  font-weight: 600;
}
.mini-streak--record {
  animation: streakGlow 1s ease-out;
}
@keyframes streakGlow {
  0% { text-shadow: 0 0 8px var(--warning); }
  100% { text-shadow: none; }
}
.mini-stats-time {
  color: var(--text-secondary);
  font-size: 12px;
}
.mini-stats-btn {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
@media (hover: hover){
.mini-stats-btn:hover {
  background: var(--accent-light);
}
}

/* ═══ Stats: Progress Ring ═══ */
.progress-ring {
  position: relative;
  flex-shrink: 0;
}
.progress-ring-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 9px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ═══ Stats: Overview Cards ═══ */
.stats-overview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stats-overview-main {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.stats-big-number {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}
.stats-label {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
}
.stats-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: block;
  margin-top: 2px;
}
.stats-sublabel {
  font-size: 11px;
  color: var(--text-secondary);
  display: block;
  margin-top: 2px;
}
.stats-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}
.stats-headline-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin-bottom: 12px;
}
.stats-headline-row .stats-value { font-size: 18px; }
.stats-estimate--headline {
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--surface-secondary);
  border-radius: var(--radius-md);
}
.stats-estimate--headline .stats-value { font-size: 16px; }
.stats-estimate--headline .stats-sublabel { font-size: 12px; }

/* ═══ Stats: Session Timeline ═══ */
.session-timeline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.timeline-track {
  border-left: 2px solid var(--border);
  margin-left: 8px;
  padding-left: 16px;
}
.timeline-entry {
  position: relative;
  padding-bottom: 16px;
}
.timeline-entry:last-child {
  padding-bottom: 0;
}
.timeline-dot {
  position: absolute;
  left: -23px;
  top: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}
.timeline-content {
  min-height: 20px;
}
.timeline-date {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 2px;
}
.timeline-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  align-items: baseline;
}
.timeline-stitches {
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.timeline-duration {
  font-size: 12px;
  color: var(--text-secondary);
}
.timeline-note {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
  margin: 4px 0 0;
}
.timeline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 4px;
}
.timeline-add-note {
  font-size: 12px;
  color: var(--text-secondary);
  background: none;
  border: none;
  padding: 4px 0;
  min-height: 28px;
  cursor: pointer;
  margin-top: 0;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
@media (pointer: coarse) { .timeline-add-note { min-height: 44px; padding: 0 2px; } }
@media (hover: hover){
.timeline-add-note:hover {
  color: var(--accent);
}
}
.timeline-show-all {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
}
@media (hover: hover){
.timeline-show-all:hover {
  background: var(--accent-light);
}
}
.note-editor {
  margin-top: 4px;
}

/* ═══ Stats: Dashboard ═══ */
.stats-dashboard {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--s-4);
}

/* ═══ Stats: Charts ═══ */
.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.chart-container {
  margin-top: 4px;
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: 10px;
}
.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.chart-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
}
.chart-toggle {
  display: flex;
  gap: 0;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.chart-toggle-btn {
  min-width: 0;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 500;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chart-toggle-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}
.chart-toggle-btn.active {
  background: var(--accent);
  color: var(--surface);
  font-weight: 600;
}
.chart-x-labels {
  display: flex;
  justify-content: space-between;
  padding: 4px 0 0;
  font-size: 11px;
  color: var(--text-secondary);
}
.chart-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}
.chart-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-line {
  display: inline-block;
  width: 18px;
  height: 0;
  vertical-align: middle;
}
.legend-line.solid {
  border-top: 2.5px solid var(--accent);
}
.legend-line.dashed {
  border-top: 1.5px dashed var(--text-tertiary);
}
.legend-line.dotted {
  border-top: 2px dotted var(--warning);
}
.stats-empty {
  font-size: 13px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 24px 0;
}

/* ═══ Stats: Milestones ═══ */
.milestones {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.stats-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 10px;
}
.milestone-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  gap: 8px;
  padding-bottom: 4px;
}
.milestone-badge {
  min-width: 0;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
  border: 1.5px solid transparent;
}
.milestone-badge.achieved {
  background: var(--success-soft);
  border-color: var(--success-soft);
}
.milestone-badge.achieved .milestone-percent {
  color: var(--success-text);
  font-weight: 700;
}
.milestone-badge.achieved .milestone-date {
  color: var(--success-text);
}
.milestone-badge.next {
  background: var(--accent-light);
  border-color: var(--accent-border);
}
.milestone-badge.next .milestone-percent {
  color: var(--accent-text);
  font-weight: 700;
}
.milestone-badge.next .milestone-date {
  color: var(--accent-text);
}
.milestone-badge.future {
  background: var(--surface-secondary);
  border: 1.5px dashed var(--text-tertiary);   /* upcoming is dashed, achieved is solid and ticked, next is heavier: not colour alone */
}
.milestone-badge.future .milestone-percent,
.milestone-badge.future .milestone-date {
  color: var(--text-tertiary);
}
.milestone-badge.next { border-width: 2.5px; }
.milestone-badge .milestone-mark { display: inline-flex; margin-right: 3px; vertical-align: -0.1em; }
.milestone-badge .milestone-state { display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; margin-top: 2px; }
.milestone-percent {
  font-size: 16px;
  font-weight: 600;
  display: block;
  color: var(--text-primary);
}
.milestone-date {
  font-size: 10px;
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
}

/* ═══ Stats: Phase C — Goals, Streaks, Celebrations ═══ */
.stats-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 600px) {
  .stats-two-col { grid-template-columns: 1fr; }
}
.goal-tracker-panel,
.streaks-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.goal-setting,
.target-setting {
  margin-bottom: 4px;
}
.goal-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: block;
  margin-bottom: 6px;
}
.goal-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.goal-input {
  flex: 1;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  min-width: 0;
}
.goal-set-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}
@media (hover: hover){
.goal-set-btn:hover {
  background: var(--accent-light);
}
}
.goal-presets {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.goal-preset-btn {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-secondary);
  color: var(--text-secondary);
  cursor: pointer;
}
.goal-preset-btn.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
@media (hover: hover){
.goal-preset-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
}
.goal-suggestion {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 6px 0 0;
}
.goal-progress {
  margin-top: 10px;
}
.goal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
}
.goal-row-label {
  font-size: 12px;
  color: var(--text-secondary);
}
.goal-row-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.goal-row-value.met {
  color: var(--success);
}
.goal-row-value.pending {
  color: var(--accent-ink);
}
.goal-bar-container {
  height: 6px;
  background: var(--surface-tertiary);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.goal-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.stat-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}
.stat-row-label {
  font-size: 12px;
  color: var(--text-secondary);
}
.stat-row-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.timeline-milestone-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent);
  padding: 2px 10px;
  border-radius: 6px;
  border: 1px solid var(--accent-border);
  margin-bottom: 4px;
}
.milestone-celebration {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: var(--surface);
  border: 1.5px solid var(--accent-border);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  z-index: 200;
  animation: celebrationSlideUp 0.3s ease, celebrationFadeOut 0.5s ease 3.5s forwards;
}
@keyframes celebrationSlideUp {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
@keyframes celebrationFadeOut {
  to { opacity: 0; pointer-events: none; }
}
.celebration-icon {
  font-size: 16px;
}
.celebration-text {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-primary);
}
.celebration-subtext {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ═══ Stats: Phase D — Sharing & Export ═══ */
.stats-export-bar {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.stats-export-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
@media (hover: hover){
.stats-export-btn:hover {
  background: var(--surface-tertiary);
  border-color: var(--border);
  color: var(--text-primary);
}
}
.stats-export-btn--share {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
@media (hover: hover){
.stats-export-btn--share:hover {
  background: var(--accent-light);
}
}

/* ═══ Phase E: Colour Timeline ═══ */

/* ═══ Visual Progress: Section Grid & Comparison ═══ */
.section-grid {
  width: 100%;
}
.section-cell {
  min-height: 28px;
  user-select: none;
  transition: opacity 0.15s;
}
@media (hover: hover){
.section-cell:hover {
  opacity: 0.85;
}
}
.section-cell--selected {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.section-cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ═════════════════════════════════════════════════════════
   EMBROIDERY PATTERN PLANNER
   ═════════════════════════════════════════════════════════ */
.emb-page {
  min-height: 100vh;
  background: var(--surface-secondary);
}
.emb-container {
  max-width: 460px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}
.emb-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.emb-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.emb-upload-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.emb-nav-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.emb-back-btn {
  background: none;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: inherit;
}
@media (hover: hover){
.emb-back-btn:hover {
  background: var(--surface-tertiary);
  color: var(--text-primary);
  filter: none;
}
}
.emb-heading {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.emb-preview-img {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  display: block;
  background: var(--surface-secondary);
}
.emb-method-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.emb-method-card {
  flex: 1;
  border-radius: var(--radius-xl);
  padding: 14px;
}
.emb-method-card--auto {
  border: 2px solid var(--accent);
  background: var(--accent-light);
}
.emb-method-card--draw {
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.emb-method-title {
  font-size: 14px;
  font-weight: 700;
  margin: 4px 0 2px;
  color: var(--text-primary);
}
.emb-method-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 0;
}
.emb-btn {
  border: none;
  padding: 8px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}
.emb-btn--primary {
  background: var(--accent);
  color: var(--surface);
}
@media (hover: hover){
.emb-btn--primary:hover {
  background: var(--accent-hover);
  filter: none;
}
}
.emb-btn--secondary {
  background: var(--accent);
  color: var(--surface);
}
@media (hover: hover){
.emb-btn--secondary:hover {
  background: var(--accent-hover);
  filter: none;
}
}
.emb-btn--amber {
  background: var(--warning);
  color: var(--surface);
}
@media (hover: hover){
.emb-btn--amber:hover {
  background: var(--accent-ink);
  filter: none;
}
}
.emb-btn--sm {
  padding: 4px 12px;
  font-size: 11px;
  border-radius: 5px;
}
.emb-btn--full {
  width: 100%;
  padding: 8px 0;
}
.emb-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 3px;
}
.emb-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-tertiary);
}
.emb-suggestion-badge {
  font-size: 10px;
  color: var(--warning);
  font-weight: 600;
  background: var(--warning-soft);
  padding: 3px 8px;
  border-radius: 10px;
}
.emb-hint {
  border-radius: 7px;
  padding: 8px;
  margin-bottom: 6px;
  font-size: 11px;
  line-height: 1.5;
}
.emb-hint--teal {
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  color: var(--accent);
}
.emb-hint--amber {
  background: var(--warning-soft);
  border: 1px solid var(--warning);
  color: var(--accent-ink);
}
.emb-hint-text {
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 4px;
  margin: 0;
}
.emb-region-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.emb-color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid var(--border);
  display: inline-block;
  flex-shrink: 0;
}
.emb-region-name-input {
  font-size: 14px;
  font-weight: 700;
  border: none;
  background: transparent;
  padding: 0;
  width: 110px;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
}
.emb-region-name-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
.emb-region-dmc {
  font-size: 11px;
  color: var(--text-secondary);
}
.emb-delete-btn {
  font-size: 11px;
  background: var(--danger-soft);
  color: var(--danger);
  border: none;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
}
@media (hover: hover){
.emb-delete-btn:hover {
  background: var(--danger-soft);
  filter: none;
}
}
.emb-stitch-btn {
  padding: 4px 9px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--surface-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-weight: 400;
  font-family: inherit;
  transition: all 0.15s ease;
}
@media (hover: hover){
.emb-stitch-btn:hover {
  filter: none;
  background: var(--surface-secondary);
}
}
.emb-stitch-btn--active {
  font-weight: 700;
  border-width: 2px;
}
.emb-stitch-desc {
  font-size: 10px;
  color: var(--text-secondary);
  margin: 3px 0 0;
}
.emb-rec {
  border-radius: var(--radius-md);
  padding: 10px;
}
.emb-rec--warn {
  background: var(--warning-soft);
  border: 1px solid var(--warning);
}
.emb-rec--tip {
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
}
.emb-rec-msg {
  font-size: 11px;
  line-height: 1.4;
  margin-bottom: 4px;
}
.emb-rec--warn .emb-rec-msg { color: var(--accent-ink); }
.emb-rec--tip .emb-rec-msg { color: var(--accent-hover); }
.emb-rec-suggest {
  font-size: 11px;
  font-weight: 600;
}
.emb-rec--warn .emb-rec-suggest { color: var(--accent-ink); }
.emb-rec--tip .emb-rec-suggest { color: var(--accent); }
.emb-rec-dismiss {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
}
.emb-dmc-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  max-height: 48px;
  overflow-y: auto;
}
.emb-dmc-swatch {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  transition: all 0.1s ease;
}
.emb-dmc-swatch--active {
  border: 2.5px solid var(--accent);
}
/* Manager right panel — desktop base.
   MUST stay above the mobile media block below. It used to live down beside
   .mgr-main/.mgr-content; because it has the same specificity as the mobile
   drawer rule and was declared ~580 lines later, `width:280px` and
   `border-left` silently won on phones and the bottom sheet rendered as a
   280px stub. .rpanel is already ordered this way — keep them consistent. */
.mgr-rpanel{width:280px;background:var(--surface);border-left:1px solid var(--border);flex-shrink:0;overflow-y:auto;display:flex;flex-direction:column;}

@media (pointer: coarse), (max-width: 899px) {
  .tb-strip{height:auto;min-height:38px;}
  .tb-strip-inner{overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;padding-top:6px;padding-bottom:6px;min-height:52px;}
  .tb-btn,.tb-fit-btn,.tb-overflow-btn{min-width:44px;min-height:44px;justify-content:center;touch-action:manipulation;}
  .tb-swatch-scroll-btn{min-width:44px;min-height:44px;}
  .pal-chip-swap{opacity:1!important;min-width:24px;min-height:24px;}
  .tb-overflow-wrap--open::before{content:'';position:fixed;inset:0;background:rgba(0,0,0,0.3);z-index:299;}
  .tb-more-panel{position:fixed;bottom:0;left:0;right:0;top:auto;border-radius:var(--radius-md) var(--radius-md) 0 0;max-height:50dvh;overflow-y:auto;box-shadow:0 -4px 20px rgba(0,0,0,0.12);}
  .tb-grp{min-height:48px;align-items:stretch;}
  .tb-zoom-grp{min-height:44px;}
  .tb-overflow-menu{min-width:240px;}
  .tb-ovf-item{min-height:44px;touch-action:manipulation;}
  .col-row{min-height:44px;}
  .rp-pill-toggle button{min-height:44px;}
  .session-chip{min-height:44px;display:none!important;}
  .status-bar{display:none;}
  .creator-pattern-chips{gap:6px!important;}
  .creator-palette-chip{min-width:44px;min-height:44px;padding:8px 12px!important;border-radius:8px!important;gap:6px!important;font-size:12px!important;}
  .creator-palette-chip-swatch{width:18px!important;height:18px!important;border-radius:4px!important;}
  .creator-palette-chip-remove{min-width:24px;min-height:24px;font-size:12px!important;}
  .rp-tab{min-height:44px;}
  /* Manager right panel drawer */
  .mgr-rpanel{position:fixed;bottom:0;left:0;right:0;width:100%;max-height:44px;overflow:hidden;transition:max-height 0.25s ease;z-index:500;border-radius:16px 16px 0 0;border-left:none;border-top:1px solid var(--border);box-shadow:0 -2px 12px rgba(0,0,0,0.08);}
  .mgr-rpanel--open{max-height:70dvh;overflow-y:auto;padding-bottom:env(safe-area-inset-bottom,0px);}
  /* Panel handle strip in manager */
  .mgr-panel-handle{height:44px;display:flex;align-items:center;justify-content:center;flex-direction:column;cursor:pointer;background:var(--surface);flex-shrink:0;}
  /* Bottom padding so content isn't hidden behind peek handle */
  .canvas-area{padding-bottom:56px;}
  .mgr-content{padding-bottom:56px;}
  /* ── Tracker mobile-only: bottom action bar + colour quick-switcher ── */
  /* Make canvas clear the action bar (56px) + drawer peek (44px) + a small gap. */
  body.tracker-mobile .canvas-area{padding-bottom:112px;}
  /* Hide legacy floating undo (replaced by the action bar's undo button). */
  body.tracker-mobile .fab-undo{display:none!important;}
  /* Bottom action bar */
  body.tracker-mobile .tracker-action-bar{
    display:flex;position:fixed;bottom:0;left:0;right:0;height:56px;
    background:var(--surface);border-top:1px solid var(--border);
    align-items:center;padding:0 12px;gap:8px;z-index:501;
    box-shadow:0 -2px 8px rgba(0,0,0,0.06);
    /* Respect iOS safe-area inset */
    padding-bottom:env(safe-area-inset-bottom,0);
    height:calc(56px + env(safe-area-inset-bottom,0));
  }
  body.tracker-mobile .tracker-action-bar .colour-indicator{
    display:flex;align-items:center;gap:8px;flex:1;min-width:0;
    cursor:pointer;padding:6px 10px;border-radius:var(--radius-md);
    background:var(--surface-tertiary);border:none;font-family:inherit;
    color:var(--text-primary);text-align:left;min-height:44px;
    touch-action:manipulation;
  }
  body.tracker-mobile .tracker-action-bar .colour-indicator:active{background:var(--border);}
  body.tracker-mobile .tracker-action-bar .colour-indicator .ci-sw{
    width:28px;height:28px;border-radius:6px;flex-shrink:0;
    border:1px solid var(--border);
  }
  body.tracker-mobile .tracker-action-bar .colour-indicator .ci-text{
    flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.2;
  }
  body.tracker-mobile .tracker-action-bar .colour-indicator .ci-id{
    font-size:12px;font-weight:700;color:var(--text-primary);
    white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  }
  body.tracker-mobile .tracker-action-bar .colour-indicator .ci-name{
    font-size:10px;color:var(--text-tertiary);
    white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  }
  body.tracker-mobile .tracker-action-bar .colour-indicator .ci-chev{
    font-size:10px;color:var(--text-tertiary);flex-shrink:0;margin-right:2px;
  }
  body.tracker-mobile .tracker-action-bar .colour-indicator--empty{
    color:var(--text-tertiary);font-size:12px;font-weight:600;
  }
  body.tracker-mobile .tracker-action-bar .action-btn{
    width:48px;height:48px;border-radius:12px;border:none;
    display:flex;align-items:center;justify-content:center;
    font-size:20px;cursor:pointer;flex-shrink:0;touch-action:manipulation;
    font-family:inherit;
  }
  body.tracker-mobile .tracker-action-bar .action-btn--undo{
    background:var(--surface-tertiary);color:var(--text-secondary);
    border:1px solid var(--border);
  }
  body.tracker-mobile .tracker-action-bar .action-btn--undo:disabled{
    opacity:0.3;cursor:default;
  }
  body.tracker-mobile .tracker-action-bar .action-btn--mark{
    background:var(--accent);color:var(--surface);
    box-shadow:0 2px 8px rgba(184, 92, 56,0.3);
  }
  /* Colour quick-switcher drawer */
  body.tracker-mobile .colour-quick-drawer{
    position:fixed;left:0;right:0;
    bottom:calc(56px + env(safe-area-inset-bottom,0));
    background:var(--surface);border-top:1px solid var(--border);
    border-radius:16px 16px 0 0;box-shadow:0 -4px 16px rgba(0,0,0,0.12);
    z-index:502;max-height:0;overflow:hidden;
    transition:max-height 0.25s ease;
  }
  body.tracker-mobile .colour-quick-drawer--open{max-height:50dvh;overflow-y:auto;}
  body.tracker-mobile .colour-quick-drawer .cqd-handle{
    padding:6px 0 4px;display:flex;justify-content:center;flex-shrink:0;
  }
  body.tracker-mobile .colour-quick-drawer .cqd-grid{
    display:grid;grid-template-columns:repeat(auto-fill,minmax(64px,1fr));
    gap:8px;padding:4px 12px 16px;
  }
  body.tracker-mobile .colour-quick-drawer .cqd-tile{
    display:flex;flex-direction:column;align-items:center;justify-content:center;
    gap:3px;padding:8px 4px;border-radius:10px;
    background:var(--surface-tertiary);border:2px solid transparent;
    cursor:pointer;font-family:inherit;min-height:64px;touch-action:manipulation;
  }
  body.tracker-mobile .colour-quick-drawer .cqd-tile--on{
    border-color:var(--accent);background:var(--accent-light);
  }
  body.tracker-mobile .colour-quick-drawer .cqd-tile--done{opacity:0.4;}
  body.tracker-mobile .colour-quick-drawer .cqd-sw{
    width:28px;height:28px;border-radius:6px;border:1px solid var(--border);
  }
  body.tracker-mobile .colour-quick-drawer .cqd-id{
    font-size:11px;font-weight:700;color:var(--text-primary);line-height:1;
  }
  body.tracker-mobile .colour-quick-drawer .cqd-pct{
    font-size:9px;color:var(--text-tertiary);line-height:1;font-variant-numeric:tabular-nums;
  }
  /* Quick-switcher backdrop sits above rpanel-backdrop */
  body.tracker-mobile .colour-quick-backdrop{
    position:fixed;inset:0;z-index:500;background:rgba(0,0,0,0.25);
  }
  /* Info strip — bigger text + taller progress bar on mobile */
  body.tracker-mobile .info-strip{height:36px;}
  body.tracker-mobile .info-strip-bar{height:6px;}
  body.tracker-mobile .info-strip-row{font-size:12px;height:30px;}
  body.tracker-mobile .info-strip-pct,
  body.tracker-mobile .info-strip-timer{font-size:12px;}
  /* Make the info strip tappable on mobile (opens stats) */
  body.tracker-mobile .info-strip{cursor:pointer;}
  /* ── Immersive mode (auto-hide topbar/toolbar while scrolling pattern) ── */
  body.tracker-mobile.tracker-immersive .tb-topbar{
    transform:translateY(-100%);transition:transform 0.25s ease;
  }
  body.tracker-mobile.tracker-immersive .toolbar-row{
    transform:translateY(-100%);transition:transform 0.25s ease;
  }
  body.tracker-mobile .tb-topbar,
  body.tracker-mobile .toolbar-row{transition:transform 0.25s ease;}
  /* Subtle teal cue at top while immersive */
  body.tracker-mobile.tracker-immersive::before{
    content:'';position:fixed;top:0;left:0;right:0;height:2px;
    background:var(--accent);z-index:1000;opacity:0.6;
    pointer-events:none;
  }
}
/* Default: action bar / quick drawer hidden everywhere unless mobile */
.tracker-action-bar{display:none;}
.colour-quick-drawer{display:none;}
.colour-quick-backdrop{display:none;}
body.tracker-mobile .colour-quick-drawer{display:block;}
body.tracker-mobile .colour-quick-backdrop{display:block;}

/* ═════════════════════════════════════════════════════════
   Phase 4 (UX-12) — Tracker Workshop chrome
   Floating tool dock + bottom mode pill + sticky colour chip on
   phone. Wake-lock chip lives inline with the toolbar pill row.
   ═════════════════════════════════════════════════════════ */
/* Hide-by-default; phone media query below opts in. */
.tracker-tool-dock,.tracker-mode-pill,.tracker-colour-chip{display:none;}
/* Wake-lock chip — visible on every viewport inside the toolbar. */
.tracker-wake-chip{
  display:inline-flex;align-items:center;gap:6px;
  padding:4px 10px;min-height:32px;border-radius:var(--radius-pill,999px);
  border:1px solid var(--border);background:var(--surface);color:var(--text-secondary);
  font:500 11px/1 var(--font-ui,inherit);cursor:pointer;flex-shrink:0;margin-left:6px;
}
@media (hover: hover){.tracker-wake-chip:hover{background:var(--surface-tertiary);}}
.tracker-wake-chip .twc-dot{display:inline-flex;color:var(--text-tertiary);font-size:10px;}
.tracker-wake-chip--on{background:var(--accent-light,#F4DDCF);border-color:var(--accent);color:var(--accent);}
.tracker-wake-chip--on .twc-dot{color:var(--success);}
@media (prefers-reduced-motion: reduce){
  .tracker-wake-chip,.tracker-tool-dock,.tracker-mode-pill,.tracker-colour-chip{transition:none!important;animation:none!important;}
}

/* ── Phone (≤599px and pointer:coarse) — dock + mode pill + colour chip ── */
@media (max-width: 599px), (pointer: coarse){
  body.tracker-mobile .tracker-colour-chip{
    display:flex;position:sticky;top:0;z-index:480;
    background:var(--surface);border-bottom:1px solid var(--border);
    padding:6px 12px;padding-top:max(6px,env(safe-area-inset-top,0));
  }
  body.tracker-mobile .tracker-colour-chip .tcc-btn{
    display:flex;align-items:center;gap:8px;flex:1;min-height:44px;min-width:0;
    padding:6px 8px;border:none;background:transparent;color:var(--text-primary);
    font:inherit;text-align:left;cursor:pointer;border-radius:8px;touch-action:manipulation;
  }
  body.tracker-mobile .tracker-colour-chip .tcc-btn:active{background:var(--surface-tertiary);}
  body.tracker-mobile .tcc-sw{width:24px;height:24px;border-radius:4px;border:1px solid var(--border);flex-shrink:0;}
  body.tracker-mobile .tcc-sw--empty{background:repeating-linear-gradient(45deg,var(--border) 0 4px,transparent 4px 8px);}
  body.tracker-mobile .tcc-id{font-weight:700;font-size:13px;flex-shrink:0;}
  body.tracker-mobile .tcc-name{font-size:12px;color:var(--text-secondary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;}
  body.tracker-mobile .tcc-rem{font-size:11px;color:var(--text-tertiary);font-variant-numeric:tabular-nums;flex-shrink:0;}

  body.tracker-mobile .tracker-tool-dock{
    display:flex;flex-direction:column;gap:6px;
    position:fixed;right:max(8px,env(safe-area-inset-right,0));
    z-index:490;
    background:var(--surface);border:1px solid var(--border);border-radius:14px;
    padding:6px;box-shadow:0 4px 12px rgba(0,0,0,0.10);
    transition:top 0.2s ease;
  }
  /* Suppress the smoothing transition while the user is actively
     dragging the dock — otherwise each pointermove update visibly
     lags. The data-dragging flag is toggled in tracker-app.js. */
  body.tracker-mobile .tracker-tool-dock[data-dragging]{transition:none;}
  body.tracker-mobile .ttd-btn{
    width:44px;height:44px;border:none;background:transparent;border-radius:10px;
    color:var(--text-secondary);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;
    font-size:18px;touch-action:manipulation;font-family:inherit;
  }
  body.tracker-mobile .ttd-btn:active{background:var(--surface-tertiary);}
  body.tracker-mobile .ttd-btn:disabled{opacity:0.35;cursor:default;}
  body.tracker-mobile .ttd-btn--on{background:var(--accent);color:var(--surface);}
  body.tracker-mobile .ttd-handle{cursor:grab;color:var(--text-tertiary);font-size:14px;border-bottom:1px solid var(--border);border-radius:0;height:30px;}
  body.tracker-mobile .ttd-handle:active{cursor:grabbing;}

  body.tracker-mobile .tracker-mode-pill{
    display:flex;gap:4px;
    position:fixed;left:50%;transform:translateX(-50%);
    bottom:calc(64px + env(safe-area-inset-bottom,0));
    z-index:495;
    background:var(--surface);border:1px solid var(--border);
    border-radius:999px;padding:4px;box-shadow:0 4px 16px rgba(0,0,0,0.12);
  }
  body.tracker-mobile .tmp-seg{
    min-height:44px;min-width:72px;padding:0 18px;
    border:none;background:transparent;border-radius:999px;
    font:500 13px/1 var(--font-ui,inherit);color:var(--text-secondary);
    cursor:pointer;touch-action:manipulation;
  }
  body.tracker-mobile .tmp-seg--on{
    background:var(--accent);color:var(--surface);font-weight:600;
  }

  /* Bump existing safe-area / canvas padding so the new dock + mode pill
     don't obscure the canvas. */
  body.tracker-mobile .canvas-area{padding-bottom:max(132px,calc(132px + env(safe-area-inset-bottom,0)))!important;}
}

/* ── Tablet (≥600px) — hide phone-only chrome ── */
@media (min-width: 600px){
  body.tracker-mobile .tracker-mode-pill{display:none;}
  body.tracker-mobile .tracker-tool-dock{display:none;}
  body.tracker-mobile .tracker-colour-chip{display:none;}
  /* The block above opens on `(max-width: 599px), (pointer: coarse)` — a
     union, so a tablet matches it via the coarse arm and reserves 132px at
     the foot of the chart for the mode pill and tool dock. Those three are
     then hidden here, but the padding was never given back, leaving a band
     of dead space under the chart on every tablet. Reclaim it alongside the
     elements it was compensating for, so the two stay in step. */
  body.tracker-mobile .canvas-area{padding-bottom:env(safe-area-inset-bottom,0)!important;}
}

/* Creator panel as a bottom drawer. Width-only on purpose: a touch tablet
   at 900px or wider (iPad Pro landscape) gets the desktop side panel. When
   this lived in the (pointer:coarse) block the panel stayed width:100% at
   >=900px and covered the whole canvas. Touch-target sizes stay in the
   coarse-pointer block above. */
@media (max-width: 899px) {
  .rpanel{position:fixed;bottom:0;left:0;right:0;width:100%;border-left:none;border-top:1px solid var(--border);top:auto;max-height:45px;overflow:hidden;transition:max-height 0.25s ease;z-index:500;border-radius:16px 16px 0 0;box-shadow:0 -2px 12px rgba(0,0,0,0.08);}
  /* Edit mode peeks the handle and the whole tab strip (about 92px). */
  .rpanel--edit{max-height:94px;}
  .rpanel--drawer-open,.rpanel--open{max-height:70dvh;overflow-y:auto;}
  .rp-tabs{position:sticky;top:0;z-index:10;}
  /* Creator panel handle bar (the Manager's drawer handle reuses it) */
  .rpanel-handle-bar{width:36px;height:4px;background:var(--border);border-radius:2px;margin:0 auto 6px;}
  /* Backdrop */
  .rpanel-backdrop{position:fixed;inset:0;z-index:499;background:rgba(0,0,0,0.25);}
  /* Convert mode has no tab strip, so the drawer gets a Settings row that
     stays fully visible while collapsed (see creator/Sidebar.js). */
  .rpanel-drawer-header{display:flex;flex-direction:column;justify-content:center;flex-shrink:0;width:100%;min-height:44px;padding:6px 16px 4px;border:none;background:var(--surface);color:var(--text-primary);font-family:inherit;cursor:pointer;touch-action:manipulation;position:sticky;top:0;z-index:12;}
  .rpanel-drawer-header .rpanel-handle-bar{display:block;margin:0 auto 4px;}
  .rpanel-drawer-header__row{display:flex;align-items:center;justify-content:space-between;gap:var(--s-2);font-size:var(--text-sm);font-weight:600;line-height:1.3;}
  .rpanel-drawer-header__chev{display:inline-flex;color:var(--text-secondary);}
  .rpanel-drawer-header__chev svg{width:18px;height:18px;}
  /* Collapsed, the drawer peeks its handle and tab strip; the page has its
     own Convert button, so the Back to Convert row waits until it opens. */
  .rpanel:not(.rpanel--open) .rpanel-back-to-convert{display:none;}
}

/* ═════════════════════════════════════════════════════════
   DESKTOP LAYOUT — Full viewport with root scrolling
   Creator canvas/sidebar keep their internal scrolling behaviour.
   ═════════════════════════════════════════════════════════ */
@media (min-width: 900px) {
  html, body { height: 100%; overflow: visible; }
  #root { height: 100vh; overflow: auto; }
  /* The Creator fills the window rather than growing with its content, so
     the chart and the sidebar's tab content scroll in their own boxes: a
     long Tools tab no longer scrolls the chart off the screen. */
  .cs-design-root { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; height: 100%; }
  /* cs-main children stretch to fill remaining viewport height */
  .cs-main { align-items: stretch; }
  /* Canvas area scrolls within its own box, not the page */
  .canvas-area { overflow: auto; padding-bottom: 0; }
  /* rpanel: permanent flex-column side-panel */
  .rpanel {
    position: relative;
    top: auto;
    max-height: none;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    transition: none;
    border-radius: 0;
    border-top: none;
    border-left: 1px solid var(--border);
    box-shadow: none;
    overflow: hidden;
  }
  /* Tab bar rows stay pinned — not sticky (sticky doesn't work in overflow:hidden parent) */
  .rp-tabs { flex-shrink: 0; position: relative; top: auto; }
  /* Creator sidebar tab list stays pinned */
  .rpanel [role="tablist"] { flex-shrink: 0; }
  /* Creator sidebar scrollable content area: fill remaining space */
  .rpanel [role="tablist"] ~ div { flex: 1; min-height: 0; overflow-y: auto; }
  /* Tracker tab content fills remaining space */
  .rp-tab-content { flex: 1; min-height: 0; overflow-y: auto; }
  /* Manager right panel: restore desktop side-panel */
  .mgr-rpanel {
    position: relative;
    max-height: none;
    width: 280px;
    border-left: 1px solid var(--border);
    border-top: none;
    border-radius: 0;
    box-shadow: none;
    overflow-y: auto;
    transition: none;
  }
  /* Manager content area: scrolls within its own box */
  .mgr-content { padding-bottom: 0; min-height: 0; }
  /* Hide mobile-only affordances */
  .rpanel-handle-wrap { display: none !important; }
  .mgr-panel-handle { display: none !important; }
  .rpanel-backdrop { display: none !important; }
}
.emb-legend-title {
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--text-primary);
}
.emb-legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
}
.emb-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.1s ease;
}
@media (hover: hover){
.emb-legend-item:hover {
  background: var(--surface-secondary);
}
}
.emb-legend-item--active {
  background: var(--accent-light);
  border-color: var(--accent-border);
}
.emb-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.emb-legend-name {
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}
.emb-legend-meta {
  font-size: 9px;
  color: var(--text-secondary);
}
.emb-legend-badge {
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: var(--accent);
  flex-shrink: 0;
}
.emb-legend-badge--warn {
  background: var(--warning);
}


/* ═══ Stats: Colour Progress ═══ */
.colour-progress {
  background: var(--surface);   /* was an undefined token with a white fallback: a white panel in dark mode, under pale text */
  border: 1px solid var(--border, #E5DCCB);
  border-radius: 10px;
  padding: 14px 16px;
}
.stats-colour-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 12px;
  color: var(--text-secondary, #5C5448);
  margin-bottom: 10px;
}
.stats-colour-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: min(28rem, 60vh);
  overflow: auto;
  scrollbar-gutter: stable;
}
.stats-colour-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) minmax(0, auto);
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
}
.stats-colour-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
}
.stats-colour-row.complete .colour-bar-fill { background: var(--success); }
.colour-info { grid-column: 2 / -1; flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.colour-info-main { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; min-width: 0; }
.colour-detail { font-size: var(--text-xs); color: var(--text-tertiary); }
.colour-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  /* color-3 (C1): position + overflow enable the ::after texture overlay below.
     Inline `background: rgb(...)` shorthand resets background-image, so the
     subtle thread sheen has to live on a pseudo-element. */
  position: relative;
  overflow: hidden;
}
.colour-swatch::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.18) 0%,
    transparent 50%,
    rgba(0, 0, 0, 0.06) 100%
  );
  pointer-events: none;
}
.colour-swatch--large::after {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.14) 0%,
    transparent 50%,
    rgba(0, 0, 0, 0.05) 100%
  );
}
.colour-id {
  font-weight: 600;
  min-width: 56px;
  font-size: 12px;
  color: var(--text-primary, #1B1814);
  flex-shrink: 0;
}
.colour-name {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  min-width: 0;
  overflow-wrap: anywhere;
}
.colour-bar {
  grid-column: 2;
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  min-width: 40px;
}
.colour-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}
.colour-remaining {
  max-width: 14ch;
  overflow-wrap: anywhere;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  min-width: 50px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ═══ TRACKER RIGHT PANEL ═══ */
.rp-section{padding:12px 14px;border-bottom:1px solid var(--border-subtle);}
.rp-section:last-child{border-bottom:none;}
.rp-heading{font-size:11px;font-weight:700;color:var(--text-primary);text-transform:uppercase;letter-spacing:0.4px;margin-bottom:8px;display:flex;align-items:center;justify-content:space-between;}
.rp-heading .badge{font-size:10px;font-weight:500;background:var(--accent-light);color:var(--accent);padding:2px 6px;border-radius:10px;text-transform:none;letter-spacing:0;}
.rp-pill-toggle{display:flex;background:var(--surface-tertiary);border-radius:var(--radius-md);padding:2px;border:1px solid var(--border);}
.rp-pill-toggle button{flex:1;font-size:10px;padding:5px;border:none;background:transparent;border-radius:6px;cursor:pointer;color:var(--text-tertiary);font-weight:500;font-family:inherit;}
.rp-pill-toggle button.on{background:var(--surface);color:var(--accent);font-weight:600;box-shadow:var(--shadow-sm);}
.session-chip{display:inline-flex;align-items:center;gap:5px;padding:4px 12px;background:var(--success-soft);border:1px solid var(--success);border-radius:10px;font-size:11px;font-weight:600;color:var(--success);margin-left:8px;white-space:nowrap;flex-shrink:0;cursor:pointer;transition:background 0.2s,border-color 0.2s;}
@media (hover: hover){.session-chip:hover{filter:brightness(0.95);}}
.session-chip .dot{width:7px;height:7px;border-radius:50%;background:var(--success);animation:sess-pulse 1.5s ease-in-out infinite;}
.session-chip--paused{background:var(--warning-soft);border-color:var(--warning);color:var(--accent-ink);}
.session-chip--idle{background:var(--surface-tertiary);border-color:var(--border);color:var(--text-secondary);}
@keyframes sess-pulse{0%,100%{opacity:1;}50%{opacity:0.4;}}
@keyframes range-anchor-pulse{0%{box-shadow:0 0 0 0 rgba(59,130,246,0.5);}100%{box-shadow:0 0 0 4px rgba(59,130,246,0);}}
/* ── Modal choice buttons (onboarding etc.) ── */
.modal-choice-btn{padding:12px 16px;border-radius:10px;border:1px solid var(--border);background:var(--surface);color:var(--text-primary);cursor:pointer;font-size:14px;font-weight:600;text-align:left;width:100%;}
@media (hover: hover){.modal-choice-btn:hover{border-color:var(--accent);background:var(--accent-light);color:var(--accent);}}
.modal-choice-btn--on{border-color:var(--accent);background:var(--accent-light);color:var(--accent);}
/* ═══ Progress bar: today accent segment ═══ */
.tb-progress-today{background:var(--success);border-radius:0 2px 2px 0;animation:todayGlow 2s ease-in-out infinite alternate;}

/* ═══ Info Strip (replaces Progress Bar + MiniStatsBar) ═══ */
.info-strip-wrap{position:sticky;top:var(--app-header-height, 48px);z-index:98;background:var(--surface);border-bottom:1px solid var(--border);display:flex;align-items:stretch;}
.info-strip-wrap > .info-strip{position:static;border-bottom:0;flex:1;min-width:0;}
.info-strip-chip-wrap{display:flex;align-items:center;padding:0 12px 0 6px;flex-shrink:0;}
.info-strip-chip{font-size:11px;padding:4px 10px;}
.info-strip{position:sticky;top:var(--app-header-height, 48px);z-index:98;background:var(--surface);border-bottom:1px solid var(--border);height:28px;display:flex;flex-direction:column;justify-content:flex-end;}
.info-strip-bar{height:4px;background:var(--border);display:flex;width:100%;flex-shrink:0;}
.info-strip-fill{height:100%;background:var(--accent);transition:width 0.3s ease;}
.info-strip-fill--done{background:var(--success);}
.info-strip-today{background:var(--success);border-radius:0 2px 2px 0;animation:todayGlow 2s ease-in-out infinite alternate;}
.info-strip-row{display:flex;align-items:center;justify-content:space-between;padding:0 16px;height:24px;max-width:1300px;margin:0 auto;width:100%;gap:12px;}
.info-strip-pct{font-size:11px;font-weight:700;color:var(--accent-text);white-space:nowrap;display:flex;align-items:center;gap:4px;}
.info-strip-counts{font-size:11px;font-weight:400;color:var(--text-secondary);white-space:nowrap;font-variant-numeric:tabular-nums;}
.info-strip-breakdown{font-size:11px;font-weight:400;color:var(--text-tertiary);white-space:nowrap;font-variant-numeric:tabular-nums;}
/* The "layers hidden" chip (tracker-layer-chip.js): a hidden layer is remembered per project, so the strip says so. */
.tracker-layers-chip{display:inline-flex;align-items:center;gap:4px;min-width:0;max-width:100%;padding:1px 8px;border:1px solid var(--warning);border-radius:var(--radius-pill);background:var(--warning-soft);color:var(--text-primary);font-family:inherit;font-size:11px;font-weight:600;line-height:1.4;cursor:pointer;white-space:nowrap;}
.tracker-layers-chip__icon{display:inline-flex;flex-shrink:0;}
.tracker-layers-chip__text{overflow:hidden;text-overflow:ellipsis;min-width:0;}
.tracker-layers-chip__sep{color:var(--text-secondary);}
.tracker-layers-chip__show{color:var(--accent-text);text-decoration:underline;text-underline-offset:2px;flex-shrink:0;}
.tracker-layers-chip:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}
/* Focus mode: a pill above the floating bar, never inside it (the bar is already as wide as a phone). */
.tracker-layers-chip--float{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(max(16px, env(safe-area-inset-bottom, 0px)) + 68px);max-width:calc(100vw - 32px);z-index:var(--z-coachmark, 1200);min-height:36px;padding:0 14px;font-size:12px;box-shadow:var(--shadow-lg);}
@media (hover: hover){.tracker-layers-chip:hover{background:var(--surface-tertiary);}}
@media (pointer: coarse){.tracker-layers-chip{min-height:44px;padding:0 12px;}}
.info-strip-timer{font-size:11px;font-weight:500;color:var(--text-secondary);white-space:nowrap;font-variant-numeric:tabular-nums;margin-left:auto;background:none;border:0;padding:0;font-family:inherit;cursor:pointer;}
@media (pointer: coarse){.info-strip-timer{min-height:44px;padding:0 6px;}}
/* Completion projection bar — shown below the info-strip when pace data is available */
/* The one-time Highlight hint. It sits above .cs-main, so while the docked
   palette (320px, from 1024px up) is open it needs that offset (plus the 16px
   gutter) as .cs-main--palette-open has, or its start slides under the panel. */
.tracker-hint-banner{display:flex;align-items:center;justify-content:space-between;gap:var(--s-2);box-sizing:border-box;margin:0 16px var(--s-1);padding:6px 10px;background:var(--surface-secondary);border:1px solid var(--accent-light);border-radius:var(--radius-sm);font-size:var(--text-xs);color:var(--accent-text);}
.tracker-hint-banner__text{flex:1 1 auto;min-width:0;overflow-wrap:anywhere;}
.tracker-hint-banner kbd{font-size:10px;padding:0 3px;border:1px solid var(--accent-light);border-radius:3px;background:var(--surface);}
.tracker-hint-banner__close{flex-shrink:0;padding:0;line-height:1;display:inline-flex;background:none;border:none;cursor:pointer;color:var(--accent-text);}
@media(min-width:1024px){
  .tracker-hint-banner{transition:margin-left var(--motion,0.18s ease);}
  .tracker-hint-banner--palette-open{margin-left:336px;}
  body.cs-focus .tracker-hint-banner--palette-open{margin-left:16px;}   /* focus mode hides the panel, as it zeroes .cs-main's margin */
}
.completion-projection-bar{display:flex;align-items:center;gap:12px;padding:3px 16px 4px;background:var(--surface-secondary);border-bottom:1px solid var(--border);font-variant-numeric:tabular-nums;}
.completion-projection-text{font-size:11px;font-weight:500;color:var(--accent);}
.completion-projection-speed{font-size:11px;color:var(--text-tertiary);}
@media(max-width:480px){.completion-projection-speed{display:none;}}
@keyframes todayGlow{0%{filter:brightness(1);}100%{filter:brightness(1.15);}}
/* ═══ Mini-goal bar (unified daily/weekly/monthly) ═══ */
@keyframes goalPulse{0%{filter:brightness(1.4);}100%{filter:brightness(1);}}
.mini-goal{display:flex;align-items:center;gap:8px;padding:3px 14px 5px;cursor:pointer;background:var(--surface-secondary);border:1px solid var(--border);border-top:none;border-radius:0 0 8px 8px;margin-bottom:2px;}
@media (hover: hover){.mini-goal:hover{background:var(--surface-tertiary);}}
.mini-goal-label{font-size:11px;font-weight:600;color:var(--accent);white-space:nowrap;flex-shrink:0;}
.mini-goal-count{font-size:11px;font-weight:600;color:var(--text-primary);font-variant-numeric:tabular-nums;white-space:nowrap;flex-shrink:0;}
.mini-goal-track{flex:1;height:4px;background:var(--border);border-radius:2px;overflow:hidden;min-width:40px;}
.mini-goal-fill{height:100%;background:var(--accent);border-radius:2px;transition:width 0.3s;}
.mini-goal-fill--done{height:100%;background:var(--success);border-radius:2px;animation:goalPulse 0.6s ease-out;}
.goal-pace-context{font-size:11px;color:var(--text-tertiary);margin-top:6px;font-variant-numeric:tabular-nums;}
/* ═══ Session onboarding toast ═══ */
/* ═══ Session saved toast (note prompt) ═══ */
.session-toast{display:flex;align-items:center;gap:8px;padding:8px 16px;background:var(--success-soft);border-bottom:1px solid var(--success-soft);font-size:12px;color:var(--success);}
.session-toast>span{flex:1;}
.session-toast button{flex-shrink:0;font-size:11px;font-weight:600;padding:3px 12px;border-radius:6px;border:1px solid var(--success);background:var(--surface);color:var(--success);cursor:pointer;}
@media (hover: hover){.session-toast button:hover{background:var(--success-soft);}}
.session-toast button[aria-label="Dismiss"]{background:transparent;border-color:transparent;color:var(--success);padding:3px 6px;}
.session-toast input{flex:1;font-size:12px;padding:4px 8px;border-radius:6px;border:1px solid var(--success);background:var(--surface);color:var(--success);font-family:inherit;outline:none;}
.session-toast input:focus{border-color:var(--success);}
/* Focus block nav row — chip + "Next section" button ───────────────── */
.focus-block-nav{display:flex;align-items:center;gap:6px;width:fit-content;margin-bottom:var(--s-1);}
.focus-block-chip{display:inline-flex;align-items:center;gap:6px;padding:3px 10px 3px 8px;background:var(--accent-light);border:1px solid var(--accent-border);border-radius:20px;font-size:var(--text-xs);font-weight:600;color:var(--accent);cursor:pointer;user-select:none;}
@media (hover: hover){.focus-block-chip:hover{background:var(--accent-border);}}
.focus-block-next-btn{display:inline-flex;align-items:center;gap:4px;padding:3px 10px;background:var(--surface);border:1px solid var(--accent-border);border-radius:20px;font-size:var(--text-xs);font-weight:600;color:var(--accent);cursor:pointer;user-select:none;font-family:inherit;transition:background 120ms;}
@media (hover: hover){.focus-block-next-btn:hover{background:var(--accent-light);}}
.sess-card{padding:10px;background:var(--accent-light);border-radius:var(--radius-md);border:1px solid var(--accent-light);display:flex;flex-direction:column;gap:6px;}
.sess-card .row{display:flex;justify-content:space-between;font-size:12px;}
.sess-card .val{font-weight:700;color:var(--accent);}
.sess-card .lbl{color:var(--text-tertiary);font-size:11px;}
.col-list{display:flex;flex-direction:column;gap:2px;max-height:280px;overflow-y:auto;}
.col-row{display:flex;align-items:center;gap:6px;padding:5px 6px;border-radius:6px;cursor:pointer;font-size:11px;}
@media (hover: hover){.col-row:hover{background:var(--surface-tertiary);}}
.col-row.focus{background:var(--accent-light);outline:1px solid var(--accent);}
.col-row .sw{width:16px;height:16px;border-radius:4px;border:1px solid var(--border);flex-shrink:0;}
.col-row .sym{font-family:monospace;font-size:10px;color:var(--text-tertiary);width:12px;text-align:center;}
.col-row .cid{font-weight:600;min-width:30px;}
.col-row .nm{flex:1;color:var(--text-tertiary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.col-row .prog{width:50px;height:4px;background:var(--surface-tertiary);border-radius:2px;overflow:hidden;border:1px solid var(--border);}
.col-row .prog .pf{height:100%;background:var(--accent);border-radius:2px;}
.col-row .ct{font-size:10px;color:var(--text-tertiary);font-family:monospace;min-width:44px;text-align:right;}

/* ═══ MANAGER NEW DESIGN ═══ */
.mgr-tab-bar{height:48px;background:var(--surface);border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:4px;flex-shrink:0;min-width:0;padding:0 8px;}
.mgr-tab{display:flex;align-items:center;gap:6px;padding:8px 20px;border-radius:10px;font-size:13px;font-weight:500;color:var(--text-tertiary);cursor:pointer;border:none;background:transparent;transition:all 0.12s;font-family:inherit;}
@media (hover: hover){.mgr-tab:hover{background:var(--surface-tertiary);color:var(--text-secondary);}}
.mgr-tab.on{background:var(--accent);color:var(--surface);box-shadow:0 2px 8px rgba(184, 92, 56,0.3);font-weight:600;}
.mgr-tab .icon{font-size:16px;}
.mgr-tab .cnt{font-size:10px;background:rgba(255,255,255,0.25);padding:1px 7px;border-radius:8px;font-weight:700;}
.mgr-tab:not(.on) .cnt{background:var(--surface-tertiary);color:var(--text-tertiary);}
/* The chips, sort control and Bulk Add button are all white-space:nowrap and
   none of them shrinks, so their intrinsic widths total ~1050px. Without a
   scroller that pushed the *document* to 1050px on a 393px phone, which in
   turn expands the layout viewport — and `position:fixed` resolves against
   the layout viewport, which is why .mgr-rpanel used to land ~1900px down
   the page instead of docked to the bottom. Keep the row on one line but
   let it scroll inside its own box. */
.mgr-filter-bar{padding:10px 20px;background:var(--surface);border-bottom:1px solid var(--border);display:flex;align-items:center;gap:8px;flex-shrink:0;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;}
.mgr-filter-bar::-webkit-scrollbar{display:none;}
.mgr-filter-bar>*{flex-shrink:0;}
/* flex-basis is 180px rather than 0 because the bar above is now a scroller:
   with `flex:1` (basis 0) and no free space to grow into, the search box
   would collapse to zero width on narrow screens. It still grows to the
   300px cap whenever the row does have room, so desktop is unchanged. */
.mgr-filter-bar input{flex:1 0 180px;max-width:300px;padding:7px 12px;font-size:12px;border:1px solid var(--border);border-radius:var(--radius-md);background:var(--surface-tertiary);color:var(--text-primary);font-family:inherit;}
.mgr-filter-bar input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px rgba(184, 92, 56,0.3);}
.mgr-chip{padding:5px 12px;font-size:11px;font-weight:500;border:1px solid var(--border);background:var(--surface);color:var(--text-tertiary);border-radius:16px;cursor:pointer;white-space:nowrap;font-family:inherit;}
/* Thread sort control. Was an inline style on the <select>, which outranked
   the coarse-pointer 16px rule and left iOS zooming the page on focus. */
.mgr-sort-select{font-size:12px;padding:3px 6px;border-radius:6px;border:1px solid var(--border);background:var(--surface);color:var(--text-primary);cursor:pointer;font-family:inherit;}
@media (hover: hover){.mgr-chip:hover{border-color:var(--border);color:var(--text-secondary);}}
.mgr-chip.on{background:var(--accent);color:var(--surface);border-color:var(--accent);}
.mgr-stats-strip{padding:8px 20px;display:flex;gap:16px;font-size:12px;color:var(--text-tertiary);flex-shrink:0;border-bottom:1px solid var(--border-subtle);}
.mgr-stats-strip .stat{display:flex;align-items:center;gap:4px;}
.mgr-stats-strip .stat .val{font-weight:700;color:var(--text-primary);}
.mgr-main{flex:1;display:flex;overflow:hidden;}
.mgr-content{flex:1;overflow-y:auto;padding:16px 20px;}
/* .mgr-rpanel base rule moved above the mobile drawer media block — see the
   comment there. Do not re-add it here; it would override the drawer again. */
.pat-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(300px,100%),1fr));gap:10px;}
.pcard{padding:12px 14px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-xl);cursor:pointer;transition:var(--transition-ui-fast);
  /* Skip layout and paint for off-screen pattern cards (action plan H6 =
     2B.2). Reserve a generous intrinsic height. */
  content-visibility:auto;
  contain-intrinsic-size:auto 120px;
}
@media (hover: hover){.pcard:hover{border-color:var(--border);box-shadow:var(--shadow-sm);}}
.pcard.on{border-color:var(--accent);box-shadow:0 0 0 2px rgba(184, 92, 56,0.3);background:var(--accent-light);}
.pcard .ptitle{font-weight:700;font-size:14px;margin-bottom:2px;display:flex;align-items:center;gap:6px;}
/* Thread detail in rpanel */
.alert-card{padding:10px 12px;border-radius:var(--radius-md);margin-bottom:8px;font-size:12px;}
.alert-card.warn{background:var(--warning-soft);border:1px solid var(--warning);color:var(--accent-ink);}
.alert-card.danger{background:var(--danger-soft);border:1px solid var(--danger-soft);color:var(--danger);}
.alert-card.success{background:var(--success-soft);border:1px solid var(--success);color:var(--success);}
/* Stash alert headings remain available when their details are tucked away. */
.stash-alert{margin-bottom:16px;}
.stash-alert.quiet{background:var(--surface-secondary);border:1px solid var(--border);color:var(--text-secondary);}
.stash-alert-heading{margin:0;font-size:inherit;}
.stash-alert-toggle{display:flex;align-items:center;gap:8px;width:100%;min-height:44px;padding:0;border:0;border-radius:var(--radius-sm);background:transparent;color:inherit;font:inherit;font-weight:700;text-align:left;cursor:pointer;}
.stash-alert-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:3px;}
.stash-alert-title{flex:1;min-width:0;overflow-wrap:anywhere;}
.stash-alert-count{white-space:nowrap;}
.stash-alert-icon,.stash-alert-chevron{display:flex;flex-shrink:0;}
.stash-alert-body{padding-top:4px;}
.stash-alert-body[hidden]{display:none;}
.alert-card .at{font-weight:700;margin-bottom:4px;display:flex;align-items:center;gap:4px;}

/* Manager rpanel sections (short aliases) */
.rp-s{padding:14px 16px;border-bottom:1px solid var(--border-subtle);}
.rp-s:last-child{border-bottom:none;}
.rp-h{font-size:11px;font-weight:700;color:var(--text-primary);text-transform:uppercase;letter-spacing:0.4px;margin-bottom:8px;display:flex;align-items:center;justify-content:space-between;}
.rp-h .badge{font-size:10px;font-weight:500;background:var(--accent-light);color:var(--accent);padding:2px 6px;border-radius:10px;text-transform:none;letter-spacing:0;}

/* Used-in list */
.used-in{display:flex;flex-direction:column;gap:4px;}
.used-in .ui-row{display:flex;align-items:center;gap:6px;padding:4px 6px;border-radius:6px;font-size:11px;color:var(--text-secondary);}
@media (hover: hover){.used-in .ui-row:hover{background:var(--surface-tertiary);}}
.used-in .ui-row .need{font-weight:600;margin-left:auto;color:var(--text-tertiary);font-size:10px;}

/* Pattern card status badges */
.pcard .status{font-size:10px;font-weight:700;padding:2px 8px;border-radius:8px;}
.pcard .status.wishlist,.status.wishlist{background:var(--warning-soft);color:var(--accent-ink);}
.pcard .status.owned,.status.owned{background:var(--accent-light);color:var(--accent);}
.pcard .status.inprogress,.pcard .status.progress,.status.inprogress,.status.progress{background:var(--danger-soft);color:var(--danger);}
.pcard .status.completed,.pcard .status.done,.status.completed,.status.done{background:var(--success-soft);color:var(--success);}
.status{font-size:10px;font-weight:700;padding:2px 8px;border-radius:8px;}
.pcard .pdesigner{font-size:11px;color:var(--text-tertiary);margin-bottom:6px;}

/* Preview mode */
.preview-canvas{image-rendering:crisp-edges;image-rendering:pixelated;display:block;}
.preview-canvas--realistic{image-rendering:auto;}
.preview-wrap{position:relative;}
.preview-status-bar{font-size:11px;color:var(--text-tertiary);padding:4px 8px;text-align:center;}
.pcard .ptags{display:flex;gap:4px;flex-wrap:wrap;margin-bottom:8px;}
.pcard .ptags .tag{font-size:10px;padding:2px 8px;background:var(--surface-tertiary);border-radius:10px;color:var(--text-secondary);}
.pcard .pmeta{display:flex;justify-content:space-between;font-size:11px;color:var(--text-tertiary);margin-top:8px;}

/* Global button for rpanel actions */
.g-btn{display:inline-flex;align-items:center;gap:5px;padding:6px 14px;font-size:12px;font-weight:600;border:1px solid var(--border);background:var(--surface);color:var(--text-secondary);border-radius:var(--radius-md);cursor:pointer;white-space:nowrap;font-family:inherit;}
@media (hover: hover){.g-btn:hover{border-color:var(--border);background:var(--surface-tertiary);}}
.g-btn--primary,.g-btn.primary{background:var(--accent);color:var(--surface);border-color:var(--accent);}
@media (hover: hover){.g-btn.primary:hover{background:var(--accent-hover, var(--accent));border-color:var(--accent-hover, var(--accent));}}

kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--surface-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--border);
  line-height: 1.4;
  min-width: 20px;
  text-align: center;
}

/* ═══ Palette Swap ═══ */
.ps-confirm-overlay {
  animation: ps-fade-in 0.2s ease;
}
@keyframes ps-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .ps-confirm-overlay {
    animation: none;
  }
}
.ps-preset-card {
  transition: border-color 0.15s, background 0.15s;
}
@media (hover: hover){
.ps-preset-card:hover {
  border-color: var(--accent-border);
  background: var(--surface-secondary);
}
}
.ps-preset-card--selected {
  border-color: var(--accent) !important;
  background: var(--accent-light) !important;
}

/* ═══ Keyboard Focus Rings ═══ */
[role="switch"]:focus-visible,
[role="checkbox"]:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ═══ Stats: Project Comparison ═══ */
.project-comparison {
  padding: 16px 0;
}
.comparison-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 8px;
  flex-wrap: wrap;
}
.comparison-bars {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.comparison-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}
@media (hover: hover){
.comparison-bar-row:hover {
  background: var(--surface-tertiary);
}
}
.comparison-bar-row.current {
  background: var(--accent-light);
  border-color: var(--accent-border);
}
.comparison-name {
  font-weight: 600;
  font-size: 13px;
  min-width: 120px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.comparison-track {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.comparison-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
}
.comparison-fill.complete {
  background: var(--success);
}
.comparison-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 52px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 13px;
}
.comparison-table thead {
  background: var(--surface-secondary);
  border-bottom: 1px solid var(--border);
}
.comparison-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  white-space: nowrap;
  user-select: none;
}
@media (hover: hover){
.comparison-table th:hover {
  color: var(--accent);
}
}
.comparison-row {
  border-top: 1px solid var(--surface-tertiary);
  cursor: pointer;
  transition: background 0.12s;
}
@media (hover: hover){
.comparison-row:hover {
  background: var(--surface-secondary);
}
}
.comparison-row.current {
  background: var(--accent-light);
}
.comparison-insights {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: 10px;
  margin-top: 16px;
}
.comparison-insight-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.comparison-insight-icon {
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1.2;
}

/* ═══════════════════════════════════════════════════════════
   GLOBAL STATS DASHBOARD (GSD)
   ═══════════════════════════════════════════════════════════ */

/* Stats container with tab bar */
.stats-container {
  max-width: 1280px;
  margin: 0 auto;
  /* the page's width, never the widest thing inside it (a long project name in the tab bar used to widen the whole
     page on a phone) */
  width: 100%;
  min-width: 0;
}
.stats-container-body {
  padding: 0;
}

/* Tab bar */
.gsd-tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  /* overflow stays visible so absolutely-positioned children
     (e.g. the Lifetime chip popover) are not clipped vertically.
     Horizontal scrolling for overflowing tabs lives on .gsd-tabs-inner. */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.gsd-tabs-chip-wrap {
  position: relative;
  flex-shrink: 0;
  padding: 0 12px;
  display: flex;
  align-items: center;
}
.gsd-lifetime-chip__num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text-primary);
  margin-left: 4px;
}
.gsd-tabs-inner {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 0 4px;
}
.gsd-tabs-inner::-webkit-scrollbar { display: none; }
.gsd-tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--text-tertiary);
  white-space: nowrap;
  font-family: inherit;
  flex-shrink: 0;
  min-height: 44px;
  transition: color 0.12s;
}
@media (hover: hover){.gsd-tab:hover { color: var(--text-secondary); }}
.gsd-tab--on {
  color: var(--accent-text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

/* Dashboard body */
.gsd {
  padding: 0 16px;
  max-width: 1280px;
  margin: 0 auto;
}
@media (min-width: 600px) {
  .gsd { padding: 0 20px; }
}

.gsd-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 1.5rem 0 0.75rem;
}

/* Metric cards */
.gsd-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 0.5rem;
}
.gsd-metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  text-align: center;
}
.gsd-metric-label {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}
.gsd-metric-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.15;
}
.gsd-metric-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Streak */
.gsd-streak {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 0.5rem;
}
.gsd-streak-flame { font-size: 28px; flex-shrink: 0; }
.gsd-streak-body { flex: 1; min-width: 0; }
.gsd-streak-num { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }
.gsd-streak-label { font-size: 12px; color: var(--text-secondary); }
.gsd-streak-best { font-size: 12px; color: var(--text-tertiary); white-space: nowrap; flex-shrink: 0; }

/* Project cards */
.gsd-projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 0.5rem;
}
.gsd-project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  min-height: 44px;
  transition: border-color 0.12s, background 0.12s;
}
@media (hover: hover){
.gsd-project-card:hover {
  border-color: var(--accent-border);
  background: var(--accent-light);
}
}
.gsd-pc-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gsd-pc-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Week comparison */
.gsd-week {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 0.5rem;
}
.gsd-week-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 600px) {
  .gsd-week-grid { grid-template-columns: repeat(4, 1fr); }
}
.gsd-week-metric { text-align: center; }
.gsd-week-metric-label { font-size: 11px; color: var(--text-tertiary); margin-bottom: 4px; }
.gsd-week-metric-value { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.gsd-week-metric-delta { font-size: 12px; font-weight: 500; margin-top: 2px; }

/* Heatmap */
.gsd-heatmap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}
.gsd-heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  height: 80px;
}
.gsd-heatmap-cell {
  border-radius: 2px;
  /* Safari <15 fallback: cells will use the grid row height and may not be square */
}
@supports (aspect-ratio: 1) {
  .gsd-heatmap-cell { aspect-ratio: 1; }
}
.gsd-heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  justify-content: flex-end;
}

/* Bar chart */
.gsd-chart-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.gsd-range-btn {
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--text-secondary);
  font-family: inherit;
  min-height: 28px;
}
.gsd-range-btn--on {
  background: var(--accent-light);
  border-color: var(--accent-border);
  color: var(--accent);
  font-weight: 600;
}
.gsd-bars-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 8px 8px;
  margin-bottom: 0.5rem;
}
.gsd-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 100px;
  overflow: hidden;
}
.gsd-bar-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  height: 100%;
}
.gsd-bar-stack-wrap {
  flex: 1;
  display: flex;
  align-items: flex-end;
}
.gsd-bar-stack {
  width: 100%;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 2px 2px 0 0;
  overflow: hidden;
  min-height: 1px;
}
.gsd-bar-segment { width: 100%; }
.gsd-bar-label {
  font-size: 9px;
  color: var(--text-tertiary);
  text-align: center;
  line-height: 1.4;
  margin-top: 2px;
  overflow: hidden;
}
.gsd-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.gsd-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-secondary);
}
.gsd-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Insights */

/* ── Thread Usage Overlay Legend ─────────────────────────────────────── */
.thread-usage-legend{display:flex;flex-direction:column;gap:4px;font-size:10px;color:var(--text-secondary);}

/* ── Sync UI ──────────────────────────────────────────────────────── */

/* Sync panel on home screen */
.sync-panel { margin-bottom: 20px; }
.sync-panel .home-panel-header { display: flex; align-items: center; gap: 6px; }
.sync-panel-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }

/* Device name */
.sync-device-row { display: flex; align-items: center; gap: 8px; }
.sync-device-label { font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.sync-device-input {
  flex: 1; padding: 5px 8px; border-radius: 6px;
  border: 1px solid var(--border); font-size: 13px;
  font-family: inherit; box-sizing: border-box;
}
.sync-device-name-btn {
  background: none; border: none; font-size: 13px; color: var(--accent);
  cursor: pointer; padding: 0; font-family: inherit;
}
@media (hover: hover){.sync-device-name-btn:hover { text-decoration: underline; }}

/* Timestamps */
.sync-timestamps { display: flex; flex-direction: column; gap: 4px; }
.sync-timestamp { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
.sync-activity-link { background: none; border: none; padding: 0; margin-top: 2px; font-size: 11px; color: var(--accent); cursor: pointer; text-align: left; align-self: flex-start; }
@media (hover: hover){.sync-activity-link:hover { text-decoration: underline; }}

/* Devices in this folder (Concept B) */
.sync-devices-panel { margin: 8px 0; padding: 8px 12px; border-radius: 6px; background: var(--surface-secondary); border: 1px solid var(--border); }
.sync-devices-title { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.sync-devices-list { display: flex; flex-direction: column; gap: 4px; }
.sync-device-row { display: flex; flex-direction: column; gap: 1px; padding: 4px 0; border-top: 0.5px solid var(--border); }
.sync-device-row:first-child { border-top: 0; }
.sync-device-name { font-size: 13px; color: var(--text-primary); display: flex; align-items: center; gap: 6px; }
.sync-device-tag { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); padding: 1px 6px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 12%, transparent); }
.sync-device-meta { font-size: 11px; color: var(--text-tertiary); }
.sync-device-imported { color: var(--success, var(--accent)); font-weight: 500; }
.sync-device-row--mine { /* highlights the row that represents this device */ }

/* Sync Activity modal (Concept A) */
.sync-activity-modal { max-width: 560px; max-height: 80vh; display: flex; flex-direction: column; }
.sync-activity-filters { display: flex; gap: 4px; margin: 0 0 12px; flex-wrap: wrap; }
.sync-activity-filter { background: var(--surface-secondary); border: 1px solid var(--border); border-radius: 4px; padding: 4px 10px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
@media (hover: hover){.sync-activity-filter:hover { color: var(--text-primary); }}
.sync-activity-filter.is-active { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.sync-activity-list { flex: 1 1 auto; overflow-y: auto; min-height: 100px; max-height: 50vh; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-secondary); }
.sync-activity-empty { padding: 24px 16px; text-align: center; font-size: 13px; color: var(--text-tertiary); }
.sync-activity-item { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 0.5px solid var(--border); }
.sync-activity-item:last-child { border-bottom: 0; }
.sync-activity-icon { flex: 0 0 auto; width: 18px; color: var(--text-tertiary); display: flex; align-items: flex-start; padding-top: 2px; }
.sync-activity-icon svg { width: 16px; height: 16px; }
.sync-activity-item--in .sync-activity-icon { color: var(--accent); }
.sync-activity-item--out .sync-activity-icon { color: var(--success, var(--accent)); }
.sync-activity-item--export-fail .sync-activity-icon,
.sync-activity-item--import-fail .sync-activity-icon,
.sync-activity-item--watcher-error .sync-activity-icon,
.sync-activity-item--permission-needed .sync-activity-icon { color: var(--warning, #c08410); }
.sync-activity-body { flex: 1 1 auto; min-width: 0; }
.sync-activity-title-row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.sync-activity-title { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.sync-activity-time { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; flex-shrink: 0; }
.sync-activity-meta { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; word-break: break-all; }
.sync-activity-meta--error { color: var(--warning, #c08410); }

/* Result banner */
.sync-result { padding: 8px 12px; border-radius: 6px; font-size: 13px; }
.sync-result--success { background: var(--success-soft); border: 1px solid var(--success); color: var(--success); }
.sync-result--error { background: var(--danger-soft); border: 1px solid var(--danger-soft); color: var(--danger); }
/* Neutral outcome — e.g. the user dismissed the iOS share sheet, so nothing
   was sent. Not a failure, so it must not read as one. */
.sync-result--info { background: var(--surface-secondary, var(--surface)); border: 1px solid var(--border); color: var(--text-secondary); }

/* Action buttons */
.sync-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sync-action-btn { flex: 1; min-width: 120px; text-align: center; justify-content: center; display: inline-flex; align-items: center; }

/* Hint text */
.sync-hint { margin: 0; font-size: 12px; color: var(--text-tertiary); line-height: 1.5; }

/* Header sync indicator */
.tb-sync-indicator { position: relative; display: inline-flex; align-items: center; }
.tb-sync-indicator--active svg { color: var(--success); }
.tb-sync-indicator--folder svg { color: var(--accent); }
/* Pending-conflicts dot. Absolute-positioned so adding it doesn't reflow
   surrounding nav items. Uses --danger so it inherits the workshop palette
   in both themes. */
.tb-sync-indicator-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger, #C0392B);
  box-shadow: 0 0 0 2px var(--surface, #fff);
  pointer-events: none;
}
/* Unshared-changes dot for devices that sync by file. Accent, not danger:
   nothing is wrong, there is just work to send. */
.tb-sync-indicator-badge--unsent { background: var(--accent); }

/* ── Pairing sync dialogs (relay-sync.js) ─────────────────────────────── */
.relay-dialog { padding: 24px; color: var(--text-primary); }
.relay-dialog h3 { margin: 0 0 8px; font-size: 18px; }
.relay-dialog-lead { margin: 0 0 16px; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.relay-dialog-note { margin: 8px 0 0; color: var(--text-secondary); font-size: 12px; line-height: 1.5; text-align: center; }
.relay-dialog-wait { margin: 24px 0; text-align: center; color: var(--text-secondary); }
.relay-dialog-error { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--radius-md); background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.relay-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
/* QR codes stay black on white in both themes so cameras can read them. */
.relay-qr { width: 220px; max-width: 70vw; margin: 0 auto; border-radius: var(--radius-md); overflow: hidden; }
.relay-qr svg { display: block; width: 100%; height: auto; }
.relay-code { margin: 12px 0 0; text-align: center; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 26px; font-weight: 700; letter-spacing: 3px; }
.relay-scan { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.relay-scan video { display: none; width: 100%; max-height: 260px; border-radius: var(--radius-md); background: var(--surface-tertiary); object-fit: cover; }
.relay-scan--on video { display: block; }
.relay-scan .btn { display: inline-flex; align-items: center; gap: 6px; }
.relay-type { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.relay-type label { width: 100%; font-size: 13px; color: var(--text-secondary); }
.relay-type input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--text-primary); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; letter-spacing: 1px; text-transform: uppercase; }

/* ── Sync status popover (header cloud button) ───────────────────────── */
.sync-popover-wrap { position: relative; display: inline-flex; align-items: center; flex-shrink: 0; }
.sync-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 268px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 250;
  padding: 12px 14px 10px;
  font-size: 13px;
  color: var(--text-primary);
}
/* Arrow pointing up */
.sync-popover::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 12px;
  width: 10px;
  height: 10px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}
.sync-popover-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
}
.sync-popover-header svg { width: 18px; height: 18px; flex-shrink: 0; }
.sync-popover-title { font-weight: 600; font-size: 13px; color: var(--text-primary); flex: 1; }
.sync-popover-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-tertiary); padding: 2px; line-height: 1;
  border-radius: var(--radius-sm);
}
@media (hover: hover){.sync-popover-close:hover { color: var(--text-primary); background: var(--surface-tertiary); }}
.sync-popover-close svg { width: 14px; height: 14px; display: block; }
.sync-popover-row {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 3px 0; font-size: 12px; color: var(--text-secondary);
}
.sync-popover-row svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; color: var(--text-tertiary); }
.sync-popover-row--warn { color: var(--warning, #c08410); }
.sync-popover-row--warn svg { color: var(--warning, #c08410); }
.sync-popover-row--ok svg { color: var(--success); }
.sync-popover-divider { height: 1px; background: var(--line, var(--border)); margin: 8px 0; }
.sync-popover-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 2px; }
.sync-popover-btn {
  font-size: 11px; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-primary);
  cursor: pointer; font-family: inherit; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px;
}
@media (hover: hover){.sync-popover-btn:hover { background: var(--surface-tertiary); }}
.sync-popover-btn--primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
@media (hover: hover){.sync-popover-btn--primary:hover { filter: brightness(1.08); background: var(--accent); }}
.sync-popover-btn svg { width: 12px; height: 12px; }
.sync-popover-help-link {
  display: block; margin-top: 8px; font-size: 11px;
  color: var(--text-tertiary); text-decoration: none; cursor: pointer;
  background: none; border: none; padding: 0; font-family: inherit;
  text-align: left;
}
@media (hover: hover){.sync-popover-help-link:hover { color: var(--accent); text-decoration: underline; }}

/* Folder watch section */
.sync-folder-section { margin-bottom: 8px; }
.sync-folder-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.sync-folder-name { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 500; color: var(--accent); }
.sync-folder-name svg { width: 14px; height: 14px; }
.sync-folder-disconnect { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--text-tertiary); padding: 0 2px; line-height: 1; }
@media (hover: hover){.sync-folder-disconnect:hover { color: var(--danger); }}
.sync-help-icon { background: none; border: none; cursor: help; font-size: 14px; font-weight: 700; color: var(--accent); padding: 0 4px; line-height: 1; min-width: 18px; text-align: center; border-radius: 50%; transition: background 0.2s; }
@media (hover: hover){.sync-help-icon:hover { background: rgba(184, 92, 56, 0.1); }}
.sync-folder-btn { font-size: 12px; padding: 4px 10px; }
.sync-autosync-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.sync-autosync-label { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.sync-autosync-label input[type="checkbox"] { accent-color: var(--accent); }
.sync-autosync-hint { font-size: 11px; color: var(--text-tertiary); }

/* Folder updates banner */
.sync-folder-updates { padding: 8px 12px; border-radius: 6px; background: var(--surface-secondary); border: 1px solid var(--border); margin-bottom: 8px; }
.sync-folder-updates-title { font-size: 13px; font-weight: 600; color: var(--accent); display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.sync-folder-updates-title svg { width: 16px; height: 16px; }
/* Warning variant — used when folder permission was dropped and sync is paused. */
.sync-folder-updates--warn { background: color-mix(in srgb, var(--warning, #c08410) 12%, var(--surface-secondary)); border-color: var(--warning, #c08410); }
.sync-folder-updates--warn .sync-folder-updates-title { color: var(--warning, #c08410); }
.sync-folder-update-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 0.5px solid var(--border); }
.sync-folder-update-info { font-size: 12px; color: var(--text-secondary); }
.sync-folder-update-btn { font-size: 11px; padding: 3px 10px; white-space: nowrap; }

/* ── Sync Summary Modal ──────────────────────────────────────────── */
.sync-summary-modal { max-width: 560px; max-height: 80vh; overflow-y: auto; }
.sync-summary-title { margin: 0 0 12px; font-size: 20px; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.sync-summary-source { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }

/* Stat badges row */
.sync-stats-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.sync-stat-badge {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600;
}
.sync-stat-badge--new { background: var(--accent-light); color: var(--accent); }
.sync-stat-badge--identical { background: var(--surface-tertiary); color: var(--text-tertiary); }
.sync-stat-badge--merge { background: var(--success-soft); color: var(--success); }
.sync-stat-badge--conflict { background: var(--warning-soft); color: var(--accent-ink); }

/* Sections */
.sync-section { margin-bottom: 16px; }
.sync-section-header {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-tertiary); letter-spacing: 0.06em; margin-bottom: 6px;
  padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.sync-section-header--conflict { color: var(--accent-ink); display: flex; align-items: center; gap: 4px; }

/* Project rows */
.sync-project-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; border-bottom: 0.5px solid var(--surface-tertiary);
}
.sync-project-name { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.sync-project-meta { font-size: 12px; color: var(--text-tertiary); }

/* Action buttons */
.sync-summary-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--surface-tertiary); }
.sync-btn { padding: 8px 18px; font-size: 13px; border-radius: 6px; cursor: pointer; font-weight: 500; font-family: inherit; }
.sync-btn--primary { background: var(--accent); color: var(--surface); border: none; }
@media (hover: hover){.sync-btn--primary:hover { background: var(--accent-hover); }}
.sync-btn--primary:disabled { background: var(--border); cursor: not-allowed; }
.sync-btn--secondary { background: var(--surface); color: var(--text-secondary); border: 1px solid var(--border); }
@media (hover: hover){.sync-btn--secondary:hover { background: var(--surface-secondary); }}

/* ── Conflict Card ───────────────────────────────────────────────── */
.sync-conflict-card {
  border: 1px solid var(--warning); border-radius: 8px; padding: 12px;
  margin-bottom: 8px; background: var(--warning-soft);
}
.sync-conflict-card--resolved { border-color: var(--success); background: var(--success-soft); }
.sync-conflict-name { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.sync-conflict-sides { display: flex; gap: 8px; align-items: stretch; margin-bottom: 10px; }
.sync-conflict-side {
  flex: 1; padding: 8px 10px; border-radius: 6px;
  background: rgba(255,255,255,0.7); border: 0.5px solid var(--border);
}
.sync-conflict-side-label { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--text-tertiary); letter-spacing: 0.06em; margin-bottom: 4px; }
.sync-conflict-side-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.sync-conflict-side-meta { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.sync-conflict-side-date { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
.sync-conflict-vs { display: flex; align-items: center; font-size: 11px; font-weight: 700; color: var(--text-tertiary); padding: 0 2px; }

/* Choice buttons */
.sync-conflict-choices { display: flex; gap: 6px; }
.sync-choice-btn {
  flex: 1; padding: 6px 10px; font-size: 12px; font-weight: 500;
  border-radius: 6px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-secondary); cursor: pointer; font-family: inherit; text-align: center;
}
@media (hover: hover){.sync-choice-btn:hover { background: var(--surface-secondary); border-color: var(--border); }}
.sync-choice-btn--active { background: var(--accent); color: var(--surface); border-color: var(--accent); }
@media (hover: hover){.sync-choice-btn--active:hover { background: var(--accent-hover); }}

/* Resolved label */
.sync-conflict-resolved-label {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--success); margin-top: 6px;
}

/* Local-only muted row */
.sync-project-row--muted { opacity: 0.6; }

/* Stash merge preview */
.sync-stash-preview { font-size: 13px; color: var(--text-secondary); padding: 4px 0; }

/* ── Sync Review Gate (SCR-062) ──────────────────────────────────── */
.srg-modal { max-width: 520px; max-height: 85vh; display: flex; flex-direction: column; }
.srg-header { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; flex-shrink: 0; }
.srg-header svg { flex-shrink: 0; }
.srg-header-title { margin: 0; font-size: 18px; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.srg-header-sub { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.srg-body { flex: 1; overflow-y: auto; padding: 4px 0 8px; }
.srg-loading { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-secondary); padding: 32px 0; justify-content: center; }
.srg-empty-state { text-align: center; padding: 32px 0; color: var(--text-secondary); }
.srg-empty-icon { margin-bottom: 8px; display: flex; justify-content: center; }
.srg-empty-icon svg { width: 36px; height: 36px; color: var(--success); }
.srg-empty-heading { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.srg-empty-body { font-size: 13px; color: var(--text-secondary); }
.srg-body-text { font-size: 14px; color: var(--text-secondary); margin: 12px 0; }
.srg-notice { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); background: var(--surface-secondary); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 12px; }
.srg-section { margin-bottom: 8px; }
.srg-section-heading { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); margin-bottom: 8px; }
.srg-section-divider { height: 1px; background: var(--line); margin-bottom: 12px; }
.srg-summary-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.srg-summary-icon { display: flex; align-items: center; flex-shrink: 0; }
.srg-summary-icon svg { width: 16px; height: 16px; }
.srg-conflicts-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.srg-conflicts-heading { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.srg-counter-chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--surface-secondary); color: var(--text-secondary); border: 1px solid var(--line); }
.srg-counter-chip--complete { background: var(--success); color: #fff; border-color: var(--success); }
.srg-conflict-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px; transition: opacity var(--motion); }
.srg-conflict-card--resolved { opacity: 0.75; }
.srg-conflict-subject { margin-bottom: 8px; }
.srg-conflict-subject-text { display: block; font-size: 13px; font-weight: 600; color: var(--text-primary); }
.srg-conflict-subject-sub { display: block; font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.srg-conflict-sides { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; margin-bottom: 10px; }
.srg-value-block { background: var(--surface-secondary); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 10px; }
.srg-value-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); margin-bottom: 3px; }
.srg-value-content { font-size: 13px; color: var(--text-primary); word-break: break-word; }
.srg-conflict-vs { font-size: 11px; font-weight: 700; color: var(--text-tertiary); text-align: center; }
.srg-conflict-choices { display: flex; gap: 6px; }
.srg-choice-btn { flex: 1; padding: 6px 10px; font-size: 12px; font-weight: 500; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text-secondary); cursor: pointer; font-family: inherit; text-align: center; transition: background var(--motion), border-color var(--motion); display: flex; align-items: center; justify-content: center; gap: 4px; }
@media (hover: hover){.srg-choice-btn:hover { background: var(--surface-secondary); }}
.srg-choice-btn--chosen { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.srg-choice-btn--chosen svg { color: var(--accent); }
.srg-resolution-badge { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--success); margin-top: 6px; }
.srg-resolution-badge svg { width: 14px; height: 14px; }
.srg-error-row { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--danger, #c0392b); margin-top: 8px; }
.srg-footer { display: flex; justify-content: flex-end; padding-top: 12px; border-top: 1px solid var(--line); margin-top: 8px; flex-shrink: 0; }
.srg-btn { padding: 9px 22px; font-size: 14px; font-weight: 600; border-radius: var(--radius-sm); border: none; cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 6px; }
.srg-btn--primary { background: var(--accent); color: var(--surface); }
@media (hover: hover){.srg-btn--primary:hover:not([aria-disabled="true"]) { background: var(--accent-hover, var(--accent)); }}
.srg-btn--primary[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.srg-btn--applying { opacity: 0.8; cursor: wait; }
@media (max-width: 400px) { .srg-conflict-sides { grid-template-columns: 1fr; } .srg-conflict-vs { display: none; } }

/* ── Visual conflict diff (Tier-2). Shown above the sides row for chart
   and stitch conflicts. Three thumbnails (Local | Diff | Remote) plus
   a colour legend. Below 400 px the thumbnails stack vertically and
   shrink to 120 × 120 so they still fit alongside the choice buttons. */
.srg-diff-viewer { margin: 0 0 10px; padding: 8px 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); }
.srg-diff-summary { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.srg-diff-toggle { background: none; border: none; padding: 0; color: var(--accent); font-size: 12px; font-weight: 500; cursor: pointer; font-family: inherit; }
@media (hover: hover){.srg-diff-toggle:hover { text-decoration: underline; }}
.srg-diff-thumbnails { display: flex; gap: 12px; justify-content: space-around; margin-top: 8px; flex-wrap: wrap; }
.srg-thumbnail-figure { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 0; }
.srg-thumbnail { display: block; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-secondary); width: 240px; height: 240px; object-fit: contain; }
.srg-thumbnail-caption { font-size: 11px; color: var(--text-secondary); }
.srg-diff-legend { font-size: 11px; color: var(--text-secondary); margin-top: 8px; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 4px; }
.srg-legend-item { display: flex; align-items: center; gap: 4px; }
.srg-legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
@media (max-width: 400px) {
  .srg-diff-thumbnails { flex-direction: column; align-items: center; }
  .srg-thumbnail { width: 120px; height: 120px; }
  .srg-diff-legend { grid-template-columns: 1fr 1fr; }
}


.thread-usage-legend>div{display:flex;align-items:center;gap:6px;}
.tul-swatch{display:inline-block;width:14px;height:10px;border-radius:2px;flex-shrink:0;}
.gsd-insights {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 0.5rem;
}
@media (min-width: 600px) {
  .gsd-insights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.gsd-insight {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  min-height: 44px;
}
.gsd-insight-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  font-size: 15px;
}
.gsd-insight-icon--teal { background: var(--accent-light); color: var(--success); }
.gsd-insight-icon--amber { background: var(--warning-soft); color: var(--accent-ink); }
.gsd-insight-icon--purple { background: var(--accent-light); color: var(--accent); }
.gsd-insight-icon--coral { background: var(--surface-secondary); color: var(--accent); }
.gsd-insight-icon--blue { background: var(--surface-secondary); color: var(--accent); }
.gsd-insight-text { font-size: 13px; color: var(--text-primary); line-height: 1.5; flex: 1; }

/* Session timeline */
.gsd-timeline { margin-bottom: 1.5rem; }
.gsd-tl-day { margin-bottom: 16px; }
.gsd-tl-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.gsd-tl-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  min-height: 44px;
}
.gsd-tl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.gsd-tl-body { flex: 1; min-width: 0; }
.gsd-tl-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.gsd-tl-meta { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.gsd-tl-note { font-size: 12px; color: var(--text-tertiary); font-style: italic; margin-top: 2px; }
.gsd-tl-stitches { font-size: 13px; font-weight: 600; color: var(--accent); flex-shrink: 0; }
.gsd-tl-milestone {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  min-height: 44px;
}
.gsd-tl-milestone-icon { font-size: 16px; flex-shrink: 0; color: var(--accent-ink); }


/* --- Multi-Project Dashboard (mpd-*) ------------------------------- */

.home-panels--dashboard-footer { margin-top: 16px; }

.mpd { display: flex; flex-direction: column; gap: 16px; width: 100%; }

/* Summary bar */
.mpd-summary-bar {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  font-size: 13px; color: var(--text-secondary);
  background: var(--surface-tertiary); border-radius: var(--radius-md);
  padding: 8px 14px; align-items: center;
}
.mpd-streak { font-weight: 600; color: var(--accent-ink); }

/* Suggestion card */
.mpd-suggestion {
  background: var(--warning-soft); border: 1px solid var(--warning);
  border-radius: var(--radius-lg); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.mpd-suggestion-title { font-size: 14px; font-weight: 600; color: var(--accent-ink); }
.mpd-suggestion-reason { font-size: 13px; color: var(--accent-ink); }

/* Empty active message */
.mpd-empty-active {
  font-size: 14px; color: var(--text-secondary);
  text-align: center; padding: 20px;
  border: 1px dashed var(--border); border-radius: var(--radius-lg);
}

/* Project cards grid */
.mpd-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 14px;
}

/* Individual project card */
.mpd-card {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  overflow: hidden; background: var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  transition: box-shadow 0.15s;
}
@media (hover: hover){.mpd-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }}
.mpd-card-thumb {
  height: 90px; overflow: hidden; background: var(--surface-tertiary);
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.mpd-card-thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* A drawn pattern preview keeps its shape and zooms in to fill the 90px strip,
   centred. The zoom stops at twice the whole-pattern size, so at most half the
   pattern is cropped; a very wide pattern can leave space above and below.
   --ar (pattern width / height) is set on .mpd-card-thumb by home-screen.js. */
.mpd-card-thumb-img--pattern {
  flex: none; max-width: none; max-height: none;
  width: min(max(100%, calc(90px * var(--ar, 1))), calc(2 * min(100%, calc(90px * var(--ar, 1))))) !important;
  height: auto !important;
  object-fit: contain; background: transparent !important; border-radius: 0 !important;
}
.mpd-card-thumb-placeholder { width: 100%; height: 100%; background: var(--surface-tertiary); }
.mpd-card-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.mpd-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.mpd-card-name {
  font-weight: 600; font-size: 14px; color: var(--text-primary);
  cursor: pointer; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (hover: hover){.mpd-card-name:hover { color: var(--accent); }}
.mpd-card-pct { font-size: 13px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.mpd-card-pct--done { color: var(--success); }
.mpd-card-progress { display: flex; align-items: center; gap: 8px; }
.mpd-card-progress-track {
  flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.mpd-card-progress-fill {
  height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s;
}
.mpd-card-difficulty {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border: 1.5px solid currentColor;
  border-radius: 999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.mpd-card-meta { font-size: 12px; color: var(--text-tertiary); display: flex; gap: 4px; align-items: center; }
.mpd-card-sep { color: var(--text-tertiary); }
.mpd-card-recency { font-size: 12px; color: var(--text-secondary); }
.mpd-card-recency--warn { color: var(--accent-ink); font-weight: 500; }
.mpd-card-session { font-size: 12px; color: var(--text-secondary); }
.mpd-card-estimate { font-size: 12px; color: var(--text-tertiary); }
.mpd-card-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 4px; gap: 8px;
}
.mpd-card-stash { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.mpd-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Shared button styles */
.mpd-btn {
  font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer;
  border-radius: var(--radius-md); padding: 5px 12px; border: none; transition: background 0.15s;
}
.mpd-btn--primary { background: var(--accent); color: var(--surface); }
@media (hover: hover){.mpd-btn--primary:hover { background: var(--accent-hover); }}
.mpd-btn--ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border); padding: 4px 8px;
}
@media (hover: hover){.mpd-btn--ghost:hover { background: var(--surface-tertiary); color: var(--text-primary); }}

/* Section headers (queued / paused / completed) */
.mpd-section { display: flex; flex-direction: column; gap: 0; }
.mpd-section-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px;
}
.mpd-section-count {
  background: var(--surface-tertiary); color: var(--text-secondary);
  font-size: 11px; font-weight: 700; border-radius: 20px;
  padding: 1px 7px; min-width: 20px; text-align: center;
}
.mpd-section-add {
  margin-left: auto; font-size: 12px; padding: 3px 10px;
}
.mpd-section-collapse-hdr {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  text-align: left; padding: 8px 0; display: flex; align-items: center; gap: 6px;
  width: 100%; transition: color 0.15s;
}
@media (hover: hover){.mpd-section-collapse-hdr:hover { color: var(--text-primary); }}
.mpd-collapse-arrow { font-size: 11px; color: var(--text-tertiary); width: 12px; }
.mpd-empty-msg { font-size: 13px; color: var(--text-tertiary); padding: 8px 0 4px; }

/* Compact project row (queued / paused / completed) */
.mpd-compact-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border-subtle);
}
.mpd-compact-row:last-child { border-bottom: none; }
.mpd-compact-thumb {
  width: 36px; height: 36px; flex-shrink: 0; overflow: hidden;
  background: var(--surface-tertiary); border-radius: 4px; cursor: pointer;
}
.mpd-compact-thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mpd-compact-thumb-placeholder { width: 100%; height: 100%; background: var(--surface-tertiary); }
.mpd-compact-info {
  flex: 1; display: flex; flex-direction: column; gap: 2px; cursor: pointer;
  min-width: 0;
}
.mpd-compact-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (hover: hover){.mpd-compact-name:hover { color: var(--accent); }}
.mpd-compact-detail { font-size: 12px; color: var(--text-tertiary); }
.mpd-compact-menu-btn { padding: 4px 8px; margin-left: auto; }

/* State change menu popover */
.mpd-state-menu {
  position: absolute; top: 100%; right: 0; z-index: 200;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 6px 24px rgba(0,0,0,0.13);
  min-width: 180px; padding: 6px 0; margin-top: 2px;
}
.mpd-state-menu-title {
  font-size: 11px; font-weight: 700; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 6px 14px 4px;
}
.mpd-state-menu-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 13px; color: var(--text-primary);
  padding: 8px 14px; transition: background 0.1s;
}
@media (hover: hover){.mpd-state-menu-item:hover { background: var(--surface-tertiary); }}
.mpd-state-menu-item--danger { color: var(--danger, #d33); }
@media (hover: hover){.mpd-state-menu-item--danger:hover { background: rgba(211, 51, 51, 0.08); }}

/* Stats link */
.mpd-stats-link {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 500; color: var(--accent);
  text-align: left; padding: 8px 0; transition: color 0.15s;
}
@media (hover: hover){.mpd-stats-link:hover { color: var(--accent-hover); text-decoration: underline; }}

/* Card menu button */
.mpd-card-menu-btn { min-width: 32px; text-align: center; padding: 4px 8px; }

/* ------------------------- Mobile / touch overrides (WU-8) -------------------------
   Mobile-first per project convention: defaults are desktop, this block layers on top
   for touch + narrow viewports only. Increases the smallest font sizes to ~13px and
   guarantees a 44x44 touch area on the densest UI controls. */
@media (pointer: coarse) and (max-width: 1024px) {
  /* Touch-target floor (WCAG 2.5.5) for the smallest tap targets in the app */
  .tb-btn, .tb-fit-btn, .tb-app-tab, .tb-page-btn, .rp-tab,
  .cs-cmdp-row, .mpd-card-menu-btn,
  /* A4 (UX Phase 5) — extend the floor to home & dashboard buttons,
     context-bar quick-actions, and the resume recap modal CTAs. */
  .home-btn, .mpd-btn, .tb-context-btn, .resume-recap-btn,
  .tb-nav-link, .tb-context-name--editable, .tb-proj-badge-name--editable {
    min-height: 44px;
  }
  .home-btn, .mpd-btn { padding: 10px 16px; }
  .tb-btn { padding: 8px 12px; gap: 6px; }
  .tb-fit-btn { padding: 8px 12px; }
  /* Bump tiny labels so they meet the 12px+ legibility floor */
  .tb-zoom-lbl, .tb-zoom-pct, .tb-progress-txt, .tb-progress-rem,
  .tb-status, .tb-ovf-lbl, .tb-proj-badge-name, .tb-proj-badge-pct {
    font-size: 13px;
  }
  .tb-btn, .rp-tab, .tb-fit-btn, .tb-app-tab, .tb-app-nav .tb-app-tab, .tb-page-btn { font-size: 13px; }
}

/* ═══════════════════════════════════════════════════════════════════
   Thread Stash and Shopping list (redesign option 1, docs/stash-redesign).
   An owned-first list edited in place. Replaces the 1,229-card grid, its
   side panel and the stacked alert panels.
   ═══════════════════════════════════════════════════════════════════ */
.mgr-tabs{display:flex;align-items:center;gap:4px;min-width:0;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;}
.mgr-tabs::-webkit-scrollbar{display:none;}
.mgr-tabs .mgr-tab{flex-shrink:0;white-space:nowrap;}
a.mgr-tab{text-decoration:none;}
.mgr-tab:focus-visible{outline:2px solid var(--accent);outline-offset:-2px;}
/* Navigation shell (hub plan, Phase 3): the <nav> is the tab bar on
   narrow screens and a left side menu from 1024px. */
.mgr-shell{flex:1;min-height:0;display:flex;flex-direction:column;}
.mgr-shell-main{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;}
.mgr-nav-secondary{display:none;}
.mgr-nav-sep{display:block;height:1px;margin:8px 6px;background:var(--border);}
@media (min-width: 1024px){
  .mgr-shell{flex-direction:row;}
  .mgr-nav.mgr-tab-bar{flex-direction:column;align-items:stretch;justify-content:flex-start;gap:2px;width:228px;height:auto;padding:14px 10px;overflow-y:auto;border-bottom:0;border-right:1px solid var(--border);}
  .mgr-nav .mgr-tabs{flex-direction:column;align-items:stretch;gap:2px;overflow:visible;}
  .mgr-nav .mgr-tab{width:100%;justify-content:flex-start;padding:9px 12px;border-radius:var(--radius-md);}
  .mgr-nav .mgr-tab .cnt{margin-left:auto;}
  .mgr-nav .mgr-tab.on{background:var(--accent-soft);color:var(--accent-text);box-shadow:none;}
  .mgr-nav .mgr-tab.on .cnt{background:var(--surface);color:var(--accent-text);}
  .mgr-nav-secondary{display:flex;flex-direction:column;gap:2px;}
  .mgr-nav .mgr-showcase{margin-top:auto;justify-content:flex-start;padding:9px 12px;}
}
.mgr-showcase{display:inline-flex;align-items:center;gap:6px;flex-shrink:0;min-height:36px;padding:0 14px;font-size:12px;font-weight:600;color:var(--accent-text);background:none;border:none;border-radius:var(--radius-md);cursor:pointer;font-family:inherit;white-space:nowrap;}
.mgr-showcase svg{width:15px;height:15px;}
.mgr-showcase:focus-visible{outline:2px solid var(--accent);outline-offset:-2px;}

.stash-page{flex:1;min-height:0;overflow-y:auto;padding:16px 20px 40px;display:flex;flex-direction:column;gap:12px;}
.stash-page>*{flex-shrink:0;width:100%;max-width:1200px;margin-left:auto;margin-right:auto;}

/* Toolbar: wraps instead of hiding controls off-screen. */
.stash-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px;}
.stash-search{flex:1 1 260px;max-width:420px;display:flex;align-items:center;gap:8px;min-height:38px;padding:0 12px;border:1px solid var(--border);border-radius:var(--radius-md);background:var(--surface);color:var(--text-tertiary);}
.stash-search:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft);}
.stash-search svg{width:16px;height:16px;flex-shrink:0;}
.stash-search input{flex:1;min-width:0;height:36px;border:0;background:transparent;font:inherit;font-size:13px;color:var(--text-primary);outline:none;}
.stash-seg{display:flex;flex-wrap:wrap;gap:2px;padding:3px;background:var(--surface-tertiary);border-radius:var(--radius-lg);}
.stash-seg button{display:inline-flex;align-items:center;gap:6px;min-height:32px;padding:0 11px;border:0;border-radius:var(--radius-md);background:transparent;color:var(--text-secondary);font:inherit;font-size:12.5px;font-weight:600;cursor:pointer;white-space:nowrap;}
.stash-seg button.on{background:var(--surface);color:var(--text-primary);box-shadow:var(--shadow-sm);}
.stash-seg button:focus-visible{outline:2px solid var(--accent);outline-offset:-2px;}
.stash-seg .n{font-size:11px;font-weight:700;color:var(--text-tertiary);font-variant-numeric:tabular-nums;}
.stash-toolbar-end{margin-left:auto;display:flex;flex-wrap:wrap;gap:8px;}

/* Buttons */
.stash-btn{display:inline-flex;align-items:center;gap:6px;min-height:34px;padding:0 12px;border:1px solid var(--border);border-radius:var(--radius-md);background:var(--surface);color:var(--text-primary);font:inherit;font-size:12.5px;font-weight:600;cursor:pointer;white-space:nowrap;}
.stash-btn svg{width:15px;height:15px;flex-shrink:0;}
@media (hover: hover){.stash-btn:not(:disabled):hover{border-color:var(--line-2);background:var(--surface-secondary);}}
.stash-btn:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}
.stash-btn:disabled{opacity:.5;cursor:default;}
.stash-btn--primary{background:var(--accent);border-color:var(--accent);color:var(--text-on-accent);}
@media (hover: hover){.stash-btn--primary:not(:disabled):hover{background:var(--accent-hover);border-color:var(--accent-hover);}}
.stash-btn--quiet{border-color:transparent;background:transparent;color:var(--text-secondary);}
.stash-btn--danger{color:var(--danger);}
.stash-btn--icon{display:inline-flex;min-width:34px;justify-content:center;padding:0;}

/* View and Add threads menus */
.stash-menu{position:relative;}
.stash-menu-panel{position:absolute;top:calc(100% + 6px);left:0;z-index:60;min-width:250px;padding:6px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-lg);}
.stash-menu--end .stash-menu-panel{left:auto;right:0;}
.stash-menu-list{display:flex;flex-direction:column;}
.stash-menu-list button{display:flex;align-items:flex-start;gap:10px;padding:9px 10px;border:0;border-radius:var(--radius-md);background:transparent;color:var(--text-primary);font:inherit;text-align:left;cursor:pointer;}
@media (hover: hover){.stash-menu-list button:hover{background:var(--surface-tertiary);}}
.stash-menu-list button:focus-visible{outline:2px solid var(--accent);outline-offset:-2px;}
.stash-menu-list svg{width:18px;height:18px;margin-top:1px;flex-shrink:0;color:var(--text-secondary);}
.stash-menu-list b{display:block;font-size:13px;}
.stash-menu-list small{display:block;margin-top:1px;font-size:12px;color:var(--text-secondary);}
.stash-view-panel{display:grid;gap:10px;padding:8px;}
.stash-view-panel label{display:grid;gap:4px;font-size:12px;font-weight:600;color:var(--text-secondary);}
.stash-view-panel select{min-height:34px;padding:4px 8px;}

/* One-line attention summary (replaces the stacked alert panels). */
.stash-attention{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px;padding:9px 12px;background:var(--surface);border:1px solid var(--border);border-left:4px solid var(--warning);border-radius:var(--radius-lg);}
.stash-attention p{flex:1 1 280px;min-width:0;margin:0;font-size:13px;color:var(--text-secondary);}
.stash-attention b{color:var(--text-primary);}
.stash-attention-icon{display:flex;color:var(--warning);}
.stash-attention-icon svg{width:18px;height:18px;}

/* The list */
.stash-list-wrap{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-xl);overflow:hidden;}
.stash-list{list-style:none;margin:0;padding:0;}
/* Every track has an explicit minimum, so the header and each row resolve
   to the same columns, and the narrowest the row can be (~600px with touch
   targets) fits the list between the phone layout (761px) and the side menu
   (1024px plus 228px). --stash-tap is the stepper button and arrow size. */
.stash-list-wrap{--stash-tap:32px;}
.stash-list-head,.stash-row-main{display:grid;grid-template-columns:minmax(150px,1.3fr) calc(var(--stash-tap) * 2 + 48px) 104px minmax(0,1.4fr) minmax(80px,.6fr) var(--stash-tap);gap:12px;align-items:center;padding:6px 12px;}
.stash-list-head{padding-top:8px;padding-bottom:8px;background:var(--surface-secondary);border-bottom:1px solid var(--border-subtle);font-size:11px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:var(--text-tertiary);}
.stash-row{border-bottom:1px solid var(--border-subtle);content-visibility:auto;contain-intrinsic-size:auto 54px;}
.stash-row:last-child{border-bottom:0;}
.stash-row.is-open .stash-row-main{background:var(--accent-soft);}
.stash-ident{display:flex;align-items:center;gap:10px;min-width:0;padding:4px 0;border:0;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer;border-radius:var(--radius-sm);}
.stash-ident:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}
span.stash-ident{cursor:default;}
.stash-swatch{width:30px;height:30px;flex-shrink:0;border-radius:var(--radius-md);box-shadow:inset 0 0 0 1px rgba(0,0,0,.14);}
.stash-swatch--sm{width:16px;height:16px;border-radius:var(--radius-xs);}
.stash-id{display:grid;grid-template-columns:auto 1fr;column-gap:6px;align-items:baseline;min-width:0;}
.stash-code{font-size:14px;font-weight:700;}
.stash-brand{justify-self:start;padding:0 4px;font-size:10px;font-weight:700;line-height:15px;letter-spacing:.04em;text-transform:uppercase;color:var(--text-tertiary);border:1px solid var(--border);border-radius:var(--radius-xs);}
.stash-brand--anchor{color:var(--accent-text);border-color:var(--accent-border);background:var(--accent-soft);}
.stash-name{grid-column:1 / -1;min-width:0;overflow:hidden;font-size:12px;color:var(--text-tertiary);text-overflow:ellipsis;white-space:nowrap;}
.stash-muted{font-size:12px;color:var(--text-tertiary);}

/* Skein stepper: type a number or step by one. */
.stash-stepper{display:inline-flex;align-items:center;justify-self:start;overflow:hidden;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);}
.stash-stepper button{display:grid;place-items:center;width:32px;height:32px;padding:0;border:0;background:transparent;color:var(--text-secondary);cursor:pointer;}
@media (hover: hover){.stash-stepper button:not(:disabled):hover{background:var(--surface-tertiary);color:var(--text-primary);}}
.stash-stepper button:disabled{opacity:.35;cursor:default;}
.stash-stepper button:focus-visible{outline:2px solid var(--accent);outline-offset:-2px;}
.stash-stepper svg{width:14px;height:14px;}
.stash-stepper input{width:44px;height:32px;padding:0;border:0;border-left:1px solid var(--border-subtle);border-right:1px solid var(--border-subtle);background:transparent;color:var(--text-primary);font:inherit;font-size:14px;font-weight:700;font-variant-numeric:tabular-nums;text-align:center;-moz-appearance:textfield;appearance:textfield;}
.stash-stepper input::-webkit-outer-spin-button,.stash-stepper input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0;}
.stash-stepper input:focus{outline:2px solid var(--accent);outline-offset:-2px;}

/* Opened-skein level and status */
.stash-opened{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--text-secondary);white-space:nowrap;}
.stash-opened.is-none{color:var(--text-tertiary);}
.stash-level{flex-shrink:0;}
.stash-level circle{fill:none;stroke:var(--text-tertiary);stroke-width:1.3;}
.stash-level--empty circle{stroke-dasharray:2 2;}
.stash-level-fill{fill:var(--accent);}
.stash-uses{display:flex;flex-wrap:wrap;gap:4px;min-width:0;}
.stash-chip{max-width:100%;overflow:hidden;padding:2px 7px;font-size:11.5px;font-weight:600;color:var(--text-secondary);text-overflow:ellipsis;white-space:nowrap;background:var(--surface-tertiary);border-radius:var(--radius-sm);}
.stash-chip--quiet{background:transparent;border:1px dashed var(--border);}
.stash-status{display:flex;flex-wrap:wrap;gap:4px;}
.stash-pill{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;font-size:11.5px;font-weight:700;white-space:nowrap;border-radius:var(--radius-pill);}
.stash-pill svg{width:12px;height:12px;}
.stash-pill--short{background:var(--danger-soft);color:var(--danger);}
.stash-pill--low{background:var(--warning-soft);color:var(--accent-ink);}
.stash-pill--list{background:var(--accent-soft);color:var(--accent-text);}
.stash-chev{display:grid;place-items:center;width:32px;height:32px;padding:0;border:0;border-radius:var(--radius-md);background:transparent;color:var(--text-tertiary);cursor:pointer;}
@media (hover: hover){.stash-chev:hover{background:var(--surface-tertiary);color:var(--text-primary);}}
.stash-chev:focus-visible{outline:2px solid var(--accent);outline-offset:-2px;}
.stash-chev svg{width:16px;height:16px;}

/* Rows for shades you don't own (Every shade, search results). */
.stash-row--add .stash-row-main{grid-template-columns:minmax(150px,1.3fr) minmax(0,1.4fr) minmax(80px,.6fr) auto;}
.stash-add{color:var(--accent-text);}

/* The editor under an expanded row (replaces the side panel). */
.stash-row-edit{display:flex;flex-wrap:wrap;gap:14px 28px;padding:12px 12px 14px 52px;background:var(--surface-secondary);border-top:1px solid var(--border-subtle);}
.stash-field{display:flex;flex-direction:column;align-items:flex-start;gap:6px;min-width:0;}
.stash-field--grow{flex:1 1 200px;}
.stash-field-label{font-size:11px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:var(--text-tertiary);}
.stash-hint{font-size:11.5px;color:var(--text-tertiary);}
.stash-levels{display:inline-flex;flex-wrap:wrap;overflow:hidden;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);}
.stash-levels button{min-height:32px;padding:0 11px;border:0;border-right:1px solid var(--border-subtle);background:transparent;color:var(--text-secondary);font:inherit;font-size:12.5px;font-weight:600;cursor:pointer;}
.stash-levels button:last-child{border-right:0;}
.stash-levels button.on{background:var(--accent);color:var(--text-on-accent);}
.stash-levels button:focus-visible{outline:2px solid var(--accent);outline-offset:-2px;}
.stash-needs{display:grid;gap:3px;min-width:180px;margin:0;padding:0;list-style:none;font-size:12.5px;}
.stash-needs li{display:flex;justify-content:space-between;gap:12px;}
.stash-needs b{white-space:nowrap;}
.lbl-short{display:none;}
.stash-actions{flex-direction:row;flex-wrap:wrap;gap:8px;margin-left:auto;}

.stash-more{display:flex;margin:10px auto;}
.stash-group{margin:0;padding:10px 12px;font-size:11px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:var(--text-tertiary);background:var(--surface-secondary);border-bottom:1px solid var(--border-subtle);}
.stash-empty{margin:0;padding:28px 16px;font-size:14px;color:var(--text-secondary);text-align:center;background:var(--surface);border:1px dashed var(--border);border-radius:var(--radius-xl);}
.stash-empty-wrap{padding:12px 0;}

/* Shopping list tab */
.stash-card{display:flex;flex-direction:column;gap:10px;padding:14px 16px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-xl);}
.stash-card-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px;}
.stash-card-head h2{display:flex;align-items:center;gap:8px;margin:0;font-size:16px;font-weight:800;}
.stash-card-head h2 svg{width:18px;height:18px;color:var(--text-secondary);}
.stash-card-action{margin-left:auto;}
.stash-shop-list{margin:0;padding:0;list-style:none;}
.stash-shop-row{--stash-tap:34px;display:grid;grid-template-columns:var(--stash-tap) minmax(150px,1.2fr) minmax(0,1.6fr) auto var(--stash-tap);gap:12px;align-items:center;padding:6px 0;border-bottom:1px solid var(--border-subtle);}
.stash-shop-row.is-ticked{background:var(--success-soft);margin:0 -16px;padding-left:16px;padding-right:16px;}
.stash-tick{display:grid;place-items:center;width:34px;height:34px;border-radius:var(--radius-md);cursor:pointer;}
.stash-tick input{width:20px;height:20px;margin:0;accent-color:var(--success);cursor:pointer;}
.stash-tick:focus-within{outline:2px solid var(--accent);outline-offset:-2px;}
.stash-shop-hint{margin:-4px 0 0;}
/* Phone shopping checklist (hub plan, Phase 5): grouped by pattern, with
   Copy and Done pinned to the bottom of the screen. */
.stash-shop-group+.stash-shop-group{margin-top:12px;}
.stash-shop-group-title{margin:0;padding:6px 0;font-size:11px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:var(--text-tertiary);border-bottom:1px solid var(--border-subtle);}
.stash-shop-footer{position:sticky;bottom:0;z-index:5;display:flex;gap:8px;width:auto;max-width:none;margin:0 -12px -88px;padding:10px 12px calc(10px + env(safe-area-inset-bottom, 0px));background:var(--surface);border-top:1px solid var(--border);box-shadow:0 -4px 12px rgba(0,0,0,.06);}
.stash-shop-footer .stash-btn{flex:1 1 0;justify-content:center;min-height:48px;font-size:14px;}
.stash-shop-footer .stash-btn--primary{flex:2 1 0;}
/* On phones the document scrolls, not the page; let the footer stick to
   the screen rather than to a box that never scrolls. */
@media (max-width: 760px){.stash-page.stash-shop{overflow:visible;}}
.stash-shop-row:last-child{border-bottom:0;}
.stash-shop-qty{font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap;}
.stash-page .stash-alert{margin-bottom:0;}
.stash-page .stash-alert:not(.warn):not(.danger):not(.quiet){background:var(--surface);border:1px solid var(--border);}
.stash-alert-desc{margin:0 0 8px;font-size:12.5px;color:var(--text-secondary);}
.stash-alert-list{display:flex;flex-direction:column;gap:4px;max-height:240px;margin:0;padding:0;overflow:auto;list-style:none;}
.stash-alert-row{display:flex;flex-wrap:wrap;align-items:center;gap:4px 8px;width:100%;padding:7px 10px;background:var(--surface);color:var(--text-primary);font:inherit;font-size:12.5px;text-align:left;border:1px solid var(--border);border-radius:var(--radius-md);cursor:pointer;}
@media (hover: hover){.stash-alert-row:hover{border-color:var(--line-2);}}
.stash-alert-row:focus-visible{outline:2px solid var(--accent);outline-offset:1px;}
.stash-alert-row .stash-name{flex:1 1 120px;}
.stash-alert-qty{font-weight:700;color:var(--text-secondary);white-space:nowrap;}
.stash-alert-who{flex-basis:100%;padding-left:24px;font-size:11.5px;color:var(--text-tertiary);}
.stash-alert-foot{margin-top:10px;}

/* Project materials (inside the Shopping list tab) */
.stash-details summary{font-size:13px;font-weight:600;color:var(--accent-text);cursor:pointer;}
.stash-details p{max-width:75ch;margin:6px 0 0;font-size:13px;color:var(--text-secondary);}
.stash-subhead{margin:4px 0 0;font-size:13px;font-weight:700;}
.stash-plain-list{display:grid;gap:2px;margin:0;padding-left:18px;font-size:13px;}
.stash-material-group{display:flex;flex-direction:column;gap:8px;padding-top:10px;border-top:1px solid var(--border-subtle);}
.stash-material-head{display:flex;flex-wrap:wrap;align-items:center;gap:10px;}
.stash-material-head h3{flex:1 1 auto;margin:0;font-size:14px;font-weight:700;}
.stash-sub-note{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:0;font-size:12.5px;}
.stash-table-wrap{overflow-x:auto;border:1px solid var(--border-subtle);border-radius:var(--radius-md);}
.stash-table{width:100%;border-collapse:collapse;font-size:12.5px;font-variant-numeric:tabular-nums;}
.stash-table caption{padding:6px 10px;font-size:11.5px;color:var(--text-tertiary);text-align:left;caption-side:top;}
.stash-table th,.stash-table td{padding:6px 10px;text-align:left;white-space:nowrap;border-top:1px solid var(--border-subtle);}
.stash-table thead th{font-size:11px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--text-tertiary);background:var(--surface-secondary);}
.stash-table td.is-short{font-weight:700;color:var(--danger);}
.stash-inline-form{display:flex;align-items:center;gap:6px;}
.stash-inline-form input{width:100px;min-height:30px;padding:2px 8px;background:var(--surface);color:var(--text-primary);font:inherit;border:1px solid var(--border);border-radius:var(--radius-sm);}
.stash-inline-form .stash-btn{min-height:30px;}
.stash-error{margin:0;font-size:13px;color:var(--danger);}
.stash-form-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px;}

/* Import and export page */
.stash-page-title{margin:0;font-size:22px;font-weight:800;letter-spacing:-.01em;}
.stash-card-title{display:flex;align-items:center;gap:8px;margin:0;font-size:15px;font-weight:800;}
.stash-card-title svg{width:18px;height:18px;color:var(--text-secondary);}
.stash-transfer{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;}
.stash-transfer .stash-card p{margin:0;}
.stash-transfer>.stash-card:last-child:nth-child(odd){grid-column:1 / -1;}
@media (max-width: 760px){.stash-transfer{grid-template-columns:minmax(0,1fr);}}

/* Stock-take (hub plan, Phase 4): a dialog on desktop, the whole screen
   on phones; the number pad shows on touch screens. */
.overlay-panel.stash-st{display:flex;flex-direction:column;max-height:calc(100dvh - 32px);}
.stash-st-head{display:flex;align-items:center;gap:12px;padding:14px 18px;border-bottom:1px solid var(--border);}
.stash-st-head h2{margin:0;font-size:18px;font-weight:800;}
.stash-st-head .stash-btn{margin-left:auto;}
.stash-st-body{display:flex;flex:1;flex-direction:column;gap:14px;min-height:0;padding:16px 18px 18px;overflow-y:auto;}
.stash-st-thread{display:grid;justify-items:center;gap:8px;text-align:center;}
.stash-st-thread .stash-stepper{justify-self:center;}
.stash-st-swatch{width:88px;height:88px;border-radius:20px;box-shadow:inset 0 0 0 1px rgba(0,0,0,.14);}
.stash-st-code{font-size:24px;font-weight:800;letter-spacing:-.01em;}
.stash-pill--quiet{background:var(--surface-tertiary);color:var(--text-secondary);}
.stash-stepper--lg button{width:48px;height:48px;}
.stash-stepper--lg input{width:64px;height:48px;font-size:20px;}
.stash-st-intro{margin:0;padding:12px 14px;font-size:14px;color:var(--text-secondary);background:var(--surface-secondary);border-radius:var(--radius-md);}
.stash-st-entry label{display:block;margin-bottom:6px;font-size:11px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:var(--text-tertiary);}
.stash-st-entry-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px;}
.stash-st-input{flex:1 1 160px;min-width:0;height:48px;padding:0 12px;background:var(--surface);color:var(--text-primary);font:inherit;font-size:22px;font-weight:800;letter-spacing:.04em;border:1px solid var(--border);border-radius:var(--radius-md);}
.stash-st-input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft);}
.stash-st-match{min-height:1.4em;margin:6px 0 0;font-size:13px;color:var(--text-secondary);}
.stash-st-match.is-error{color:var(--danger);}
.stash-st-keypad{display:none;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;}
.stash-st-keypad button{height:52px;background:var(--surface);color:var(--text-primary);font:inherit;font-size:20px;font-weight:600;border:1px solid var(--border);border-radius:var(--radius-lg);cursor:pointer;}
.stash-st-keypad button.fn{font-size:13px;font-weight:700;color:var(--text-secondary);background:var(--surface-tertiary);}
.stash-st-keypad button:disabled{opacity:.45;cursor:default;}
.stash-st-keypad button:focus-visible{outline:2px solid var(--accent);outline-offset:1px;}
.stash-st-foot{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;}
.stash-st-next{min-height:48px;padding:0 22px;font-size:14px;}
.stash-st-log ul{max-height:160px;margin:6px 0 0;padding-left:18px;overflow:auto;font-size:13px;}
.stash-st-sum{margin:0;font-size:16px;font-weight:700;}
.stash-st-usedup-link{align-self:flex-start;color:var(--danger);}
@media (pointer: coarse){
  .stash-st-keypad{display:grid;}
  .stash-st-keys{display:none;}
  .stash-st-input{font-size:22px;}
}
@media (max-width: 599px){
  .overlay-panel.stash-st{height:100dvh;max-height:100dvh;border-radius:0;}
  .stash-st-next{flex:1 1 100%;}
}
/* Phones: Stock-take floats over the Thread Stash list. */
.stash-fab{display:none;}
@media (max-width: 760px){
  .stash-fab{position:fixed;right:max(16px, env(safe-area-inset-right, 0px));bottom:calc(16px + env(safe-area-inset-bottom, 0px));z-index:40;display:inline-flex;align-items:center;gap:8px;height:48px;padding:0 18px;background:var(--accent);color:var(--text-on-accent);font:inherit;font-weight:700;border:0;border-radius:24px;box-shadow:var(--shadow-lg);cursor:pointer;}
  .stash-fab svg{width:18px;height:18px;}
  .stash-page{padding-bottom:88px;}
}

/* Custom thread catalogues page */
.stash-dialog-body{display:flex;flex-direction:column;gap:12px;font-size:13px;}
.stash-dialog-body .stash-form-row .stash-muted{margin-left:4px;}
.stash-dialog-body p{margin:0;}
.stash-file{display:flex;flex-direction:column;gap:4px;}
.stash-file>span,.stash-textarea>span{font-size:12px;font-weight:600;color:var(--text-secondary);}
.stash-textarea{display:flex;flex-direction:column;gap:4px;}
.stash-textarea textarea{width:100%;padding:8px 10px;background:var(--surface);color:var(--text-primary);font:inherit;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12.5px;border:1px solid var(--border);border-radius:var(--radius-md);resize:vertical;}
.stash-preview{display:flex;flex-direction:column;gap:8px;padding:10px 12px;background:var(--surface-secondary);border:1px solid var(--border-subtle);border-radius:var(--radius-md);}
.stash-preview-list,.stash-preview-errors{max-height:200px;margin:0;padding-left:18px;overflow:auto;font-size:12.5px;}
.stash-preview-errors{color:var(--danger);}
.stash-status-msg{color:var(--text-secondary);}
.stash-status-msg:empty{display:none;}

/* Overview: the Stash Manager's home page (hub plan, Phase 2). */
.stash-overview-head{display:flex;flex-wrap:wrap;align-items:center;gap:10px 16px;}
.stash-overview-head h2{flex:1 1 auto;margin:0;font-size:22px;font-weight:800;letter-spacing:-.01em;}
.stash-overview-head .stash-search{flex:0 1 360px;}
.stash-start h2{display:flex;align-items:center;gap:8px;margin:0;font-size:16px;font-weight:800;}
.stash-start h2 svg{width:18px;height:18px;color:var(--accent-text);}
.stash-tiles{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;}
.stash-tile{display:grid;gap:2px;justify-items:start;padding:12px 14px;background:var(--surface);color:var(--text-primary);font:inherit;text-align:left;border:1px solid var(--border);border-radius:var(--radius-xl);cursor:pointer;}
@media (hover: hover){.stash-tile:hover{border-color:var(--line-2);box-shadow:var(--shadow-sm);}}
.stash-tile:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}
.stash-tile-k{font-size:11px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:var(--text-tertiary);}
.stash-tile-v{font-size:28px;font-weight:800;line-height:1.15;letter-spacing:-.02em;font-variant-numeric:tabular-nums;}
.stash-tile-s{font-size:12px;color:var(--text-secondary);}
.stash-tile--accent .stash-tile-v{color:var(--accent-text);}
.stash-tile--warn .stash-tile-v{color:var(--accent-ink);}
.stash-tile--warn{background:var(--warning-soft);border-color:var(--warning);}
.stash-overview-cols{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(0,1fr);gap:12px;align-items:start;}
.stash-overview-side{display:flex;flex-direction:column;gap:12px;min-width:0;}
.stash-see-all{align-self:flex-start;color:var(--accent-text);}
.stash-ready-list{display:flex;flex-direction:column;margin:0;padding:0;list-style:none;}
.stash-ready-row{display:grid;gap:4px;width:100%;padding:8px 0;background:transparent;color:var(--text-primary);font:inherit;font-size:13px;text-align:left;border:0;border-bottom:1px solid var(--border-subtle);cursor:pointer;}
.stash-ready-list li:last-child .stash-ready-row{border-bottom:0;}
.stash-ready-row:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:var(--radius-sm);}
@media (hover: hover){.stash-ready-row:hover b{color:var(--accent-text);}}
.stash-ready-top{display:flex;justify-content:space-between;gap:12px;}
.stash-ready-top b{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.stash-ready-pct{font-variant-numeric:tabular-nums;color:var(--text-secondary);}
.stash-progress{display:block;height:6px;overflow:hidden;background:var(--surface-tertiary);border-radius:3px;}
.stash-progress span{display:block;height:100%;background:var(--accent);border-radius:3px;}
.stash-progress span.is-full{background:var(--success);}
.stash-alert-list--flat{max-height:none;}
.stash-alert-list--flat .stash-alert-row .stash-name{white-space:normal;}
/* Buy next sits in a narrower column, so its rows always stack: the
   patterns a thread is for go on their own line under it. */
.stash-overview .stash-shop-row{grid-template-columns:var(--stash-tap) minmax(0,1fr) auto var(--stash-tap);grid-template-areas:"tick id qty x" ". uses uses uses";row-gap:2px;}
.stash-overview .stash-shop-row .stash-tick{grid-area:tick;}
.stash-overview .stash-shop-row .stash-ident{grid-area:id;}
.stash-overview .stash-shop-row .stash-shop-qty{grid-area:qty;}
.stash-overview .stash-shop-row .stash-btn--icon{grid-area:x;}
.stash-overview .stash-shop-row .stash-uses{grid-area:uses;padding-left:40px;}
.stash-overview .stash-shop-row .stash-uses:empty{display:none;}
@media (max-width: 900px){
  .stash-overview-cols{grid-template-columns:minmax(0,1fr);}
}
@media (max-width: 760px){
  .stash-tiles{grid-template-columns:repeat(2,minmax(0,1fr));}
  .stash-overview-head .stash-search{flex:1 1 100%;}
}

/* Touch: 44px targets, and 16px inputs so iOS doesn't zoom the page. */
@media (pointer: coarse){
  .stash-btn,.stash-seg button,.mgr-showcase{min-height:44px;}
  .stash-stepper button{width:44px;height:44px;}
  .stash-stepper input{height:44px;font-size:16px;}
  .stash-chev{width:44px;height:44px;}
  .stash-levels button{min-height:44px;padding:0 13px;}
  .stash-search input,.stash-inline-form input{font-size:16px;}
  .stash-tick{width:44px;height:44px;}
  .stash-list-wrap{--stash-tap:44px;}
  .stash-shop-row{--stash-tap:44px;}
  .stash-tick input{width:24px;height:24px;}
}

/* Phones and narrow windows: rows become two lines, the editor stacks. */
@media (max-width: 760px){
  .stash-page{padding:12px 12px 32px;}
  .stash-toolbar-end{margin-left:0;}
  .stash-search{max-width:none;flex-basis:100%;}
  .stash-list-head{display:none;}
  .stash-row-main{grid-template-columns:minmax(0,1fr) auto auto;grid-template-areas:"id step chev" "open status status";row-gap:2px;column-gap:8px;padding:8px 8px 8px 12px;}
  .stash-row-main .stash-ident{grid-area:id;}
  .stash-row-main .stash-stepper{grid-area:step;}
  .stash-row-main .stash-chev{grid-area:chev;}
  .stash-row-main .stash-opened{grid-area:open;padding-left:40px;}
  .stash-row-main .stash-status{grid-area:status;justify-content:flex-end;}
  .stash-row-main .stash-uses{display:none;}
  .stash-row--add .stash-row-main{grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"id add" "status status";}
  .stash-row--add .stash-add{grid-area:add;}
  .stash-row--add .stash-status{grid-area:status;padding-left:40px;justify-content:flex-start;}
  .stash-status:empty{display:none;}
  .stash-row-edit{padding:12px;}
  .stash-actions{margin-left:0;}
  .stash-shop-row{grid-template-columns:auto minmax(0,1fr) auto auto;grid-template-areas:"tick id qty x" ". uses uses uses";row-gap:4px;column-gap:8px;}
  .stash-shop-row.is-ticked{margin:0 -16px;padding-left:16px;padding-right:16px;}
  .stash-shop-row.is-ticked{grid-template-areas:"tick id id x" ". qty qty qty" ". uses uses uses";}
  .stash-shop-row.is-ticked .stash-shop-qty{justify-self:start;padding-left:40px;}
  .stash-shop-row .stash-tick{grid-area:tick;}
  .stash-shop-row .stash-ident{grid-area:id;}
  .stash-shop-row .stash-shop-qty{grid-area:qty;}
  .stash-shop-row .stash-btn--icon{grid-area:x;}
  .stash-shop-row .stash-uses{grid-area:uses;padding-left:40px;}
  .stash-card-action{margin-left:0;}
  .stash-shop-row .stash-uses:empty{display:none;}
}
@media (max-width: 599px){
  /* Shorter labels on phones; the full text stays for screen readers. */
  .lbl-long{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;}
  .lbl-short{display:inline;}
  .stash-search{flex-basis:0;flex-grow:1;min-width:0;}
  .stash-toolbar-end{flex-wrap:nowrap;}
  .stash-view-btn span{display:none;}
  .stash-view-btn{padding:0 10px;}
  .stash-seg{width:100%;order:3;}
  .stash-seg button{flex:1 1 auto;justify-content:center;padding:0 6px;}
  .stash-attention{padding:8px 10px;}
  .stash-attention p{font-size:12.5px;}
  .mgr-tab-bar{padding:0 4px;}
  .mgr-tab{padding:8px 10px;}
  .mgr-tab .icon{display:none;}
  .mgr-showcase{padding:0 10px;}
  .mgr-showcase-label{display:none;}
}

/* ------------------------- Touch press feedback (WU-11) -------------------------
   Visible feedback that a tap was registered on touch devices, where :hover never
   triggers. Scoped to (pointer: coarse) so desktop click feel is unchanged. */
@media (pointer: coarse) {
  .tb-btn:active, .tb-fit-btn:active, .rp-tab:active,
  .cs-cmdp-row:active, .pcard:active,
  .mpd-card:active, .mpd-card-menu-btn:active,
  button:not(:disabled):active {
    transform: scale(0.97);
    transition: transform 0.05s;
  }
}

/* ------------------------- Skip-to-content link (WU-11) ------------------------- */
.skip-to-content {
  position: absolute; top: -9999px; left: 8px; z-index: 100000;
  padding: 8px 14px; background: var(--accent, #B85C38); color: var(--surface);
  border-radius: 6px; font-weight: 600; text-decoration: none;
  font-family: inherit; font-size: 14px;
}
.skip-to-content:focus { top: 8px; outline: 2px solid var(--surface); outline-offset: 2px; }

/* ------------------------- Title truncation tweaks (WU-17) ------------------------- */
@media (max-width: 480px) {
  .pcard, .mpd-card { /* card titles often truncate at 1 line; allow 2 on phone */
    /* no global override -- specific name elements opt in below */
  }
  .mpd-card-title, .pcard-title, .pat-grid .pcard b, .pat-grid .pcard strong {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
  }
}

/* ───────────────────────────────────────────────────────────────────────
   Accessibility & theme overrides driven by Preferences › Accessibility.
   Classes are applied to <html> by apply-prefs.js.
   ─────────────────────────────────────────────────────────────────────── */

html.pref-font-s   { font-size: 14px; }
html.pref-font-m   { font-size: 16px; } /* default */
html.pref-font-l   { font-size: 18px; }
html.pref-font-xl  { font-size: 20px; }

html.pref-reduced-motion *,
html.pref-reduced-motion *::before,
html.pref-reduced-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

html.pref-high-contrast {
  --line: #1B1814;
  --line-2: var(--text-secondary);
}
html.pref-high-contrast body,
html.pref-high-contrast .card,
html.pref-high-contrast button,
html.pref-high-contrast input,
html.pref-high-contrast select,
html.pref-high-contrast textarea {
  border-color: var(--text-primary) !important;
}
html.pref-high-contrast,
html.pref-high-contrast body { color: #000 !important; }

/* Dark mode (UX-12 Phase 2). Most of the work is done by the
   [data-theme="dark"] block at the top of this file, which overrides every
   chrome token. The rules below cover hardcoded backgrounds in legacy
   components that haven't been migrated to var(--surface) yet. */
html.pref-dark { background: var(--surface-secondary); color-scheme: dark; }
html.pref-dark body { background: var(--surface-secondary); color: var(--text-primary); }
html.pref-dark .card,
html.pref-dark [data-card],
html.pref-dark .panel,
html.pref-dark .modal,
html.pref-dark .toolbar,
html.pref-dark .sidebar { background: var(--surface) !important; color: var(--text-primary) !important; border-color: var(--border) !important; }
/* The Stash Manager's list and tab bar style their own controls from the
   theme tokens; this blanket rule would flatten selected states. */
html.pref-dark input:not(.stash-page *):not(.stash-st *),
html.pref-dark select,
html.pref-dark textarea,
html.pref-dark button:not(.btn-primary):not([data-pref-modal] *):not(.ppal-tile-swatch):not(.ppal-size-btn):not(.stash-page *):not(.mgr-tab-bar *):not(.stash-st *):not(.stash-fab) {
  background: var(--surface-tertiary) !important; color: var(--text-primary) !important; border-color: var(--border) !important;
}
html.pref-dark a { color: var(--accent); }

/* --- A2 (UX Phase 5) --- Bold edit-mode strip in the Tracker.
   Sits directly under the global header, above the toolbar, so users
   cannot mistake destructive "Modify" actions for normal "Mark" tracking. */
.edit-mode-strip {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 16px; min-height: 40px;
  background: var(--danger-soft); border-bottom: 2px solid var(--danger);
  color: var(--danger); font-size: 13px; font-weight: 600;
}
.edit-mode-strip__label { display: inline-flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.edit-mode-strip__label svg { color: var(--danger); flex-shrink: 0; }
.edit-mode-strip__hint { color: var(--danger); font-weight: 500; font-size: 12px; }
.edit-mode-strip__exit {
  border: 1px solid var(--danger); background: var(--surface); color: var(--danger);
  font-weight: 600; font-size: 12px; padding: 6px 12px; border-radius: 6px;
  cursor: pointer; min-height: 32px;
}
@media (hover: hover){.edit-mode-strip__exit:hover { background: var(--danger-soft); }}
.toolbar-row--edit { background: var(--danger-soft); }
.pill--edit { box-shadow: inset 0 0 0 1px var(--danger-soft); }
@media (max-width: 480px) {
  .edit-mode-strip { flex-wrap: wrap; padding: 8px 12px; }
  .edit-mode-strip__hint { display: none; }
}

/* A3 (UX Phase 5) — Tracker resume recap modal */

/* A3 (UX Phase 5) — Tracker resume recap modal
   Fires once per project load when the project has prior stitching sessions.
   Mobile: full-screen below 480px (addresses G6). */
.resume-recap-overlay {
  z-index: 1100;
}
.resume-recap-modal {
  max-width: 540px;
  width: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.resume-recap-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.resume-recap-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}
.resume-recap-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.resume-recap-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
@media (hover: hover){.resume-recap-close:hover { background: var(--surface-tertiary); color: var(--text-primary); }}
.resume-recap-body { padding: 16px; }
.resume-recap-progress { margin-bottom: 18px; }
.resume-recap-progress-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}
.resume-recap-progress-pct {
  font-weight: 600;
  color: var(--accent);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.resume-recap-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.resume-recap-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.resume-recap-progress-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.resume-recap-section-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.resume-recap-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.resume-recap-card {
  background: var(--surface-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}
.resume-recap-card-num {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.resume-recap-card-lbl {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.resume-recap-note {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 8px;
  font-style: italic;
}
.resume-recap-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.resume-recap-btn {
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
}
@media (hover: hover){.resume-recap-btn:hover { background: var(--surface-secondary); color: var(--text-primary); }}
.resume-recap-btn--primary {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
  font-weight: 600;
}
@media (hover: hover){.resume-recap-btn--primary:hover { background: var(--accent-hover); color: var(--surface); }}
@media (max-width: 480px) {
  .resume-recap-overlay { padding: 0; align-items: stretch; }
  .resume-recap-modal {
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .resume-recap-body { flex: 1; overflow-y: auto; }
  .resume-recap-footer { flex-direction: column-reverse; }
  .resume-recap-btn { width: 100%; padding: 12px 14px; }
}

/* ════════════════════════════════════════════════════════════════════
   B2 — drag-mark and range select (touch overlay)
   Painted as transparent divs over the tracker canvas while a gesture
   is in progress. Path cells use the intent colour at 50 % opacity;
   the long-press anchor gets a thicker outline. Pulse class flashes
   committed cells for 250 ms.
   ════════════════════════════════════════════════════════════════════ */
.drag-mark-overlay { position: absolute; }
.drag-mark-cell {
  position: absolute;
  border-radius: 2px;
  background: rgba(184, 92, 56, 0.50);   /* mark — teal/green family */
  box-shadow: inset 0 0 0 1px rgba(184, 92, 56, 0.85);
  transition: opacity 60ms ease-out;
}
.drag-mark-overlay--unmark .drag-mark-cell {
  background: rgba(220, 38, 38, 0.50);    /* unmark — red family */
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.85);
}
.drag-mark-anchor {
  position: absolute;
  border-radius: 3px;
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--accent, #B85C38),
              0 0 0 1px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.drag-mark-overlay--unmark .drag-mark-anchor {
  box-shadow: inset 0 0 0 2px var(--danger, #A53D3D),
              0 0 0 1px rgba(0, 0, 0, 0.25);
}
.drag-mark-pulse,
.cell-pulse {
  position: absolute;
  border-radius: 2px;
  background: rgba(184, 92, 56, 0.40);
  animation: dragMarkPulse 250ms ease-out;
  pointer-events: none;
}
.drag-mark-overlay--unmark .drag-mark-pulse {
  background: rgba(220, 38, 38, 0.40);
}
@keyframes dragMarkPulse {
  0%   { transform: scale(1.20); opacity: 0.85; }
  100% { transform: scale(1.00); opacity: 0;    }
}
@media (prefers-reduced-motion: reduce) {
  .drag-mark-pulse, .cell-pulse { animation: none; opacity: 0; }
}


/* ════ B6 — Help & Shortcuts drawer ════════════════════════════════════ */
/* Side drawer for unified Help, Shortcuts, and Getting Started.          */
/* Most layout is inline (see help-drawer.js) so it works without a CSS   */
/* dependency; this block adds the slide animation and mobile full-screen */
/* override.                                                              */

.cs-help-drawer {
  animation: cs-help-drawer-slide-in 180ms ease-out;
}
@keyframes cs-help-drawer-slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.cs-help-drawer kbd {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.cs-help-drawer button:focus-visible,
.cs-help-drawer input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .cs-help-drawer {
    width: 100vw !important;
    border-left: none !important;
  }
  /* On mobile the click-outside scrim has no width — there's no app surface
     visible behind the drawer — so hide it to keep the tap target clean. */
  .cs-help-drawer-scrim {
    display: none !important;
  }
}

/* ════════════════════════════════════════════════════════════════════════
   B5 — Multi-select dashboard + rich cards
   ════════════════════════════════════════════════════════════════════════ */

/* Bulk action bar — sits above the dashboard while selection mode is on. */
.mpd-bulk-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  margin-bottom: 12px;
  background: var(--surface, #fff);
  border: 1px solid var(--accent-border, #c7d2fe);
  border-radius: var(--radius-lg, 10px);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  flex-wrap: wrap;
}
.mpd-bulk-bar-left,
.mpd-bulk-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mpd-bulk-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #0f172a);
  margin-right: 4px;
}
.mpd-bulk-delete {
  color: var(--danger);
}
@media (hover: hover){
.mpd-bulk-delete:hover:not(:disabled) {
  background: var(--danger-soft);
}
}
.mpd-bulk-bar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Card selection affordance — checkbox sits in the top-left corner.
   Hidden by default, shown on hover (desktop) and always shown when
   the dashboard is in selection mode. */
.mpd-card {
  position: relative;
}
.mpd-card-select {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 5;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1.5px solid var(--border, #CFC4AC);
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent, #B85C38);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  transition: background 0.12s, border-color 0.12s;
}
.mpd-card:hover .mpd-card-select,
.mpd--selection-mode .mpd-card-select {
  display: inline-flex;
}
.mpd-card-select--checked {
  background: var(--accent, #B85C38);
  border-color: var(--accent, #B85C38);
  color: var(--surface);
}
.mpd-card--selected {
  outline: 2px solid var(--accent, #B85C38);
  outline-offset: 2px;
}
.mpd--selection-mode .mpd-card {
  cursor: pointer;
}

/* Continue button in the card footer — make sure it stays tap-friendly on
   mobile (no hover-only visibility tricks should ever hide it). */
@media (max-width: 480px) {
  .mpd-card-actions .mpd-btn { min-height: 36px; }
  .mpd-bulk-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .mpd-bulk-bar-left,
  .mpd-bulk-bar-right {
    flex-shrink: 0;
  }
}

/* B3 — Mode-aware sidebar (Pattern / Project / Materials) */
.cs-page-fade { animation: cs-page-fade-in 160ms ease-out; }
@keyframes cs-page-fade-in { from { opacity: 0.4; } to { opacity: 1; } }
.cs-sidebar-fade { animation: cs-page-fade-in 160ms ease-out; }

/* fix-3.6 — mode-swap micro-cue: translate the page content 12px towards the
   freed sidebar space during the fade-in so the user perceives the layout
   *expanding* rather than the sidebar simply *vanishing*. Respect
   prefers-reduced-motion (no translate, opacity only). */
.cs-page-fade { animation: cs-page-fade-in-translate 200ms ease-out; }
@keyframes cs-page-fade-in-translate {
  from { opacity: 0.4; transform: translateX(12px); }
  to   { opacity: 1;   transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .cs-page-fade, .cs-sidebar-fade {
    animation: cs-page-fade-in 160ms ease-out;
    transform: none !important;
  }
}

/* B4 — Materials hub */
.materials-hub { display:flex; flex-direction:column; min-height:300px; }

/* C4 — sub-tab strip nests visually under the parent Sidebar tab strip:
   - inset wrap with surface-2 fill and a 2px accent left border
   - "View:" caption + breadcrumb micro-label sit above the pill rail
   - pills are outline-style at rest, accent-filled when active, so they
     read as "filter" rather than "page". */
.mh-subtabs-wrap {
  display:flex; align-items:center; flex-wrap:wrap; gap:8px;
  padding:8px 12px 8px 22px;
  background:var(--surface-2, #EFE7D6);
  border-bottom:1px solid var(--border);
  border-left:2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  flex-shrink:0;
  position:relative;
}
.mh-breadcrumb {
  flex-basis:100%;
  display:flex; align-items:center; gap:4px;
  font-size:11px; line-height:1.2;
  color:var(--text-tertiary);
  min-width:0;
  margin-bottom:2px;
}
.mh-breadcrumb-root {
  font-weight:500;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  max-width:60%;
}
.mh-breadcrumb-sep {
  display:inline-flex; align-items:center;
  font-size:10px; color:var(--text-tertiary); opacity:0.7;
  flex-shrink:0;
}
.mh-breadcrumb-current {
  font-weight:600; color:var(--text-primary);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  flex:0 1 auto;
}
.mh-subtabs-label {
  display:inline-flex; align-items:center; gap:4px;
  font-size:10px; font-weight:700; text-transform:uppercase;
  letter-spacing:0.6px; color:var(--text-tertiary);
  flex-shrink:0; padding-right:4px;
}
.mh-subtabs-label-icon { display:inline-flex; align-items:center; }
.mh-subtabs { display:flex; gap:6px; flex:1; min-width:0; }
.mh-subtab {
  display:inline-flex; align-items:center; gap:6px;
  padding:6px 12px; min-height:32px;
  font-size:11.5px; font-weight:500;
  color:var(--text-secondary);
  background:transparent;
  border:1px solid var(--border);
  border-radius:999px;
  cursor:pointer; font-family:inherit;
  transition:background 0.12s, color 0.12s, border-color 0.12s;
}
@media (hover: hover){.mh-subtab:hover { background:var(--surface-tertiary); color:var(--text-primary); border-color:var(--text-tertiary); }}
.mh-subtab.on {
  background:var(--accent);
  color:var(--surface);
  font-weight:550;
  border-color:var(--accent);
}
.mh-subtab:focus-visible {
  outline:2px solid var(--accent);
  outline-offset:2px;
}
.mh-subtab-icon { display:inline-flex; align-items:center; }
.mh-body {
  flex:1; overflow-y:auto;
  padding:14px 16px;
  background:var(--surface);
  border-radius:0 0 12px 12px;
}

/* C4 — shared empty-state layout (centred icon + headline + body + action). */
.mh-empty {
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  text-align:center; gap:8px;
  padding:32px 16px;
  color:var(--text-secondary);
}
.mh-empty-icon {
  display:inline-flex; align-items:center; justify-content:center;
  width:32px; height:32px; font-size:32px;
  color:var(--text-tertiary);
  margin-bottom:4px;
}
.mh-empty-headline {
  margin:0; font-size:14px; font-weight:600; line-height:1.3;
  color:var(--text-primary);
}
.mh-empty-body {
  margin:0; font-size:12px; color:var(--text-tertiary); line-height:1.4;
  max-width:42ch;
}
.mh-empty-action {
  margin-top:8px; padding:8px 14px;
  font-size:12px; font-weight:600; font-family:inherit;
  background:var(--accent); color:var(--surface);
  border:none; border-radius:8px; cursor:pointer; min-height:36px;
}
.mh-empty-action:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }

@media (max-width: 480px) {
  .mh-subtabs-wrap { padding-left:14px; padding-right:8px; }
  .mh-breadcrumb { font-size:10.5px; }
  .mh-breadcrumb-root { max-width:40%; }
  .mh-subtabs {
    overflow-x:auto; flex-wrap:nowrap;
    /* fix-3.2 — fade the right edge so users see there's more content. */
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); /* css-tokens-lint-allow: alpha mask stop, the colour is never painted */
            mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); /* css-tokens-lint-allow: alpha mask stop, the colour is never painted */
    scrollbar-width:none;
  }
  .mh-subtabs::-webkit-scrollbar { display:none; }
  /* fix-3.2 — guarantee 44x44 mobile touch target on each sub-tab. */
  .mh-subtab { flex-shrink:0; min-height:44px; min-width:44px; padding:10px 14px; }
  .mh-empty { padding:20px 12px; }
}

/* fix-3.5 — styled bulk delete confirmation modal (replaces window.confirm). */
.mpd-bulk-delete-modal { max-width: 440px; }
.mpd-bulk-delete-modal h3 { margin: 0 0 8px; font-size: 17px; color: var(--text-primary); }
.mpd-bulk-delete-modal p { margin: 0 0 12px; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.mpd-bulk-delete-modal ul { margin: 0 0 16px; padding-left: 18px; font-size: 12px; color: var(--text-secondary); max-height: 160px; overflow-y: auto; }
.mpd-bulk-delete-actions { display: flex; gap: 8px; justify-content: flex-end; }
.mpd-bulk-delete-actions button { padding: 8px 16px; border-radius: 6px; font-size: 13px; font-family: inherit; cursor: pointer; min-height: 40px; }
.mpd-bulk-delete-actions .mpd-cancel-btn { background: var(--surface); border: 1px solid var(--border); color: var(--text-primary); }
.mpd-bulk-delete-actions .mpd-confirm-delete-btn { background: var(--danger); border: 1px solid var(--danger); color: var(--surface); font-weight: 600; }
@media (hover: hover){.mpd-bulk-delete-actions .mpd-confirm-delete-btn:hover { background: var(--danger); }}

/* fix-3.7 — persistent Cancel selection control replacing the Continue bar
   slot while in selection mode. */
.mpd-selection-cancel-bar {
  background: var(--surface-2, #EFE7D6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 8px);
  padding: 8px 14px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; min-height: 48px;
  font-size: 13px; color: var(--text-secondary);
}
.mpd-selection-cancel-bar button {
  padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-primary);
  cursor: pointer; min-height: 36px; font-family: inherit;
}

/* -- C8 Coachmark (first-stitch coaching) ----------------------- */
.cs-coachmark { position: fixed; inset: 0; z-index: 10000; pointer-events: none; }
.cs-coachmark-scrim {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  pointer-events: auto; animation: csCoachFade 160ms ease-out;
}
.cs-coachmark-highlight-ring {
  position: fixed; pointer-events: none; border-radius: 8px;
  box-shadow: 0 0 0 3px var(--accent, #B85C38), 0 0 0 6px rgba(184, 92, 56, 0.25);
  animation: csCoachPulse 1.4s ease-in-out infinite;
}
.cs-coachmark-popover {
  position: fixed; pointer-events: auto;
  background: var(--surface); color: var(--text-primary);
  border-radius: 10px; box-shadow: 0 16px 40px rgba(15, 23, 42, 0.25);
  padding: 16px 18px; max-width: 90vw;
  font-family: inherit;
  animation: csCoachPop 180ms ease-out;
}
.cs-coachmark-title {
  margin: 0 0 6px 0; font-size: 15px; font-weight: 700; color: var(--text-primary);
}
.cs-coachmark-body {
  margin: 0 0 14px 0; font-size: 13px; line-height: 1.5; color: var(--text-secondary);
}
.cs-coachmark-buttons {
  display: flex; justify-content: flex-end; gap: 8px;
}
.cs-coachmark-learn-more {
  display: block; margin: 0 0 10px 0; padding: 0;
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 12px; color: var(--accent, #B85C38); text-decoration: underline;
  text-underline-offset: 2px; text-align: left;
}
.cs-coachmark-learn-more:focus-visible {
  outline: 2px solid var(--accent, #B85C38); outline-offset: 2px; border-radius: 2px;
}
.cs-coachmark-btn {
  min-height: 36px; min-width: 64px;
  padding: 8px 14px; border-radius: 6px; font-size: 13px; font-weight: 600;
  background: var(--surface); color: var(--text-primary); border: 1px solid var(--border);
  cursor: pointer; font-family: inherit;
}
.cs-coachmark-btn--primary {
  background: var(--accent, #B85C38); color: var(--surface); border-color: var(--accent, #B85C38);
}
.cs-coachmark-btn:focus-visible {
  outline: 2px solid var(--accent, #B85C38); outline-offset: 2px;
}
@media (max-width: 480px) {
  .cs-coachmark-popover { max-width: calc(100vw - 24px); padding: 14px 14px; }
  .cs-coachmark-btn { min-height: 44px; min-width: 44px; padding: 10px 16px; }
}
@keyframes csCoachFade {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes csCoachPop {
  from { opacity: 0; transform: translateY(4px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes csCoachPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent, #B85C38), 0 0 0 6px rgba(184, 92, 56, 0.25); }
  50%      { box-shadow: 0 0 0 3px var(--accent, #B85C38), 0 0 0 10px rgba(184, 92, 56, 0.10); }
}
@media (prefers-reduced-motion: reduce) {
  .cs-coachmark-scrim, .cs-coachmark-popover, .cs-coachmark-highlight-ring { animation: none !important; }
}
.cs-coachmark-no-motion { animation: none !important; }



/* -- C7 Image Import Wizard (experimental) --------------------- */
.iw-wizard-root { position: fixed; inset: 0; z-index: 9500; display: flex; align-items: center; justify-content: center; }
.iw-scrim { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.55); }
.iw-wizard {
  position: relative; background: var(--surface); color: var(--text-primary);
  border-radius: 12px; box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
  width: min(720px, 92vw); max-height: 92vh;
  display: flex; flex-direction: column; font-family: inherit;
}
.iw-header { padding: 18px 20px 0; border-bottom: 1px solid var(--border); }
.iw-progress {
  list-style: none; margin: 0 0 12px; padding: 0;
  display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-tertiary);
}
.iw-progress-item { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--surface-tertiary); }
.iw-progress-item--reached { background: var(--accent-light); color: var(--accent-hover); }
.iw-progress-item--active { background: var(--accent, #B85C38); color: var(--surface); }
.iw-progress-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; }
.iw-progress-marker, .iw-progress-btn { font-size: 12px; }
.iw-body { padding: 18px 20px; overflow-y: auto; }
.iw-step-title { margin: 0 0 6px; font-size: 17px; font-weight: 700; color: var(--text-primary); outline: none; }
.iw-step-desc { margin: 0 0 14px; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.iw-controls {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.iw-controls-spacer { flex: 1; }
.iw-btn {
  min-height: 40px; padding: 8px 16px;
  background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.iw-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.iw-btn--primary { background: var(--accent, #B85C38); color: var(--surface); border-color: var(--accent, #B85C38); }
.iw-btn--ghost { background: transparent; border-color: transparent; color: var(--text-tertiary); }
.iw-btn--danger { background: var(--danger); color: var(--surface); border-color: var(--danger); }
.iw-btn:focus-visible { outline: 2px solid var(--accent, #B85C38); outline-offset: 2px; }

.iw-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.iw-grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; }
.iw-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.iw-field-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.iw-field input[type="number"], .iw-field input[type="text"], .iw-field select {
  padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border); font: inherit; min-height: 40px;
}
.iw-checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 8px 0; cursor: pointer; }
.iw-output { font-size: 12px; color: var(--text-secondary); min-width: 28px; text-align: right; }
.iw-readout { background: var(--surface-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-top: 12px; }
.iw-warn { background: var(--warning-soft); border: 1px solid var(--warning); color: var(--accent-ink); border-radius: 8px; padding: 8px 12px; font-size: 12px; margin-top: 10px; }

.iw-crop-viewport {
  width: 100%; max-width: 320px; height: 320px; /* Safari <15 fallback: explicit square */
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-secondary);
  display: flex; align-items: center; justify-content: center; overflow: hidden; margin: 0 auto 14px;
}
@supports (aspect-ratio: 1) {
  .iw-crop-viewport { height: auto; aspect-ratio: 1 / 1; }
}
.iw-crop-viewport img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform 120ms ease-out; }
.iw-crop-empty { padding: 40px 20px; text-align: center; color: var(--text-tertiary); font-size: 13px; }
.iw-crop-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.iw-aspect-group { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.iw-aspect-legend { font-size: 12px; font-weight: 600; color: var(--text-secondary); padding: 0; margin-right: 4px; }
.iw-radio { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }

.iw-palette-modes { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; }
.iw-card {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.iw-card--active { border-color: var(--accent, #B85C38); background: var(--accent-light); }
.iw-card-body { flex: 1; }
.iw-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.iw-card-desc { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

.iw-preview-thumb {
  width: 100%; max-width: 256px; height: 256px; /* Safari <15 fallback: explicit square */
  border: 1px solid var(--border); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; overflow: hidden; margin: 0 auto 14px;
}
@supports (aspect-ratio: 1) {
  .iw-preview-thumb { height: auto; aspect-ratio: 1 / 1; }
}
.iw-preview-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }

.iw-summary {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px; background: var(--surface-secondary); border: 1px solid var(--border); border-radius: 8px;
}
.iw-summary-thumb {
  width: 96px; height: 96px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.iw-summary-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; image-rendering: pixelated; }
.iw-summary-list { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; }
.iw-summary-list dt { color: var(--text-tertiary); display: flex; align-items: center; gap: 5px; }
.iw-summary-list dd { margin: 0; color: var(--text-primary); font-weight: 500; }
.iw-info-icon { display: inline-flex; align-items: center; color: var(--text-tertiary); cursor: help; line-height: 1; }
.iw-info-icon svg { width: 13px; height: 13px; }
.iw-stitchability-hint { margin-top: 3px; font-size: 12px; font-weight: 400; color: var(--text-tertiary); line-height: 1.4; }

.iw-discard-modal {
  position: absolute; inset: 0; background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; padding: 20px;
}
.iw-discard-modal h3 { margin: 0 0 8px; font-size: 16px; color: var(--text-primary); }
.iw-discard-modal p { margin: 0 0 14px; font-size: 13px; color: var(--text-secondary); }
.iw-discard-modal > * { background: var(--surface); border-radius: 10px; padding: 18px; max-width: 360px; }
.iw-discard-buttons { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 480px) {
  .iw-wizard { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .iw-controls { position: sticky; bottom: 0; background: var(--surface); }
  .iw-btn { min-height: 48px; padding: 12px 18px; }
  .iw-grid-two { grid-template-columns: 1fr; }
  .iw-summary { flex-direction: column; align-items: stretch; }
  .iw-summary-thumb { width: 100%; height: 160px; }
}

/* ════════════════════════════════════════════════════════════════════
   Phase 5 (UX-12) — Creator outcome action bar
   Persistent bar above the Creator's tab content. Promotes Print PDF,
   Track this pattern, and a small Export… menu. Strict alias / fast
   path for handlers that already live elsewhere in the Creator.
   ════════════════════════════════════════════════════════════════════ */

.creator-actionbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--surface-raised, #FFFDF8);
  border-bottom: 1px solid var(--line, #E5DCCB);
}

.creator-actionbar__primary {
  display: flex;
  align-items: center;
  gap: 8px;
}

.creator-actionbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 1;
  min-width: 0;
}

.creator-actionbar__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  min-height: 32px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--surface-raised, #fff);
  border: 1px solid var(--line, #E5DCCB);
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

@media (hover: hover){
.creator-actionbar__btn:hover {
  background: var(--accent-soft, #F4DDCF);
  border-color: var(--accent-border, #E8B89A);
}
}

.creator-actionbar__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.creator-actionbar__btn--primary {
  background: var(--accent);
  color: var(--text-on-accent, #FFF8F0);
  border-color: var(--accent);
  font-weight: 600;
}

@media (hover: hover){
.creator-actionbar__btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--text-on-accent, #FFF8F0);
}
}

.creator-actionbar__btn--ghost {
  background: transparent;
}

@media (hover: hover){
.creator-actionbar__btn--ghost:hover {
  background: var(--accent-soft, #F4DDCF);
}
}

.creator-actionbar__menu-wrap {
  position: relative;
}

.creator-actionbar__menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 220px;
  background: var(--surface-raised, #FFFDF8);
  border: 1px solid var(--line, #E5DCCB);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  padding: 4px 0;
  /* Sits above the sticky tool strip (z-index 99) and topbar (z-index 100).
     Without this the Export menu was clipped behind those rows. */
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.creator-actionbar__menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  min-height: 36px;
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.creator-actionbar__menu-item:hover,
.creator-actionbar__menu-item:focus-visible {
  background: var(--accent-soft, #F4DDCF);
  outline: none;
}

/* ─── Option 2 — Mode switch + Pattern info chip + popover ──────────── */
/* Polish A — switched from a 3-pip segmented "tablist" (Create / Edit /
   Track) to a phase label + two real action buttons. The label is a
   plain span so screen readers announce the current phase, and every
   visible button now performs an action. */
.creator-actionbar__mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  flex-wrap: wrap;
}

.creator-actionbar__mode-phase {
  font: 600 12px/1 inherit;
  color: var(--text-secondary, #5C5448);
  padding: 0 4px;
  white-space: nowrap;
}

.creator-actionbar__mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line, #E5DCCB);
  background: var(--surface-secondary, #F9F5F0);
  border-radius: var(--radius-md, 8px);
  padding: 6px 10px;
  font: 600 12px/1 inherit;
  color: var(--text-secondary, #5C5448);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

@media (hover: hover){
.creator-actionbar__mode-btn:hover {
  background: var(--accent-soft, #F4DDCF);
  color: var(--text-primary);
  border-color: var(--accent, #B85C38);
}
}

.creator-actionbar__mode-btn--forward {
  background: var(--accent, #B85C38);
  color: #FFFDF8;
  border-color: var(--accent, #B85C38);
}

@media (hover: hover){
.creator-actionbar__mode-btn--forward:hover {
  background: var(--accent-2, var(--accent, #B85C38));
  color: #FFFDF8;
}
}

.creator-actionbar__mode-btn:focus-visible {
  outline: 2px solid var(--accent, #B85C38);
  outline-offset: 2px;
}

.creator-actionbar__info-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.creator-actionbar__info-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line, #E5DCCB);
  border-radius: 999px;
  background: var(--surface-raised, #FFFDF8);
  font: 500 12px/1 inherit;
  color: var(--text-secondary, #5C5448);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.creator-actionbar__info-trigger:hover,
.creator-actionbar__info-trigger[aria-expanded="true"] {
  background: var(--accent-soft, #F4DDCF);
  border-color: var(--accent, #B85C38);
  color: var(--text-primary);
}

.creator-actionbar__info-trigger:focus-visible {
  outline: 2px solid var(--accent, #B85C38);
  outline-offset: 2px;
}

/* Difficulty tier chip — always visible in the action bar */
.creator-actionbar__difficulty-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: 1.5px solid currentColor;
  border-radius: 999px;
  font: 600 11px/1 inherit;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: default;
}

/* Stats link — ghost anchor in the primary group */
.creator-actionbar__stats-link {
  text-decoration: none;
}

.creator-popover-info {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 280px;
  background: var(--surface-raised, #FFFDF8);
  border: 1px solid var(--line, #E5DCCB);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  padding: 14px 16px;
  z-index: 1001;
  color: var(--text-primary);
}

.creator-popover-info__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary, #8A8270);
  margin: 0 0 8px;
}

.creator-popover-info__grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 18px;
  font-size: 12px;
}

.creator-popover-info__label {
  color: var(--text-tertiary, #8A8270);
}

.creator-popover-info__value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  text-align: right;
}

.creator-popover-info__note {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-tertiary, #8A8270);
}

.creator-popover-info__divider {
  height: 1px;
  background: var(--line, #E5DCCB);
  margin: 12px 0;
  border: 0;
}

.creator-popover-info__badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.creator-popover-info__badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft, #F4DDCF);
  color: var(--accent, #B85C38);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Difficulty breakdown section ──────────────────────────────────────── */
.creator-popover-difficulty__tier-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.creator-popover-difficulty__badge {
  font-size: 13px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  background: transparent;
  letter-spacing: 0.02em;
}

.creator-popover-difficulty__score {
  font-size: 11px;
  color: var(--text-tertiary, #8A8270);
  font-variant-numeric: tabular-nums;
}

.creator-popover-difficulty__factors {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 8px;
}

.creator-popover-difficulty__factor-row {
  display: grid;
  grid-template-columns: 1fr 80px 28px;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.creator-popover-difficulty__factor-label {
  color: var(--text-secondary, #6B5F54);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.creator-popover-difficulty__factor-track {
  height: 5px;
  background: var(--line, #E5DCCB);
  border-radius: 3px;
  overflow: hidden;
}

.creator-popover-difficulty__factor-fill {
  height: 100%;
  background: var(--accent, #B85C38);
  border-radius: 3px;
  transition: width var(--motion, 160ms ease-out);
}

.creator-popover-difficulty__factor-pct {
  color: var(--text-tertiary, #8A8270);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.creator-popover-difficulty__details {
  border-top: 1px solid var(--line, #E5DCCB);
  margin-top: 4px;
  padding-top: 6px;
}

.creator-popover-difficulty__summary {
  font-size: 11px;
  color: var(--text-tertiary, #8A8270);
  cursor: pointer;
  user-select: none;
  list-style: none;
  padding: 2px 0;
}

.creator-popover-difficulty__summary::-webkit-details-marker { display: none; }

.creator-popover-difficulty__summary::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid var(--text-tertiary, #8A8270);
  margin-right: 5px;
  vertical-align: middle;
  transition: transform var(--motion, 160ms ease-out);
}

details[open] .creator-popover-difficulty__summary::before {
  transform: rotate(90deg);
}

.creator-popover-difficulty__formula {
  margin-top: 8px;
}

.creator-popover-difficulty__formula-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.creator-popover-difficulty__formula-table th,
.creator-popover-difficulty__formula-table td {
  text-align: left;
  padding: 2px 4px 2px 0;
  color: var(--text-secondary, #6B5F54);
  border-bottom: 1px solid var(--line, #E5DCCB);
}

.creator-popover-difficulty__formula-table th {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary, #8A8270);
}

.creator-popover-difficulty__formula-table td:not(:first-child),
.creator-popover-difficulty__formula-table th:not(:first-child) {
  text-align: right;
  padding-right: 0;
}

.creator-popover-difficulty__formula-total td {
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: none;
  padding-top: 4px;
}

.creator-popover-difficulty__formula-note {
  font-size: 10px;
  color: var(--text-tertiary, #8A8270);
  font-style: italic;
  margin-top: 5px;
}

.creator-popover-info-scrim {
  display: none;
}

@media (max-width: 599px) {
  .creator-popover-info-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
  }

  .creator-popover-info {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    min-width: 0;
    width: 100%;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.18);
    padding: 18px 18px 22px;
    max-height: 70vh;
    overflow-y: auto;
  }

  .creator-popover-info::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    background: var(--line, #E5DCCB);
    border-radius: 2px;
    margin: -4px auto 14px;
  }

  .creator-actionbar__mode-switch {
    margin-right: 0;
  }

  .creator-actionbar__info-wrap {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .creator-actionbar__mode-btn,
  .creator-actionbar__info-trigger {
    transition: none;
  }
}

@media (pointer: coarse) {
  .creator-actionbar__mode-btn,
  .creator-actionbar__info-trigger {
    min-height: 44px;
    padding: 10px 16px;
  }
}

/* ════════════════════════════════════════════════════════════════
   AppInfoPopover — shared chip + popover (Plan B).
   Used by Tracker, Manager, /home, and Stats.
   ════════════════════════════════════════════════════════════════ */

.app-info-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line, #E5DCCB);
  border-radius: 999px;
  background: var(--surface, #FFFDF8);
  font: 500 12px/1 inherit;
  color: var(--text-secondary, #5C5448);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.app-info-chip:hover,
.app-info-chip[aria-expanded="true"] {
  background: var(--accent-soft, #F4DDCF);
  border-color: var(--accent, #B85C38);
  color: var(--text-primary);
}

.app-info-chip:focus-visible {
  outline: 2px solid var(--accent, #B85C38);
  outline-offset: 2px;
}

.app-info-chip__chevron {
  display: inline-flex;
  align-items: center;
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

.app-info-chip__label {
  color: var(--text-primary);
  font-weight: 600;
}

.app-info-chip-wrap {
  position: relative;
  display: inline-block;
}

.app-info-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 280px;
  max-width: 360px;
  background: var(--surface, #FFFDF8);
  border: 1px solid var(--line, #E5DCCB);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  padding: 14px 16px;
  z-index: 1001;
  color: var(--text-primary);
}

.app-info-popover--left { right: auto; left: 0; }

.app-info-popover__section + .app-info-popover__section {
  margin-top: 12px;
}

.app-info-popover__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary, #8A8270);
  margin: 0 0 8px;
}

.app-info-popover__grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 18px;
  font-size: 12px;
}

.app-info-popover__label {
  color: var(--text-tertiary, #8A8270);
}

.app-info-popover__value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  text-align: right;
}

.app-info-popover__divider {
  height: 1px;
  background: var(--line, #E5DCCB);
  margin: 12px 0;
  border: 0;
}

.app-info-popover__badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.app-info-popover__badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft, #F4DDCF);
  color: var(--accent, #B85C38);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.app-info-popover__badge--warning {
  background: var(--warning-soft, #F2E2BE);
  color: var(--warning, #C0883A);
}

.app-info-popover__badge--danger {
  background: var(--danger-soft, #F1D2D2);
  color: var(--danger, #A53D3D);
}

.app-info-popover__badge--success {
  background: var(--success-soft, #DEE7D2);
  color: var(--success, #4F7D3F);
}

.app-info-scrim { display: none; }

@media (max-width: 599px) {
  .app-info-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
  }

  .app-info-popover {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    min-width: 0;
    max-width: none;
    width: 100%;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.18);
    padding: 18px 18px 22px;
    max-height: 70vh;
    overflow-y: auto;
  }

  .app-info-popover::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    background: var(--line, #E5DCCB);
    border-radius: 2px;
    margin: -4px auto 14px;
  }
}

@media (pointer: coarse) {
  .app-info-chip {
    min-height: 44px;
    padding: 10px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-info-chip { transition: none; }
}


@media (max-width: 899px) {
  .creator-actionbar {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px;
  }
  .creator-actionbar__actions {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
    gap: 6px;
  }
}

@media (max-width: 599px) {
  .creator-actionbar {
    padding: 8px 10px;
    gap: 6px;
  }
  .creator-actionbar__primary {
    width: 100%;
  }
  .creator-actionbar__btn--primary {
    flex: 1 1 100%;
    justify-content: center;
  }
}

/* 44px touch targets on coarse pointers (phones, tablets). */
@media (pointer: coarse) {
  .creator-actionbar__btn {
    min-height: 44px;
    padding: 8px 14px;
  }
  .creator-actionbar__menu-item {
    min-height: 44px;
  }
}

/* prefers-reduced-motion suppresses the hover transition. */
@media (prefers-reduced-motion: reduce) {
  .creator-actionbar__btn {
    transition: none;
  }
}

/* Q2/I5 (audit) — at the smallest phones (<360px) the Track + Export
   labels collapse to icon-only so the row stays single-line.
   Title/aria-label preserved for accessibility. */
@media (max-width: 359px) {
  .creator-actionbar__btn:not(.creator-actionbar__btn--primary) span {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .creator-actionbar__btn:not(.creator-actionbar__btn--primary) {
    min-width: 44px;
    padding: 8px 10px;
  }
}



/* ---------------------------------------------------------
   Phase 6 (UX-12) - Header consolidation
   Project switcher dropdown in the topbar + small chevron
   wrapper used by the existing page/file dropdowns. Workshop
   tokens only; 44px coarse-pointer targets; reduced-motion
   suppresses the open transitions.
   --------------------------------------------------------- */
.tb-page-btn-chev {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  font-size: 12px;
  opacity: 0.6;
  color: currentColor;
}

.tb-proj-switcher {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}
.tb-proj-switcher__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-pill, 999px);
  color: var(--text-primary);
  font: 500 12px/1 var(--font-ui, inherit);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  max-width: 220px;
}
@media (hover: hover){
.tb-proj-switcher__btn:hover {
  background: var(--surface-tertiary);
  border-color: var(--accent);
}
}
.tb-proj-switcher__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.tb-proj-switcher__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
  text-transform: uppercase;
}
.tb-proj-switcher__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.tb-proj-switcher__chev {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  opacity: 0.6;
  color: var(--text-secondary);
}
/* Tablet widths (the header passes `status`): the switcher, the progress figure and the save state are ONE
   capsule, so nothing clips and the File menu stays on screen at 768 and 1024. The save label is spoken, not
   shown; a problem is never reduced to an icon (same rule as the phone block). */
.tb-proj-switcher--merged{border:1px solid var(--border);background:var(--surface);border-radius:var(--radius-pill, 999px);padding-right:8px;gap:2px;}
.tb-proj-switcher--merged .tb-proj-switcher__btn{border:0;background:transparent;border-radius:var(--radius-pill, 999px);max-width:160px;min-width:0;}
.tb-proj-switcher--merged .tb-proj-switcher__name{max-width:96px;}
.tb-proj-switcher__status{position:relative;display:inline-flex;align-items:center;gap:4px;flex-shrink:0;}
.tb-proj-switcher__status .tb-proj-badge-saved{padding:0 2px;}
.tb-proj-switcher__status .tb-proj-badge-saved svg{width:16px;height:16px;}
.tb-proj-switcher__status .tb-save-label{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;padding:0;}
.tb-proj-switcher__status .tb-proj-badge-saved--error .tb-save-label{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto;}
.tb-proj-switcher__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 600;
  min-width: 240px;
  max-width: 320px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 10px);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.12));
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tb-proj-switcher__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  color: var(--text-primary);
  text-align: left;
  width: 100%;
  transition: background 0.15s ease;
}
.tb-proj-switcher__item:hover,
.tb-proj-switcher__item:focus-visible {
  background: var(--surface-tertiary);
  outline: none;
}
.tb-proj-switcher__item--all {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 8px;
  color: var(--accent);
  font-weight: 600;
  justify-content: center;
}
.tb-proj-switcher__item-text {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.tb-proj-switcher__item-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}
.tb-proj-switcher__item-pct {
  font-size: 11px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.tb-proj-switcher__empty {
  padding: 10px 8px;
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
}

@media (pointer: coarse) {
  .tb-proj-switcher__btn { min-height: 44px; }
  .tb-proj-switcher__item { min-height: 44px; }
  .name-prompt-input { min-height: 44px; font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .tb-proj-switcher__btn,
  .tb-proj-switcher__item { transition: none; }
}
/* === END Phase 6 (UX-12) — Header consolidation === */

/* === UX-12 Phase 7 — /home landing ============================
   Workshop-styled cross-mode landing page (home.html / home-app.js).
   Workshop tokens only. 44px touch targets on coarse pointers.
   prefers-reduced-motion suppresses transitions. */

.home-shell {
  background: var(--surface-secondary);
  min-height: 100vh;
}
.home-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--s-5, 24px) var(--s-5, 24px) var(--s-7, 48px);
  display: flex;
  flex-direction: column;
  gap: var(--s-5, 24px);
}
.home-hero { padding: var(--s-3, 12px) 0 0; }

.home-section__title {
  margin: 0 0 var(--s-3, 12px);
  font-size: var(--text-md, 13px);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  font-weight: 600;
  display: flex;
  align-items: center;
}
.home-section__more {
  margin-left: auto;
  font-size: var(--text-sm, 12px);
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  text-decoration: none;
}
@media (hover: hover){.home-section__more:hover { text-decoration: underline; }}

/* Footer */
.home-footer {
  display: flex;
  gap: var(--s-4, 16px);
  justify-content: center;
  padding: var(--s-4, 16px) 0;
  font-size: var(--text-sm, 12px);
}
.home-footer__link {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  padding: 4px 8px;
}
@media (hover: hover){.home-footer__link:hover { color: var(--accent); text-decoration: underline; }}

/* Mobile reflow */
@media (max-width: 599px) {
  .home-page { padding: var(--s-3, 12px) var(--s-3, 12px) var(--s-6, 32px); gap: var(--s-4, 16px); }
}

@media (pointer: coarse) {
  .home-footer__link { min-height: 44px; }
}

/* ─────────────────────────────────────────────────────────────────────────
   Combo A — Tab bar + Project Hub (home-app.js rewrite)
───────────────────────────────────────────────────────────────────────── */

/* ── Base button styles used by home-app.js ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2, 8px);
  padding: 8px 14px;
  font-size: var(--text-sm, 12px);
  font-weight: 600;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
  transition: background var(--motion, 160ms ease-out), color var(--motion, 160ms ease-out);
}
@media (hover: hover){.btn:hover { background: var(--surface-tertiary); color: var(--text-primary); }}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--surface); border-color: var(--accent); }
@media (hover: hover){.btn-primary:hover { background: var(--accent-hover, #9E4D2F); border-color: var(--accent-hover, #9E4D2F); color: var(--surface); }}
/* ── btn-sm modifier (used by project row Track / Edit buttons) ── */
.btn-sm { padding: 5px 11px; font-size: var(--text-sm, 12px); }

/* ── Home: "Ask what they have" (home-app.js) ──────────────────────────
   reports/home-redesign-proposals.md, Option 1. Workshop tokens only. */
.home-page { max-width: 1040px; gap: var(--s-6); position: relative; padding-top: var(--s-6); }
.home-muted { color: var(--text-secondary); margin: 0; }
.home-small { font-size: var(--text-sm); }
.home-eyebrow { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-secondary); }
.home-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl); }
.home-link { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--accent-text); cursor: pointer; text-decoration: none; }
@media (hover: hover) { .home-link:hover { text-decoration: underline; } }
.home-section__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-4); }
.home-section__heading { margin: 0 0 var(--s-4); font-size: 20px; font-weight: 700; letter-spacing: -0.01em; color: var(--text-primary); }
.home-section__head .home-section__heading { margin: 0; }

/* Hero (first visit) */
.home-hero { padding: 0; }
.home-hero__title { margin: 0; font-size: 34px; line-height: 1.15; letter-spacing: -0.02em; max-width: 20ch; color: var(--text-primary); }
.home-hero__lede { margin: var(--s-3) 0 0; font-size: 16px; line-height: 1.5; color: var(--text-secondary); max-width: 58ch; }
.home-hero__trust { list-style: none; margin: var(--s-4) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }
.home-hero__trust li { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-md); color: var(--text-secondary); }
.home-hero__trust li > span { display: inline-flex; color: var(--success); }

/* Start cards */
.home-intents { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); }
.home-intent {
  display: flex; flex-direction: column; gap: 10px; text-align: left; font: inherit; color: var(--text-primary);
  padding: 22px; min-height: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; text-decoration: none;
  transition: border-color var(--motion), box-shadow var(--motion), transform var(--motion);
}
@media (hover: hover) { .home-intent:hover { border-color: var(--accent-border); box-shadow: var(--shadow); transform: translateY(-1px); filter: none; } }
.home-intent:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.home-intent--disabled, .home-intent:disabled { opacity: 0.5; pointer-events: none; }
.home-intent__art { width: 48px; height: 48px; border-radius: var(--radius-xl); background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-size: 24px; flex-shrink: 0; }
.home-intent__title { font-size: var(--text-xl); line-height: 1.25; }
.home-intent__desc { font-size: var(--text-lg); line-height: 1.45; color: var(--text-secondary); }
.home-intent__foot { margin-top: auto; padding-top: var(--s-2); display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); font-size: var(--text-sm); color: var(--text-tertiary); }
.home-intent__go { display: inline-flex; align-items: center; gap: 2px; font-size: var(--text-md); font-weight: 600; color: var(--accent-text); white-space: nowrap; }
.home-intent__go > span { display: inline-flex; }
/* Compact row for returning users: the same three cards, smaller. */
.home-intents--compact { gap: var(--s-3); }
.home-intents--compact .home-intent { min-height: 0; flex-direction: row; align-items: center; gap: var(--s-3); padding: 14px; border-radius: var(--radius-lg); }
.home-intents--compact .home-intent__art { width: 36px; height: 36px; font-size: 18px; border-radius: var(--radius-lg); }
.home-intent__copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.home-intent__copy strong { font-size: var(--text-lg); }
.home-intent__copy small { font-size: var(--text-sm); color: var(--text-secondary); }

.home-below-cards { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-5); margin-top: var(--s-3); font-size: var(--text-sm); color: var(--text-tertiary); }
.home-below-cards__drop { display: inline-flex; align-items: center; gap: 6px; }
.home-below-cards__drop > span { display: inline-flex; }
.home-files-help { margin: var(--s-3) 0 0; padding: 14px var(--s-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); font-size: var(--text-md); color: var(--text-secondary); display: grid; gap: 4px; }
.home-files-help dt { font-weight: 600; color: var(--text-primary); }
.home-files-help dd { margin: 0 0 var(--s-2); line-height: 1.5; }
.home-files-help__more { margin: 0; }
.home-files-help[hidden] { display: none; }

/* Drop anywhere */
.home-drop-hint { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; border: 2px dashed var(--accent); border-radius: var(--radius-xl); background: var(--accent-soft); pointer-events: none; }
.home-drop-hint span { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--text-xl); font-weight: 600; color: var(--accent-text); background: var(--surface); padding: var(--s-3) var(--s-4); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.home-create-file-input, .home-import-file-input { display: none; }

/* Practice pattern */
.home-practice { padding: 18px 20px; }
.home-practice__head { display: grid; grid-template-columns: 48px 1fr; gap: var(--s-4); align-items: center; }
.home-practice__art { width: 48px; height: 48px; border-radius: var(--radius-xl); background: var(--tint-fabric); color: var(--text-secondary); display: grid; place-items: center; font-size: 22px; }
.home-practice__title { margin: 0 0 2px; font-size: 15px; font-weight: 700; color: var(--text-primary); }
.home-practice__head p { font-size: var(--text-md); line-height: 1.5; }
.home-sample { margin-top: var(--s-3); }
.home-sample > summary { list-style: none; display: inline-flex; min-height: 40px; }
.home-sample > summary::-webkit-details-marker { display: none; }
.home-sample[open] > summary { margin-bottom: var(--s-3); }
.home-sample__body h3 { margin: 0 0 var(--s-2); font-size: var(--text-lg); }
.home-sample p { line-height: 1.6; color: var(--text-secondary); }
.home-sample__threads { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-block: var(--s-2); }
.home-sample__threads button { min-height: 44px; }
.home-sample__threads [aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.home-sample__chart { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, 1fr); aspect-ratio: 1; width: 288px; max-width: 100%; margin-block: var(--s-3); }
.home-sample__cell { border: 1px solid var(--border); color: var(--text-primary); background: var(--surface-secondary); font-weight: 700; cursor: pointer; }
.home-sample__cell:disabled { opacity: .45; cursor: default; }
.home-sample__cell[aria-pressed="true"] { background: var(--accent-light); }
.home-sample__cell svg { width: 20px; height: 20px; }
.home-sample__cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }

/* How it fits together */
.home-how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); }
.home-how__item { display: grid; grid-template-columns: 36px 1fr; gap: 4px var(--s-3); align-items: start; }
.home-how__art { grid-row: span 2; width: 36px; height: 36px; border-radius: var(--radius-lg); background: var(--surface-tertiary); color: var(--text-secondary); display: grid; place-items: center; font-size: 18px; }
.home-how__item strong { font-size: var(--text-lg); color: var(--text-primary); }
.home-how__item p { margin: 0; font-size: var(--text-md); line-height: 1.5; color: var(--text-secondary); }

/* Returning: welcome + Continue */
.home-welcome__title { margin: 0 0 2px; font-size: 26px; letter-spacing: -0.02em; color: var(--text-primary); }
.home-continue { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: var(--s-5); align-items: center; padding: 20px; }
.home-continue__name { margin: 4px 0 6px; font-size: 22px; letter-spacing: -0.01em; color: var(--text-primary); }
.home-continue__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--text-md); color: var(--text-secondary); margin-bottom: 10px; }
.home-continue__meta > span { display: inline-flex; align-items: center; gap: 5px; }
.home-continue__meta strong { color: var(--text-primary); }
.home-continue__bar { height: 8px; max-width: 520px; }
.home-continue__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-4); align-items: center; }
.home-continue__actions .btn { font-size: var(--text-md); padding: 9px 14px; }

/* Progress bar */
.home-bar { display: block; height: 6px; border-radius: var(--radius-pill); background: var(--surface-tertiary); overflow: hidden; }
.home-bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.home-bar--done > span { background: var(--success); }

/* Pattern previews */
.home-thumb { display: block; width: 100%; aspect-ratio: 1; border-radius: var(--radius-md); overflow: hidden; background: var(--tint-fabric); }
.home-thumb__img { width: 100% !important; height: 100% !important; object-fit: contain; border-radius: 0 !important; background: transparent !important; }
.home-thumb--empty { display: grid; place-items: center; color: var(--text-tertiary); font-size: 30px; background: var(--surface-tertiary); }

/* Filters */
.home-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.home-filter { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text-secondary); border-radius: var(--radius-pill); padding: 4px 12px; font: inherit; font-size: var(--text-sm); font-weight: 500; cursor: pointer; }
.home-filter[aria-pressed="true"] { background: var(--text-primary); border-color: var(--text-primary); color: var(--surface); }
.home-filter__n { opacity: 0.75; }

/* Project cards */
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s-4); }
.home-pcard { position: relative; padding: var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); transition: border-color var(--motion), box-shadow var(--motion); }
@media (hover: hover) { .home-pcard:hover { border-color: var(--accent-border); box-shadow: var(--shadow); } }
.home-pcard__main { display: flex; flex-direction: column; gap: var(--s-2); width: 100%; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
@media (hover: hover) { .home-pcard__main:hover { filter: none; } }
.home-pcard__main:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius-md); }
.home-pcard__name { font-weight: 600; font-size: var(--text-lg); line-height: 1.3; color: var(--text-primary); overflow-wrap: anywhere; }
.home-pcard__row { display: flex; justify-content: space-between; align-items: center; gap: var(--s-2); font-size: var(--text-sm); color: var(--text-secondary); }
.home-pcard__ready { align-self: flex-start; }
.home-pcard > .home-pcard__menu { position: absolute; top: 18px; right: 18px; }
.home-pcard__menu .home-menu__btn { background: var(--surface); box-shadow: var(--shadow-sm); }
.home-draft-row { border-style: dashed; }
.home-draft-row__actions { display: flex; gap: var(--s-2); }
.home-show-all { align-self: center; margin-top: var(--s-4); }
.home-section .home-show-all { display: flex; margin-inline: auto; }
.home-chip { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); font-weight: 600; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--surface-tertiary); color: var(--text-secondary); white-space: nowrap; }
.home-chip--ok { background: var(--success-soft); color: var(--success-text); }

/* More menu */
.home-menu { position: relative; display: inline-flex; }
.home-menu__btn { width: 32px; height: 32px; padding: 0; justify-content: center; }
.home-continue__actions .home-menu__btn { width: 38px; height: 38px; }
.home-menu__list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 220px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.home-menu__item { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--radius-sm); background: none; font: inherit; font-size: var(--text-md); color: var(--text-primary); text-align: left; cursor: pointer; }
.home-menu__item:hover, .home-menu__item:focus-visible { background: var(--surface-tertiary); filter: none; outline: none; }
.home-menu__icon { display: inline-flex; color: var(--text-secondary); padding-top: 1px; }
.home-menu__text small { display: block; font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 1px; }

/* Dialogs: photo question and project details */
.home-dialog { padding: var(--s-5); display: grid; gap: var(--s-3); }
.home-dialog__title { margin: 0; padding-right: var(--s-6); font-size: var(--text-xl); color: var(--text-primary); }
.home-dialog__file { display: flex; align-items: center; gap: var(--s-2); margin: 0; padding: 10px 12px; font-size: var(--text-md); background: var(--surface-secondary); border: 1px solid var(--line); border-radius: var(--radius-md); overflow-wrap: anywhere; }
.home-dialog__file > span { display: inline-flex; color: var(--text-secondary); }
.home-dialog__text { margin: 0; font-size: var(--text-lg); line-height: 1.5; color: var(--text-secondary); }
.home-dialog__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: flex-end; }
.home-choice-list { display: grid; gap: 10px; }
.home-choice { display: grid; grid-template-columns: 40px 1fr; gap: var(--s-3); align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); font: inherit; color: var(--text-primary); text-align: left; cursor: pointer; }
@media (hover: hover) { .home-choice:hover { border-color: var(--accent-border); background: var(--surface-secondary); filter: none; } }
.home-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.home-choice__art { width: 40px; height: 40px; border-radius: var(--radius-lg); background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-size: 20px; }
.home-choice strong { display: block; font-size: var(--text-lg); }
.home-choice small { display: block; font-size: var(--text-sm); color: var(--text-secondary); margin-top: 2px; }
.home-details { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--s-4); margin: 0; font-size: var(--text-md); }
.home-details dt { color: var(--text-secondary); }
.home-details dd { margin: 0; color: var(--text-primary); }

/* Footer (Restore a backup clicks a hidden file input) */
.home-footer { border-top: 1px solid var(--line); padding-top: var(--s-4); }
.home-footer__file { display: none; }

/* Hand-off overlay while a picture goes to the Creator. */
.home-create-pending { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-3); background: var(--surface); border-radius: var(--radius-lg); z-index: 7; }
.home-create-pending__spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: home-create-pending-spin 0.9s linear infinite; }
.home-create-pending__msg { font-size: var(--text-md); font-weight: 600; color: var(--text-primary); }
@keyframes home-create-pending-spin { to { transform: rotate(360deg); } }
.creator-boot-spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--accent);
  animation: home-create-pending-spin 0.9s linear infinite;
}

/* Dark theme: the legacy html.pref-dark button / a rules (!important) would
   paint every Home card, link and filter grey or accent. Keep Home's own look. The doubled class out-ranks that rule's :not() chain. */
html.pref-dark .home-shell .home-page .home-intent.home-intent,
html.pref-dark .home-shell .home-page .home-choice.home-choice { background: var(--surface) !important; color: var(--text-primary) !important; border-color: var(--line) !important; }
html.pref-dark .home-shell .home-page .home-pcard__main.home-pcard__main { background: transparent !important; color: var(--text-primary) !important; border-color: transparent !important; }
html.pref-dark .home-shell .home-page .home-link.home-link { background: transparent !important; color: var(--accent-text) !important; border-color: transparent !important; }
html.pref-dark .home-shell .home-page .home-footer__link.home-footer__link { background: transparent !important; color: var(--text-tertiary) !important; border-color: transparent !important; }
html.pref-dark .home-shell .home-page .home-filter.home-filter { background: var(--surface) !important; color: var(--text-secondary) !important; border-color: var(--line-2) !important; }
html.pref-dark .home-shell .home-page .home-filter.home-filter[aria-pressed="true"] { background: var(--text-primary) !important; color: var(--surface) !important; border-color: var(--text-primary) !important; }
html.pref-dark .home-shell .home-page .home-menu__item.home-menu__item { background: transparent !important; color: var(--text-primary) !important; border-color: transparent !important; }
html.pref-dark .home-shell .home-page .home-menu__item.home-menu__item:hover,
html.pref-dark .home-shell .home-page .home-menu__item.home-menu__item:focus-visible { background: var(--surface-tertiary) !important; }

/* Phone: one column, two project cards per row (walkthrough F15). */
@media (max-width: 640px) {
  .home-page { padding-top: var(--s-5); gap: var(--s-5); }
  .home-hero__title { font-size: 26px; }
  .home-hero__lede { font-size: 15px; }
  .home-hero__trust { flex-direction: column; gap: 6px; }
  .home-intents, .home-how { grid-template-columns: 1fr; }
  .home-intent { min-height: 0; display: grid; grid-template-columns: 48px 1fr; gap: 4px 14px; padding: var(--s-4); }
  .home-intent__art { grid-row: span 2; }
  .home-intent__foot { grid-column: 1 / -1; padding-top: 6px; }
  .home-intents--compact .home-intent { display: flex; }
  .home-continue { grid-template-columns: 88px minmax(0, 1fr); gap: 14px; padding: 14px; }
  .home-continue__name { font-size: 18px; }
  .home-continue__body { display: contents; }
  .home-continue__body > .home-eyebrow, .home-continue__body > .home-continue__name, .home-continue__body > .home-continue__meta { grid-column: 2; }
  .home-continue__body > .home-continue__bar, .home-continue__body > .home-continue__actions { grid-column: 1 / -1; margin-top: 0; }
  .home-continue__thumb { grid-row: span 3; align-self: start; }
  .home-continue__actions { flex-wrap: nowrap; }
  .home-continue__actions .btn { padding: 9px 10px; }
  .home-continue__actions .btn-primary { flex: 1; min-width: 0; justify-content: center; }
  .home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .home-pcard { padding: var(--s-2); }
  .home-pcard > .home-pcard__menu { top: 12px; right: 12px; }
  .home-pcard__row { flex-wrap: wrap; }
  .home-draft-row__actions { flex-wrap: wrap; }
  .home-section__heading { font-size: 18px; }
}

/* Touch: 44px targets. */
@media (pointer: coarse) {
  .home-menu__btn, .home-continue__actions .home-menu__btn { width: 44px; height: 44px; }
  .home-filter { min-height: 44px; }
  .home-menu__item { min-height: 44px; align-items: center; }
  .home-link { min-height: 44px; }
  .home-draft-row__actions .btn-sm, .home-continue__actions .btn { min-height: 44px; }
  .home-sample > summary { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .home-intent, .home-pcard { transition: none; }
  @media (hover: hover) { .home-intent:hover { transform: none; } }
  .home-create-pending__spinner, .creator-boot-spinner { animation: none; }
  .home-screen { animation: none; }
}

/* ═════════════════════════════════════════════════════════
   Polish pass — accessibility safety net
   (focus-visible replacements for elements that strip outline,
   generic disabled state, and a few mobile-drawer reduced-motion
   guards). Appended at the end of the file so component rules
   override where appropriate but disabled/focus styles always
   land last.
   ═════════════════════════════════════════════════════════ */

/* Replace stripped outlines with a visible focus ring whenever
   the element receives keyboard focus. */
.tb-proj-badge-input:focus-visible,
.tb-context-name-input:focus-visible,
.session-toast input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Generic disabled affordance. Component-level rules can still
   opt out by being more specific. */
button:disabled,
button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Mobile drawer / immersive-toolbar transitions should respect
   the reduced-motion preference. */
@media (prefers-reduced-motion: reduce) {
  .rpanel,
  .mgr-rpanel,
  .colour-quick-drawer,
  .tb-topbar,
  .toolbar-row {
    transition: none !important;
    animation: none !important;
  }
}


/* --- Polish 13 (UX-12) — Sidebar tab bar redesign --------------------
   Replaces the cramped 5-7 text-only tabs with icon+label pill cards
   in a flex-wrap row. Each tab has a clear hover/active/disabled
   state. Disabled tabs (Phase 1 of the consolidation plan) show a
   small lock badge in the corner. */
.creator-sidebar-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border, var(--line, #E5DCCB));
  scrollbar-width: none;
}
.creator-sidebar-tabs::-webkit-scrollbar { display: none; }
.creator-sidebar-tab {
  flex: 1 1 56px;
  min-width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border: 1px solid transparent;
  background: var(--surface-secondary, var(--surface-2, #F9F5F0));
  border-radius: var(--radius-md, 8px);
  font: 600 11px/1 inherit;
  color: var(--text-secondary, #5C5448);
  cursor: pointer;
  position: relative;
  min-height: 50px;
  font-family: inherit;
  transition: background .12s ease, color .12s ease, border-color .12s ease, transform .08s ease;
}
.creator-sidebar-tab svg {
  width: 18px;
  height: 18px;
  display: block;
}
.creator-sidebar-tab__label {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
@media (hover: hover){
.creator-sidebar-tab:hover:not([aria-disabled="true"]):not([aria-selected="true"]) {
  background: var(--accent-soft, var(--accent-light, #F4DDCF));
  color: var(--text-primary, #1B1814);
  border-color: var(--accent, #B85C38);
}
}
.creator-sidebar-tab[aria-selected="true"] {
  background: var(--accent, #B85C38);
  color: #FFFDF8;
  border-color: var(--accent, #B85C38);
  box-shadow: 0 1px 0 var(--accent-hover, #9E4D2F) inset;
}
@media (hover: hover){
.creator-sidebar-tab[aria-selected="true"]:hover {
  background: var(--accent-hover, var(--accent, #B85C38));
}
}
.creator-sidebar-tab[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}
@media (hover: hover){
.creator-sidebar-tab[aria-disabled="true"]:hover {
  background: var(--surface-secondary, var(--surface-2, #F9F5F0));
}
}
.creator-sidebar-tab__lock {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  opacity: 0.75;
  pointer-events: none;
}
.creator-sidebar-tab:focus-visible {
  outline: 2px solid var(--accent, #B85C38);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .creator-sidebar-tab { transition: none; }
}

/* Locked-tab hint pill shown in the panel body when a disabled tab is
   focused. Used by the Phase 1+ unified sidebar to tell users why
   Tools / View are not yet available. */
.creator-sidebar-locked {
  margin: 16px 12px;
  padding: 16px 14px;
  background: var(--surface-secondary, #F9F5F0);
  border: 1.5px dashed var(--border-strong, var(--border, #D0C4B4));
  border-radius: var(--radius-md, 8px);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.creator-sidebar-locked__title {
  font: 600 13px/1.2 inherit;
  color: var(--text-primary, #1B1814);
}
.creator-sidebar-locked__body {
  font-size: 12px;
  color: var(--text-secondary, #5C5448);
  line-height: 1.45;
  max-width: 240px;
}
.creator-sidebar-locked__cta {
  margin-top: 4px;
  padding: 6px 12px;
  font: 600 12px/1 inherit;
  color: var(--accent-hover, #9E4D2F);
  background: var(--accent-light, #FBF0EB);
  border: 1px solid var(--accent-soft, #F4DDCF);
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  font-family: inherit;
}
@media (hover: hover){
.creator-sidebar-locked__cta:hover {
  background: var(--accent-soft, #F4DDCF);
}
}

/* -----------------------------------------------------------------------
   Import Review Modal (import-engine/ui/ImportReviewModal.js)
   Uses the canonical Workshop tokens (--s-N spacing, --line, --surface,
   --accent, --radius-*, --shadow-*) and the shared .g-btn button family
   so the modal sits in the same visual language as every other dialog
   in the app. The layout is unchanged from the original implementation.
   ----------------------------------------------------------------------- */

.import-review-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-4);
  animation: overlay-scrim-fade var(--motion, 160ms) ease-out;
}
.import-review-modal {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template:
    "header header" auto
    "design design" auto
    "tabs   tabs"   auto
    "verify verify" auto
    "body   warn"   1fr
    "footer footer" auto / 1fr 280px;
  width: min(1100px, 100%);
  height: min(720px, 95vh);
  overflow: hidden;
  font-family: inherit;
}
.import-review-header {
  grid-area: header;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
}
.import-review-header h2 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.import-review-coverage {
  display: inline-flex; align-items: center; gap: var(--s-2);
  color: var(--text-secondary);
  font-size: var(--text-md);
}
.import-review-coverage > svg { width: 16px; height: 16px; }
.import-review-close {
  background: transparent; border: none; color: var(--text-secondary);
  cursor: pointer; padding: var(--s-1);
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
}
@media (hover: hover){.import-review-close:hover { color: var(--text-primary); background: var(--surface-tertiary); }}
.import-review-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.import-review-close > svg { width: 18px; height: 18px; }

.import-review-tabs {
  grid-area: tabs;
  display: flex; gap: 0;
  border-bottom: 1px solid var(--line);
  padding: 0 var(--s-3);
  background: var(--surface-tertiary);
}
.import-review-tab {
  background: transparent; border: none;
  padding: var(--s-2) var(--s-3);
  color: var(--text-secondary); cursor: pointer;
  display: inline-flex; align-items: center; gap: var(--s-2);
  border-bottom: 2px solid transparent;
  font: inherit; font-size: var(--text-md); line-height: 1.2;
}
.import-review-tab > svg { width: 16px; height: 16px; flex-shrink: 0; }
@media (hover: hover){.import-review-tab:hover { color: var(--text-primary); background: var(--surface); }}
.import-review-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.import-review-tab.active {
  color: var(--accent); border-bottom-color: var(--accent);
  background: var(--surface);
}

.import-review-body {
  grid-area: body;
  overflow: auto; padding: var(--s-4);
  min-width: 0;
  background: var(--surface);
}
.import-preview-pane {
  display: flex; flex-direction: column; gap: var(--s-2);
  align-items: flex-start;
  height: 100%;
}
.import-review-warnings {
  grid-area: warn;
  border-left: 1px solid var(--line);
  padding: var(--s-3);
  overflow: auto;
  background: var(--surface);
}
.import-warnings { list-style: none; margin: 0; padding: 0; }
.import-warnings.empty {
  display: flex; align-items: center; gap: var(--s-2);
  color: var(--success);
  font-size: var(--text-md);
}
.import-warnings.empty > svg { width: 16px; height: 16px; }
.import-warning {
  display: flex; align-items: flex-start; gap: var(--s-2);
  padding: var(--s-2) 0; border-bottom: 1px solid var(--line);
  font-size: var(--text-md);
  color: var(--text-secondary);
}
.import-warning > svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.import-warning.high { color: var(--danger); }
.import-warning.medium { color: var(--warning); }

.import-review-footer {
  grid-area: footer;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.import-review-toggle {
  flex: 1;
  display: inline-flex; align-items: center; gap: var(--s-2);
  color: var(--text-secondary);
  font-size: var(--text-md);
  cursor: pointer;
}
.import-review-actions { display: flex; gap: var(--s-2); }

/* ── Pages tab: check and correct where each page of a PDF chart goes ── */
.page-layout { display: flex; flex-direction: column; gap: var(--s-3); }
.page-layout h3 {
  margin: 0 0 var(--s-2); font-size: var(--text-md); font-weight: 600; color: var(--text-primary);
}
.page-layout-intro {
  margin: 0; padding: var(--s-2) var(--s-3);
  border-radius: var(--radius-md);
  background: var(--surface-secondary); color: var(--text-secondary);
  font-size: var(--text-md); line-height: 1.4;
}
.page-layout-intro.attention { background: var(--warning-soft); color: var(--text-primary); }
.page-layout-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4); }
.page-layout-stepper {
  display: inline-flex; align-items: center; gap: var(--s-2);
  color: var(--text-secondary); font-size: var(--text-md);
}
.page-layout-stepper .g-btn { padding: var(--s-1); }
.page-layout-stepper .g-btn > svg { width: 16px; height: 16px; }
.page-layout-stepper .g-btn:disabled { opacity: 0.45; cursor: default; }
.page-layout-value {
  min-width: 2ch; text-align: center; font-weight: 700; color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.page-layout-hint { margin: 0; color: var(--text-tertiary); font-size: var(--text-sm); }
.page-layout-grid { display: grid; gap: var(--s-2); }
.page-layout-slot { min-width: 0; }
.page-layout-tile {
  width: 100%; min-height: 96px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-1);
  padding: var(--s-2);
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text-primary);
  font: inherit; cursor: pointer;
  touch-action: manipulation;
}
@media (hover: hover) { .page-layout-tile:hover { border-color: var(--accent); } }
.page-layout-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.page-layout-tile.selected {
  border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent);
  background: var(--accent-light);
}
.page-layout-tile.empty {
  border-style: dashed; background: var(--surface-secondary); color: var(--text-tertiary);
}
.page-layout-empty { font-size: var(--text-sm); }
.page-layout-thumb {
  max-width: 100%; height: auto;
  border: 1px solid var(--border-subtle); background: var(--surface-secondary);
  image-rendering: pixelated;
}
.page-layout-label { font-size: var(--text-md); font-weight: 600; }
.page-layout-size { font-size: var(--text-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.page-layout-selected-actions { display: flex; gap: var(--s-2); }
.page-layout-tray-list { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.page-layout-tray-list .page-layout-tile { width: auto; min-width: 120px; min-height: 0; }
.page-layout-result .import-preview-pane { height: auto; }
/* Dragging with a finger: holding a page must not select text or open the
   long-press menu, the page held fades, and where it would land is marked. */
.page-layout-tile { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.page-layout-tile.lifted { opacity: 0.4; }
.page-layout-slot.drop-target .page-layout-tile,
.page-layout-tray.drop-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.page-layout-tray.drop-target { border-radius: var(--radius-md); }
.page-layout-tray-hint { margin: 0; color: var(--text-tertiary); font-size: var(--text-sm); }
.page-layout-ghost {
  position: fixed; z-index: var(--z-toast); pointer-events: none;
  transform: translate(-50%, -120%);
  padding: var(--s-1) var(--s-3); border-radius: var(--radius-md);
  background: var(--accent); color: var(--surface); font-weight: 600; font-size: var(--text-md);
  box-shadow: var(--shadow-md);
}

/* The footer buttons are plain `.g-btn` instances — no per-modal overrides. */

.import-preview-canvas {
  display: block; max-width: 100%;
  border: 1px solid var(--line); background: #fff; /* css-tokens-lint-allow: blank fabric, matches the #fff ImportPreviewPane paints in every theme */
  border-radius: var(--radius-sm);
}
.import-preview-meta {
  margin-top: var(--s-2);
  color: var(--text-secondary);
  font-size: var(--text-md);
}

.import-palette-list { display: flex; flex-direction: column; gap: var(--s-1); }
.import-palette-header {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--s-2);
  font-size: var(--text-md);
}
.import-palette-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: var(--s-3); align-items: center;
  padding: var(--s-1) 0;
  font-size: var(--text-md);
}
.import-palette-row.pending {
  padding: var(--s-2); border-radius: var(--radius-sm);
  background: var(--warning-soft);
}
.import-palette-swatch {
  display: block; width: 1.2em; height: 1.2em; flex: none;
  border: 1px solid var(--line); border-radius: 2px;
}
.import-glyph-sample {
  display: block; width: 1.9em; height: 1.9em; flex: none;
  border: 1px solid var(--line); border-radius: 2px; background: var(--surface);
}
.import-palette-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s-2); min-width: 0; }
.import-palette-id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.import-palette-note { color: var(--text-secondary); font-size: var(--text-sm); }
.import-palette-count { color: var(--text-secondary); }
.import-palette-row .g-btn.icon-only { padding: var(--s-1); }
.import-palette-pending {
  display: flex; align-items: flex-start; gap: var(--s-2);
  margin: 0 0 var(--s-2); color: var(--text-primary); font-size: var(--text-md); line-height: 1.4;
}
.import-palette-pending svg { flex: none; width: 1.1em; height: 1.1em; color: var(--warning); margin-top: 0.15em; }
.import-thread-chooser { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.import-thread-input {
  width: 7em; padding: var(--s-1) var(--s-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-primary); font: inherit;
}
.import-thread-input[aria-invalid="true"] { border-color: var(--danger); }
.import-thread-brand {
  padding: var(--s-1); border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-primary); font: inherit;
}
.import-colour-picker {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface);
}
.import-picker-section h4 { margin: 0 0 var(--s-2); font-size: var(--text-sm); color: var(--text-secondary); font-weight: 600; }
.import-picker-swatches { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.import-swatch-btn {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 2.75em; padding: var(--s-1); border: 1px solid transparent; border-radius: var(--radius-sm);
  background: none; color: var(--text-secondary); font: inherit; font-size: var(--text-sm); cursor: pointer;
}
.import-swatch-btn:hover, .import-swatch-btn:focus-visible { border-color: var(--accent); color: var(--text-primary); }
.import-swatch-chip { display: block; width: 1.8em; height: 1.8em; border: 1px solid var(--line); border-radius: 2px; }
.import-swatch-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.import-picker-families { display: flex; flex-wrap: wrap; gap: var(--s-1); margin-bottom: var(--s-2); }
.import-family-btn {
  padding: var(--s-1) var(--s-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-secondary); font: inherit; font-size: var(--text-sm); cursor: pointer;
}
.import-family-btn.active { border-color: var(--accent); color: var(--text-primary); background: var(--accent-soft); }
.import-picker-actions { display: flex; justify-content: flex-end; }
.import-lookalikes {
  display: flex; flex-direction: column; gap: var(--s-2);
  margin-bottom: var(--s-3); padding: var(--s-3);
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.import-lookalikes h3 { margin: 0; font-size: var(--text-md); }
.import-lookalikes-intro, .import-lookalikes-more { margin: 0; color: var(--text-secondary); font-size: var(--text-sm); }
.import-lookalike { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.import-lookalike-pair { display: inline-flex; gap: var(--s-1); }
.import-lookalike-pair .import-glyph-sample { width: 2.6em; height: 2.6em; }
.import-lookalike-names { flex: 1 1 10em; font-size: var(--text-md); }
.import-lookalike-actions { display: inline-flex; gap: var(--s-2); }
.import-thread-match { display: inline-flex; align-items: center; gap: var(--s-1); color: var(--text-secondary); font-size: var(--text-sm); }
.import-thread-error { flex-basis: 100%; color: var(--danger); font-size: var(--text-sm); }
.import-palette-assigned { margin-top: var(--s-4); border-top: 1px solid var(--line); padding-top: var(--s-3); }
.import-palette-assigned h3 { margin: 0 0 var(--s-2); font-size: var(--text-md); }
.import-palette-assigned-row { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-1) 0; font-size: var(--text-md); }
.import-palette-arrow { display: inline-flex; color: var(--text-secondary); }
.import-palette-arrow svg { width: 1em; height: 1em; }
@media (max-width: 600px) {
  .import-palette-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .import-palette-row .import-thread-chooser { grid-column: 1 / -1; }
}

.import-metadata-form {
  display: flex; flex-direction: column;
  gap: var(--s-3);
  max-width: 480px;
}
.import-metadata-form label {
  display: flex; flex-direction: column;
  gap: var(--s-1);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
}
.import-metadata-form input {
  padding: var(--s-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  font-weight: 400;
  min-height: 36px;
}
.import-metadata-form input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
  border-color: var(--accent);
}
.import-metadata-readout {
  display: flex; gap: var(--s-4);
  margin-top: var(--s-3);
  color: var(--text-secondary);
  font-size: var(--text-md);
}

.import-side-by-side {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--s-3); height: 100%;
}
.import-side-pane {
  display: flex; flex-direction: column;
  gap: var(--s-2); height: 100%;
}
.import-side-label { font-weight: 600; color: var(--text-secondary); font-size: var(--text-md); }
.import-side-frame { width: 100%; height: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.import-side-empty {
  color: var(--text-secondary);
  padding: var(--s-3);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  min-height: 160px;
  font-size: var(--text-md);
}

/* Compare-tab iframe needs a real height — without it the modal grid rows
   collapse and the iframe shows as a 1-pixel sliver (which Chrome renders
   as the broken-image placeholder for PDF blobs). */
.import-side-pane { min-height: 0; }
.import-side-frame, .import-side-pane > .import-preview-pane { min-height: 320px; }

.import-progress { display: flex; flex-direction: column; gap: var(--s-1); width: 100%; }
.import-progress-bar { height: 4px; background: var(--accent); border-radius: 2px; transition: width 200ms; }
.import-progress-label { color: var(--text-secondary); font-size: var(--text-md); }

/* A PDF holding several designs: which one to import. */
.import-design-picker {
  grid-area: design;
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3);
  padding: var(--s-2) var(--s-4); border-bottom: 1px solid var(--line);
  font-size: var(--text-md);
}
.import-design-picker label { font-weight: 600; }
.import-design-picker select {
  padding: var(--s-1) var(--s-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-primary); font: inherit; max-width: 100%;
}
.import-design-note { color: var(--text-secondary); font-size: var(--text-sm); }

/* While a file is read, before the review opens (showImportProgress). */
.import-busy {
  position: fixed; left: 50%; bottom: var(--s-5); transform: translateX(-50%);
  z-index: var(--z-toast);
  width: min(360px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); box-shadow: var(--shadow-md);
  color: var(--text-primary);
}
.import-busy-title { font-weight: 600; font-size: var(--text-md); overflow-wrap: anywhere; }
.import-busy-label { color: var(--text-secondary); font-size: var(--text-sm); }
.import-busy-cancel { align-self: flex-end; }
.import-busy-track { position: relative; height: 4px; overflow: hidden; border-radius: 2px; background: var(--line); }
.import-busy-bar { height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width var(--motion, 200ms); }
.import-busy-bar.indeterminate { width: 35%; animation: import-busy-slide 1.2s ease-in-out infinite; }
@keyframes import-busy-slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) {
  .import-busy-bar.indeterminate { animation: none; width: 100%; opacity: 0.5; }
}

/* Mobile: collapse the side rail under the body so neither pane gets
   squashed below 720px wide. */
@media (max-width: 720px) {
  .import-review-modal-overlay { padding: 0; }
  .import-review-modal {
    width: 100%; height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border-left: none; border-right: none;
    grid-template:
      "header" auto
      "design" auto
      "tabs"   auto
      "verify" auto
      "body"   1fr
      "warn"   auto
      "footer" auto / 1fr;
  }
  .import-review-warnings {
    border-left: none;
    border-top: 1px solid var(--line);
    max-height: 30vh;
  }
  .import-review-footer {
    flex-wrap: wrap;
    gap: var(--s-2);
  }
  .import-review-toggle { flex-basis: 100%; order: 2; }
  .import-review-actions { flex: 1; justify-content: flex-end; }
  .import-side-by-side {
    grid-template-columns: 1fr;
  }
}

/* Phones (audit IMPORT-06): a full-screen sheet whose single column can't be
   pushed wider than the screen by its content. The header (title and trust
   figure, which wraps) and the footer stay put while the body scrolls; the
   tab row scrolls sideways with every label shown; notes fold into one line. */
@media (max-width: 600px) {
  .import-review-modal {
    grid-template:
      "header" auto
      "design" auto
      "tabs"   auto
      "verify" auto
      "body"   minmax(0, 1fr)
      "warn"   auto
      "footer" auto / minmax(0, 1fr);
  }
  .import-review-modal > * { min-width: 0; max-width: 100%; box-sizing: border-box; }
  .import-review-modal * { min-width: 0; max-width: 100%; box-sizing: border-box; }
  .import-review-header { flex-wrap: wrap; row-gap: var(--s-1); padding: var(--s-3); }
  .import-review-header h2 { font-size: var(--text-lg); flex: 1 1 0; }
  .import-review-close { order: 2; min-width: 44px; min-height: 44px; }
  .import-review-coverage { order: 3; flex: 1 1 100%; font-size: var(--text-sm); overflow-wrap: anywhere; }
  .import-review-coverage > span { min-width: 0; }
  .import-review-tabs {
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    padding: 0 var(--s-2);
  }
  .import-review-tabs::-webkit-scrollbar { display: none; }
  .import-review-tab { flex: none; white-space: nowrap; min-height: 44px; max-width: none; padding: var(--s-2) 10px; }
  .import-review-body { padding: var(--s-3); }
  .import-design-picker { padding: var(--s-2) var(--s-3); }
  .import-design-picker select { flex: 1 1 auto; }
  .import-review-notes { max-height: 40vh; padding: 0 var(--s-3); }
  .import-review-notes > summary {
    display: flex; align-items: center; gap: var(--s-2);
    min-height: 44px; cursor: pointer; list-style: none;
    color: var(--text-secondary); font-size: var(--text-md); font-weight: 600;
  }
  .import-review-notes > summary::-webkit-details-marker { display: none; }
  .import-review-notes > summary > svg { width: 16px; height: 16px; flex: none; }
  .import-review-notes[open] > summary { border-bottom: 1px solid var(--line); }
  .import-review-footer { padding: var(--s-2) var(--s-3); }
  .import-review-actions { flex-wrap: wrap; }
  .import-review-actions > .g-btn { flex: 1 1 auto; justify-content: center; min-height: 44px; }
  .import-palette-row { grid-template-columns: auto minmax(0, 1fr) auto auto; gap: var(--s-2); }
  .import-thread-chooser > * { flex: 1 1 auto; }
  .import-side-frame { width: 100%; }
  /* Previews and page thumbnails shrink to the screen, keeping their shape. */
  .import-review-modal canvas { height: auto; }
}

/* A thread the importer couldn't identify, until one is chosen (IMPORT-07). */
.thread-placeholder-swatch {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.2em; height: 1.2em; flex: none;
  border: 1px dashed var(--text-tertiary); border-radius: 2px;
  background: repeating-linear-gradient(45deg, var(--surface-tertiary) 0 3px, var(--surface) 3px 6px);
  color: var(--text-secondary);
}
.thread-placeholder-swatch > svg { width: 80%; height: 80%; }

/* ════════════════════════════════════════════════════════════════
   Touch UX pass — compact-touch (real touch devices, ≤1024 px)
   See reports/touch-*.md for the design rationale.

   Goals:
   • 44 × 44 px floor on every interactive control inside .toolbar-row
     and .tracker-action-bar.
   • Toolbar moves to the bottom (thumb zone) and stops being sticky.
   • Canvas scroll container reserves space for the bottom toolbar
     so the chart isn't hidden under it.
   • Lpanel three-state support: .lpanel--rail (56 px collapsed strip)
     and .lpanel--hidden (display: none). Original open behaviour
     preserved when neither class is present.
   • Focus-mode helpers — body.cs-focus hides chrome surfaces; a
     floating mini-bar (.cs-focus-bar) is revealed.
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) and (pointer: coarse) {
  /* Reserve room at the bottom of the page for the fixed toolbar +
     safe-area inset so nothing slides under the home indicator.
     Scoped to Creator so the Tracker's own action-bar layout is
     unaffected (Tracker manages its bottom space separately). */
  body.page-creator { padding-bottom: calc(var(--ct-toolbar-h, 64px) + env(safe-area-inset-bottom, 0px)); }

  /* Bottom-fixed creator toolbar. */
  body.page-creator .toolbar-row {
    position: fixed;
    top: auto !important;
    bottom: 0;
    left: 0;
    right: 0;
    border-bottom: none;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: var(--z-action-bar, 500);
  }
  .pill-row { min-height: 64px; height: auto; padding: 6px 8px; }

  /* 44 px touch target floor for all toolbar buttons. */
  .toolbar-row .tb-btn,
  .toolbar-row .tb-fit-btn,
  .toolbar-row .tb-overflow-btn,
  .toolbar-row .pill .tb-btn {
    min-width: 44px;
    min-height: 44px;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 10px;
    gap: 6px;
  }
  .toolbar-row .tb-grp { gap: 4px; padding: 4px; }

  /* Tracker action bar — same floor + safe-area. */
  .tracker-action-bar {
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
  }
  .tracker-action-bar button,
  .tracker-action-bar .ta-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ── Lpanel three-state rules (apply at every viewport so the JS
      toggle works on desktop too — narrow screens already handled
      by the bottom-sheet rules earlier in this file). ───────────── */
.lpanel--hidden { display: none !important; }
.lpanel--rail {
  width: 56px !important;
  min-width: 56px !important;
  max-width: 56px !important;
  overflow: hidden !important;
  padding: 8px 4px !important;
}
.lpanel--rail .lpanel-section,
.lpanel--rail .lpanel-section-title,
.lpanel--rail .lpanel-row-label {
  display: none !important;
}
.lpanel--rail .lpanel-rail-content { display: flex !important; }
.lpanel-rail-content {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
}
.lpanel-rail-swatch {
  width: 40px; height: 40px;
  border-radius: 8px;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
}
.lpanel-rail-btn {
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 160ms ease-out, border-color 160ms ease-out, color 160ms ease-out;
}
@media (hover: hover){.lpanel-rail-btn:hover { background: var(--accent-light, var(--surface-tertiary)); color: var(--accent); border-color: var(--accent); }}
.lpanel-rail-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Focus mode — strip chrome down to canvas + floating mini-bar ── */
body.cs-focus .header,
body.cs-focus .info-strip,
body.cs-focus .toolbar-row:not(.ppal-mode-strip),
body.cs-focus .tracker-action-bar,
body.cs-focus .rpanel,
body.cs-focus .lpanel:not(.lpanel--open):not(.lpanel--rail),
body.cs-focus .status-bar {
  display: none !important;
}
body.cs-focus { padding-bottom: 0 !important; padding-left: 0 !important; padding-right: 0 !important; }
/* Drop the docked-palette offset (and any padding the canvas wrapper added
   for the bottom toolbar) so the chart can grow to fill the freed viewport.
   The palette itself is hidden above, so nothing is left to clear. */
body.cs-focus .cs-main { margin-left: 0 !important; height: 100vh; max-height: 100vh; }
body.cs-focus .canvas-area,
body.cs-focus .stitch-wrap,
body.cs-focus .stitch-area { flex: 1 1 auto !important; height: 100% !important; max-height: 100vh !important; padding-bottom: env(safe-area-inset-bottom, 0px) !important; }
/* Don't render the lpanel-backdrop scrim either — there's no panel. */
/* (the scrim is only drawn while the colour panel is open, which Focus now leaves alone) */

/* The Focus mini-bar is a fixed pill at the bottom-centre of the
   viewport. Always above modals' backdrop is intentional — it's the
   user's only way out of focus mode.

   Fade behaviour: the bar fades to 60% after a few seconds of
   inactivity so it doesn't dominate the chart. The Exit chip is
   excluded from the fade (it's the user's escape hatch and must
   stay legible at all times). */
.cs-focus-bar {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-coachmark, 1200);
  transition: opacity 220ms ease-out;
}
.cs-focus-bar.cs-focus-bar--faded > *:not(.cs-focus-exit) { opacity: 0.8; }   /* it recedes, but its labels stay readable (0.55 left them at 2.6:1) */
.cs-focus-bar.cs-focus-bar--faded button:not(.cs-focus-exit) { color: var(--text-primary); }
.cs-focus-bar:hover > *,
.cs-focus-bar:focus-within > * { opacity: 1 !important; }
.cs-focus-bar button {
  min-width: 44px; min-height: 44px;
  border: none;
  background: transparent;
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 0 12px;
  transition: opacity 220ms ease-out, background 160ms ease-out, color 160ms ease-out;
}
@media (hover: hover){.cs-focus-bar button:hover { background: var(--surface-tertiary); color: var(--text-primary); }}
.cs-focus-bar button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.cs-focus-bar .cs-focus-swatch {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
  flex-shrink: 0;
}
.cs-focus-bar .cs-focus-exit {
  background: var(--accent);
  color: var(--text-on-accent, #fff);
  font-weight: 700;
  padding: 0 18px;
  margin-left: 6px;
  /* Lift the exit chip with a 2 px ring + drop shadow so it reads
     as the dominant action even against the dimmed bar. */
  box-shadow: 0 0 0 2px var(--surface), 0 2px 6px rgba(0, 0, 0, 0.18);
  letter-spacing: 0.02em;
}
@media (hover: hover){
.cs-focus-bar .cs-focus-exit:hover {
  background: var(--accent-hover);
  color: var(--text-on-accent, #fff);
  box-shadow: 0 0 0 2px var(--surface), 0 4px 10px rgba(0, 0, 0, 0.22);
}
}
.cs-focus-bar .cs-focus-exit:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 3px;
}

/* Persistent status chip at bottom-left of canvas — shows active
   tool + colour so the user always knows what a tap will do. Only
   shown on touch viewports (the desktop has hover affordances). */
@media (max-width: 1024px) and (pointer: coarse) {
  .cs-status-chip {
    position: fixed;
    left: max(12px, env(safe-area-inset-left, 0px));
    bottom: calc(var(--ct-toolbar-h, 64px) + env(safe-area-inset-bottom, 0px) + 12px);
    z-index: var(--z-fab, 450);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-md);
    font-size: 12px;
    color: var(--text-secondary);
    pointer-events: none;
  }
  .cs-status-chip-swatch {
    width: 18px; height: 18px;
    border-radius: 4px;
    border: 1px solid var(--border);
  }
  .cs-status-chip-tool { font-weight: 600; color: var(--text-primary); }
}



/* ----------------------------------------------------------------
   color-3 (C2 + C3): Swatch detail popover and similar-colour
   comparator. See components.js for the React components.
   ---------------------------------------------------------------- */

.swatch-detail-popover {
  position: fixed;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,0.14), 0 1px 3px rgba(0,0,0,0.08);
  padding: 12px;
  width: 240px;
  font-size: 13px;
  color: var(--text-primary);
}
.sdp-header { display: flex; align-items: baseline; gap: 6px; margin-bottom: 10px; }
.sdp-code { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.sdp-name { font-size: 12px; color: var(--text-secondary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sdp-close {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: var(--text-secondary); padding: 2px 4px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; line-height: 1;
}
@media (hover: hover){.sdp-close:hover { color: var(--text-primary); background: var(--surface-tertiary, rgba(0,0,0,0.05)); }}
.sdp-swatch-large {
  width: 56px; height: 56px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); margin-bottom: 12px;
}
.sdp-fabric-row { display: flex; gap: 8px; margin-bottom: 10px; justify-content: space-between; }
.sdp-fabric-item { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.sdp-fabric-bg {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.sdp-fabric-chip { width: 28px; height: 28px; border-radius: 2px; }
.sdp-fabric-label { font-size: 10px; color: var(--text-secondary); text-align: center; line-height: 1.2; }
.sdp-note {
  font-size: 11px; color: var(--text-secondary);
  display: flex; align-items: flex-start; gap: 5px; line-height: 1.4;
  margin: 0 0 6px 0;
}
.sdp-note-icon { display: inline-flex; width: 12px; height: 12px; flex-shrink: 0; margin-top: 1px; }
.sdp-note-icon svg { width: 12px; height: 12px; }
.sdp-similar {
  font-size: 11px; color: var(--text-secondary);
  padding: 6px 8px; background: var(--surface-tertiary, rgba(0,0,0,0.04));
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  line-height: 1.4; margin: 4px 0 0 0;
}

.similar-comparator {
  padding: 14px 16px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-hover, #B7500A);
  border-radius: var(--radius-sm);
  margin: 6px 0 10px;
}
.sc-threads {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 12px; justify-content: space-between;
}
.sc-thread { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 60px; }
.sc-swatch-tall {
  width: 40px; height: 60px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.sc-code { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.sc-name { font-size: 11px; color: var(--text-secondary); text-align: center; max-width: 80px; line-height: 1.3; }
.sc-delta-block {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; flex: 1; gap: 4px; padding-top: 8px;
}
.sc-delta-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sc-delta-desc { font-size: 11px; color: var(--text-secondary); text-align: center; max-width: 140px; line-height: 1.3; }
.sc-fabric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 0 12px;
}
.sc-fabric-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sc-fabric-bg {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.sc-fabric-chip { width: 28px; height: 28px; border-radius: 2px; }
.sc-fabric-label { font-size: 10px; color: var(--text-secondary); text-align: center; line-height: 1.2; }
.sc-note {
  font-size: 11px; color: var(--text-secondary); line-height: 1.5;
  margin: 0 0 10px; font-style: italic;
}
.sc-dismiss { align-self: flex-start; }
.chevron-toggle { transition: transform 160ms ease-out; color: var(--text-secondary); display: inline-flex; }
.chevron-toggle--open { transform: rotate(180deg); }

@media (max-width: 480px) {
  .swatch-detail-popover {
    position: fixed !important;
    left: 8px !important; right: 8px !important;
    bottom: 8px !important; top: auto !important;
    width: auto !important;
  }
}

/* ── App version badge (version.js) ─────────────────────────────── */
#app-version-badge {
  position: fixed;
  bottom: calc(4px + env(safe-area-inset-bottom, 0px));
  right: 8px;
  font-size: 10px;
  line-height: 1;
  color: var(--text-tertiary);
  pointer-events: none;
  user-select: none;
  z-index: 9;
  font-family: inherit;
  letter-spacing: 0.02em;
}
/* On touch/mobile the badge is covered by bottom sheet panels — hide it
   there; the version is accessible via Settings > Version history instead. */
@media (pointer: coarse) {
  #app-version-badge { display: none; }
}

/* ════════════════════════════════════════════════════════════════
   Option 3 — Split Palette UI (UX-12 Phase 3)
   Palette panel replaces the lpanel tab system. Mode strip floats
   on the right edge of the canvas. More panel slides over the canvas.
   ════════════════════════════════════════════════════════════════ */

/* ── Palette panel wrapper (inside .lpanel.lpanel--open) ─────── */
.ppal-wrap{display:flex;flex-direction:column;height:100%;min-height:0;overflow:hidden;}

/* Panel header */
.ppal-header{padding:10px 12px 8px;border-bottom:1px solid var(--border);flex-shrink:0;}
.ppal-header-top{display:flex;align-items:center;justify-content:space-between;margin-bottom:6px;}
.ppal-title{font-size:var(--text-sm);font-weight:700;color:var(--accent);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;}
.ppal-close{background:none;border:none;cursor:pointer;color:var(--text-tertiary);padding:2px;border-radius:4px;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;line-height:1;}
@media (hover: hover){.ppal-close:hover{color:var(--text-primary);background:var(--surface-tertiary);}}
/* Pin toggle — only meaningful at >=1024px, where the panel docks as a
   persistent side-pane (see .cs-main--palette-open above). Hidden on
   mobile/tablet where the panel is a dismissable overlay/bottom-sheet.
   Keep this breakpoint in step with the docking media query and with
   pinSupported in tracker-app.js. */
.ppal-pin-btn{background:none;border:none;cursor:pointer;color:var(--text-tertiary);padding:2px;border-radius:4px;display:none;align-items:center;justify-content:center;flex-shrink:0;line-height:1;margin-right:2px;}
@media (hover: hover){.ppal-pin-btn:hover{color:var(--text-primary);background:var(--surface-tertiary);}}
.ppal-pin-btn--on{color:var(--accent);}
@media (hover: hover){.ppal-pin-btn--on:hover{color:var(--accent);background:var(--accent-light);}}
@media(min-width:1024px){
  .ppal-pin-btn{display:inline-flex;}
}
.ppal-progress-bar{height:4px;background:var(--surface-tertiary);border-radius:2px;overflow:hidden;margin-bottom:6px;}
.ppal-progress-fill{height:100%;background:var(--accent);border-radius:2px;transition:width 0.3s ease;}
.ppal-header-stats{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
.ppal-pct{font-size:var(--text-xs);font-weight:700;color:var(--accent);font-variant-numeric:tabular-nums;}
.ppal-session-time{font-size:var(--text-xs);color:var(--text-secondary);display:inline-flex;align-items:center;gap:3px;}
.ppal-session-chip{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:var(--radius-pill);border:1px solid var(--accent-border);background:var(--accent-light);color:var(--accent);font-size:10px;font-weight:600;cursor:pointer;margin-left:auto;flex-shrink:0;}
@media (hover: hover){.ppal-session-chip:hover{background:var(--accent-border);}}
.ppal-session-chip{font-family:inherit;}
@media (pointer: coarse){.ppal-session-chip{min-height:44px;min-width:44px;padding:6px 14px;font-size:12px;}}

/* Sort row */
.ppal-use-note{margin:0;padding:4px 12px 0;font-size:10px;line-height:1.35;color:var(--text-tertiary);}
.ppal-blend-note{padding:0 12px;}
.ppal-sort-row{display:flex;gap:4px;padding:6px 12px;border-bottom:1px solid var(--border);flex-shrink:0;}
.ppal-sort-btn{flex:1;padding:4px 0;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface-secondary);color:var(--text-secondary);font-size:10px;font-weight:500;cursor:pointer;font-family:inherit;transition:background var(--motion-fast),color var(--motion-fast);}
@media (hover: hover){.ppal-sort-btn:hover{background:var(--surface-tertiary);}}
.ppal-sort-btn--on{background:var(--accent);color:var(--accent-ink);border-color:var(--accent);font-weight:600;}

/* Active colour tile (pinned, always-visible) */
.ppal-active-tile{display:flex;align-items:center;gap:10px;padding:10px 12px;background:var(--accent-light);border-bottom:1px solid var(--accent-border);flex-shrink:0;min-height:72px;}
.ppal-active-tile--done{background:var(--success-soft);}
.ppal-active-swatch-wrap{flex-shrink:0;width:56px;height:56px;display:flex;align-items:center;justify-content:center;}
.ppal-active-swatch{width:48px;height:48px;border-radius:var(--radius-md);border:2px solid var(--border);display:block;}
.ppal-active-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px;}
.ppal-active-id{font-size:13px;font-weight:700;color:var(--accent);}
.ppal-active-name{font-size:11px;color:var(--text-secondary);overflow-wrap:anywhere;line-height:1.3;}
.ppal-active-count{font-size:11px;color:var(--text-tertiary);font-variant-numeric:tabular-nums;}
.ppal-active-none{padding:10px 12px;background:var(--surface-secondary);border-bottom:1px solid var(--border);font-size:var(--text-xs);color:var(--text-tertiary);display:flex;align-items:center;gap:6px;min-height:44px;flex-shrink:0;}
.ppal-find-btn{flex-shrink:0;width:36px;height:36px;display:flex;align-items:center;justify-content:center;border:1px solid var(--accent-border);border-radius:var(--radius-sm);background:var(--surface);color:var(--accent);cursor:pointer;transition:background var(--motion-fast);}
@media (hover: hover){.ppal-find-btn:hover{background:var(--accent);color:var(--surface);}}
@media (pointer:coarse){.ppal-find-btn{width:44px;height:44px;}}

/* Colour tile list */
.ppal-tile-list{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:4px 0;}
.ppal-tile{display:flex;align-items:stretch;gap:0;cursor:pointer;border-radius:0;border-bottom:0.5px solid var(--border);transition:background var(--motion-fast);}
@media (hover: hover){.ppal-tile:hover{background:var(--surface-secondary);}}
.ppal-tile--on{background:var(--accent-light)!important;box-shadow:inset 4px 0 0 var(--accent-text);}   /* the selected colour has a bar on its edge, not only a tint */
.ppal-tile--done:not(.ppal-tile--on){opacity:0.5;}
.ppal-tile-swatch{width:40px;min-width:40px;border-radius:0;border-right:1px solid var(--border);flex-shrink:0;cursor:pointer;}
@media (pointer:coarse){.ppal-tile-swatch{width:48px;min-width:48px;}}
.ppal-tile-body{flex:1;min-width:0;padding:6px 10px;display:flex;flex-direction:column;gap:3px;}
.ppal-tile-id-row{display:flex;align-items:flex-start;gap:6px;}
.ppal-tile-text{display:flex;flex-direction:column;gap:1px;flex:1;min-width:0;text-align:left;}
.ppal-tile-id{font-size:11px;font-weight:700;color:var(--text-primary);font-variant-numeric:tabular-nums;overflow-wrap:anywhere;}
.ppal-tile--on .ppal-tile-id{color:var(--accent-text);font-weight:700;}
.ppal-tile-tag{margin-left:2px;padding:0 5px;border-radius:var(--radius-pill);background:var(--accent-light);color:var(--accent-text);font-size:9px;font-weight:600;vertical-align:1px;}
/* The name wraps (UX-013) instead of being cut short, and the strands and skeins follow it. */
.ppal-tile-name{font-size:11px;color:var(--text-secondary);overflow-wrap:anywhere;line-height:1.3;}
.ppal-tile-use{font-size:10px;color:var(--text-tertiary);line-height:1.3;font-variant-numeric:tabular-nums;}
.ppal-tile-pct{font-size:10px;color:var(--text-tertiary);font-variant-numeric:tabular-nums;flex-shrink:0;}
.ppal-tile-bar{height:3px;background:var(--surface-tertiary);border-radius:2px;overflow:hidden;}
.ppal-tile-bar-fill{height:100%;background:var(--accent);border-radius:2px;}
.ppal-tile-count-row{display:flex;align-items:center;gap:4px;}
.ppal-tile-count{font-size:10px;color:var(--text-tertiary);font-variant-numeric:tabular-nums;flex:1;}
.ppal-tile-actions{display:flex;align-items:center;gap:3px;flex-wrap:wrap;justify-content:flex-end;margin-left:auto;max-width:100%;}
.ppal-tile-park-btn,.ppal-tile-done-btn{display:inline-flex;align-items:center;gap:2px;font-size:9px;padding:2px 6px;border-radius:4px;border:1px solid var(--border);background:var(--surface);cursor:pointer;white-space:nowrap;font-family:inherit;font-weight:600;}
.ppal-tile-count-row{flex-wrap:wrap;row-gap:4px;}
.ppal-tile-count{flex:1 1 4em;}
.ppal-tile-done-btn span{white-space:nowrap;}
/* Touch: the action chips are their own 44px targets, spaced apart, so a tap meant to select a colour cannot mark it. */
@media (pointer:coarse){
  .ppal-tile-park-btn,.ppal-tile-done-btn{min-height:44px;min-width:44px;justify-content:center;gap:4px;padding:6px 12px;font-size:11px;touch-action:manipulation;}
  .ppal-tile-actions{gap:8px;}
  .ppal-tile-count-row{row-gap:6px;}
}
/* Key to the done and not-done look, under the progress bar. */
.ppal-key{display:flex;align-items:center;flex-wrap:wrap;gap:4px 12px;margin-top:6px;font-size:10px;color:var(--text-tertiary);}
.ppal-key-item{display:inline-flex;align-items:center;gap:4px;}
.ppal-key-swatch{position:relative;display:inline-block;width:14px;height:14px;border-radius:3px;border:1px solid var(--border);overflow:hidden;flex-shrink:0;}
.ppal-key-tick{position:absolute;top:0;right:0;width:8px;height:8px;background:var(--text-primary);clip-path:polygon(0 0,100% 0,100% 100%);}
.ppal-key-note{flex-basis:100%;line-height:1.35;}

/* "What's a blend?" (components.js BlendHelpNote): a short plain-language disclosure under a key. */
.blend-help{margin:var(--s-1) 0;font-size:var(--text-xs);color:var(--text-secondary);}
.blend-help__toggle{display:inline-flex;align-items:center;gap:4px;padding:2px 0;border:0;background:none;color:var(--accent-text);font:inherit;font-weight:600;text-decoration:underline;cursor:pointer;}
.blend-help__toggle svg{width:14px;height:14px;}
.blend-help__body{margin-top:var(--s-1);padding:var(--s-2);border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface-secondary);line-height:1.45;}
.blend-help__body p{margin:0 0 var(--s-1);}
.blend-help__more{padding:0;border:0;background:none;color:var(--accent-text);font:inherit;text-decoration:underline;cursor:pointer;}
/* Touch long-press rectangle anchor: what to do next, plus Park / Cancel.
   Floats over the chart like the Shift-range hint, so it never moves it. */
.range-anchor-bar{position:absolute;top:4px;left:50%;transform:translateX(-50%);z-index:30;display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:6px;max-width:calc(100% - 32px);padding:6px 8px 6px 12px;border-radius:var(--radius-md);background:var(--accent);color:var(--surface);font-size:var(--text-xs);font-weight:600;box-shadow:var(--shadow-sm);}
.range-anchor-bar__icon{display:inline-flex;}
.range-anchor-bar__icon svg{width:14px;height:14px;}
.range-anchor-bar__btn{display:inline-flex;align-items:center;gap:4px;padding:4px 10px;border:0;border-radius:var(--radius-sm);background:var(--surface);color:var(--accent-ink);font:inherit;cursor:pointer;}
.range-anchor-bar__btn--on{background:var(--accent);color:var(--surface);}
@media (pointer:coarse){.range-anchor-bar__btn{min-height:40px;padding:6px 12px;}}
/* Status bar under the chart: "Clear guide" sits at its right edge. */
.tracker-hover-bar__clear{margin-left:auto;display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border:1px solid currentColor;border-radius:var(--radius-sm);background:transparent;color:inherit;font:inherit;font-size:var(--text-xs);cursor:pointer;opacity:0.9;}
.tracker-hover-bar__clear svg{width:12px;height:12px;}
@media (hover:hover){.tracker-hover-bar__clear:hover{opacity:1;}}
@media (pointer:coarse){.tracker-hover-bar__clear{min-height:36px;padding:4px 12px;}}
/* Read by screen readers, not shown. */
.tracker-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;}

/* ── Canvas column wrapper (for mode strip positioning) ────── */
.ppal-canvas-col{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;position:relative;overflow:hidden;}
.ppal-canvas-col .canvas-area{flex:1;min-height:0;overflow:auto;}

/* ── Floating mode strip (right edge of canvas) ─────────────── */
.ppal-mode-strip{
  position:absolute;
  right:8px;
  top:50%;
  transform:translateY(-50%);
  z-index:10;
  display:flex;
  flex-direction:column;
  gap:4px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:4px;
  box-shadow:var(--shadow-md,0 4px 12px rgba(0,0,0,0.12));
}
.ppal-mode-btn{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  width:48px;
  min-height:48px;
  border:none;
  border-radius:var(--radius-sm);
  background:transparent;
  color:var(--text-secondary);
  cursor:pointer;
  font-family:inherit;
  transition:background var(--motion-fast),color var(--motion-fast);
  padding:4px 2px;
}
@media (hover: hover){.ppal-mode-btn:hover{background:var(--surface-tertiary);color:var(--text-primary);}}
.ppal-mode-btn--on{background:var(--accent-light);color:var(--accent-text);}
.ppal-mode-btn:disabled{opacity:0.35;cursor:not-allowed;}
.ppal-mode-btn-icon{display:flex;align-items:center;justify-content:center;font-size:18px;line-height:1;}
.ppal-mode-btn-label{font-size:9px;font-weight:600;letter-spacing:0.03em;text-transform:uppercase;line-height:1;}
/* On narrow screens the strip takes less space */
@media (max-width:480px){
  .ppal-mode-strip{right:4px;gap:2px;padding:3px;}
  .ppal-mode-btn{width:44px;min-height:44px;}
}

/* ── More panel (slides in from right over canvas) ───────────── */
.ppal-more-backdrop{
  position:absolute;
  inset:0;
  z-index:19;
  background:rgba(0,0,0,0.2);
  animation:ppal-fade-in var(--motion-fast);
}
@keyframes ppal-fade-in{from{opacity:0;}to{opacity:1;}}
@media (prefers-reduced-motion:reduce){.ppal-more-backdrop{animation:none;}}
.ppal-more-panel{
  visibility:hidden;                       /* shut: out of the tab order and of reach, not only off screen */
  position:absolute;
  top:0;
  right:0;
  bottom:0;
  width:300px;
  max-width:90%;
  background:var(--surface);
  border-left:1px solid var(--border);
  box-shadow:var(--shadow-lg,-4px 0 16px rgba(0,0,0,0.15));
  z-index:20;
  display:flex;
  flex-direction:column;
  transform:translateX(100%);
  transition:transform var(--motion),visibility 0s linear 0.2s;
  overflow:hidden;
}
.ppal-more-panel--open{transform:translateX(0);visibility:visible;transition-delay:0s;}
@media (prefers-reduced-motion:reduce){.ppal-more-panel{transition:none;}}
.ppal-more-header{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--border);flex-shrink:0;}
.ppal-more-title{font-size:var(--text-sm);font-weight:700;color:var(--text-primary);flex:1;}
.ppal-utility-chip{display:inline-flex;align-items:center;gap:4px;padding:3px 8px;border-radius:var(--radius-pill);border:1px solid var(--border);background:var(--surface-secondary);color:var(--text-secondary);font-size:10px;font-weight:500;cursor:pointer;font-family:inherit;flex-shrink:0;}
.ppal-utility-chip--on{background:var(--accent-light);border-color:var(--accent-border);color:var(--accent-text);}
@media (hover: hover){.ppal-utility-chip:hover{background:var(--surface-tertiary);}}
.ppal-more-close{background:none;border:none;cursor:pointer;color:var(--text-tertiary);padding:4px;border-radius:4px;display:inline-flex;align-items:center;flex-shrink:0;margin-left:4px;}
@media (hover: hover){.ppal-more-close:hover{color:var(--text-primary);background:var(--surface-tertiary);}}
.ppal-more-tabs{display:flex;border-bottom:1px solid var(--border);flex-shrink:0;overflow-x:auto;scrollbar-width:none;}
.ppal-more-tabs::-webkit-scrollbar{display:none;}
.ppal-more-tab{flex:1;min-width:52px;padding:8px 4px;border:none;border-bottom:2px solid transparent;background:transparent;color:var(--text-secondary);font-size:11px;font-weight:500;cursor:pointer;font-family:inherit;white-space:nowrap;transition:color var(--motion-fast),border-color var(--motion-fast);}
@media (hover: hover){.ppal-more-tab:hover{color:var(--text-primary);}}
.ppal-more-tab--on{color:var(--accent-text);border-bottom-color:var(--accent);font-weight:700;}
.ppal-more-content{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:16px;}

/* ── Phone-only colour chip trigger (top of canvas) ─────────── */
.ppal-phone-chip{
  display:none;
  position:absolute;
  top:8px;
  left:8px;
  z-index:9;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius:var(--radius-pill);
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--text-primary);
  font-size:var(--text-xs);
  font-weight:600;
  cursor:pointer;
  box-shadow:var(--shadow-sm,0 1px 4px rgba(0,0,0,0.1));
  min-height:36px;
  font-family:inherit;
}
.ppal-phone-chip-sw{width:20px;height:20px;border-radius:50%;border:1.5px solid var(--border);flex-shrink:0;display:inline-block;}
.ppal-phone-chip--empty{color:var(--text-tertiary);}
@media (max-width:899px){
  .ppal-phone-chip{display:inline-flex;}
  /* Shift mode strip down on phone so it doesn't overlap the chip */
  .ppal-mode-strip{top:auto;bottom:50%;transform:translateY(50%);}
}

/* ── Desktop-only: always show palette panel ─────────────────── */
@media (min-width:900px){
  /* Ensure the lpanel rail and phone chip are hidden on desktop */
  .lpanel--rail{display:none!important;}
  .ppal-phone-chip{display:none!important;}
}

/* ── Reduced padding on canvas since toolbar-row is gone ──────── */
.cs-page-content .canvas-area{padding-bottom:0;}
@media (pointer:coarse){
  .ppal-canvas-col .canvas-area{padding-bottom:0!important;}
}

/* ═════════════════════════════════════════════════════════
   TOUCH ERGONOMICS — reports/mobile-experience-audit.md D1–D4
   Second mobile pass. Everything here is gated on a coarse pointer, so
   desktop rendering is untouched.
   ═════════════════════════════════════════════════════════ */

/* ── D1. iOS zooms the page whenever a field under 16px takes focus, and
   does not zoom back out. Every measured entry page had at least one.
   16px on the field is the only reliable cure; these bars all have room
   for it now that the filter bar and the topbar scroll. ── */
@media (pointer: coarse){
  input:not([type=checkbox]):not([type=radio]):not([type=range]),
  select,
  textarea{ font-size:16px; }
  /* Class-level sizes elsewhere in the sheet outrank the bare element
     selectors above, so the named offenders are repeated at equal or higher
     specificity. Add to this list rather than reaching for !important. */
  .mgr-sort-select,
  .mgr-filter-bar input,
  .mgr-filter-bar select{ font-size:16px; }
  /* Inline rename fields sit inside fixed-height chrome, so scale them
     down visually while keeping the computed size at the 16px threshold. */
  .tb-proj-badge-input,
  .tb-context-name-input{
    font-size:16px; transform:scale(0.75); transform-origin:left center;
  }
}

/* ── D2. Touch targets. Measured under 40px in at least one axis:
   .tb-nav-link 24x44, .tb-app-tab 35x44, .mgr-chip 27px tall,
   .ppal-utility-chip 57x22, .ppal-more-tab 60x33, .ppal-more-close 21x21.
   Where a taller box would disturb a dense row, the hit area is grown with
   a transparent ::after instead of the visible box. ── */
@media (pointer: coarse){
  .tb-nav-link{ min-width:44px; min-height:44px; justify-content:center;
                display:inline-flex; align-items:center; touch-action:manipulation; }
  .tb-app-nav .tb-app-tab{ min-width:44px; min-height:44px; display:inline-flex;
               align-items:center; justify-content:center; }
  .mgr-chip,
  .ppal-utility-chip,
  .ppal-more-tab,
  /* Second tier, found by re-measuring after the first touch pass. The
     highlight-style buttons carry inline padding, so they need a class of
     their own to be reachable from CSS at all. */
  .ppal-hl-mode-btn,
  .ppal-phone-chip{ min-height:44px; touch-action:manipulation; }
  .modal-close{ min-width:44px; min-height:44px; }
  /* Checkboxes ship at 16px. 44px would dominate the dense rows they sit in,
     so this is a partial improvement rather than a full fix — the row label
     remains the larger target. */
  input[type=checkbox], .ppal-check{ width:24px; height:24px; }
  .mgr-filter-bar select,
  .mgr-filter-bar button{ min-height:44px; touch-action:manipulation; }
  /* Visible size unchanged — only the hit area grows. Needs a positioned
     ancestor, which .ppal-more-close already has. */
  .ppal-more-close{ position:relative; }
  .ppal-more-close::after{ content:''; position:absolute; inset:-12px; }
  /* The info strip is tappable (it opens stats) but reads as a label. */
  .info-strip{ min-height:44px; touch-action:manipulation; }
}

/* ── D3. Long-pressing the chart raised the iOS "Save Image / Copy" sheet,
   and a drag-mark started a text selection — both directly in the way of
   the tracker's primary gesture. ── */
.canvas-area,
.canvas-area canvas{
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ── D4. The smallest chrome text was 9–10px, which is below the point
   where it survives a phone screen. Only the sub-11px cases are lifted —
   a blanket floor would reflow dense rows that are fine as they are. ── */
@media (pointer: coarse){
  .cqd-pct,
  .stash-badge,
  .tb-proj-badge-pct,
  .tb-proj-badge-saved,
  .mgr-tab .cnt{ font-size:11px; }
}

/* Tracker panel checkboxes. Sizing lives here, not inline: an inline
   width/height outranks the coarse-pointer rule that enlarges them for
   touch (the same trap the thread sort control fell into). */
.ppal-check{ width:16px; height:16px; cursor:pointer; }

/* ══ Work area (Stitch Tracker) ═══════════════════════════════════════════
   The bar above the chart while a work area is active, and the picker
   dialog. See work-area.js and components/WorkAreaPicker.js. */
.work-area-bar{display:flex;align-items:center;flex-wrap:wrap;gap:var(--s-2) var(--s-3);padding:6px var(--s-3);margin-bottom:var(--s-2);background:var(--accent-soft);border:1px solid var(--accent-border);border-radius:var(--radius-lg);color:var(--accent-ink);font-size:var(--text-sm);}
.work-area-bar__title{display:inline-flex;align-items:center;gap:6px;font-weight:600;min-width:0;}
.work-area-bar__title svg{width:16px;height:16px;flex:none;}
.work-area-bar__range{font-variant-numeric:tabular-nums;white-space:nowrap;}
.work-area-bar__progress{display:flex;align-items:center;gap:var(--s-2);flex:1 1 120px;min-width:110px;}
.work-area-bar__track{flex:1;height:6px;border-radius:var(--radius-pill);background:var(--surface);overflow:hidden;}
.work-area-bar__fill{height:100%;background:var(--success);border-radius:inherit;transition:width var(--motion);}
.work-area-bar__pct{font-weight:600;font-variant-numeric:tabular-nums;min-width:3em;text-align:right;}
.work-area-bar__actions{display:flex;align-items:center;flex-wrap:wrap;gap:6px;margin-left:auto;}
.work-area-bar__icon-btn{display:inline-grid;place-items:center;width:30px;height:30px;padding:0;border-radius:var(--radius-md);border:1px solid var(--border);background:var(--surface);color:var(--text-secondary);cursor:pointer;}
@media (hover:hover){.work-area-bar__icon-btn:hover:not(:disabled){border-color:var(--accent);color:var(--text-primary);}}
.work-area-bar__icon-btn:disabled{opacity:.45;cursor:default;}
.work-area-bar__icon-btn svg{width:16px;height:16px;}
.work-area-seg{display:inline-flex;align-items:center;gap:2px;padding:2px;border-radius:var(--radius-md);background:var(--surface);border:1px solid var(--border);}
.work-area-seg__label{font-size:var(--text-xs);color:var(--text-secondary);padding:0 6px;}
.work-area-seg__custom{font-size:var(--text-xs);font-weight:600;color:var(--accent);padding:0 6px;}
.work-area-seg button{min-width:30px;height:26px;padding:0 8px;border:0;border-radius:var(--radius-sm);background:transparent;color:var(--text-secondary);font:inherit;font-size:var(--text-sm);font-weight:500;cursor:pointer;font-variant-numeric:tabular-nums;}
.work-area-seg button[aria-pressed="true"]{background:var(--accent);color:var(--text-on-accent);}
.work-area-seg button:focus-visible,.work-area-bar__icon-btn:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}

.work-area-picker{width:min(720px,100%);max-height:calc(100dvh - 32px);display:flex;flex-direction:column;padding:0;}
.work-area-picker__body{padding:var(--s-5) var(--s-5) var(--s-2);display:flex;flex-direction:column;gap:var(--s-3);overflow:auto;flex:1 1 auto;min-height:0;}
.work-area-picker__title{margin:0;font-size:var(--text-xl);font-weight:600;color:var(--text-primary);}
.work-area-picker__lede{margin:0;font-size:var(--text-sm);color:var(--text-secondary);}
.work-area-picker__controls{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:var(--s-3);}
.work-area-picker__key{display:flex;gap:var(--s-4);flex-wrap:wrap;font-size:var(--text-xs);color:var(--text-muted);}
.work-area-picker__key span{display:inline-flex;align-items:center;gap:6px;}
.work-area-key{display:inline-block;width:12px;height:12px;border-radius:3px;}
.work-area-key--sel{background:var(--accent);}
.work-area-key--done{background:var(--success);opacity:.7;}
.work-area-key--part{background:linear-gradient(to top,var(--success) 30%,var(--surface-tertiary) 30%);}
.work-area-picker__overview{display:grid;place-items:center;padding:var(--s-3);background:var(--surface-tertiary);border:1px solid var(--border);border-radius:var(--radius-lg);min-height:200px;}
.work-area-picker__canvas{display:block;touch-action:none;cursor:cell;border-radius:var(--radius-xs);}
.work-area-picker__summary{display:flex;flex-wrap:wrap;align-items:baseline;gap:var(--s-2) var(--s-4);font-size:var(--text-sm);color:var(--text-secondary);font-variant-numeric:tabular-nums;}
.work-area-picker__summary strong{color:var(--text-primary);font-size:var(--text-lg);}
.work-area-picker__foot{flex:none;display:flex;align-items:center;flex-wrap:wrap;gap:var(--s-2);padding:var(--s-3) var(--s-5) var(--s-5);border-top:1px solid var(--border-subtle);}
.work-area-picker__spacer{flex:1;}
.work-area-picker__foot .g-btn{min-height:36px;}
.work-area-picker__foot .g-btn svg{width:16px;height:16px;}
@media (max-width:560px){
  .work-area-bar__range{display:none;}
  .work-area-bar__actions{margin-left:0;width:100%;}
  .work-area-picker__body{padding:var(--s-4) var(--s-4) var(--s-2);}
  .work-area-picker__foot{padding:var(--s-3) var(--s-4) var(--s-4);}
  .work-area-picker__spacer{display:none;}
}

/* ── ModeToggle (components/ModeToggle.js) — Creator Navigate | Draw and
   Tracker Mark | Navigate (audit DRAW-01). 44 px targets everywhere. ── */
.mode-toggle{display:inline-flex;align-items:stretch;flex-shrink:0;border:1px solid var(--line);border-radius:var(--radius-sm);background:var(--surface);overflow:hidden;}
.mode-toggle__btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:44px;min-width:44px;padding:0 12px;border:none;background:transparent;color:var(--text-secondary);font:inherit;font-size:var(--text-sm);font-weight:500;cursor:pointer;}
.mode-toggle__btn + .mode-toggle__btn{border-left:1px solid var(--line);}
.mode-toggle__btn--on{background:var(--accent);color:var(--surface);font-weight:600;}
.mode-toggle__btn:focus-visible{outline:2px solid var(--accent);outline-offset:-2px;}
.mode-toggle__icon{display:inline-flex;}
.mode-toggle__icon svg{width:16px;height:16px;}
.mode-toggle--compact .mode-toggle__btn{padding:0 10px;}
.mode-toggle--block{display:flex;width:100%;}
.mode-toggle--block .mode-toggle__btn{flex:1;}

/* ═══ New design sheet (audit DRAW-02) ═══════════════════════════════════
   creator/NewDesignSheet.js: a centred dialog, full screen on phones. */
.new-design-overlay {
  position: fixed; inset: 0; z-index: 1100;
  display: flex; align-items: center; justify-content: center; padding: var(--s-4);
  background: rgba(15, 23, 42, 0.45);
}
.new-design-sheet {
  width: min(560px, 100%); max-height: min(760px, 94vh);
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); color: var(--text-primary);
  border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.new-design-sheet__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line);
}
.new-design-sheet__head h2 { margin: 0; font-size: var(--text-xl); }
.new-design-sheet__close {
  min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-secondary); cursor: pointer; border-radius: var(--radius-sm);
}
.new-design-sheet__close svg { width: 18px; height: 18px; }
.new-design-sheet__body { flex: 1; overflow-y: auto; padding: var(--s-3) var(--s-4); min-height: 0; }
.new-design-sheet__section { padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
.new-design-sheet__section:last-child { border-bottom: none; }
.new-design-sheet__section h3 { margin: 0 0 var(--s-2); font-size: var(--text-md); font-weight: 600; }
.new-design-sheet__optional { font-weight: 400; color: var(--text-tertiary); }
.new-design-sheet__chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--s-2); }
.new-design-chip {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 52px; padding: 8px 10px; cursor: pointer; text-align: left; font: inherit;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--text-primary);
}
.new-design-chip--on { border-color: var(--accent); background: var(--accent-light); }
.new-design-chip__label { font-weight: 600; font-size: var(--text-sm); }
.new-design-chip__size { font-size: var(--text-xs); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.new-design-sheet__custom { display: flex; align-items: flex-end; gap: var(--s-2); margin-top: var(--s-2); }
.new-design-sheet__custom label { display: flex; flex-direction: column; gap: 4px; font-size: var(--text-xs); color: var(--text-secondary); flex: 1; }
.new-design-sheet__custom input {
  width: 100%; box-sizing: border-box; padding: 6px 8px; font-size: var(--text-md);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-primary);
}
.new-design-sheet__readout { margin: var(--s-2) 0 0; font-size: var(--text-sm); color: var(--text-secondary); }
.new-design-sheet__hint { margin: 0 0 var(--s-2); font-size: var(--text-xs); color: var(--text-tertiary); }
.new-design-sheet__file { display: none; }
.new-design-sheet__trace { display: flex; gap: var(--s-3); align-items: flex-start; min-width: 0; }
.new-design-sheet__trace img {
  width: 96px; height: 96px; object-fit: contain; flex: none;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-secondary);
}
.new-design-sheet__trace-controls { display: flex; flex-direction: column; gap: var(--s-2); flex: 1; min-width: 0; font-size: var(--text-sm); }
.new-design-sheet__trace-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-design-sheet__trace-controls label { display: flex; flex-direction: column; gap: 4px; }
.new-design-sheet__trace-buttons { display: flex; gap: var(--s-2); }
.new-design-sheet__foot {
  display: flex; justify-content: flex-end; gap: var(--s-2);
  padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); background: var(--surface);
}
.new-design-sheet__foot .g-btn { min-height: 40px; padding: 8px 16px; font-size: var(--text-sm); }
@media (max-width: 600px) {
  .new-design-overlay { padding: 0; }
  .new-design-sheet { width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; border: none; }
  .new-design-sheet__foot .g-btn { flex: 1; justify-content: center; min-height: 44px; }
}

/* ═══ Fabric block (audit COMMON-08) ═══════════════════════════════════════
   creator/FabricBlock.js: count, colour, finished and cut size. Swatch
   backgrounds are the fabric's own colour, set inline. */
.fabric-block { display: flex; flex-direction: column; gap: var(--s-3); }
.fabric-block__field { display: flex; flex-direction: column; gap: 4px; }
.fabric-block__label {
  font-size: var(--text-xs); font-weight: 600; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.fabric-block__select {
  width: 100%; padding: 6px 10px; border-radius: var(--radius-md);
  border: 0.5px solid var(--border); font-size: var(--text-md);
  background: var(--surface); color: var(--text-primary);
}
.fabric-block__swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fabric-block__swatch {
  width: 32px; height: 32px; padding: 0; position: relative; cursor: pointer;
  border-radius: var(--radius-sm); border: 1.5px solid var(--border);
}
.fabric-block__swatch--on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.fabric-block__swatch--custom {
  display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
  background: var(--surface); color: var(--text-secondary);
}
.fabric-block__swatch--custom input[type="color"] {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: none; padding: 0;
}
.fabric-block__custom-icon { display: inline-flex; width: 16px; height: 16px; pointer-events: none; }
.fabric-block__custom-icon svg { width: 16px; height: 16px; }
.fabric-block__sizes {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0;
  font-size: var(--text-sm);
}
.fabric-block__sizes dt { color: var(--text-tertiary); }
.fabric-block__sizes dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.fabric-block__note { color: var(--text-tertiary); font-size: var(--text-xs); }

/* Read-only fabric count with an Edit link (Materials; creator/FabricBlock.js). */
.fabric-summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; font-size: var(--text-sm); }
.fabric-summary__label { color: var(--text-tertiary); }
.fabric-summary__value { color: var(--text-primary); font-weight: 600; }
.fabric-summary__edit {
  padding: 0; border: none; background: none; cursor: pointer; font: inherit;
  color: var(--accent-text, var(--accent)); text-decoration: underline;
}
@media (pointer: coarse) { .fabric-summary__edit { min-height: 44px; padding: 0 8px; } }
.fabric-summary__edit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

/* ═══ Palette tab: pattern colours, symbols, Add colour (audit DRAW-05) ═══
   creator/Sidebar.js. Swatch ink is black or white by the thread's own
   luminance, so it does not follow the theme. */
.pal-rows { display: flex; flex-direction: column; gap: 2px; }
.pal-row {
  display: flex; align-items: center; gap: var(--s-2);
  min-height: 36px; padding: 2px 4px 2px 2px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-size: var(--text-sm);
  position: relative; min-width: 0;
}
.pal-row:hover { background: var(--surface-secondary); }
.pal-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pal-row--selected { border-color: var(--accent); background: var(--accent-light); }
.pal-row--hi { border-color: var(--accent-hover); background: var(--surface-tertiary); }
.pal-row--unused { opacity: 0.6; }
.pal-row__swatch {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: var(--radius-sm);
  border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1; font-weight: 600; font-family: var(--font-symbol);
}
.pal-row__swatch--black { color: black; }
.pal-row__swatch--white { color: white; }
/* The key row's text: the thread label, its name and the strands and skeins it takes. The name wraps (UX-013) rather than
   being cut short; a long catalogue name such as "Antique Mauve Very Dark" shows in full. */
.pal-row__label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 2px 0; }
.pal-row__id { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-primary); overflow-wrap: anywhere; }
.pal-row__tag { margin-left: 2px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--accent-light); color: var(--accent-text); font-size: 10px; font-weight: 600; vertical-align: 1px; }
.pal-row__name { min-width: 0; overflow-wrap: anywhere; color: var(--text-secondary); font-size: var(--text-xs); line-height: 1.3; }
.pal-row__use { color: var(--text-tertiary); font-size: var(--text-xs); line-height: 1.3; font-variant-numeric: tabular-nums; }
.pal-row__count { font-variant-numeric: tabular-nums; color: var(--text-tertiary); font-size: var(--text-xs); }
.pal-row__stash { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.pal-row__btn {
  flex-shrink: 0; width: 30px; height: 30px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-tertiary); cursor: pointer;
}
.pal-row__btn:hover, .pal-row__btn:focus-visible { color: var(--accent); border-color: var(--border); background: var(--surface); }
.pal-row__btn svg { width: 16px; height: 16px; }

.pal-symbols {
  margin-top: var(--s-2); padding: var(--s-2);
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-secondary);
}
.pal-symbols__head { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.pal-symbols__title { flex: 1; font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.pal-symbols__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 4px; }
.pal-symbols__btn {
  height: 36px; font-size: 18px; line-height: 1; cursor: pointer; font-family: var(--font-symbol);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-primary);
}
.pal-symbols__btn:hover, .pal-symbols__btn:focus-visible { border-color: var(--accent); color: var(--accent); }
.pal-symbols__empty { font-size: var(--text-xs); color: var(--text-tertiary); }

.pal-add { padding: var(--s-2) 12px var(--s-3); }
.pal-add__btn {
  width: 100%; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  border: 1px dashed var(--accent); border-radius: var(--radius-md);
  background: var(--surface); color: var(--accent); font-weight: 600; font-size: var(--text-sm); cursor: pointer;
}
.pal-add__btn:hover { background: var(--accent-light); }
.pal-add__btn svg { width: 16px; height: 16px; }
.pal-picker { padding: var(--s-2) 12px var(--s-3); border-top: 0.5px solid var(--border); min-width: 0; }
.pal-picker__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-2); }
.pal-picker__title { font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.pal-pick-tabs { display: flex; gap: 2px; margin-bottom: var(--s-2); border-bottom: 1px solid var(--border); }
.pal-pick-tab {
  flex: 1; min-height: 36px; padding: 4px 6px; cursor: pointer;
  border: none; border-bottom: 2px solid transparent; background: transparent;
  color: var(--text-secondary); font-size: var(--text-xs); font-weight: 500;
}
.pal-pick-tab--on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.pal-pick-note { font-size: var(--text-xs); color: var(--text-tertiary); margin-bottom: var(--s-1); }
.pal-pick-search {
  width: 100%; box-sizing: border-box; padding: 6px 10px; margin-bottom: var(--s-2);
  border: 0.5px solid var(--border); border-radius: var(--radius-md); font-size: var(--text-sm);
}
.pal-pick-families { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: var(--s-2); }
.pal-pick-family {
  padding: 3px 9px; min-height: 28px; cursor: pointer; font-size: var(--text-xs);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text-secondary);
}
.pal-pick-family--on { border-color: var(--accent); background: var(--accent-light); color: var(--accent); font-weight: 600; }
.pal-pick-list { max-height: 240px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.pal-pick-row {
  display: flex; align-items: center; gap: var(--s-2); width: 100%; min-height: 34px; padding: 3px 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--surface);
  cursor: pointer; text-align: left; font: inherit; color: var(--text-primary);
}
.pal-pick-row:hover { background: var(--surface-secondary); }
.pal-pick-row--in { background: var(--accent-light); border-color: var(--accent-border); opacity: 0.75; cursor: default; }
.pal-pick-row__swatch { width: 18px; height: 18px; border-radius: 3px; flex-shrink: 0; border: 1px solid var(--border); }
.pal-pick-row__id { font-weight: 600; min-width: 40px; font-size: var(--text-sm); }
.pal-pick-row__name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: var(--text-xs); color: var(--text-secondary); line-height: 1.3; }
.pal-pick-row__mark { display: inline-flex; color: var(--text-tertiary); }
.pal-pick-row--in .pal-pick-row__mark { color: var(--accent); }
.pal-pick-row__mark svg { width: 14px; height: 14px; }
.pal-pick-empty { font-size: var(--text-xs); color: var(--text-tertiary); padding: 8px 0; text-align: center; }

/* Tool-strip swatches carry their symbol (P1-4). */
.tb-swatch-sym { font-size: 16px; line-height: 1; font-weight: 600; pointer-events: none; font-family: var(--font-symbol); }
.tb-swatch-sym--black { color: black; }
.tb-swatch-sym--white { color: white; }
.tb-swatch-tip {
  position: fixed; z-index: 1300; transform: translate(-50%, -100%);
  padding: 6px 10px; border-radius: var(--radius-sm);
  background: var(--text-primary); color: var(--surface); font-size: var(--text-xs);
  white-space: nowrap; pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ═══ Touch loupe and precision cursor (audit DRAW-03) ═══════════════════
   creator/Loupe.js positions these in viewport px while a finger draws. */
.creator-loupe {
  position: fixed;
  z-index: 1200;
  border-radius: 50%;
  border: 2px solid var(--surface);
  outline: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  background: var(--surface-tertiary);
  pointer-events: none;
  touch-action: none;
}
.creator-precision-cursor {
  position: fixed;
  z-index: 1201;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  color: var(--text-primary);
  filter: drop-shadow(0 0 1px var(--surface)) drop-shadow(0 0 1px var(--surface));
  pointer-events: none;
}
.creator-precision-cursor svg { display: block; }

/* ═══ Compact phone chrome (audit COMMON-03) ══════════════════════════════
   body.creator-compact is set by creator-main.js under 900px wide (phones and
   portrait tablets). One 48px top bar (creator/CompactBar.js) replaces the
   global header and the action bar; a bottom tool rail (creator/ToolStrip.js)
   replaces the tool strip. The settings drawer (.rpanel) is hidden while
   closed and opens ABOVE the rail, so the two never overlap; the rail's
   colour swatch and More › Panels open it. Desktop and tablet landscape
   (900px and wider) are unchanged. */
:root{--creator-rail-h:56px;--creator-status-h:72px;}
body.creator-compact .tb-topbar,
body.creator-compact .creator-actionbar,
body.creator-compact .cc-hide-compact{display:none!important;}
.creator-compact-top{position:sticky;top:0;z-index:120;display:flex;align-items:center;gap:4px;height:48px;padding:0 4px;padding-top:env(safe-area-inset-top,0px);box-sizing:content-box;background:var(--surface);border-bottom:1px solid var(--line);}
.cc-btn{display:inline-flex;align-items:center;justify-content:center;min-width:44px;min-height:44px;padding:0;border:none;border-radius:var(--radius-sm);background:transparent;color:var(--text-secondary);font:inherit;cursor:pointer;flex-shrink:0;text-decoration:none;}
.cc-btn svg{width:20px;height:20px;}
.cc-btn:disabled{opacity:0.4;cursor:default;}
.cc-btn:focus-visible,.cc-name:focus-visible{outline:2px solid var(--accent);outline-offset:-2px;}
.cc-name{flex:1;min-width:0;display:inline-flex;align-items:center;gap:6px;min-height:44px;padding:0 6px;border:none;background:transparent;color:var(--text-primary);font:inherit;font-size:var(--text-sm);font-weight:600;text-align:left;cursor:pointer;}
.cc-name__text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.cc-name__icon{display:inline-flex;color:var(--text-tertiary);flex-shrink:0;}
.cc-name__icon svg{width:14px;height:14px;}
.cc-save{display:inline-flex;align-items:center;justify-content:center;width:24px;flex-shrink:0;color:var(--text-tertiary);}
.cc-save svg{width:18px;height:18px;}
.cc-save--ok{color:var(--success);}
.cc-save--danger{color:var(--danger);}
.cc-modes{display:inline-flex;flex-shrink:0;border:1px solid var(--line);border-radius:var(--radius-sm);overflow:hidden;}
.cc-mode{flex-direction:column;gap:1px;border-radius:0;min-width:44px;padding:0 4px;font-size:10px;font-weight:600;line-height:1;}
.cc-mode svg{width:18px;height:18px;}
.cc-mode__label{white-space:nowrap;}
.cc-mode + .cc-mode{border-left:1px solid var(--line);}
.cc-mode--on{background:var(--accent);color:var(--surface);}
.cc-sheet-backdrop{position:fixed;inset:0;z-index:1090;background:var(--text-primary);opacity:0.3;}
.cc-sheet{position:fixed;left:0;right:0;bottom:0;z-index:1091;max-height:80dvh;overflow-y:auto;background:var(--surface);border-radius:16px 16px 0 0;padding:8px 8px calc(12px + env(safe-area-inset-bottom,0px));box-shadow:0 -4px 20px rgba(0,0,0,0.15);display:flex;flex-direction:column;gap:2px;}
.cc-sheet__handle{width:36px;height:4px;border-radius:2px;background:var(--line);margin:0 auto 6px;}
.cc-sheet__item{display:flex;align-items:center;gap:12px;width:100%;min-height:48px;padding:0 14px;border:none;border-radius:var(--radius-md);background:transparent;color:var(--text-primary);font:inherit;font-size:var(--text-md);text-align:left;cursor:pointer;}
.cc-sheet__item svg{width:20px;height:20px;flex-shrink:0;}
.cc-sheet__item--primary{background:var(--accent);color:var(--surface);font-weight:600;}
.cc-sheet__chev{margin-left:auto;display:inline-flex;}
.cc-sheet__meta{margin-left:auto;font-size:var(--text-sm);color:var(--text-secondary);}
.cc-sheet__sub{padding-left:24px;display:flex;flex-direction:column;gap:2px;}
.cc-sheet__score{display:flex;align-items:center;gap:10px;min-height:44px;padding:0 14px;font-size:var(--text-sm);color:var(--text-secondary);}
.cc-sheet__score-val{font-weight:700;color:var(--text-primary);}
.cc-sheet__sep{height:1px;background:var(--line);margin:4px 8px;}
.cc-sheet__links{display:flex;gap:4px;padding:4px 6px 0;}
.cc-sheet__link{flex:1;display:inline-flex;align-items:center;justify-content:center;min-height:44px;border:1px solid var(--line);border-radius:var(--radius-md);color:var(--text-primary);text-decoration:none;font-size:var(--text-sm);}
/* Bottom rail */
.creator-rail{position:fixed;left:0;right:0;bottom:0;z-index:510;background:var(--surface);border-top:1px solid var(--line);padding-bottom:env(safe-area-inset-bottom,0px);box-shadow:0 -2px 10px rgba(0,0,0,0.06);}
.creator-rail__row{display:flex;align-items:center;justify-content:space-between;gap:0;height:var(--creator-rail-h);padding:0 1px;overflow-x:auto;scrollbar-width:none;}
.creator-rail__row::-webkit-scrollbar{display:none;}
.creator-rail__btn{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;flex:1 1 44px;min-width:44px;max-width:72px;min-height:44px;padding:0;border:none;border-radius:var(--radius-sm);background:transparent;color:var(--text-secondary);font:inherit;cursor:pointer;}
.creator-rail__label{font-size:10px;font-weight:600;line-height:1;white-space:nowrap;}
.creator-rail__btn svg{width:22px;height:22px;}
.creator-rail__btn--on{background:var(--accent-soft);color:var(--accent);}
.creator-rail__btn:disabled{opacity:0.35;cursor:default;}
.creator-rail__swatch{display:block;width:22px;height:22px;border-radius:6px;border:2px solid var(--line);}
.creator-rail__mode{flex:2 1 88px;min-width:88px;max-width:144px;}
.creator-rail__mode .mode-toggle__btn{flex:1 1 0;flex-direction:column;gap:2px;min-width:44px;padding:0 2px;font-size:10px;font-weight:600;line-height:1;}
.creator-rail .tb-overflow-wrap{position:static;display:flex;flex:1 1 44px;min-width:44px;max-width:72px;}
.creator-rail .tb-overflow-wrap > .tb-btn{flex:1;flex-direction:column;gap:2px;min-width:44px;min-height:44px;padding:0;justify-content:center;font-size:10px;}
.creator-rail .tb-overflow-wrap > .tb-btn svg{width:22px;height:22px;}
.creator-rail .swatch-strip-row{border-top:none;border-bottom:1px solid var(--line);}
.mode-toggle--compact .mode-toggle__label{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;}
.creator-rail__mode.mode-toggle--compact .mode-toggle__label{position:static;width:auto;height:auto;overflow:visible;clip:auto;}
.tb-more-check{display:flex;align-items:center;gap:8px;min-height:44px;font-size:var(--text-sm);color:var(--text-primary);cursor:pointer;}
body.creator-compact .tb-more-panel{position:fixed;left:0;right:0;top:auto;bottom:calc(var(--creator-rail-h) + env(safe-area-inset-bottom,0px));max-height:60dvh;overflow-y:auto;border-radius:16px 16px 0 0;z-index:520;}
/* Leave room under the chart for the rail. */
body.creator-compact .cs-page-content{padding-bottom:calc(var(--creator-rail-h) + env(safe-area-inset-bottom,0px) + 8px);}
/* The settings drawer: hidden while closed, opens above the rail. */
body.creator-compact .rpanel.rpanel--edit{bottom:calc(var(--creator-rail-h) + env(safe-area-inset-bottom,0px));}
body.creator-compact .rpanel.rpanel--edit:not(.rpanel--open){display:none;}
body.creator-compact .rpanel.rpanel--edit.rpanel--open{max-height:calc(100dvh - 48px - var(--creator-rail-h) - 16px);}
.cc-generate{display:inline-flex;align-items:center;gap:6px;min-height:40px;padding:0 12px;border:none;border-radius:var(--radius-md);background:var(--accent);color:var(--surface);font:inherit;font-size:var(--text-sm);font-weight:600;cursor:pointer;flex-shrink:0;}
.cc-generate svg{width:16px;height:16px;}
.cc-generate:disabled{opacity:0.6;cursor:default;}
/* The chart fills the space between the top bar and the rail, leaving two
   lines for the status text under it. */
body.creator-compact .cs-chart-scroll{height:calc(100dvh - 48px - env(safe-area-inset-top,0px) - var(--creator-rail-h) - env(safe-area-inset-bottom,0px) - var(--creator-status-h))!important;max-height:none!important;min-height:0!important;}
body.creator-compact .cs-page-content{padding-top:4px;}
/* The hint under the chart wraps rather than clipping; the coordinates and colour readout drop to a line of their own. */
body.creator-compact .tb-status{padding:6px 12px;font-size:12px;line-height:1.35;overflow-wrap:anywhere;}
body.creator-compact .tb-status > span:first-child{flex:1 1 100%;min-width:0;}
/* Toasts sit above the rail. A phone's one-line banner also clears the hint, so a notice never hides it. */
body.creator-compact .creator-toast-container,body.creator-compact [data-toast-container]{bottom:calc(var(--creator-rail-h) + env(safe-area-inset-bottom,0px) + 8px)!important;}
body.creator-compact .creator-toast-container--phone,body.creator-compact [data-toast-container][data-toast-phone="1"]{bottom:calc(var(--creator-rail-h) + env(safe-area-inset-bottom,0px) + var(--creator-status-h))!important;}
/* The Tracker's Focus bar floats 16px up and is 62px tall: the phone banner sits above it. */
body.cs-focus [data-toast-container][data-toast-phone="1"]{bottom:calc(max(16px, env(safe-area-inset-bottom, 0px)) + 62px + 8px)!important;}
/* Phone landscape: the chart takes everything between the bars; the status
   line is dropped (the Navigate | Draw switch in the rail says the mode). */
@media (max-height: 500px) {
  body.creator-compact .cs-chart-scroll{height:calc(100dvh - 48px - env(safe-area-inset-top,0px) - var(--creator-rail-h) - env(safe-area-inset-bottom,0px) - 24px)!important;}   /* 4px above the chart, the 8px strip under it and the rail's own 8px of padding */
  body.creator-compact .tb-status{display:none!important;}   /* the bar sets display inline, so only !important wins */
  body.creator-compact{--creator-status-h:8px;}
}
.creator-rail .tb-overflow-wrap > .tb-btn{position:relative;z-index:301;background:var(--surface);}

/* ── What kind of picture is this? (audit IMG-01) ───────────────────────── */
.picture-type__exact{margin-top:8px;font-size:var(--text-sm);}
/* Detail and tidiness: four steps from More detail to Easiest to stitch. */
.stitch-style__desc{margin:6px 0 0;font-size:var(--text-xs);line-height:1.45;color:var(--text-secondary);}
.stitch-style__outcome{margin:4px 0 0;font-size:var(--text-xs);color:var(--text-tertiary);font-variant-numeric:tabular-nums;}

/* ── Thread brand for Convert (audit IMG-04) ─────────────────────────────── */

/* ── Size field: stitches or finished size (audit IMG-03) ───────────────── */
.size-field{display:flex;flex-direction:column;gap:var(--s-2);margin-top:var(--s-2);}
.size-field__mode{display:flex;width:100%;}
.size-field__mode .lp-seg{font-size:var(--text-xs);min-height:32px;}
.size-field__lock{display:flex;align-items:center;gap:6px;font-size:var(--text-sm);cursor:pointer;}
.size-field__row{display:flex;align-items:flex-end;gap:var(--s-2);}
.size-field__label{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0;font-size:var(--text-xs);color:var(--text-tertiary);}
.size-field__input{width:100%;padding:5px 8px;border:0.5px solid var(--border);border-radius:var(--radius-sm);font-size:var(--text-md);background:var(--surface);color:var(--text-primary);}
.size-field__x,.size-field__unit{font-size:var(--text-sm);color:var(--text-secondary);padding-bottom:6px;}
.size-field__chips{display:flex;flex-wrap:wrap;gap:6px;}
.size-field__chip{padding:4px 10px;min-height:32px;border:1px solid var(--border);border-radius:999px;background:var(--surface);color:var(--text-secondary);font-size:var(--text-xs);font-weight:600;cursor:pointer;font-family:inherit;}
.size-field__chip:disabled{opacity:0.5;cursor:default;}
@media (hover: hover){.size-field__chip:not(:disabled):hover{background:var(--surface-tertiary);}}
.size-field__readout{margin:0;font-size:var(--text-sm);color:var(--text-primary);font-variant-numeric:tabular-nums;}
.size-field__note{margin:0;font-size:var(--text-xs);color:var(--text-secondary);background:var(--surface-tertiary);border-radius:var(--radius-sm);padding:4px 8px;}

/* ── Compare options (audit IMG-05) ─────────────────────────────────────── */
.compare-strip{padding:8px 14px 12px;}
.compare-strip__head{display:flex;align-items:center;justify-content:space-between;gap:var(--s-2);flex-wrap:wrap;}
.compare-strip__toggle{display:inline-flex;align-items:center;gap:6px;min-height:32px;padding:0;border:none;background:none;font:inherit;font-size:12px;font-weight:600;color:var(--text-secondary);cursor:pointer;}
.compare-strip__chev{display:inline-flex;width:14px;height:14px;transform:rotate(-90deg);transition:transform var(--motion,150ms) ease;}
.compare-strip--open .compare-strip__chev{transform:none;}
.compare-strip__dim .lp-seg{font-size:var(--text-xs);}
.compare-strip__row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--s-2);margin-top:var(--s-2);}
.compare-strip__option{display:flex;flex-direction:column;align-items:stretch;gap:4px;padding:8px;border:1px solid var(--border);border-radius:var(--radius-md);background:var(--surface);color:var(--text-primary);font:inherit;text-align:left;cursor:pointer;min-width:0;}
.compare-strip__option:disabled{cursor:default;opacity:1;color:var(--text-primary);}
.compare-strip__option--same{opacity:0.55;}
.compare-strip__option--current{border-color:var(--accent);background:var(--accent-light);}
@media (hover: hover){.compare-strip__option:not(:disabled):hover{border-color:var(--accent);}}
.compare-strip__label{font-size:var(--text-xs);font-weight:700;color:var(--text-secondary);}
.compare-strip__thumb{display:flex;align-items:center;justify-content:center;aspect-ratio:1/1;background:var(--surface-tertiary);border-radius:var(--radius-sm);overflow:hidden;}
.compare-strip__thumb img{width:100%;height:100%;object-fit:contain;image-rendering:pixelated;}
.compare-strip__pending{width:16px;height:16px;border-radius:50%;border:2px solid var(--line);border-top-color:var(--accent);animation:cs-spin 900ms linear infinite;}
.compare-strip__stat{font-size:var(--text-xs);color:var(--text-secondary);line-height:1.35;}
/* Phones: one row that scrolls sideways. */
body.creator-compact .compare-strip__row{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;-webkit-overflow-scrolling:touch;}
body.creator-compact .compare-strip__option{flex:0 0 44%;scroll-snap-align:start;}
@media (prefers-reduced-motion: reduce){.compare-strip__pending{animation:none;}.compare-strip__chev{transition:none;}}

/* ── Generating a pattern (audit IMG-07) ────────────────────────────────── */
/* Same card as the import progress (.import-busy), centred over a light
   scrim so the settings can't change underneath it. */
.generate-busy-scrim{position:fixed;inset:0;z-index:1000;display:flex;align-items:center;justify-content:center;padding:var(--s-4);background:color-mix(in srgb, var(--surface) 70%, transparent);}
.generate-busy{width:min(360px, 100%);display:flex;flex-direction:column;gap:var(--s-2);padding:var(--s-3) var(--s-4);border:1px solid var(--line);border-radius:var(--radius-md);background:var(--surface);box-shadow:var(--shadow-md);color:var(--text-primary);}

/* Convert sidebar: technical names folded under "Advanced" (audit P2-9). */
.convert-advanced { margin-top: 8px; font-size: var(--text-sm); color: var(--text-secondary); }
.convert-advanced > summary {
  /* Left as a list item so the disclosure triangle shows. */
  cursor: pointer; color: var(--text-secondary); font-weight: 500;
  padding: 6px 0; border-radius: var(--radius-sm);
}
@media (hover: hover) { .convert-advanced > summary:hover { color: var(--text-primary); } }
.convert-advanced > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.convert-advanced > p { margin: 4px 0 0; line-height: 1.45; }
@media (pointer: coarse) { .convert-advanced > summary { padding: 12px 0; } }

/* Selection action bar: copy, paste, flip and rotate (audit DRAW-04).
   Fixed over the chart, just above (or below) the selection; under the
   phone tool rail and its More sheet. */
.cs-selbar {
  position: fixed; z-index: 505;
  display: flex; align-items: center; gap: 2px;
  padding: 4px; border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  max-width: calc(100vw - 16px); flex-wrap: wrap;
}
.cs-selbar__hint { font-size: var(--text-xs); color: var(--text-tertiary); padding: 0 6px; }
@media (max-width: 480px) { .cs-selbar__hint { display: none; } }
.cs-selbar__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 36px; min-height: 36px; padding: 0 8px;
  border: none; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-primary); font: inherit; font-size: var(--text-sm); cursor: pointer;
}
.cs-selbar__btn svg { width: 18px; height: 18px; }
.cs-selbar__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cs-selbar__btn--primary { background: var(--accent); color: var(--text-on-accent); font-weight: 600; }
@media (hover: hover) {
  .cs-selbar__btn:hover { background: var(--surface-secondary); }
  .cs-selbar__btn--primary:hover { background: var(--accent-hover); }
}
@media (pointer: coarse) {
  .cs-selbar__btn { min-width: 44px; min-height: 44px; }
}
/* The same actions in the Tools tab's Selection section. */
.cs-seltools { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: var(--s-2); }
.cs-seltools__btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px;
  font: inherit; font-size: var(--text-xs); color: var(--text-secondary);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
}
.cs-seltools__btn:disabled { opacity: 0.45; cursor: default; }
.cs-seltools__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cs-seltools__btn--primary { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); font-weight: 600; }
.cs-seltools__float { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--text-xs); color: var(--text-secondary); }
.cs-seltools__float > span { flex: 1 1 100%; }
@media (hover: hover) { .cs-seltools__btn:not(:disabled):hover { color: var(--text-primary); background: var(--surface-secondary); } }
/* Tools tab sections for shapes and mirror drawing (audit DRAW-04). */
.cs-toolsec { padding: 12px; border-top: 1px solid var(--border); }
.cs-toolsec__title { font-size: var(--text-xs); font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: var(--s-2); }
.cs-toolsec .cs-seltools { margin-top: 6px; }
.cs-toolsec__check { display: flex; align-items: center; gap: var(--s-2); margin-top: 8px; font-size: var(--text-sm); color: var(--text-secondary); cursor: pointer; }
.cs-toolsec__hint { font-size: var(--text-xs); color: var(--text-tertiary); margin: 6px 0 0; line-height: 1.45; }
.cs-seltools__btn--on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
@media (pointer: coarse) { .cs-seltools__btn { min-height: 44px; } }
/* Mirror-axis grips (audit DRAW-04): on the chart's top edge (left-right
   axis) and left edge (top-bottom axis), centred on the axis line. */
.cs-mirror-grip {
  position: fixed; z-index: 504;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--text-on-accent);
  box-shadow: var(--shadow-md); cursor: grab; touch-action: none;
}
.cs-mirror-grip svg { width: 18px; height: 18px; }
.cs-mirror-grip--v { transform: translate(-50%, -50%); }
.cs-mirror-grip--h { transform: translate(-50%, -50%) rotate(90deg); }
.cs-mirror-grip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (pointer: coarse) { .cs-mirror-grip { width: 44px; height: 44px; } }
/* Text tool sheet (audit DRAW-04): not modal, so the chart stays usable.
   A card on wide screens; on phones it sits at the bottom, above the rail. */
.cs-textsheet {
  position: fixed; z-index: 506; right: 16px; top: 140px; width: 320px; max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 160px); overflow-y: auto;
  padding: 12px; border-radius: var(--radius-md); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 8px; font-size: var(--text-sm); color: var(--text-primary);
}
body.creator-compact .cs-textsheet {
  left: 0; right: 0; top: auto; width: auto; max-width: none;
  bottom: calc(var(--creator-rail-h, 64px) + env(safe-area-inset-bottom, 0px));
  max-height: 50dvh; border-radius: 16px 16px 0 0;
}
.cs-textsheet > * { flex-shrink: 0; }
.cs-textsheet__head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -12px; margin: -12px -12px 0; padding: 12px 12px 4px; background: var(--surface); z-index: 1; }
.cs-textsheet__title { font-weight: 600; }
.cs-textsheet__close { border: none; background: transparent; color: var(--text-secondary); min-width: 36px; min-height: 36px; border-radius: var(--radius-sm); cursor: pointer; }
.cs-textsheet__input {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; padding: 8px; min-height: 64px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-primary); resize: vertical;
}
.cs-textsheet__input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cs-textsheet__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cs-textsheet__label { color: var(--text-secondary); }
.cs-textsheet__seg { display: inline-flex; gap: 2px; background: var(--surface-tertiary); padding: 2px; border-radius: var(--radius-sm); }
.cs-textsheet__seg button, .cs-textsheet__stepper button {
  border: none; background: transparent; font: inherit; color: var(--text-secondary);
  min-height: 32px; padding: 0 10px; border-radius: var(--radius-sm); cursor: pointer;
}
.cs-textsheet__seg button.is-on { background: var(--surface); color: var(--text-primary); font-weight: 600; box-shadow: var(--shadow-sm); }
.cs-textsheet__stepper { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.cs-textsheet__stepper button { border: 1px solid var(--border); min-width: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.cs-textsheet__stepper button:disabled { opacity: 0.4; cursor: default; }
.cs-textsheet__size, .cs-textsheet__hint { margin: 0; font-size: var(--text-xs); color: var(--text-tertiary); }
.cs-textsheet__note { margin: 0; font-size: var(--text-xs); color: var(--text-secondary); }
.cs-textsheet__warn { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px; border-radius: var(--radius-sm); background: var(--warning-soft); color: var(--text-primary); }
.cs-textsheet__warn-icon { display: inline-flex; width: 16px; height: 16px; color: var(--warning); }
.cs-textsheet__warn-actions { display: flex; gap: 6px; flex-basis: 100%; }
.cs-textsheet__warn-actions button { font: inherit; font-size: var(--text-xs); padding: 4px 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text-primary); border-radius: var(--radius-sm); cursor: pointer; }
.cs-textsheet__head-actions { display: flex; align-items: center; gap: 4px; }
.cs-textsheet__btn { font: inherit; padding: 6px 14px; min-height: 36px; border: 1px solid var(--border); background: var(--surface); color: var(--text-primary); border-radius: var(--radius-sm); cursor: pointer; }
.cs-textsheet__btn--primary { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); font-weight: 600; }
.cs-textsheet__btn:disabled { opacity: 0.5; cursor: default; }
@media (pointer: coarse) {
  .cs-textsheet__seg button, .cs-textsheet__stepper button, .cs-textsheet__btn, .cs-textsheet__close, .cs-textsheet__warn-actions button { min-height: 44px; min-width: 44px; }
}

/* Stats: reading a chart without hovering (Phase 3), and the page's groups */
.chart-scrubber { margin-top: 8px; }
.chart-readout {
  min-height: 1.6em;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-secondary);
  color: var(--text-primary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.chart-scrub-range { display: block; width: 100%; margin: 8px 0 0; min-height: 28px; accent-color: var(--accent); }
.chart-table { margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.chart-table summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; color: var(--text-secondary); }
.chart-table-scroll { max-height: 240px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 6px; }
.chart-table table { width: 100%; border-collapse: collapse; }
.chart-table caption { text-align: left; padding: 6px 8px; font-weight: 600; color: var(--text-primary); }
.chart-table th, .chart-table td { text-align: left; padding: 4px 8px; border-top: 1px solid var(--border-subtle); font-variant-numeric: tabular-nums; }
.chart-table th { color: var(--text-secondary); font-weight: 600; }
.stats-accordion {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.stats-accordion-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}
.stats-accordion-summary::-webkit-details-marker { display: none; }
.stats-accordion-summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--text-secondary); border-bottom: 2px solid var(--text-secondary); transform: rotate(45deg); transition: transform var(--motion-fast, 0.12s); flex-shrink: 0; margin-right: 4px; }
.stats-accordion[open] > .stats-accordion-summary::after { transform: rotate(-135deg); }
.stats-accordion-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius-lg); }
.stats-accordion-hint { font-size: var(--text-xs); font-weight: 400; color: var(--text-secondary); margin-left: auto; }
.stats-accordion-body { padding: 0 16px 16px; }
/* the accordion's own title is the group's name, so the component's repeats it */
.stats-accordion-body .stats-section-title,
.stats-accordion-body > div > h3:first-child,
.stats-accordion-body > div > h4:first-child { display: none !important; }
.stats-accordion-body > div { border: 0 !important; background: transparent !important; padding: 0 !important; margin-top: 0 !important; }
@media (pointer: coarse) { .chart-scrub-range { min-height: 36px; } }

/* Stats: small text and tinted buttons that pass contrast (the tokens they use elsewhere are a little light for 11-12 px) */
.stats-container, .stats-dashboard, .gsd-tabs { --text-tertiary: var(--text-secondary); }
.stats-container .goal-set-btn,
.stats-container .stats-export-btn--share,
.stats-container .timeline-show-all,
.stats-container .milestone-badge.next .milestone-percent,
.stats-container .milestone-badge.next .milestone-date,
.stats-dashboard .goal-set-btn { color: var(--accent-ink); }
.stats-container .milestone-badge.achieved .milestone-percent,
.stats-container .milestone-badge.achieved .milestone-date { color: var(--text-primary); }


/* ── Phase 4 (small screens and touch) ───────────────────────────────
   TRACK-07: controls are at least 44 px on touch; the save status is a compact icon on a phone (a narrow screen, or a
   short one: a phone on its side) instead of a clipped pill. A tablet keeps the name and the percentage. The older "hide the badge on mobile" rule further up never applied (a later rule set it back to flex), which
   is why it showed as a 22 px sliver. ── */
@media (max-width: 599px), (max-height: 520px) {
  .tb-proj-badge{ padding:0; border:none; background:transparent; flex-shrink:0; max-width:none; overflow:visible; }
  /* The save status shares the percentage's class, so hide the percentage only. */
  .tb-proj-badge .tb-proj-badge-name{ display:none !important; }   /* it is an inline-styled button; the project switcher already names the project */
  .tb-proj-badge-pct:not(.tb-proj-badge-saved){ display:none; }
  .tb-proj-badge-saved{ padding:0 4px; }
  .tb-save-label{ position:absolute; width:1px; height:1px; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0; padding:0; }
  .tb-proj-badge-saved svg{ width:20px; height:20px; }
  /* A problem is never reduced to an icon. */
  .tb-proj-badge-saved--error .tb-save-label{ position:static; width:auto; height:auto; margin:0; overflow:visible; clip:auto; white-space:nowrap; }
}
@media (pointer: coarse) {
  .ppal-close, .ppal-more-close, .lp-close, .tracker-dismiss-btn, .toast-dismiss{ min-width:44px; min-height:44px; justify-content:center; }
  .ppal-more-close::after{ display:none; }
}


/* ── Phase 4 batch 2 (TRACK-07): give the chart the screen ───────────────
   Focus mode now actually tucks the top bar and the progress strip away (it was written for class names this page no
   longer uses), leaves a thin progress line and the floating bar with Exit focus, and keeps the controls strip. On a
   phone it is the default. The chart box is sized from the measured space (useFillChartHeight in tracker-app.js). */
body.cs-focus .tb-topbar,
body.cs-focus .info-strip-wrap,
body.cs-focus .tracker-hint,
body.cs-focus .tracker-hover-wrap--idle { display: none !important; }   /* a placed guide still shows its coordinates and Clear guide */
body.cs-focus .canvas-area { padding-top: 22px; padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important; }
.cs-focus-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 18px; z-index: var(--z-coachmark, 1200);
  background: var(--surface-tertiary); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; pointer-events: none; overflow: hidden;
}
.cs-focus-progress__fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-light); }
.cs-focus-progress__text { position: relative; padding: 0 10px; font-size: 11px; font-weight: 600; color: var(--accent-ink); font-variant-numeric: tabular-nums; }

/* The colour the controls strip's first button stands for; the Palette pill that floated over the hint banner is gone. */
.ppal-mode-swatch { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border); }
.ppal-phone-chip { display: none !important; }
/* Nothing to say on a touch screen when no guide is placed (there is no hover). */
@media (pointer: coarse) { .tracker-hover-wrap--idle { display: none !important; } }

@media (max-width: 1023px), (pointer: coarse) {
  /* The measured space; 600 px until it has been measured. The colour drawer's own shorter height still wins. */
  .tracker-chart-scroll { max-height: var(--tracker-chart-h, 600px); }
  .tracker-chart-scroll.is-drawer { max-height: 340px; }
  /* End space so the last column can be scrolled clear of the controls strip. Only the scroll extent grows. */
  .tracker-chart-view { margin-right: 60px; }
  .ppal-canvas-col--left .tracker-chart-view { margin-right: 0; }
  .ppal-canvas-col--left .tracker-chart-scroll { margin-left: 60px; }
  .ppal-canvas-col--left .ppal-mode-strip { right: auto; left: 8px; }
}
/* The way out of Focus is a touch target, not a keyboard hint. */
.cs-focus-bar .cs-focus-exit { white-space: nowrap; }
@media (pointer: coarse) { .cs-focus-bar .cs-focus-exit kbd { display: none; } }


/* ── Phase 4 batch 3 (TRACK-08): touch intent, Paint mode, Lock touches ─────── */
@media (pointer: coarse) { .toast-action { min-height: 44px; min-width: 44px; } }
.ppal-touch-row { display: flex; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
@media (pointer: coarse) { .ppal-touch-row .ppal-utility-chip { min-height: 44px; } }
.touch-lock-pill {
  position: fixed; top: 28px; left: 50%; transform: translateX(-50%);
  z-index: var(--z-coachmark, 1200); min-height: 44px; max-width: calc(100vw - 24px);
  display: inline-flex; align-items: center; gap: 8px; padding: 0 16px; overflow: hidden;
  border: 1px solid var(--accent-border); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--accent-ink); font: inherit; font-size: var(--text-sm); font-weight: 600;
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.12)); cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none;
}
.touch-lock-pill svg { width: 18px; height: 18px; }
.touch-lock-pill__icon { display: inline-flex; position: relative; z-index: 1; }
.touch-lock-pill > span:not(.touch-lock-pill__fill):not(.touch-lock-pill__icon) { position: relative; z-index: 1; }
.touch-lock-pill__fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent-light); }
.touch-lock-pill--holding .touch-lock-pill__fill { width: 100%; transition: width var(--unlock-ms, 700ms) linear; }
@media (prefers-reduced-motion: reduce) { .touch-lock-pill--holding .touch-lock-pill__fill { transition: none; width: 100%; } }
body:not(.cs-focus) .touch-lock-pill { top: calc(var(--app-header-height, 48px) + 8px); }

/* Phase 4 batch 4 (TRACK-05) — the "welcome back" recap is a strip, not a dialog, so the chart stays usable. */
.resume-recap-banner {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(var(--app-header-height, 48px) + 8px); z-index: 900;
  display: flex; align-items: center; gap: 8px;
  max-width: min(640px, calc(100vw - 16px)); width: max-content;
  padding: 8px 8px 8px 14px;
  background: var(--surface); color: var(--text-primary);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
}
.resume-recap-banner-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.resume-recap-banner-text span { color: var(--text-secondary); font-size: var(--text-xs); }
.resume-recap-banner-btn, .resume-recap-banner-close {
  min-height: 36px; padding: 0 10px; background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); cursor: pointer; font: inherit; white-space: nowrap;
}
@media (pointer: coarse) { .resume-recap-banner-btn, .resume-recap-banner-close { min-height: 44px; } .resume-recap-banner-close { min-width: 44px; } }
.resume-recap-banner-close { border: none; display: inline-flex; align-items: center; min-width: 36px; justify-content: center; }
@media (max-width: 599px) {
  .resume-recap-banner { flex-wrap: wrap; }
  .resume-recap-banner-btn { flex: 1; }
}

/* Phase 4 end-of-phase hunt — a viewport shorter than the controls strip (browser zoom 200% on a phone is 196x364,
   and the strip is about 330 px): the strip scrolls inside the chart column instead of running off the bottom,
   where More could not be reached because nothing on the page scrolls. */
.ppal-mode-strip { max-height: calc(100% - 8px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }

/* ═══ Stats: bento layout ═══
   One shared grid for every stats tab. A wrapping flex row, so each row of
   tiles always fills the full width and a hidden tile never leaves a gap.
   Size classes set a preferred width; flex-grow shares out what is left. */
.bento {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.bento-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: 100%;
  overflow-wrap: anywhere;
  min-width: 0;
  flex: 1 1 300px;
}
.bento-cell--sm   { flex: 1 1 200px; }
.bento-cell--md   { flex: 1.3 1 300px; }
.bento-cell--lg   { flex: 2 1 440px; }
.bento-cell--xl   { flex: 3 1 620px; }
.bento-cell--full { flex: 1 1 100%; }
.bento-cell > .gsd-section-label,
.bento-cell > .stats-section-title { margin: 0 0 var(--s-2); }
.bento-cell > :where(:not(.gsd-section-label):not(.stats-section-title)) {
  flex: 0 1 auto;
  min-width: 0;
  width: 100%;
  margin-top: 0;
  margin-bottom: 0;
}
.bento-cell > .stats-accordion { margin-top: 0; align-self: stretch; }
@media (max-width: 640px) {
  .bento-cell,
  .bento-cell--sm,
  .bento-cell--md,
  .bento-cell--lg,
  .bento-cell--xl { flex-basis: 100%; }
}
.gsd-week-summary {
  margin: var(--s-3) 0 0;
  padding-top: var(--s-3);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text-secondary);
}
.bento-cell.gsd-timeline > :not(.gsd-section-label) { flex: none; }
.gsd-tl-cols { column-width: 320px; column-gap: var(--s-5); }
.gsd-tl-cols .gsd-tl-day { break-inside: avoid; }
.bento-cell--stack { gap: var(--s-3); }
.bento-cell--stack > * { flex: 0 1 auto; }

.bento-cell > .stats-export-bar { flex: none; margin-top: var(--s-3); }
.bento-cell .gsd-insights { align-content: start; }
@media (max-width: 640px) {
  .gsd-metrics > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* Overview / Visuals switch in a project's Stats */
.stats-viewtabs {
  display: inline-flex;
  margin: 0 0 var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  overflow: hidden;
}
.stats-viewtab {
  padding: 6px 18px;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--text-md);
  cursor: pointer;
}
.stats-viewtab--on { background: var(--accent-light); color: var(--accent-ink); font-weight: 600; }
.stats-viewtab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ── Tracker pattern overview (Phase 5, TRACK-09) ─────────────────────────────────────────────────────────────── */
.tracker-minimap{position:absolute;left:0;top:0;z-index:20;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface-tertiary);box-shadow:var(--shadow-sm);overflow:hidden;touch-action:none;cursor:pointer;user-select:none;-webkit-user-select:none;}
.tracker-minimap:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}
.tracker-minimap__canvas{display:block;width:100%;height:100%;image-rendering:pixelated;}
.tracker-minimap__view{position:absolute;left:0;top:0;box-sizing:border-box;border:2px solid var(--accent);box-shadow:0 0 0 1px var(--surface),inset 0 0 0 1px var(--surface);pointer-events:none;will-change:transform;}
.tracker-minimap-open{position:absolute;left:0;top:0;z-index:20;min-width:44px;min-height:44px;display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface);color:var(--text-primary);box-shadow:var(--shadow-sm);cursor:pointer;font-size:20px;}
.tracker-minimap-open:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}
@media (forced-colors:active){.tracker-minimap__view{border-color:Highlight;}.tracker-minimap{border-color:CanvasText;}}
@media print{.tracker-minimap,.tracker-minimap-open{display:none!important;}}

/* Keyboard focus on the chart: the guide crosshair is the cursor, and the box shows the chart is where keys go. */
.tracker-chart-scroll:has(canvas:focus-visible){outline:2px solid var(--accent);outline-offset:-2px;}
.tracker-chart-scroll canvas:focus-visible{outline:none;}

/* Stats content sizing: scroll dense matrices locally, keep the page fluid. */
.stats-dashboard, .gsd, .stats-container-body { min-width: 0; width: 100%; }
.stats-colour-controls label { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1); min-width: 0; }
.colour-progress { container-type: inline-size; }
@container (min-width: 520px) {
  .stats-colour-row { grid-template-columns: 14px minmax(0, 2fr) minmax(80px, 1fr) minmax(0, auto); }
  .colour-info { grid-column: 2; }
  .colour-bar { grid-column: 3; }
}
.section-grid-scroll { max-width: 100%; max-height: 28rem; overflow: auto; padding: 3px; margin-bottom: var(--s-3); }
.stats-sections > div { min-width: 0; }
.stats-sections > div:not(.section-grid-scroll) { flex-wrap: wrap; gap: var(--s-2); }
.comparison-previews { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: var(--s-3); }
.comparison-preview { min-width: 0; text-align: center; }
.comparison-preview canvas { max-width: 100%; }
.stats-comparison input[type="text"] { max-width: 100%; }
.stats-dashboard .session-editor label { flex: 1 1 9rem; min-width: 0; }
.stats-dashboard .session-editor input { width: 100%; min-width: 0; }
.stats-dashboard select, .gsd select { max-width: 100%; }
.gsd-metrics { grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); }
.gsd-metric, .gsd-tl-body, .timeline-content { min-width: 0; overflow-wrap: anywhere; }
.gsd-streak { flex-wrap: wrap; }
.comparison-header { flex-wrap: wrap; gap: var(--s-2); }
.comparison-name { white-space: normal; overflow-wrap: anywhere; }
.chart-container { min-width: 0; }
.chart-container svg { height: auto; }

.stats-plot-scroll { max-width: 100%; overflow-x: auto; }
.stats-plot { min-width: 480px; }
.stats-plot svg { width: 100%; height: auto; }

.colour-progress .stats-empty { text-align: left; padding: var(--s-2) 0; }
.gsd { overflow-wrap: anywhere; }
.gsd .gsd-metric { min-width: 0; }
.gsd-projects { grid-template-columns: repeat(auto-fill, minmax(min(100%, 130px), 1fr)); }

.colour-progress .colour-id { max-width: 100%; min-width: 0; }

.project-comparison { min-width: 0; width: 100%; overflow-wrap: anywhere; }
.comparison-insight-card > span:last-child { min-width: 0; }

.stats-container :is(button, input, select, summary) { scroll-margin-top: calc(var(--app-header-height, 48px) + 80px); }
.stats-container > .gsd-tabs { top: var(--app-header-height, 48px); }

/* Import evidence stays available on desktop and phone. */
.import-review-status { font-weight: 600; color: var(--text-primary); }
.import-review-verification {
  padding: var(--s-3); border-bottom: 1px solid var(--line);
  grid-area: verify; min-height: 0; max-height: 25vh; overflow: auto;
  color: var(--text-secondary); font-size: var(--text-sm);
}
.import-review-verification summary { cursor: pointer; font-weight: 600; }
.import-review-verification a { color: var(--accent); }

.import-review-header { flex-wrap: wrap; }
.import-review-status { flex-basis: 100%; }

.bead-progress { padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--text-primary); }
.bead-progress-list { max-height: 240px; overflow: auto; }
.bead-progress-list > div { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 6px; }
.bead-progress button { min-height: 44px; color: var(--text-primary); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 10px; }
.bead-progress button[aria-pressed="true"] { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }

/* Ready-to-stitch review shares Workshop tokens and contains wide canvases. */
.ready-review { max-width: 1200px; margin: 0 auto; padding: var(--s-3); color: var(--text-primary); }
.ready-review h2, .ready-review h3 { margin: 0 0 var(--s-2); }
.ready-review p { line-height: 1.55; color: var(--text-secondary); margin: var(--s-2) 0 var(--s-3); }
.ready-review-images { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); }
.ready-review figure { margin: 0; padding: var(--s-2); min-width: 0; background: var(--surface-secondary); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: auto; }
.ready-review figcaption { font-weight: 600; margin-bottom: var(--s-2); }
.ready-review canvas, .ready-review img { display: block; width: auto; max-width: 100%; height: auto; margin: 0 auto; object-fit: contain; }
.ready-review img { max-height: 400px; }
.ready-review .preview-wrap { min-width: 0; overflow: hidden; }
.ready-review .preview-status-bar { white-space: normal; overflow-wrap: anywhere; }
.ready-review-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); margin: var(--s-3) 0; }
.ready-review-summary > div { padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--radius-sm); min-width: 0; }
.ready-review button { min-height: 44px; padding: var(--s-2) var(--s-3); margin: 0 var(--s-2) var(--s-2) 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--accent); cursor: pointer; font: inherit; max-width: 100%; }
.ready-review label { display: flex; flex-direction: column; gap: var(--s-1); }
.ready-review input, .ready-review select { box-sizing: border-box; min-height: 44px; max-width: 100%; width: 100%; padding: var(--s-2); border: 1px solid var(--line); background: var(--surface); color: var(--text-primary); border-radius: var(--radius-sm); font: inherit; }
.ready-review-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); }
.ready-review-images--sample { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: var(--s-3); }
.ready-review-note { border-left: 3px solid var(--accent); padding-left: var(--s-3); }
@media (max-width: 700px) {
  .ready-review-images, .ready-review-summary { grid-template-columns: minmax(0, 1fr); }
  .ready-review-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ready-review { padding: var(--s-2); padding-bottom: 100px; }
}

.ready-review-images--sample.is-enlarged canvas { max-width: none; }

/* Optional foreground WebDAV connection in Preferences. */
.webdav-panel { padding: 16px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-primary); }
.webdav-panel p { color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.webdav-panel form, .webdav-panel label { display: flex; flex-direction: column; gap: 8px; }
.webdav-panel form { gap: 12px; }
.webdav-panel input { width: 100%; box-sizing: border-box; padding: 8px; color: var(--text-primary); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.webdav-panel button { padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-primary); cursor: pointer; }
.webdav-panel button:disabled { opacity: .5; cursor: default; }
.webdav-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Existing-project chart review */
.chart-update-dialog {
  width: min(900px, 94vw);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 24px;
}
.chart-update-dialog label { display: block; margin-block: 12px; }
.chart-update-dialog input[type="number"] { width: 7em; }
.chart-update-dialog textarea { display: block; width: 100%; min-height: 6em; }
.chart-update-dialog pre { max-height: 300px; overflow: auto; white-space: pre-wrap; }
.chart-update-dialog .btn { margin: 4px; }
.chart-update-decisions { max-height: 350px; overflow: auto; }
.chart-update-dialog select { max-width: 100%; }

/* Focused tracking journey: independent palette actions, usable target sizes. */
.ppal-tile-swatch{appearance:none;padding:0;border:0;border-right:1px solid var(--border);}
.ppal-tile-select{width:100%;min-height:24px;padding:0;border:0;background:transparent;text-align:left;font-family:inherit;cursor:pointer;}
.ppal-tile-park-btn,.ppal-tile-done-btn{min-width:24px;min-height:24px;}
.ppal-tile--done:not(.ppal-tile--on){opacity:1;}
.info-strip-open{border:0;background:transparent;min-width:24px;min-height:24px;padding:0;cursor:pointer;font-family:inherit;}
.tracker-chart-summary{margin:0 0 var(--s-2);font-size:var(--text-xs);color:var(--text-secondary);}
@media (pointer:coarse){
  .ppal-tile-select,.ppal-tile-park-btn,.ppal-tile-done-btn{min-height:44px;}
  .ppal-tile-park-btn,.ppal-tile-done-btn{min-width:44px;}
}

/* First-use additions use existing Workshop surfaces and stay within the flows. */
.import-warning-repair { margin: var(--s-1); min-height: 44px; white-space: normal; }



/* The (i) hint icon (InfoIcon, components.js): a small button that shows a
   setting's hint on hover, focus or tap. Its text is kept for screen readers. */
.info-icon{display:inline-flex;align-items:center;flex-shrink:0;}
.info-icon__btn{display:inline-flex;align-items:center;justify-content:center;padding:2px;margin:-2px;border:none;background:none;border-radius:50%;color:var(--text-tertiary);cursor:help;line-height:1;font:inherit;}
.info-icon__btn svg{width:14px;height:14px;}
@media (hover:hover){.info-icon__btn:hover{color:var(--accent);}}
.info-icon__btn:focus-visible{outline:2px solid var(--accent);outline-offset:1px;color:var(--accent);}
@media (pointer:coarse){.info-icon__btn{padding:8px;margin:-8px;}}
.info-icon__text{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;}

/* A field label with a hover hint beside it (InfoIcon). */
.convert-label{display:flex;align-items:center;gap:4px;flex-wrap:wrap;}
.convert-label > label{display:inline-flex;align-items:center;gap:6px;}
.size-field__heading{font-size:var(--text-xs);font-weight:600;color:var(--text-tertiary);text-transform:uppercase;letter-spacing:0.5px;}

/* ── Convert panel (creator/ConvertPanel.js) ─────────────────────────────
   Laid out like the Edit panel: its tab strip (.creator-sidebar-tabs), its
   sections (.cs-toolsec) and its hints (.cs-toolsec__hint), so the two read
   the same. One label size (--text-sm), one hint size (--text-xs). */
.cv-tabs { flex-shrink: 0; background: var(--surface); }
.cv-panel { display: flex; flex-direction: column; }
.cv-panel > .cs-toolsec:first-of-type { border-top: none; }
.cv-lead { margin: 0; padding: 12px 12px 0; font-size: var(--text-sm); line-height: 1.45; color: var(--text-secondary); }
.cv-sec__head { display: flex; align-items: center; gap: 4px; margin-bottom: var(--s-2); }
.cv-sec__head .cv-sec__title { margin: 0; }
.cv-sec .size-field { margin-top: 0; }
.cv-hint--muted { color: var(--text-tertiary); }
.cv-check { margin-top: 2px; }
.cv-check .cs-toolsec__check { margin-top: 6px; color: var(--text-primary); }
.cv-check--disabled { opacity: 0.55; cursor: not-allowed; }
.cv-seg { display: flex; width: 100%; margin-top: 2px; }
.cv-seg .lp-seg { font-size: var(--text-xs); min-height: 32px; padding: 4px 6px; line-height: 1.2; white-space: normal; }
.cv-seg .lp-seg:disabled { cursor: default; }
.cv-seg .lp-seg:disabled:not(.lp-seg--on) { color: var(--text-tertiary); }
.cv-seg--sub { margin-top: 6px; }
.cv-seg--sub .lp-seg { min-height: 28px; font-weight: 500; }
.cv-seg--grid { display: grid; grid-template-columns: 1fr 1fr; }
.cv-seg--grid .lp-seg { min-height: 36px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cv-seg--grid .lp-seg:nth-child(2n) { border-right: none; }
.cv-seg--grid .lp-seg:nth-last-child(-n+2) { border-bottom: none; }
.cv-seg--wrap { flex-wrap: wrap; }
@media (pointer: coarse) { .cv-seg .lp-seg { min-height: 44px; } }
.cv-sec .slider-row, .cv-sec input[type="range"] { width: 100%; }
.cv-sec > div + div { margin-top: 6px; }
.cv-note { display: flex; align-items: flex-start; gap: 6px; margin-top: var(--s-2); padding: 6px 10px; border-radius: var(--radius-md); font-size: var(--text-xs); line-height: 1.45; background: var(--surface-secondary); border: 1px solid var(--line); color: var(--text-secondary); }
.cv-note__icon { display: inline-flex; width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }
.cv-note__icon svg { width: 14px; height: 14px; }
.cv-note--warning { background: var(--warning-soft); border-color: var(--warning-soft); color: var(--accent-ink); }
.cv-note--danger { background: var(--danger-soft); border-color: var(--danger-soft); color: var(--danger); }
.cv-bgpick { display: flex; align-items: center; gap: var(--s-2); margin: var(--s-2) 0; }
.cv-bgpick__swatch { width: 28px; height: 28px; border-radius: var(--radius-sm); border: 2px solid var(--border); cursor: pointer; padding: 0; flex-shrink: 0; }
.cv-bgpick .cs-seltools__btn, .cv-reset { width: auto; }
.cv-reset { margin-top: var(--s-2); }
.cv-field { display: flex; flex-direction: column; gap: 4px; margin-top: var(--s-2); }
.cv-field:first-of-type { margin-top: 0; }
.cv-field__label { font-size: var(--text-sm); color: var(--text-secondary); }
.cv-input { width: 100%; box-sizing: border-box; padding: 6px 8px; font: inherit; font-size: var(--text-sm); color: var(--text-primary); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.cv-input--area { resize: vertical; min-height: 54px; }
.cv-input--seed { width: 84px; }
.cv-link { background: none; border: none; padding: 0; font: inherit; font-size: var(--text-xs); color: var(--accent); cursor: pointer; }
.cv-link:focus-visible, .cv-next__btn:focus-visible, .cv-generate:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cv-disclosure { display: inline-flex; align-items: center; gap: 4px; margin-top: var(--s-2); color: var(--text-secondary); }
.cv-disclosure__chev { display: inline-flex; width: 12px; height: 12px; transition: transform var(--motion, 0.15s); }
.cv-disclosure[aria-expanded="true"] .cv-disclosure__chev { transform: rotate(90deg); }
.cv-stash-strip { margin-top: var(--s-2); }
.cv-stash-strip__chips { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 4px; }
.cv-stash-strip__chip { display: block; width: 12px; height: 12px; border-radius: 2px; }
.cv-quickadd { margin-top: var(--s-3); }
.cv-quickadd__row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.cv-quickadd__swatch { display: block; width: 20px; height: 20px; border-radius: var(--radius-sm); }
.cv-variations { margin-top: var(--s-3); padding-top: var(--s-2); border-top: 1px solid var(--line); }
.cv-variations__row { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.cv-gallery { margin-top: var(--s-2); display: flex; flex-direction: column; align-items: center; gap: var(--s-2); }
.cv-gallery__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; }
.cv-gallery__slot { display: flex; flex-direction: column; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-secondary); overflow: hidden; cursor: pointer; font: inherit; }
.cv-gallery__slot:disabled { cursor: default; }
.cv-gallery__slot img { width: 100%; display: block; image-rendering: pixelated; }
.cv-gallery__cap { padding: 3px 6px; font-size: var(--text-xs); color: var(--text-secondary); text-align: left; }
.cv-gallery__wait { height: 60px; display: flex; align-items: center; justify-content: center; font-size: var(--text-xs); color: var(--text-tertiary); }
.cv-history__row { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; margin-top: 4px; }
.cv-history__item { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; cursor: pointer; font: inherit; font-size: var(--text-xs); color: var(--text-tertiary); }
.cv-history__item img, .cv-history__blank { display: block; width: 32px; height: 32px; object-fit: cover; image-rendering: pixelated; background: var(--surface-tertiary); }
.cv-sub__head { display: flex; align-items: center; gap: 4px; margin-top: var(--s-3); }
.cv-tidied { margin-top: var(--s-2); }
.cv-tidied .cs-seltools__btn { margin-top: 6px; }
.cv-stats { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 4px; margin: 0; font-size: var(--text-sm); }
.cv-stats dt { color: var(--text-tertiary); }
.cv-stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.cv-next { padding: 12px; border-top: 1px solid var(--border); }
.cv-next__btn { width: 100%; display: inline-flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 12px; font: inherit; font-size: var(--text-sm); font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); border: 1px solid var(--accent-border, var(--accent)); border-radius: var(--radius-md); cursor: pointer; }
.cv-next__btn svg { width: 16px; height: 16px; }
@media (hover: hover) { .cv-next__btn:hover { background: var(--accent-light); } }
.cv-footer { flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.cv-footer__summary { margin: 0; font-size: var(--text-xs); line-height: 1.4; color: var(--text-secondary); }
.cv-footer__state { margin: 0; font-size: var(--text-xs); line-height: 1.4; color: var(--text-tertiary); }
.cv-footer__empty { text-align: center; }
.cv-generate { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; font: inherit; font-size: var(--text-md); font-weight: 600; color: var(--surface); background: var(--accent); border: none; border-radius: var(--radius-md); cursor: pointer; }
.cv-generate--quiet { color: var(--text-primary); background: var(--surface-tertiary); }
.cv-generate:disabled { cursor: wait; color: var(--surface); background: var(--text-tertiary); }
@media (hover: hover) { .cv-generate:not(:disabled):not(.cv-generate--quiet):hover { background: var(--accent-hover); } }
@media (max-width: 899px) {
  /* In the bottom drawer the whole panel scrolls; Generate stays at its foot. */
  .cv-footer { position: sticky; bottom: 0; z-index: 11; }
}

/* ── Convert preview (creator-main.js ConvertPreview) ────────────────────── */
.cvp { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: var(--s-2); }
.cvp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.cvp-head__title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cvp-title { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: var(--text-md); font-weight: 600; color: var(--text-primary); }
.cvp-title--card { padding: 8px 12px 6px; font-size: var(--text-sm); }
.cvp-spinner { display: inline-flex; width: 12px; height: 12px; color: var(--text-secondary); }
.cvp-size { font-size: var(--text-xs); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.cvp-views .lp-seg { font-size: var(--text-xs); padding: 4px 10px; min-height: 30px; white-space: nowrap; }
@media (pointer: coarse) { .cvp-views .lp-seg { min-height: 44px; } }
.cvp-note { display: flex; align-items: flex-start; gap: 6px; padding: 6px 10px; border-radius: var(--radius-md); font-size: var(--text-xs); line-height: 1.45; color: var(--text-primary); background: var(--surface-secondary); border: 1px solid var(--line); }
.cvp-note--warn { background: var(--warning-soft); }
.cvp-note--stale { background: var(--accent-soft); border-color: var(--accent-border, var(--line)); }
.cvp-note__icon { display: inline-flex; width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }
.cvp-note__icon svg { width: 14px; height: 14px; }
.cvp-change { margin: 0; font-size: var(--text-xs); line-height: 1.45; color: var(--text-secondary); }
.cvp-change strong { color: var(--text-primary); font-weight: 600; }
.cvp-body { position: relative; }
.cvp-box { position: relative; width: 100%; overflow: hidden; border-radius: var(--radius-md); border: 1px solid var(--line); }
.cvp-flat { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; image-rendering: pixelated; }
.cvp-overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; image-rendering: pixelated; pointer-events: none; }
.cvp-stitched { border-radius: var(--radius-md); border: 1px solid var(--line); overflow: hidden; background: var(--surface-secondary); }
.cvp-stitched__inner { position: relative; width: max-content; }
.cvp-stitched__canvas { display: block; }
.cvp-stitched--close { overflow: auto; max-height: 70vh; }
.cvp-wait { padding: 40px 16px; text-align: center; font-size: var(--text-sm); color: var(--text-secondary); }
.cvp-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.cvp-tools .cs-seltools__btn svg { width: 14px; height: 14px; }
.cvp-caption { margin: 0; font-size: var(--text-xs); color: var(--text-tertiary); line-height: 1.4; }

/* Dark theme: the legacy html.pref-dark button rule (!important) paints every
   button grey, which hid the chosen option in segmented choices, the chosen
   Creator panel tab, pressed tool buttons, Generate and Next, and the
   colour of swatch buttons. The doubled classes out-rank its :not() chain. */
html.pref-dark button.lp-seg.lp-seg.lp-seg--on.lp-seg--on { background: var(--accent) !important; color: var(--text-on-accent) !important; border-color: var(--border) !important; }
html.pref-dark button.creator-sidebar-tab.creator-sidebar-tab[aria-selected="true"] { background: var(--accent) !important; color: var(--text-on-accent) !important; border-color: var(--accent) !important; }
html.pref-dark button.cs-seltools__btn.cs-seltools__btn.cs-seltools__btn--on { background: var(--accent-soft) !important; color: var(--accent-ink) !important; border-color: var(--accent) !important; }
html.pref-dark button.cv-generate.cv-generate.cv-generate:not(.cv-generate--quiet):not(:disabled) { background: var(--accent) !important; color: var(--text-on-accent) !important; border-color: var(--accent) !important; }
html.pref-dark button.cv-next__btn.cv-next__btn.cv-next__btn { background: var(--accent-soft) !important; color: var(--accent-ink) !important; border-color: var(--accent) !important; }
html.pref-dark button.cv-bgpick__swatch.cv-bgpick__swatch.cv-bgpick__swatch,
html.pref-dark button.fabric-block__swatch.fabric-block__swatch.fabric-block__swatch { background: var(--swatch, var(--surface-tertiary)) !important; }

/* Convert's middle column shares the settings section type and spacing. */
.cvp-source { flex: 0 0 auto; width: min(30%, 220px); min-width: 0; }
.cvp-source__controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; border-top: 1px solid var(--line); }
.cvp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.cv-estimates { color: var(--text-primary); font-size: var(--text-sm); }
.cv-thread-list { display: flex; flex-direction: column; max-height: 240px; overflow-y: auto; }
.cv-thread { display: flex; align-items: center; gap: 8px; padding: 8px; min-height: 44px; border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--surface); color: var(--text-primary); font: inherit; text-align: left; cursor: pointer; }
.cv-thread[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.cv-thread__swatch { width: 16px; height: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); flex-shrink: 0; }
.cv-thread__name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cv-pin { padding: 12px; min-width: 0; }
.cv-pin__pictures { display: flex; gap: 12px; overflow: hidden; }
.cv-pin figure { flex: 1; min-width: 0; margin: 0; }
.cv-pin figcaption { font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: 8px; }
.cv-pin canvas { max-width: 100%; height: auto !important; }
@media (max-width: 899px) {
  .cvp-layout { flex-direction: column; padding: 8px !important; gap: 8px !important; overflow-y: auto; }
  .cvp-source { width: 100%; }
  .cvp-source__card { display: flex; align-items: center; gap: 8px; padding: 8px; flex-wrap: wrap; }
  .cvp-source__card > .cvp-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .cvp-source__card > img { width: 48px !important; height: 48px; object-fit: contain; }
  .cvp-source__controls { flex: 1; border: 0; padding: 0; }
  .cvp-source__controls button { min-height: 44px; }
  .cvp-main { flex: 0 0 auto; overflow: visible; }
  .cv-pin__pictures[data-choice="current"] [data-version="pinned"],
  .cv-pin__pictures[data-choice="pinned"] [data-version="current"] { display: none; }
}

@media (min-width: 900px) { .cv-pin__switch { display: none; } }

/* Physical blend preview uses the same renderer as the stitch review. */
.blend-recipe-preview { display: flex; gap: var(--s-2); align-items: center; margin-block: var(--s-2); color: var(--text-secondary); font-size: var(--text-xs); }
.blend-recipe-preview__swatch { width: 32px; height: 32px; flex-shrink: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.blend-recipe-preview canvas { width: 48px; height: 48px; flex-shrink: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.blend-component-slots > div { width: 100%; box-sizing: border-box; }
.blend-component-slots button { display: inline-flex; margin-left: auto; min-width: 32px; min-height: 32px; align-items: center; justify-content: center; }
.blend-component-slots button svg { width: 16px; height: 16px; }

/* Compact colour list (Tracker): one slim line per colour; the selected colour's card holds the buttons.
   The choice is kept per device (cs_trackerCompactColours). */
.ppal-sort-row{align-items:center;gap:6px;}
.ppal-sort-group{display:flex;gap:4px;flex:1;min-width:0;}
.ppal-size-toggle{display:flex;flex-shrink:0;border:1px solid var(--border);border-radius:var(--radius-sm);overflow:hidden;}
.ppal-size-btn{display:inline-flex;align-items:center;justify-content:center;width:30px;min-height:24px;padding:0;border:0;background:var(--surface-secondary);color:var(--text-secondary);cursor:pointer;font-family:inherit;}
.ppal-size-btn+.ppal-size-btn{border-left:1px solid var(--border);}
@media (hover: hover){.ppal-size-btn:hover{background:var(--surface-tertiary);}}
.ppal-size-btn--on,.ppal-size-btn--on:hover{background:var(--accent-light);color:var(--accent-text);}
.ppal-wrap--compact .ppal-header{padding:8px 12px;display:flex;flex-wrap:wrap;align-items:center;gap:6px;}
/* Compact: title, %, session chip, pin and close share one line, with the progress bar under it. */
.ppal-wrap--compact .ppal-header-top,.ppal-wrap--compact .ppal-header-stats{display:contents;}
.ppal-wrap--compact .ppal-title{order:1;}
.ppal-wrap--compact .ppal-pct{order:2;}
.ppal-wrap--compact .ppal-session-chip{order:3;margin-left:0;}
.ppal-wrap--compact .ppal-pin-btn{order:4;}
.ppal-wrap--compact .ppal-close{order:5;}
.ppal-wrap--compact .ppal-progress-bar{order:6;flex-basis:100%;margin-bottom:0;}
.ppal-row-bar .ppal-tile-bar-fill{display:block;}
.ppal-active-tile--compact{flex-direction:column;align-items:stretch;gap:6px;padding:6px 12px;min-height:0;}
.ppal-active-top{display:flex;align-items:center;gap:10px;}
.ppal-active-tile--compact .ppal-active-swatch-wrap{width:36px;height:36px;}
.ppal-active-tile--compact .ppal-active-swatch{width:32px;height:32px;}
.ppal-active-tile--compact .ppal-tile-actions{justify-content:flex-start;margin-left:46px;}
.ppal-tile--compact{align-items:center;}
.ppal-tile--compact .ppal-tile-swatch{width:24px;min-width:24px;height:24px;margin-left:12px;border:1px solid var(--border);border-radius:5px;}
.ppal-row-select{position:relative;flex:1;min-width:0;display:flex;align-items:center;gap:8px;min-height:32px;padding:0 12px 0 10px;}
.ppal-tile--compact .ppal-tile-text{flex-direction:row;align-items:baseline;gap:6px;}
.ppal-tile--compact .ppal-tile-id{flex-shrink:0;font-size:12px;white-space:nowrap;overflow-wrap:normal;}
.ppal-tile--compact .ppal-tile-name{flex:1;min-width:0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.ppal-tile--compact .ppal-tile-pct{font-size:11px;min-width:3em;text-align:right;}
.ppal-row-done{display:inline-flex;justify-content:flex-end;min-width:3em;color:var(--success);}
.ppal-row-bar{position:absolute;left:10px;right:12px;bottom:3px;height:2px;border-radius:1px;background:var(--surface-tertiary);overflow:hidden;}
@media (pointer:coarse){
  .ppal-size-btn{width:44px;min-height:44px;}
  .ppal-tile--compact .ppal-tile-swatch{width:32px;min-width:32px;height:32px;}
  .ppal-row-select{min-height:44px;}
}
