/* ==========================================================================
   Player UI — design system
   Source of truth: Figma file uZ7iWwvNrNKPbTVOLkgMAj, frame node 33:2
   See player/DESIGN-SYSTEM.md for the full token + component reference.
   ========================================================================== */

/* ───── Tokens ───── */
:root {
  /* Color — names mirror Figma tokens (UI/Dark/*, Brand/*) */
  --color-bg-canvas:   #191919;                  /* UI/Dark/Background */
  --color-panel:       #202020;                  /* UI/Dark/Panel */
  --color-input:       #2C2C2D;                  /* UI/Dark/Input */
  --color-stroke-hi:   #414144;                  /* UI/Dark/Highlight */
  --color-highlight-plus: #727379;               /* UI/Dark/Highlight+ — one step brighter than Highlight; used for X / reload action chips on media + layer rows. */
  --color-stroke:      #4A4C54;                  /* UI/Dark/Stroke */
  --color-text:        #A5A7AD;                  /* UI/Dark/Text */
  --color-text-dim-40: rgba(247, 247, 247, 0.4); /* UI/Dark/Off-White 40% */
  --color-blue:        #3F8AE2;                  /* UI/Dark/Blue (selection) */
  --color-accent:      #2F6EEE;                  /* UI/Accent Blue — Boolean ON track (Figma 482:1899) */
  --color-accent-red:  #E1392D;                  /* UI/Accent Red — Recording bg, error status */
  --color-accent-green: #2FB766;                 /* "set / ready" — the start screen's API key dot (user 2026-11-16) */
  --color-accent-purple: #8C4DE6;                /* UI/Accent Purple — the cimble's selection (hover / selected rect, its ⋯ badge). Proposed 2026-11-12, not in Figma yet */
  --color-off-white:   #F7F7F7;                  /* Brand/Off-White */
  --color-off-black:   #0F1011;                  /* Brand/Off-Black */
  --color-grey:        #7C868D;                  /* Brand/Grey */
  /* Text-selection highlight, site-wide: Brand/Grey, see-through (user
     2026-11-12 — was the browser's blue). */
  --color-selection:   rgba(124, 134, 141, 0.45);
  /* Hover overlay — universal "this is interactive" wash (see
     Patterns › Button hover in DESIGN-SYSTEM.md). 10 % white painted
     on top of the resting bg via an inset box-shadow. */
  --color-hover-overlay: rgba(255, 255, 255, 0.1);
  /* Stroke @ 40 % — color-swatch hairline. The base token is
     `--color-stroke` (`#4A4C54`); this 40 % variant is its only
     usage in the player chrome today. */
  --color-stroke-faint: rgba(74, 76, 84, 0.4);
  /* Transparency checker — ONE pattern for every "this is transparent"
     surface: the canvas frame backing, colour swatches with alpha, and
     media thumbnails with transparent pixels. Panel base + Input squares,
     6 px squares (12 px tile). Use all four tokens together. */
  --checker-base: var(--color-panel);
  --checker-image:
    linear-gradient(45deg,  var(--color-input) 25%, transparent 25%),
    linear-gradient(-45deg, var(--color-input) 25%, transparent 25%),
    linear-gradient(45deg,  transparent 75%, var(--color-input) 75%),
    linear-gradient(-45deg, transparent 75%, var(--color-input) 75%);
  --checker-size: 12px 12px;
  --checker-position: 0 0, 0 6px, 6px -6px, -6px 0;

  /* Aliases — kept so JS reads and older selectors keep working. */
  --bg:         var(--color-bg-canvas);
  --panel:      var(--color-panel);
  --input:      var(--color-input);
  --line:       var(--color-stroke-hi);
  --ink:        var(--color-off-white);
  --ink-soft:   var(--color-text);
  --ink-mute:   var(--color-stroke-hi);
  --ink-dim:    var(--color-text-dim-40);
  --off-black:  var(--color-off-black);
  --brand-grey: var(--color-grey);

  /* Typography */
  /* Adobe Typekit's "neue-haas-grotesk-display" slug (loaded by the
     <link> in index.html). The kit ships two weights:
       500 — 55 Roman
       600 — 65 Medium
     So all "Roman" usages in this codebase use `font-weight: 500`
     and all "Medium" usages use `font-weight: 600`. The Text variant
     (which uses 400 / 500 / 700) stays loaded by the same kit as a
     fallback for any code that hasn't migrated. The legacy "NHG"
     Framer face is also kept as a deep fallback in case the kit
     fails to load entirely. */
  --font-text:    "neue-haas-grotesk-display", "neue-haas-grotesk-text", "NHG", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: "neue-haas-grotesk-display", "Neue Haas Grotesk Display Pro", "neue-haas-grotesk-text", "NHG", "Helvetica Neue", Helvetica, Arial, sans-serif;

  /* iOS home-indicator safe area at the bottom of the viewport. Exposed
     as a CSS variable so JS (canvas-view#fitToCanvasArea) can also
     read the value via getComputedStyle without parsing env() at
     runtime. On devices without a home indicator the env() resolves
     to 0, so callers see 0 and the safe-area math is a no-op. */
  --safe-area-bottom: env(safe-area-inset-bottom, 0);

  /* Layout */
  --lib-w: 280px;
  /* Sidebar default: 20vw, with a 320 px floor (smaller is unusable for
     the controls) and a 40vw ceiling (anything wider than that eats too
     much canvas on narrow browsers). The same min/max are enforced in
     JS for the drag handle + window-resize clamp; the CSS clamp here
     just gives a sensible default before localStorage restores. */
  --ctl-w: clamp(352px, 20vw, 40vw);   /* default ≥ 352 (user 2026-11-17: "a bit wider" — a palette row's hex fits whole); a drag may go down to 320 */
  /* Media tile / color column width — FIXED (user rule 2026-11-10): a wider
     sidebar adds columns, it never scales tiles or swatch cells. Value =
     3 columns + two 10 px gaps filling the 220 px inner width of the
     narrowest (320 px) sidebar. */
  --media-col: 66px;   /* whole px (user 2026-11-17; was 66.666): 3 × 66 + 2 × 11 gap = 220 */
  /* Color-group column width — FIXED, same rule: a wider sidebar adds
     columns, nothing scales. 80 px → two columns in the narrowest (320 px,
     220 px inner) sidebar, and exactly two 36 px swatches + 8 px gap. */
  --color-col: 80px;

  /* Radius */
  --radius-pill:  999px;
  --radius-panel: 32px;
  --radius-label: 8px;

  /* Button height — canonical 56 px for every button-shaped surface
     (ratio pills, Randomize / Run / cfg buttons, canvas upload CTA,
     export text pills 2x / PNG / Timer). The discs (Capture / Record /
     Settings) are the only exception: 58 px in both axes so they read
     as a slightly heavier "frame" around the text pills they bracket
     in the export row. Pull from these two tokens rather than hard-
     coding any pixel height. */
  --btn-h:        56px;
  --btn-export-h: 58px;

  /* Input-row height — the canonical row size for input-like surfaces
     INSIDE a floating popup: layer rows + the add row in the Layers
     popup, the blend / sizing dropdown headers in the per-image
     Settings popup, and any future popup row that follows this
     pattern. Paired with `padding: 0 12px` for horizontal inset and
     `display: flex; align-items: center` for vertical centering of
     icon + label. Tighter than the sidebar's --btn-h (56) so the
     popup reads as a compact secondary surface, not a primary CTA. */
  --input-row-h: 40px;

  /* Effects */
  --shadow-frame: 0 0 20px rgba(0, 0, 0, 0.2);
  /* Frame Shadow, LIGHT-background variant — 5% (vs 20% for the dark UI). For
     light surfaces like the landing-page frame previews. */
  --shadow-frame-light: 0 0 20px rgba(0, 0, 0, 0.05);
  /* Handle Shadow (Figma 386:931) — drop shadow on the frame resize handles.
     Dark = handles on the dark canvas (player); Light = on a light bg (landing). */
  --shadow-handle:       0 0 8px rgba(0, 0, 0, 0.6);
  --shadow-handle-light: 0 0 8px rgba(0, 0, 0, 0.15);
  --shadow-pill:  0 0 10px rgba(0, 0, 0, 0.2);

  /* Motion — shared across collapsible controls (Navigator, Dropdown, …).
     `--transition-collapse` drives the height/opacity/padding of stacked
     rows when a panel opens or closes. `--transition-icon` drives small
     affordances like chevron rotation. Anything that opens/closes inside
     a control panel should pull from these tokens so cadence stays in
     lockstep across control types. */
  --transition-collapse: 0.4s ease;
  --transition-icon:     0.2s ease;
}

/* ───── Reset + base ───── */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* Kill iOS Safari's default tap-highlight (the rgba(0,0,0,0.18) box
   that flashes on every tappable element). Our `:active` rules provide
   the proper tactile feedback (scale 0.94 / 0.96) — the dark box
   overlays them and looks like a bug to users. Single root rule
   cascades to every descendant. */
html, body {
  -webkit-tap-highlight-color: transparent;
}

/* Suppress the browser's default focus outline on every interactive
   element. Custom focus styling (color shifts, .active classes) is
   already provided per-component where useful; the platform's blue/
   white ring would otherwise overlay our chrome (e.g. on the Reset
   "altered" text or any ratio pill). Text-selection highlights inside
   inputs are unrelated — they come from ::selection, not :focus. */
:focus,
:focus-visible { outline: none; }
/* NO colour fades on hover (user 2026-11-17 — they caused the flicker):
   background, color, box-shadow, border / outline colour, filter and fill /
   stroke change at once; hovers still SCALE (transform transitions) and
   things still fade in / out with opacity (tooltips, popups, badges).
   Don't add colour / background / shadow transitions back. */
::selection { background: var(--color-selection); }

html {
  height: 100%;
  overflow: hidden;
  background-color: var(--color-bg-canvas);
  transition: background-color 0.4s ease;   /* recording: the page fades to black (not a hover) */
}
/* Recording (record.js): the canvas background goes black and the dot grid
   fades — the stage reads as "playing" (user 2026-11-12). */
html:has(body.is-recording) { background-color: #000000; }

/* Background dot grid — three octave-aligned layers (fine 40 / mid 80
   / coarse 160). Step opacity (each layer either 0 or 1), with a
   short CSS transition so adjacent layers cross-fade smoothly when
   the zoom crosses an octave boundary. NO spacing clamp — that was
   the drift source. The coarse layer covers BOTH zoom extremes (very
   high AND very low zoom < 0.3) so the densest layer ever shown at
   extreme zoom-out is coarse @ 16 px spacing (160 × 0.1), well above
   the dot diameter so no moiré. `background-position: 50% + pan`
   keeps the central dot anchored at viewport-center + pan regardless
   of the layer's tile size. */
.bg-dots {
  position: fixed;
  inset: -30px;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
body.is-recording .bg-dots { opacity: 0; }

/* FPS counter — top-left of viewport, 10 px inset. Text styling matches
   the zoom / tiny pills (.c1-pill — 500 11.5px/14px, 0.75 letter-
   spacing) so the counter reads as part of the same "tiny on-canvas
   text" family. UI/Text grey + tabular-nums so digits don't jitter as
   the value updates twice a second; pointer-events: none so it doesn't
   intercept canvas clicks. */
/* Top centre (Figma A2): the top-left corner holds Back + the logo. */
.fps-counter {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px;
  color: var(--color-text);
  font: 500 11.5px/14px var(--font-display);
  letter-spacing: 0.75px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  user-select: none;
  /* Below the badge host (z 14) and the popups (z 12 / 13) so when a
     layer-settings badge clamps to the same top-left corner the badge
     paints on top of the counter instead of the counter sitting over
     the button. */
  z-index: 10;
}
/* Hide the counter while a tool is loading/transitioning — it'd flash
   "—fps" or a stale value over the skeleton, which reads as noise.
   Returns once `.stage.transitioning` drops and the new tool is up. */
body:has(.stage.transitioning) .fps-counter { display: none; }

/* The cimble logo, top-left (tool.html #appCorner): the START SCREEN's logo
   (user 2026-11-16 — the Back square is gone; the logo is the way back, Save /
   Don't save first): the mark + "cimble". .start-brand / .start-mark live
   here so both pages share them. */
.app-corner {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 11;
  display: flex;
  align-items: center;
  min-height: 55px;
}
.start-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--color-off-white);
  text-decoration: none;
  font: 600 19px/1 var(--font-display);
  letter-spacing: -0.2px;
}
.start-mark { display: inline-flex; }
.start-mark svg { width: 18px; height: auto; display: block; }
body:has(.stage.transitioning) .app-corner { visibility: hidden; }
body.fullscreen .app-corner { display: none; }
/* A narrow window: the mark alone (the word would run under the sidebar). */
@media (max-width: 640px) { .app-logo .app-logo-word { display: none; } }
@media (pointer: coarse) and (max-width: 900px) {
  .app-corner { top: 12px; left: 12px; min-height: 44px; }
}
.bg-dots-layer {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--color-input) 1.5px, transparent 1.5px);
  background-position:
    calc(50% + var(--bg-pan-x, 0px))
    calc(50% + var(--bg-pan-y, 0px));
  /* 400 ms ease — at rest each layer is still binary (0 / 1) because
     JS publishes step opacities, but the wider transition makes the
     octave swap read as a smooth wipe rather than a snap. */
  transition: opacity 400ms ease;
}
.bg-dots-fine   { background-size: calc(40px  * var(--bg-zoom, 1)) calc(40px  * var(--bg-zoom, 1)); opacity: var(--bg-grid-fine,   0); }
.bg-dots-mid    { background-size: calc(80px  * var(--bg-zoom, 1)) calc(80px  * var(--bg-zoom, 1)); opacity: var(--bg-grid-mid,    1); }
.bg-dots-coarse { background-size: calc(160px * var(--bg-zoom, 1)) calc(160px * var(--bg-zoom, 1)); opacity: var(--bg-grid-coarse, 0); }

body {
  height: 100vh;
  overflow: hidden;
  background: transparent;
  color: var(--color-off-white);
  font: 600 14px/1.4 var(--font-text);
  -webkit-font-smoothing: antialiased;
  /* The Navigator + Controls sidebars are `position: fixed` overlays now —
     `.stage` gets the full viewport so the iframe extends behind them. */
}

/* ───── Layout: Stage ─────
   Sits in the gap between the fixed sidebars. The fixed `left` / `right`
   anchors automatically resolve width to `viewport - lib - ctl`, so the
   iframe sized inside (via ratio.js using `.canvas-area`'s clientWidth/Height)
   always fits between the panels — never extends behind them. */
/* `.stage` spans the full viewport so the panned frame can travel into
   the area visually covered by the controls sidebar (which sits on top
   with z-index: 10). Flex-centering of the frame still settles in the
   visible region because `.canvas-area` carries `padding-right` equal to
   the sidebar's width. */
.stage {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: transparent;
  overflow: hidden;
}
.canvas-area {
  flex: 1;
  /* Override `min-height: auto` default — without it, a flex item refuses
     to shrink below its child's intrinsic size. Combined with `overflow:
     visible` for the panned frame, that meant the canvas-area would grow
     vertically to fit the frame instead of staying at the stage height,
     which broke the fit-to-screen math (clientHeight reported the
     stretched canvas-area height, not the viewport's). */
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* overflow: visible — the frame can pan out of the visible region into
     the sidebar zone; clipping happens at the .stage level via its own
     overflow: hidden. */
  overflow: visible;
  position: relative;
  background: transparent;
  /* Canvas-area spans the FULL viewport — the sidebar overlays on top
     (z-index 10). Frame centers in the entire browser window, same
     reference frame as the zoom pill, upload button, and off-screen
     pill. The right portion of the frame can slip under the sidebar
     when zoomed in; that's accepted as part of the overlay model. */
}
/* Specific ratio active or image loaded → symmetric breathing room
   (80 px top/sides, 100 px bottom — the extra 20 px reserves space
   for the size pill below the frame group). Figma node 116:3262. */
.canvas-area.ratio-contained,
.canvas-area.image-contained {
  padding: 80px 80px 100px 80px;
}
/* Fullscreen ratio — frame fills the full viewport, no padding around.
   The Fullscreen pill is auto-injected into every tool's ratio row
   (see ratio.js); selecting it sets `body.fullscreen` + this class,
   pins zoom at 100 %, locks pan at 0/0, and lets the canvas-view's
   resize listener keep the frame's CSS dims in sync with the viewport.
   Overrides the .ratio-contained padding above. */
body.fullscreen .canvas-area {
  padding: 0;
}
/* Strip every visible frame affordance in fullscreen — no shadow, no
   rounded corners, no hairline overlay, and no resize handles even on
   hover. The frame fills the viewport, so any chrome would be a band
   visibly cutting across the canvas edge. */
body.fullscreen .frame.selected {
  box-shadow: none;
  border-radius: 0;
}
body.fullscreen .frame.selected::after { display: none; }
body.fullscreen .frame-handle { display: none !important; }
/* Zoom pill greyed + uninteractive while Fullscreen is on — the pill
   still reads "100 %" because setZoom is a no-op (so the displayed
   value is whatever the pill last rendered, locked at 1). */
body.fullscreen .zoom-pill,
body.cimble-play .zoom-pill,
body.cimble-play-static .zoom-pill {
  /* greyed: Panel fill + UI/Highlight text (2026-11-17; was 40 %) */
  background: var(--color-panel); color: var(--color-stroke-hi);
  pointer-events: none;
  cursor: not-allowed;
}
/* Locked canvas: still greyed, but it takes the pointer — its hint says
   "Unlock canvas to zoom" and a press shakes the lock (user 2026-11-17;
   layers.js pokeLock). No hover lift / wash. */
body.cimble-play:not(.fullscreen) .zoom-pill,
body.cimble-play-static:not(.fullscreen) .zoom-pill { pointer-events: auto; }
body.cimble-play .zoom-pill:hover,
body.cimble-play-static .zoom-pill:hover { background: var(--color-panel); color: var(--color-stroke-hi); }
/* The lock's "here I am" shake (user 2026-11-17): the Layers button or the
   zoom pill pressed / hinted while the canvas is locked. The ICON shakes —
   the button keeps its own transform (hover lift, frame position). */
@keyframes lock-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-3px) rotate(-8deg); }
  35% { transform: translateX(3px) rotate(8deg); }
  55% { transform: translateX(-2px) rotate(-5deg); }
  75% { transform: translateX(2px) rotate(4deg); }
}
.frame-mode-btn.is-shaking svg { animation: lock-shake 0.45s ease; }
/* Live mode locks zoom / pan too (user 2026-11-13) — same faded pill. */
/* AR-transition envelope — added to <body> for 400 ms whenever
   applyRatio fires (Fullscreen toggle OR a regular ratio pill click
   that changes the frame dim). .frame's width/height + the iframe's
   width/height transition together so frame chrome (border, handles)
   and iframe content stay visually aligned through the animation.
   canvas-area padding transitions too, to absorb the .ratio-contained
   ↔ Fullscreen padding swap.
   Tools whose canvas backing reacts to size changes (duotone's
   aspect-pinned WebGL) must render synchronously inside their
   `resizeCanvas` to avoid a flicker between `canvas.width = X`
   (which clears the GL framebuffer) and the next rAF render. */
/* Fullscreen transition envelope — added to <body> on Fullscreen
   ENTRY/EXIT only (ratio.js#applyRatio). Frame chrome, frame-group
   pan, canvas-area padding, AND iframe content all CSS-transition
   over 400 ms in lockstep. `setFullscreen` pre-positions the iframe
   at its old visual size so the iframe's transition starts from a
   visually-matched state. Regular AR pill clicks DON'T get this
   class — they snap (applyFrame writes new dims directly), which
   avoids the image squish from Chrome's content-viewport lag during
   continuous CSS resizes. */
body.fs-transitioning .frame         { transition: width 0.4s ease, height 0.4s ease; }
body.fs-transitioning .frame-group   { transition: transform 0.4s ease; }
/* The canvas-area padding transition was retired: while it was in
   flight, getComputedStyle returned a mid-transition padding value, so
   ratio.js#fitToCanvasArea (which runs synchronously after exiting
   fullscreen) computed availW/availH off pre-target values and landed
   the wrong fit zoom (e.g. 72 % instead of 64 % for a 16:9 Pill Trail
   restore). Padding is an invisible spacer — its snap isn't perceived
   visually because the frame width / iframe content still animate via
   their own transitions below; only the centering anchor jumps,
   which is unnoticeable without visible canvas-area chrome. */
body.fs-transitioning .frame iframe  { transition: width 0.4s ease, height 0.4s ease, transform 0.4s ease; }
/* Image-layer overlay + chrome + hover outline + settings badge ride the
   same 0.4 s envelope so they translate / resize in lockstep with the
   cimble (the frame + iframe transitions above). Without this, the
   subscribeToView callback writes the new left/top/width/height
   instantly in renderOverlays — layers snap to their final position
   while the frame is still animating, which reads as the two surfaces
   moving independently. left/top/width/height all listed because the
   per-axis vs anchor-reposition branch in applyFrameChangeToLayers
   may touch any subset. The badge's existing transform/background/filter
   transitions are temporarily replaced here — during a 0.4 s
   fullscreen swap the user isn't interacting with it, so dropping the
   hover-scale animation for that window is acceptable. */
body.fs-transitioning .layer-overlay,
body.fs-transitioning .layer-chrome,
body.fs-transitioning .layer-hover-outline {
  transition: left 0.4s ease, top 0.4s ease, width 0.4s ease, height 0.4s ease;
}
body.fs-transitioning .layer-settings-badge {
  transition: left 0.4s ease, top 0.4s ease;
}

/* ───── Component: Navigator (tool dropdown inside Controls panel) ─────
   The Navigator used to be a separate left sidebar; now it lives at the top
   of the controls panel as a collapsible dropdown.

   • Wrapper (.navigator-wrap) sits inside `.controls-body` and provides the
     10 px vertical padding around the dropdown panel.
   • Panel (.navigator) is its own rounded `--color-input` panel with a
     drop-shadow, distinct from the surrounding `--color-panel` controls.
   • Rows (.tool-list li) — collapsed state shows only the active row plus
     a chevron; expanded state reveals the rest, separated by hairline
     border-tops.

   Click on the active row toggles `.expanded` on the navigator; clicking
   any other row selects that tool and collapses the dropdown. */
.navigator-wrap {
  width: 100%;
  padding: 10px 0;
}
.navigator {
  background: var(--color-input);
  border-radius: 14px;
  overflow: hidden;
  /* Drop-shadow + transparent inset baseline so the closed-hover rule
     below can tween cleanly into the 10 % white overlay without the
     box-shadow list-length swapping mid-transition. */
  box-shadow: var(--shadow-frame), inset 0 0 0 9999px transparent;
  /* Collapsed state: max-height 83 px (matches the skeleton's
     navigator block). overflow: hidden clips the font-metric
     ascent/descent that would otherwise push the natural height to
     ~90 px. Expanded state: max-height jumps to a known-larger value
     so the full tool list can fit; the same max-height property
     interpolates in both directions, matching the per-row max-height
     transitions in lockstep so open AND close both animate. Using a
     bare max-height (NOT also height) keeps the transition symmetric
     — height: 83 ↔ height: auto would snap because CSS doesn't
     interpolate between explicit and intrinsic sizing. */
  max-height: 83px;
  transition: max-height var(--transition-collapse);
}
/* Closed-hover treatment — mirrors `.ctrl-dropdown:not(.open):hover`:
   the whole panel lifts to UI/Highlight + 10 % white overlay so a
   collapsed navigator reads as one button-style hit target. When
   expanded, the panel reverts to its resting bg so the per-row pills
   are the only highlight surface. The `:not(.suppress-hover)` gate
   keeps the lift from snapping back on the instant a click closes
   the navigator — `library.js#collapseNavigator` stamps the class
   while the cursor is still inside, and the panel's `mouseleave`
   strips it. */
.navigator:not(.expanded):not(.suppress-hover):hover {
  background: var(--color-stroke-hi);
  box-shadow: var(--shadow-frame), inset 0 0 0 9999px var(--color-hover-overlay);
}
.navigator.expanded {
  max-height: 2000px;
}

.tool-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}
.tool-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  /* 28 + 24 (line-height) + 30 = 82 px content + 0.5 px border-top
     (transparent on the first row, opaque on the rest) ≈ 82.5 px
     outer per row. Same padding-top on every row regardless of
     position so all rows render at exactly the same height. */
  padding: 28px 24px 30px 20px;
  border-top: 0.5px solid var(--color-stroke-hi);
  color: var(--color-text);
  font: 600 23.2px/24px var(--font-display);
  letter-spacing: 0.25px;
  /* Anchor for the ::before highlight pill (mirrors `.ctrl-dropdown-row`'s
     hover treatment). */
  position: relative;
  /* Drives the open/close transition for non-active rows — `max-height` is
     a known-larger bound (rows are ~84 px tall), `opacity` fades the row,
     `padding-top/bottom` collapse the spacing, `border-top-width` collapses
     the divider. `overflow: hidden` clips the row content while it's mid-
     collapse so text doesn't bleed past the shrinking row box. */
  overflow: hidden;
  transition: max-height        var(--transition-collapse),
    opacity           var(--transition-collapse),
    padding-top       var(--transition-collapse),
    padding-bottom    var(--transition-collapse),
    border-top-width  var(--transition-collapse);
}
/* First row has no visible separator above it, but the 0.5 px border
   stays in layout (just transparent) so the row's outer height matches
   every other row exactly. Removing the border entirely shrunk the
   first li by 0.5 px and the row read as ~1 px shorter than the rest. */
.tool-list li:first-child   { border-top-color: transparent; }
.tool-list li:hover         { color: var(--color-off-white); }
.tool-list li.active        { color: var(--color-off-white); }
.tool-list li .tool-name    { flex: 1; padding-bottom: 2px; position: relative; }
.tool-list li .tool-chevron { position: relative; }
/* Hover highlight pill — matches `.ctrl-dropdown-row` (UI/Highlight bg,
   6 px radius). Pseudo-element so the row's full-width hairline border-
   top stays unaffected; 10 px inset on all four sides so the pill has
   the same gap to the panel's left/right edges as it has to the
   neighbouring row's boundary above/below. Row geometry is unchanged
   — the inset only affects the visual pill. The active row stays
   unboxed unless hovered, mirroring the ctrl-dropdown rule. */
.tool-list li::before {
  content: "";
  position: absolute;
  inset: 11px 10px;
  border-radius: 6px;
  pointer-events: none;
  transition: none;
}
/* Hover pill skips the active row. Clicking the active row only
   toggles the navigator open/closed (not a tool swap), so it doesn't
   need the "click to pick" highlight that non-active rows get. The
   smaller ctrl-dropdown still highlights its picked row on hover —
   that's a different interaction (picked row exists in the option
   list, hover reads as "you can re-click to commit"). */
.tool-list li:not(.active):hover::before { background: var(--color-stroke-hi); }
/* Chevron — only visible on the active row, flipped vertically when the
   navigator is expanded. The outer `.tool-chevron` span carries the
   asymmetric padding for optical alignment (the chevron's V-tip is closer
   to one edge than the other, so a uniform layout would look off-center).
   • DOWN: padding-top 2 px (pushes the icon down, centering against text).
   • UP: padding-top 4 px PLUS scaleY(-1), which inverts the padding into
     a visual padding-bottom and flips the icon to point up. */
.tool-list li .tool-chevron {
  /* Wrapper. Layout only — the rotation now lives on the inner icon
     so its rotation pivot is the icon's own centre (not the wrapper's,
     which the icon's -2 px margin-top offsets away from). Without
     this, rotating the wrapper swung the icon ~4 px downward at the
     end of the animation; with the icon owning the rotation, it
     stays optically centred against the H2 cap-line throughout. */
  flex-shrink: 0;
  display: none;
}
.tool-list li .tool-chevron-icon {
  /* Symbols/Down chevron (Figma 179:1055), 12-wide variant. Aspect
     2 : 1 → 12 × 6 visible; round caps bleed slightly outside via
     overflow:visible on the SVG so the bbox can stay at the design
     dim. The -2 px margin-top shifts the chevron optically up
     against the H2 cap-line — `align-items: center` puts the icon's
     geometric centre on the text's vertical centre, which reads as
     visually low because the cap-line sits above the geometric
     centre of mixed-case text. */
  display: block;
  width: 12px;
  height: 6px;
  margin-top: -4px;
  transition: transform var(--transition-icon);
}
.tool-list li.active .tool-chevron { display: block; }
.navigator.expanded .tool-list li.active .tool-chevron-icon {
  /* rotate (not scaleY) so the chevron sweeps smoothly through 90° on
     its way to flipped — scaleY(-1) interpolates through 0 height and
     visually flattens the glyph mid-tween. Matches the control
     dropdown's chevron animation. */
  transform: rotate(180deg);
}
/* Hover the active row (the one showing the chevron) → scale the
   chevron 1.2× (matches the stepper glyph hover). When expanded the
   rotation composes with the scale. */
.tool-list li.active:hover .tool-chevron-icon { transform: scale(1.2); }
.navigator.expanded .tool-list li.active:hover .tool-chevron-icon {
  transform: rotate(180deg) scale(1.2);
}
/* Arrow-key tool-swap escape hatch — `library.js#navigate` sets this for
   one frame so flipping `.active` between rows doesn't animate (the
   dropdown isn't being opened/closed; only the active row is changing). */
.navigator.no-transition .tool-list li { transition: none; }

/* Collapsed dropdown — non-active rows are 0-height + invisible but still
   in the layout, so the expand/collapse transition can animate the four
   transitioned properties from 0 → row size and back. */
.tool-list li:not(.active) {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-width: 0;
  pointer-events: none;
}
.navigator.expanded .tool-list li:not(.active) {
  max-height: 100px;
  opacity: 1;
  padding-top: 30px;
  padding-bottom: 30px;
  border-top-width: 0.5px;
  pointer-events: auto;
}

/* ───── Component: Frame (iframe + selection) ───── */
.frame {
  position: relative;
  border: none;
  box-shadow: none;
  overflow: hidden;
  width: 100%;
  height: 100%;
  background: transparent;
}
.frame iframe {
  display: block;
  /* Absolute-positioned at .frame's top-left. Width/height are written
     by `canvas-view.js#applyFrame` as the LOGICAL base dim (no zoom
     multiplier) and visually scaled via `transform: scale(zoom)`. This
     keeps the iframe's CSS dim CONSTANT during continuous zoom (pill
     drag, pinch), so the embedded document doesn't relayout, the canvas
     inside doesn't recompute its CSS dim, and the WebGL backing buffer
     stays put — no flicker.
     Frame resize (corner drag, ratio click, Fullscreen entry) DOES
     change baseW/baseH, so the iframe relayouts then — same path as
     before. Handles + hairline live on `.frame` (which still tracks the
     full visual size via width/height) so they stay at constant pixel
     size and at the correct visual corners regardless of zoom. */
  /* Centered in .frame via top/left: 50% + a translate(-50%, -50%) baked
     into the JS-written transform alongside scale(zoom). When the frame's
     CSS dim animates during an AR transition (frame.style.width/height
     transitions), the iframe stays anchored at the frame's center — so
     the chrome shrinks/grows symmetrically inward/outward around the
     image rather than the image staying glued to the top-left corner. */
  position: absolute;
  top: 50%;
  left: 50%;
  border: none;
  background: transparent;
  transform-origin: center center;
  /* Rounded corners per Figma 386:931 — iframe clips its embedded
     content to the same 8 px corner the frame border + shadow follow. */
  border-radius: 8px;
  will-change: transform;
}
/* Selected — Figma-style "frame is contained" treatment. Driven by the
   .selected class set in player.js (updateSizeLabel) when a specific ratio
   is active OR an image with known dimensions is loaded.

   The blue selection border was retired in v61, but the four white corner
   squares stay — they read as Figma-style selection markers without the
   accent color. `overflow: visible` lets them (and the size pill) extend
   outside the frame.

   Transparency checker on the frame backing — `--color-panel` (`#202020`)
   base + `--color-input` (`#2C2C2D`) squares, 6 px tile. The iframe sits
   on top with a transparent body, so any alpha pixels in the tool's
   output reveal this checker rather than the canvas dot grid behind.

   0.5 px UI/Text hairline around the frame edge (Figma 101:1165). Painted
   as an inset box-shadow rather than `border: 0.5px solid` — sub-pixel
   border widths rasterize unevenly along an 8 px corner curve in Chrome,
   producing visibly "crunchy" segments where the border thickness shifts
   between straight edges and curves. Inset box-shadow composites cleanly.
   Position-wise the hairline lands at the same place a border would
   (centered at frame_edge - 0.25 px), so the `-4.25 px` handle offsets
   still target it correctly. */
.frame.selected {
  /* Outer drop shadow only here; the 0.5 px hairline lives on ::after
     (declared below) so it can sit ABOVE the iframe in z-order. An
     inset box-shadow on .frame itself paints between border + padding
     edge — which the iframe (100% × 100% child) covers entirely, hiding
     the shadow. */
  box-shadow: var(--shadow-frame);
  overflow: visible;
  /* Rounded corners per Figma 386:931 — same 8 px radius as labels /
     dropdowns. Hairline + shadow + checker backdrop all follow this curve. */
  border-radius: 8px;
  background-color: var(--checker-base);
  background-image: var(--checker-image);
  background-size: var(--checker-size);
  background-position: var(--checker-position);
}
/* 0.5 px UI/Text hairline — painted via a pseudo-element overlay rather
   than `border: 0.5px solid` because sub-pixel border widths rasterize
   unevenly along an 8 px corner curve in Chrome (visible as "crunchy"
   segments where border thickness shifts between straight edges and
   curves). The pseudo sits at inset: 0 with the SAME border-radius as
   .frame.selected, and uses an inset box-shadow at 0.5 px — which
   composites uniformly onto the rounded shape because it's a single
   rasterized pass over the whole rounded box. z-index lifts it ABOVE
   the iframe (which is z: auto = 0) but BELOW the handles (z: 10) and
   the extended hover zone (also pseudo-element, no z-index conflict).
   pointer-events: none keeps clicks falling through to the iframe and
   handles unchanged. */
.frame.selected::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 0.5px var(--color-text);
  pointer-events: none;
  z-index: 5;
}
/* Image reset / replace button — sits OUTSIDE the frame's top-right
   corner (bottom-left of the button touches the corner with a 10 px gap
   each way). Lives in the parent doc so it stays at fixed pixel size and
   a constant offset from the corner regardless of zoom.
   Colored per design system: Solid variant (UI/Highlight bg,
   Brand/Off-White icon) — same treatment as the in-panel Action button
   and active ratio pills. */
.frame-reset-btn {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);   /* 10 px above frame's top edge */
  left:   calc(100% + 10px);   /* 10 px past frame's right edge */
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s ease;
  z-index: 11;
}
.frame-reset-btn.visible { display: flex; }
.frame-reset-btn:hover {
  background: var(--color-stroke);
  transform: scale(1.06);
}
.frame-reset-btn:active { transform: scale(0.95); }
.frame-reset-btn svg { flex-shrink: 0; }

/* Play / edit mode button (layers.js#updateModeBtn, user 2026-11-12) —
   above the frame, flush with its LEFT edge, 10 px up like the size pill
   is 10 px down. A 22 px square, radius 6. The glyph is the ACTION (❚❚
   while playing, ▶ in edit mode). Hovering it doesn't light the frame's
   hover chrome (rules above).
     • Edit mode (▶): the universal Button look — resting UI/Input +
       UI/Text like a ratio pill; hover = Highlight bg, off-white glyph,
       1.1 scale, 10 % white wash (DESIGN-SYSTEM.md § Button hover).
     • Play mode (❚❚): the Record red (user 2026-11-12, was green) at 60 %
       resting, 100 % on hover (same 1.1 scale) — like Record while recording.
   Both dip to 0.94 while pressed. */
