/* ==========================================================================
   1. TOKENS — interface only (canvas colors live in js/config.js)
      Source: STYLE-GUIDE.md §1. Single dark theme, single accent.
   ========================================================================== */
:root{
  /* Surfaces */
  --page:#050505; --panel:#111111; --input:#1a1a1a; --stage:#050505;
  /* Text */
  --text:#f2f2f2; --text2:rgba(255,255,255,.52); --text-disabled:rgba(255,255,255,.28);
  /* Borders */
  --border:rgba(255,255,255,.08); --border-strong:rgba(255,255,255,.16);
  /* Interaction */
  --hover:rgba(255,255,255,.05); --active:rgba(255,255,255,.10); --focus-ring:rgba(255,255,255,.70);
  /* Accent */
  --accent:#9890fd; --on-accent:#0a0a0a;
  /* Layout */
  --edge:32px; --edge-x:40px; --header-h:64px; --sidebar-w:320px; --textcard-w:280px; --ui-gap:12px;
  /* Radius */
  --radius-sm:4px; --radius:8px; --radius-lg:12px;
  /* Type */
  --font-sans:'Inter',system-ui,-apple-system,'Segoe UI',sans-serif;
  --shadow-popover:0 8px 32px rgba(0,0,0,.5);

  color-scheme:dark;
  font-family:var(--font-sans);
  font-size:14px; line-height:1.4;
  -webkit-font-smoothing:antialiased;
}

*,*::before,*::after{box-sizing:border-box}
html,body{height:100%;margin:0}
body{background:var(--page);color:var(--text);overflow:hidden}
button,input,textarea,select{font:inherit;color:inherit}
button{user-select:none;cursor:pointer}
h2,h3,p{margin:0}
[hidden]{display:none !important}
:focus-visible{outline:2px solid var(--focus-ring);outline-offset:2px}
.tnum{font-variant-numeric:tabular-nums}
/* Read by screen readers and search engines, not shown (the page intro in index.html) */
.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}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{transition:none !important;animation:none !important}}

/* ==========================================================================
   2. LAYOUT — the main IS the stage; header and sidebar float on top
   ========================================================================== */
.app{height:100dvh}
.workspace{
  position:relative;height:100%;overflow:hidden;display:flex;flex-direction:column;
  /* reserve room for the floating pieces */
  padding:136px 372px 32px 40px;
}
.board-grid{
  background-color:var(--stage);
  background-image:
    linear-gradient(rgba(255,255,255,.05) 1px,transparent 1px),
    linear-gradient(90deg,rgba(255,255,255,.05) 1px,transparent 1px);
  background-size:24px 24px;
  background-position:50% center;
}

/* ==========================================================================
   3. HEADER
   ========================================================================== */
.float-header{
  position:absolute;top:40px;left:40px;right:40px;z-index:20;
  height:var(--header-h);display:flex;align-items:center;justify-content:space-between;gap:8px;
  padding:16px 16px 16px 20px;border-radius:var(--radius-lg);background:var(--panel);
}
.header-left{display:flex;align-items:center;gap:16px;min-width:0}
.brand{display:flex;align-items:center;gap:8px;color:var(--text);flex-shrink:0}
.brand-name{font-weight:600;text-transform:uppercase;letter-spacing:.02em;white-space:nowrap}
.sep{width:1px;height:20px;margin:0 8px;background:var(--border-strong);flex-shrink:0}
.crumb{display:flex;align-items:center;gap:8px;min-width:0}
.crumb-label{color:var(--text2)}
.board-name{
  min-width:0;max-width:280px;border:1px solid transparent;border-radius:var(--radius);
  background:transparent;padding:4px 12px;outline:none;transition:background-color 100ms ease,border-color 100ms ease;
}
.board-name:hover{background:rgba(255,255,255,.04)}
.board-name:focus,.board-name:focus-visible{border-color:rgba(255,255,255,.1);background:rgba(255,255,255,.06);outline:none}
.header-center{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}
.header-right{display:flex;align-items:center;gap:8px}
.chev{color:var(--text2);flex-shrink:0}

