/* Glaaass · styles.
 *
 * The chrome follows the Sidekick motion lab (experiment 10): dark chrome over
 * a dark field, a pill top bar, draggable and collapsible panels with sections,
 * tall rounded sliders, a Panels menu, option rows in Export, and a shortcut
 * sheet. The stage is a contained "dish" whose rim follows the petri dish in
 * the Unsettled gallery (experiment 1): an outer band with a hairline, a
 * highlight arc on the top-left, an inner well with its own line. Tokens are
 * copied here so this experiment stands alone.
 */

:root {
  --page: #ffffff;
  --chrome: #1b1b1d;
  --chrome-raised: #232326;
  --chrome-sunk: #151517;
  --hair: rgba(255, 255, 255, 0.08);
  --hair-strong: rgba(255, 255, 255, 0.13);
  --fill: rgba(255, 255, 255, 0.055);
  --fill-hover: rgba(255, 255, 255, 0.09);
  --fill-active: rgba(255, 255, 255, 0.13);
  --track-fill: rgba(255, 255, 255, 0.12);

  --text: #ededef;
  --text-2: #a3a3ab;
  --text-3: #7d7d86;
  --on-light: #141416;
  --light: #ececee;
  --thumb: #f2f2f4;

  --accent: #7c9bff;
  --accent-soft: rgba(124, 155, 255, 0.16);
  --accent-ring: rgba(124, 155, 255, 0.55);
  --pass: #7ddc97;
  --pass-soft: rgba(125, 220, 151, 0.13);
  --fail: #ff8a80;
  --fail-soft: rgba(255, 138, 128, 0.13);
  --warn: #ffd27a;
  --warn-soft: rgba(255, 207, 112, 0.14);
  /* The two families of judgement, kept visibly apart. */
  --legi: #9fd4ff;
  --a11y: #d6b8ff;

  --r-panel: 22px;
  --r-dish: 40px;
  --r-well: 31px;
  --dish-pad: 9px;
  --r-ctl: 12px;
  --r-chip: 8px;
  --r-pill: 999px;

  --shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.18), 0 10px 30px -6px rgba(0, 0, 0, 0.32), 0 24px 60px -20px rgba(0, 0, 0, 0.25);
  --shadow-pop: 0 0 0 0.5px rgba(0, 0, 0, 0.4), 0 4px 10px rgba(0, 0, 0, 0.22), 0 24px 64px -12px rgba(0, 0, 0, 0.5);

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.2, 1);
  --t-fast: 140ms;
  --t: 200ms;
  --t-slow: 240ms;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --top: 12px;
  --bar-h: 44px;
  --panel-top: calc(var(--top) + var(--bar-h) + 12px);
  --lib-w: 260px;
  --par-w: 320px;

  color-scheme: dark;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden; color: var(--text);
  background: var(--page);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-chip); }
.booting * { transition: none !important; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none !important; }

kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  font: 500 11px/1 var(--mono);
  color: var(--text);
  background: var(--fill);
  border: 1px solid var(--hair);
  border-bottom-color: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
}

/* ------------------------------------------------------------------ */
/* Icons and buttons                                                   */
/* ------------------------------------------------------------------ */