.frame-mode-btn {
  appearance: none;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: var(--color-input);
  color: var(--color-text);
  box-shadow: inset 0 0 0 9999px transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}
/* "Lock layers" (user 2026-11-16, was Live / play): our lock icon — grey while
   unlocked (the old play button's look), WHITE while the frame is locked. */
.frame-mode-btn.is-locked {
  background: var(--color-off-white);
  color: var(--color-off-black);
}
@media (hover: hover) {
  .frame-mode-btn:not(.is-locked):hover {
    background: var(--color-stroke-hi);
    color: var(--color-off-white);
    transform: scale(1.1);
    box-shadow: inset 0 0 0 9999px var(--color-hover-overlay);
  }
  .frame-mode-btn.is-locked:hover { transform: scale(1.1); }
  /* Press dip beats the hover scale (same specificity, declared after). */
  .frame-mode-btn:not(.is-locked):hover:active,
  .frame-mode-btn.is-locked:hover:active { transform: scale(0.94); }
}
.frame-mode-btn:active { transform: scale(0.94); }
.frame-mode-btn svg { flex-shrink: 0; display: block; width: auto; height: 12px; }
/* Right of the mode button, one row (layers.js, user 2026-11-16): "Live is
   on" / "Live is off" — the status pill's look, shown ALWAYS — then the fps
   readout (moved here from the top of the screen). Never takes the pointer. */
.frame-mode-info {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 28px;               /* 22 px button + 6 px */
  height: 22px;             /* the button's — the fps centres on it */
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  pointer-events: none;
}
.frame-mode-label.status-pill {
  position: static;
  z-index: auto;
  transform: none;
  translate: -4px 0;
  transition: opacity 0.15s ease, translate 0.15s ease;
}
.frame-mode-label.status-pill.visible { transform: none; translate: 0 0; }
.frame-mode-info .fps-counter {
  position: static;
  transform: none;
  padding: 0;
  z-index: auto;
}
/* Play mode (layers.js toggles .cimble-playing): text / image layers are
   transparent to the pointer — no hover, no click; the cimble gets it all
   (user 2026-11-12). A layer selected from the Layers popup keeps its
   handles (.layer-chrome is a separate element). */
.frame-group.cimble-playing .layer-overlay,
.frame-group.cimble-playing .layer-text-hit { pointer-events: none; }

/* ───── Recording (record.js → body.is-recording, user 2026-11-12) ─────
   Every piece of UI but the Stop button + timer leaves: the sidebar slides
   out to the right, the export pills + zoom pill down, the Layers button
   left, the fps readout up; the frame's own chrome (handles, size pill,
   mode button, layer handles / badge, frame hairline) fades. body.rec-exit
   (500 ms after Stop) plays the way back in. Animations on the separate
   `translate` / `opacity`, so no element's own transform / transition
   list is touched. */
@keyframes rec-out-right { to   { translate: calc(100% + 40px) 0; } }
@keyframes rec-in-right  { from { translate: calc(100% + 40px) 0; } }
@keyframes rec-out-down  { to   { translate: 0 calc(100% + 40px); } }
@keyframes rec-in-down   { from { translate: 0 calc(100% + 40px); } }
@keyframes rec-out-left  { to   { translate: calc(-100% - 40px) 0; } }
@keyframes rec-in-left   { from { translate: calc(-100% - 40px) 0; } }
@keyframes rec-out-up    { to   { translate: 0 calc(-100% - 40px); } }
@keyframes rec-in-up     { from { translate: 0 calc(-100% - 40px); } }
@keyframes rec-fade-out  { to   { opacity: 0; } }
@keyframes rec-fade-in   { from { opacity: 0; } }
body.is-recording .controls,
body.is-recording .layers-fab,
body.is-recording .export-pills > :not(#recordBtn):not(#recordTimer),
body.is-recording .zoom-pill,
body.is-recording .fps-counter,
body.is-recording .app-corner,
body.is-recording .frame-handle,
body.is-recording .frame-size-pill,
body.is-recording .frame-mode-btn,
body.is-recording .frame-mode-label,
body.is-recording #layerChromeHost > *,
body.is-recording #layerBadgeHost,
body.is-recording #snapGuidelineHost,
body.is-recording .offscreen-pill,
body.is-recording .canvas-upload-btn,
body.is-recording .frame.selected::after {
  animation: rec-fade-out 0.4s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none !important;
}
/* Their insides set pointer-events: auto (handles, the badge) — off too. */
body.is-recording #layerChromeHost *,
body.is-recording #layerBadgeHost * { pointer-events: none !important; }
body.is-recording .controls { animation-name: rec-out-right; }
body.is-recording .layers-fab { animation-name: rec-out-left; }
body.is-recording .export-pills > :not(#recordBtn):not(#recordTimer),
body.is-recording .zoom-pill { animation-name: rec-out-down; }
body.is-recording .fps-counter { animation-name: rec-out-up; }
body.is-recording .app-corner { animation-name: rec-out-left; }
body.rec-exit .controls,
body.rec-exit .layers-fab,
body.rec-exit .export-pills > :not(#recordBtn):not(#recordTimer),
body.rec-exit .zoom-pill,
body.rec-exit .fps-counter,
body.rec-exit .app-corner,
body.rec-exit .frame-handle,
body.rec-exit .frame-size-pill,
body.rec-exit .frame-mode-btn,
body.rec-exit .frame-mode-label,
body.rec-exit #layerChromeHost > *,
body.rec-exit #layerBadgeHost,
body.rec-exit .frame.selected::after {
  animation: rec-fade-in 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
body.rec-exit .controls { animation-name: rec-in-right; }
body.rec-exit .layers-fab { animation-name: rec-in-left; }
body.rec-exit .export-pills > :not(#recordBtn):not(#recordTimer),
body.rec-exit .zoom-pill { animation-name: rec-in-down; }
body.rec-exit .fps-counter { animation-name: rec-in-up; }
body.rec-exit .app-corner { animation-name: rec-in-left; }
/* Phone: the controls are a bottom sheet and the Layers button sits in the
   export row — both go DOWN. */
body.is-mobile.is-recording .controls,
body.is-mobile.is-recording .layers-fab { animation-name: rec-out-down; }
body.is-mobile.rec-exit .controls,
body.is-mobile.rec-exit .layers-fab { animation-name: rec-in-down; }
/* Frame locked (user 2026-11-16 — it used to slide away): the Layers button
   STAYS, greyed out like the other buttons that do nothing right now (the
   zoom pill: 40 %, not-allowed) — no hover lift; hovering it shows "Unlock
   frame to add layers" (layers.js#showHint). Recording still slides it out. */
.layers-fab.is-live-locked { background: var(--color-panel); color: var(--color-stroke-hi); cursor: default; }   /* greyed (2026-11-17; was 40 %); the cursor stays the arrow (user 2026-11-17: was not-allowed) */
/* Tooltips (hints.js, user 2026-11-16 — "like the lock's"): the status
   pill's look beside the hovered button, sliding in from the button's side
   (data-side = right | left | top | bottom, set by hints.js). Above every
   popup / picker / dialog. A long text (an example prompt) wraps. */
.status-pill.ui-hint {
  top: 0;
  left: 0;
  z-index: 1001;
  transform: translate(-6px, -50%);
}
.status-pill.ui-hint.visible { transform: translate(0, -50%); }
.status-pill.ui-hint[data-side="left"] { transform: translate(calc(-100% + 6px), -50%); }
.status-pill.ui-hint[data-side="left"].visible { transform: translate(-100%, -50%); }
.status-pill.ui-hint[data-side="top"] { transform: translate(-50%, calc(-100% + 6px)); }
.status-pill.ui-hint[data-side="top"].visible { transform: translate(-50%, -100%); }
.status-pill.ui-hint[data-side="bottom"] { transform: translate(-50%, -6px); }
.status-pill.ui-hint[data-side="bottom"].visible { transform: translate(-50%, 0); }
.status-pill.ui-hint.is-long {
  height: auto;
  max-width: 280px;
  padding: 6px 8px;
  white-space: normal;
}
/* Fullscreen keeps the current mode (user 2026-11-12): the button moves to
   the top-left corner — the frame fills the viewport, so its usual spot is
   off-screen. .frame-group sits at the viewport origin there (pan locked
   at 0). The fps readout is top-centre now (2026-11-15) and Back / the
   logo hide in fullscreen, so the corner is free. */
body.fullscreen .frame-mode-btn,
body.fullscreen .frame-mode-info {
  top: 10px;
  bottom: auto;
  left: 10px;
  z-index: 12;
}
body.fullscreen .frame-mode-info { left: 38px; }
/* The cimble's badge would clamp into the corner under the sidebar. */
body.fullscreen .layer-settings-badge[data-cimble] { display: none; }

.frame-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--color-off-white);
  /* 0.5px UI/Text border + drop shadow per Figma 386:931 (Hover_Dark). */
  border: 0.5px solid var(--color-text);
  box-shadow: var(--shadow-handle);
  z-index: 10;
  /* `touch-action: none` keeps mobile/trackpad gestures from being eaten
     by the browser's scroll/zoom while we're handling the drag in JS. */
  touch-action: none;
  /* Hidden at rest; fades in only when the frame group is hovered
     (rule below). Matches the controls-resize-handle treatment.
     pointer-events:none while invisible so accidental clicks near a
     frame corner don't trigger a resize before the handles appear. */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
/* Extended hit target — the visible square is 8 px but pointer events
   register inside this 24 × 24 box, so users can grab the corner without
   being pixel-perfect. Sits behind the visible square (negative inset). */
.frame-handle::before {
  content: "";
  position: absolute;
  inset: -8px;
}
/* Frame handles show ONLY while the cimble is SELECTED (a click on the
   frame in edit mode, or its Layers row) — `.cimble-active`, below — with
   its rect kept on. Hovering the cimble draws that rect alone, exactly like
   a text / image layer (layers.js, user 2026-11-12). The size pill shows
   only while selected too (rule further down). Both used to appear on any
   frame-group hover — including hovering a layer inside the frame. */
/* `.cimble-active` is set on `.frame-group` by layers.js while the cimble
   is the selected layer — parallels a selected text / image layer, which
   shows THAT layer's handles + badge until elsewhere is clicked. */
.frame-group.cimble-active .frame.selected .frame-handle {
  opacity: 1;
  pointer-events: auto;
}
/* Uniform `-4.25 px` offsets per Figma 101:1165 — the 8 px handle sits
   centered on the frame's 0.5 px UI/Text border (4 px overhang + 0.25 px
   border-center alignment). Corners use both axes; the mid-edge handles
   center themselves on the unconstrained axis via translate. */
.frame-handle-tl { top: -4.25px;    left: -4.25px;  cursor: nwse-resize; }
.frame-handle-tr { top: -4.25px;    right: -4.25px; cursor: nesw-resize; }
.frame-handle-bl { bottom: -4.25px; left: -4.25px;  cursor: nesw-resize; }
.frame-handle-br { bottom: -4.25px; right: -4.25px; cursor: nwse-resize; }
.frame-handle-t  { top: -4.25px;    left: 50%;      transform: translateX(-50%); cursor: ns-resize; }
.frame-handle-b  { bottom: -4.25px; left: 50%;      transform: translateX(-50%); cursor: ns-resize; }
.frame-handle-l  { top: 50%;        left: -4.25px;  transform: translateY(-50%); cursor: ew-resize; }
.frame-handle-r  { top: 50%;        right: -4.25px; transform: translateY(-50%); cursor: ew-resize; }
/* Frame + size pill are wrapped in `.frame-group` so they center as a unit
   inside `.canvas-area`. The pill is in normal flow now (no absolute
   positioning), separated from the frame by the group's `gap`. */
.frame-group {
  position: relative; /* anchor for the absolute-positioned size pill */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: opacity 150ms ease;
}
/* Tool-switch / site-load placeholder. `player.js#loadTool` adds
   `.transitioning` to `#stage`; while it's on, every chrome element
   (frame-group, zoom pill, export pills, upload button, off-screen
   pill, sidebar contents) is hidden and shimmer-skeleton stand-ins
   render in their place — all reveal together when endTransition
   drops the class. */
.stage.transitioning .frame-group           { display: none; }
.stage.transitioning ~ .zoom-pill,
.stage.transitioning ~ .canvas-upload-btn,
.stage.transitioning ~ .offscreen-pill,
.stage.transitioning ~ .export-pills        { display: none; }
/* During the transition, NOTHING in the sidebar shows except the
   skeleton — including the navigator (tool list), the static Size
   group with its label + Reset link, the Aspect Ratio sub-label, and
   any dynamic controls built mid-transition (rebuildControls runs as
   soon as cfg_schema arrives). The skeleton is the single visible
   sidebar state until endTransition drops the class, at which point
   everything reveals at once.
   A sibling selector, not `body:has(.stage.transitioning)` (2026-11-17): a
   :has() on body made ANY text change anywhere (the fps readout, value
   readouts, pills) re-check the whole document's styles. #stage comes
   before aside#controls, both children of <body>. */
.stage.transitioning ~ .controls .controls-body > :not(.controls-skeleton) {
  display: none;
}
/* Single full-viewport canvas skeleton. Covers everything outside the
   sidebar (canvas, frame, zoom pill, export pills, upload button, off-
   screen pill) with one shimmer wipe — the sidebar (z-index 10) sits
   on top with its own .controls-skeleton inside. */
.canvas-skeleton {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.stage.transitioning ~ .canvas-skeleton { display: block; }

/* Controls-panel skeleton — sits below the static "Size" group. Shown
   only while the stage is transitioning; clearControls leaves the
   data-preserve container intact, and once buildControls populates
   the real controls, the visibility selector turns the skeleton off. */
.controls-skeleton { display: none; }
body:has(.stage.transitioning) .controls-skeleton {
  display: flex;
  flex-direction: column;
  width: 100%;
}
/* Navigator block at the top (Figma 205:1660): a 83 px tall rounded-14
   rectangle wrapped in a py-10 spacer that matches the real
   .navigator-wrap padding. Carries the frame shadow so the reveal
   slides cleanly into the populated Navigator. */
.skeleton-nav-wrap { padding: 10px 0; width: 100%; }
.skeleton-nav {
  height: 83px;
  border-radius: 14px;
}
.skeleton-bar-shadow { box-shadow: var(--shadow-frame); }
/* Per-section skeleton block — mirrors a real .ctrl-group's outer
   geometry (px-20 py-40 + 0.5 px top border from the second onward)
   so the populated panel reveals at the same layout. Inside each
   section the inner stack uses 12 px gap. */
.skeleton-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 40px 20px;
  width: 100%;
}
.skeleton-section + .skeleton-section {
  border-top: 0.5px solid var(--color-stroke-hi);
}
.skeleton-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
/* Bar sizes per Figma 205:1657: section header 40, label row 16,
   input surface 99. All rounded-8, all UI/Input bg with shimmer. */
.skeleton-bar { border-radius: 8px; }
.skeleton-bar-header { height: 40px; width: 100%; }
.skeleton-bar-label  { height: 16px; width: 100%; }
.skeleton-bar-input  { height: 99px; width: 100%; }

/* Shared shimmer treatment — single straight vertical band wiping
   left → right (90deg gradient axis = vertical color stops). Broad
   highlight (25% → 75%) so the wipe reads as a band, not a thin line.
   Animation runs TWICE then holds on the final off-screen frame
   (forwards fill-mode), so after the two passes the skeleton sits
   on the solid base color until endTransition hides it. Colors are
   strictly design-system tokens, paired to the surface underneath:
     • Canvas skeleton: Background → Panel highlight (sits on the
       canvas, so the wipe lifts to the next-step-up token).
     • Sidebar bars: Input → Stroke Highlight (sit on Panel, so the
       same +1-step relationship applies). */
.canvas-skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-canvas) 0%,
    var(--color-bg-canvas) 25%,
    var(--color-panel)     50%,
    var(--color-bg-canvas) 75%,
    var(--color-bg-canvas) 100%
  );
  background-size: 250% 100%;
  animation: skeleton-shimmer 0.7s linear 2 forwards;
}
.skeleton-bar,
.skeleton-nav {
  background: linear-gradient(
    90deg,
    var(--color-input) 0%,
    var(--color-input) 25%,
    var(--color-stroke-hi) 50%,
    var(--color-input) 75%,
    var(--color-input) 100%
  );
  background-size: 250% 100%;
  animation: skeleton-shimmer 0.7s linear 2 forwards;
}

/* Highlight band enters off-screen right, sweeps left. Linear, no
   easing — keeps the wipe rhythmic across both passes. */
@keyframes skeleton-shimmer {
  0%   { background-position: 150% 0; }
  100% { background-position: -150% 0; }
}
/* ───── Component: Tiny pill (Figma 460:1241) ─────
   Shared base for every C1-sized pill in the player: Pixel Size,
   Zoom, Off-screen, and the sidebar keyword pills. C1 typography
   (450, 11.5 / 14, +0.75), 22 px tall, 6 px radius, 6 px padding,
   1 px gap between content spans (4 px in the text-icon variant).
   Concrete variants override only background + padding-asymmetry +
   gap as needed. */
.c1-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
  height: 22px;
  /* Figma 460:1241 (refresh): vertical 6, horizontal 7 — tiny pills
     read a touch wider than tall. Variants override per direction. */
  padding: 6px 7px;
  gap: 1px;
  background: var(--color-input);
  color: var(--color-text);
  font: 500 11.5px/14px var(--font-display);
  letter-spacing: 0.75px;
  border-radius: 6px;
  white-space: nowrap;
}

/* Pixel Size pill — Figma component 164:694. Two <input>s (W, H) and a
   middle "x" separator. Padding 4/7/5/7 (the extra 1 px at bottom
   optically centers the descenderless digits). The inputs are
   editable — type a value + Enter / blur to commit, Up / Down arrow
   to step by 1 (Shift = 10). Wired in ratio.js#setupSizePill. */
.frame-size-pill {
  display: none;
  /* Resting tiny-pill treatment (inherited from .c1-pill: bg
     --color-input, color --color-text). Only the pill ITSELF being
     hovered swaps to the active treatment (bg --color-stroke-hi, see
     :hover rule below); frame hover surfaces the pill but doesn't
     light it up. Individual W / H inputs light up their own value to
     off-white via the .frame-size-pill-value:hover rule further down. */
  transition: none;
  /* `pointer-events: auto` so cursor on the pill (including the empty
     padding zones around the W / H inputs and the "x" separator)
     registers as hovering the pill — which keeps the .frame-group:hover
     state alive when the cursor moves from the frame down onto the pill.
     `pointer-events: none` here previously made the pill invisible to
     hit-testing, so the cursor passed through to whatever was behind
     (canvas-area background) and .frame-group:hover dropped, hiding the
     pill mid-move. The inputs inside still set their own `pointer-events:
     auto` for editing. */
  pointer-events: auto;
  /* Absolute-positioned below the frame (`top: 100% + 10 px` resolves
     against .frame-group's height — since the pill is OUT of the flex
     flow, the group sizes to the frame alone). Keeping the pill out of
     flex sizing is essential for Fullscreen mode: when the frame fills
     the viewport, any flex-flow child below it would push the frame
     off-center / above the viewport top. Now the pill simply trails the
     frame's bottom edge regardless of frame size — in normal mode it
     sits 10 px below the frame; in Fullscreen the frame's bottom is at
     the viewport bottom, so the pill ends up just below the viewport
     (no separate hide rule needed, the flex layout handles it). */
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
}
/* The size pill shows only once the cimble is SELECTED (a click on the frame
   in edit mode, or its Layers row) — with its handles (user 2026-11-12;
   briefly it showed throughout edit mode). */
.frame.selected ~ .frame-size-pill { display: none; }
.frame-group.cimble-active .frame.selected ~ .frame-size-pill { display: inline-flex; }
/* Pill itself hovered → active treatment (bg lift). Which W / H values
   light up is decided by the highlight rules near the bottom of this
   block (both axes by default; only the hovered one in Shift/solo mode). */
/* The size pill is the cimble's — PURPLE like its selection rect + ⋯ badge
   (user 2026-11-12), instead of the grey c1-pill. Background: 60 % at
   rest, 100 % on hover AND while the cimble is selected (.cimble-active —
   in practice always, it only shows then). Text: 80 % white at rest (user
   2026-11-15, was 60 %), 100 % on hover. Shift-solo still lights only the
   hovered value (rules below). */
.frame-size-pill {
  background: color-mix(in srgb, var(--color-accent-purple) 60%, transparent);
  color: rgb(247 247 247 / 0.8);
}
.frame-size-pill:hover,
.frame-group.cimble-active .frame-size-pill { background: var(--color-accent-purple); }
/* Text (user 2026-11-16): WHITE while the cimble is picked (in practice
   always — it only shows then). Without Shift, hovering / dragging dims
   both values to 80 % (a drag changes both). With Shift (user 2026-11-17,
   swapped): the hovered — or dragged — value stays WHITE and the other
   goes 80 %. Rules below the value styles; same on the layers' blue pill. */
.frame-group.cimble-active .frame-size-pill { color: var(--color-off-white); }
.frame-group.cimble-active .frame-size-pill:not(.shift-solo):hover { color: rgb(247 247 247 / 0.8); }
/* A text / image layer's size pill (user 2026-11-16): the frame's pixel pill
   in the layers' BLUE, centred 10 px under the selected layer (inside its
   chrome, so it follows drags and zoom); W × H in base px. Dragging it
   scales the layer from its centre (layers.js#wireSizePillScrub). Text
   colours like the cimble's (see above). */
.layer-size-pill {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-accent);
  color: var(--color-off-white);
  white-space: nowrap;
  pointer-events: auto;
  cursor: ew-resize;
  touch-action: none;
  z-index: 3;
  transition: none;
}
.layer-size-pill:not(.shift-solo):hover,
.layer-size-pill.shift-solo:has(.layer-size-v:hover),
.layer-size-pill .layer-size-v.hl { color: rgb(247 247 247 / 0.8); }
/* Shift (user 2026-11-17, swapped): the hovered / dragged value stays white. */
.layer-size-pill.shift-solo .layer-size-v:hover,
.layer-size-pill:has(.layer-size-v:not(.hl)) .layer-size-v.hl { color: var(--color-off-white); }
.layer-size-pill:has(.layer-size-v.hl) .layer-size-v:not(.hl) { color: rgb(247 247 247 / 0.8); }
.layer-size-pill .layer-size-v { transition: none; }
body.is-recording .layer-size-pill { display: none; }
.frame-size-pill:not(.shift-solo):hover { color: var(--color-off-white); }
/* Without Shift the WHOLE pill scrubs — the "×" and the padding scale the
   frame uniformly too, like W / H (ratio.js#beginScrub, user 2026-11-12);
   with Shift only W / H drag (one axis each). */
.frame-size-pill:not(.shift-solo) { cursor: ew-resize; }
/* Re-enable pointer events on the inputs only so the rest of the pill
   chrome (incl. the "x" separator) stays click-through. */
.frame-size-pill-value {
  pointer-events: auto;
  field-sizing: content;
  min-width: 1ch;
  padding: 0;
  margin: 0;
  border: none;
  outline: none;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: center;
  /* ew-resize hints at the drag-scrub affordance (Figma-style scrubby
     slider); native text caret takes over once focused. */
  cursor: ew-resize;
  -moz-appearance: textfield;
  transition: none;
}
.frame-size-pill-value::-webkit-outer-spin-button,
.frame-size-pill-value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.frame-size-pill-value:focus {
  color: var(--color-off-white);
  cursor: text;
}
/* While a scrub is in flight, force ew-resize cursor everywhere so it
   stays consistent as the pointer moves off the input — mirrors the
   .zoom-scrubbing pattern. */
body.size-scrubbing,
body.size-scrubbing * { cursor: ew-resize !important; }

/* Zoom-level pill — Figma component 237:2152. Placed at the BOTTOM
   CENTER of the visible canvas region (full viewport minus the
   controls sidebar) with 40 px padding from the bottom edge. The
   centered placement mitigates the drag-stops-at-edge limitation
   (Pointer Lock would solve it but triggers non-suppressible browser
   toasts) — from center, the user has half-viewport width on each
   side before hitting an edge.
   C1 chassis with the "Solid" color treatment (bg `--color-stroke-hi`
   `#414144`, text `--color-off-white` `#F7F7F7`) — more prominent than
   the Pixel Size pill which uses the "Input" treatment. Interactive:
   drag-to-scrub the number, or click to focus the inner <input> and
   type a value. `canvas-view.js#setupZoomPill` wires the listeners;
   `.zoom-scrubbing` on body forces ew-resize cursor during a drag. */
.zoom-pill {
  position: fixed;
  bottom: 20px;
  left: 20px;   /* bottom-left (user 2026-11-16, was centred — the export row is there now) */
  z-index: 11;
  /* Per Figma 460:1420 the resting Zoom pill uses bg --color-input
     (inherited from .c1-pill) and Hover surfaces bg --color-stroke-hi
     with the text in off-white — see the :hover rule below. */
  /* Reserve content width for the 3-digit case ("100%" / "200%") so the
     pill stays the same size at every zoom level; shorter values like
     "50%" then center as a "digits %" group within this footprint via
     .c1-pill's justify-content. */
  min-width: calc(4ch + 4px);
  cursor: ew-resize;
  user-select: none;
  transition: opacity 0.4s ease;   /* opacity: the Live / Fullscreen fade */
}
.zoom-pill:hover {
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
}
/* Pixel pill highlight:
   • Default (uniform drag) — hovering anywhere on the pill lights up BOTH
     W and H, signalling the next drag scales both axes together.
   • Shift held (.shift-solo, toggled by ratio.js while hovering) — only the
     input under the cursor lights up; the next drag changes that axis alone.
   • .hl is set by ratio.js on the changing input(s) during an active scrub
     so they stay lit even when the pointer leaves the input box.
   The "x" separator is never a .frame-size-pill-value, so it stays dim. */
.frame-size-pill-value.hl { color: rgb(247 247 247 / 0.8); }
/* Shift + a value hovered: the rest of the pill dims, that value stays white. */
.frame-group.cimble-active .frame-size-pill.shift-solo:has(.frame-size-pill-value:hover) { color: rgb(247 247 247 / 0.8); }
.frame-size-pill.shift-solo .frame-size-pill-value:hover { color: var(--color-off-white); }
/* A one-axis (Shift) drag — one value .hl: it stays white, the other dims. */
.frame-size-pill:has(.frame-size-pill-value:not(.hl)) .frame-size-pill-value.hl { color: var(--color-off-white); }
.frame-size-pill:has(.frame-size-pill-value.hl) .frame-size-pill-value:not(.hl) { color: rgb(247 247 247 / 0.8); }
.zoom-pill-value {
  /* Reset native input chrome — the input has to look identical to a
     plain <span> until focused. `field-sizing: content` sizes the
     input to its current value so "8%", "50%", "100%" all read as a
     single centered unit, rather than living inside a fixed 3ch box
     that leaves a stray gap before the % glyph for short values. */
  field-sizing: content;
  min-width: 1ch;
  padding: 0;
  margin: 0;
  border: none;
  outline: none;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: center;
  /* Drag cursor everywhere on the pill — including over the digits,
     not just the % span. Native text inputs default to `cursor: text`;
     override here so the drag affordance is consistent, then :focus
     swaps to text cursor for the typing flow. */
  cursor: ew-resize;
  /* Hide the native number-input spinner buttons. */
  -moz-appearance: textfield;
}
.zoom-pill-value::-webkit-outer-spin-button,
.zoom-pill-value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.zoom-pill-value:focus {
  /* Subtle hint that the field is now in edit mode. */
  color: var(--color-off-white);
  cursor: text;
}

/* While zoom drag-scrub is active, force ew-resize cursor everywhere —
   pointer may move off the pill but the cursor should stay consistent. */
body.zoom-scrubbing,
body.zoom-scrubbing * { cursor: ew-resize !important; }
.zoom-pill.hidden { display: none; }

/* Off-screen pill — Figma component 249:2200 (6 variants: Left, Right,
   LeftUp, LeftDown, RightUp, RightDown). One DOM node; class swaps
   pick the variant. Position is set inline by
   canvas-view.js#updateOffscreenPill so the pill tracks the iframe's
   center clamped to the viewport (10 px inside each edge). Sits on top
   of everything (incl. the controls sidebar at z-index 10) so it stays
   clickable even when the iframe has been panned far right past the
   sidebar. `visibility: hidden` by default — not `display: none` — so
   `offsetWidth/Height` are measurable for the clamp math before the
   pill is shown. */
.offscreen-pill {
  position: fixed;
  z-index: 50;
  visibility: hidden;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  /* Off-screen variant of the tiny pill (Figma 460:1548…460:1573,
     refresh): off-white surface with the lighter --shadow-pill
     elevation (`0 0 10 px rgba(0,0,0,0.2)`, matching Figma's
     drop-shadow exactly), off-black text, 22 px tall, 6 px radius,
     fixed width 138 px. Asymmetric padding applied per direction
     below: horizontal arrows (Left/Right) use 5 / 7; diagonal arrows
     (Up/Down on either side) use 6 / 7. */
  height: 22px;
  width: 138px;
  gap: 4px;
  padding: 6px 7px;
  background: var(--color-off-white);
  color: var(--color-off-black);
  border: none;
  border-radius: 6px;
  font: 500 11.5px/14px var(--font-display);
  letter-spacing: 0.75px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  filter: drop-shadow(var(--shadow-pill));
  /* Center the pill on its (left, top) anchor point — JS writes those
     two values, the transform handles the half-size offset so we don't
     need pill dimensions on the JS side for positioning. */
  transform: translate(-50%, -50%);
  transition: opacity 0.15s ease;
}
.offscreen-pill.visible {
  visibility: visible;
  pointer-events: auto;
}
.offscreen-pill:hover { opacity: 0.85; }
.offscreen-pill-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 6px;
  height: 6px;
  flex-shrink: 0;
}
.offscreen-pill-arrow svg {
  display: block;
  width: 6px;
  height: auto;
}
/* Variant: arrow side. Only one of the two arrow spans is shown at a
   time; the other is `display: none`. Default HTML always renders
   both, so we hide the inactive one via :not(). */
.offscreen-pill:not(.arrow-left)  .offscreen-pill-arrow-left  { display: none; }
.offscreen-pill:not(.arrow-right) .offscreen-pill-arrow-right { display: none; }
/* Variant: arrow direction. Base SVG = down-chevron, rotated per
   `direction-*`. `direction-down` keeps the SVG as-is. */
.offscreen-pill.direction-left  .offscreen-pill-arrow svg { transform: rotate(90deg); }
.offscreen-pill.direction-right .offscreen-pill-arrow svg { transform: rotate(-90deg); }
.offscreen-pill.direction-up    .offscreen-pill-arrow svg { transform: rotate(180deg); }
/* Per-direction padding asymmetry (Figma 460:1548…460:1573 refresh):
   horizontal arrows (Left/Right) cuddle tight against their side at
   5 px; diagonal arrows (Up/Down on either side) keep a touch more
   breathing room at 6 px. Text side always gets the wider 7 px. */
.offscreen-pill.arrow-left.direction-left   { padding-left: 5px;  padding-right: 7px; }
.offscreen-pill.arrow-right.direction-right { padding-left: 7px;  padding-right: 5px; }
.offscreen-pill.arrow-left:not(.direction-left)   { padding-left: 6px; padding-right: 7px; }
.offscreen-pill.arrow-right:not(.direction-right) { padding-left: 7px; padding-right: 6px; }

/* ───── Component: Pill (base) ─────
   Shared shape + typography for every pill-shaped button (ratio, export,
   in-panel Action). Color variants below pick the bg/text combination. */
.ratio-pill,
.export-pill {
  position: relative; /* anchor for the ::after hairline overlay variants */
  border: none;
  border-radius: var(--radius-pill);
  /* Canonical pill padding — 18 px vertical / 20 px horizontal.
     Shared by every design-system pill button (.ratio-pill,
     .export-pill, .canvas-upload-btn, .btn-ctrl) so they read as
     one component family. See DESIGN-SYSTEM.md § "Pill button". */
  padding: 18px 20px;
  font: 600 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex-shrink: 0;
  pointer-events: auto;
  transition: transform   0.15s ease,
    opacity     0.15s ease;
}
/* Lift the export-row pills off the canvas — in Fullscreen the row sits
   directly over arbitrary tool output and would otherwise blend in. The
   ratio-pill row sits inside the controls panel so it doesn't need the
   shadow.
   The trailing `inset 0 0 0 9999px transparent` is a no-op visually but
   creates a stable starting layer for the hover overlay — the :hover
   rule below swaps its color to rgba(255,255,255,0.1) and the transition
   tweens cleanly because both states have the same shadow-list length. */
.export-pill {
  /* Text pills (2x / PNG / Timer) inherit the canonical 56 px button
     height. Discs (Capture / Record / Settings) override below with
     --btn-export-h so they read as the heavier bookends of the row. */
  min-height: var(--btn-h);
  box-shadow: var(--shadow-frame), inset 0 0 0 9999px transparent;
}

/* Ratio pill row — sits inside the Canvas section in the controls panel.
   Pills wrap onto multiple rows when the panel is too narrow. */
.ratio-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  width: 100%;
}
.ratio-pill {
  min-width: 64px;
  /* Canonical 56 px in-panel button height (--btn-h). Locks via
     min-height so font-metric drift below the 17 px line-box can't
     shrink the pill below the shared baseline. */
  min-height: var(--btn-h);
  background: var(--color-input);
  color: var(--color-text);
  /* Transparent inset baseline so the shared hover overlay can tween
     in cleanly (see hover rule below). */
  box-shadow: inset 0 0 0 9999px transparent;
}
/* Shared button-hover (Figma 118:542 ButtonHover treatment): scale 1.1
   + 10 % white overlay + bg lifts to --color-stroke-hi + text → off-
   white. Same effect as .export-pill and .btn-ctrl; ratio pills now
   match across all three surfaces. The :not(.active) gate skips this
   for the currently-selected pill — it's already at the "active"
   visual state, so re-applying the lift on hover would just stack on
   top of itself. Active pill keeps its style and does nothing on
   hover. */
/* Hover treatments are scoped to (hover: hover) — devices with a
   real cursor (mouse, trackpad, pen). On touch-only devices iOS
   Safari sticks the :hover state after a tap, so the visual lift
   re-fires when the user closes a popup with a second tap.
   Wrapping the rule in this media query suppresses hover styles
   entirely on touch, while leaving keyboard / mouse hover intact. */
/* Also on the ACTIVE pill (user 2026-11-17 — like the open Layers button):
   it keeps its highlight and gets the lift + wash on hover. A wide pill grows
   by the same few px as a round button (hover-grow.js → --hover-grow). */
@media (hover: hover) {
  .ratio-pill:not(.suppress-hover):hover {
    background: var(--color-stroke-hi);
    color: var(--color-off-white);
    transform: scale(var(--hover-grow, 1.1));
    box-shadow: inset 0 0 0 9999px var(--color-hover-overlay);
  }
}
.ratio-pill.active { background: var(--color-stroke-hi); color: var(--color-off-white); }
/* Whole-pixel widths for buttons sized by their text (user 2026-11-17): a
   text's width is fractional ("Fullscreen" made a 105.44 px pill), so its
   edges — and everything after it — fell between pixels, and the hover's
   redraw at the end of the transition could land a pixel off. Rounded UP to
   the next whole px (calc-size: Chrome 129+; elsewhere the width stays). */
@supports (width: calc-size(fit-content, round(up, size, 1px))) {
  .ratio-pill, .btn-ctrl, .ctrl-group-reset { width: calc-size(fit-content, round(up, size, 1px)); }
}
/* Click-bounce: while the pointer is pressed, dip to 0.96 then spring
   back via the existing transform transition. The `:hover:active`
   variant is needed because the hover rule above sets `transform:
   scale(1.1)` at the same specificity (0,3,0) as the bare
   `:not(.active):active` rule — without the combined `:hover:active`
   tie-breaker, press-while-hover stays at scale(1.1) and the bounce
   never paints. */