/* ==========================================================================
   4. BUTTONS
   ========================================================================== */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;white-space:nowrap;
  height:32px;padding:0 12px;border-radius:var(--radius);border:1px solid var(--border);background:transparent;color:var(--text);
  transition:background-color 120ms ease,border-color 120ms ease;
}
.btn:hover:not(:disabled){border-color:var(--border-strong);background:var(--hover)}
.btn:disabled{color:var(--text-disabled)}
.btn.on,.btn[aria-expanded="true"]{border-color:var(--border-strong);background:var(--input)}
.btn.icon{width:32px;padding:0}
#anim-toggle .i-play{display:none}
#anim-toggle.paused .i-play{display:block}
#anim-toggle.paused .i-pause{display:none}

.export-btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;border-radius:var(--radius);
  height:48px;padding:0 16px;background:var(--accent);color:var(--on-accent);
  font-size:14px;font-weight:650;letter-spacing:.01em;
}
.export-btn:hover{filter:brightness(1.06)}
.export-btn:active{filter:brightness(.96)}
.export-btn.header-export{height:32px;border-radius:var(--radius);font-size:14px;padding:0 16px;gap:8px}

/* ==========================================================================
   5. CANVAS — rendered at real size, shown scaled to fit (js/ui.js → fitCanvas)
   ========================================================================== */
.board{position:relative;flex:1;min-height:0}
.canvas-frame{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}
.canvas-frame canvas{display:block;border-radius:var(--radius-lg);box-shadow:0 24px 48px -12px rgba(0,0,0,.6);background:#000}
.canvas-info{
  position:absolute;left:50%;top:100%;margin-top:12px;transform:translateX(-50%);
  white-space:nowrap;font-size:12px;color:var(--text2);
}

.history-controls{position:absolute;bottom:100%;right:0;margin-bottom:12px;display:flex;align-items:center;gap:8px}
.history-btn{
  display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;
  border:1px solid transparent;border-radius:8px;background:var(--panel);color:var(--text);cursor:pointer;
  transition:background 120ms ease,border-color 120ms ease;
}
.history-btn:hover{border-color:var(--border-strong)}
.history-btn:disabled{color:var(--text-disabled);cursor:default}

/* ==========================================================================
   6. SIDEBAR — stack of floating cards
   ========================================================================== */
.float-stack{
  position:absolute;right:40px;z-index:10;width:var(--sidebar-w);
  top:136px;bottom:32px;
  display:flex;flex-direction:column;justify-content:center;gap:var(--ui-gap);
}
.float-card{border-radius:var(--radius-lg);border:1px solid var(--border);background:var(--panel)}
.tabs-card{flex-shrink:0;overflow:hidden}

.tabs{display:flex;border-radius:11px;overflow:hidden}
.tab{
  position:relative;flex:1;display:inline-flex;align-items:center;justify-content:center;gap:8px;
  border:0;background:transparent;padding:16px 0;color:var(--text2);transition:color 120ms ease;
}
.tab:hover,.tab.active{color:var(--text)}
.tab.active::after{content:'';position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--accent)}
.step{
  display:inline-grid;place-items:center;width:20px;height:20px;border-radius:50%;
  font-size:12px;font-weight:600;background:rgba(255,255,255,.1);color:var(--text2);
}
.tab.active .step{background:var(--accent);color:var(--on-accent)}

.panel-card{display:flex;flex-direction:column;flex:0 1 500px;min-height:0;overflow:hidden}
.panel-head{flex-shrink:0;border-bottom:1px solid var(--border);padding:12px 16px}
.panel-title{font-size:14px;font-weight:600;line-height:1.25}
.panel-sub{font-size:12px;color:var(--text2);margin-top:2px}
.panel-body{
  flex:1;min-height:0;overflow-y:auto;padding:24px 16px 16px;margin:0;
  scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.14) transparent;
}
.tab-panel{display:flex;flex-direction:column;gap:16px}
#strip-slot-text,#strip-slot-layout,#lead-slot{display:contents}   /* where the line sliders sit, per look */

.field{display:flex;flex-direction:column;gap:8px;min-width:0}
.label{display:flex;align-items:baseline;justify-content:space-between;gap:8px;font-size:12px;font-weight:400;color:var(--text2)}
.label label{cursor:default}
.label output,.label .meta{color:var(--text-disabled);font-variant-numeric:tabular-nums}

/* Sidebar footer links */
.float-links{display:flex;gap:8px;flex-shrink:0}
.float-link{
  flex:1;display:inline-flex;align-items:center;justify-content:center;gap:4px;height:36px;padding:0 4px;
  font-size:11px;border-radius:12px;border:1px solid transparent;background:var(--panel);color:var(--text);
}
.float-link:hover{border-color:var(--border-strong)}