.icon { display: inline-flex; width: 16px; height: 16px; flex: none; }
.icon svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  color: var(--text-2);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover:not(:disabled) { background: var(--fill-hover); color: var(--text); }
.icon-btn:active:not(:disabled) { background: var(--fill-active); }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.small { width: 28px; height: 28px; border-radius: var(--r-chip); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 10px;
  font-weight: 500; font-size: 13px;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), opacity var(--t-fast);
}
.btn .icon { width: 14px; height: 14px; }
.btn-quiet { background: var(--fill); color: var(--text); }
.btn-quiet:hover { background: var(--fill-hover); }
.btn-quiet:active { background: var(--fill-active); }
.btn-light { background: var(--light); color: var(--on-light); font-weight: 600; border-radius: var(--r-pill); padding: 0 14px; }
.btn-light:hover { background: #fff; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { color: var(--text); background: var(--fill); }

.text-field {
  width: 100%; height: 36px; min-width: 0;
  padding: 0 12px;
  border-radius: var(--r-ctl);
  border: 1px solid transparent;
  background: var(--fill);
  color: var(--text);
  font-size: 13px;
  transition: border-color var(--t-fast), background-color var(--t-fast);
}
.text-field:hover { background: var(--fill-hover); }
.text-field:focus { border-color: var(--accent-ring); background: var(--chrome-sunk); outline: none; }

/* ------------------------------------------------------------------ */
/* The dish: a contained stage                                         */
/* ------------------------------------------------------------------ */

.dish {
  position: fixed; z-index: 1;
  left: 12px; top: 68px; width: 400px; height: 300px;
  border-radius: var(--r-dish);
  background: linear-gradient(180deg, #1e1e22, #18181b);
  border: 1px solid rgba(255, 255, 255, 0.075);
  box-shadow: 0 5px 14px -4px rgba(0, 0, 0, 0.55), 0 30px 60px -30px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: left var(--t-slow) var(--ease), top var(--t-slow) var(--ease), width var(--t-slow) var(--ease), height var(--t-slow) var(--ease);
}
.dish.no-anim { transition: none; }
.dish { transform-origin: 0 0; }
/* Phone size: an iPhone-like screen radius; the rim bar keeps its size while the dish scales. */
body.device-phone { --r-dish: 64px; --r-well: 55px; }
body.device-phone .dish-bar { transform: translate(-50%, 50%) scale(calc(1 / var(--dish-scale, 1))); transform-origin: 50% 50%; max-width: none; }
/* The highlight arc on the rim, top-left, like light on the petri dish's glass. */
.dish::before {
  content: ""; position: absolute; inset: 3px;
  padding: 1.5px;
  border-radius: calc(var(--r-dish) - 4px);
  background: conic-gradient(from 200deg, transparent 0deg, rgba(255, 255, 255, 0.5) 50deg, rgba(255, 255, 255, 0.12) 110deg, transparent 150deg, transparent 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}
.dish-well {
  position: absolute; inset: var(--dish-pad);
  border-radius: var(--r-well);
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 0 0 4px rgba(0, 0, 0, 0.25);
  isolation: isolate;
}
.layer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
body:not(.mode-reference) #glCanvas { visibility: hidden; }

/* The dish's own controls sit on its bottom rim. */
.dish-bar {
  position: absolute; left: 50%; bottom: 0; z-index: 3;
  transform: translate(-50%, 50%);
  display: flex; align-items: center; gap: 2px;
  height: 40px; padding: 0 5px;
  max-width: calc(100% - 48px);
  overflow-x: auto; scrollbar-width: none;
  background: var(--chrome);
  border: 1px solid var(--hair-strong);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.dish-bar::-webkit-scrollbar { display: none; }

.glass {
  position: absolute; left: 0; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  padding: 0 16px;
  text-align: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.glass.dragging { cursor: grabbing; }
.glass:focus-visible { outline: none; }
/* The recipe's focus ring, drawn by app.js around the glass; shown on keyboard focus or when previewed. */
.focus-ring { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; opacity: 0; box-sizing: border-box; }
.glass:focus-visible ~ .focus-ring, body.show-ring .focus-ring { opacity: 1; }
.glass-text {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  letter-spacing: -0.01em;
  pointer-events: none;
}
.measure-box {
  position: absolute; left: 0; top: 0; z-index: 2;
  border: 1.5px dashed rgba(255, 255, 255, 0.9);
  outline: 1.5px dashed rgba(0, 0, 0, 0.7);
  outline-offset: -3px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t) var(--ease);
}
body.show-measure .measure-box { opacity: 1; }
.stage-note {
  position: absolute; left: 50%; top: 12px; z-index: 3;
  transform: translateX(-50%);
  padding: 7px 12px;
  border-radius: var(--r-pill);
  background: var(--chrome);
  border: 1px solid var(--hair);
  box-shadow: var(--shadow);
  color: var(--text-2);
  font-size: 12px;
  white-space: nowrap;
  max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis;
}

/* ------------------------------------------------------------------ */
/* Top bar                                                             */
/* ------------------------------------------------------------------ */

.topbar {
  position: fixed; z-index: 30;
  top: var(--top); left: 12px; right: 12px;
  height: var(--bar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  pointer-events: none;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}
.pill {
  pointer-events: auto;
  display: flex; align-items: center; gap: 2px;
  height: var(--bar-h);
  padding: 0 6px;
  background: var(--chrome);
  border: 1px solid var(--hair);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow);
}
.brand-pill { padding-left: 14px; }
.brand { display: inline-flex; align-items: center; gap: 9px; padding-right: 4px; }
#panelsButton[aria-expanded="true"] { background: var(--fill-active); color: var(--text); }
.brand-mark {
  width: 18px; height: 18px; border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.15) 45%, rgba(255, 255, 255, 0.05) 60%, rgba(255, 255, 255, 0.5)),
    linear-gradient(135deg, #7c9bff, #c49bff 50%, #7ddcd0);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}
.brand-name { font-weight: 600; font-size: 13px; letter-spacing: -0.005em; white-space: nowrap; }
.pill-sep { width: 1px; height: 18px; background: var(--hair-strong); margin: 0 6px; flex: none; }
.pill-group { display: inline-flex; align-items: center; gap: 2px; }
.tools-pill { padding-right: 5px; }

.export-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; margin-left: 6px; padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--light); color: var(--on-light);
  font-weight: 600; font-size: 13px;
  transition: background-color var(--t-fast), transform var(--t-fast) var(--ease);
}
.export-btn:hover { background: #fff; }
.export-btn:active { transform: scale(0.97); }
.export-btn[aria-expanded="true"] { background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.drawer-btn { display: none; }

.bg-swatches { display: inline-flex; align-items: center; gap: 5px; padding: 0 4px; }
.bg-swatch {
  width: 22px; height: 22px; flex: none;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  background-size: cover; background-position: center;
  transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.bg-swatch:hover { transform: scale(1.08); }
.bg-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--chrome), 0 0 0 3.5px var(--text); }
.bg-swatch:focus-visible { outline-offset: 4px; border-radius: 50%; }

/* Segmented */
.segmented {
  display: inline-flex; align-items: stretch; gap: 2px;
  padding: 3px;
  background: var(--fill);
  border-radius: 11px;
}
.seg {
  flex: 1;
  min-height: 28px; padding: 0 12px;
  border-radius: var(--r-chip);
  color: var(--text-2);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg:hover { color: var(--text); }
.seg[aria-pressed="true"] { background: var(--light); color: var(--on-light); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.segmented.small .seg { min-height: 24px; padding: 0 10px; font-size: 12px; }
#modeSwitch { background: transparent; padding: 0; }
#modeSwitch .seg { min-height: 30px; border-radius: var(--r-pill); }
#modeSwitch .seg:hover:not([aria-pressed="true"]) { background: var(--fill); }

/* ------------------------------------------------------------------ */
/* Panels: draggable by the header, title collapses                    */
/* ------------------------------------------------------------------ */

.panel {
  position: fixed; z-index: 20;
  top: var(--panel-top);
  height: max(50px, calc(100dvh - var(--panel-top) - 12px - var(--drag-down, 0px)));
  display: flex; flex-direction: column;
  background: var(--chrome);
  border: 1px solid var(--hair);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: height var(--t-slow) var(--ease-in-out), opacity var(--t) var(--ease), transform var(--t-slow) var(--ease), box-shadow var(--t) var(--ease);
}
.panel.raised { z-index: 22; }
.panel.dragging { transition: none; box-shadow: var(--shadow-pop); }
.panel.moved { box-shadow: var(--shadow-pop); }
.panel-left { left: 12px; width: var(--lib-w); }
.panel-right { right: 12px; width: var(--par-w); }
.panel.collapsed { height: 50px !important; }
.panel.is-off { opacity: 0; pointer-events: none; visibility: hidden; transition: opacity var(--t) var(--ease), visibility 0s linear var(--t); }

.panel-head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  height: 48px; padding: 0 8px 0 6px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.panel-head .panel-actions { cursor: default; }
.panel-title {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 8px 0 10px;
  border-radius: 10px;
  font-size: 14px; font-weight: 600; letter-spacing: -0.005em;
  color: var(--text);
  white-space: nowrap;
  cursor: inherit;
}
.panel-title:hover { background: var(--fill); }
.panel-title .icon { width: 14px; height: 14px; color: var(--text-3); transition: transform var(--t) var(--ease); }
.panel.collapsed .panel-title .icon { transform: rotate(-90deg); }
.panel-actions { display: flex; align-items: center; gap: 2px; }

.panel-body {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  border-top: 1px solid var(--hair);
  transition: opacity var(--t) var(--ease);
}
.panel.collapsed .panel-body { opacity: 0; }
.panel-scroll {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 2px 0 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

/* Panels menu, opened from the logo */
.popover {
  position: fixed; z-index: 50;
  background: var(--chrome-raised);
  border: 1px solid var(--hair-strong);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(-6px) scale(0.985);
  transition: opacity var(--t-fast) var(--ease), transform var(--t) var(--ease);
}
.popover.open { opacity: 1; transform: none; }
.panels-menu { width: 240px; padding: 6px; border-radius: 16px; transform-origin: top left; }
.menu-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 34px; padding: 0 10px 0 8px;
  border-radius: 10px;
  font-size: 13px; color: var(--text); text-align: left;
  transition: background-color var(--t-fast) var(--ease);
}
.menu-item:hover, .menu-item:focus-visible { background: var(--fill-hover); outline: none; }
.menu-item:active { background: var(--fill-active); }
.menu-check { display: inline-grid; place-items: center; width: 16px; height: 16px; color: var(--text); }
.menu-item[aria-checked="false"] .menu-check .icon { visibility: hidden; }
.menu-item[role="menuitem"] { color: var(--text-2); }
.menu-item[role="menuitem"]:hover, .menu-item[role="menuitem"]:focus-visible { color: var(--text); }
.menu-label { flex: 1; }
.menu-kbd { height: 18px; min-width: 18px; font-size: 10px; color: var(--text-2); }
.menu-sep { height: 1px; margin: 5px 6px; background: var(--hair); }
.menu-head { padding: 8px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }

/* Recipes list */
.recipe-list { list-style: none; margin: 0; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.recipe {
  width: 100%;
  display: flex; align-items: flex-start; gap: 11px;
  padding: 8px;
  border-radius: 12px;
  text-align: left;
  color: var(--text-2);
  transition: background-color var(--t-fast) var(--ease);
}
.recipe:hover { background: var(--fill); }
.recipe[aria-pressed="true"] { background: var(--fill-hover); color: var(--text); }
.recipe-thumb {
  flex: none; width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #ff9bb3, #7fb6ff 55%, #ffe08a);
  position: relative; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.recipe-thumb::after {
  content: ""; position: absolute; inset: 7px;
  border-radius: var(--thumb-r, 7px);
  background: var(--thumb-bg, rgba(255, 255, 255, 0.3));
  backdrop-filter: blur(var(--thumb-blur, 4px));
  -webkit-backdrop-filter: blur(var(--thumb-blur, 4px));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}
.recipe[aria-pressed="true"] .recipe-thumb { box-shadow: 0 0 0 2px var(--chrome), 0 0 0 3.5px var(--accent); }
.recipe-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding-top: 1px; }
.recipe-name { font-size: 13.5px; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 7px; }
.recipe-key { margin-left: auto; height: 18px; min-width: 18px; font-size: 10px; color: var(--text-3); opacity: 0; transition: opacity var(--t-fast); }
.recipe:hover .recipe-key, .recipe[aria-pressed="true"] .recipe-key { opacity: 1; }
.recipe:not([aria-pressed="true"]) .recipe-name { color: var(--text-2); }
.recipe:hover .recipe-name { color: var(--text); }
.recipe-summary { font-size: 12px; line-height: 1.45; color: var(--text-3); }
.recipe[aria-pressed="true"] .recipe-summary { color: var(--text-2); }

/* Sections */
.section + .section { border-top: 1px solid var(--hair); }
.section-toggle {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 16px;
  text-align: left;
}
.section-title {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-2);
  transition: color var(--t-fast);
}
.section-toggle .icon { width: 14px; height: 14px; color: var(--text-3); transition: transform var(--t) var(--ease); transform: rotate(-90deg); }
.section.open .section-toggle .icon { transform: none; }
.section-toggle:hover .section-title, .section-toggle:hover .icon { color: var(--text); }
.section-toggle:focus-visible { outline-offset: -2px; }
.section-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--t) var(--ease-in-out); }
.section.open .section-body { grid-template-rows: 1fr; }
.section-inner { min-height: 0; overflow: hidden; padding: 0 16px; opacity: 0; transition: opacity var(--t-fast) var(--ease), padding var(--t) var(--ease-in-out); }
.section.open .section-inner { opacity: 1; padding-bottom: 16px; }
.section-note { font-size: 12px; line-height: 1.45; color: var(--text-3); margin: -2px 0 12px; }

/* Controls */
.ctl { position: relative; }
.ctl + .ctl { margin-top: 14px; }
.ctl-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 24px; margin-bottom: 8px; }
.ctl-label {
  display: inline-flex; align-items: center; gap: 7px; min-width: 0;
  font-size: 15px; font-weight: 450; letter-spacing: -0.01em;
  color: var(--text);
  user-select: none;
  cursor: default;
}
.ctl-label-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.changed-dot { width: 5px; height: 5px; flex: none; border-radius: 50%; background: var(--accent); opacity: 0; transform: scale(0.4); transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.ctl.changed .changed-dot { opacity: 1; transform: none; }
.ctl.changed .ctl-label { cursor: pointer; }

.chip-value, .chip-input {
  display: inline-flex; align-items: baseline; justify-content: flex-end; gap: 3px;
  height: 24px; min-width: 52px; padding: 0 8px;
  border-radius: var(--r-chip);
  background: var(--fill);
  font: 500 12px/24px var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
  cursor: text;
}
.chip-value:hover { background: var(--fill-hover); }
.chip-unit { color: var(--text-3); font-size: 11px; }
.chip-input { width: 84px; border: 1px solid var(--accent-ring); background: var(--chrome-sunk); text-align: right; outline: none; }

.slider-track {
  --pad: 6px;
  --thumb-w: 6px;
  position: relative;
  height: 36px;
  border-radius: var(--r-ctl);
  background: var(--fill);
  cursor: ew-resize;
  touch-action: none;
  transition: background-color var(--t-fast);
}
.slider-track:hover, .ctl.dragging .slider-track { background: var(--fill-hover); }
.slider-fill {
  position: absolute; left: 3px; top: 3px; bottom: 3px;
  width: calc(var(--r) * (100% - 2 * var(--pad)) + var(--pad) - 3px + var(--thumb-w) / 2);
  border-radius: 9px;
  background: var(--track-fill);
  pointer-events: none;
}
.slider-thumb {
  position: absolute; top: 50%;
  left: calc(var(--pad) + var(--r) * (100% - 2 * var(--pad)) - var(--thumb-w) / 2);
  width: var(--thumb-w); height: 20px; margin-top: -10px;
  border-radius: 3px;
  background: var(--thumb);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: height var(--t-fast) var(--ease), margin var(--t-fast) var(--ease);
}
.slider-track:hover .slider-thumb, .ctl.dragging .slider-thumb { height: 24px; margin-top: -12px; }
.slider-default {
  position: absolute; top: 50%;
  left: calc(var(--pad) + var(--d) * (100% - 2 * var(--pad)) - 1px);
  width: 2px; height: 2px; margin-top: -1px;
  border-radius: 50%;
  background: var(--text-3);
  opacity: 0;
  pointer-events: none;
}
.ctl.changed .slider-default { opacity: 0.9; }
.slider-track:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-ctl); }

.ctl-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }
.ctl > .segmented { display: flex; width: 100%; }