.ratio-pill:active             { transform: scale(0.94); }
@media (hover: hover) {
  .ratio-pill:not(.suppress-hover):hover:active { transform: scale(0.94); }
}
/* A right press on a menu cycle pill (4s → 8s, JPG → PNG; right-click =
   back) dips too — settings-ui.js sets .is-pressed (user 2026-11-17). */
.ratio-pill.is-pressed,
.ratio-pill.is-pressed:not(.suppress-hover):hover { transform: scale(0.94); }

/* Disabled state — fired by player.js#updateSizeLabel when an
   image-required tool has no image loaded yet. All pills read as
   greyed-out (Input bg + UI/Highlight text, arrow cursor, no hover
   lift / scale / wash); clicking still routes through ratio.js but
   the app callback redirects to a shake of the upload button
   instead of activating the ratio. The `.ratio-pill:not(.active)`
   hover rule above is also overridden so hovering doesn't lift. */
#ratioPills.disabled .ratio-pill,
#ratioPills.disabled .ratio-pill.active,
#ratioPills.disabled .ratio-pill:not(.suppress-hover):hover {
  background: var(--color-panel);   /* greyed (2026-11-17; was UI/Input) */
  color: var(--color-stroke-hi);
  cursor: default;
  transform: none;
  box-shadow: inset 0 0 0 9999px transparent;
}
#ratioPills.disabled .ratio-pill:active { transform: none; }
/* Dedicated Custom pill — owned by ratio.js, rendered at the leftmost
   position in the row, pushed in only after a corner-drag has saved a
   manual size (or while one is mid-drag). `display: none` keeps it out
   of the layout entirely until shown, so the regular pills sit flush
   against the section's left padding by default. */
.ratio-pill-custom { display: none; }
.ratio-pill-custom.visible { display: inline-flex; }
/* Generic hide for ratio pills — used by refreshPillState to drop the
   Original pill when an active predefined ratio matches the loaded
   image's aspect (so Original isn't redundant with that predefined). */
.ratio-pill.hidden { display: none; }

/* Export pill row — viewport-anchored, bottom-left. Uses `position: fixed`
   so it stays put without depending on body's layout being a positioning
   context (body is plain block now, not grid). */
.export-pills {
  position: fixed;
  bottom: 20px;
  /* Centred on the window like on a phone (user 2026-11-16, was bottom-left) —
     the frame's centre is the window's centre too. */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  z-index: 11;
  transition: opacity 200ms ease;
}
/* Hidden when the active tool needs a user upload but none has landed yet
   (`player.js#updateExportVisibility`). Faded out + non-interactive rather
   than display:none so the row can ease in once an image arrives. */
.export-pills.hidden {
  opacity: 0;
}
.export-pills.hidden .export-pill { pointer-events: none; }
/* Hover lift (Figma 118:542 "ButtonHover" treatment): scale 1.1 +
   10 % white overlay + bg lifts from --color-input to
   --color-stroke-hi + text/icon brightens from --color-text to
   --color-off-white. Skipped on :disabled so a busy Capture button
   doesn't pop, and on .recording so the active red Record button
   keeps its accent color (only overlay + scale, no bg change). */
/* Hover treatments scoped to (hover: hover) — see the .ratio-pill
   hover block above for the iOS sticky-hover rationale. */
@media (hover: hover) {
  .export-pill:not(:disabled):not(.recording):not(.suppress-hover):hover {
    background: var(--color-stroke-hi);
    color: var(--color-off-white);
    transform: scale(1.1);
    box-shadow: var(--shadow-frame), inset 0 0 0 9999px var(--color-hover-overlay);
  }
  .export-pill.recording:not(:disabled):not(.suppress-hover):hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-frame), inset 0 0 0 9999px var(--color-hover-overlay);
  }
}
/* Settings popup is open → keep the settings disc in the highlighted
   resting treatment (bg lift + off-white icon + shadow) so it reads
   as the active anchor of the open popup. NO scale here — the
   `:hover` rule above (higher specificity) re-applies scale(1.1)
   only when the cursor is over the active button, signalling
   "click again to close". Same shape as the layers FAB's
   `[aria-expanded="true"]` rule. */
.export-pill-settings[aria-expanded="true"] {
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
  box-shadow: var(--shadow-frame), inset 0 0 0 9999px var(--color-hover-overlay);
}
.export-pill-settings[aria-expanded="true"]:not(:active) { transform: scale(1.1); }   /* active = enlarged (user 2026-11-17) */
/* Click-bounce: pointerdown dips to 0.96, release springs back via the
   existing transform transition. Selectors MUST mirror the hover rules above
   at full specificity (0,5,0) — INCLUDING `:not(.suppress-hover)`. Without that
   the hover's scale(1.1) [(0,5,0)] out-specifies active's scale(0.94) during
   press-while-hover (which is always, since you hover what you click) and the
   bounce is invisible. Source order, active last, gives the equal-specificity
   tiebreaker. */
.export-pill:not(:disabled):not(.recording):not(.suppress-hover):active { transform: scale(0.94); }
.export-pill.recording:not(:disabled):not(.suppress-hover):active       { transform: scale(0.94); }
.export-pill:disabled { background: var(--color-panel); color: var(--color-stroke-hi); cursor: not-allowed; }   /* greyed (2026-11-17; was 40 %) */
/* Color variants (Figma 118:542):
     • Capture (.export-pill-dl) — circular icon button, UI/Input bg,
       UI/Text grey camera icon at rest. Hover lifts both via the shared
       .export-pill hover rule below (bg → stroke-hi + 10 % white
       overlay + scale 1.1, color → off-white). Figma 393:1423.
     • Record (.export-pill-record) — same resting treatment as Capture
       (UI/Input bg + red-dot SVG, Figma 393:1138). UI/Accent Red bg +
       off-white square SVG when `.recording` is on (Figma 409:11306).
     • Scale / Format — text pills (existing styling).
   The bg / color values match Figma's "Button" + "ButtonHover" variant
   pair: dim resting state, brightens to highlight + off-white on hover. */
.export-pill-dl,
.export-pill-record,
.export-pill-render,
.export-pill-settings {
  box-sizing: border-box;
  /* Square disc — uses --btn-export-h in both axes so it sits flush
     with the PNG / 2x / Timer pills (which inherit the same height
     from `.export-pill`) along one baseline. */
  width: var(--btn-export-h);
  height: var(--btn-export-h);
  min-width: var(--btn-export-h);
  min-height: var(--btn-export-h);
  flex: 0 0 var(--btn-export-h);
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--color-input);
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.export-pill-dl .export-pill-icon { transform: translateY(-1px); }
.export-pill-icon { flex-shrink: 0; display: block; }
.export-pill-record-active { display: none; }
.export-pill-record.recording {
  background: var(--color-accent-red);
}
.export-pill-record.recording .export-pill-record-idle  { display: none; }
.export-pill-record.recording .export-pill-record-active { display: block; }
/* (`.export-pill-scale` and `.export-pill-fmt` were removed in 2026-06:
   the Scale and Format pills are now dropdowns inside the Settings
   popup — see settings-ui.js#insertExportControls. Their CSS rules
   were retired with the markup.) */
.export-pill-record.hidden { display: none; }
/* Render video (render-video.js): clapperboard glyph at rest; while a
   render runs, a stop square (click = cancel) on the off-white, like
   Record's active state but neutral — rendering isn't "live". */
/* Optical centring of the clapperboard (user 2026-11-12): its mass sits
   low in the 12 × 12 box — 3 px bottom padding lifts it to the button's
   visual centre; 1 px right padding nudges it left (2026-11-13). */
.export-pill-render-idle { padding: 0 1px 3px 0; box-sizing: content-box; }
.export-pill-render-active { display: none; }
.export-pill-render.rendering .export-pill-render-idle  { display: none; }
.export-pill-render.rendering .export-pill-render-active { display: block; }
.export-pill-render.rendering { color: var(--color-off-white); }
/* Mobile: a finished render waits for a tap (share sheet needs one). */
.export-pill-render.ready { color: var(--color-off-white); background: var(--color-stroke-hi); }
/* Recording timer pill — visible only while recording, shows m:ss elapsed.
   Same styling as the PNG/2x pills; non-interactive. Figma 417:11313.
   The ::before reserves the width of "00:00" so the pill stays a constant
   size as the displayed time (in ::after, via data-time) grows. */
.export-pill-timer {
  /* Same translucent-input treatment as PNG/2x so the export-pills
     row reads as one consistent surface. */
  background: var(--color-input);
  color: var(--color-text);
  cursor: default;
  pointer-events: none;
  user-select: none;
  font-variant-numeric: tabular-nums;
  /* Hidden state collapses max-width + opacity (NOT display:none) so
     adjacent siblings (the Settings button) can slide smoothly into /
     out of the freed space. Overflow:hidden clips the inner text
     while max-width is shrinking. */
  overflow: hidden;
  transition:
    max-width  var(--transition-collapse),
    opacity    var(--transition-collapse),
    padding    var(--transition-collapse),
    margin     var(--transition-collapse);
}
.export-pill-timer::before {
  content: "00:00";
  visibility: hidden;
}
.export-pill-timer::after {
  content: attr(data-time);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.export-pill-timer.hidden {
  /* Collapse to zero width / no padding so the row reflows. The
     `margin-left: -8px` cancels ONE of the parent's flex `gap: 8`
     slots that would otherwise sit on both sides of the now-empty
     timer (yielding a 16 px gap between Record and Settings instead
     of the design's 8 px). With the negative margin, the effective
     Record↔Settings spacing collapses back to 8 px. */
  max-width: 0;
  padding-left: 0;
  padding-right: 0;
  margin: 0 0 0 -8px;
  opacity: 0;
  border: none;
}

/* Settings button (Figma 495:1856). Circular pill matching Record /
   Capture — shape rules merged into the `.export-pill-dl,
   .export-pill-record, .export-pill-settings` shared block above.
   Here just the inner glyph: three 3 × 3 UI/Text squares spaced 4 px
   apart (Figma 495:1856 → 524:3458 / 524:3464 / 524:3470). Hover/press
   inherit from the universal `.export-pill` treatment. */
.export-pill-settings-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.export-pill-settings-dot {
  display: block;
  width: 3px;
  height: 3px;
  background: var(--color-text);
}

/* Settings popup — small floating panel anchored ABOVE the settings
   button. Position computed by JS (left + bottom = above the button).
   Hidden state uses opacity + scale fade so it eases in / out. */
/* Settings popup — Figma `OHJ-Playground` 802:2479. Two visual
   sections separated by 0.5 px hairlines (top and bottom of the
   middle section in the canonical 3-section layout — for our
   2-section adaptation, the action section carries border-bottom
   to produce the same divider line above the pills):
     • action rows (Download .cimble + Load + Save to library)
     • pill row (Scale, Format, Record format)
   210 px wide, 10 px outer padding, 14 px radius, --shadow-frame. */
.settings-popup {
  position: fixed;
  z-index: 13;
  /* Width sizes to content — the pill row's intrinsic width sets the
     popup width (the three .ratio-pill buttons need ~245 px between
     them, well over the design's nominal 205 px), and the action
     section stretches via `width: 100%` to match. */
  width: fit-content;
  /* Canonical popup padding — 12 px on every side, shared with
     .layers-popup + .layer-settings-popup so all three popups read
     as the same surface. See DESIGN-SYSTEM.md § "Popup chrome". */
  padding: 12px;
  background: var(--color-panel);
  /* No outer border — the design system treats panels as borderless
     surfaces, with stroke only on INTERNAL separators (section
     dividers). Elevation comes from --shadow-frame, matching every
     other floating panel. */
  border-radius: 14px;
  box-shadow: var(--shadow-frame);
  display: flex;
  flex-direction: column;
  gap: 4px;   /* Figma 802:2479 → 806:2633 (was 10 → 6) */
  transform-origin: bottom left;
  transition:
    opacity   0.15s ease,
    transform 0.15s ease;
}
.settings-popup.hidden {
  opacity: 0;
  transform: scale(0.95) translateY(4px);
  pointer-events: none;
}
/* …its pills too: the base pill rule (.ratio-pill / .export-pill) turns
   pointer events back ON, so the invisible Render-settings pills caught
   clicks — on a phone they sit over the frame (bug found 2026-11-12). */
.settings-popup.hidden * { pointer-events: none; }
/* File-actions section. Stretches to popup width via flex's default
   align-items: stretch. The divider above the pills is this
   section's bottom border; the popup's 16 px gap above pills
   provides the visual separation. */
.settings-popup-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  border-bottom: 0.5px solid var(--color-stroke-hi);
  padding-bottom: 16px;
}

/* Action row — 36 × full-width pill with 8 px radius. At REST the
   row is transparent against the popup with dim --color-text label;
   on HOVER it fills with --color-input + off-white text. The Figma
   shows the HOVER state (all three rows highlighted) — at rest the
   popup reads as a flat list of plain-text menu items, and the
   hover lift is the only color change. No `.primary` accent: every
   available action has the same resting appearance, distinguishing
   itself only by position + label. */
.settings-popup-action {
  appearance: none;
  border: none;
  background: transparent;
  text-align: left;
  height: 36px;
  padding: 0 8px;   /* Figma 803:2570 (was 12) */
  border-radius: 8px;
  cursor: pointer;
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  color: var(--color-text);
  display: flex;
  align-items: center;
  transition: none;
}
.settings-popup-action:not(.placeholder):hover,
.settings-popup-action[aria-expanded="true"] {   /* ⋯ → Manage versions while its list is open */
  background: var(--color-input);
  color: var(--color-off-white);
}
/* Disabled / placeholder actions — Load .cimble + Save to library
   are in the design but the underlying features don't exist yet.
   Per Figma, disabled text uses --color-stroke-hi (#414144) directly
   instead of dimming via opacity — the result is the same visually
   but the rule is more semantically explicit (and survives nested
   opacity contexts cleanly). Remove `.placeholder` when wiring the
   real handlers. */
.settings-popup-action.placeholder {
  cursor: default;
  color: var(--color-stroke-hi);
}

/* Pill row — sits directly under the popup (no section wrapper).
   Stretches to popup width (`width: 100%`), 16 px top padding from
   the divider above. 8 px gap between pills — the canonical
   pill/button gap shared with .ratio-buttons + .export-pills. The
   pills themselves use the canonical `.ratio-pill` styling from the
   design system — 56 px tall, 999 px radius, P2b font, --color-input
   bg, the universal Button hover treatment. The .settings-popup-pill
   class is a marker for the placeholder override below. */
.settings-popup-pill-row {
  display: flex;
  gap: 8px;
  /* 6 px under the "Capture / Render settings" caption (Figma 804:2765
     had 8; user 2026-11-11: 2 px tighter), on top of the popup's 4 px
     gap; 2 px below the pills (user rule 2026-11-11). */
  padding-top: 6px;
  padding-bottom: 2px;
  width: 100%;
}
/* A pill row with another section under it (Capture settings): same
   divider + 16 px as the file-actions section above. */
.settings-popup-pill-row.has-divider {
  padding-bottom: 16px;
  border-bottom: 0.5px solid var(--color-stroke-hi);
}
/* "Capture settings" caption between the divider and the pill row
   (Figma 802:2479 → 832:2843): 4 px top padding (+ the popup's 4 px
   gap), 8 px sides, C1 type in UI/Interactive, inner 5 / 2 / 6 padding
   per the design. */
.settings-popup-caption {
  display: flex;
  align-items: center;
  width: 100%;
  /* Figma 832:2843: 4 px top, 8 px sides (aligns with the action rows'
     8 px text inset above). */
  padding: 4px 8px 0;
}
.settings-popup-caption-text {
  /* No side padding (user 2026-11-11) — the caption's left edge lines up
     with the action rows' text (both 8 px in from the popup). */
  padding: 5px 0 6px;
  font: 500 11.5px/14px var(--font-display);   /* C1 */
  letter-spacing: 0.75px;
  color: var(--color-highlight-plus);   /* UI/Interactive #727379 (Figma 832:2845) */
  white-space: nowrap;
}
/* MP4 placeholder — same pill as 1x / PNG but with dimmed text (Figma
   802:2479). Wears `.ratio-pill .settings-popup-pill .placeholder
   .suppress-hover` from settings-ui.js; .suppress-hover gates the
   .ratio-pill hover rule (`:not(.suppress-hover):hover`), .placeholder
   adds the cursor + dim text, and the :active rule below kills the
   press-down. */
.settings-popup-pill.placeholder {
  cursor: default;
  /* Dimmed like the unavailable "Load .cimble" / "Save to library" rows
     (Figma 806:3159: UI/Highlight #414144) — MP4 is the only record
     format, so there's nothing to toggle. */
  color: var(--color-stroke-hi);
}
/* No press-down either — a pill with nothing to toggle must not look
   clickable. Same specificity as `.ratio-pill:not(.active):active`
   (0,3,0) and declared later, so this wins. */
.settings-popup-pill.placeholder:active {
  transform: none;
}

/* Status pill (HTML5 export progress) — the off-screen pill's surface +
   type (see .offscreen-pill): off-white, off-black C1 text, 22 px tall,
   6 px radius, --shadow-pill. Width hugs the label; fixed top-centre. */
.status-pill {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  height: 22px;
  padding: 6px 7px;
  background: var(--color-off-white);
  color: var(--color-off-black);
  border-radius: 6px;
  font: 500 11.5px/14px var(--font-display);
  letter-spacing: 0.75px;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
  filter: drop-shadow(var(--shadow-pill));
  opacity: 0;
  transform: translate(-50%, -6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.status-pill.visible { opacity: 1; transform: translate(-50%, 0); }
/* A clickable status pill (showStatus opts.onClick — "File saved" → its
   folder): takes the pointer while shown. */
.status-pill.is-action.visible { pointer-events: auto; cursor: pointer; }
/* Optional trailing glyph (showStatus's `icon`; the Live pill's lock used it
   until 2026-11-13): 4 px gap like the off-screen pill's arrow, scaled to
   the pill's 10 px content height. */
.status-pill-icon { display: inline-flex; margin-left: 4px; }
.status-pill-icon svg { display: block; width: auto; height: 10px; }

/* ───── Component: Controls panel (right sidebar) ───── */
.controls {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--ctl-w);
  height: 100vh;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow: hidden;
}
.controls-inner { pointer-events: auto; }

/* Canvas-level upload button — fixed in the visible region of canvas-area
   (independent of frame zoom/pan), so when an imageRequired tool has no
   image loaded the user always sees a stable centered "Upload image"
   call-to-action. Click posts `request_image_upload` to the iframe; the
   tool's handler triggers its hidden fileInput.
   Primary pill treatment (off-white fill, off-black text — matches the
   Download export pill). */
.canvas-upload-btn {
  display: none;
  position: fixed;
  top: 50%;
  /* Centered on the full viewport — same reference frame as the zoom
     pill and the frame itself now that canvas-area spans the whole
     window. The sidebar overlays the right edge. */
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 11;
  /* Canonical pill padding — see .ratio-pill / .export-pill. */
  padding: 18px 20px;
  /* Canonical 56 px button height (--btn-h) — matches Randomize / Run
     and the rest of the in-panel actions. */
  min-height: var(--btn-h);
  background: var(--color-off-white);
  color: var(--color-off-black);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font: 600 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  /* Hover affordance: darken the off-white pill via opacity (same
     0.85 used for keyword pills) + scale 1.1 — no colour swap. The
     translate(-50%, -50%) centering baseline is repeated in each
     transform state so scale composes against the centered origin
     (otherwise the button jumps off-centre on hover). */
  transition:
    transform 0.15s ease,
    opacity   0.15s ease;
}
.canvas-upload-btn:not(.suppress-hover):hover {
  opacity: 0.85;
  transform: translate(-50%, -50%) scale(1.1);
}
.canvas-upload-btn:active { transform: translate(-50%, -50%) scale(0.94); }
/* Press-while-hover specificity tiebreaker — see .btn-ctrl notes. */
.canvas-upload-btn:not(.suppress-hover):hover:active { transform: translate(-50%, -50%) scale(0.94); }
.canvas-upload-btn.visible { display: inline-flex; align-items: center; justify-content: center; }

/* While a controls-panel resize drag is active, force col-resize cursor
   everywhere — the pointer may move on/off the small 8 × 8 handle, but
   the cursor should stay consistent for the duration of the drag. */
body.controls-resizing,
body.controls-resizing * { cursor: col-resize !important; }

/* Drag handle for resizing the controls panel — an 8 × 8 white square
   straddling the left edge of `.controls-inner` (`.controls` has 40 px of
   outer padding, so `left: 40px` lands on the visible panel edge;
   negative margins center the 8 px box on that point), vertically
   centered on the panel. Matches the iframe's `.frame-handle` square in
   size and color. Only this 8 × 8 region is grabbable —
   `app.js#setupControlsResize` listens for pointerdown and drags
   `--ctl-w`. Figma reference: node 234:2126.

   Hidden at rest; fades in only when the sidebar is hovered, or while
   a drag is in progress (so the handle stays visible if the cursor
   slips off the 8 × 8 hit area mid-drag). pointer-events stays auto
   so the handle is still grabbable while invisible — once the cursor
   crosses the panel edge the handle becomes visible immediately. */
.controls-resize-handle {
  position: absolute;
  top: 50%;
  left: 20px;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  margin-left: -4px;
  background: var(--color-off-white);
  cursor: col-resize;
  pointer-events: auto;
  z-index: 11;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.controls:hover .controls-resize-handle,
body.controls-resizing .controls-resize-handle {
  opacity: 1;
}

.controls-inner {
  background: var(--color-panel);
  border-radius: 24px;
  /* The 10 px horizontal panel padding sits on .controls-body (the scroll
     box), so a hovered button's lift at the content edge isn't clipped by
     it (user 2026-11-15: the ⋯ / New lift was cut off). */
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  box-shadow: var(--shadow-frame);
}
/* "Reset all" header strip retired — the latest Figma has no global reset.
   Each .ctrl-group now owns its per-section Reset link. */

.controls-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 0 10px;   /* the panel's horizontal padding (see .controls-inner) */
  /* Hide the scrollbar UI in both engines while keeping scroll behaviour. */
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* legacy Edge / IE */
}
.controls-body::-webkit-scrollbar { display: none; }   /* WebKit */
/* No scroll while the skeleton is up — the skeleton is intentionally
   sized to fit the viewport, and a stray scroll past it would reveal
   nothing (the real controls are display:none during the transition).
   Re-enables when .stage.transitioning drops. */
body:has(.stage.transitioning) .controls-body { overflow-y: hidden; }

/* ───── Component: Document bar (doc-ui.js, step 1 2026-11-13) ─────
   The sidebar's top row, Figma 60:269: [⋯] Name.cimble • [v5 ▾] [New].
   48 px (--ctrl-h, 2026-11-17; was 55) squares (radius 12) around the centred name (P2a: name
   Off-White, ".cimble" UI/Text). Sticky — pinned while the controls
   scroll — with the section hairline under it. */
.doc-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  background: var(--color-panel);
  border-bottom: 0.5px solid var(--color-stroke-hi);
}
.doc-bar:empty { display: none; }
/* Phones: inside the bottom sheet, on the sheet's 20 px gutter. */
@media (pointer: coarse) and (max-width: 900px) {
  .doc-bar { padding: 10px 20px; }
}
.doc-bar-btn {
  appearance: none;
  /* The sidebar's box height (--ctrl-h, 48 — user 2026-11-17; was 55),
     the radius scaled with it (14 → 12). */
  flex: 0 0 var(--ctrl-h);
  width: var(--ctrl-h);
  height: var(--ctrl-h);
  padding: 0;
  border: none;
  border-radius: 12px;
  background: var(--color-input);
  color: var(--color-off-white);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  /* The universal Button hover (DESIGN-SYSTEM § Button hover): Highlight
     bg + the 10 % white wash + the whole button at 1.1. */
  box-shadow: inset 0 0 0 9999px transparent;
  transition: transform 0.15s ease;
}
.doc-bar-btn svg { display: block; }
/* The ⋯ = File + every setting (one settings button, 2026-11-15); its dots
   are UI/Text (Figma 60:269), Off-White hovered / open. */
.doc-bar-menu { color: var(--color-text); background: transparent; }   /* no fill at rest, like New (user 2026-11-16) */
.doc-bar-menu:not(.suppress-hover):hover,
.doc-bar-menu[aria-expanded="true"] { color: var(--color-off-white); }
.doc-bar-btn:not(.suppress-hover):hover,
.doc-bar-btn[aria-expanded="true"] {
  background: var(--color-stroke-hi);
  box-shadow: inset 0 0 0 9999px var(--color-hover-overlay);
}
.doc-bar-btn:not(.suppress-hover):hover,
.doc-bar-btn[aria-expanded="true"]:not(:active) { transform: scale(1.1); }   /* the whole button, like every square / round one; active = enlarged (2026-11-17) */
/* New (user 2026-11-16): no fill at rest — label grey (UI/Text) like the
   sidebar's labels; hovered / open it lights up to UI/Input with Off-White.
   The ratio pills' weight (600). */
.doc-bar-new { background: transparent; color: var(--color-text); font-weight: 600; }
/* Where New sat (it moved into the ⋯ menu, user 2026-11-17): an empty slot
   of its size, so the name stays centred. */
.doc-bar-spacer { flex: 0 0 var(--ctrl-h); width: var(--ctrl-h); height: var(--ctrl-h); }
.doc-new-menu { min-width: 200px; }
/* ⋯ hovers the same (user 2026-11-16 — its Highlight + wash was too bright). */
.doc-bar-new:not(.suppress-hover):hover,
.doc-bar-new[aria-expanded="true"],
.doc-bar-menu:not(.suppress-hover):hover,
.doc-bar-menu[aria-expanded="true"] {
  background: var(--color-input);
  color: var(--color-off-white);
  box-shadow: inset 0 0 0 9999px transparent;
}
.doc-bar-btn:not(.suppress-hover):hover:active,
.doc-bar-btn:active { transform: scale(0.94); }
/* The name (Figma 60:269 → 1153:6842, user 2026-11-15): plain centred text
   — "Name" Off-White + ".cimble" UI/Text — with the version right after it. */
.doc-bar-name {
  flex: 1 1 auto;
  min-width: 0;
  /* The same height as New (user 2026-11-16): the name and "New" centre on
     the same box, so their baselines line up whatever the font. 48 since
     2026-11-17 (--ctrl-h; was 55). */
  height: var(--ctrl-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.doc-dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);   /* blue (user 2026-11-17, later; was red — red reads as an error) */
  display: none;
}
.doc-dot.visible { display: block; }
/* Inside the name's hover box (and the rename field), before the name. */
.doc-name .doc-dot,
.doc-name-field .doc-dot { align-self: center; margin-right: 6px; }
/* When it doesn't fit, ".cimble" is dropped first (doc-ui fitName), then
   the name ends in an ellipsis. */
.doc-name {
  display: flex;
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  color: var(--color-text);
}
.doc-name-base {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-off-white);
}
.doc-name-ext { flex: 0 0 auto; }
/* Click the name to rename it (doc-ui): a UI/Input wash on hover, then an
   in-place field in the same type. */
.doc-name {
  cursor: text;
  margin: 0 -8px;
  padding: 7px 8px;
  border-radius: 8px;
  transition: none;
}
.doc-name:hover { background: var(--color-input); }
.doc-name[hidden] { display: none; }
/* Renaming: one box = the field + a fixed ".cimble" after it (user
   2026-11-16 — the suffix stays, but can't be edited). The box carries the
   field look; the input inside is bare and sizes to its text. It takes the
   resting name's exact box (.doc-name: 8 px padding inside a −8 px margin),
   so entering it moves nothing — the version stays put (user 2026-11-16) —
   and ".cimble" drops out when the name doesn't fit, as at rest. */
.doc-name-field {
  flex: 0 1 auto;
  min-width: 0;
  height: 31px;   /* .doc-name: 17 px line + 7 px top / bottom */
  box-sizing: border-box;
  margin: 0 -8px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--color-input);
  box-shadow: inset 0 0 0 1px rgba(247, 247, 247, 0.5);
  display: inline-flex;
  align-items: center;
  cursor: text;
}
.doc-name-input {
  flex: 0 1 auto;
  /* Exactly the text (+ the caret): ".cimble" follows even a 1-letter name
     (user 2026-11-16 — a 20 px minimum left a gap). */
  min-width: 2px;
  max-width: 100%;
  field-sizing: content;
  height: 100%;
  padding: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--color-off-white);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
}
.doc-name-field.no-ext .doc-name-field-ext { display: none; }
.doc-name-field-ext {
  flex: 0 0 auto;
  color: var(--color-text);   /* as at rest (.doc-name-ext) */
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  user-select: none;
}
.doc-name.no-ext .doc-name-ext { display: none; }
/* The version — opens the version list. Figma 60:269 (1153:6963): plain
   "v1" in Off-White 40 % + a 6 × 3 UI/Interactive chevron, 3 px apart (user
   2026-11-15, was a pill). Hovered / open: Off-White on a UI/Input wash;
   right after a run (doc-ui showApplied) the label reads Off-White. */
.doc-version-pill {
  appearance: none;
  flex: 0 0 auto;
  height: 32px;
  /* The hover wash's padding doesn't move the text — and the name before it
     has an 8 px wash too, so the version keeps 10 px more from it: the two
     hover boxes sit 2 px apart, never overlapping (user 2026-11-16). */
  margin: 0 -8px 0 2px;
  padding: 0 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-dim-40);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  transition: none;
}
.doc-version-pill svg { width: 6px; height: 3px; color: var(--color-highlight-plus); transition: transform 0.15s ease; }
.doc-version-pill:hover,
.doc-version-pill[aria-expanded="true"] { background: var(--color-input); color: var(--color-off-white); }
.doc-version-pill:hover svg,
.doc-version-pill[aria-expanded="true"] svg { color: var(--color-off-white); }
.doc-version-pill.is-fresh { color: var(--color-off-white); }
.doc-version-pill[aria-expanded="true"] svg { transform: rotate(180deg); }

/* Its popups — the .settings-popup surface, dropping DOWN from the bar; the
   ⋯ menu (File + settings) opens OUTSIDE the panel, to its left. */
.settings-popup.doc-popup {
  min-width: 200px;
  overflow-y: auto;
  scrollbar-width: none;
  transform-origin: top left;
}
.settings-popup.doc-popup::-webkit-scrollbar { display: none; }
.settings-popup.doc-popup.hidden { transform: scale(0.95) translateY(-4px); }
/* The ⋯ menu grows out of its corner next to the panel. */
.settings-popup.doc-popup.doc-menu { transform-origin: top right; }
/* The last section has nothing under it to divide from. */
.settings-popup.doc-popup .settings-popup-section:last-child { border-bottom: none; padding-bottom: 0; }
.doc-action { justify-content: space-between; gap: 24px; }
/* On / off settings (Snap, Extras — user 2026-11-16): a tick LEFT of the word
   while on, in the word's own colour; turned off, the tick's column closes
   and the word slides left to line up with the menu's other items. */
.doc-toggle { justify-content: flex-start; gap: 0; }
.doc-toggle-tick {
  flex: 0 0 auto;
  width: 0;
  margin-right: 0;
  height: 8px;
  overflow: hidden;
  display: inline-flex;
  color: inherit;
  opacity: 0;
  transition: width 0.15s ease, margin-right 0.15s ease, opacity 0.15s ease;
}
.doc-toggle-tick svg { display: block; flex: 0 0 10px; }
.doc-toggle.is-on .doc-toggle-tick { width: 10px; margin-right: 6px; opacity: 1; }
.doc-action-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-shortcut { flex: 0 0 auto; color: var(--color-text-dim-40); }
.settings-popup-action:not(.placeholder):hover .doc-shortcut { color: var(--color-text); }
.doc-caption { margin-top: 8px; }

/* Version list. */
.doc-versions { gap: 2px; }
.doc-versions-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 8px 8px;
}
/* "Versions" reads like every sidebar label (.ctrl-label, user 2026-11-15). */
.doc-versions-title { font: 500 13.6px/17px var(--font-display); letter-spacing: 0.35px; color: var(--color-text); }
.doc-versions-count,
.doc-version-meta,
.doc-version-side { font: 500 11.5px/15px var(--font-display); letter-spacing: 0.5px; color: var(--color-text); }
.doc-versions-rows { display: flex; flex-direction: column; gap: 2px; }
.doc-version-row {
  appearance: none;
  border: none;
  background: transparent;
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: none;
}
.doc-version-row:not(.is-current):hover { background: var(--color-input); }
.doc-version-row.is-current { cursor: default; }
.doc-version-badge {
  min-width: 38px;
  height: 24px;
  box-sizing: border-box;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--color-input);
  color: var(--color-off-white);
  font: 500 11.5px/24px var(--font-display);
  letter-spacing: 0.5px;
  text-align: center;
}
.doc-version-row:not(.is-current):hover .doc-version-badge { background: var(--color-stroke-hi); }
.doc-version-row.is-current .doc-version-badge { background: var(--color-off-white); color: var(--color-off-black); }
.doc-version-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.doc-version-prompt {
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  color: var(--color-off-white);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-version-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Hovering a version shows its still over the tool (layers above stay). */
.version-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--color-bg-canvas);
  border-radius: 8px;
  pointer-events: none;
  z-index: 1;
}
body.fullscreen .version-preview { border-radius: 0; }