/* Checklist */
.checklist{position:absolute;bottom:32px;left:40px;width:240px;z-index:10;padding:4px;border-radius:12px;border:1px solid var(--border);background:var(--panel)}
.checklist-list{padding:8px;margin-bottom:8px;display:flex;flex-direction:column;gap:2px;font-size:12px}
.checklist-list > *{padding:8px;border-radius:8px}

/* Toast */
.toast{position:fixed;bottom:32px;z-index:50;padding:8px 8px 8px 16px;border-radius:12px;border:1px solid var(--border-strong);background:var(--panel);box-shadow:0 10px 30px rgba(0,0,0,.5);font-size:14px}

/* Text card — sits on the canvas' top-left edge, mirroring the history controls; the header is the expander */
/* Canvas tools: Library + Text card on the canvas' top-left edge */
.canvas-tools{position:absolute;left:0;bottom:100%;margin-bottom:12px;z-index:10;display:flex;align-items:flex-start;gap:8px}
.tool-btn{
  display:flex;align-items:center;gap:8px;height:32px;padding:0 12px;border:0;border-radius:var(--radius-lg);
  background:var(--panel);color:var(--text);cursor:pointer;font:inherit;font-size:13px;font-weight:500;
}
.tool-btn:hover{background:#181818}
.tool-btn[aria-expanded="true"]{box-shadow:inset 0 0 0 1px var(--border-strong)}
.text-card{
  position:relative;
  width:max-content;border-radius:var(--radius-lg);background:var(--panel);
}
.text-head{
  display:flex;align-items:center;gap:8px;height:32px;padding:0 12px;border:0;background:transparent;color:var(--text);
  border-radius:var(--radius-lg);cursor:pointer;font:inherit;font-size:13px;font-weight:500;
}
.text-head:hover{background:rgba(255,255,255,.04)}
.text-count{margin:0 0 8px 4px;font-size:12px;color:var(--text2)}
.text-head .chev{color:var(--text2);transition:transform 160ms ease}
.text-head[aria-expanded="true"] .chev{transform:rotate(180deg)}
.text-body{position:absolute;left:0;top:100%;width:var(--textcard-w);margin-top:8px;padding:12px;
  border-radius:var(--radius-lg);background:var(--panel);
  max-height:calc(100dvh - 300px);overflow-y:auto;overscroll-behavior:contain}   /* long content (face look) scrolls inside the card */
.text-body[hidden]{display:none}
.text-body .text-field{display:block;field-sizing:content;resize:none;min-height:7.5rem;max-height:50dvh}

/* Text field */
.text-field{
  width:100%;border-radius:var(--radius);border:1px solid rgba(255,255,255,.1);background:rgba(255,255,255,.03);
  padding:8px 12px;font-size:14px;line-height:1.5;outline:none;resize:vertical;min-height:7.5rem;
  text-transform:uppercase;transition:background-color 100ms ease;
}
.text-field:hover{background:rgba(255,255,255,.04)}
.text-field:focus{background:rgba(255,255,255,.06);outline:none}
.text-field::placeholder{color:var(--text-disabled)}

/* Dropdown trigger inside the panel: full-width */
.dd-trigger{width:100%;justify-content:space-between;height:32px;border-radius:var(--radius);background:var(--input)}

/* Option grid (radio / checkbox styled as segmented options) */
.option-grid{display:grid;gap:8px}
.option-grid.cols-2{grid-template-columns:1fr 1fr}
.opt{
  position:relative;display:flex;align-items:center;justify-content:center;gap:8px;height:40px;
  border-radius:var(--radius);border:1px solid var(--border);background:var(--input);color:var(--text2);cursor:pointer;
  transition:color 120ms ease,border-color 120ms ease,background-color 120ms ease;
}
.opt:hover{color:var(--text)}
.opt input{position:absolute;opacity:0;width:1px;height:1px;margin:0;pointer-events:none}
.opt:has(input:checked){border-color:var(--accent);background:var(--panel);color:var(--text)}
/* Face look: with one person's piece picked, the part pickers show (and change) that person's choice only */
.person-edit .opt:has(input:checked):not(.person-on){border-color:var(--border);background:var(--input);color:var(--text2)}
.person-edit .opt.person-on{border-color:var(--accent);background:var(--panel);color:var(--text)}
.opt:has(input:focus-visible){outline:2px solid var(--focus-ring);outline-offset:2px}
.opt em{font-style:italic}
.swatch{width:12px;height:12px;border-radius:50%;box-shadow:0 0 0 1px var(--border-strong)}

/* Slider: 2px track filled up to --p, 12px white thumb */
input[type=range]{appearance:none;-webkit-appearance:none;width:100%;height:16px;margin:0;background:transparent;cursor:pointer}
input[type=range]::-webkit-slider-runnable-track{
  height:2px;border-radius:2px;
  background:linear-gradient(to right,var(--text) var(--p,0%),var(--border-strong) var(--p,0%));
}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;margin-top:-5px;border:0;border-radius:50%;background:#fff}
input[type=range]::-moz-range-track{height:2px;border-radius:2px;background:var(--border-strong)}
input[type=range]::-moz-range-progress{height:2px;border-radius:2px;background:var(--text)}
input[type=range]::-moz-range-thumb{width:12px;height:12px;border:0;border-radius:50%;background:#fff}

/* ==========================================================================
   7. DROPDOWN MENU (portal, fixed)
   ========================================================================== */
.menu{
  position:fixed;z-index:60;min-width:240px;padding:8px;border-radius:var(--radius-lg);
  border:1px solid var(--border-strong);background:var(--panel);box-shadow:var(--shadow-popover);
  max-height:min(416px,calc(100dvh - 16px));overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
  animation:menu-in 180ms cubic-bezier(.16,1,.3,1) both;
}
.menu[data-closing]{animation:menu-out 120ms ease-in both}
.menu-opt{
  position:relative;display:flex;align-items:center;justify-content:space-between;gap:16px;width:100%;height:32px;
  padding:0 12px;border:0;border-radius:var(--radius);background:none;color:var(--text);text-align:left;
}
.menu-opt:hover,.menu-opt:focus-visible{background:var(--hover);outline:none}
/* Selected: input surface + accent bar on the left */
.menu-opt[aria-selected="true"]{background:var(--input)}
.menu-opt[aria-selected="true"]::before{
  content:'';position:absolute;left:0;top:8px;bottom:8px;width:2px;border-radius:2px;background:var(--accent);
}
.menu-opt .hint{color:var(--text2);font-variant-numeric:tabular-nums}
@keyframes menu-in{from{opacity:0;transform:translateY(8px) scale(.97)}to{opacity:1;transform:none}}
@keyframes menu-out{from{opacity:1;transform:none}to{opacity:0;transform:translateY(4px) scale(.98)}}

/* ==========================================================================
   7c. EXPORT POPOVER — anchored under the header Export button (js/export.js)
   ========================================================================== */
.export-pop{
  position:fixed;z-index:60;width:304px;display:flex;flex-direction:column;gap:12px;padding:12px;
  border-radius:var(--radius-lg);border:1px solid var(--border-strong);background:var(--panel);box-shadow:var(--shadow-popover);
  animation:menu-in 180ms cubic-bezier(.16,1,.3,1) both;
}
.option-grid.cols-3{grid-template-columns:repeat(3,1fr)}
.option-grid.cols-5{grid-template-columns:repeat(5,1fr);gap:6px}
.option-grid.cols-6{grid-template-columns:repeat(6,1fr);gap:6px}
.option-grid.cols-7{grid-template-columns:repeat(7,1fr);gap:6px}
.option-grid.cols-8{grid-template-columns:repeat(8,1fr);gap:6px}
.option-grid.square .opt{aspect-ratio:1;height:auto;min-height:0;padding:0}
.swatch-none{position:relative;background:#fff;overflow:hidden}
.swatch-none::after{content:"";position:absolute;left:50%;top:-2px;bottom:-2px;width:1.5px;background:#e8343a;transform:translateX(-50%) rotate(45deg)}
.option-grid.cols-4{grid-template-columns:repeat(4,1fr)}
.opt:has(input:disabled){color:var(--text-disabled);cursor:not-allowed}
/* Flowers: the flower library, a card per kind with its thumbnail */
.fl-library{gap:6px}
.fl-res{flex-direction:column;height:auto;padding:5px 5px 6px;gap:5px;font-size:11px;line-height:1.2;text-align:center}
.fl-res canvas{display:block;width:100%;aspect-ratio:4/3;border-radius:calc(var(--radius) - 2px);transition:opacity 120ms ease}
.fl-res:not(:has(input:checked)) canvas{opacity:.3}
.export-row{display:flex;align-items:center;gap:8px}
.export-row .option-grid{flex:1}
.export-size{font-size:12px;color:var(--text2);white-space:nowrap}
.export-go{width:100%;position:relative;overflow:hidden;isolation:isolate}
.export-share{width:100%;background:var(--input);color:var(--text);box-shadow:inset 0 0 0 1px var(--border-strong)}
.export-share[hidden]{display:none}
.export-go.recording{background:var(--input);color:var(--text);box-shadow:inset 0 0 0 1px var(--border-strong)}
.export-go.recording::before{
  content:'';position:absolute;inset:0;z-index:-1;width:var(--progress,0%);
  background:rgba(152,144,253,.22);transition:width 100ms linear;
}
.export-hint{font-size:12px;color:var(--text2)}
.export-hint.warn{color:#f2c230}
.header-export.recording::after{
  content:'';width:8px;height:8px;border-radius:50%;background:#e8451e;
  animation:rec-blink 1s steps(2,start) infinite;
}
@keyframes rec-blink{to{visibility:hidden}}

/* ==========================================================================
   7d. LIBRARY POPOVER — presets grid under the header Library button (js/library.js)
   ========================================================================== */
.library-pop{
  position:fixed;z-index:60;width:min(536px,calc(100vw - 16px));display:flex;flex-direction:column;gap:12px;padding:12px;
  border-radius:var(--radius-lg);border:1px solid var(--border-strong);background:var(--panel);box-shadow:var(--shadow-popover);
  max-height:calc(100dvh - 96px);overflow-y:auto;overscroll-behavior:contain;
  animation:menu-in 180ms cubic-bezier(.16,1,.3,1) both;
}
.library-head{display:flex;align-items:baseline;justify-content:space-between;padding:4px 4px 0}
.library-title{font-size:13px;font-weight:600;margin:0}
.library-meta{font-size:12px;color:var(--text2)}
.library-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:12px}
.lib-card{display:flex;flex-direction:column;gap:2px;padding:0;border:0;background:none;color:var(--text);text-align:left}
.lib-thumb{display:block;width:100%;aspect-ratio:16/10;object-fit:cover;border-radius:var(--radius);margin-bottom:6px;
  box-shadow:0 0 0 1px var(--border);transition:box-shadow 120ms ease,transform 160ms cubic-bezier(.16,1,.3,1)}
.lib-card:hover .lib-thumb{box-shadow:0 0 0 1px var(--border-strong);transform:translateY(-1px)}
.lib-card:focus-visible{outline:none}
.lib-card:focus-visible .lib-thumb{box-shadow:0 0 0 2px var(--focus-ring)}
.lib-card[aria-selected="true"] .lib-thumb{box-shadow:0 0 0 2px var(--accent)}
.lib-name{font-size:12px;font-weight:500;padding:0 2px}
.lib-hint{font-size:11px;color:var(--text2);padding:0 2px}
.library-foot{margin:0;padding:8px 4px 0;border-top:1px solid var(--border);font-size:12px;color:var(--text2);text-align:center}
/* Look-specific controls (data-look): only shown in their own look */
[data-look][hidden]{display:none !important}
.field-group{display:flex;flex-direction:column;gap:16px;border-top:1px solid var(--border);margin-top:8px;padding-top:24px}
.field-group.opens-tab{border-top:0;margin-top:0;padding-top:0}
.group-title.group-rule{margin:8px 0 -4px;padding-top:24px;border-top:1px solid var(--border)}
.group-title{margin:0 0 -4px;font-size:12px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--text2)}
.text-field.single{min-height:0;resize:none;padding:6px 10px;font-size:13px}
.kit-link{margin:4px 0 0;font-size:12px}
.footer-field{margin-top:12px}
.footer-field .text-count{display:block}
.text-body .footer-field .text-field{min-height:0;max-height:none}
.text-sep{border:0;border-top:1px solid var(--border);margin:16px 0}
.text-sep[hidden]{display:none}
.face-footer{margin-top:12px}
.face-behind{margin-bottom:12px}
.face-textstyle{margin-top:12px}
.face-text{display:flex;flex-direction:column;gap:8px}
.face-text .text-count{margin-bottom:0}
.face-text .label{margin:4px 0 0 4px}
.text-body .face-text .text-field{min-height:0;max-height:none}
.kit-link a{color:var(--text2);text-underline-offset:3px}
.kit-link a:hover{color:var(--text)}

/* ==========================================================================
   8. RESPONSIVE (< 1024px): stacked column
   ========================================================================== */
@media (max-width:1023px){
  .app{height:auto;min-height:100dvh}
  body{overflow:auto}
  .workspace{padding:12px;gap:12px;height:auto;min-height:100dvh}
  .float-header{position:static;height:auto;min-height:52px;flex-wrap:wrap;gap:8px;padding:8px 12px 8px 16px}
  .header-center{position:static;transform:none;order:3;width:100%}
  .header-center .btn{width:100%}
  .header-right{order:2}
  .board{flex:none;height:min(60dvh,560px);z-index:15}   /* the Text card's body hangs below the board — keep it above the stacked sidebar */
  .text-card,.text-collapsed .text-card{width:auto}
  .float-stack{position:static;width:100%;height:auto}
  .checklist,.float-links{display:none}
  .panel-card{flex:none;height:min(46dvh,416px)}
  .btn,.text-field{min-height:40px}
  .export-btn.header-export{height:36px}
}
@media (max-width:767px){ .crumb-label{display:none} }
@media (max-width:639px){
  .brand-name,.sep{display:none}
  #regen .btn-label{display:none}
  #regen{width:40px;padding:0}
}

.info-bar{flex-shrink:0;display:flex;width:100%;gap:8px}
.info-btn{flex:1 1 auto;min-width:0;display:inline-flex;align-items:center;justify-content:center;gap:6px;height:36px;padding:0 8px;border-radius:var(--radius-lg);border:1px solid transparent;background:var(--panel);color:var(--text);font:inherit;font-size:11px;transition:background-color 120ms ease,border-color 120ms ease;font-weight:500;cursor:pointer;white-space:nowrap}
a.info-btn{text-decoration:none}
.info-btn svg{width:14px;height:14px;flex-shrink:0}
.info-btn:hover{border-color:var(--border-strong)}

/* Preview mode — hides every control, leaving only the canvas and the Preview button to exit */
body.previewing .float-stack,body.previewing .history-controls,body.previewing .canvas-tools,body.previewing .canvas-info,
body.previewing .header-left,body.previewing #regen,body.previewing #export{display:none}

/* Preview mode — the canvas takes the whole stage; only the pause/exit buttons remain, floating top-right */
body.previewing .workspace{padding:72px 40px 40px}
body.previewing .header-center{display:none}
body.previewing .float-header{left:auto;height:auto;padding:0;background:transparent;justify-content:flex-end}

/* ==========================================================================
   7d. HOW TO USE MODAL — centered, same surface as the export popover
   ========================================================================== */
.howto-backdrop{position:fixed;inset:0;z-index:70;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(0,0,0,.55);backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}
.howto-backdrop[hidden]{display:none}
.howto-pop{
  position:relative;width:min(415px,100%);max-height:calc(100vh - 32px);overflow:auto;display:flex;flex-direction:column;gap:20px;padding:24px;
  border-radius:var(--radius-lg);border:1px solid var(--border-strong);background:var(--panel);box-shadow:var(--shadow-popover);
  animation:menu-in 180ms cubic-bezier(.16,1,.3,1) both;
}
.howto-x{position:absolute;top:16px;right:16px;width:24px;height:24px;display:grid;place-items:center;border:0;padding:0;background:none;box-shadow:none;color:var(--text2);cursor:pointer}
.howto-x:hover{color:var(--text)}
.howto-x:focus:not(:focus-visible){outline:none}
.howto-pop:focus{outline:none}
.howto-head h2{font-size:15px;font-weight:600;margin:0 0 4px}
.howto-head p{font-size:12px;color:var(--text2);margin:0}
.howto-steps{list-style:none;margin:0;padding:0}
.howto-steps li{position:relative;display:flex;gap:16px;align-items:flex-start;padding-bottom:20px;
  animation:howto-row 700ms cubic-bezier(.16,1,.3,1) calc(var(--i) * 120ms + 150ms) both}
.howto-steps li:last-child{padding-bottom:0}
/* guide line: dotted track + white line drawn over it */
.howto-steps li::before,.howto-steps li::after{content:"";position:absolute;left:12px;top:26px;bottom:0;width:1px}
.howto-steps li::before{background:repeating-linear-gradient(to bottom,rgba(255,255,255,.35) 0 4px,transparent 4px 8px)}
.howto-steps li::after{background:#fff;transform:scaleY(0);transform-origin:top;
  animation:howto-line 300ms linear calc(var(--i) * 670ms + 1270ms) forwards}
.howto-steps li:last-child::before,.howto-steps li:last-child::after{display:none}
.hstep{flex:none;position:relative;width:26px;height:26px;box-sizing:border-box;border-radius:50%;display:grid;place-items:center;
  font-size:12px;font-weight:600;color:var(--text-disabled);background:var(--panel);border:1px solid var(--border-strong);
  animation:howto-fill 400ms ease-out calc(var(--i) * 670ms + 1150ms) forwards}
.hstep svg{position:absolute;inset:-1px;width:26px;height:26px;transform:rotate(-90deg);pointer-events:none}
.hstep circle{fill:none;stroke:#fff;stroke-width:1.5;stroke-linecap:round;stroke-dasharray:77;stroke-dashoffset:77;opacity:0;
  animation:howto-ring 250ms ease-in-out calc(var(--i) * 670ms + 900ms) forwards}
.howto-steps h3{font-size:13px;font-weight:600;margin:0 0 2px;color:var(--text2);
  animation:howto-title 600ms ease calc(var(--i) * 670ms + 1150ms) forwards}
.howto-steps p{font-size:12px;line-height:1.5;color:var(--text2);margin:0}
@keyframes howto-row{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes howto-ring{0%{stroke-dashoffset:77;opacity:0}1%{opacity:1}100%{stroke-dashoffset:0;opacity:1}}
@keyframes howto-fill{to{background:#fff;border-color:#fff;color:#0a0a0a}}
@keyframes howto-title{to{color:var(--text)}}
@keyframes howto-line{to{transform:scaleY(1)}}
.howto-confetti{position:absolute;inset:0;pointer-events:none;overflow:hidden}
.howto-confetti i{position:absolute;border-radius:1px;opacity:0;
  animation:howto-confetti 1500ms cubic-bezier(.2,.8,.3,1) var(--d) forwards}
@keyframes howto-confetti{
  0%{opacity:1;transform:translate(0,0) rotate(0)}
  60%{opacity:1}
  100%{opacity:0;transform:translate(var(--x),calc(var(--y) + 160px)) rotate(var(--r))}}
@media (prefers-reduced-motion:reduce){
  .howto-steps li,.hstep,.hstep circle,.howto-steps h3,.howto-steps li::after{animation:none}
  .hstep{background:#fff;border-color:#fff;color:#0a0a0a}
  .hstep circle{display:none}
  .howto-steps li::after{transform:scaleY(1)}
  .howto-steps h3{color:var(--text)}
}

/* ==========================================================================
   FACE LOOK — photo button, part pickers drawn from the kit, palette chips
   ========================================================================== */
.face-btn{width:100%;justify-content:center;height:40px;border-radius:var(--radius);background:var(--input)}
.face-status{margin:8px 0 0 2px;font-size:12px;color:var(--text2)}
.paper-color{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:8px}
.color-field{
  display:flex;align-items:center;gap:8px;height:40px;padding:0 10px;border-radius:var(--radius);
  border:1px solid var(--border);background:var(--input);color:var(--text2);font-size:13px;cursor:pointer;
}
.color-field:hover{color:var(--text)}
.color-field:has(input:focus-visible){outline:2px solid var(--focus-ring);outline-offset:2px}
.color-field input{width:20px;height:20px;padding:0;border:0;border-radius:50%;background:none;cursor:pointer;flex:none}
.color-field input::-webkit-color-swatch-wrapper{padding:0}
.color-field input::-webkit-color-swatch{border:0;border-radius:50%;box-shadow:0 0 0 1px var(--border-strong)}
.color-field input::-moz-color-swatch{border:0;border-radius:50%}
.picker-btn{height:40px;background:var(--input)}
.picker-btn[aria-pressed="true"]{border-color:var(--accent);background:var(--panel)}
.face-grid{grid-template-columns:repeat(4,1fr)}
.face-tile{height:56px;padding:6px}
.face-tile svg{width:100%;height:100%}
.face-auto{font-size:12px}
.face-pal{width:28px;height:12px;border-radius:6px;box-shadow:0 0 0 1px var(--border-strong);
  background:linear-gradient(90deg,var(--a) 0 25%,var(--b) 0 50%,var(--c) 0 75%,var(--d) 0)}
.board.dropping{outline:2px dashed var(--accent);outline-offset:-12px}
.face-empty{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;
  pointer-events:none;color:#0b0b0c;font-size:14px;text-align:center}
.face-empty[hidden]{display:none}
.face-empty p{margin:0;font-weight:500}
.face-empty-btn{pointer-events:auto;height:40px;padding:0 18px;background:#0b0b0c;color:#f4ede4;border-color:#0b0b0c}
.face-empty-btn:hover:not(:disabled){background:#222;border-color:#222}
.face-empty-btn[hidden],.face-empty-hint[hidden]{display:none}
.face-empty-hint{font-size:12px;opacity:.6}
body.previewing .face-empty{display:none}
.face-sel{position:absolute;pointer-events:none;border:1.5px solid var(--accent);border-radius:2px;box-sizing:border-box}
.face-sel[hidden]{display:none}
.face-handle{position:absolute;width:12px;height:12px;margin:-6px;background:#fff;border:1.5px solid var(--accent);border-radius:3px;pointer-events:auto;touch-action:none}
.face-handle.nw{left:0;top:0;cursor:nwse-resize}.face-handle.se{left:100%;top:100%;cursor:nwse-resize}
.face-handle.ne{left:100%;top:0;cursor:nesw-resize}.face-handle.sw{left:0;top:100%;cursor:nesw-resize}
.face-handle.rot{left:50%;top:-22px;border-radius:50%;cursor:grab}
.face-handle.rot::after{content:"";position:absolute;left:50%;top:100%;width:1.5px;height:15px;margin-left:-.75px;background:var(--accent)}
.face-sel.scaling .face-handle.rot{cursor:grabbing}
.face-del{position:absolute;left:50%;top:100%;width:28px;height:28px;margin:12px 0 0 -14px;display:grid;place-items:center;padding:0;
  border:1.5px solid var(--accent);border-radius:50%;background:#fff;color:#0b0b0c;cursor:pointer;pointer-events:auto;touch-action:none;
  transform:rotate(calc(-1 * var(--rot, 0rad)))}   /* the frame turns with the piece; the bin stays upright */
.face-del:hover{background:#ffe1e1;color:#c0262d}
@media (pointer:coarse){.face-del{width:36px;height:36px;margin-left:-18px}}
body.previewing .face-sel{display:none}
#stage.draggable{cursor:grab;touch-action:none}
#stage.dragging{cursor:grabbing}
#stage.picking{cursor:crosshair}

/* Face look: switches that reveal their settings */
.toggle-row{display:flex;align-items:center;justify-content:space-between;margin:0 0 8px}
.toggle-row .text-count{margin:0 0 0 4px}
.face-behind,.face-footerhead{gap:0}
.switch{position:relative;display:inline-block;width:36px;height:20px;cursor:pointer}
.switch input{position:absolute;inset:0;opacity:0;margin:0;cursor:pointer}
.switch-ui{position:absolute;inset:0;border-radius:10px;background:var(--input);border:1px solid var(--border-strong);transition:background-color 140ms ease,border-color 140ms ease;pointer-events:none}
.switch-ui::after{content:"";position:absolute;top:2px;left:2px;width:14px;height:14px;border-radius:50%;background:var(--text2);transition:transform 140ms ease,background-color 140ms ease}
.switch input:checked + .switch-ui{background:var(--accent);border-color:var(--accent)}
.switch input:checked + .switch-ui::after{transform:translateX(16px);background:#fff}
.switch input:focus-visible + .switch-ui{outline:2px solid var(--focus-ring);outline-offset:2px}
.collapsed{display:none !important}
.tab-panel > div:empty{display:none}   /* empty slots would add a flex gap above the first control */

.letter-thumb{width:78%;height:78%;object-fit:contain;pointer-events:none}
.opt[aria-pressed=true]{border-color:var(--accent);background:var(--panel);color:var(--text)}

/* Credit line under the info bar */
.credit{margin:8px 0 0;text-align:center;font-size:11px;color:var(--text-disabled)}
.credit a{color:inherit;text-decoration:underline}
.credit a:hover{color:var(--text)}