.color-field { position: relative; display: flex; align-items: center; height: 36px; padding: 0 4px 0 6px; border-radius: var(--r-ctl); background: var(--fill); }
.color-field:hover { background: var(--fill-hover); }
.color-field:focus-within { box-shadow: 0 0 0 1px var(--accent-ring); }
.swatch { position: relative; width: 24px; height: 24px; flex: none; border-radius: 7px; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16); overflow: hidden; }
.swatch input { position: absolute; inset: -6px; width: 36px; height: 36px; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.hex-field { width: 84px; height: 28px; padding: 0 8px; background: transparent; border: 0; font: 500 12px var(--mono); letter-spacing: 0.02em; color: var(--text); text-transform: uppercase; }
.hex-field:focus { outline: none; }

.switch { position: relative; flex: none; width: 40px; height: 24px; border-radius: var(--r-pill); background: var(--fill-active); transition: background-color var(--t) var(--ease); }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-2); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); transition: transform var(--t) var(--ease), background-color var(--t) var(--ease); }
.switch[aria-checked="true"] { background: var(--light); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(16px); background: var(--chrome); }
.switch:focus-visible { border-radius: var(--r-pill); }
.ctl-toggle .ctl-label { cursor: pointer; font-size: 14px; }
.ctl-toggle kbd { margin-left: auto; margin-right: 10px; height: 18px; min-width: 18px; font-size: 10px; color: var(--text-3); }