/* After a run: "v5 applied · Back to v4" — the status pill, clickable. */
.status-pill.doc-toast { pointer-events: auto; }
.doc-toast-link {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* Small modal questions (unsaved changes, restore unsaved work, open a
   file's code). */
.doc-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.doc-dialog-backdrop.visible { opacity: 1; }
.doc-dialog {
  width: min(380px, 100%);
  padding: 24px;
  border-radius: 16px;
  background: var(--color-panel);
  box-shadow: var(--shadow-frame);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transform: scale(0.97);
  transition: transform 0.15s ease;
}
.doc-dialog-backdrop.visible .doc-dialog { transform: none; }
.doc-dialog-title { font: 600 16px/20px var(--font-display); letter-spacing: 0.25px; color: var(--color-off-white); }
.doc-dialog-text { font: 500 13.6px/19px var(--font-display); letter-spacing: 0.35px; color: var(--color-text); white-space: pre-line; overflow-wrap: anywhere; max-height: 40vh; overflow-y: auto; }
.doc-dialog-buttons { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btn-ctrl.doc-dialog-btn { align-self: auto; padding: 0 18px; min-height: 40px; }

/* Create (step 2): the composer — description, reference chips, key. */
.doc-composer { width: min(520px, 100%); }
.doc-composer.is-drop { box-shadow: var(--shadow-frame), inset 0 0 0 1.5px var(--color-accent); }
.doc-composer-input,
.doc-composer-key {
  width: 100%;
  box-sizing: border-box;
  border: none;
  border-radius: 12px;
  background: var(--color-input);
  color: var(--color-off-white);
  font: 500 13.6px/19px var(--font-display);
  letter-spacing: 0.35px;
  outline: none;
}
.doc-composer-input { min-height: 116px; padding: 14px 16px; resize: vertical; }
.doc-composer-key { height: 44px; padding: 0 16px; }
.doc-composer-input::placeholder,
.doc-composer-key::placeholder { color: var(--color-text); }
/* (.doc-composer-input / -key: the shared focus stroke — see .ctrl-stepper:has(:focus).) */
.doc-composer-refs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.doc-composer-chip {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--color-input) center / cover no-repeat;
}
.doc-composer-chip-x {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--color-highlight-plus);
  color: var(--color-off-white);
  font: 600 12px/18px var(--font-display);
  cursor: pointer;
}
.doc-composer-attach {
  appearance: none;
  height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: var(--color-input);
  color: var(--color-text);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  cursor: pointer;
  transition: none;
}
.doc-composer-attach:hover { background: var(--color-stroke-hi); color: var(--color-off-white); }
.doc-composer-hint { font: 500 11.5px/15px var(--font-display); letter-spacing: 0.5px; color: var(--color-text); }

/* Create: progress card, centred on the canvas over the Iterate veil. */
.doc-create-progress {
  position: fixed;
  z-index: 50;
  transform: translate(-50%, -50%) scale(0.97);
  min-width: 220px;
  padding: 20px 24px;
  border-radius: 16px;
  background: var(--color-panel);
  box-shadow: var(--shadow-frame);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.doc-create-progress.visible { opacity: 1; transform: translate(-50%, -50%); }
.doc-create-title { font: 600 16px/20px var(--font-display); letter-spacing: 0.25px; color: var(--color-off-white); font-variant-numeric: tabular-nums; }
.doc-create-step { font: 500 13.6px/17px var(--font-display); letter-spacing: 0.35px; color: var(--color-text); margin-bottom: 6px; }
.doc-create-progress .doc-dialog-btn { align-self: center; }
.btn-ctrl.doc-dialog-btn.is-primary { background: var(--color-off-white); color: var(--color-off-black); }

/* ───── Component: Control group (section) ───── */
.ctrl-group {
  display: flex;
  flex-direction: column;
  /* 24 px between consecutive controls within a section. The h3
     gets an extra 8 px margin-bottom (below) so the section title
     → first control gap totals 32 px. */
  gap: 24px;
  padding: 40px 20px;
  border-top: 0.5px solid var(--color-stroke-hi);
}
/* The Canvas section is no longer the first DOM child of `.controls-body`
   (the navigator-wrap is) — so we target `.canvas-group` by class for the
   no-top-border + tighter top-padding treatment. */
.ctrl-group.canvas-group { border-top: none; padding: 30px 20px; }
/* Last section gets extra bottom breathing room since the panel itself
   carries no bottom padding. */
.ctrl-group:last-child  { padding-bottom: 50px; }

/* "Label" variant header — title left, "Reset" link right. h3 carries
   an 8 px margin-bottom so section title → first control = 32 px
   (the parent .ctrl-group's 24 px gap + 8 px margin). Controls within
   the section keep the 24 px gap, no extra margin. */
.ctrl-group h3 {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin: 0 0 8px 0;
}
.ctrl-group-label {
  font: 600 23.2px/24px var(--font-display);
  color: var(--color-off-white);
  letter-spacing: 0.25px;
}
.ctrl-group-icon { display: none; }
.ctrl-group-reset {
  background: none;
  border: none;
  padding: 4px 6px 5px;
  border-radius: 6px;
  cursor: default;
  /* C1 — 450 weight, 11.5 / 14 lh / 0.75 tracking. */
  font: 500 11.5px/14px var(--font-display);
  letter-spacing: 0.75px;
  color: var(--color-stroke-hi);
  transition: none;
}
.ctrl-group-reset.altered       { color: var(--color-text); cursor: pointer; }
.ctrl-group-reset.altered:not(.suppress-hover):hover {
  color: var(--color-off-white);
  background: var(--color-stroke-hi);
}

/* ───── Component: Slider control ─────
   Wrapper for any single .ctrl: flex column, gap 12 between label row and the
   control itself. Section spacing between consecutive .ctrl items is owned by
   .ctrl-group's gap (32) — except where consecutive sliders are wrapped in a
   `.ctrl-stack` (gap: 24); see below. */
.ctrl              { display: flex; flex-direction: column; gap: 12px; }

/* ───── Component: Media control (Figma 402:10810) ─────
   Header row carries the label on the left and a "N files" count on the
   right (number in Off-White, "files" suffix in UI/Text). The grid is a
   fixed 3-column layout: thumbnails fill from the top-left, then a "+"
   add tile appears in the next slot (when below `max`), then transparent
   placeholders pad the trailing row so the grid shape stays consistent
   regardless of fill count. */
.ctrl-media {}
/* Header strip — label LEFT, "n of N" counter RIGHT. Layout-only:
   no padding/font/color (those live on `.ctrl-label` and the counter
   span below, both matched to `.ctrl-label-row` / `.ctrl-value` so
   baselines align with slider rows panel-wide). */
.ctrl-media-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
/* "n of N" counter — same padding as `.ctrl-value` (4 / 6 / 5) so
   its text baseline aligns with the `.ctrl-label` next to it AND
   with every other right-side value across the panel. Non-
   interactive (no hover-highlight box), but the spacing is shared
   so the column's right edge reads as a single typographic
   alignment line whether the value is a scrub-edit slider value or
   a read-only counter. */
.ctrl-media-count {
  padding: 4px 6px 5px;
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  color: var(--color-text);
  white-space: nowrap;
}
.ctrl-media-count-num { color: var(--color-off-white); }
.ctrl-media-grid {
  display: grid;
  /* FIXED-size tiles (--media-col, 3 columns at the narrowest
     sidebar): widening the sidebar adds columns, it never scales the
     tiles. Rows left-align; the partial last row leaves trailing cells
     empty (no placeholder padding needed). */
  grid-template-columns: repeat(auto-fill, var(--media-col));
  gap: 10px 11px;   /* 11 px between columns: three 66 px tiles fill the 220 px sidebar exactly */
  width: 100%;
}
.ctrl-media-tile {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: none;
  background: transparent;
  padding: 0;
  overflow: hidden;
  position: relative;
}
/* Thumb opts out of overflow:hidden so the X-remove badge can overflow
   the top-right corner per design. Img keeps the rounded clip itself
   and stays at full opacity on hover — the X badge is the only hover
   affordance. crosshair cursor signals click-to-crop. */
.ctrl-media-thumb {
  /* Slot backing behind a contain-fit image's letterbox bands — UI/Input,
     same as the "+" tile. Images with transparent pixels swap this for the
     canvas checker (.has-alpha, set by controls.js#buildMedia), so the
     whole square shows the grid behind the transparent PNG / SVG. */
  background: var(--color-input);
  /* `grab` reads as "you can drag this" — paired with `.dragging`'s
     `grabbing` below for the drag-in-progress state. Was `crosshair`
     back when click-to-crop was the only affordance; the hover overlay
     with the crop icon now carries that signal, so the cursor can
     advertise the drag-to-reorder behaviour instead. */
  cursor: grab;
  overflow: visible;
  /* FLIP slide for drag-to-reorder. CSS owns the transition so the inline
     `transition: none` the JS sets briefly (for the inverse-transform
     setup) can be cleared with an empty string and this rule re-applies. */
  transition: transform 0.18s ease;
}
.ctrl-media-thumb img {
  width: 100%;
  height: 100%;
  /* FIT, not fill — the whole image is visible inside the square slot
     (letterboxed on the short axis). */
  object-fit: contain;
  display: block;
  user-select: none;
  pointer-events: none;
  border-radius: 8px;
}
/* Corner badges — 20 px UI/Interactive (--color-highlight-plus, #727379)
   discs straddling the tile's top-right corner (Figma uZ7iWwvNrNKPbTVOLkgMAj
   402:10794): X-remove (431:11439) on the corner, crop (828:2809) 3 px to
   its left. Hidden by default; revealed only when the parent thumb is
   hovered. The scale animation (1.2 hover / 0.92 press) fires ONLY on
   hovering the badge itself — moving the cursor onto the image alone
   doesn't scale it. `:hover` on a badge also keeps the parent
   `.ctrl-media-thumb:hover` matched via the descendant-hover rule, so the
   badges stay visible while the cursor is over them even though they
   extend outside the tile's bounding box. */
.ctrl-media-badge {
  position: absolute;
  top: -10px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-pill);
  border: none;
  padding: 0;
  /* UI/Highlight+ bg — one step brighter than UI/Highlight so the
     action chip lifts off the Panel/Input rows it sits on top of.
     Shared across all corner badges so the affordance reads as one
     component family. Paired with .layer-row-remove. */
  background: var(--color-highlight-plus);
  color: var(--color-off-white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  /* Hidden = scaled-down + rotated -10deg. On thumb hover the disc pops
     into its neutral state (scale 1, rotate 0) via ease-out for a
     "snap into place" feel; badge-hover and press transforms compose on
     top of neutral. transform + opacity share one easing curve since a
     CSS property can only have one transition declaration. */
  transform: scale(0.6) rotate(-10deg);
  transition: opacity     0.2s ease-out,
    transform   0.2s ease-out;
  /* Design-system drop shadow + transparent inset baseline. The disc is
     opacity 0 at rest so the shadow only paints once the parent thumb
     is hovered (opacity carries the shadow). Inset baseline keeps the
     shadow-list length stable so the hover overlay can tween in. */
  box-shadow: var(--shadow-frame), inset 0 0 0 9999px transparent;
}
/* X: centred on the corner (Figma right -10.33 / top -10). */
.ctrl-media-remove { right: -10px; }
/* Crop: 3 px gap left of the X (Figma right 12.67). Takes the corner
   slot when the tile has no X (pool at its declared minimum). */
.ctrl-media-crop { right: 13px; }
.ctrl-media-crop.is-corner { right: -10px; }
/* Hover bridge (user 2026-11-13): the discs' top halves sit OUTSIDE the
   tile, so sliding from crop to X crossed a gap that belonged to neither
   (3 px at the middle, ~11 px near the top of the round discs). One slip
   unhovered the tile and the badges vanished before reaching the X. Each
   badge's hit area is a full square (no round corners), and the two
   squares overlap across the gap — crop reaches 2 px right, X 2 px left.
   The outer edges stay put, so neither intrudes on a neighbouring tile
   (10 px grid gap). Inherits the badge's pointer-events, so it's only
   live while the badges are shown. */
.ctrl-media-badge::before {
  content: "";
  position: absolute;
  inset: 0;
}
.ctrl-media-crop:not(.is-corner)::before { right: -2px; }
.ctrl-media-remove::before { left: -2px; }
.ctrl-media-thumb:hover .ctrl-media-badge {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) rotate(0);
}
.ctrl-media-thumb.has-alpha {
  background-color: var(--checker-base);
  background-image: var(--checker-image);
  background-size: var(--checker-size);
  background-position: var(--checker-position);
}
/* Single-slot pools aren't draggable, so `grab` would lie — the click
   replaces the image, so advertise a plain click. */
.ctrl-media-thumb:not([draggable="true"]) { cursor: pointer; }

/* Drag-to-reorder feedback for media tiles — same pattern as
   .ctrl-keywords-pill.dragging / .drop-before / .drop-after, scaled to
   the tile's 4 px radius. Box-shadow inset so layout doesn't shift. */
.ctrl-media-thumb.dragging { opacity: 0.4; cursor: grabbing; }
.ctrl-media-thumb.drop-before { box-shadow: inset 2px 0 0 var(--color-off-white); }
.ctrl-media-thumb.drop-after  { box-shadow: inset -2px 0 0 var(--color-off-white); }

/* Hover overlay with the REPLACE affordance — Figma 431:11392 (tint) /
   684:3207 (18 px Symbols container holding the replace glyph). Clicking
   the image replaces it. Hidden at rest, fades in on tile hover, hidden
   during drag so the drag snapshot stays clean. */
.ctrl-media-replace-overlay {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  /* +20 % alpha vs Figma 431:11392's 0.4 baseline (per-tool tweak —
     the lighter Figma value made the affordance hard to spot against
     image content). */
  background: rgba(32, 32, 32, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-off-white);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.ctrl-media-replace-icon {
  /* The glyph is 6 px wider than the Figma 11 px (user 2026-11-12): 17 px
     in a 24 px box. */
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Like every other icon's hover: the IMAGE hovered → Off-White + bigger;
     a corner badge (X / crop) hovered instead → UI/Text grey at its
     default size — the click would hit the badge, not "replace". */
  color: var(--color-text);
  transition: transform 0.15s ease;
}
.ctrl-media-replace-icon svg { width: 17px; height: 17px; }   /* 6 px over Figma's 11 (user 2026-11-12: +8, then −2) */
.ctrl-media-thumb:hover .ctrl-media-replace-icon {
  color: var(--color-off-white);
  transform: scale(1.2);
}
.ctrl-media-thumb:hover:has(.ctrl-media-badge:hover) .ctrl-media-replace-icon {
  color: var(--color-text);
  transform: none;
}
.ctrl-media-replace-overlay svg {
  /* "Frame Shadow Dark" (Figma effect token): 0/0/10 rgba(0,0,0,0.2).
     drop-shadow filter (not box-shadow) so it traces the glyph's
     silhouette rather than its bounding rect. */
  filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.2));
}
.ctrl-media-thumb:hover .ctrl-media-replace-overlay {
  opacity: 1;
  pointer-events: auto;
}
.ctrl-media-thumb.dragging .ctrl-media-badge {
  /* Hide the badges while the tile is being dragged. `transition: none`
     snaps opacity to 0 synchronously so the browser-captured drag
     snapshot (taken at the end of the dragstart handler) doesn't include
     them. The fade-IN on hover after a drop still runs at the full
     0.2 s ease-out from the base rule — only the drag-out is a snap. */
  opacity: 0;
  pointer-events: none;
  transition: none;
}
.ctrl-media-thumb.dragging .ctrl-media-replace-overlay {
  /* Snap out during drag so the HTML5 drag-snapshot captures a clean
     image, not a translucent overlay. transition:none avoids fading.   */
  opacity: 0;
  pointer-events: none;
  transition: none;
}
.ctrl-media-badge:not(.suppress-hover):hover {
  transform: scale(1.2);
  box-shadow: var(--shadow-frame), inset 0 0 0 9999px var(--color-hover-overlay);
}
/* Press-while-hover specificity tiebreaker — see .export-pill notes.
   Without the matching `:not(.suppress-hover):hover` chain, hover's
   (0,3,0) scale(1.2) wins over a bare `:active` (0,2,0) and the press
   bounce never paints. */
.ctrl-media-badge:not(.suppress-hover):hover:active,
.ctrl-media-badge:active { transform: scale(0.92); }
/* Media cropper overlay — opened by clicking a media thumb. The image
   pans inside an aspect-ratio-matched frame anchored to the viewport
   centre. On close, the framed region is canvas-rendered and replaces
   the thumb's image in the pool (see `openMediaCropper` in
   controls.js). Figma refs: 530:1825 (cropper), 531:2220 (in-page).

   Layer order (back → front, all `position: fixed; inset: 0`):
     1. .media-cropper-overlay itself — `--color-bg-canvas` @ 90 % +
        12 px blur backdrop; captures pointer events for drag + close.
     2. .media-cropper-img — the pannable image, anchored centre via
        transform; JS writes `translate(calc(-50% + Xpx), …)`.
     3. .media-cropper-mask — frame-sized box with a huge 60 % black
        box-shadow halo, which paints the dark wash over everything
        OUTSIDE the frame. The 8 px radius makes the wash's cutout
        match the visible frame's rounded corners.
     4. .media-cropper-frame — the visible border + `--shadow-frame`. */
.media-cropper-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(25, 25, 25, 0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  /* Custom X-glyph cursor (20 × 20 white strokes, hotspot in the centre)
     signals "click to close" everywhere outside the frame. Pointer
     fallback for browsers that drop the SVG cursor. */
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'><line x1='5' y1='5' x2='15' y2='15' stroke='%23F7F7F7' stroke-width='1.6' stroke-linecap='round'/><line x1='15' y1='5' x2='5' y2='15' stroke='%23F7F7F7' stroke-width='1.6' stroke-linecap='round'/></svg>") 10 10, pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.media-cropper-overlay.open { opacity: 1; }
/* Whole overlay flips to grabbing during a drag so the cursor reads
   consistently even if the drag started inside the frame and the
   pointer wandered outside. */
.media-cropper-overlay.dragging,
.media-cropper-overlay.dragging .media-cropper-frame { cursor: grabbing; }
/* Holds the image + its dark wash. `overflow: hidden` clips the wash's
   9999 px box-shadow halo to the image's bounds so outside the image
   the 90 % backdrop alone darkens the site (≈ 10 % blurred site
   visible through it). JS sets width/height to displayW/H and a
   pan-driven translate. pointer-events:auto + grab cursor so any
   drag inside the image's display bounds (frame interior AND dark
   wash) reads as draggable — events bubble to overlay's pointerdown
   handler, and the click-vs-drag logic there only fires `close` when
   the down-target is the overlay itself (backdrop outside the image). */
.media-cropper-img-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  overflow: hidden;
  cursor: grab;
}
.media-cropper-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
  display: block;
  max-width: none;
}
/* Lives INSIDE img-wrap — JS positions it in the wrap's local coords
   so the frame cut-out tracks the viewport-anchored frame as the image
   pans. Halo paints 60 % black; img-wrap's overflow:hidden contains it. */
.media-cropper-mask {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 8px;
  background: transparent;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.media-cropper-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 0.5px solid var(--color-text);
  border-radius: 8px;
  box-shadow: var(--shadow-frame);
  /* Pointer-events on so the frame shows the grab cursor (and click /
     drag still bubble to the overlay handler that owns pan + close). */
  pointer-events: auto;
  cursor: grab;
}

.ctrl-media-add {
  background: var(--color-input);
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform   0.15s ease;
  /* Transparent inset baseline — see .export-pill for the rationale. */
  box-shadow: inset 0 0 0 9999px transparent;
}
.ctrl-media-add:not(.suppress-hover):hover {
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
  transform: scale(1.1);
  box-shadow: inset 0 0 0 9999px var(--color-hover-overlay);
}
.ctrl-media-add:active { transform: scale(0.94); }
/* Combined :hover:active (0,4,0) beats the hover scale (0,3,0) so the dip shows
   during press-while-hover — the canonical click-bounce fix. */
.ctrl-media-add:not(.suppress-hover):hover:active { transform: scale(0.94); }
.ctrl-media-placeholder { pointer-events: none; }

/* Sub-group for consecutive sliders within a section. controls.js auto-wraps
   any contiguous run of `slider`-type cfg entries into one of these. The
   24 px gap is tighter than the section's 32 px so related sliders read as
   a stack rather than independent controls. */
.ctrl-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
}

.ctrl-label-row {
  display: flex;
  align-items: flex-start;
  width: 100%;
}
.ctrl > .ctrl-label { display: none; } /* label lives in .ctrl-label-row */
/* Canonical control-label treatment — P2a (Roman 450 13.6/17), UI/Text
   grey (#A5A7AD), `padding: 4px 2px 5px`, 0.35 px tracking.

   ── Padding rationale ──
   The 4 / 5 vertical padding matches `.ctrl-value`'s 4 / 6 / 5 — the
   value chip sits on the right of a slider's label row, and the
   label baseline must line up with the value-chip baseline so the
   header row reads as a single typographic line. The 2 px horizontal
   keeps every label flush-left with the SAME 2 px offset from its
   wrapper, regardless of control type — sliders, steppers,
   dropdowns, textfields, toggles, media tiles, the API-key field,
   the prompt textfield. Don't override this per-control. (We used to
   ship `:has(.ctrl-value)` with 6 px sides for the slider label only,
   which silently nudged slider labels 4 px to the right of every
   other label; that was a design-system bug.)

   Every wrapper that hosts a `.ctrl-label` (`.ctrl-label-row`,
   `.toggle-row`, `.ctrl-textfield-header`, `.ctrl-media-head`, …)
   inherits this; the wrappers only set LAYOUT (flex/min-width). DO
   NOT redeclare font/color/padding per wrapper. The body inherits
   `--color-off-white`, so a missing `color` here paints the label
   white and breaks design-system fidelity. */
.ctrl-label {
  padding: 4px 2px 5px;
  font: 500 13.6px/17px var(--font-display);
  color: var(--color-text);
  letter-spacing: 0.35px;
}
.ctrl-label-row .ctrl-label {
  flex: 1;
}

.ctrl-slider-row {
  display: flex;
  align-items: center;
  height: 32px;
  width: 100%;
}
.ctrl-slider-row input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 32px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-pill);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: ew-resize;
  background: var(--color-input);
}
.ctrl-slider-row input[type="range"]::-webkit-slider-runnable-track {
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--color-input);
}
.ctrl-slider-row input[type="range"]::-moz-range-track {
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--color-input);
}
.ctrl-slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-off-white);
  border: none;
  box-shadow: none;
  cursor: ew-resize;
  /* WebKit anchors the thumb to the top of the track by default — push it
     down by half the size difference (32 − 28) / 2 = 2px to vertically center. */
  margin-top: 2px;
}
.ctrl-slider-row input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-off-white);
  border: none;
  cursor: ew-resize;
}

/* ───── Component: Stepper (Figma 105:1663) ─────
   Pill button with –/value/+ for unbounded integers (font size, line height,
   letter spacing, px padding, etc.). See feedback_stepper_for_unbounded_ints.md.
   The two side ZONES are full-height squares (48 × 48) so the entire left/
   right end of the pill is a hit target, not just the glyph. The center
   VALUE zone supports click-and-drag scrub (1 step per 2 px of motion). */
/* Stepper (Figma 105:1663) — rounded-rect input surface with the value
   centered between 8 × 8 glyph icons. Padding 18 / 16 matches the
   TextField + Keywords surface, so all input-style controls in the
   sidebar share one rectangle shape (radius 8, bg UI/Input). The ±
   zones keep generous hit areas via negative margin: their padding
   eats into the outer 16 px so the visible glyph is small but the
   click target reaches the full inset corner. */
.ctrl-stepper {
  display: flex;
  /* Stretch zones to full stepper height so the WHOLE left/right
     half (not just the glyph row) is hit-eligible for –/+. */
  align-items: stretch;
  width: 100%;
  /* Unified 55 px input-surface height — matches Dropdown and the
     single-line API-key TextField. Horizontal padding was moved
     INTO the –/+ zones (as `padding-left`/`padding-right: 16px`)
     so the 16 px outer inset is part of the zone's hit area —
     clicking anywhere in the outer edge fires –/+, not dead space. */
  min-height: var(--ctrl-h);
  box-sizing: border-box;
  gap: 0;
  padding: 0;
  border-radius: 8px;
  background: var(--color-input);
  user-select: none;
}
.ctrl-stepper-zone {
  appearance: none;
  -webkit-appearance: none;
  /* Grow to fill all empty horizontal space on each side of the value.
     Combined with the stepper's `align-items: stretch`, this means the
     entire LEFT half of the surface fires –, the entire RIGHT half
     fires +, and only the value zone in the middle escapes –/+. */
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--color-off-white);
  /* 8 px all round: the hover square (.ctrl-stepper-hit) sits 8 px in
     from the stepper's edges and fills the remaining height (Figma
     702:3296). The zone is still the whole half — the click target. */
  padding: 8px;
  box-sizing: border-box;
  transition: opacity 0.15s ease;
}
.ctrl-stepper-zone[data-dir="-"] { justify-content: flex-start; }
.ctrl-stepper-zone[data-dir="+"] { justify-content: flex-end; }
/* Hover square around the − / + glyph (Figma 702:3296): full height of
   the zone's content box (stepper height − 2 × 8 px), square, 8 px
   radius, UI/Highlight fill on hover. Glyph centred inside. */
.ctrl-stepper-hit {
  height: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: none;
}
/* THE focus stroke (user 2026-11-16): the ACTIVE control — the one being
   typed in, dragged, or reached with Tab — gets the stroke the rename field
   and the Iterate box show (1 px Off-White at 50 %), around the WHOLE
   control and only there: never a part inside it as well (a stepper's ±
   zone, a dropdown's chevron, the Iterate text area). Fields show it on any
   focus; buttons (ratio pills, Run, the export row …) when reached with Tab
   (a click shows their own pressed / active state instead). */
:root { --focus-stroke: rgba(247, 247, 247, 0.5); }
/* Every rectangular input box in the SIDEBAR (stepper, input, dropdown,
   single-line text field, keywords field, colour row + its × / +, the Case
   row, the API key) is this tall — 48 px (user 2026-11-17; was 55). Layer
   popups keep their own 40 px rows (--input-row-h). Text in these boxes
   is centred with the 1 px optical lift (2 px bottom padding). */
:root { --ctrl-h: 48px; }
/* …except DROPDOWNS: 56 px (user 2026-11-17 — "I meant dropdowns should be
   56 height"; the chevron square follows: 56 − 16 = 40). */
:root { --dd-h: 56px; }
/* GREYED-OUT buttons (disabled / locked) — user 2026-11-17: a PANEL fill
   with the label / icon in UI/Highlight, at full opacity (a 40 % fade
   washed the fill out with everything else). Used by every rule marked
   "greyed" below. */
/* KEYBOARD ONLY (user 2026-11-17): every stroke below needs :root.kbd-focus
   — set by Tab, cleared by any press (key-focus.js). A click never strokes
   a field, a dropdown or a colour; ⌘Z / ⇧⌘Z do (.undo-flash). */
:root.kbd-focus .ctrl-stepper:has(:focus),
:root.kbd-focus .ctrl-input:has(input:focus),
:root.kbd-focus .ctrl-value:has(input:focus),
/* (Dropdowns draw their stroke as an overlay — see .ctrl-dropdown::before
   below; the keywords control strokes only its text field, user 2026-11-17.) */
:root.kbd-focus .ctrl-textfield-box:has(:focus),
:root.kbd-focus .ctrl-keywords-input-box:not(.is-editing-word):has(input:focus),
:root.kbd-focus .ctrl-color-field:has(input:focus),
:root.kbd-focus .clr-cimble-field:has(input:focus),
:root.kbd-focus .prompt-key-input:focus,
:root.kbd-focus .doc-composer-input:focus,
:root.kbd-focus .doc-composer-key:focus,
:root.kbd-focus .toggle-switch:has(input:focus-visible),
:root.kbd-focus button:focus-visible,
:root.kbd-focus [role="button"]:focus-visible,
:root.kbd-focus a:focus-visible {
  outline: 1px solid var(--focus-stroke);
  outline-offset: -1px;
}
/* A dropdown: the WHOLE dropdown while it's open (header + list — user
   2026-11-17); closed, only keyboard focus. Drawn as an overlay ABOVE its
   header (an outline was painted under the header, which sits on z-index 1
   with its own fill, so the stroke's top was cut off — user 2026-11-17). */
/* (An undo / redo flash on a dropdown uses the same overlay — its outline
   would be under the header too.) */
:root.kbd-focus .ctrl-dropdown.open::before,
:root.kbd-focus .ctrl-dropdown:not(.open):focus-visible::before,
:root.kbd-focus .ctrl-dropdown:not(.open):has(:focus-visible)::before,
.ctrl-dropdown.undo-flash::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--focus-stroke);
  pointer-events: none;
  z-index: 3;
}
/* A slider: the stroke is on its track — the pill itself — inset like every
   other control's, so it follows the pill's rounding (user 2026-11-16: the
   track row's 8 px box showed corners). */
:root.kbd-focus .ctrl-slider-row input[type="range"]:focus {
  outline: 1px solid var(--focus-stroke);
  outline-offset: -1px;
}
/* A colour circle: its input is invisible on top (opacity 0) — the ring is
   drawn by the circle's ::after, right on its edge (user 2026-11-17; it
   used to be an outline 2 px outside). */
/* The control an undo / redo just changed (tool-page.js#flashUndoTarget). */
.undo-flash { outline: 1px solid var(--focus-stroke) !important; outline-offset: -1px; }
.ctrl-dropdown.undo-flash { outline: none !important; }   /* its ::before overlay instead */
/* A sidebar colour being picked (user 2026-11-17): the CIRCLE that was
   clicked carries the stroke (just outside it, like keyboard focus); its
   hex / % field only when IT is typed in. Typing in a picker field moves
   the stroke there — one stroke at a time. */
/* (the ring itself: .color-swatch::after rules by .color-swatch-fill) */
/* The text layer's colour = a 40 px box around a small circle: the BOX
   carries the stroke (inset, like the popup's other boxes), not the circle. */
:root.kbd-focus .layer-text-color:has(input:focus),
:root.kbd-focus .layer-text-color.is-picking { outline: 1px solid var(--focus-stroke); outline-offset: -1px; }
/* (.is-picking: while ITS picker is open — the picker's hex field takes the
   focus right away, and the box lost its stroke; user 2026-11-17.) */
/* (its circle shows no ring then — .color-swatch::after rules) */
/* Parts INSIDE a stroked control never get their own. */
.ctrl-stepper-zone:focus-visible,
.ctrl-dropdown :focus-visible,
.ctrl-textfield-box :focus-visible { outline: none; }
.ctrl-stepper-glyph {
  display: block;
  width: 9px;
  height: 9px;
  /* Hovering EITHER side lights that side's square (.ctrl-stepper-hit)
     and scales its glyph 9 → 11 px (Figma 702:3296); pressing bounces
     down to 0.94. Scaling the glyph rather than the zone keeps the
     stepper's flex layout stable. */
  transition: transform 0.15s ease;
}
/* Hover scopes to (hover: hover) — iOS Safari sticks the :hover state
   after a tap, so the glyph would stay scaled-up after release. The
   :active rule (outside the media query) still fires on touch press
   to give the tactile dip. Same pattern used on .ratio-pill /
   .export-pill / .layers-fab / .sheet-settings-btn. */
@media (hover: hover) {
  .ctrl-stepper-zone:not(.suppress-hover):hover .ctrl-stepper-hit { background: var(--color-stroke-hi); }
  /* 9 → 11 px on hover, the Figma hover glyph size (was 1.4×, before the
     square carried the hover cue). */
  .ctrl-stepper-zone:not(.suppress-hover):hover .ctrl-stepper-glyph { transform: scale(1.2222); }
  .ctrl-stepper-zone:not(.suppress-hover):hover:active .ctrl-stepper-glyph { transform: scale(0.94); }  /* dip wins over the hover scale */
}
.ctrl-stepper-zone:active .ctrl-stepper-glyph { transform: scale(0.94); }
.ctrl-stepper-value {
  /* Hug content — the value zone is only the number + optional unit
     text. Drag-scrub fires only here, not on the surrounding empty
     space (which now belongs to the –/+ zones). */
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  /* Drag-scrub affordance — works whether the user clicks to type or
     drags to scrub. JS prevents text selection during drag. */
  cursor: ew-resize;
  /* Hover-highlight rect — the SAME component as .ctrl-value (slider) and
     .ctrl-input-value (input): 4 / 6 / 5 padding, 6 px radius, UI/Highlight
     fill on hover or while typing (user rule 2026-11-11). min 48 px like
     theirs, but it GROWS with the value (no clipping — the ± zones leave
     room), so a committed value is never cut off. */
  min-width: 48px;
  padding: 4px 6px 5px;
  box-sizing: border-box;
  border-radius: 6px;
  /* .ctrl-stepper stretches its children (so the ± zones fill the full
     height); the value rect must NOT — it hugs the text like the others. */
  align-self: center;
  transition: none;
}
.ctrl-stepper-value:hover,
.ctrl-stepper-value:focus-within {
  background: var(--color-stroke-hi);
}
.ctrl-stepper-value:hover .ctrl-stepper-unit,
.ctrl-stepper-value:focus-within .ctrl-stepper-unit {
  color: var(--color-off-white);
}
.ctrl-stepper-input {
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  /* P2b (500 13.6/17 / 0.35) Off-White — matches the centered value
     treatment in Figma 105:1663. */
  color: var(--color-off-white);
  font: 600 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  /* width is set inline by buildStepper sizeInput() in ch units to keep the
     value visually centered between the – / + buttons. */
}
.ctrl-stepper-input::-webkit-outer-spin-button,
.ctrl-stepper-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.ctrl-stepper-input:focus {
  outline: none;
  color: var(--color-off-white);
}
.ctrl-stepper-unit {
  color: var(--color-text);
  font: 600 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
}

/* `input` control — pill-shaped value field. Same visual envelope as
   .ctrl-stepper (55 px tall, 8 px radius, --color-input bg) but with no
   +/- zones. Figma 359:1306 — paired side-by-side layout via .ctrl-row
   below. The value zone FILLS the box (user rule 2026-11-12): the whole
   box is one surface — it lights on hover, drags to scrub and clicks into
   typing (value selected) from anywhere inside it, and the text has no
   hover state of its own. Same model as the text-layer popup's number
   fields. */
.ctrl-input {
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-height: var(--ctrl-h);
  padding: 0;
  border-radius: 8px;
  background: var(--color-input);
  box-sizing: border-box;
  user-select: none;
  transition: none;
}
/* ONE element owns the fill (user 2026-11-12, hover flicker): the box
   itself, which clips nothing — not the value zone inside it, which clips
   the text field. */
.ctrl-input:hover,
.ctrl-input:focus-within {
  background: var(--color-stroke-hi);
}
.ctrl-input-value {
  /* The whole box's scrub / click / hover zone — it paints nothing (the
     box above owns the fill). The 16 px side inset (the box's old padding)
     keeps value + unit clear of the edges; a value too long for it takes
     the whole width instead (fitInputWidth clipTo). */
  flex: 1 1 auto;
  width: 100%;
  padding: 0 16px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: ew-resize;
  min-width: 0;
  /* Clip at the BOX edge (not the inner padding): a long typed value
     stretches over the padding and scrolls inside (fitInputWidth clipTo).
     A plain rectangular clip — no border-radius here: a rounded overflow
     clip around the text field is a mask layer in WebKit, and repainting
     it on hover is the likely source of the hover flicker (2026-11-12). */
  overflow: hidden;
}
/* Not typing: the text is just part of the surface — the box's scrub
   cursor, no I-beam of its own. Typing: the normal text cursor. */
.ctrl-input-value:not(:focus-within) .ctrl-input-input { cursor: inherit; }
.ctrl-input:hover .ctrl-input-unit,
.ctrl-input:focus-within .ctrl-input-unit {
  color: var(--color-off-white);
}
.ctrl-input-input {
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--color-off-white);
  /* P2b — matches .ctrl-stepper-input. Width set inline by sizeInput()
     in ch units so the centered value stays centered across digit counts. */
  font: 600 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.ctrl-input-input::-webkit-outer-spin-button,
.ctrl-input-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.ctrl-input-input:focus {
  outline: none;
  color: var(--color-off-white);
}
.ctrl-input-unit {
  color: var(--color-text);
  font: 600 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
}

/* Side-by-side row for input pairs (e.g. Padding X / Padding Y). Each
   child .ctrl shares the available width equally. 10 px gap per Figma
   359:1306. Inputs only — NOT for steppers/sliders (the previous side-
   by-side stepper layout was rejected; see feedback_typography_section). */
.ctrl-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  width: 100%;
}
.ctrl-row > .ctrl {
  flex: 1 1 0;
  min-width: 0;
}

/* Size section (user 2026-11-13): Aspect Ratio, Width / Height, then the
   tool's Margin X / Y — cfg group "Size", rendered into the section by
   controls.js. The wrapper is layout-transparent so its rows keep the
   section's 24 px rhythm. */
.ctrl-size-cfg { display: contents; }

/* Number value — plain text on the right of the label row (no chip background). */
.ctrl-value {
  flex: 0 0 auto;
  /* Hover-highlight target — same component family as `.settings-popup-item`
     and `.ctrl-dropdown-row`: 6 px radius, `--color-stroke-hi` hover fill,
     off-white text on hover. Fixed 48 px width with 4/6/5 padding; the
     input + unit cluster is centred inside via `justify-content: center`
     (not `flex-end`) so the value reads as a balanced block rather than
     a right-anchored ticker. */
  width: 48px;
  padding: 4px 6px 5px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  /* Drag to scrub, click to type (user 2026-11-13) — like `.ctrl-input-value`. */
  cursor: ew-resize;
  /* Clip at the BOX edge (not the inner padding): a long typed value
     stretches over the padding and scrolls inside (fitInputWidth clipTo). */
  overflow: hidden;
  transition: none;
}
.ctrl-value:not(:focus-within) .ctrl-value-input { cursor: inherit; }
/* While a typed value overflows the fixed box, the unit suffix steps aside
   so the value gets the whole box (back as soon as it fits again). */
