/* ---------- tokens ------------------------------------------------------
   Taken verbatim from the marketing site (demo-slider.html) so the editor and
   the pages that link to it read as one product.

   The short names underneath (--bg, --panel, --dim, --acc, --fg, --rm) are the
   editor's original variable names. site/scripts/sync-app.mjs injects a small
   stylesheet for the "back to the site" link that references --dim, --line,
   --panel and --ink, so those names have to keep resolving. They are aliases
   now, not a second palette.

   --edge is the border of anything you can click. It is deliberately darker
   than --line: a hairline that divides is decorative, a hairline that IS the
   control needs 3:1 (WCAG 1.4.11). --muted clears that at 3.48:1 on white. */
:root{
  --ink:#0E1417; --ink-2:#4A5A61; --muted:#7C8C93;
  --line:#E3EAED; --ground:#FFFFFF; --sunk:#F4F7F8;
  --accent:#1668A8; --lift:#12324A; --pop:#FF5C2B; --mint:#17BE8B;
  --edge:var(--muted);

  --keep-bg:#E3F7EC; --keep-ink:#0B5B3B; --keep-edge:#3FA277;
  --rem-bg:#FDE7E5;  --rem-ink:#8C1D18;  --rem-edge:#C2635C;
  --rest-bg:#E4EFF8; --rest-ink:#0F4C7A; --rest-edge:#5E93BE;

  /* aliases: see note above */
  --bg:var(--ground); --panel:var(--ground); --dim:var(--ink-2);
  --acc:var(--accent); --fg:#0F7A4A; --rm:#B3261E;
}
*{box-sizing:border-box}
[hidden]{display:none !important}
html,body{height:100%}
body{margin:0;background:var(--ground);color:var(--ink);
  font:14px/1.5 "IBM Plex Sans",ui-sans-serif,-apple-system,"SF Pro Text",Inter,system-ui,sans-serif;
  -webkit-font-smoothing:antialiased;
  display:flex;flex-direction:column;overflow:hidden}

/* One focus ring for the whole app, on the accent so it is unmistakable
   against every surface here (5.87:1 on white, 5.45:1 on --sunk). */
:where(a,button,input,select,canvas,[tabindex]):focus-visible{
  outline:2px solid var(--accent);outline-offset:2px;border-radius:4px}

header{padding:15px 22px;border-bottom:1px solid var(--line);flex:0 0 auto;background:var(--ground)}
header h1{margin:0;font-family:Archivo,"IBM Plex Sans",system-ui,sans-serif;
  font-weight:800;font-size:18px;letter-spacing:-.015em;line-height:1.1}
.sub{margin:3px 0 0;color:var(--ink-2);font-size:12.5px}
main{flex:1 1 auto;display:flex;min-height:0}
#stage{flex:1 1 auto;position:relative;display:flex;align-items:center;justify-content:center;
  padding:22px;min-width:0;background:var(--sunk)}
#panel{flex:0 0 288px;border-left:1px solid var(--line);background:var(--ground);
  overflow-y:auto;padding:4px 0}

.drop{width:100%;height:100%;border:1.5px dashed var(--edge);border-radius:14px;
  background:var(--ground);display:flex;align-items:center;justify-content:center}
.drop.hot{border-color:var(--accent);background:#1668A80f}
.drop-inner{display:flex;flex-direction:column;align-items:center;gap:12px;color:var(--ink-2)}
.drop-inner strong{color:var(--ink);font-family:Archivo,"IBM Plex Sans",system-ui,sans-serif;
  font-weight:700;font-size:17px;letter-spacing:-.01em}
.hint{font-size:12px;max-width:280px;text-align:center;color:var(--ink-2)}

#viewer{position:relative;max-width:100%;max-height:100%;display:flex}
/* The hairline is a box-shadow, not a border: #cv's on-screen rect is measured
   against cv.width to size the painted brush ring (see updateCursor in app.js),
   and a border would put those two out of step. */
#cv{max-width:100%;max-height:calc(100vh - 132px);display:block;border-radius:10px;
  box-shadow:0 0 0 1px var(--line),0 18px 40px -24px rgba(14,20,23,.35);touch-action:none}
/* the brush ring is painted into the canvas itself (see drawRing in app.js),
   so the OS pointer would only be a second, wrong-sized cursor on top of it */
#cv.paint{cursor:none}

/* Sits over the picture, so it is opaque enough to stay readable whatever is
   underneath: at 95% white the worst case (a black photo) still leaves the
   text at 15.9:1. */