/* Visual controls (visuals.js) */
.viz { margin-bottom: 14px; }
.viz-box { position: relative; border-radius: var(--r-ctl); background: var(--chrome-sunk); box-shadow: inset 0 0 0 1px var(--hair); overflow: hidden; touch-action: none; }
.viz-box canvas { display: block; width: 100%; height: 100%; }
.viz-handle {
  position: absolute; left: 0; top: 0; z-index: 1;
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--thumb);
  box-shadow: 0 0 0 3px rgba(124, 155, 255, 0.35), 0 1px 3px rgba(0, 0, 0, 0.5);
  cursor: grab; touch-action: none;
  transition: box-shadow var(--t-fast), transform var(--t-fast) var(--ease);
}
.viz-handle:hover, .viz-handle.dragging { box-shadow: 0 0 0 5px rgba(124, 155, 255, 0.45), 0 1px 3px rgba(0, 0, 0, 0.5); }
.viz-handle.dragging { cursor: grabbing; transform: scale(1.1); }
.viz-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 50%; }
.viz-handle.tall { width: 12px; height: 18px; margin: -9px 0 0 -6px; border-radius: 6px; }
.viz-handle.wide { width: 18px; height: 12px; margin: -6px 0 0 -9px; border-radius: 6px; }
.viz-handle.small { width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; background: var(--accent); }
.viz-handle.sun { width: 16px; height: 16px; margin: -8px 0 0 -8px; background: #ffd678; box-shadow: 0 0 0 3px rgba(255, 214, 120, 0.3), 0 1px 3px rgba(0, 0, 0, 0.5); }
.viz-handle.dot { background: #2a3150; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 1px 4px rgba(0, 0, 0, 0.35); }
.viz-read { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.viz-chip { display: inline-flex; align-items: baseline; gap: 5px; height: 22px; padding: 0 8px; border-radius: 7px; background: var(--fill); font-size: 11.5px; color: var(--text-3); }
.viz-chip b { font: 500 11.5px var(--mono); color: var(--text); font-variant-numeric: tabular-nums; }
.viz-chip.changed b { color: var(--accent); }

/* Mini controls in a labelled row: Content and Accessibility */
.mini { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.mini-label { font-size: 11.5px; color: var(--text-2); display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.mini.changed .mini-label::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.mini.is-off { opacity: 0.4; pointer-events: none; }
.mini .color-field { padding: 0 4px; gap: 6px; }
.mini .hex-field { width: 100%; min-width: 0; padding: 0; font-size: 11px; }
.mini .swatch { width: 22px; height: 22px; border-radius: 6px; }
.mini-select {
  appearance: none; width: 100%; height: 36px; padding: 0 22px 0 10px;
  border: 0; border-radius: var(--r-ctl);
  background: var(--fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='m1 1 4 4 4-4' fill='none' stroke='%23a3a3ab' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 9px center;
  color: var(--text); font-size: 13px; cursor: pointer;
}
.mini-select:hover { background-color: var(--fill-hover); }
.mini-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mini-select option { background: var(--chrome-raised); color: var(--text); }

/* Compact number fields: W / H / R in one row. Drag the letter to scrub. */
.ctl-trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.num-field {
  position: relative;
  display: flex; align-items: center;
  height: 36px; min-width: 0;
  padding: 0 8px 0 0;
  border-radius: var(--r-ctl);
  background: var(--fill);
  transition: background-color var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
}
.num-field:hover { background: var(--fill-hover); }
.num-field:focus-within { box-shadow: 0 0 0 1px var(--accent-ring); background: var(--chrome-sunk); }
.num-field.is-off { opacity: 0.4; pointer-events: none; }
.num-scrub {
  flex: none;
  display: grid; place-items: center;
  width: 28px; height: 100%;
  font: 600 12px var(--font); color: var(--text-3);
  cursor: ew-resize; touch-action: none;
  user-select: none; -webkit-user-select: none;
  border-radius: var(--r-ctl) 0 0 var(--r-ctl);
}
.num-scrub:hover, .num-field.scrubbing .num-scrub { color: var(--text); }
.num-field.changed .num-scrub { color: var(--accent); }
.num-input {
  flex: 1 1 auto; min-width: 0; width: 100%;
  height: 100%; padding: 0;
  background: transparent; border: 0;
  font: 500 13px var(--mono); font-variant-numeric: tabular-nums;
  color: var(--text);
}
.num-input:focus { outline: none; }
.num-unit { flex: none; font-size: 11px; color: var(--text-3); }

/* ------------------------------------------------------------------ */
/* Legibility & accessibility panel                                    */
/* Header: title and two verdicts. Body: summary, details (optional),   */
/* the Make it pass card, then the action bar. Calm by default: marks   */
/* and numbers, no boxes; explanations live in Details and tooltips.    */
/* ------------------------------------------------------------------ */

.panel-bottom {
  left: calc(12px + var(--lib-w) + 12px);
  right: calc(12px + var(--par-w) + 12px);
  top: auto; bottom: 12px;
  height: auto;
  max-width: 900px;
  margin: 0 auto;
}
.panel-bottom.collapsed { height: 50px !important; }
.leg-status { display: inline-flex; gap: 6px; margin-left: 4px; margin-right: auto; min-width: 0; overflow: hidden; }
.leg-body { overflow: hidden; }
.leg-quick { display: none; }
.panel-bottom.collapsed .leg-quick { display: inline-flex; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.status-pill.pass { background: var(--pass-soft); color: var(--pass); }
.status-pill.fail { background: var(--fail-soft); color: var(--fail); }
.status-pill b { font-size: 11px; font-weight: 700; }

/* Summary: one row per family */
.leg-summary { padding: 4px 16px 2px; }
.fam { display: grid; grid-template-columns: 132px minmax(0, 1fr); align-items: center; gap: 12px; min-height: 40px; }
.fam + .fam { border-top: 1px solid var(--hair); }
.fam-name { display: flex; flex-direction: column; gap: 1px; font-size: 12.5px; font-weight: 600; letter-spacing: -0.005em; }
.fam-name span { display: inline-flex; align-items: center; gap: 7px; }
.fam-name span::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: currentColor; }
.fam.legi .fam-name span { color: var(--legi); }
.fam.a11y .fam-name span { color: var(--a11y); }
.fam-name small { font-size: 11px; font-weight: 400; color: var(--text-3); padding-left: 13px; }
.fam-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; }

.stat { display: inline-flex; align-items: baseline; gap: 6px; min-height: 26px; padding: 0; border-radius: 6px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
button.stat { padding: 0 6px; margin: 0 -6px; }
button.stat:hover { background: var(--fill); color: var(--text); }
.stat-mark { width: 12px; text-align: center; font-size: 11px; font-weight: 700; color: var(--text-3); }
.stat.pass .stat-mark { color: var(--pass); }
.stat.fail .stat-mark { color: var(--fail); }
.stat-val { font: 600 13px var(--font); font-variant-numeric: tabular-nums; color: var(--text); letter-spacing: -0.01em; }
.stat.fail .stat-val { color: var(--fail); }
.stat-val small { font-size: 11px; font-weight: 500; color: var(--text-3); margin-left: 1px; }
button.stat .stat-val { color: var(--accent); font-weight: 500; }
button.stat.pass .stat-val, button.stat.fail .stat-val { font-weight: 600; }
button.stat.pass .stat-val { color: var(--text); }
button.stat.fail .stat-val { color: var(--fail); }

/* Action bar: Show details on the left, the two actions on the right */
.leg-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px 10px 8px; border-top: 1px solid var(--hair); }
.leg-bar .spacer { flex: 1; }
.details-btn .icon { width: 12px; height: 12px; transform: rotate(-90deg); transition: transform var(--t) var(--ease); }
.details-btn[aria-expanded="true"] .icon { transform: rotate(0deg); }
.progress { height: 2px; background: var(--fill-active); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 120ms linear; }

/* Details: two quiet columns */
.leg-details {
  max-height: min(380px, calc(100dvh - 330px));
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin;
  border-top: 1px solid var(--hair);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  padding: 14px 16px 16px;
}
.det { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.det-title { display: flex; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 600; margin: 0; }
.det.legi .det-title { color: var(--legi); }
.det.a11y .det-title { color: var(--a11y); }
.det-title small { font-size: 11.5px; font-weight: 400; color: var(--text-3); }
.det-lead { font-size: 12px; line-height: 1.5; color: var(--text-3); }
.det-sub { font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin-top: 6px; }
.kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px 10px; margin: 0; }
.kv dt { font-size: 11px; color: var(--text-3); }
.kv dd { margin: 0 0 2px; font: 600 13px var(--font); font-variant-numeric: tabular-nums; grid-row: 2; }
.det-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.det-table td { padding: 6px 8px 6px 0; border-top: 1px solid var(--hair); vertical-align: middle; }
.det-table tr:first-child td { border-top: 0; }
.det-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; padding-right: 0; padding-left: 8px; }
.det-table td.muted { color: var(--text-3); }
.det-table.quiet td { color: var(--text-3); }
.crit { color: var(--text); }
.det-table.quiet .crit { color: var(--text-2); }
.sc { margin-left: 7px; font: 500 10.5px var(--mono); color: var(--text-3); }
.det-table .link-btn { margin-left: 8px; }
.res { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: var(--r-pill); font-size: 10.5px; font-weight: 600; background: var(--fill-active); color: var(--text-3); }
.res.pass { background: var(--pass-soft); color: var(--pass); }
.res.fail { background: var(--fail-soft); color: var(--fail); }
.minibar { position: relative; display: inline-block; width: 64px; height: 4px; border-radius: 2px; background: var(--fill-active); vertical-align: middle; overflow: hidden; }
.minibar span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--pass); }
.minibar.bad span { background: var(--fail); }
.det-empty { font-size: 12px; color: var(--text-3); }
.link-btn { color: var(--accent); font-size: 12px; font-weight: 500; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.sol-list { display: flex; flex-direction: column; }
.solution { display: flex; align-items: center; gap: 10px; min-height: 36px; border-top: 1px solid var(--hair); }
.solution:first-child { border-top: 0; }
.solution-swatch { width: 24px; height: 24px; flex: none; border-radius: 7px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2); display: grid; place-items: center; font: 700 10.5px var(--font); }
.solution-text { flex: 1; min-width: 0; font-size: 12.5px; }
.solution-text strong { font-weight: 600; }
.solution-text span { color: var(--text-3); font-family: var(--mono); font-size: 11.5px; margin-left: 4px; }

/* Make it pass: the suggestion, directly above the button that made it */
.suggest { margin: 0 10px 2px; padding: 12px 14px; border-radius: 14px; background: var(--chrome-raised); box-shadow: inset 0 0 0 1px var(--hair-strong); display: flex; flex-direction: column; gap: 8px; }
.leg-details:not([hidden]) + .suggest { margin-top: 10px; }
.leg-summary + .suggest { margin-top: 6px; }
.suggest-head { display: flex; align-items: center; gap: 8px; color: var(--text); }
.suggest-head .icon { color: var(--accent); width: 14px; height: 14px; }
.suggest-title { font-size: 13px; font-weight: 600; }
.suggest-rows { display: flex; flex-direction: column; gap: 2px; padding-left: 22px; }
.suggest-row { display: grid; grid-template-columns: 96px auto 14px auto; justify-content: start; align-items: center; gap: 8px; min-height: 24px; font-size: 12.5px; }
.suggest-label { color: var(--text-2); }
.suggest-from { font: 500 12px var(--mono); color: var(--text-3); text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, 0.25); }
.suggest-arrow { color: var(--text-3); text-align: center; }
.suggest-to { font: 600 12px var(--mono); color: var(--text); }
.suggest-note { font-size: 11.5px; line-height: 1.45; color: var(--text-3); padding-left: 22px; }
.suggest-actions { display: flex; gap: 6px; padding-left: 22px; }

/* ------------------------------------------------------------------ */
/* Export sheet: option rows                                           */
/* ------------------------------------------------------------------ */

.export-sheet {
  top: calc(var(--top) + var(--bar-h) + 8px); right: 12px;
  width: 400px; max-width: calc(100vw - 24px);
  max-height: calc(100dvh - var(--top) - var(--bar-h) - 20px);
  overflow-y: auto;
  padding: 8px;
  transform-origin: top right;
}
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 8px 10px 12px; }
.sheet-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.sheet-sub { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.export-group { padding: 8px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.export-list { display: flex; flex-direction: column; gap: 2px; }
.export-row-wrap { position: relative; }
.export-row {
  width: 100%;
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 12px;
  min-height: 52px; padding: 8px 48px 8px 10px;
  border-radius: 14px;
  text-align: left;
  transition: background-color var(--t-fast);
}
.export-row:hover { background: var(--fill-hover); }
.export-row:active { background: var(--fill-active); }
.export-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--fill); color: var(--text-2); }
.export-row:hover .export-icon { color: var(--text); }
.export-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.export-title { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 500; }
.export-desc { font-size: 12px; color: var(--text-3); line-height: 1.35; }
.export-ext { font: 11px var(--mono); color: var(--text-3); }
.export-copy { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); opacity: 0; }
.export-row-wrap:hover .export-copy, .export-copy:focus-visible { opacity: 1; }
.fidelity { display: inline-flex; align-items: center; height: 17px; padding: 0 6px; border-radius: var(--r-pill); font-size: 10px; font-weight: 650; letter-spacing: 0.02em; background: var(--fill-active); color: var(--text-2); }
.fidelity.full { background: var(--pass-soft); color: var(--pass); }
.fidelity.partial { background: var(--warn-soft); color: var(--warn); }
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 6px; border-top: 1px solid var(--hair); margin-top: 6px; }
.export-status { font-size: 12px; color: var(--text-2); min-height: 1em; }
.export-status.error { color: var(--fail); }
@media (hover: none) { .export-copy { opacity: 1; } }