.value-overflow .ctrl-value-unit,
.value-overflow .ctrl-input-unit { display: none; }
.ctrl-value:hover,
.ctrl-value:focus-within {
  /* `:focus-within` keeps the highlight visible while the user is typing
     in the input — clicking the box → input takes focus → box stays lit
     until the user clicks/tabs away, mirroring how editable fields work
     in the rest of the UI. */
  background: var(--color-stroke-hi);
}
/* Brighten on hover OR focus. `:not(.over-range)` keeps the red flag
   winning when the typed value is outside the slider's [min,max] — the
   bg still highlights, but the number stays red so the over-drive cue
   isn't lost. */
.ctrl-value:hover .ctrl-value-input:not(.over-range),
.ctrl-value:focus-within .ctrl-value-input:not(.over-range),
.ctrl-value:hover .ctrl-value-unit,
.ctrl-value:focus-within .ctrl-value-unit {
  color: var(--color-off-white);
}

/* (The historical `.ctrl-label-row:has(.ctrl-value) .ctrl-label`
   override that gave slider labels 4 / 6 / 5 padding has been retired
   — the canonical `.ctrl-label` already carries 4 / 2 / 5, so the
   slider's label baseline lines up with the value chip's text by
   default. Restoring the override would re-create the visual
   inconsistency where slider labels sat 4 px right of every other
   control's label. See the .ctrl-label rule above for the full
   rationale.) */
.ctrl-value-input {
  /* Width is set inline by `sizeSliderValueInput()` in controls.js based
     on the current value's char count, so the unit sits flush against
     the value with no internal whitespace. The 1 ch fallback only
     applies for one frame before the JS sets a real width. */
  width: 1ch;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--color-off-white);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.ctrl-value-input::-webkit-outer-spin-button,
.ctrl-value-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ctrl-value-input:focus { outline: none; color: var(--color-off-white); }
/* Typed value outside the slider's [min,max] range (over-driving the effect).
   Scoped with :focus too so it stays red while the user is typing it. */
.ctrl-value-input.over-range,
.ctrl-value-input.over-range:focus { color: var(--color-accent-red); }
.ctrl-value-unit {
  color: var(--color-text);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  margin-left: 2px;
}

/* ───── Component: Color swatch ───── */
/* 8 px between swatches — a touch tighter than the square media tiles'
   10 px: round shapes read as further apart, so this matches optically
   (user rule 2026-11-11). */
.color-row { display: flex; flex-wrap: wrap; gap: 8px; }
/* Color grid (user layout rule 2026-11-10) — TWO fixed-width columns
   (--color-col, 80 px) at the default (narrowest) sidebar, more as it
   widens; nothing scales. A group (label + swatches) with 1 or 2 colors
   takes one column (36 + 8 + 36 = 80 px); 3+ colors take the full row
   with swatches packed left to right (8 px apart).
   Rows of groups are 20 px apart, the standard gap between controls. */
.ctrl-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--color-col));
  column-gap: 10px;
  row-gap: 20px;
  width: 100%;
}
.ctrl-color-group {
  display: flex;
  flex-direction: column;
  /* 12 px label → swatches (Figma 66:875). */
  gap: 12px;
  /* Swatches pinned to the bottom so a neighbour's taller label can't
     knock them out of line (labels are single-line, but the row height
     is still shared). */
  justify-content: space-between;
  min-width: 0;
}
.ctrl-color-group.span-1   { grid-column: span 1; }
.ctrl-color-group.span-all { grid-column: 1 / -1; }
.ctrl-color-group-label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.color-swatch {
  position: relative;
  /* 36 × 36 (user rule 2026-11-11, was 39 → 35 → 36) — TWO swatches + the
     8 px swatch gap fill one 80 px --color-col exactly: 36 + 8 + 36 = 80.
     36 × 36 visible = 35 × 35 fill + 0.5 px hairline on each side. The
     hairline is painted by ::after below (inset box-shadow on a pseudo)
     because `border: 0.5px solid` rasterizes unevenly along the circular
     curve in Chrome — same crunchy artifact as the frame. The earlier
     implementation used `box-sizing: content-box` + a real 1 px border to
     keep the fill at exactly 35 × 35 with the stroke drawn OUTSIDE; with
     the new approach the box itself is 36 × 36 (border-box, inherits the
     global) and the fill sits inset 0.5 px so its edge butts up against
     the inside of the hairline. */
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  /* No background and no clipping here — .color-swatch-fill is the whole
     visible circle (colour over checker, one element) and ::after its
     hairline / active ring (2026-11-17). */
  /* Same hover/click affordance as buttons: scale 1.1 on hover, 0.96
     click-bounce. The 0.15 s transition matches .btn-ctrl so a hovered
     color and a hovered button feel like one design system. */
  transition: transform 0.15s ease;
}
.color-swatch:not(.suppress-hover):hover  { transform: scale(1.1); }
/* ACTIVE = ENLARGED (user 2026-11-17, final — "I do want layers button,
   color circles and other buttons and icons to stay in their enlarged state
   while active"): a circle whose picker is open keeps its hover size (and
   its ring); a press still dips. Same for every button / icon whose menu or
   popup is open — the rules marked "active = enlarged". */
.color-swatch.is-open:not(:active) { transform: scale(1.1); }

/* ───── Component: Color rows (Figma 66:875, redesigned 2026-11-16) ─────
   The label, then ONE ROW PER COLOUR (10 px apart): a 55 px slot with the
   39 px swatch · the hex + opacity field (55 px, UI/Input, fills the row) ·
   a 55 px × (palette controls only). A palette ends with a "+" row (an
   empty ring + a full-width +), its × slot kept so the + lines up with the
   fields. controls.js#buildColorBlock / buildColorRow / buildPalette. */
.ctrl-color-block { gap: 12px; container-type: inline-size; }
.ctrl-color-rows { display: flex; flex-direction: column; gap: 10px; }
.ctrl-color-row { display: flex; align-items: center; gap: 10px; }
.ctrl-color-slot {
  /* As wide as the 39 px circle at EVERY sidebar width (user 2026-11-17:
     the circle → field gap changed when the panel got narrow — a 48 px
     slot centred the circle 4.5 px in, a narrow block tightened it to 39),
     so the gap is always the row's 10 px; as tall as the row. */
  flex: 0 0 39px;
  width: 39px; height: var(--ctrl-h);
  display: flex; align-items: center; justify-content: center;
}
/* 39 px (user 2026-11-17: back to this after trying 55 and 53-hovering-
   to-58 the same day). */
.ctrl-color-slot .color-swatch { width: 39px; height: 39px; }
.ctrl-color-empty {
  width: 39px; height: 39px;   /* the colour circles' size */
  box-sizing: border-box;
  padding: 0;
  border-radius: 50%;
  /* No stroke (user 2026-11-17 — a ring read as "highlighted"): a plain disc
     in the "+" button's UI/Input. */
  border: none;
  background: var(--color-input);
  cursor: pointer;
  transition: transform 0.15s ease;
}
/* The empty circle + the "+" are ONE add control (user 2026-11-17):
   hovering either grows the circle (like a colour circle) and lights the
   "+" (its fill, the icon 1.2). */
.ctrl-color-add-row:has(.ctrl-color-empty:hover, .ctrl-color-add:hover) .ctrl-color-empty { transform: scale(1.1); }
.ctrl-color-add-row:has(.ctrl-color-empty:hover, .ctrl-color-add:hover) .ctrl-color-add { background: var(--color-stroke-hi); }
.ctrl-color-add-row:has(.ctrl-color-empty:hover, .ctrl-color-add:hover) .ctrl-color-add svg { transform: scale(1.2); }
.ctrl-color-add-row:has(.ctrl-color-empty:active, .ctrl-color-add:active) .ctrl-color-empty { transform: scale(0.94); }
.ctrl-color-field {
  flex: 1 1 auto;
  min-width: 0;
  height: var(--ctrl-h);
  box-sizing: border-box;
  padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
  border-radius: 8px;
  background: var(--color-input);
  cursor: text;
  transition: none;
}
.ctrl-color-field:hover,
.ctrl-color-field:focus-within,
.ctrl-color-field.is-scrubbing { background: var(--color-stroke-hi); }
.ctrl-color-hex,
.ctrl-color-alpha-input {
  margin: 0; padding: 0; border: none; outline: none;
  background: transparent;
  color: var(--color-off-white);
  /* A typed field: the single-line text fields' style (500 13.6 / 17 —
     user 2026-11-17). */
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
}
.ctrl-color-hex { flex: 1 1 auto; min-width: 0; text-overflow: ellipsis; }   /* no room → "ff00…" (the × never shrinks) */
/* "#" — a grey label like a stepper's "px" (UI/Text), right before the
   digits (no gap: it reads as one value). */
.ctrl-color-hash {
  flex: none;
  margin-right: -12px;   /* cancels the field's 12 px gap, so "#" sits against the digits */
  color: var(--color-text);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  cursor: text;
}
.ctrl-color-alpha {
  flex: 0 0 auto;
  display: inline-flex; align-items: center;
  color: var(--color-off-white);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  cursor: ew-resize;
  user-select: none;
}
.ctrl-color-alpha-input { width: 3ch; text-align: right; font-variant-numeric: tabular-nums; cursor: inherit; }
/* (No hover box of its own for the opacity — the whole field lights, user
   2026-11-17: a value chip and a stepper-style square were both tried.) */
.ctrl-color-alpha-input:focus { cursor: text; }
.ctrl-color-alpha-unit { color: var(--color-text); }
.ctrl-color-remove,
.ctrl-color-add {
  height: var(--ctrl-h);
  border: none;
  border-radius: 8px;
  background: var(--color-input);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  cursor: pointer;
}
.ctrl-color-remove {
  flex: 0 0 var(--ctrl-h);
  width: var(--ctrl-h);   /* always a square, the row's height */
  color: var(--color-text);
  transition: transform 0.15s ease;
}
/* A square button: the whole button grows on hover. */
.ctrl-color-remove:not(:disabled):hover { transform: scale(1.1); background: var(--color-stroke-hi); color: var(--color-off-white); }
.ctrl-color-remove:not(:disabled):hover:active { transform: scale(0.94); }
.ctrl-color-remove.is-hidden { visibility: hidden; pointer-events: none; }
/* The + spans the field's width: a row-like button — fill lights, icon grows. */
.ctrl-color-add {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--color-off-white);
  transition: none;
}
.ctrl-color-add svg { transition: transform 0.15s ease; }
.ctrl-color-add:hover { background: var(--color-stroke-hi); }
.ctrl-color-add:hover svg { transform: scale(1.2); }
.ctrl-color-add:active svg { transform: scale(0.94); }
/* NOTHING changes with the sidebar's width (user 2026-11-17): the slot (=
   the circle), the × (a full --ctrl-h square) and the field's 16 px sides +
   12 px gap stay — the hex digits truncate instead (.ctrl-color-hex
   ellipsis). (A narrow block used to tighten the slot.) */
.color-swatch:active { transform: scale(0.94); }
.color-swatch:not(.suppress-hover):hover:active { transform: scale(0.94); }  /* dip wins over hover */
.color-swatch::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 0.5px var(--color-stroke-faint);
  pointer-events: none;
  z-index: 3;   /* over the fill (1) and a see-through colour's inner circle (2) */
}
/* (The checker used to be a ::before inset 1 px under a fill inset 0.5 px —
   a semi-transparent colour showed a ring where only one covered.) */
.color-swatch input[type="color"],
.color-swatch input.coloris,
.color-swatch .clr-field {
  position: absolute !important; inset: 0 !important;
  width: 100% !important; height: 100% !important;
  border: none !important; padding: 0 !important;
  background: transparent !important; cursor: pointer !important;
  opacity: 0 !important;
}
/* ONE circle, one edge (user 2026-11-17: "clean these circles up"): the
   colour and the transparency checker are two background layers of the SAME
   element — no ring where a checker and a fill of different sizes met. The
   colour comes in as --swatch-color (controls.js buildColor). The checker is
   the canvas frame's (Panel + Input squares), five layers spelled out. */
.color-swatch-fill {
  position: absolute; inset: 0; border-radius: 50%; z-index: 1;
  /* The checker one step LIGHTER than the canvas frame's (Input + Highlight
     squares, not Panel + Input): with no hairline, a see-through circle's
     dark squares would melt into the panel and break up its outline. */
  --checker-base: var(--color-input);
  --checker-sq: var(--color-stroke-hi);
  background-color: var(--checker-base);
  background-image: linear-gradient(var(--swatch-color, transparent), var(--swatch-color, transparent)),
    linear-gradient(45deg,  var(--checker-sq) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-sq) 25%, transparent 25%),
    linear-gradient(45deg,  transparent 75%, var(--checker-sq) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-sq) 75%);
  background-size: 100% 100%, 12px 12px, 12px 12px, 12px 12px, 12px 12px;
  background-position: 0 0, 0 0, 0 6px, 6px -6px, -6px 0;
}
/* The active colour (picking it, or keyboard focus): its hairline becomes
   the active stroke RIGHT ON the circle's edge — half over the fill's edge,
   half outside, so there's no gap or dark seam between ring and colour. */
:root.kbd-focus .color-swatch:has(input:focus)::after,
.ctrl-color-row.is-picking .color-swatch::after {
  inset: 0.5px;
  box-shadow: 0 0 0 1px var(--focus-stroke);
}
/* (.is-picking is the ONE click stroke kept — user 2026-11-17: a clicked
   circle whose picker is open has nothing else showing it's the one being
   edited: no selected text, no wash. With the keyboard, typing in a picker
   field moves the stroke there — one stroke at a time; a CLICK into a picker
   field strokes nothing, so the circle keeps its ring.) */
:root.kbd-focus .ctrl-color-row.is-picking.picker-typing .color-swatch:not(.is-translucent)::after,
.layer-text-color .color-swatch:not(.is-translucent):has(input:focus)::after {
  inset: 0;
  box-shadow: inset 0 0 0 0.5px var(--color-stroke-faint);
}
/* A see-through colour (below 100 %, user 2026-11-17): a SOLID circle of the
   colour at 100 % in the middle (half the diameter, its own crisp circle) on
   the see-through colour over the checker — you see what it would be, even
   at 0 %. No hairline around these (it read as a glitch); one clean edge.
   (A 3 px solid ring round the edge came first — the user preferred this.) */
.color-swatch.is-translucent::before {
  content: "";
  position: absolute;
  inset: 25%;
  border-radius: 50%;
  background: var(--swatch-solid);
  z-index: 2;
  pointer-events: none;
}
.color-swatch.is-translucent::after { box-shadow: none; }
:root.kbd-focus .ctrl-color-row.is-picking.picker-typing .color-swatch.is-translucent::after,
.layer-text-color .color-swatch.is-translucent:has(input:focus)::after { inset: 0; box-shadow: none; }
/* The old hover name tip (unused — tooltips are hints.js); the swatch no
   longer clips it. */
.color-swatch-label { display: none !important; }
.color-swatch-label {
  position: absolute;
  top: calc(100% + 4px); left: 50%;
  transform: translateX(-50%);
  font: 600 11px/1var(--font-text);
  color: var(--color-text);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.color-swatch:not(.suppress-hover):hover .color-swatch-label { opacity: 1; }

/* The colour picker = one of our popups (user 2026-11-17): no border, the
   popup surface + shadow (.layer-settings-popup: Panel, 16 px radius,
   --shadow-frame, 12 px padding), 12 px between its parts. Coloris's round
   field, preview circle and format toggle are hidden — controls.js
   #ensurePickerPanel builds the Hex | RGB | HSL switch + fields. */
.clr-picker {
  width: 224px !important;
  box-sizing: border-box;
  border-radius: 16px !important;
  border: none !important;
  background: var(--color-panel) !important;
  box-shadow: var(--shadow-frame) !important;
  padding: 12px !important;
  row-gap: 12px;
}
.clr-picker .clr-gradient { height: 128px; margin: 0; border-radius: 8px; }
.clr-picker .clr-hue,
.clr-picker .clr-alpha { width: calc(100% - 16px); margin: 2px 8px 0; }
.clr-picker .clr-preview,
.clr-picker .clr-color,
.clr-picker .clr-format { display: none !important; }
.clr-cimble { order: 1; width: 100%; display: flex; flex-direction: column; gap: 8px; }
.clr-cimble-format .layer-segmented-btn {
  /* The picker is a POPUP: the popups' text style, like their dropdowns /
     fields (500 13.6 / 17, user 2026-11-17 — it was 600 12.5 px). The
     sidebar's own values stay 600. */
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
}
.clr-cimble-fields { display: flex; gap: 8px; }
.clr-cimble-field {
  flex: 1 1 0;
  min-width: 0;
  height: var(--input-row-h);
  box-sizing: border-box;
  padding: 0 10px;
  display: flex; align-items: center; gap: 6px;
  border-radius: 8px;
  background: var(--color-input);
  cursor: text;
  transition: none;
}
.clr-cimble-field:hover,
.clr-cimble-field:focus-within { background: var(--color-stroke-hi); }
.clr-cimble-unit { flex: 0 0 auto; color: var(--color-text); font: 500 13.6px/17px var(--font-display); letter-spacing: 0.35px; }
.clr-cimble-field input {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0; padding: 0; border: none; outline: none;
  background: transparent;
  color: var(--color-off-white);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.clr-cimble-field.is-hex input { text-align: left; }
.clr-field { display: none !important; }

/* ───── Component: Boolean (toggle) — see DESIGN-SYSTEM.md §Boolean ─────
   Label row holds label (left) + state text "On"/"Off" (right). The pill
   sits below, flex-start aligned so it hugs content. Handle position is
   driven by asymmetric padding (no absolute positioning) so the transition
   is a single padding/background tween. */
.toggle-row { display: flex; justify-content: space-between; align-items: center; }
/* State text ("On" / "Off") sits next to the label in the row. Color
   reflects the current state — UI/Text grey when OFF, Off-White when
   ON. Clicking the text toggles the switch (wired in
   controls.js#buildToggle); hovering the text previews the action
   via the :hover rules below. The previous `:has(.toggle-switch:hover)`
   preview was retired — it forced a global :has() restyle that
   caused other Reset links to flicker on toggle commits, and the
   "hover the text to preview" interaction reads more directly. */
.toggle-state {
  padding: 2px;
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
  transition: none;
}
.toggle-state.on { color: var(--color-off-white); }
/* Hover the state text → preview the action a click would commit,
   but only when currently OFF. The ON state stays at off-white on
   hover (no preview-back-to-grey) — clicking the brighter text to
   commit a change reads as the affirmative action, and the ON
   appearance doesn't get a second "previewing OFF" affordance. */
.toggle-state:hover    { color: var(--color-off-white); }
.toggle-state.on:hover { color: var(--color-off-white); }

.toggle-switch {
  position: relative;
  display: flex;
  align-items: center;
  width: 60px;
  height: 32px;
  padding: 0 28px 0 0;   /* the knob FILLS the track's height (user 2026-11-17: "always take up the entire container") */
  border-radius: var(--radius-pill);
  /* OFF colors (Figma 482:1888): track UI/Highlight, handle Off-White. */
  background: var(--color-stroke-hi);
  align-self: flex-start;
  cursor: pointer;
  box-sizing: border-box;
  /* Explicit padding-left/right (instead of shorthand `padding`) so
     the browser interpolates the handle slide reliably across engines
     — Safari was inconsistent with shorthand `padding` transitions. */
  transition: padding-left  150ms ease,
    padding-right 150ms ease;
}
.toggle-switch::after {
  content: "";
  width: 32px;
  height: 32px;
  border-radius: 50%;
  /* OFF handle: Brand/Off-White on the dim UI/Highlight track. */
  background: var(--color-off-white);
  transition: none;
}
/* Hover (user 2026-11-17): the buttons' 10 % white wash on the TRACK (an
   inset shadow paints under the knob, so the knob stays Off-White), at once
   — no colour fades. (A knob that grew to fill the track on hover came
   first; the user made the full-size knob permanent instead.) */
@media (hover: hover) {
  .toggle-switch:not(.disabled):hover { box-shadow: inset 0 0 0 9999px var(--color-hover-overlay); }
}
/* ON colors (Figma 482:1899): track flips to UI/Accent Blue, handle
   stays Brand/Off-White. The 150 ms transitions on .toggle-switch
   (padding + background) AND on .toggle-switch::after (background)
   tween in lockstep — the handle slides from left to right via the
   padding swap and the track shifts from grey to blue. The handle
   keeps its off-white colour so it reads as the same disc moving,
   not a second state change. */
.toggle-switch.on            { padding: 0 0 0 28px; background: var(--color-accent); }
.toggle-switch.on::after     { background: var(--color-off-white); }
.toggle-switch input         { position: absolute; opacity: 0; pointer-events: none; }
/* Disabled — browser doesn't support Local Font Access API
   (Safari / Firefox). The pill stays in its OFF visual + 40 % opacity
   to read as inert, with cursor: default so it doesn't feel like
   something the user can click. */
.toggle-switch.disabled      { cursor: default; opacity: 0.4; pointer-events: none; }
/* In a layer popup (the Shadow switch): smaller by the popup's own ratio —
   its rows are 40 px where the sidebar's are 55 (× 0.73): 44 × 23, the knob
   filling its height (23), like the sidebar's 32 in 32. */
.layer-settings-popup .toggle-switch { width: 44px; height: 23px; padding: 0 21px 0 0; align-self: center; }
.layer-settings-popup .toggle-switch::after { width: 23px; height: 23px; }
.layer-settings-popup .toggle-switch.on { padding: 0 0 0 21px; }

/* ───── Component: Button control ("Action" variant) ─────
   Hugs its content (not full-width). Aligned to the start of the .ctrl flex
   column so it sits under the label row at the left edge. */
.btn-ctrl {
  position: relative;
  align-self: flex-start;
  /* Canonical pill padding — see .ratio-pill / .export-pill. */
  padding: 18px 20px;
  /* Canonical 56 px in-panel button height (--btn-h) — same baseline
     as `.ratio-pill`. */
  min-height: var(--btn-h);
  /* Resting: UI/Highlight fill + Off-White label — the button reads
     fully "on" at rest. Hover keeps every color the same and only
     scales 1.1 + layers in the 10 % white wash; click bounces to 0.96
     then springs back via the existing transform transition. */
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
  border: none;
  border-radius: var(--radius-pill);
  font: 600 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  cursor: pointer;
  transition: transform   0.15s ease,
    opacity     0.15s ease;
  /* Transparent inset baseline so :hover can tween a translucent white
     overlay into existence without a shadow-list length mismatch. */
  box-shadow: inset 0 0 0 9999px transparent;
}
.btn-ctrl:not(:disabled):not(.prompt-run):not(.suppress-hover):hover {
  /* Scale + wash only. No color change — the label was already
     Off-White at rest. */
  transform: scale(var(--hover-grow, 1.1));
  box-shadow: inset 0 0 0 9999px var(--color-hover-overlay);
}
/* Click bounce. The :active selector MUST mirror the hover rule's full
   specificity (0,5,0) — INCLUDING `:not(.suppress-hover)` — and sit after it.
   The earlier `:active` was only (0,4,0), so the hover's scale(1.1) [(0,5,0)]
   out-specified it and clicks-while-hovering stayed at 1.1 — the bounce was
   invisible (the "Randomize bug"; the old comment wrongly claimed parity). */
.btn-ctrl:not(:disabled):not(.prompt-run):not(.suppress-hover):active { transform: scale(0.94); }
.btn-ctrl.prompt-run.is-active:not(.suppress-hover):active           { transform: scale(0.94); }
.btn-ctrl:disabled { background: var(--color-panel); color: var(--color-stroke-hi); cursor: not-allowed; }   /* greyed (2026-11-17; was 40 %) */

/* Run button (instruction prompt) — gated by textfield input.
   • Empty input: button stays at the .btn-ctrl resting treatment with
     NO hover affordance (the prompt itself is the call-to-action, not
     the button).
   • Text entered: prompt-ui.js adds `.is-active`. The button takes
     the action-coloured treatment (stroke-hi bg + off-white text)
     unconditionally — that IS its activated baseline. Hover then
     adds only a 1.1 scale + the translucent white wash; no further
     colour change. Click-bounce (0.96) inherits from .btn-ctrl. */
/* Inactive Run button (no prompt typed) reads as not-yet-clickable —
   the bg drops back to UI/Input and the label sits in UI/Highlight so
   it fades into a dim resting surface that's clearly NOT in the
   filled-button state. Cursor stays as the default arrow. Clicking
   still fires the shake in prompt-ui.js so the user sees the "needs
   input" affordance. */
.btn-ctrl.prompt-run:not(.is-active) {
  cursor: default;
  background: var(--color-panel);   /* greyed (2026-11-17; was UI/Input) */
  color: var(--color-stroke-hi);
}
/* Active Run takes the canonical filled-button look (UI/Highlight fill,
   Off-White label at rest). Hover only adds the 10 % wash + scale 1.1
   — no color change, matching the rest of `.btn-ctrl` so the activated
   Run reads as a peer of Randomize / cfg buttons. */
.btn-ctrl.prompt-run.is-active {
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
}
.btn-ctrl.prompt-run.is-active:not(.suppress-hover):hover {
  transform: scale(var(--hover-grow, 1.1));
  box-shadow: inset 0 0 0 9999px var(--color-hover-overlay);
}

/* ───── Component: Dropdown (Figma 159:2372 collapsed / 163:474 expanded) ─────
   Canonical dropdown for the design system. See controls.js#buildDropdown
   for the matching JS + click semantics. Anything new that opens/closes
   should reuse this component verbatim — don't fork.

   STRUCTURE
     .ctrl-dropdown                — outer panel.
       .ctrl-dropdown-header       — ALWAYS visible. Current selection + chevron.
       .ctrl-dropdown-options      — collapsible menu below the header.
         .ctrl-dropdown-row        — one per pickable option.

   INTERACTION RULES (codified — apply to every dropdown)
     • Closed: clicking anywhere on the panel opens it.
     • Open: clicking ANYWHERE on an option row (left, right, text — the
       whole row is the hit target) applies that option + closes. Clicks
       inside the panel but NOT on a row (header, chevron, padding) close
       without applying.
     • Click-outside closes without applying.

   MOTION
     Expansion uses --transition-collapse (shared with the Navigator tool
     dropdown). Chevron rotation uses --transition-icon.
*/
.ctrl-dropdown {
  display: flex;
  flex-direction: column;
  width: 100%;
  /* Figma 499:1222: bg --color-input, 8 px radius, NO outer padding.
     The header carries its own 18 / 16 padding and the options list
     carries its own 0 / 16 / 18 / 16 padding, so rows clip at the
     dropdown's rounded outer corners (via overflow: hidden) rather
     than at an inner padding edge. min-height: 55 px so the
     COLLAPSED dropdown stays the same height as Stepper + single-
     line TextField. */
  min-height: var(--dd-h);
  box-sizing: border-box;
  background: var(--color-input);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  outline: none;
  overflow: hidden;
  position: relative;
  /* Button-style hover lift on the CLOSED surface — see
     `:not(.open):not(.suppress-hover):hover` below. */
  transition: none;
  box-shadow: inset 0 0 0 9999px transparent;
}
.ctrl-dropdown:not(.open):not(.suppress-hover):not(.is-disabled):hover {
  background: var(--color-stroke-hi);
  box-shadow: inset 0 0 0 9999px var(--color-hover-overlay);
}
.ctrl-dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  /* Figma 499:1240 — 18 / 16 padding lives ON the header now (the
     outer dropdown is paddingless). bg matches the outer dropdown so
     the header sits as a continuous strip across the top when the
     dropdown is open. */
  /* Right side reserves the chevron's square (.ctrl-dropdown-arrow-hit:
     its width + 8 px inset) plus the 8 px gap to the text — the square is
     positioned, not in flow, and a long value must never touch it. */
  /* --ctrl-h tall, the text (17 px line + 2 px lift) centred — the same
     height as every other box (user 2026-11-15 at 55; 48 since 2026-11-17).
     No border: the divider is the ::after below (a 0.5 px border rounded
     up to 1 px made it 56). */
  height: var(--dd-h);
  box-sizing: border-box;
  padding: 0 calc(var(--dd-arrow-hit) + 16px) 0 16px;
  background: var(--color-input);
  transition: none;
  box-shadow: inset 0 0 0 9999px transparent;
  /* Above the options panel in stacking order — rows scrolling past
     the header's bottom edge get visually masked by the header's
     solid background. */
  position: relative;
  z-index: 1;
}
/* Header divider — FULL width (user 2026-11-11: the list's group dividers
   are inset, the header line is not). It's the header's bottom 0.5 px, so
   layout never changes, and keeps the divider's timing: eases in with the
   panel, fades out only after the 0.4 s collapse. */
.ctrl-dropdown-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0.5px;
  background: var(--color-stroke-hi);
  opacity: 0;
  transition: opacity 0.1s ease 0.4s;
  pointer-events: none;
}
.ctrl-dropdown.open .ctrl-dropdown-header::after { opacity: 1; transition: opacity 0.1s ease; }
/* Hover lift on the CLOSED pill — the header carries the visible
   bg/overlay, since its own opaque `--color-input` background masks
   any change applied at the .ctrl-dropdown level below. Targeting
   the header directly is what makes the brighter-bg + 10 % white
   wash actually render on the closed surface. */
.ctrl-dropdown:not(.open):not(.suppress-hover):not(.is-disabled):hover .ctrl-dropdown-header {
  background: var(--color-stroke-hi);
  box-shadow: inset 0 0 0 9999px var(--color-hover-overlay);
}
.ctrl-dropdown-header .ctrl-dropdown-text {
  flex: 1;
  min-width: 0;
  padding-bottom: 2px;
  /* Picked value reads in Off-White (Figma 499:1224). */
  color: var(--color-off-white);
}
.ctrl-dropdown-options {
  /* Outer = scroll viewport. NO padding here — padding lives on the
     `.ctrl-dropdown-options-inner` wrapper below so it never changes
     between open/closed states. Outer carries the max-height
     transition + overflow:hidden; on close, it just clips the inner
     from the bottom while the inner's layout (and the rows' y-
     positions) stays untouched. */
  width: 100%;
  box-sizing: border-box;
  min-height: 0;
  max-height: 0;
  pointer-events: none;
  overflow: hidden;
  /* `contain` traps wheel/trackpad scroll inside this list once it
     hits the top or bottom — no chaining to the sidebar's own
     scroll. The native macOS rubber-band overscroll still plays
     inside the dropdown so the user gets the "drag past the bound"
     feedback without losing their place in the sidebar. */
  overscroll-behavior: contain;
  transition: max-height var(--transition-collapse);
}
.ctrl-dropdown.open .ctrl-dropdown-options {
  /* Cap the visible list at ~10 rows; longer lists (e.g. ~300 local system
     fonts) scroll INSIDE the dropdown instead of pushing the sidebar to
     the bottom. */
  max-height: 320px;
  overflow-y: auto;
  pointer-events: auto;
}
.ctrl-dropdown-options-inner {
  /* Inner = the padded row stack. Padding stays CONSTANT regardless of
     the outer's max-height, so rows hold their natural y-position
     throughout the collapse animation and don't jump when `.open` is
     removed. Horizontal padding is symmetric (10 / 10) so the row-
     highlight pill sits with equal gap to the dropdown's left and
     right edges; the row's own 6 px x-padding lands text at 16 px
     from each edge (matches the header). Rows pack flush (gap 0) —
     each row carries its own vertical padding so the highlight pill
     reads as the inter-row spacing. */
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 18px 10px;
  box-sizing: border-box;
  width: 100%;
}
/* Scrollbars are hidden on ALL dropdown menus — the bar visually competes
   with the row highlights and the design system treats every dropdown
   the same (short LUT lists and ~300-row local-font lists alike). The
   menu stays scrollable; only the bar is suppressed. */
.ctrl-dropdown-options {
  scrollbar-width: none;          /* Firefox */
}
.ctrl-dropdown-options::-webkit-scrollbar {
  display: none;                  /* Chromium + Safari */
}
.ctrl-dropdown-row {
  /* Figma 499:1235 etc — each row carries its own 6/6/7 padding so the
     hover highlight pill (6 px radius, UI/Highlight bg) reads as a
     tightly-fitting capsule around the text. Rows pack flush on the
     parent (gap 0) and their own padding fills the visual gap between
     text lines, so the cursor between text rows always lands inside
     one row's hit area — no separate hit-extension pseudo needed. */
  display: flex;
  align-items: center;
  width: 100%;
  padding: 6px 6px 7px;
  border-radius: 6px;
  flex-shrink: 0;
  position: relative;
  transition: none;
}
/* Highlight pill is HOVER-ONLY. The picked option carries off-white
   text as its permanent state (no resting pill) but still gets the
   pill on hover, matching every other row — hovering ANY row reads as
   the same click affordance. */
.ctrl-dropdown-row:hover {
  background: var(--color-stroke-hi);
}
.ctrl-dropdown-text {
  flex: 1 1 0;
  min-width: 0;
  /* P2b weight 600 — matches the rest of the design system (.btn-ctrl,
     .stepper-value, dropdown header). Figma's reference shows 500
     for this specific Medium-style token, but the design system
     elsewhere uses 600 consistently and we keep parity. */
  font: 600 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  /* Row text in the list — default UI/Text grey (Figma 499:1236).
     The .selected row flips to off-white via the rule below. */
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: none;
}
/* The currently-selected option ALSO appears in its natural position in
   the list — duplicated by design — and gets the same text treatment as
   the header (`--color-off-white`) so the user can see where the current
   pick falls relative to the alternatives without scanning the header.
   Clicking the selected row is a no-op (handled in controls.js — early
   return when `val === def.value`). */
.ctrl-dropdown-row.selected .ctrl-dropdown-text { color: var(--color-off-white); }
.ctrl-dropdown-row:hover .ctrl-dropdown-text { color: var(--color-off-white); }
/* "None" row stays grey even when it's the active selection — it
   represents the no-effect / inert state and shouldn't visually
   compete with real values. Hover still flips off-white text +
   highlight pill (inherited from the base hover rule) so the row
   reads as clickable. */
.ctrl-dropdown-row.is-none.selected .ctrl-dropdown-text { color: var(--color-text); }
.ctrl-dropdown-row.is-none:hover .ctrl-dropdown-text { color: var(--color-off-white); }
.ctrl-dropdown-arrow {
  /* Figma 499:1261 / Symbols/Down: chevron in flex flow inside the
     header, sits at the right edge after the picked-value text.
     Stroke uses currentColor and inherits off-white. Sized 9 × 5.5
     (1 px wider than the 8 × 4 source, proportions preserved — see
     the matching SVG sizing below). */
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 9px;
  height: 5.5px;
  padding-top: 1px;
  color: var(--color-off-white);
  /* Hover scales the chevron 1.4× (matches the stepper +/- glyph
     hover). The rotation that fires on open is also on this element,
     so the open-hover rule below composes both transforms. */
  transition: transform var(--transition-icon);
}
.ctrl-dropdown-arrow svg { display: block; width: 9px; height: 4.5px; }
.ctrl-dropdown.open .ctrl-dropdown-arrow { transform: rotate(180deg); }
/* Closed-hover: panel hover = header hover (options have max-height 0).
   Scale 1.2× — half the stepper glyph's 1.4× delta, since the chevron
   reads as smaller chrome than the stepper +/-. */
.ctrl-dropdown:not(.open):not(.suppress-hover):not(.is-disabled):hover .ctrl-dropdown-arrow {
  transform: scale(1.2);
}

/* Chevron square — every dropdown's chevron (sidebar .ctrl-dropdown + the
   layer popup's .layer-settings-dropdown) sits in the stepper's ± square
   (user 2026-11-12): 8 px in from the header's top / right / bottom, so
   its height is the header's − 16 (55 → 39 in the sidebar, like a
   stepper's; 40 → 24 in popups), 8 px radius, glyph centred.
   Its hover state (square UI/Highlight + chevron 9 → 11 px, the stepper's)
   exists ONLY while the list is OPEN, and marks what closes it
   (user rule 2026-11-12): only the square itself — every dropdown is
   searchable now, so the rest of the open header is the search field (a
   click there types, it doesn't close), and hovering it leaves the chevron
   alone. (The legacy player's .layer-settings-dropdown has no search: its
   whole header still lights the square.)
   Closed, a dropdown is one button: the whole panel lifts (above), no
   square; it opens into its search from anywhere. */