#busy{position:absolute;inset:auto 0 0 0;background:#fffffff2;border-top:1px solid var(--line);
  color:var(--ink);padding:10px 14px;border-radius:0 0 10px 10px;display:flex;align-items:center;
  gap:10px;font-size:12px}
.bar{flex:1;height:4px;background:var(--line);border-radius:2px;overflow:hidden}
.bar i{display:block;height:100%;width:0;background:var(--accent);transition:width .12s}

.group{padding:16px 18px;border-bottom:1px solid var(--line)}
.grouphead{font-size:11px;text-transform:uppercase;letter-spacing:.08em;color:var(--ink-2);margin-bottom:10px}
.row{display:flex;align-items:center;gap:8px;margin:10px 0;font-size:12.5px;color:var(--ink-2)}
.row input[type=range]{flex:1;accent-color:var(--accent);min-width:0}
.row output{width:26px;text-align:right;color:var(--ink);font-variant-numeric:tabular-nums}
.row select{flex:1;background:var(--ground);color:var(--ink);border:1px solid var(--edge);
  border-radius:7px;padding:6px 7px;font:inherit;font-size:12.5px;min-width:0}
.row select:hover{border-color:var(--ink-2)}
.check{display:flex;align-items:center;gap:8px;margin:10px 0;font-size:12.5px;color:var(--ink-2)}
.check input{accent-color:var(--accent)}

.seg{display:flex;gap:4px;background:var(--sunk);border:1px solid var(--line);border-radius:9px;padding:3px}
.seg button{flex:1;background:none;border:0;color:var(--ink-2);padding:6px 2px;border-radius:6px;
  font:inherit;font-size:12px;cursor:pointer}
.seg button.on{background:var(--ground);color:var(--ink);box-shadow:0 0 0 1px var(--line)}
.seg button:hover:not(.on){color:var(--ink)}
/* Keep and Remove never change meaning: green adds, red subtracts. */
#tool button[data-t=fg].on{background:var(--keep-bg);color:var(--keep-ink);box-shadow:0 0 0 1px var(--keep-edge)}
#tool button[data-t=bg].on{background:var(--rem-bg);color:var(--rem-ink);box-shadow:0 0 0 1px var(--rem-edge)}

.btn{background:var(--ground);border:1px solid var(--edge);color:var(--ink);padding:8px 13px;
  border-radius:8px;font:inherit;font-size:12.5px;font-weight:500;cursor:pointer}
.btn:hover{background:var(--sunk);border-color:var(--ink-2)}
.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff;font-weight:600}
.btn.primary:hover{background:var(--lift);border-color:var(--lift)}
.btn:disabled{opacity:.45;cursor:default}
.btn:disabled:hover{background:var(--ground);border-color:var(--edge)}
.btn.primary:disabled:hover{background:var(--accent);border-color:var(--accent)}
.btn.wide{width:100%;margin-top:8px}
.btnrow{display:flex;gap:6px;margin-top:10px}
.btnrow .btn{flex:1}

#stats{width:100%;border-collapse:collapse;font-size:12.5px}
#stats td{padding:4px 0;color:var(--ink-2)}
#stats td:last-child{text-align:right;color:var(--ink);font-variant-numeric:tabular-nums}
.note{font-size:11.5px;color:var(--ink-2);margin:10px 0 0;line-height:1.45}

/* The silent model upgrade's entire visible footprint. Deliberately quiet: no
   accent colour, no motion that pulls the eye, no pointer target -- it reports
   that something already happened, it does not ask for anything. */
#upgraded{position:absolute;top:10px;right:10px;pointer-events:none;
  background:#fffffff2;border:1px solid var(--line);color:var(--ink-2);
  padding:4px 10px;border-radius:999px;font-size:11px;letter-spacing:.02em;
  opacity:0;transition:opacity .5s ease}
#upgraded.show{opacity:1}
@media (prefers-reduced-motion:reduce){#upgraded{transition:none}}

#coach{position:absolute;left:0;right:0;bottom:0;background:#fffffff2;color:var(--ink-2);
  border-top:1px solid var(--line);
  padding:10px 12px;border-radius:0 0 10px 10px;font-size:12px;line-height:1.4}
#coach b{color:var(--ink);font-weight:600}
#coach.gone{display:none}

.brushes{display:flex;gap:5px}
.brush{flex:1 1 0;min-width:0;display:flex;align-items:center;justify-content:center;gap:5px;
  background:var(--ground);border:1px solid var(--edge);color:var(--ink-2);white-space:nowrap;
  padding:11px 3px;border-radius:9px;font:inherit;font-size:12px;font-weight:600;cursor:pointer}