/* ------------------------------------------------------------------ */
/* Shortcut sheet                                                      */
/* ------------------------------------------------------------------ */

.modal-scrim {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(5, 6, 10, 0.42);
  opacity: 0;
  transition: opacity var(--t) var(--ease);
}
.modal-scrim.open { opacity: 1; }
.modal {
  width: 720px; max-width: 100%;
  max-height: calc(100dvh - 32px); overflow-y: auto;
  padding: 10px 14px 16px;
  background: var(--chrome);
  border: 1px solid var(--hair-strong);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-pop);
  transform: translateY(8px) scale(0.99);
  transition: transform var(--t) var(--ease);
}
.modal-scrim.open .modal { transform: none; }
.keys-cols { columns: 2 280px; column-gap: 28px; padding: 4px 10px 0; }
.keys-group { break-inside: avoid; margin-bottom: 18px; }
.keys-group h3 { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin: 0 0 6px; }
.keys-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; border-bottom: 1px solid var(--hair); }
.keys-row:last-child { border-bottom: 0; }
.keys-label { font-size: 13px; color: var(--text-2); }
.keys-keys { display: inline-flex; gap: 4px; flex: none; }
.keys-note { padding: 0 10px; }

/* Version picker (version.js): a recessed pill naming the version, and a small menu. */
.version-slot { display: inline-flex; align-items: center; margin-left: 2px; }
.version-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 7px 0 9px;
  border-radius: var(--r-pill);
  background: var(--fill); box-shadow: inset 0 0 0 1px var(--hair);
  color: var(--text-2); font: 600 11.5px var(--font); letter-spacing: 0.02em;
}
.version-btn:hover, .version-btn[aria-expanded="true"] { background: var(--fill-hover); color: var(--text); }
.version-btn svg { color: var(--text-3); transition: transform var(--t) var(--ease); }
.version-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.version-menu { width: 300px; padding: 6px; border-radius: 16px; transform-origin: top left; }
.version-item { display: grid; grid-template-columns: 16px 1fr; gap: 10px; padding: 8px 10px 9px 8px; border-radius: 10px; color: var(--text); text-decoration: none; }
.version-item:hover, .version-item:focus-visible { background: var(--fill-hover); outline: none; }
.version-check { font-size: 12px; color: var(--text); padding-top: 1px; }
.version-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.version-title { font-size: 13px; }
.version-title b { font-weight: 600; }
.version-note { font-size: 12px; line-height: 1.4; color: var(--text-3); }