.ctrl-dropdown { --dd-arrow-hit: calc(var(--dd-h) - 16px); }   /* the chevron square: the box minus 8 px each side */
/* A Weight dropdown whose font has ONE weight has nothing to pick (user
   2026-11-12): it doesn't open, doesn't lift on hover, and its value +
   chevron read UI/Highlight — the system's disabled grey (as on disabled
   ratio pills and resting Reset). */
.ctrl-dropdown.is-disabled { cursor: default; }
.ctrl-dropdown.is-disabled .ctrl-dropdown-header .ctrl-dropdown-text,
.ctrl-dropdown.is-disabled .ctrl-dropdown-arrow { color: var(--color-stroke-hi); }
.layer-settings-dropdown { --dd-arrow-hit: 24px; }
.ctrl-dropdown-arrow-hit {
  /* Explicit size (not top + bottom insets): the header's 0.5 px divider
     border would make it 0.5 px short of square, glyph off-centre. */
  position: absolute;
  top: 8px;
  right: 8px;
  width: var(--dd-arrow-hit);
  height: var(--dd-arrow-hit);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: none;
}
/* Centred in the square exactly like the stepper's glyph: the chevron box
   hugs its 4.5 px svg (it was a 5.5 px box with the svg at its bottom,
   tuned for sitting next to the text — 0.5 px low in the square). */
.ctrl-dropdown-arrow-hit > .ctrl-dropdown-arrow { height: auto; padding-top: 0; align-items: center; }
@media (hover: hover) {
  .ctrl-dropdown.open .ctrl-dropdown-header > .ctrl-dropdown-arrow-hit:hover,
  .layer-settings-dropdown.open .layer-settings-dropdown-header:hover > .ctrl-dropdown-arrow-hit {
    background: var(--color-stroke-hi);
    color: var(--color-off-white);
  }
  .ctrl-dropdown.open .ctrl-dropdown-header > .ctrl-dropdown-arrow-hit:hover > .ctrl-dropdown-arrow,
  .layer-settings-dropdown.open .layer-settings-dropdown-header:hover > .ctrl-dropdown-arrow-hit > .layer-settings-dropdown-arrow {
    transform: rotate(180deg) scale(1.2222);
  }
}
/* Press dip (0.94), like the stepper glyph — same contexts, declared after
   the hover (same specificity) so it wins. */
.ctrl-dropdown.open .ctrl-dropdown-header > .ctrl-dropdown-arrow-hit:active > .ctrl-dropdown-arrow,
.layer-settings-dropdown.open .layer-settings-dropdown-header:active > .ctrl-dropdown-arrow-hit > .layer-settings-dropdown-arrow {
  transform: rotate(180deg) scale(0.94);
}


/* Group dividers inside a SIDEBAR dropdown's list (`dividersBefore`): larger
   type than the popup's → 8 px above / below (user 2026-11-11); no side
   margins — the hairline spans the list's 10 px inset (the header line is
   full width). */
.ctrl-dropdown-options-inner > .layer-settings-dropdown-divider { margin: 8px 0; }
/* …the layer popup's smaller rows keep its 4 px (user rule 2026-11-11). */
.layer-settings-popup .ctrl-dropdown-options-inner > .layer-settings-dropdown-divider { margin: 4px 0; }
/* `hideWhenSelected` (the blend list's Normal): out of the list while it's
   the pick; a divider it would leave leading / doubled hides with it. A
   query shows one flat list, so the dividers go too. */
.ctrl-dropdown-row.is-hidden-selected,
.ctrl-dropdown-options-inner > .layer-settings-dropdown-divider.is-redundant,
.ctrl-dropdown.is-filtering .ctrl-dropdown-options-inner > .layer-settings-dropdown-divider { display: none; }

/* ───── Dropdown search + font Recent (Figma 980:2712 "C", 980:3070 "E") ─────
   Every dropdown (fonts first, all of them since 2026-11-12): while OPEN
   the header's value text is swapped for a search field — the current value as placeholder
   (UI/Text), typed text Off-White; no magnifier icon (user 2026-11-11).
   The header keeps its exact size (no layout jump). See
   controls.js#buildDropdown. */
.ctrl-dropdown-search {
  display: none;
  flex: 1;
  min-width: 0;
  align-items: center;
}
.ctrl-dropdown.is-searching .ctrl-dropdown-search { display: flex; }
.ctrl-dropdown.is-searching .ctrl-dropdown-header > .ctrl-dropdown-text { display: none; }
.ctrl-dropdown-search-input {
  flex: 1;
  min-width: 0;
  margin: 0;
  /* Same metrics as the header's value text, so the placeholder sits
     exactly where the picked value sat. */
  padding: 0 0 2px;
  border: 0;
  outline: none;
  background: transparent;
  font: 600 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  color: var(--color-off-white);
  caret-color: var(--color-off-white);
  cursor: text;
  user-select: text;
}
.ctrl-dropdown-search-input::placeholder { color: var(--color-text); opacity: 1; }
/* Group labels — C1, UI/Interactive. "All fonts" gets extra air above. */
.ctrl-dropdown-group-label {
  flex-shrink: 0;
  padding: 8px 6px 6px;
  font: 500 11.5px/14px var(--font-display);   /* C1 */
  letter-spacing: 0.75px;
  color: var(--color-highlight-plus);
  cursor: default;
}
.ctrl-dropdown-group-label.is-all { padding-top: 12px; }
/* A query shows one flat list: groups + the Recent copies hide. */
.ctrl-dropdown.is-filtering .ctrl-dropdown-group-label { display: none; }
.ctrl-dropdown-row.is-filtered { display: none; }
/* Keyboard / top-match row: the same pill + text as hover (Enter applies it). */
.ctrl-dropdown-row.is-active { background: var(--color-stroke-hi); }
.ctrl-dropdown-row.is-active .ctrl-dropdown-text { color: var(--color-off-white); }
/* Matched characters read Off-White, the rest of the name UI/Text. */
.ctrl-dropdown.is-filtering .ctrl-dropdown-row:not(.is-active):not(:hover) .ctrl-dropdown-text { color: var(--color-text); }
.ctrl-dropdown-match { color: var(--color-off-white); }
/* No matches — P2b title + C1 hint, centred. Top/bottom land at the
   design's 26 / 30 px with the list's own 18 px padding. */
.ctrl-dropdown-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;   /* title → hint (user 2026-11-11; Figma had 12) */
  padding: 8px 6px 12px;
  text-align: center;
  cursor: default;
}
.ctrl-dropdown.is-empty .ctrl-dropdown-empty { display: flex; }
.ctrl-dropdown-empty p { margin: 0; }
.ctrl-dropdown-empty-title {
  font: 600 13.6px/17px var(--font-display);   /* P2b */
  letter-spacing: 0.35px;
  color: var(--color-off-white);
}
/* Hint uses the control-label type (= .ctrl-label: P2a, UI/Text) — user
   2026-11-11; Figma had C1. Typography only, not the label's padding. */
.ctrl-dropdown-empty-hint {
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  color: var(--color-text);
}

/* Local-font rows in the family dropdown previously carried a small
   "System" badge on the right. The badge was retired — local and
   curated families now read as one alphabetised list with no source
   distinction. The data-source="local" attribute is still set in
   buildDropdown (cheap, no visual side-effect) so a future badge can
   re-attach without re-threading the JS. */

/* ───── Local-fonts consent toggle (synthetic; injected by controls.js
   above any cfg dropdown with `localFonts: true`) ───── */
.ctrl-localfonts-note {
  margin: 6px 0 0;
  font: 600 12px/16px var(--font-display);
  color: var(--color-text-dim-40);
  letter-spacing: 0.3px;
}

/* ───── Text field (Figma 162:439) ─────
   STRUCTURE
     .ctrl-textfield
       .ctrl-textfield-header  — Label (left, dim) + char counter (right, bright)
       .ctrl-textfield-box     — bg --color-input, radius 8, padding 16/20
         <textarea>            — P1 typography (65 Medium, 21.46/24, +0.30 px)

   Typography
     Header → P2a (450 13.6/17 var(--font-display), +0.35px), inherits via
     `.ctrl-label`. Counter uses --color-off-white per Figma.
     Body   → P1 (500 21.46/24 var(--font-display), +0.30px), --color-text.

   Auto-sizing
     `field-sizing: content` lets the textarea grow with its content where
     supported (Chrome 123+, Safari 17.4+). controls.js also runs a JS
     auto-resize as a fallback for older browsers. */
.ctrl-textfield {
  /* `.ctrl` already sets display:flex flex-direction:column gap:12px — match
     that and ensure the header sits flush against its container's edges. */
}
.ctrl-textfield-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
}
.ctrl-textfield-header .ctrl-label {
  flex: 1 0 0;
  min-width: 0;
}
.ctrl-textfield-count {
  flex: 0 0 auto;
  /* Same 4 / 6 / 5 padding as `.ctrl-value` + `.ctrl-media-count`
     so the right-side counter's baseline aligns with `.ctrl-label`
     on the left — same canonical pattern used across every
     control's header row. */
  padding: 4px 6px 5px;
  font: 500 13.6px/17px var(--font-display);
  color: var(--color-off-white);
  letter-spacing: 0.35px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
/* Generic textfield's char counter renders "{N} chars" with the number
   in off-white (inherited) and the unit suffix in UI/Text grey — see
   Figma 162:439. The TextFieldAction variant (the prompt section) uses
   the same .ctrl-textfield-count slot for the model name and skips this
   span, so its label reads as a single off-white string. */
.ctrl-textfield-count-suffix { color: var(--color-text); }
.ctrl-textfield-box {
  display: flex;
  align-items: flex-start;
  width: 100%;
  /* Design-system spec (Figma 162:439, 439:1114): 18 / 16 inset
     position, 8 px radius, UI/Input bg, FIXED 144 px height. Padding
     was moved off the BOX and onto the INPUT below so that overflow
     content can extend visually all the way to the field's right
     border — clipping happens at the rounded-rect outline via
     overflow: hidden, not at the inner padding edge. */
  height: 144px;
  background: var(--color-input);
  border-radius: 8px;
  overflow: hidden;
  /* Anchor for the prompt-section typewriter overlay (and any future
     absolute-positioned descendants of a textfield surface). Harmless
     for textfields without an overlay child. */
  position: relative;
}
.ctrl-textfield-input {
  flex: 1 0 0;
  min-width: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  /* Symmetric padding — 18 top/bottom + 16 left/right. Every textfield
     control (the prompt AND any tool's `text` cfg control) breathes the
     same on both sides. This is the canonical textfield inset; see
     player/DESIGN-SYSTEM.md. */
  padding: 18px 16px;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  /* P2a Roman 13.6/17 / 0.35 tracking. User-typed text reads as
     off-white so it's clearly distinguished from the dim grey
     placeholder — matches the Keywords + API key fields. The
     placeholder rule below resets the resting hint to UI/Text grey. */
  color: var(--color-off-white);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  /* Scroll within the fixed-height box; native scrollbar is hidden by
     the Webkit/Firefox rules below to keep the surface flat. */
  overflow-y: auto;
  scrollbar-width: none;
  box-sizing: border-box;
}
.ctrl-textfield-input::-webkit-scrollbar { display: none; }
.ctrl-textfield-input::placeholder {
  color: var(--color-text);
}
/* Single-line TextField (cfg `multiline: false`) — the design system's
   unified 55 px single-line input height (same as Stepper / collapsed
   Dropdown), instead of the multi-line field's fixed 144 px. The <input>
   keeps the canonical 18 / 16 padding + P2a type from
   .ctrl-textfield-input; overflow scrolls horizontally inside it. */
.ctrl-textfield-box--single {
  height: auto;
  min-height: var(--ctrl-h);
  align-items: center;
}
.ctrl-textfield-box--single .ctrl-textfield-input {
  /* The field fills the --ctrl-h box, its text centred with a dropdown
     value's 2 px lift (was 18 + 17 + 20 = 55). */
  height: var(--ctrl-h);
  padding-top: 0;
  padding-bottom: 2px;
  overflow: hidden;
  white-space: nowrap;
}

/* ───── Component: Keywords (tag input) — Figma 334:902 ─────
   Tag input on top of the canonical TextField surface. Pills row above
   wraps freely; the input box below uses the same 18 / 16 padding +
   8 px radius + UI/Input bg as the other textfields. The Stack is the
   gap-12 column the Figma "Input" container shows. */
.ctrl-keywords-stack {
  display: flex;
  flex-direction: column;
  /* 16 px between the pills row and the input box — a touch wider
     than the inter-control 12 so the "type something…" field reads
     as a distinct entry surface beneath the pills. */
  gap: 16px;
  width: 100%;
}
.ctrl-keywords-pills {
  display: flex;
  flex-wrap: wrap;
  /* row-gap 9 (between wrapped lines), column-gap 8 (between
     horizontal neighbors). */
  gap: 9px 8px;
  width: 100%;
}
.ctrl-keywords-pills:empty { display: none; }
.ctrl-keywords-pill {
  /* Tiny-pill TextIcon variant (Figma 334:902 / 460:1242 refresh):
     P2a typography (matches `.ctrl-label` above every control), 22 px
     tall, 6 px radius, bg --color-stroke-hi, 8 px gap between text
     and × glyph, symmetric 8 px padding on all sides. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 22px;
  gap: 0;
  padding: 0 0 0 8px;   /* the × is a 22 px square at the right end (2026-11-17) */
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
  border: none;
  border-radius: 6px;
  cursor: grab;   /* a click selects it, a drag moves it */
  /* P2a — same typography as the labels above every control. NOTE:
     Figma's P2a token reports weight 450, which is INCORRECT for our
     Adobe Typekit "Neue Haas Grotesk Display" load — "55 Roman" maps
     to CSS weight 500 in the served kit. Always use 500 here, never
     450. See memory [[typekit-weights]]. */
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  flex-shrink: 0;
  /* `transform` transition is the FLIP slide-into-place when neighbouring
     pills shift during drag-to-reorder. CSS owns it so the inline
     transition the JS sets (briefly, for the inverse-transform setup)
     can be cleared with an empty string and CSS picks back up. */
  transition: opacity 0.15s ease, transform 0.18s ease, scale 0.15s ease;
}
/* Hover (user 2026-11-17): the pill grows like a button (`scale`, so the
   FLIP's inline transform is untouched; --hover-grow = a round button's few
   px, hover-grow.js) — on the × too, which ALSO keeps the old look: the
   pill dims, the × goes white. A press on the word dips. */
@media (hover: hover) {
  .ctrl-keywords-pill:hover { scale: var(--hover-grow, 1.1); }   /* on the × too (user 2026-11-17) */
  .ctrl-keywords-pill:has(.ctrl-keywords-pill-x:hover) { opacity: 0.85; }
}
.ctrl-keywords-pill:active:not(:has(.ctrl-keywords-pill-x:active)) { scale: 0.96; }
/* Selected (its text is in the field below to edit; it can be dragged): the
   active STROKE, like a picked colour circle — no colour change (user
   2026-11-17; an Off-White pill with dark text came first). */
.ctrl-keywords-pill.is-selected { outline: 1px solid var(--focus-stroke); outline-offset: -1px; }

/* Drag-to-reorder feedback. The source pill dims while the user drags
   (cursor still + opacity = consistent "this is what you're moving"
   signal). Target pill gets a 2 px vertical line on the LEFT (drop-before)
   or RIGHT (drop-after) edge — inset box-shadow so it doesn't shift
   layout. The .dragging selector sits AFTER :hover above, same (0,2,0)
   specificity, so it wins via source order. */
.ctrl-keywords-pill.dragging { opacity: 0.4; cursor: grabbing; }
.ctrl-keywords-pill.drop-before { box-shadow: inset 2px 0 0 var(--color-off-white); }
.ctrl-keywords-pill.drop-after  { box-shadow: inset -2px 0 0 var(--color-off-white); }
.ctrl-keywords-pill-text { padding-bottom: 1px; }
.ctrl-keywords-pill-x {
  display: flex;
  align-items: center;
  justify-content: center;
  /* A 22 px square around the × (the pill's height) — only it removes the
     word; hovered, the × turns white (user 2026-11-17). */
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  /* × glyph is dim against the off-white text so it reads as a
     secondary "remove" affordance, not a primary focal point. */
  color: var(--color-text);
  cursor: pointer;
}
.ctrl-keywords-pill-x:hover { color: var(--color-off-white); }
.ctrl-keywords-input-box {
  display: flex;
  align-items: flex-start;
  width: 100%;
  /* Padding moved to the inner <input> — see comment on
     .ctrl-textfield-box. Lets overflow text extend to the field's
     right border, clipped by the rounded-rect outline. */
  background: var(--color-input);
  border-radius: 8px;
  overflow: hidden;
  /* Positioning context for the typewriter `.ctrl-keywords-placeholder`
     overlay that paints "Type something..." on first visibility. */
  position: relative;
}
/* Typewriter overlay — paints onto an absolute layer positioned over
   the input so the typewriter animation can render character by
   character without competing with the input's native placeholder. */
.ctrl-keywords-placeholder {
  position: absolute;
  top: calc((var(--ctrl-h) - 19px) / 2);   /* where the input's text sits (centred, 2 px lift) */
  left: 16px;
  right: 16px;
  height: 17px;
  pointer-events: none;
  color: var(--color-text);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  white-space: nowrap;
  overflow: hidden;
}
.ctrl-keywords-placeholder.hidden { display: none; }
.ctrl-keywords-placeholder-mute { visibility: hidden; }
.ctrl-keywords-input {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
  margin: 0;
  /* +2 px on the bottom inset (20 vs 18) to optically lift the text
     above geometric centre — same trick as `.ctrl-dropdown-header`'s
     `padding-bottom: 2px`. Without it the input's descenderless text
     sits visibly low next to a dropdown of the same height. Now: the box's
     height, the text centred in it with that 2 px lift. */
  height: var(--ctrl-h);
  padding: 0 0 2px 16px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--color-off-white);
  box-sizing: border-box;
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
}
.ctrl-keywords-input::placeholder { color: var(--color-text); }

/* ───── Component: "Give instructions" prompt section ─────
   A synthetic, preserved sidebar group hosting the NL prompt that
   re-generates the current tool. Pinned to the LAST section across all
   tools by rebuildControls (player.js#rebuildControls re-appends it
   after buildControls so freshly-added tool sections can't push it
   off the bottom). Uses the canonical .ctrl-textfield for the input
   surface — no prompt-scoped typography overrides. */
.prompt-row {
  display: flex;
  align-items: center;
  gap: 12px;
  /* No margin-top: the parent .ctrl already sets gap: 12px between its
     flex children, matching Figma 439:1114's column gap. Adding any
     margin here was doubling the gap to 24 px. */
}
/* Typewriter overlay for the prompt textfield. Renders the FULL
   placeholder string at all times; characters past the typewriter
   index are wrapped in `.prompt-placeholder-mute` so they're
   `visibility: hidden` — they occupy space (locking the wrap
   geometry) but aren't visible. This is why words don't jump
   between lines as the cursor advances. */
.prompt-placeholder {
  position: absolute;
  /* Mirrors the textarea's content area: 18 top/bottom + 16 left/right so the
     placeholder wraps at the same column as the typed text (which now has a
     matching 16 px right padding). */
  top: 18px;
  left: 16px;
  right: 16px;
  bottom: 18px;
  pointer-events: none;
  color: var(--color-text);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: hidden;
}
.prompt-placeholder.hidden { display: none; }
.prompt-placeholder-mute { visibility: hidden; }
.prompt-status {
  font: 500 11.5px/14px var(--font-display);
  letter-spacing: 0.75px;
  color: var(--color-text);
  flex: 1 0 0;
  min-width: 0;
  /* Status text must NEVER truncate — it's often the only explanation of
     what to do next. It wraps beside the Run button instead (the row is
     align-items: center, so Run stays put; the row just gets taller). */
  white-space: normal;
  overflow-wrap: anywhere;
  transition: none;
}
.prompt-status.error  { color: var(--color-accent-red); }
/* After an applied Iterate: "Applied 14:02 · 9.1k tokens · Revert". */
.prompt-revert {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  color: var(--color-off-white);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.prompt-revert:hover { color: var(--color-text); }

/* Iterate in progress (tool-page-iterate.js#lock, user 2026-11-13): lock
   everything that changes the cimble or its output — the other sidebar
   sections, layers, frame, export row, Live — while zoom / pan, reading and
   Cancel stay available. The frame dims behind a slow shimmer. */
body.is-iterating .controls-body > .ctrl-group:not(#promptGroup),
body.is-iterating #exportPills,
body.is-iterating #layersBtn,
body.is-iterating #frameModeBtn,
body.is-iterating #layersPopup:not(.hidden),
body.is-iterating #layerSettingsPopup:not(.hidden),
body.is-iterating #layerBadgeHost,
body.is-iterating #docBar,
body.is-iterating .app-corner {
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
body.is-iterating .frame-group { pointer-events: none; }
/* …and everything INSIDE them: a child with its own pointer-events: auto
   (ratio pills, frame handles + size pill, Record / Capture / Render, the
   cimble's ⋯) beat the parent's none, so the ratio, the frame size and a
   recording could still change mid-Iterate (user bug 2026-11-16). */
body.is-iterating .controls-body > .ctrl-group:not(#promptGroup) *,
body.is-iterating #exportPills *,
body.is-iterating #layersBtn *,
body.is-iterating #frameModeBtn *,
body.is-iterating #layersPopup *,
body.is-iterating #layerSettingsPopup *,
body.is-iterating #layerBadgeHost *,
body.is-iterating #docBar *,
body.is-iterating .app-corner *,
body.is-iterating .frame-group *,
body.is-iterating .frame-size-pill { pointer-events: none !important; }
body.is-iterating #promptInput { opacity: 0.6; }
.iterate-veil {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
  background: rgba(25, 25, 25, 0.35);
  animation: iterate-veil-in 0.3s ease both;
}
.iterate-veil.leaving { animation: iterate-veil-out 0.3s ease both; }
.iterate-veil::after {
  content: "";
  position: absolute;
  inset: 0 -60%;
  background: linear-gradient(100deg, transparent 35%, rgba(247, 247, 247, 0.10) 50%, transparent 65%);
  animation: iterate-shimmer 1.8s linear infinite;
}
@keyframes iterate-veil-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes iterate-veil-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes iterate-shimmer  { from { transform: translateX(-35%); } to { transform: translateX(35%); } }
@media (prefers-reduced-motion: reduce) { .iterate-veil::after { animation: none; } }
.prompt-status.busy   { color: var(--color-off-white); }
/* API-key block — its own .ctrl inside the prompt section. Sibling of
   the prompt textfield; the parent .ctrl-group's 32 px gap drives the
   spacing between them so the API key reads as a peer control, not a
   nested detail. */
.prompt-key-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.prompt-key-input {
  /* Canonical single-line textfield surface (Figma 439:1128) — same
     18 / 16 inset, 8 px radius, UI/Input bg, 55 px min-height as the
     other inputs. Padding is asymmetric (18 top + 20 bottom + 16 LEFT)
     so overflow text scrolls visually to the field's right border;
     overflow: hidden + border-radius clip it at the rounded outline.
     The +2 px on the BOTTOM inset optically lifts the descenderless
     text above geometric centre — same trick as
     `.ctrl-dropdown-header`'s `padding-bottom: 2px`. Without it the
     input sits visibly low next to a 55 px dropdown. */
  width: 100%;
  height: var(--ctrl-h);
  box-sizing: border-box;
  padding: 0 0 2px 16px;
  border: none;
  border-radius: 8px;
  background: var(--color-input);
  overflow: hidden;
  color: var(--color-off-white);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  outline: none;
}
.prompt-key-input::placeholder { color: var(--color-text); }

/* ───── The Iterate composer (prompt-ui.js + iterate-composer.js,
   user 2026-11-15; Figma 1120:2684 direction A) ─────
   One UI/Input box: reference chips above the text, examples while it's
   empty + focused, a toolbar at its bottom. Off-White 50 % outline while
   focused; a dashed one while an image is dragged over it. */
/* (The Iterate header aligns like every section header — the key pill's
   box sits like Reset's, user 2026-11-17 — no baseline override.) */
.prompt-model { font: 500 13.6px/17px var(--font-display); letter-spacing: 0.35px; color: var(--color-off-white); }
.prompt-key-block[hidden] { display: none; }
.prompt-key-note { font: 500 11.5px/15px var(--font-display); letter-spacing: 0.5px; color: var(--color-highlight-plus); }
.prompt-composer {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--color-input);
  box-shadow: inset 0 0 0 1px transparent;
  transition: none;
}
:root.kbd-focus .prompt-composer:has(textarea:focus) { box-shadow: inset 0 0 0 1px var(--focus-stroke, rgba(247, 247, 247, 0.5)); }
.prompt-composer .prompt-box { height: auto; background: transparent; border-radius: 0; overflow: visible; }
.prompt-composer .ctrl-textfield-input {
  padding: 2px;
  min-height: 76px;
  max-height: 240px;
  height: 76px;
  font-weight: 500;
  line-height: 19px;
}
/* Examples showing (empty + focused): the field shrinks to two lines (A1). */
.prompt-composer.has-examples .ctrl-textfield-input { min-height: 38px; height: 38px; }
.prompt-composer .prompt-placeholder { top: 2px; left: 2px; right: 2px; bottom: auto; line-height: 19px; }
/* Iterate: the WHOLE composer carries the stroke while its text is typed in
   (below) — never the text area inside it too (user 2026-11-16). */
.prompt-composer .ctrl-textfield-box:has(:focus) { outline: none; box-shadow: none; }
.prompt-composer.is-sent .ctrl-textfield-input { color: var(--color-text); }
.prompt-refs { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; }
.prompt-refs[hidden] { display: none; }
.prompt-chip {
  appearance: none;
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: var(--color-panel) center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(247, 247, 247, 0.25);
  cursor: pointer;
}
.prompt-chip-x {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-highlight-plus);
  color: var(--color-off-white);
  font: 600 11px/16px var(--font-display);
  text-align: center;
  transition: transform 0.15s ease;
}
.prompt-chip-x:hover { transform: scale(1.15); }
.prompt-chip-tag {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  height: 12px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--color-off-white);
  font: 600 8.5px/12px var(--font-display);
  text-align: center;
}
.prompt-examples { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; min-width: 0; }   /* the keyword pills' row gap (2026-11-17) */
.prompt-examples[hidden] { display: none; }
/* Iterate's suggestion chips = the KEYWORD PILL's look (user 2026-11-17:
   "must be same style as keywords") — 22 px, 6 px radius, 8 px inset,
   UI/Highlight, Off-White 500 13.6 / 17 (text 2 px from the top, like the
   pill's), no ×; hovered they grow like the pills (hover-grow.js), a press
   dips. Was a 26 px round grey chip whose hover lit its fill. */
.prompt-example {
  appearance: none;
  display: block;
  flex: none;
  max-width: 100%;
  height: 22px;
  box-sizing: border-box;
  padding: 2px 8px 3px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  border: none;
  border-radius: 6px;
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  text-align: left;
  cursor: pointer;
  transition: scale 0.15s ease;
}
@media (hover: hover) {
  .prompt-example:hover { scale: var(--hover-grow, 1.1); }
}
.prompt-example:active { scale: 0.96; }
.prompt-ref-hint { font: 500 11.5px/16px var(--font-display); letter-spacing: 0.3px; color: var(--color-highlight-plus); }
.prompt-ref-hint[hidden] { display: none; }
.prompt-tools { display: flex; align-items: center; gap: 6px; }
.prompt-tool {
  appearance: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 16px;
  background: var(--color-stroke-hi);
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: inset 0 0 0 9999px transparent;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.prompt-tool svg { width: 14px; height: 14px; display: block; }
.prompt-tool:not(:disabled):hover { color: var(--color-off-white); box-shadow: inset 0 0 0 9999px var(--color-hover-overlay); }
.prompt-tool:not(:disabled):active { transform: scale(0.94); }
.prompt-tool:disabled { background: var(--color-panel); color: var(--color-stroke-hi); cursor: default; }   /* greyed (2026-11-17; was 40 %) */
.prompt-tool-end { margin-left: auto; }
.prompt-sent {
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
  font: 500 11.5px/22px var(--font-display);
  letter-spacing: 0.5px;
}
.prompt-sent[hidden] { display: none; }
.prompt-drop-label {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(32, 32, 32, 0.82);
  color: var(--color-off-white);
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  pointer-events: none;
}
.prompt-composer.is-drop { box-shadow: none; outline: 1.5px dashed var(--color-off-white); outline-offset: -1.5px; }
.prompt-composer.is-drop .prompt-drop-label { display: flex; }
/* Recent prompts — the doc menus' surface (.settings-popup.doc-popup), opening
   ABOVE its button, right-aligned: it grows from that corner. */
.settings-popup.doc-popup.prompt-history-pop { z-index: 60; width: 280px; max-height: 320px; transform-origin: bottom right; }
.settings-popup.doc-popup.prompt-history-pop.hidden { transform: scale(0.95) translateY(4px); }
.prompt-history-item { min-width: 0; }
.prompt-history-empty { padding: 8px; font: 500 12px/16px var(--font-display); color: var(--color-text); }
/* Run + "⌘↵" + the status / billing line. Run: 48 px, Off-White when it
   can run (Figma A2). */
.prompt-meta { display: flex; flex-direction: column; gap: 3px; flex: 1 1 auto; min-width: 0; }
.prompt-kbd { font: 500 12px/14px var(--font-display); color: var(--color-text); }
.prompt-status.is-idle { color: var(--color-highlight-plus); }
.btn-ctrl.prompt-run { min-height: 48px; padding: 0 18px; align-self: center; }
.btn-ctrl.prompt-run.is-active,
.btn-ctrl.prompt-run.is-cancel { background: var(--color-off-white); color: var(--color-off-black); }
/* Phones: a full-width Run with the status under it; no ⌘↵. */
@media (pointer: coarse) and (max-width: 900px) {
  .prompt-row { flex-wrap: wrap; }
  .btn-ctrl.prompt-run { flex: 1 0 100%; }
  .prompt-kbd { display: none; }
}

/* ───── Misc ───── */
.empty-state {
  padding: 24px 12px;
  font: 500 12px/1.5 var(--font-display);
  color: var(--color-stroke-hi);
  text-align: center;
}

/* ==========================================================================
   Component: Layers (image-layer stack inside the frame)
   Figma nodes:
     • Layers popup            uZ7iWwvNrNKPbTVOLkgMAj 673:2898
     • Selected image affordance                       705:3373
     • Per-image settings popup screenshots/ImageLayer.png
   See player/src/layers.js for the state machine + drag/resize logic.
   ========================================================================== */

/* Floating button at the left edge of the viewport, vertically centered —
   the square Back button's look (see below), in its OWN positioned
   container: the layers row is a separate surface from the export row. */
.layers-fab {
  position: fixed;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  /* Same shell as .export-pill-dl / .export-pill-record / .export-pill-settings
     (styles.css L1312-1332) — duplicated here rather than reusing the
     class so a future export-row visual change doesn't accidentally
     reshape the layers FAB. */
  /* A SQUARE button (user 2026-11-16, was a 58 px disc): 55 × 55, 8 px
     radius, UI/Input; on hover the WHOLE button grows (the rule for square
     and round buttons — user 2026-11-16), like every other one. */
  width: 55px;
  height: 55px;
  min-width: 55px;
  min-height: 55px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: var(--color-input);
  color: var(--color-text);
  box-shadow: inset 0 0 0 9999px transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 11;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.layers-fab svg { display: block; }
/* A layer picked while the Layers list is closed (layers.js#syncFabBadge,
   user 2026-11-16): the layer rows' X badge (20 px, UI/Highlight+) on the
   button's top-right corner, with a dot in the selection's colour — blue for
   text / image, purple for the cimble. Scales in / out. */
.layers-fab-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-pill);
  background: var(--color-highlight-plus);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.15s ease, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.layers-fab-badge.visible { opacity: 1; transform: scale(1); pointer-events: auto; cursor: pointer; }
/* Hovering the badge lifts the button too (it's inside it — one button, user
   2026-11-16); the badge itself grows + lights (the X badges' scale 1.2 +
   shadow + wash, pressed 0.92) ONLY when it's hovered directly (user, later
   the same day). A click on it opens the list on the picked layer. */
.layers-fab:not(:disabled):not(.suppress-hover) .layers-fab-badge.visible:hover {
  transform: scale(1.2);
  box-shadow: var(--shadow-frame), inset 0 0 0 9999px var(--color-hover-overlay);
}
.layers-fab:not(:disabled):not(.suppress-hover) .layers-fab-badge.visible:hover:active { transform: scale(0.92); }
.layers-fab-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-accent); }
.layers-fab-badge.is-cimble .layers-fab-dot { background: var(--color-accent-purple); }
/* Universal "ButtonHover" treatment — 10 % white overlay + bg lifts to
   stroke-hi + icon brightens to off-white + scale 1.1. Composed with the
   resting `translateY(-50%)` so the scale doesn't undo the vertical
   centering. Same scope (`:not(.suppress-hover)`) as .export-pill so the
   hover-suppression mechanism (used during the page transition) covers
   this button too. */
@media (hover: hover) {
  .layers-fab:not(:disabled):not(.suppress-hover):not(.is-live-locked):hover {
    background: var(--color-stroke-hi);
    color: var(--color-off-white);
    transform: translateY(-50%) scale(1.1);
    box-shadow: inset 0 0 0 9999px var(--color-hover-overlay);
  }
}
.layers-fab:not(:disabled):not(.suppress-hover):not(.is-live-locked):active {
  transform: translateY(-50%) scale(0.94);
}
/* Popup open → button stays in its highlighted resting treatment
   (bg lift + off-white icon + shadow) so the FAB reads as the active
   anchor of the open popup. NO scale here — the `:hover` rule above
   (higher specificity) re-applies scale(1.1) only when the cursor is
   over the active FAB, signalling "click again to close". The base
   translateY(-50%) carries through from `.layers-fab`'s root rule. */
/* Active = enlarged (user 2026-11-17, final): the list open keeps the
   hover size too; a press still dips. */
.layers-fab[aria-expanded="true"] {
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
  box-shadow: inset 0 0 0 9999px var(--color-hover-overlay);
}
.layers-fab[aria-expanded="true"]:not(:active) { transform: translateY(-50%) scale(1.1); }

/* Layers list popup. Width + radii + padding lifted from Figma 673:2898
   (LayerOptions variant: 210px wide, 14px radius, 10/12 padding, 8 gap,
   panel bg, frame-style drop shadow). */
.layers-popup {
  position: fixed;
  z-index: 12;
  width: 210px;
  /* Canonical popup padding — 12 px on every side, shared with
     .settings-popup + .layer-settings-popup. See DESIGN-SYSTEM.md
     § "Popup chrome". */
  padding: 12px;
  background: var(--color-panel);
  border-radius: 14px;
  box-shadow: var(--shadow-frame);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform-origin: left center;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.layers-popup.hidden {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
}
/* Live slides the Layers button away; an open list steps aside with it and
   returns when Live turns off (layers.js#syncListForLive). */
.layers-popup.live-hidden { opacity: 0; transform: scale(0.95); }
.layers-popup.live-hidden,
.layers-popup.live-hidden * { pointer-events: none !important; }

/* One row per layer. UI/Input bg, 8 px radius, --input-row-h tall with
   12 px horizontal padding — same input-row token the .layer-add-row
   and .layer-settings-dropdown-header use. 10 px gap between icon +
   label. Cursor: grab signals draggability. */
.layer-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--input-row-h);
  padding: 0 12px;
  background: var(--color-input);
  border-radius: 8px;
  color: var(--color-text);
  cursor: grab;
  user-select: none;
  transition: transform 0.15s ease;
}
/* Per-row delete X — image layer rows only (the Cimble row is a
   singleton and can't be deleted). Visually IDENTICAL to the Media
   control's .ctrl-media-badge discs (styles.css Corner badges): UI/Text
   grey 20 px disc, overflowing the row's top-right corner at -8 / -8,
   --shadow-frame drop shadow that only paints once the parent row is
   hovered (opacity 0 carries the shadow), 2× scale-and-pop on hover,
   0.92 dip on press. The X SVG is also lifted verbatim from
   .ctrl-media-remove. data-drag-ignore (set in JS) keeps clicks from
   initiating the row's reorder drag. */