.brush .dot{flex:0 0 auto;width:9px;height:9px;border-radius:50%;background:currentColor;opacity:.5}
.brush.keep.on{background:var(--keep-bg);border-color:var(--keep-edge);color:var(--keep-ink)}
.brush.rem.on{background:var(--rem-bg);border-color:var(--rem-edge);color:var(--rem-ink)}
.brush.rest.on{background:var(--rest-bg);border-color:var(--rest-edge);color:var(--rest-ink)}
.brush:hover:not(.on){color:var(--ink);border-color:var(--ink-2)}
.brush.on{box-shadow:inset 0 0 0 1px currentColor}
.brush.on .dot{opacity:1}

/* Developer-only panel: off in the production UI, shown with ?dev=1. Styled to
   read as a debug shelf rather than part of the tool. */
#dev{padding:12px 18px 18px;border-top:2px solid var(--line);background:var(--sunk);
  font-size:11.5px;color:var(--ink-2)}
#dev::before{content:"DEBUG";display:block;font-size:10px;font-weight:700;
  letter-spacing:.14em;color:var(--ink-2);margin-bottom:8px}
#dev .row,#dev .check{font-size:11.5px;margin:7px 0}
#dev .row select{font-size:11.5px;padding:4px 6px}
#stats{margin-top:10px}

.hint a{color:var(--accent);text-decoration:underline;text-underline-offset:2px}
.hint a:hover{color:var(--lift)}

#nnstate{margin:2px 0 10px}
#nnstate.err{color:var(--rm)}
#nnstate.ok{color:var(--fg)}

/* ---------- background sources -----------------------------------------
   Both panes sit directly beneath the #backdrop select and only one of them
   is ever visible, chosen by that select. */
.bgpane{margin-top:8px}
.bgpane .bgname{margin:6px 0 0;font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bgpane .btn.wide{margin-top:0}

.stockstrip{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;
  max-height:190px;overflow-y:auto}
.stockstrip .thumb{padding:0;border:2px solid var(--line);border-radius:7px;background:var(--sunk);
  aspect-ratio:4/3;overflow:hidden;cursor:pointer;display:block;
  box-shadow:2px 2px 0 var(--line)}
.stockstrip .thumb img{width:100%;height:100%;object-fit:cover;display:block}
.stockstrip .thumb:hover{border-color:var(--ink-2)}
.stockstrip .thumb.on{border-color:var(--accent);box-shadow:2px 2px 0 var(--accent)}
.stockstrip .thumb:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

/* ---------- canvas context menu -----------------------------------------
   Flat fills, a 2px --ink border and a hard offset shadow -- no gradients,
   no blur -- so the panel reads as an extruded plate sitting on the page.
   Same construction as the .stat chips on the marketing site. */
#ctxmenu{position:fixed;z-index:60;min-width:268px;padding:6px;
  background:var(--ground);border:2px solid var(--ink);border-radius:10px;
  box-shadow:5px 5px 0 var(--lift);font-size:12.5px}
.ctxhead{padding:5px 8px 7px;font-size:11px;font-weight:700;letter-spacing:.08em;
  text-transform:uppercase;color:var(--ink-2)}
.ctxitem{display:flex;align-items:center;gap:8px;width:100%;text-align:left;
  background:var(--ground);border:2px solid var(--ink);border-radius:8px;color:var(--ink);
  padding:8px 9px;margin:0 0 6px;font:inherit;font-size:12.5px;cursor:pointer;
  box-shadow:2px 2px 0 var(--lift)}
.ctxitem:last-child{margin-bottom:0}
.ctxitem:hover,.ctxitem:focus{background:var(--sunk);outline:none}
.ctxitem:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.ctxitem:active{transform:translate(2px,2px);box-shadow:0 0 0 var(--lift)}
.ctxitem[disabled]{opacity:.45;cursor:default}
.ctxitem[disabled]:active{transform:none;box-shadow:2px 2px 0 var(--lift)}
.ctxname{flex:0 0 auto;font-weight:600}
.ctxdim{flex:1 1 auto;color:var(--ink-2);font-variant-numeric:tabular-nums;font-size:11.5px}

.pill{flex:0 0 auto;display:inline-flex;align-items:center;gap:4px;
  padding:3px 8px;border-radius:999px;font-size:10px;font-weight:800;
  letter-spacing:.06em;border:2px solid var(--ink);box-shadow:2px 2px 0 var(--lift)}
.pill.free{background:#BFF3D4;color:#0D3D22}
.pill.unlock{background:var(--accent);color:#fff}
.pill .lock{width:9px;height:11px;flex:0 0 auto}

@media (prefers-reduced-motion:reduce){.ctxitem:active{transform:none}}