/* Toast and hint */
.toast {
  position: fixed; z-index: 70; left: 50%; top: calc(var(--top) + var(--bar-h) + 14px);
  transform: translate(-50%, -6px);
  padding: 8px 14px; border-radius: var(--r-pill);
  background: var(--light); color: var(--on-light);
  font-size: 12.5px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.chrome-hint {
  position: fixed; z-index: 40; left: 50%; bottom: 22px;
  transform: translate(-50%, 6px);
  padding: 7px 12px; border-radius: var(--r-pill);
  background: var(--chrome); border: 1px solid var(--hair); box-shadow: var(--shadow);
  font-size: 12px; color: var(--text-2);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}
.chrome-hint.visible { opacity: 1; transform: translate(-50%, 0); }
.chrome-hint kbd { height: 18px; min-width: 18px; font-size: 10px; }

/* Everything hidden (\): only the dish. */
body.chrome-hidden .topbar { opacity: 0; transform: translateY(-8px); pointer-events: none; }
body.chrome-hidden .topbar .pill { pointer-events: none; }

/* ------------------------------------------------------------------ */
/* Narrow screens: side panels become drawers                          */
/* ------------------------------------------------------------------ */

.drawer-scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, 0.35); }

@media (max-width: 1180px) {
  .panel-left { width: 280px; transform: translateX(calc(-100% - 24px)); z-index: 40; translate: none !important; }
  body.recipes-open .panel-left { transform: none; }
  body.recipes-open .panel-left.is-off { opacity: 1; visibility: visible; pointer-events: auto; }
  #recipesToggle { display: inline-grid; }
  .panel-bottom { left: 12px; }
}
@media (max-width: 860px) {
  .panel-right { width: min(340px, calc(100vw - 24px)); transform: translateX(calc(100% + 24px)); z-index: 40; translate: none !important; }
  body.params-open .panel-right { transform: none; }
  body.params-open .panel-right.is-off { opacity: 1; visibility: visible; pointer-events: auto; }
  #paramsToggle { display: inline-grid; }
  .panel-bottom { right: 12px; translate: none !important; }
  .brand-name { display: none; }
  .leg-details { grid-template-columns: minmax(0, 1fr); }
  .fam { grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 6px 0; }
  .leg-status { display: none; }
  #modeSwitch .seg { padding: 0 8px; }
}
@media (max-width: 520px) {
  .dish-bar .pill-sep:first-of-type + .pill-group { display: none; }
}