.layer-row-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-pill);
  border: none;
  padding: 0;
  /* UI/Highlight+ bg — shared with .ctrl-media-badge above so every
     X/reload corner badge across the player uses the same brighter
     background that lifts off the Panel/Input rows beneath. */
  background: var(--color-highlight-plus);
  color: var(--color-off-white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.6) rotate(-10deg);
  transition: opacity     0.2s ease-out,
    transform   0.2s ease-out;
  box-shadow: var(--shadow-frame), inset 0 0 0 9999px transparent;
}
.layer-row:hover .layer-row-remove,
/* Selected row: keep the X visible whenever a layer is the active
   selection — both desktop and mobile. Was previously mobile-only
   (hover doesn't latch on touch); on desktop the user reads
   "selected" as a commitment to that layer and expects its delete
   affordance to stay reachable without re-hovering the row. */
.layer-row.selected .layer-row-remove {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) rotate(0);
}
.layer-row-remove:not(.suppress-hover):hover {
  transform: scale(1.2);
  box-shadow: var(--shadow-frame), inset 0 0 0 9999px var(--color-hover-overlay);
}
/* Press-while-hover specificity tiebreaker — without the matching
   `:not(.suppress-hover):hover` chain, hover's scale(1.2) wins over a
   bare `:active` and the press bounce never paints. */
.layer-row-remove:not(.suppress-hover):hover:active,
.layer-row-remove:active { transform: scale(0.92); }
.layer-row:hover {
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
}
.layer-row.selected {
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
}
.layer-row:active { cursor: grabbing; }
.layer-row.dragging { opacity: 0.55; cursor: grabbing; }
.layer-row-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  /* Sizes match the icon viewBoxes (cimble 11×13, image 11×11). */
  width: 11px;
  height: 13px;
}
.layer-row-label {
  flex: 1 1 auto;
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
}

/* "+" add row — same `--input-row-h` height as the layer rows above
   AND the dropdown headers in the per-image settings popup, so the
   three input-row surfaces line up consistently across both popups.
   12 px horizontal padding matches the same token. */
.layer-add-row {
  appearance: none;
  border: none;
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--input-row-h);
  padding: 0 12px;
  /* As it was before 2026-11-16 (user 2026-11-17: "bring it back"): a
     UI/Input row like the layer rows; hovered or with its menu open it
     lights (UI/Highlight, Off-White +) at once — no colour fade — and the
     + grows 1.2 (below). (The fill-less row whose fill grew in on hover is
     gone.) */
  background: var(--color-input);
  border-radius: 8px;
  color: var(--color-text);
  cursor: pointer;
  transition: none;
}
.layer-add-row:not(.suppress-hover):hover,
.layer-add-row[aria-expanded="true"] { background: var(--color-stroke-hi); color: var(--color-off-white); }
/* Stepper-style glyph springiness — pop to 1.4× on hover, dip to 0.94×
   on press. Same pattern as `.ctrl-stepper-zone:hover .ctrl-stepper-glyph`
   in the sidebar (steppers); applied directly to the SVG child so the
   row itself doesn't move (background highlight stays put while the
   glyph alone responds). */
.layer-add-row svg {
  transition: transform 0.15s ease;
}
.layer-add-row:not(.suppress-hover):hover svg,
.layer-add-row[aria-expanded="true"]:not(:active) svg { transform: scale(1.2); }   /* active = enlarged (2026-11-17) */
.layer-add-row:active svg { transform: scale(0.94); }
.layer-add-row:not(.suppress-hover):hover:active svg { transform: scale(0.94); }

/* ──────────── Image layer overlays inside .frame ─────────────────────── */

/* Wrapper inside `.frame` that holds every image-layer overlay. Uses
   display: contents so the wrapper itself doesn't establish a stacking
   context — children participate in `.frame`'s context directly, so
   negative z-indices on below-cimble overlays can paint behind the
   iframe (which sits at z auto = 0). */
.layer-overlays { display: contents; }

/* Per-layer overlay. Positioned in CSS pixels = base-coords × current
   zoom, written every applyFrame() callback (canvas-view.js publishes
   to layers.js via subscribeToView). transform-origin: top left keeps
   the writing easy — left/top sit at the layer's top-left base-coord,
   width/height are the visual size at current zoom.
   The CSS variables --layer-blend / --layer-opacity / --layer-fit
   drive the per-instance blend mode, alpha, and inner object-fit; JS
   writes them on every settings change. */
/* .layer-overlay carries `mix-blend-mode` + `opacity` so the image
   blends with the iframe + earlier overlays in `.frame`'s shared
   stacking context. NO z-index here — DOM order (below/above iframe)
   determines stacking, because a z-index would create a stacking
   context that empties the blend backdrop. The selection chrome
   (handles + badge + outline) lives in a SEPARATE `.layer-chrome`
   element in #layerChromeHost so it stays outside this blended group
   and keeps its full opacity + normal blend regardless of the
   layer's settings. */
.layer-overlay {
  position: absolute;
  transform-origin: top left;
  mix-blend-mode: var(--layer-blend, normal);
  opacity: var(--layer-opacity, 1);
  cursor: move;
  touch-action: none;
  pointer-events: auto;
}
/* Hover preview — rendered as a SEPARATE element in #layerChromeHost
   (managed by layers.js#renderOverlays based on `hoveredLayerId`) so
   the outline doesn't sit inside the .layer-overlay's mix-blend-mode
   composite — an `outline: ...` directly on the overlay gets multiplied
   / screened / darkened along with the image, which the user
   specifically called out. Sibling-of-chrome instead, no blend, same
   1 px blue + -1px offset as the selected chrome's outline so the
   hover → click transition keeps a constant stroke. */
.layer-hover-outline {
  position: absolute;
  pointer-events: none;
  outline: 1px solid var(--color-accent);
  outline-offset: -1px;
}
/* The cimble's (the whole frame) follows the frame's 8 px corners, and sits
   above the frame's 0.5 px hairline (::after, z 5) so it reads as the full
   1 px blue a layer's outline is — below the frame handles (z 10). */
.layer-hover-outline.is-cimble { border-radius: 8px; z-index: 6; }
/* The cimble's own colour is PURPLE (user 2026-11-12; briefly green) — its
   hover / selected rect and its ⋯ badge — so it reads apart from the blue
   text / image layers. */
.layer-hover-outline.is-cimble { outline-color: var(--color-accent-purple); }
.layer-settings-badge[data-cimble] { background: var(--color-accent-purple); }
body.fullscreen .layer-hover-outline.is-cimble { border-radius: 0; }

/* Transparent click catcher inside .frame — sits in DOM between the
   iframe and the image overlay host so above-iframe overlays + chrome
   stay clickable, but clicks on the iframe area (which the iframe
   would otherwise absorb into its own document) reach the catcher's
   pointerdown handler and drop the selection. Pointer-events default
   to none — only flipped to auto when renderOverlays sees an image
   layer is selected. */
.frame-click-catcher {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: transparent;
}
.frame-click-catcher.active {
  pointer-events: auto;
}
/* The <img> fills the overlay box. object-fit + clip-path live on the
   image (not the wrapper) so changing sizing updates the live render
   and the clip-path-to-frame-bounds is scoped to image rendering only. */
/* The layer's shadow (layers.js#syncImageShadow, user 2026-11-16): behind
   the image, reaching past the box; inside the overlay, so the layer's
   opacity / blend apply to image + shadow as one. */
.layer-overlay .layer-shadow-canvas {
  position: absolute;
  display: block;
  pointer-events: none;
}
.layer-overlay .layer-image {
  /* Positioned too, so it paints in DOM order AFTER the (absolutely
     positioned) shadow canvas — above it. No z-index: that would lift it
     out of the layer order. */
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: var(--layer-fit, contain);
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* Selection chrome — outline + 8 corner/edge handles + 3-dot badge.
   Sibling of the image overlays (not a child), rendered in
   #layerChromeHost. Sits at a stable z-index 20 so it's above every
   overlay regardless of where the selected layer falls in the stack.
   Pointer-events: none on the container so clicks fall through to the
   .layer-overlay underneath (which handles select + move); handles and
   badge re-enable pointer-events on themselves. */
.layer-chrome {
  position: absolute;
  transform-origin: top left;
  /* pointer-events: auto on the body so clicks land here for move-drag
     on the SELECTED layer — including the below-cimble case where the
     overlay itself sits BEHIND the iframe (iframe would otherwise eat
     the click). Handles + badge override this with their own data-drag-
     ignore + handlers; the chrome body's pointerdown delegates to the
     same wireOverlayBodyDrag flow as .layer-overlay does for unselected
     layers. */
  pointer-events: auto;
  cursor: move;
  z-index: 20;
  /* Blue 1 px outline at the layer's exact bounds. outline-offset -1px
     keeps the stroke strictly INSIDE the layer's bounds so the selected
     reveal doesn't visually shift the image. Same weight as the hover
     outline on .layer-overlay so the hover → click transition keeps a
     constant stroke. */
  outline: 1px solid var(--color-accent);
  outline-offset: -1px;
}

/* Anchor strokes (layers.js#syncAnchorLines, user 2026-11-13 / -16): where
   the selected layer stays when the aspect ratio changes — a line from the
   middle of the layer edge out to the frame edge it keeps its distance to,
   or the frame line (centre / a third) it's anchored to. The chrome outline's 1 px blue. The box
   is the frame's own (#layerChromeHost is display: contents in #frame), so
   `0` / `right: 0` / `bottom: 0` land exactly on the frame edges. Under
   the chrome (z 20); never takes the pointer. */
.layer-anchors {
  position: absolute;
  inset: 0;
  z-index: 19;
  pointer-events: none;
}
.layer-anchor {
  position: absolute;
  background: var(--color-accent);
}
/* Edge strokes: layers.js sets both ends (frame edge ↔ the layer's edge,
   also when the layer is outside the frame). */
.layer-anchor-l, .layer-anchor-r { height: 1px; }
.layer-anchor-t, .layer-anchor-b { width: 1px; }
/* A layer anchored to the frame's centre or a third (user 2026-11-16): a
   4 px tick where its anchored part sits ON the (invisible) line, or a stroke
   to the line when it keeps a distance — layers.js#syncAnchorLines sets both
   ends. */
.layer-anchor-x { height: 1px; }
.layer-anchor-y { width: 1px; }

/* 8 handles (4 corners + 4 edges). Identical look + offsets to
   `.frame-handle` (8 × 8 squares, 0.5 px border, --shadow-handle drop
   shadow, extended ::before hit target) so they read as the same
   affordance — except the border is the blue accent color instead of
   the grey UI text color. Per Figma 705:3373. */
.layer-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--color-off-white);
  border: 0.5px solid var(--color-accent);
  box-shadow: var(--shadow-handle);
  touch-action: none;
  /* Default to visible because handles only exist inside .layer-chrome,
     and chrome is created only for the currently-selected layer — no
     need for an explicit reveal rule. Pointer-events: auto so the
     handles capture resize drags even when their .layer-chrome parent
     has pointer-events: none. */
  opacity: 1;
  pointer-events: auto;
}
.layer-handle::before {
  content: "";
  position: absolute;
  inset: -8px;
}
/* Same -4.25 px overhangs + cursor variants as the frame handles, so a
   user accustomed to one is at home in the other. */
.layer-handle-tl { top: -4.25px;    left: -4.25px;  cursor: nwse-resize; }
.layer-handle-tr { top: -4.25px;    right: -4.25px; cursor: nesw-resize; }
.layer-handle-bl { bottom: -4.25px; left: -4.25px;  cursor: nesw-resize; }
.layer-handle-br { bottom: -4.25px; right: -4.25px; cursor: nwse-resize; }
.layer-handle-t  { top: -4.25px;    left: 50%;      transform: translateX(-50%); cursor: ns-resize; }
.layer-handle-b  { bottom: -4.25px; left: 50%;      transform: translateX(-50%); cursor: ns-resize; }
.layer-handle-l  { top: 50%;        left: -4.25px;  transform: translateY(-50%); cursor: ew-resize; }
.layer-handle-r  { top: 50%;        right: -4.25px; transform: translateY(-50%); cursor: ew-resize; }

/* 3-dot settings badge above-right of the selected layer. Blue circle
   with three white 2 × 2 squares, drop shadow per Figma 705:3373
   (drop-shadow 0/0/4 rgba(0,0,0,0.6)). Position: 8 px ABOVE the image's
   top edge, right-aligned to the image's right edge.

   Hover-reveal animation mirrors .ctrl-media-badge's pop-in: starts at
   scale 0.6 + slight rotate when hidden, springs to scale 1.0 + zero
   rotate when shown, 0.2 s ease-out. Only revealed when the overlay is
   selected (matches the handles' rule). */
/* Viewport-fixed host for snap guidelines drawn during layer drag /
   resize. Sibling of #stage (outside the panned .frame-group). Lines
   are JS-positioned in viewport coords each frame so they stay aligned
   with the frame's edges + center axes as the user zooms / pans /
   drags. Cyan, 0.5 px. Empty unless a snap is active. */
#snapGuidelineHost {
  position: fixed;
  inset: 0;
  pointer-events: none;
  /* Above the layer chrome (z 20 in .frame's own stacking context, but
     here we're in the top-level stack — keep below the settings popup
     at z 13... actually we want it ABOVE so the line draws on top of
     image overlays + the chrome outline). 15 sits above the chrome and
     settings popup but below the off-screen pill at z 50. */
  z-index: 15;
  overflow: hidden;
}
.snap-guideline {
  position: absolute;
  background: #00FFFF;
  pointer-events: none;
  display: none;
}
.snap-guideline-v { width: 0.5px; }
.snap-guideline-h { height: 0.5px; }

/* Viewport-fixed host for the settings badge. Sibling of #stage, sits
   OUTSIDE .frame-group so its `position: fixed` children clamp to the
   viewport instead of being relative to the panned/transformed
   .frame-group. Empty unless a layer is selected. */
#layerBadgeHost {
  position: fixed;
  inset: 0;
  pointer-events: none;
  /* Above .frame-group (so the badge is never occluded by the frame's
     selected-state outline) and above the layers / settings popups so
     it remains visible while either is open. Below the off-screen pill
     (z 50). */
  z-index: 14;
}
/* Settings badge — viewport-fixed, JS-positioned. `translate(-50%, -50%)`
   centers the badge on the (left, top) anchor written by positionBadge
   so the clamp math doesn't need to know the badge's box dimensions in
   anchor-write time. */
.layer-settings-badge {
  appearance: none;
  position: fixed;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--color-accent);
  /* Off-white icon color so SETTINGS_SVG's `fill="currentColor"` paints
     white on the accent-blue disc. */
  color: var(--color-off-white);
  /* Same drop-shadow values as `--shadow-handle` (0 0 8 px black 0.6) so
     the badge sits on the same elevation as the corner / edge resize
     handles. Filter (vs box-shadow) keeps the shadow round around the
     disc instead of the bounding box. */
  filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.6));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  /* Always visible while present — badge only renders when an image
     layer is selected (renderOverlays gates this). pointer-events: auto
     so clicks land here even though #layerBadgeHost has none. */
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  transition: transform 0.15s ease;
}
.layer-settings-badge:hover {
  transform: translate(-50%, -50%) scale(1.1);
}
.layer-settings-badge:active {
  transform: translate(-50%, -50%) scale(0.96);
}

/* ──────────── Per-image settings popup ──────────────────────────────── */

/* Per Figma 711:3841 — panel bg + 16 px radius + 12 px padding + 8 px
   gap between rows. 287 px wide so the slider, blend dropdown, and
   sizing+reupload bottom row all have comfortable width. */
.layer-settings-popup {
  position: fixed;
  z-index: 13;
  width: 210px;
  /* Canonical popup padding — 12 px on every side, shared with
     .settings-popup + .layers-popup. See DESIGN-SYSTEM.md
     § "Popup chrome". */
  padding: 12px;
  background: var(--color-panel);
  border-radius: 16px;
  box-shadow: var(--shadow-frame);
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Popup spawns BELOW the badge with its LEFT edge aligned to the
     badge's left edge — see positionSettingsPopup. `top left` so the
     open-animation scale grows out of the corner nearest the badge. */
  transform-origin: top left;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.layer-settings-popup.hidden {
  opacity: 0;
  transform: scale(0.95) translateY(-4px);
  pointer-events: none;
}
/* Placed ABOVE the badge (no room below): it opens / closes from its
   bottom edge — the edge next to the badge — rising into place. */
.layer-settings-popup.is-above { transform-origin: bottom left; }
.layer-settings-popup.is-above.hidden { transform: scale(0.95) translateY(4px); }
/* Dragged by its background (layers.js#onSettingsPopupDragStart). */
/* The popup's background is its drag handle (layers.js#onSettingsPopupDragStart):
   it shows the grab hand (user 2026-11-16); the controls inside — the same
   list the drag ignores, POPUP_CONTROLS — keep their own cursors. The reset
   is :where()-wrapped (no specificity), so a control's own cursor rule
   (pointer, text, ew-resize) always wins over it. */
.layer-settings-popup { cursor: grab; }
:where(.layer-settings-popup) :where(button, input, textarea, select, a, label, [contenteditable], [tabindex],
  .ctrl-dropdown, .layer-settings-dropdown, .ctrl-value, .ctrl-input, .ctrl-stepper,
  .color-swatch, .layer-text-color, .layer-segmented, .ctrl-color-field) { cursor: auto; }
body.layer-popup-dragging,
body.layer-popup-dragging * { cursor: grabbing !important; user-select: none; }

/* Generic section-header row — label LEFT, optional scrubbable .ctrl-value
   cell RIGHT (the Blending header has both; the Image header is label-
   only). The value cell reuses the sidebar's existing .ctrl-value /
   .ctrl-value-input / .ctrl-value-unit classes so the hover-highlight
   bg + off-white-on-hover text behavior comes for free (see L2266+).
   No outer padding — the popup's own 12 px padding and the row's own
   gap to the next element handle spacing; the label sits flush against
   the popup's inner edge. */
.layer-settings-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
}
/* Sections are further apart than a label is from its own controls (user
   2026-11-17): 8 + 8 = 16 px above every section header but the first,
   8 px (the popup's gap) between a header and what it heads. */
.layer-settings-popup > .layer-settings-section-header:not(:first-child) { margin-top: 8px; }
/* While scrubbing the opacity value, lock the cursor to ew-resize across
   the whole window so the chrome doesn't flicker between hover-shapes
   on different elements as the cursor wanders mid-drag. */
body.layer-opacity-scrubbing,
body.layer-opacity-scrubbing * { cursor: ew-resize !important; }

/* Dropdown — abridged version of `.ctrl-dropdown` (controls.js). 8 px
   radius, --color-input bg, chevron that rotates 180° on .open. Self-
   contained: no cfg state, no altered tracking, no hover-preview. */
.layer-settings-dropdown {
  position: relative;
  background: var(--color-input);
  border-radius: 8px;
  color: var(--color-text);
  cursor: pointer;
  overflow: hidden;
  transition: none;
}
/* CLOSED hover lift — bg + color change on the header. Same shape as
   .ctrl-dropdown's closed-state hover in the sidebar; the
   `:not(.suppress-hover)` gate prevents the bg from re-lighting
   immediately after the user clicks the dropdown to close it (cursor
   is still over the header at that moment). suppress-hover is added
   in JS on close and removed on `mouseleave`, so the lift returns the
   next time the cursor genuinely leaves and re-enters. */
.layer-settings-dropdown:not(.open):not(.suppress-hover):hover .layer-settings-dropdown-header {
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
}
.layer-settings-dropdown.open {
  background: var(--color-input);
  color: var(--color-off-white);
}
.layer-settings-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  /* Same `--input-row-h` + 12 px horizontal padding as the .layer-row
     and .layer-add-row use — three input-row surfaces share a single
     token so the popups read as a unified component family. */
  height: var(--input-row-h);
  padding: 0 calc(var(--dd-arrow-hit) + 16px) 0 12px;   /* right: chevron square + 8 px inset + 8 px gap */
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  /* 0.5 px hairline that fades in when the dropdown opens — same
     under-header divider behavior as the sidebar's `.ctrl-dropdown-header`.
     On CLOSE the fade-out is DELAYED until the options panel has
     finished collapsing (var(--transition-collapse) = 0.4 s); only
     then does the divider ease back to transparent over 0.1 s, so it
     doesn't appear orphaned mid-collapse. The delay value MUST be a
     raw time literal because var() expands to "0.4s ease" which is
     invalid in the transition delay slot (silently dropped). Kept
     (not a hover fade — 2026-11-17). */
  border-bottom: 0.5px solid transparent;
  transition: border-bottom-color 0.1s ease 0.4s;
}
/* Header divider — full width (the group dividers below are inset);
   same timing as before (in with the panel, out after the 0.4 s
   collapse). */
.layer-settings-dropdown-header { position: relative; }
.layer-settings-dropdown-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.5px;
  height: 0.5px;
  background: var(--color-stroke-hi);
  opacity: 0;
  transition: opacity 0.1s ease 0.4s;
  pointer-events: none;
}
.layer-settings-dropdown.open .layer-settings-dropdown-header::after { opacity: 1; transition: opacity 0.1s ease; }
/* The picked value reads Brand off-white, like every sidebar dropdown's
   (user 2026-11-12 — Blend / Sizing were the only grey ones); the chevron
   too, as in the sidebar. */
.layer-settings-dropdown-value {
  flex: 1 1 auto;
  color: var(--color-off-white);
}
.layer-settings-dropdown-arrow { color: var(--color-off-white); }
.layer-settings-dropdown-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: transform var(--transition-icon);
}
.layer-settings-dropdown.open .layer-settings-dropdown-arrow {
  transform: rotate(180deg);
}
/* Outer = scroll viewport. NO padding here so a list taller than
   max-height doesn't clip the bottom padding away with the overflowing
   rows. The padded row stack lives on the .layer-settings-dropdown-options-inner
   wrapper below — same pattern as `.ctrl-dropdown` in controls.js. */
.layer-settings-dropdown-options {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-collapse);
}
.layer-settings-dropdown.open .layer-settings-dropdown-options {
  max-height: 320px;
  overflow-y: auto;
  /* Hide scrollbar — visually competes with row highlights, same as
     the sidebar's `.ctrl-dropdown-options` decision. */
  scrollbar-width: none;
}
.layer-settings-dropdown.open .layer-settings-dropdown-options::-webkit-scrollbar {
  display: none;
}
.layer-settings-dropdown-options-inner {
  display: flex;
  flex-direction: column;
  padding: 6px;
  box-sizing: border-box;
  width: 100%;
}
.layer-settings-dropdown-row {
  padding: 6px 6px 7px;
  border-radius: 6px;
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  color: var(--color-text);
  cursor: pointer;
  transition: none;
}
.layer-settings-dropdown-row.selected { color: var(--color-off-white); }
.layer-settings-dropdown-row:hover {
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
}
/* Group divider between option clusters in the menu (e.g. between
   blend-mode families per screenshots/Blendingmodesorder.png). 0.5 px
   line in --color-stroke-hi with 4 px of breathing room on each side
   so adjacent rows don't crowd it. */
.layer-settings-dropdown-divider {
  height: 0.5px;
  margin: 4px 0;   /* no side margins — spans the list's 6 px inset (user rule 2026-11-11) */
  background: var(--color-stroke-hi);
  flex-shrink: 0;
}

/* Bottom row — Sizing dropdown (flex-1) + 40 × 40 reupload square. */
.layer-settings-bottom-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.layer-settings-dropdown-flex { flex: 1 1 auto; min-width: 0; }
.layer-settings-image-btn {
  appearance: none;
  border: none;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  padding: 0;
  border-radius: 8px;
  background: var(--color-input);
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.layer-settings-image-btn:hover {
  background: var(--color-stroke-hi);
  color: var(--color-off-white);
}
.layer-settings-image-btn:active { transform: scale(0.96); }

/* ──────────── Text layers ──────────────────────────────────────────────
   Overlay = a padded box (glyphs may overhang the text box) holding the
   text's <canvas>; only the inner `.layer-text-hit` (the text box itself)
   takes the pointer. Same blend / opacity vars as image overlays. */
.layer-overlay-text { pointer-events: none; }
.layer-text-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
.layer-text-hit { position: absolute; pointer-events: auto; }
/* While typing, the selection outline stays; handles step aside and the
   chrome lets clicks through to the editor. */
.layer-chrome.is-editing { pointer-events: none; }
.layer-chrome.is-editing .layer-handle { display: none; }
/* On-canvas editor — transparent text over the live canvas (which keeps
   showing the real, blended text); carries only the caret + selection.
   Font metrics are written inline by layers.js#positionTextEditor. */
.layer-text-editor {
  position: absolute;
  z-index: 21;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  box-sizing: content-box;
  color: transparent;
  caret-color: var(--color-accent);
  overflow-wrap: anywhere;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}
/* Grab edges while typing — four transparent strips straddling the text
   box's edges (6 px out, 2 px in); dragging one moves the layer without
   ending the typing (layers.js#startTextEdit). Above the editor. */
.layer-text-grip {
  position: absolute;
  z-index: 22;
  cursor: move;
  pointer-events: auto;
  touch-action: none;
}
.layer-text-editor::selection { background: var(--color-selection); color: transparent; }

/* Layers popup "+" → Image / Text menu (Figma 1B, 1028:2883): a small
   panel 8 px right of the popup, bottom-aligned with it (layers.js
   #positionAddMenu). Rows are the popup dropdown's rows with a glyph.
   The "+" row stays lit while it's open. */
/* (Its open state: the hover look — rule by .layer-add-row above.) */
.layer-add-menu {
  position: fixed;
  z-index: 13;
  width: 132px;
  /* Canonical popup padding — 12 px on every side, same as .settings-popup
     / .layers-popup / .layer-settings-popup (DESIGN-SYSTEM.md § "Popup
     chrome"; user 2026-11-12 — the 1B frame's 6 px was off-system). */
  padding: 12px;
  box-sizing: border-box;
  background: var(--color-panel);
  /* 14 px — the Layers popup it sits beside (user 2026-11-12). */
  border-radius: 14px;
  box-shadow: var(--shadow-frame);
  display: flex;
  flex-direction: column;
  transform-origin: left bottom;   /* JS flips it to right bottom on the left side */
  transition: opacity 0.15s ease, transform 0.15s ease;
}
/* Fades out like it fades in — the close STARTS the moment the pointer
   leaves the + (hover-menu.js), not after the +'s scale-down (user
   2026-11-17; an instant hide was tried). */
.layer-add-menu.hidden { opacity: 0; transform: scale(0.95); pointer-events: none; }
.layer-add-menu-row {
  appearance: none;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
}
.layer-add-menu-row .layer-row-icon { width: 12px; height: 12px; }
.layer-row-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Text section of the layer settings popup (Figma 3C). The Font / Weight
   dropdowns and number fields are the sidebar's own controls; here they
   take the popup's input-row metrics (40 px rows, 12 px inset, 500 type —
   same as the Blend / Sizing dropdowns above them). */
.layer-settings-bottom-row.layer-text-row { align-items: flex-start; }
.layer-settings-popup .ctrl-dropdown { min-height: var(--input-row-h); }
.layer-settings-popup .ctrl-dropdown { --dd-arrow-hit: 24px; }   /* 40 px row − 2 × 8 px */
.layer-settings-popup .ctrl-dropdown-header { height: var(--input-row-h); padding: 0 calc(var(--dd-arrow-hit) + 16px) 0 12px; gap: 8px; }
/* The value text AND the search field that replaces it share the same
   metrics, so opening the search never shifts the text (it rose 1 px). */
.layer-settings-popup .ctrl-dropdown-header .ctrl-dropdown-text,
.layer-settings-popup .ctrl-dropdown-search-input { padding-bottom: 0; }
.layer-settings-popup .ctrl-dropdown-text,
.layer-settings-popup .ctrl-dropdown-search-input { font-weight: 500; }
.layer-settings-popup .ctrl-dropdown-options-inner { padding: 6px; }
.layer-settings-popup .ctrl-input.layer-text-num {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  height: var(--input-row-h);
  min-height: var(--input-row-h);
  padding: 0;
  align-items: stretch;
}
.layer-text-num .ctrl-input-value { padding: 0 6px; }   /* 40 px popup fields: tighter side inset */
.layer-text-num .ctrl-input-input,
.layer-text-num .ctrl-input-unit { font-weight: 500; }
.layer-text-pair > .layer-text-field { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
/* The shadow's Color (user 2026-11-17): the sidebar's colour row at the
   popup's 40 px — a 40 px slot with a 28 px circle (the sidebar's 39 in 55,
   scaled), 8 px, the # hex + % field (popup fields' 12 px side inset). The
   circle sits on the popup's Panel like the sidebar's, so its checker reads
   the same. */
/* (The text colour uses it too, user 2026-11-17: `.layer-color-row`.) */
/* Text: Size · Letter spacing · Line height, a row of three on WHOLE px —
   the outer two round down, the middle takes the rest (thirds of 186 were
   56.67). */
.layer-settings-bottom-row.layer-text-thirds {
  display: grid;
  grid-template-columns: round(down, calc((100% - 16px) / 3), 1px) 1fr round(down, calc((100% - 16px) / 3), 1px);
  gap: 8px;
}
.layer-color-row { width: 100%; gap: 8px; }
.layer-color-row .ctrl-color-slot { flex: 0 0 40px; width: 40px; height: 40px; }
.layer-color-row .ctrl-color-slot .color-swatch { width: 28px; height: 28px; }   /* the sidebar's 39 in 55, scaled to the 40 px row */
.layer-color-row .ctrl-color-field { height: var(--input-row-h, 40px); padding: 0 12px; }
/* "Letter spacing" is ~2 px wider than its half of the popup — it may run
   into the 8 px gap rather than wrap under itself. */
.layer-text-field > .ctrl-label { white-space: nowrap; }
.layer-settings-popup .layer-text-field > .ctrl-input.layer-text-num { flex: none; width: 100%; }
/* Text header's width toggle ("Auto width" / "Fixed width") — the header
   labels' type (.ctrl-label: 500 13.6 / 17), Brand off-white; in the
   header's right-hand value slot it takes that slot's padding (4 / 6 / 5)
   and hover box, like the Blending % value. */
.layer-width-toggle {
  appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px 6px 5px;
  border-radius: 6px;
  font: 500 13.6px/17px var(--font-display);
  letter-spacing: 0.35px;
  /* Brand off-white in both states (user 2026-11-12). */
  color: var(--color-off-white);
  transition: none;
}
@media (hover: hover) {
  .layer-width-toggle:hover { background: var(--color-stroke-hi); color: var(--color-off-white); }
}
/* Size + color share one row, half each (user 2026-11-12) — same 8 px gap
   as the Letter spacing / Line height pair, so the columns line up. */
.layer-text-halves > .layer-text-color { flex: 1 1 0; min-width: 0; width: auto; }
.layer-text-color .color-swatch { width: 20px; height: 20px; }
/* The text color is ONE button — box + dot (user 2026-11-12): hovering
   either part lights the box AND grows the dot (the swatch's own 1.1), and
   pressing either dips both. Without these, hovering the box beside the dot
   lit only the box, and the dot grew only when hovered itself. */
.layer-text-color:hover .color-swatch { transform: scale(1.1); }
.layer-text-color:active .color-swatch,
.layer-text-color:hover:active .color-swatch { transform: scale(0.94); }
.layer-text-color .color-swatch-label { display: none; }

/* Segmented control — Alignment / Case. Input-row strip, each option a
   6 px-radius pill that lights like a dropdown row; the picked one stays lit. */
.layer-segmented {
  /* The options keep the strip's 4 px inset all round, and the edges
     BETWEEN them line up with the fields above (user 2026-11-17, 4th round:
     "indented equally, and then compensate on their respective edges"):
     8 px between options (the fields' gap); the first / last option is its
     field column minus the 4 px inset on its outer side — popup: 4–56 ·
     64–122 · 130–182 under fields 0–56 · 64–122 · 130–186. Whole-px columns
     with the fields' rounding — rules below. The sidebar's Case row: its
     fields' 10 px. (Tried: 8 px inside the inset; 16 px; no side inset.) */
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  column-gap: 8px;
  height: var(--input-row-h);
  padding: 4px;
  box-sizing: border-box;
  background: var(--color-input);
  border-radius: 8px;
}
/* 100 % = the strip's content box (its width − 8). A field column =
   round(down, (width − (n−1)·gap) ÷ n) = round(down, (100% + 8 − (n−1)·gap) ÷ n);
   the first / last option = that − 4, the middle ones share the rest. */
.layer-segmented:has(> :nth-child(3):last-child) {
  grid-template-columns: calc(round(down, (100% - 8px) / 3, 1px) - 4px) 1fr calc(round(down, (100% - 8px) / 3, 1px) - 4px);
}
.layer-segmented:has(> :nth-child(4):last-child) {
  grid-template-columns: calc(round(down, (100% - 16px) / 4, 1px) - 4px) 1fr 1fr calc(round(down, (100% - 16px) / 4, 1px) - 4px);
}
.layer-segmented.ctrl-case:has(> :nth-child(4):last-child) {   /* sidebar: 10 px gaps */
  grid-template-columns: calc(round(down, (100% - 22px) / 4, 1px) - 4px) 1fr 1fr calc(round(down, (100% - 22px) / 4, 1px) - 4px);
}
.layer-segmented-btn {
  appearance: none;
  border: none;
  flex: 1 1 0;
  min-width: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  transition: none;
}
.layer-segmented-btn svg,
.layer-segmented-btn .case-glyph { transition: transform 0.15s ease; }
/* AA / Aa / aa — text in Neue Haas Medium (600 in the kit) at the UI's
   13.6 px (user 2026-11-17: the outlines read Black; then "same size as
   other text"). */
.case-glyph { display: block; font: 600 13.6px/1 var(--font-display); letter-spacing: 0.35px; }
.layer-segmented-btn.active { background: var(--color-stroke-hi); color: var(--color-off-white); }
@media (hover: hover) {
  .layer-segmented-btn:not(.active):hover { background: var(--color-stroke-hi); color: var(--color-off-white); }
  .layer-segmented-btn:not(.active):hover svg,
  .layer-segmented-btn:not(.active):hover .case-glyph { transform: scale(1.2); }
}
.layer-segmented-btn:not(.active):active svg,
.layer-segmented-btn:not(.active):active .case-glyph { transform: scale(0.94); }
/* The same switch under a sidebar Text control (the Case, controls.js
   buildCaseRow) — 55 px like every sidebar box. */
.layer-segmented.ctrl-case { height: var(--ctrl-h); column-gap: 10px; }


/* ──────────── Drag-active hover suppression ────────────────────────────
   When ANY HTML5 reorder drag is in flight (`body.drag-active`, set by
   layers.js, buildKeywords, and buildMedia on dragstart / removed on
   dragend), the cursor passing over OTHER thumbs / pills / rows still
   triggers their `:hover` state — visible as X badges popping in, crop
   overlays fading on, pills dimming, row backgrounds lifting. Override
   those hover rules to the resting state while drag-active, scoped to
   non-source elements (`:not(.dragging)`) and, for layer rows, also
   non-selected so a selected layer keeps its lifted appearance. */
body.drag-active .ctrl-media-thumb:not(.dragging):hover .ctrl-media-badge {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.6) rotate(-10deg);
  transition: none;
}
body.drag-active .ctrl-media-thumb:not(.dragging):hover .ctrl-media-replace-overlay {
  opacity: 0;
  pointer-events: none;
  transition: none;
}
body.drag-active .ctrl-keywords-pill:not(.dragging):hover {
  opacity: 1;
  scale: 1;
}
body.drag-active .layer-row:not(.dragging):not(.selected):hover {
  background: var(--color-input);
  color: var(--color-text);
}

