/* ===== Colorfigures 2.0: paper theme, colour per face, 3D props ===== */
  :root[data-theme="light"] {
    --bg:#ece8de; --panel:#f6f3ec; --edge:#ddd6c8; --line:#b3ab9b; --detail:#c9c1b2;
    --ink:#857d6e; --ink-hi:#231e16; --live:#231e16; --glass:#dfe7e9; --recess:#2b2523;
    --inkc:#231e16;                      /* the drawing's ink */
    --c-top:#f6957b; --c-front:#ef6a4c; --c-side:#4a2219; --c-mid:#cf5038;   /* body colour, set by the swatches */
  }
  body { background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .42  0 0 0 0 .39  0 0 0 0 .33  .14 0 0 0 0'/></filter><rect width='100%' height='100%' filter='url(%23p)'/></svg>"); }
  #stage { overflow:visible; }   /* the hand-drawn filter sits on a group inside the stage (see mount) — iOS-safe */
  /* faces: the x-max face (box SIDE, lower right) is the lit front, the y-max face (box FRONT, lower left) is in shade */
  #stage .face { fill:var(--c-front); stroke:var(--inkc); stroke-width:1; }
  /* ink hierarchy (1.0): each solid's silhouette is drawn heavier by size (stroke-width set inline); edges inside stay thin */
  #stage .sil { fill:none; stroke:var(--inkc); stroke-linejoin:round; stroke-linecap:round; vector-effect:non-scaling-stroke; pointer-events:none; }
  #stage .panel-ink { fill:none; stroke:var(--inkc); stroke-linejoin:round; vector-effect:non-scaling-stroke; pointer-events:none; }
  #stage .face.band { stroke-width:.7; }
  #stage .prod-band { fill:var(--k); stroke:var(--k); stroke-width:.6; vector-effect:non-scaling-stroke; pointer-events:none; }
  #stage .cast { fill:#41538f; pointer-events:none; }      /* 1.0's flat blue cast shadow */
  #stage .face.ff { fill:var(--c-side); }
  #stage .face.top { fill:var(--c-top); }
  /* materials: add to a face or to anything drawn on a face plane */
  #stage .face.metal, #stage .face.top.metal { fill:#d9dddd; } #stage .face.ff.metal { fill:#9ea6a9; }
  #stage .face.cream, #stage .face.top.cream { fill:#fff4d6; } #stage .face.ff.cream { fill:#d9cfae; }
  #stage .face.dark,  #stage .face.top.dark  { fill:#46413c; } #stage .face.ff.dark  { fill:#2a2724; }
  #stage .face.plate, #stage .face.top.plate { fill:#ddd8ca; } #stage .face.ff.plate { fill:#b9b3a4; }
  #stage .face.mid { fill:var(--c-mid); } #stage .face.top.mid { fill:color-mix(in srgb, var(--c-mid) 70%, var(--c-top)); } #stage .face.ff.mid { fill:color-mix(in srgb, var(--c-mid) 45%, var(--c-side)); }
  #stage .face.recess { fill:var(--recess); }
  #stage .face.inner { fill:color-mix(in srgb, var(--c-front) 55%, #fff); }   /* inside of a door or lid */
  #stage .face.win { fill:#e3eaec; }
  #stage .face.decal { fill:color-mix(in srgb, var(--c-side) 78%, #fff); }
  #stage .detail { stroke:var(--inkc); stroke-width:1.2; opacity:.7; }
  #stage .label { fill:var(--inkc); }
  #stage .label.on-side { fill:color-mix(in srgb, var(--c-side) 55%, #000); }
  /* glass over an opening (draw after what is behind it) */
  #stage .glass-tint { fill:#cfe9f0; opacity:.22; pointer-events:none; }
  #stage .streak { fill:#fff; opacity:.38; pointer-events:none; }
  /* 3D props from K.props (colour comes from style="--k:#hex") */
  #stage .prod { fill:var(--k); stroke:var(--inkc); stroke-width:1.1; stroke-linejoin:round; vector-effect:non-scaling-stroke; }
  #stage .prod-sh { fill:#000; opacity:.18; pointer-events:none; }
  #stage .prod-top { fill:color-mix(in srgb, var(--k) 68%, #fff); stroke:var(--inkc); stroke-width:.8; vector-effect:non-scaling-stroke; }
  #stage .prod-hi { stroke:#fff; stroke-width:1.4; opacity:.55; stroke-linecap:round; fill:none; vector-effect:non-scaling-stroke; pointer-events:none; }
  #stage .prod-label { fill:#fbf7ea; stroke:var(--inkc); stroke-width:.6; vector-effect:non-scaling-stroke; }
  #stage .prod-ink { fill:none; stroke:var(--inkc); stroke-width:1.1; stroke-linecap:round; stroke-linejoin:round; vector-effect:non-scaling-stroke; }
  /* tube(): a thick line with an ink outline (spouts, handles, hoses, cables, streams); widths are in drawing units */
  #stage .tube-ink { fill:none; stroke:var(--inkc); stroke-linecap:round; stroke-linejoin:round; }
  #stage .tube { fill:none; stroke:var(--k); stroke-linecap:round; stroke-linejoin:round; }
  /* part labels / callouts (the explanation lives in the drawing): a cream pill with ink text; add .on while that part works */
  #stage .tag rect { fill:#fff4d6; stroke:var(--inkc); stroke-width:1; vector-effect:non-scaling-stroke; }
  #stage .tag text { fill:var(--inkc); font-weight:800; }
  #stage .tag.on rect { fill:var(--accent); } #stage .tag.on text { fill:#fff; }
  #stage .tag line, #stage .tag path { stroke:var(--inkc); stroke-width:1; fill:none; vector-effect:non-scaling-stroke; }
  #stage .shelf { fill:#cfd6d8; stroke:var(--inkc); stroke-width:.7; vector-effect:non-scaling-stroke; }
  #stage .shelf-edge { fill:#a9b1b4; stroke:var(--inkc); stroke-width:.9; vector-effect:non-scaling-stroke; }
  /* "how it works" strip: the big idea + numbered steps; api.step(i) lights the current one */
  .explain { display:grid; gap:10px; margin-top:6px; padding-top:14px; border-top:1px solid var(--edge); }
  .explain .steps { display:grid; grid-template-columns:repeat(auto-fit, minmax(150px, 1fr)); gap:10px; }
  .explain .step { display:grid; grid-template-columns:auto 1fr; gap:4px 10px; align-items:start; padding:10px 12px; border:1.5px solid var(--edge);
    border-radius:12px; background:var(--bg); font-size:12px; line-height:1.45; letter-spacing:.02em; color:var(--ink); transition:border-color .25s, background .25s, color .25s, box-shadow .25s; }
  .explain .step b { display:grid; place-items:center; width:20px; height:20px; border-radius:50%; border:1.5px solid var(--line); font-size:11px; color:var(--ink); }
  .explain .step.on { border-color:var(--inkc); background:var(--panel); color:var(--ink-hi); box-shadow:3px 3px 0 var(--inkc); }
  .explain .step.on b { background:var(--c-front); border-color:var(--inkc); color:var(--inkc); }
  .explain .idea { font-size:12.5px; color:var(--ink-hi); letter-spacing:.02em; }
  .explain .idea strong { letter-spacing:.1em; text-transform:uppercase; font-size:11px; margin-right:6px; }
  /* embed mode (build.py --embed): just the figure card, no gallery chrome */
  :root[data-embed] .wrap > .top, :root[data-embed] .layout > nav, :root[data-embed] .made-with { display:none; }   /* not #stage .top (box tops)! */
  :root[data-embed] .layout { grid-template-columns:1fr; grid-template-areas:"fig"; }
  :root[data-embed] .wrap { max-width:900px; }
  /* text under the figure is off: the buttons and the motion tell the story (hint, status line, steps, big idea).
     Remove these two rules to bring it back. */
  figure > .cap:has(#hint), #explain { display:none !important; }
  /* ?shot: drawing only (thumbnails, social images) */
  html.shot .acts, html.shot figure > .cap, html.shot .wob, html.shot #explain { display:none !important; }
  /* action buttons: listed in the order you'd use them, top-left over the figure (click any, in any order) */
  .stagewrap { position:relative; }
  .acts { position:absolute; top:4px; left:0; z-index:2; display:flex; flex-direction:column; align-items:flex-start; gap:8px; }
  .acts button { font:inherit; font-size:12.5px; letter-spacing:.02em; color:var(--inkc); background:var(--panel); border:1.5px solid var(--inkc);
    border-radius:999px; padding:5px 14px; cursor:pointer; white-space:nowrap; }
  .acts button:hover { background:color-mix(in srgb, var(--panel) 90%, var(--inkc)); }
  .acts button:active { transform:translateY(1px); }
  @media (max-width:560px) { .acts { position:static; flex-direction:row; flex-wrap:wrap; gap:6px; margin-bottom:8px; } .acts button { font-size:12px; padding:4px 11px; }
    :root[data-embed] body { padding:10px 8px 16px; } :root[data-embed] figure { padding:12px; border-radius:16px; } }
  .wob { display:flex; align-items:center; gap:10px; font-size:11px; letter-spacing:.12em; text-transform:uppercase; }
  /* under the figure: wobble, body colour (moved here when embedded), labels on/off */
  .ctrlrow { display:flex; align-items:center; flex-wrap:wrap; gap:12px 24px; }
  .lbltog { display:flex; align-items:center; gap:8px; font-size:11px; letter-spacing:.12em; text-transform:uppercase; }
  .lbltog[hidden] { display:none; }
  .lbltog button { font:inherit; letter-spacing:.06em; text-transform:none; font-size:12px; color:var(--inkc); background:transparent;
    border:1.5px solid var(--inkc); border-radius:999px; padding:3px 12px; cursor:pointer; }
  .lbltog button[aria-pressed="false"] { opacity:.55; }
  html.nolabels #stage .tag, html.nolabels #stage [class*="-tag"] { display:none; }
  html.shot .ctrlrow { display:none !important; }
  .wob input { accent-color:var(--inkc); width:160px; }