/* ------------------------------------------------------------------ */
/* v2 · Parameters: tabs, one open section, ⓘ notes, compact rows      */
/* ------------------------------------------------------------------ */

.param-tabs { flex: none; display: flex; gap: 2px; margin: 8px 10px 4px; padding: 3px; border-radius: 11px; background: var(--fill); }
.param-tab { flex: 1; min-height: 28px; padding: 0 8px; border-radius: var(--r-chip); color: var(--text-2); font-size: 12.5px; font-weight: 500; white-space: nowrap; transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.param-tab:hover { color: var(--text); }
.param-tab[aria-selected="true"] { background: var(--light); color: var(--on-light); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
#params .panel-body { border-top: 1px solid var(--hair); }

.section-head { display: flex; align-items: center; padding-right: 12px; }
.section-head .section-toggle { flex: 1; }
.section-toggle { height: 40px; }
.info-tip {
  position: relative; flex: none;
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--hair-strong);
  font: italic 600 10.5px Georgia, serif; color: var(--text-3);
  cursor: help;
}
.info-tip:hover, .info-tip:focus-visible { color: var(--text); background: var(--fill-hover); }
.info-tip::after {
  content: attr(data-tip);
  position: absolute; right: -4px; top: calc(100% + 8px); z-index: 5;
  width: 240px; padding: 9px 11px;
  border-radius: 10px; background: var(--chrome-raised); box-shadow: var(--shadow-pop), inset 0 0 0 1px var(--hair-strong);
  font: 400 12px/1.45 var(--font); color: var(--text-2); text-align: left;
  opacity: 0; pointer-events: none; transform: translateY(-3px);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.info-tip:hover::after, .info-tip:focus-visible::after { opacity: 1; transform: none; }

/* Compact rows */
#params .section-inner { padding: 0 14px; }
#params .section.open .section-inner { padding-bottom: 14px; }
#params .ctl + .ctl { margin-top: 10px; }
#params .ctl-head { height: 20px; margin-bottom: 6px; }
#params .ctl-label { font-size: 13px; font-weight: 450; letter-spacing: -0.005em; }
#params .slider-track { height: 28px; border-radius: 10px; }
#params .slider-fill { border-radius: 7px; }
#params .slider-thumb { height: 16px; margin-top: -8px; }
#params .slider-track:hover .slider-thumb, #params .ctl.dragging .slider-thumb { height: 20px; margin-top: -10px; }
#params .chip-value { height: 22px; line-height: 22px; font-size: 11.5px; min-width: 46px; }
#params .segmented .seg { min-height: 26px; font-size: 12.5px; }
#params .num-field, #params .color-field, #params .mini-select, #params .text-field { height: 32px; }
#params .ctl-toggle .ctl-label { font-size: 13px; }
#params .viz { margin-bottom: 10px; }

/* ------------------------------------------------------------------ */
/* v2 · Stage guides on the glass                                      */
/* ------------------------------------------------------------------ */

.guides { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; overflow: visible; display: none; }
.guides.on { display: block; }
.g-line { fill: none; stroke: rgba(255, 255, 255, 0.85); stroke-width: 1.25; filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.55)); }
.g-line.dashed { stroke-dasharray: 4 4; }
.g-line.faint { stroke: rgba(255, 255, 255, 0.45); }
.g-line.accent { stroke: #9fb4ff; stroke-width: 2; stroke-linecap: round; }
.g-line.sun { stroke: rgba(255, 214, 120, 0.85); stroke-dasharray: 3 3; }
.g-band { fill: rgba(124, 155, 255, 0.16); stroke: none; }
.g-glow { fill: rgba(255, 214, 120, 0.6); filter: blur(6px); }
.g-handle { pointer-events: all; cursor: grab; fill: #fff; stroke: #2a3150; stroke-width: 1.5; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5)); transition: r var(--t-fast) var(--ease); }
.g-handle:hover, .g-handle.dragging { r: 10; }
.g-handle.dragging { cursor: grabbing; }
.g-handle:focus-visible { outline: none; stroke: var(--accent); stroke-width: 3; }
.g-handle.sun { fill: #ffd678; stroke: #6b4a12; }
.g-handle.bend, .g-handle.edge { fill: #9fb4ff; stroke: #1b2550; }
.g-label { font: 600 11px var(--font); fill: #fff; stroke: rgba(0, 0, 0, 0.65); stroke-width: 3px; paint-order: stroke; pointer-events: none; }

/* v2 · Stage editing: a Done pill on the dish while guides show */
.edit-bar {
  position: absolute; left: 50%; top: 12px; z-index: 4;
  transform: translateX(-50%) scale(calc(1 / var(--dish-scale, 1)));
  transform-origin: 50% 0;
  display: inline-flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 4px 0 14px;
  border-radius: var(--r-pill);
  background: var(--chrome); border: 1px solid var(--hair-strong); box-shadow: var(--shadow);
  font-size: 12.5px; color: var(--text-2); white-space: nowrap;
}
.edit-bar b { color: var(--text); font-weight: 600; }
.edit-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stage-edit-btn { opacity: 0.7; margin-right: 6px; }
.stage-edit-btn:hover { opacity: 1; }
.edit-bar:not([hidden]) ~ .stage-note { top: 58px; }

/* v2 · Focus while editing on the stage: blur the surroundings, quiet the guides */
.focus-blur {
  position: absolute; inset: 0; z-index: 1;
  pointer-events: none;
  opacity: 0;
  /* Blur plus a soft dim; the same mask keeps the glass and its shadow sharp and bright. */
  background: rgba(8, 8, 12, 0.32);
  backdrop-filter: blur(7px) saturate(0.85);
  -webkit-backdrop-filter: blur(7px) saturate(0.85);
  transition: opacity var(--t-slow) var(--ease);
}
body.stage-editing .focus-blur { opacity: 1; }

.guides .g-label { opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.guides g:hover .g-label, .guides g:focus-within .g-label, .guides g.active .g-label { opacity: 1; }
.guides > g { transition: opacity var(--t) var(--ease); }
.guides.has-active > g:not(.active) { opacity: 0.18; }

/* ------------------------------------------------------------------ */
/* v3 · Visual controls: one handle style (panel and stage), tidy values */
/* ------------------------------------------------------------------ */

.viz-box { background: #141417; }
.viz-handle, .viz-handle.sun, .viz-handle.small {
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #f4f4f6;
  box-shadow: 0 0 0 3px rgba(124, 155, 255, 0.38), 0 1px 3px rgba(0, 0, 0, 0.55);
  transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.viz-handle.small { width: 10px; height: 10px; margin: -5px 0 0 -5px; }
.viz-handle:hover, .viz-handle.dragging, .viz-handle.linked { transform: scale(1.2); box-shadow: 0 0 0 4px rgba(124, 155, 255, 0.6), 0 1px 3px rgba(0, 0, 0, 0.55); }
.viz-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.g-handle, .g-handle.sun, .g-handle.bend, .g-handle.edge { fill: #f4f4f6; stroke: rgba(124, 155, 255, 0.75); stroke-width: 3; r: 7; }
.g-handle:hover, .g-handle.dragging, .g-handle.linked { r: 9; stroke: #9fb4ff; }

.viz-read { display: flex; flex-wrap: nowrap; gap: 4px; margin-top: 6px; overflow: hidden; }
.viz-chip { flex: 1 1 0; min-width: 0; display: inline-flex; align-items: baseline; justify-content: space-between; gap: 6px; height: 24px; padding: 0 8px; border-radius: 7px; background: var(--fill); font-size: 11px; color: var(--text-3); white-space: nowrap; cursor: text; }
.viz-chip:hover { background: var(--fill-hover); color: var(--text-2); }
.viz-chip b { font: 500 11.5px var(--mono); color: var(--text); font-variant-numeric: tabular-nums; }
.viz-chip.changed b { color: var(--accent); }
.viz-input { width: 52px; min-width: 0; height: 18px; padding: 0 4px; border: 1px solid var(--accent-ring); border-radius: 5px; background: var(--chrome-sunk); color: var(--text); font: 500 11.5px var(--mono); text-align: right; outline: none; }