/* ────────────────────────────────────────────────────────────────────
   Mobile bottom-sheet elements — hidden on desktop. The mobile @media
   block below flips them on and turns the .controls sidebar into a
   bottom-anchored, full-width sheet. They exist in the DOM on every
   viewport so the JS in mobile-sheet.js doesn't need to inject them
   lazily — but on desktop they're invisible. Both the sheet-header
   (drag pill wrapper) and the sheet-header-row (Xerox / Controls /
   settings disc) get explicit display:none here because they live
   INSIDE .controls-body now — without the rule, desktop's sidebar
   would render them at the top of the panel above the navigator.
   ──────────────────────────────────────────────────────────────────── */
.sheet-header,
.sheet-header-row { display: none; }

/* ────────────────────────────────────────────────────────────────────
   Mobile layout — phones & tablets in portrait. Trigger:
     • `pointer: coarse` — primary input is finger/stylus (not mouse)
     • `max-width: 900px` — viewport narrow enough that a side panel
       would crowd the canvas.
   Both must match. A touchscreen laptop at desktop width still gets
   the desktop layout; a narrow browser window on a desktop without
   touch also stays desktop. The combined query is the same one
   mobile-sheet.js listens to for body.is-mobile.

   The mobile layout reuses the existing `#controls` sidebar as a
   bottom sheet (full-width, anchored to the viewport bottom). The
   sheet's transform is animated via `translateY()`: collapsed state
   translates the sheet down by its own height minus
   `--sheet-collapsed-h`, leaving only the header (drag handle + tool
   name + settings "···") visible. Expanded state translates back to
   0. JS controls the class toggling and a brief inline transform
   during drag.
   ──────────────────────────────────────────────────────────────────── */
@media (pointer: coarse) and (max-width: 900px) {
  /* Media tiles on touch: there's no hover, and a tap on the image now
     REPLACES it — so the corner badges (crop / remove) must be visible at
     rest or cropping would be unreachable. The replace overlay stays
     hidden (a tap is the affordance). */
  .ctrl-media-thumb .ctrl-media-badge {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }
  /* Block iOS Safari's pull-to-refresh (gives the "site moves down
     and reloads" behaviour the user reported when swiping the sheet
     header) and double-tap-to-zoom (also unwanted — the canvas auto-
     fits, there's nothing for the user to zoom into at the page
     level). `overscroll-behavior: none` on the root stops chained
     pull gestures from triggering the browser's reload affordance;
     `touch-action: manipulation` disables the 300 ms double-tap
     delay AND the zoom default while leaving panning / pinch
     (which the canvas-view layer pinch handler consumes) intact. */
  html, body {
    overscroll-behavior: none;
    touch-action: manipulation;
  }
  /* Disable text selection on touch — long-press on canvas, section
     headers, sliders, etc. would otherwise show iOS Safari's
     selection ring + magnifier and feel like a bug. Re-enabled
     below only on actual text-entry surfaces (the inputs / textarea
     allowlist). Both `user-select` and `-webkit-user-select` are
     set; iOS still requires the prefixed property. */
  body {
    user-select: none;
    -webkit-user-select: none;
  }
  /* Allowlist — every real text-entry surface keeps native selection
     so users can copy / paste / scrub-select normally. Includes
     specific design-system classes plus a generic input/textarea
     fallback so any future text input (no class declared yet)
     stays usable without a separate styles update. */
  .ctrl-stepper-input,
  .ctrl-textfield-input,
  .prompt-key-input,
  .ctrl-keywords-input,         /* inline keyword-pill input */
  .clr-field input,             /* Coloris HEX field */
  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="email"],
  input[type="search"],
  textarea,
  [contenteditable="true"] {
    user-select: text;
    -webkit-user-select: text;
  }

  :root {
    /* Collapsed-state vertical budget:
         8 px top margin (handle)
       + 6 px handle pill
       + 10 px gap (handle bottom margin / "padding above the word")
       + 17 px line-height of the "Controls" label
       + 10 px sheet-header bottom padding
       ─────
       = 51 px
       Tight: just the swipe bar and the word, 10 px of breathing room
       on either side. Settings button + tool name are display:none
       when collapsed (rule below) so they contribute zero height. */
    --sheet-collapsed-h: 51px;
    --sheet-expanded-h:  70vh;
  }

  /* ── Sidebar becomes a bottom sheet ─────────────────────────────── */
  .controls {
    /* Override `top: 0; right: 0; width: var(--ctl-w)` with full-width
       bottom-anchored sheet. `inset: auto 0 0 0` resets all four edges;
       then `bottom: env(safe-area-inset-bottom, 0)` pulls the sheet
       up by the iOS home-indicator height so the safe-area strip
       below shows the html's --color-bg-canvas (#191919, Background)
       — one shade darker than the sheet's --color-panel (#202020).
       Gives a clear visual boundary at the bottom edge of the
       swipable surface. On devices without a home indicator (Android,
       iPhone SE), `env(...)` returns 0 → no behaviour change. */
    inset: auto 0 0 0;
    bottom: env(safe-area-inset-bottom, 0);
    width: 100vw;
    height: var(--sheet-expanded-h);
    padding: 0;
    border-radius: var(--radius-panel) var(--radius-panel) 0 0;
    /* Collapsed state translates down by (height - visible strip). */
    transform: translateY(calc(100% - var(--sheet-collapsed-h)));
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
    pointer-events: auto;
    background: var(--color-panel);
    box-shadow: var(--shadow-frame);
    /* Sheet sits ABOVE the Capture / Record / Layers cluster on mobile
       (z 13 vs pills' 11 below) — the cluster is a bottom-of-screen
       row anchored just above the sheet handle, and during the drag
       the sheet should slide cleanly over it, not behind. Popups
       (settings, layers list, image-layer settings) are bumped to
       z 14 below so they still surface above the sheet when opened
       from a button inside it. */
    z-index: 13;
  }
  .controls.sheet-expanded { transform: translateY(0); }
  /* During active pointer drag the JS writes the transform inline AND
     adds `.sheet-dragging`; nuke the transition so the sheet tracks
     the finger 1:1. The class is removed on pointerup AFTER the
     inline transform is wiped, restoring the snap transition. */
  .controls.sheet-dragging { transition: none; }

  /* The inner panel was a separately-rounded surface on desktop. Flatten
     it on mobile so the rounding lives on the outer .controls (the
     bottom sheet's own top corners). */
  .controls-inner {
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    background: transparent;
  }
  .controls-body { padding: 0; }

  /* Hide the col-resize handle — sheet width is fixed at 100vw. */
  .controls-resize-handle { display: none; }

  /* The navigator (tool dropdown) is hidden because the sheet header
     surfaces the same tool name above. Hiding it via `data-preserve`
     compatible CSS (controls.js#clearControls preserves the element
     but doesn't change its display) keeps the source-of-truth intact
     while reclaiming the space. */
  .navigator-wrap { display: none; }

  /* ── Sheet header (drag handle only) ─────────────────────────────── */
  /* The header lives INSIDE .controls-body so the body fills the
     sheet's full height — the only visible clip is then the sheet's
     own rounded-corner overflow, no internal horizontal line. Sticky
     positioning keeps the pill visible at the top as content scrolls
     past. Opaque bg (matches the sheet) covers scrolling content
     under the pill so it's not visually competing. */
  .sheet-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    background: var(--color-panel);
    /* Block native vertical scrolling on the header so vertical drags
       initiate our JS handler rather than scrolling the page. */
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    flex: 0 0 auto;
  }
  .controls.sheet-dragging .sheet-header { cursor: grabbing; }
  /* Visual drag handle pill. 80 × 6 px (2× wider + 1.5× taller than
     the original 40 × 4) — bigger affordance, easier to grab. Sits
     close to the sheet's top edge (8 px margin) so it reads as a
     handle and not as content. align-self: center keeps it
     horizontally centered without affecting the rows below. */
  .sheet-handle-pill {
    align-self: center;
    width: 80px;
    height: 6px;
    /* 8 px from sheet top, 10 px before the scrollable body starts. */
    margin: 8px 0 10px;
    background: var(--color-stroke-hi);
    border-radius: var(--radius-pill);
    flex: 0 0 6px;
  }
  /* Header row — 3-column grid: tool name LEFT (1fr), static
     "Controls" label CENTER (auto), settings disc RIGHT (1fr). The
     equal 1fr side columns guarantee the centered label sits at the
     geometric center of the row regardless of which side columns
     have content. `align-items: center` vertically centers all
     three.

     No min-height — the row sizes to its tallest visible child. With
     just "Controls" (the collapsed state, with tool-name + settings
     display:none) the row is 17 px (line-height of P2b). With the
     settings disc visible (expanded state), the row grows to 58 px
     (--btn-export-h) to fit the disc. The header's overall height
     follows from this. */
  .sheet-header-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    /* 20 px horizontal — matches the sheet's outer gutter (was applied
       via .sheet-header's `padding: 0 20px` before the row moved into
       .controls-body). 10 px BOTTOM is the "padding below the word"
       per the original design requirement — top padding isn't needed
       because the pill's `margin-bottom: 10` inside .sheet-header
       already provides the gap above. Box-sizing keeps the row at
       17 px text + 10 px bottom = 27 px when collapsed, which combined
       with the 24 px sheet-header puts the total visible content at
       51 px (= --sheet-collapsed-h). When expanded the row grows to
       max(text, 58 px settings button) + 10 = 68 px. */
    padding: 0 20px 10px;
  }
  /* Active tool name (.cimble's display name). Left-aligned in its
     1fr column, P2b weight, off-white so it stands out as the
     "current document" label. Truncates with ellipsis when too long
     to fit its column. Pinned to grid column 1 so it can't get
     auto-shifted into the center column when its sibling is
     display:none. */
  .sheet-tool-name {
    grid-column: 1;
    justify-self: start;
    font: 600 13.6px/17px var(--font-display);
    letter-spacing: 0.35px;
    color: var(--color-off-white);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* The grid column width is bounded by 1fr, but a long tool name
       in a long header would push the grid wider; this min-width:0
       forces the column to participate in the 1fr distribution by
       allowing it to shrink below its content's natural width. */
    min-width: 0;
    max-width: 100%;
  }
  /* Static "Controls" label — identifies the sheet itself. Same P2b
     weight as the tool name but in the dimmer UI/Text color so the
     tool name (off-white) reads as the primary identifier and the
     "Controls" label as supporting context. Pinned to grid column 2
     so it stays centered even when its siblings are display:none —
     without this, auto-placement would shift it into column 1 the
     moment .sheet-tool-name is hidden, breaking the centering. */
  .sheet-header-label {
    grid-column: 2;
    justify-self: center;
    font: 600 13.6px/17px var(--font-display);
    letter-spacing: 0.35px;
    color: var(--color-text);
  }
  /* Settings "···" disc — same 58 × 58 circle as Capture / Record /
     Layers FAB so the mobile action vocabulary stays consistent.
     Right-aligned within its grid column. Universal "ButtonHover"
     treatment (scale 1.1 + bg lift + off-white icon + 10 % white
     overlay) mirrors `.export-pill` exactly. */
  .sheet-settings-btn {
    appearance: none;
    border: none;
    width: var(--btn-export-h);
    height: var(--btn-export-h);
    min-width: var(--btn-export-h);
    padding: 0;
    border-radius: 50%;
    background: var(--color-input);
    color: var(--color-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    /* Pinned to grid column 3 — same reason as .sheet-header-label
       above. Auto-placement would otherwise let this button drift
       into column 2 in unusual states. */
    grid-column: 3;
    justify-self: end;
    /* Keep the button click distinguishable from a sheet drag — its
       own click handler in settings-ui.js handles open/close; the
       drag handler in mobile-sheet.js explicitly bails on this
       target via `.closest(".sheet-settings-btn")`. */
    touch-action: manipulation;
    transition: transform 0.15s ease, opacity 0.2s ease;
  }
  @media (hover: hover) {
    .sheet-settings-btn:not(.suppress-hover):hover {
      background: var(--color-stroke-hi);
      color: var(--color-off-white);
      transform: scale(1.1);
      box-shadow: var(--shadow-frame), inset 0 0 0 9999px var(--color-hover-overlay);
    }
  }
  .sheet-settings-btn:not(.suppress-hover):active { transform: scale(0.94); }
  /* Active anchor — bg + color + shadow only. The :hover rule above
     (higher specificity) re-applies scale(1.1) only when the cursor
     is over the open button, signalling "click to close". */
  .sheet-settings-btn[aria-expanded="true"] {
    background: var(--color-stroke-hi);
    color: var(--color-off-white);
    box-shadow: var(--shadow-frame), inset 0 0 0 9999px var(--color-hover-overlay);
  }
  /* Hidden when the sheet is collapsed — the user hasn't engaged the
     controls surface yet, so surfacing the settings entry would be
     premature. The tool name (.cimble's display name) hides at the
     same time so the collapsed header reads as a clean "Controls"
     label only.

     `display: none` (not visibility:hidden) so the elements contribute
     zero layout — the row collapses to the height of "Controls" alone
     (17 px), shrinking the visible collapsed sheet to just the swipe
     bar + the word. Grid columns of `1fr auto 1fr` still allocate
     equal space to the two empty 1fr columns, so "Controls" stays
     dead-center regardless of which side columns have content. */
  .controls:not(.sheet-expanded) .sheet-settings-btn,
  .controls:not(.sheet-expanded) .sheet-tool-name {
    display: none;
  }

  /* ── Body scroll: enabled only when expanded ────────────────────── */
  /* When collapsed, prevent the body from being touch-grabbed (which
     would otherwise scroll a list that's mostly off-screen). When
     expanded, native scrolling works inside the body and the sheet
     header is the only drag surface — so body scroll and sheet drag
     never conflict. */
  .controls:not(.sheet-expanded) .controls-body {
    /* `overflow-y: hidden` stops the (mostly off-screen) body from
       being touch-scrolled while collapsed. NO pointer-events: none
       here because the sheet-header lives INSIDE the body now — the
       drag pill / "Controls" label need to remain tappable for
       toggle-to-expand. */
    overflow-y: hidden;
  }
  .controls.sheet-expanded .controls-body {
    overflow-y: auto;
    /* `pan-y` lets vertical scroll work; horizontal swipes still
       reach pointer handlers (e.g. the ratio pill arrow nav, though
       it has no mobile equivalent). */
    touch-action: pan-y;
    /* Kill iOS's native rubber-band bounce at the top/bottom of the
       scrollable body. `contain` means scroll chaining stops at the
       body's edge — the page doesn't bounce, doesn't pull the sheet
       implicitly. The mobile-sheet.js touchmove handler explicitly
       drags the sheet down when the body is at scrollTop=0 and the
       finger pulls down, so the user's intent ("pull the sheet down
       to close it") still works — just deterministically, not via
       the iOS overscroll affordance. */
    overscroll-behavior-y: contain;
    /* Extra bottom padding so the last ctrl-group's content (e.g.
       Iterate's textarea + Run button) isn't crowded by the device
       safe-area at the bottom of the screen. */
    padding-bottom: 40px;
  }

  /* The Iterate section's textarea autofocus / virtual-keyboard
     interaction is fine — the browser auto-scrolls the focused input
     into view inside the scrollable .controls-body, which is what we
     want. */

  /* ── Hide desktop-only chrome on mobile ─────────────────────────── */
  /* Frame resize handles — no drag-to-resize on touch (canvas auto-
     fits the visible area; the user picks ratios from the sheet). */
  .frame-handle { display: none; }
  /* Editable size pill below the frame — no resize means no value to
     edit; hide it. */
  .frame-size-pill { display: none !important; }
  /* Zoom pill — no pinch/wheel zoom on mobile (see mobile-sheet.js
     and the setupCanvasPan / host_wheel guards in app.js). */
  #zoomPill { display: none; }
  /* Desktop "···" settings button at the bottom-left of .export-pills
     — replaced on mobile by the sheet header's own "···" button. */
  .export-pill-settings { display: none; }

  /* ── Export pills — bottom-center above the sheet handle ────────── */
  /* Capture + Record live above the collapsed sheet header. Same
     58 px size as desktop; positioned centered horizontally,
     16 px above the sheet's top edge. The pills are SIBLINGS of the
     sheet in the DOM, so they stay viewport-fixed regardless of the
     sheet's transform. */
  .export-pills {
    left: 50%;
    right: auto;
    /* Bottom = sheet's visible collapsed strip (51 px) + 16 px gap +
       the iOS safe-area-inset (matches the sheet's `bottom: env(...)`
       so the cluster stays the same 16 px above the sheet's top edge
       on iPhones with a home indicator). */
    bottom: calc(var(--sheet-collapsed-h) + 16px + env(safe-area-inset-bottom, 0));
    transform: translateX(-50%);
    gap: 8px;
    /* Pills sit BELOW the sheet (z 11 vs sheet's 13). The sheet's
       rounded top edge slides cleanly over the cluster during the
       drag; the existing `body:has(.controls.sheet-expanded)`
       opacity-fade rule on these pills still applies for the
       fully-expanded state. */
    z-index: 11;
  }
  /* The .export-pills hidden state on desktop fades opacity AND
     disables pointer-events; preserve both on mobile by keeping the
     same .hidden rule (no override needed — flex centering still
     applies). */

  /* The recording timer's reveal animates max-width / opacity /
     padding over 0.4s on desktop so the Record↔Settings row reflows
     smoothly. On a phone the pill is tiny relative to the viewport
     and that 0.4s reads as a sluggish smear — the user is waiting to
     see the count. Snap straight to the visible state on mobile.
     Hides still happen instantly via .hidden's max-width:0 + the
     transition reset below. */
  .export-pill-timer { transition: none; }

  /* Record button idle↔recording flip (grey + red dot ↔ red + white
     square) tweens bg + color over 0.15 s on desktop. On mobile the
     tween fires the same frame the encoder spins up — heavy work
     drops the in-flight animation and the swap reads as a jagged
     smear. Snap straight to the target state; the SVG glyph swap is
     already instant (display: none/block) so the whole pill flips
     atomically. Desktop is unchanged. */
  .export-pill-record { transition: none; }

  /* When the sheet is expanded, every fixed-position overlay sitting
     on the canvas area (export pills bottom-center, layers FAB right-
     middle, the optional canvas-upload-btn center) sits BEHIND the
     sheet body. Fade them out and disable interaction so they don't
     compete with the controls underneath. `:has()` because all three
     selectors are SIBLINGS ABOVE .controls in source order — the
     standard ~ selector won't reach backwards. The :has() form is
     supported on iOS 15.4+ / Chrome 105+ / Firefox 121+, well within
     the touch-device baseline this @media block already targets. */
  body:has(.controls.sheet-expanded) .export-pills,
  body:has(.controls.sheet-expanded) .layers-fab,
  body:has(.controls.sheet-expanded) .canvas-upload-btn {
    opacity: 0;
    pointer-events: none;
  }

  /* Touch-canceled iframe — kills mobile Safari's pinch-zoom and
     two-finger pan on the canvas. The artboard is fit-to-area; no
     zoom or pan is intended. */
  .frame-group iframe { touch-action: none; }

  /* ── Hide the controls-panel skeleton during transitions ──────────── */
  /* The skeleton was sized for desktop's right-side sidebar (navigator
     dropdown + section bars). On mobile the navigator is hidden
     entirely and the sheet is collapsed during the page transition,
     so the skeleton renders a "ghost dropdown" above the controls
     that the user never actually sees in the real UI. Suppress it —
     the canvas-area skeleton still covers everything visible above
     the sheet on mobile. */
  body:has(.stage.transitioning) .controls-skeleton { display: none; }

  /* ── Stepper +/- tap feedback on mobile ─────────────────────────── */
  /* Desktop steppers scale the glyph 1.4× on hover via `@media
     (hover: hover)` and dip to 0.94 on press. Mobile has no hover,
     so the user only saw the 0.94 dip on tap — nothing told them
     the press registered. Override the :active rule here to use the
     SAME scale-up (1.4) the desktop hover does; release transitions
     back to 1× via the existing `transition: transform 0.15s ease`
     on .ctrl-stepper-glyph. Net effect is the desired "scale up
     and back down" pulse on every tap. */
  .ctrl-stepper-zone:active .ctrl-stepper-glyph {
    transform: scale(1.4);
  }

  /* Shrink the canvas-area's breathing-room padding on mobile.
     Desktop reserves 80 / 100 px gutters around the frame for
     drag-handles + size pill + symmetric whitespace; on a phone
     those reservations crop the frame way too aggressively. 24 px
     is the calibrated middle ground — enough breathing room that
     the frame doesn't crowd the bottom sheet visually while still
     leaving most of the viewport for the frame itself.
     fitToCanvasArea reads padding via getComputedStyle at runtime,
     so the values propagate into the fit math (padX = padY = 48). */
  .canvas-area.ratio-contained,
  .canvas-area.image-contained {
    padding: 24px;
  }

  /* Canvas upload button — center its anchor in the area ABOVE the
     sheet, not viewport center, so it isn't half-behind the sheet
     handle. translate Y compensates for the sheet's collapsed
     occlusion. */
  .canvas-upload-btn {
    top: calc(50% - var(--sheet-collapsed-h) / 2);
  }
  .canvas-upload-btn:not(.suppress-hover):hover {
    transform: translate(-50%, -50%) scale(1.1);
  }
  .canvas-upload-btn:active { transform: translate(-50%, -50%) scale(0.94); }
  .canvas-upload-btn:not(.suppress-hover):hover:active { transform: translate(-50%, -50%) scale(0.94); }

  /* (Removed mobile-only `.layer-row.selected .layer-row-remove` —
     the desktop rule above now covers both surfaces.) */

  /* ── Layers FAB — inside the .export-pills cluster ──────────────── */
  /* mobile-sheet.js re-parents #layersBtn into #exportPills on mobile
     so the Capture / Record / Layers trio centers as one flex cluster
     (the existing .export-pills `translateX(-50%)` handles centering
     and naturally accommodates the timer pill's width during
     recording). Drop the fixed positioning the desktop rule set —
     we're now a flow child of .export-pills. Override the desktop
     translateY(-50%) baseline transform too. */
  .layers-fab {
    position: static;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    transform: none;
    /* .export-pills has `pointer-events: none` (its children re-enable
       via .export-pill / .ratio-pill). The Layers FAB doesn't carry
       either class, so re-enable pointer events explicitly — without
       this, taps fall through to the canvas underneath. */
    pointer-events: auto;
  }
  /* Re-declare hover/active so only scale composes (the desktop
     rules included translateY(-50%) which would re-introduce the
     vertical offset). */
  @media (hover: hover) {
    .layers-fab:not(:disabled):not(.suppress-hover):not(.is-live-locked):hover {
      transform: scale(1.1);
    }
  }
  .layers-fab:not(:disabled):not(.suppress-hover):not(.is-live-locked):active {
    transform: scale(0.94);
  }
  .layers-fab[aria-expanded="true"]:not(:active) { transform: scale(1.1); }   /* active = enlarged (2026-11-17) */
  /* (Superseded 2026-11-17 — active keeps the hover size:) No transform on the active state — the desktop
     `.layers-fab[aria-expanded="true"]` rule above already sets the
     bg + color + shadow highlight; we want the highlight WITHOUT
     scale so the user has to hover to see the scale (the cue that
     clicking again will close the popup). The :hover rule above
     handles active+hovered automatically. */

  /* ── Settings popup ─────────────────────────────────────────────── */
  /* Inherits desktop's `width: fit-content` sizing; just enforces a
     max-width clamp so a wider-than-viewport popup can't overflow on
     narrow phones. The horizontal clamp in settings-ui.js#position()
     additionally keeps it inside the viewport gutters. */
  .settings-popup { max-width: calc(100vw - 16px); }

  /* ── Popup z-stacking ───────────────────────────────────────────── */
  /* On mobile the sheet is at z 13 (above the export-pills cluster),
     so popups that open FROM a button inside the sheet (settings) or
     above the canvas (layers list, image-layer settings) need to sit
     above the sheet to be visible. Bump all three to z 14. Desktop
     keeps the inherited base values (13 / 12 / 13) where the sheet
     doesn't exist. */
  .settings-popup,
  .layers-popup,
  .layer-settings-popup {
    z-index: 14;
  }

  /* ── Off-screen recenter pill ───────────────────────────────────── */
  /* The off-screen pill points at the iframe center clamped to the
     viewport edges; on mobile that's a wash because the iframe is
     always centered and visible. Hide it to remove an unnecessary
     overlay. */
  #offscreenPill { display: none; }

  /* FPS counter — kept visible on mobile too (top-left of viewport)
     for parity with desktop. Shift down + right by the iOS safe-area
     insets so the readout clears the notch / dynamic island in
     portrait AND the rounded-corner / camera bezel in landscape. The
     base 10 px padding still applies as the additional inner gutter
     so the digits don't crowd whatever edge they end up flush against. */
  #fpsCounter {
    top: env(safe-area-inset-top, 0);
    left: env(safe-area-inset-left, 0);
  }
}

/* The colour picker's eyedropper (controls.js#ensureEyedropper, user
   2026-11-16): left of the preset swatches, the same size, an icon in
   UI/Text that brightens on hover. */
/* Presets (user 2026-11-16) = the colours in use + some from the canvas —
   up to 20 after the eyedropper, in rows of seven. */
.clr-picker .clr-swatches { order: 2; width: 100%; margin: 0; }
#clr-swatches { display: grid; grid-template-columns: repeat(7, 22px); justify-content: space-between; row-gap: 8px; padding: 0; }
#clr-swatches > div { display: contents; }
#clr-swatches button { width: 22px; height: 22px; margin: 0; }
/* No stroke around the presets (user 2026-11-17; Coloris rings each). */
#clr-swatches button::after { box-shadow: none !important; }
/* Dragged by its background (controls.js PICKER_DRAG_AREAS), like the layer
   popups. */
#clr-picker, #clr-picker .clr-cimble, #clr-picker .clr-cimble-fields, #clr-picker #clr-swatches { cursor: grab; }
#clr-picker.is-dragging, #clr-picker.is-dragging * { cursor: grabbing !important; }
.clr-picker .clr-eyedropper {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  /* Undo the swatch look Coloris gives every button in the row (a colour
     disc ::after, a checkerboard, text pushed out of view). */
  text-indent: 0;
  overflow: visible;
  background-image: none;
  background: var(--color-input);
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.clr-picker .clr-eyedropper::after { content: none; display: none; }
/* Coloris's dark theme paints a transparency checker on every preset button
   (.clr-dark .clr-swatches button) — it outranked the rule above and showed
   as grey diagonal wedges in two corners (user 2026-11-17). */
#clr-picker .clr-eyedropper { background-image: none !important; }
.clr-picker .clr-eyedropper svg { display: block; }
.clr-picker .clr-eyedropper:hover { color: var(--color-off-white); background: var(--color-stroke-hi); transform: scale(1.1); }

/* ───── The Anthropic API key — design 2E (key-menu.js, user 2026-11-17) ─────
   A pill that says the state, a menu with the key itself as an editable
   field, the same field inline (the player's key row, the start screen's
   Generate step). Popup text family: 500. No colour fades. */
.key-pill { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.key-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.key-dot.is-green { background: var(--color-accent-green); }
.key-dot.is-red { background: var(--color-accent-red); }
.key-dot.is-none { background: var(--color-accent-red); }   /* no key = a red dot (user 2026-11-16 — kept over 2E's hollow ring) */
.key-chev { flex: none; }
.key-spin {
  flex: none;
  width: 12px; height: 12px;
  box-sizing: border-box;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  animation: key-spin 0.8s linear infinite;
}
@keyframes key-spin { to { transform: rotate(360deg); } }
.key-menu { width: 300px; display: flex; flex-direction: column; gap: 8px; }
.key-menu-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 2px 4px 0;
  font: 500 12px/16px var(--font-display); letter-spacing: 0.3px;
  color: var(--color-text);
}
.key-menu-state { display: inline-flex; align-items: center; gap: 6px; }
.key-menu-state[data-state="rejected"] { color: var(--color-accent-red); }
.key-field {
  display: flex; align-items: center; gap: 8px;
  /* 48 px, like every single-line field (--ctrl-h; user 2026-11-17 — it was
     40 in the key menu, 44 in the start screen's key step), the text at
     their 16 px inset; the ✓ 12 px from the right. */
  height: var(--ctrl-h);
  box-sizing: border-box;
  padding: 0 12px 0 16px;
  border-radius: 8px;
  background: var(--color-input);
  transition: none;
}
.key-field:hover, .key-field:focus-within { background: var(--color-stroke-hi); }
.key-field.is-error { box-shadow: inset 0 0 0 1px var(--color-accent-red); }
.key-field-input {
  flex: 1 1 auto; min-width: 0;
  margin: 0; padding: 0 0 1px;
  border: 0; outline: none; background: transparent;
  /* The saved key shows in UI/Text; what's typed / pasted (not saved yet)
     in Off-White (user 2026-11-17). */
  color: var(--color-text);
  font: 500 13.6px/17px var(--font-display); letter-spacing: 0.35px;
}
.key-field.is-pending .key-field-input { color: var(--color-off-white); }
.key-field-input::placeholder { color: var(--color-text); }
.key-field-side {
  flex: none; display: inline-flex; align-items: center;
  font: 500 12px/16px var(--font-display); letter-spacing: 0.3px;
  color: var(--color-text);
}
.key-field.is-error .key-field-side { color: var(--color-accent-red); }
.key-ok {
  appearance: none; border: 0; padding: 0;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--color-off-white); color: var(--color-off-black);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.key-ok:hover { transform: scale(1.1); }
.key-ok:active { transform: scale(0.94); }
.key-note {
  padding: 0 4px;
  font: 500 12px/16px var(--font-display); letter-spacing: 0.3px;
  color: var(--color-text);
}
.key-note.is-error { color: var(--color-accent-red); }   /* "That isn't an Anthropic key" etc. in red (user 2026-11-17) */
.key-menu-actions { border-top: 0; padding: 0; border-bottom: 0; gap: 2px; }   /* no divider above the links (user 2026-11-17) */
.key-note[hidden] { display: none; }
.key-menu-row { display: flex; align-items: center; justify-content: flex-start; gap: 10px; }
.key-menu-icon { flex: none; width: 14px; display: inline-flex; justify-content: center; }
/* "Remove key" is an ordinary row: UI/Text, the × too, Off-White on hover
   (user 2026-11-17, later — it was red). */
.key-remove { color: var(--color-text); }
.key-remove[hidden] { display: none; }
/* The player's Iterate header: the model + the key's tail as the pill. */
/* Its box sits like a section's Reset box (user 2026-11-17): top on the
   title's top, 23 px tall (the 17 px line + 3 / 3), its right edge on the
   section's — no negative margins. */
.prompt-model.key-pill {
  appearance: none; border: 0; background: transparent; padding: 3px 6px; margin: 0;
  border-radius: 6px; cursor: pointer;
  font: 500 13.6px/17px var(--font-display); letter-spacing: 0.35px; color: var(--color-text);   /* grey (user 2026-11-17) */
}
.prompt-model.key-pill:hover, .prompt-model.key-pill[aria-expanded="true"] { background: var(--color-stroke-hi); color: var(--color-off-white); }
.prompt-model.key-pill[data-state="rejected"] { color: var(--color-accent-red); }
/* (.prompt-key-block .key-field: --ctrl-h like every key field now.) */


/* ──────────── Quick bars (user 2026-11-17; Figma A1 1112:3024) ────────────
   The selected text / image layer's most-used settings, in the ⋯ badge's
   row to its left (layers.js#syncQuickBar, quick-bar.js). A1 with a 6 px
   inset (user 2026-11-17: "a couple px more padding" — A1 had 4): a 44 px
   Panel bar, 14 px radius (the items' 8 + 6, concentric), Frame Shadow,
   32 px items 4 px apart on UI/Input — Font 164 · Size 64 · Align 92 ·
   Color 32 (no ⋯: the badge stays the way in). Opens / closes like the layer popups, from the end
   next to the badge; its background drags it (grab cursor). */
.layer-quick-bar {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 44px;
  padding: 6px;
  box-sizing: border-box;
  background: var(--color-panel);
  border-radius: 14px;
  box-shadow: var(--shadow-frame);
  pointer-events: auto;
  cursor: grab;
  transform-origin: right center;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.layer-quick-bar.is-right { transform-origin: left center; }
.layer-quick-bar.hidden { opacity: 0; transform: scale(0.95); pointer-events: none; }
.layer-quick-bar.hidden * { pointer-events: none !important; }
:where(.layer-quick-bar) :where(button, input, label, [tabindex], .ctrl-dropdown, .ctrl-input,
  .color-swatch, .layer-segmented) { cursor: auto; }
.qb-slot { position: relative; flex: none; height: 32px; }

/* Font / Sizing: the popup's dropdown at 32 px. It sits in a fixed slot and
   opens DOWNWARD over the canvas — the bar never grows or moves (A2). */
.qb-font { width: 164px; }
.qb-sizing { width: 120px; }
.qb-slot > .ctrl-dropdown {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  min-height: 32px;
  --dd-arrow-hit: 20px;   /* the popup's 24 in its 40 px row, × 0.8 for 32 (whole px) */
}
.qb-slot > .ctrl-dropdown.open { z-index: 2; box-shadow: var(--shadow-frame); }
.qb-slot > .ctrl-dropdown .ctrl-dropdown-header { height: 32px; padding: 0 calc(var(--dd-arrow-hit) + 12px) 0 10px; gap: 8px; }
/* The chevron and its square at the bar's scale (user 2026-11-17: "smaller
   in relation to the dropdown being smaller than in the settings popup"):
   32 / 40 = 0.8 of the popup's — 7.2 × 3.6 chevron, 20 px square 6 px in,
   6 px corners (8 × 0.8). */
.qb-slot > .ctrl-dropdown .ctrl-dropdown-arrow-hit { top: 6px; right: 6px; border-radius: 6px; }
.qb-slot > .ctrl-dropdown .ctrl-dropdown-arrow svg { width: 7.2px; height: 3.6px; }
.qb-slot > .ctrl-dropdown .ctrl-dropdown-text,
.qb-slot > .ctrl-dropdown .ctrl-dropdown-search-input { padding-bottom: 0; font-weight: 500; }
.qb-slot > .ctrl-dropdown .ctrl-dropdown-options-inner { padding: 6px; }
/* The list never runs off the window's bottom (--qb-room: quick-bar.js). */
.qb-slot > .ctrl-dropdown.open .ctrl-dropdown-options { max-height: min(320px, var(--qb-room, 320px)); }

/* Size: the popup's number field, 64 × 32. */
.layer-quick-bar .ctrl-input.qb-size {
  flex: none;
  width: 64px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  align-items: stretch;
}

/* Alignment: the popup's segmented strip, 92 × 32 — three 28 px options,
   2 px apart and from the edges (A1). */
.layer-quick-bar .layer-segmented.qb-align {
  display: flex;
  flex: none;
  gap: 2px;
  width: 92px;
  height: 32px;
  padding: 2px;
}
.layer-quick-bar .layer-segmented.qb-align .layer-segmented-btn { flex: 0 0 28px; height: 28px; }

/* Color: an 18 px colour circle in a 32 px square (A1). */
.qb-color {
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--color-input);
}
.qb-color .color-swatch { width: 18px; height: 18px; }

/* Replace image: the popup's image square at 32. */
.layer-quick-bar .qb-replace { width: 32px; height: 32px; flex: 0 0 32px; }
