/* Sidekick motion lab v2 · design system
 *
 * One dark chrome floating over a full-bleed stage. The stage colour is the
 * preview background and never affects the chrome. Tokens first; every value
 * below is built from them. See DESIGN.md.
 */

:root {
  /* Chrome surfaces */
  --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 on chrome (contrast on #1b1b1d: 15.1, 7.6, 4.6) */
  --text: #ededef;
  --text-2: #a3a3ab;
  --text-3: #7d7d86;
  --on-light: #141416;

  /* Light fill for selected chips and the slider thumb */
  --light: #ececee;
  --thumb: #f2f2f4;

  /* One accent, used for selection, focus and "changed" */
  --accent: #7c9bff;
  --accent-soft: rgba(124, 155, 255, 0.16);
  --accent-ring: rgba(124, 155, 255, 0.55);
  --danger: #ff8a80;

  /* Stage (set by JS from the preset background) */
  --stage: #f4f6fa;
  --stage-ink: #18202f;
  --stage-ink-2: #5d6b84;
  --stage-tile: #ffffff;
  --stage-tile-line: rgba(20, 32, 60, 0.07);

  /* Radii */
  --r-panel: 22px;
  --r-ctl: 12px;
  --r-chip: 8px;
  --r-pill: 999px;

  /* Spacing (4 / 8 rhythm) */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;

  /* Elevation */
  --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);

  /* Motion */
  --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;

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

  /* Geometry */
  --top: 12px;
  --bar-h: 44px;
  --panel-top: calc(var(--top) + var(--bar-h) + 12px);
  --lib-w: 288px;
  --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;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

body.stage-dark {
  --stage-ink: #e9eefb;
  --stage-ink-2: #9db0cf;
  --stage-tile: rgba(255, 255, 255, 0.045);
  --stage-tile-line: rgba(255, 255, 255, 0.07);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--stage);
  color: var(--text);
  transition: background-color var(--t-slow) var(--ease);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
h1, h2, h3, p, figure { margin: 0; }
[hidden] { display: none !important; }
::selection { background: rgba(124, 155, 255, 0.35); color: #fff; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.color-native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-chip); }

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;
}

.booting * { transition: none !important; }

/* ================================================================== */
/* Icons and small buttons                                             */
/* ================================================================== */

.icon { display: inline-flex; width: 16px; height: 16px; flex: none; }
.icon svg { display: block; width: 100%; height: 100%; }

.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), opacity var(--t-fast);
}
.icon-btn:hover:not(:disabled) { background: var(--fill-hover); color: var(--text); }
.icon-btn:active:not(:disabled) { background: var(--fill-active); }
.icon-btn:disabled { opacity: 0.35; }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.icon-btn.small { width: 28px; height: 28px; border-radius: var(--r-chip); }
.icon-reduced .slash { opacity: 0; transition: opacity var(--t-fast); }
[aria-pressed="true"] .icon-reduced .slash { opacity: 1; }

.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);
}
.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-ghost { color: var(--text-2); }
.btn-ghost:hover { color: var(--text); background: var(--fill); }
.btn.wide { width: 100%; }
.link-btn { color: var(--accent); font-size: 12px; font-weight: 500; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.link { color: var(--text-2); font-size: 12px; text-decoration: none; }
.link:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

.select {
  appearance: none;
  height: 32px; padding: 0 30px 0 12px;
  border-radius: 10px;
  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 11px center;
  border: 0;
  color: var(--text);
  font-size: 13px;
  max-width: 100%;
  cursor: pointer;
}
.select:hover { background-color: var(--fill-hover); }
.select option, .select optgroup { background: var(--chrome-raised); color: var(--text); }

.text-field {
  height: 32px; min-width: 0;
  padding: 0 10px;
  border-radius: 10px;
  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::placeholder { color: var(--text-3); }
.text-field:hover { background: var(--fill-hover); }
.text-field:focus { border-color: var(--accent-ring); background: var(--chrome-sunk); outline: none; }

/* ================================================================== */
/* Stage                                                               */
/* ================================================================== */

.stage { position: fixed; inset: 0; overflow: hidden; }
.main-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  transition: transform var(--t-slow) var(--ease);
}
.viewport {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  transition: left var(--t-slow) var(--ease), right var(--t-slow) var(--ease), top var(--t-slow) var(--ease), bottom var(--t-slow) var(--ease);
}
.viewport > * { pointer-events: auto; }
.edit-caption {
  position: absolute; left: 0; right: 0; bottom: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  pointer-events: none;
  color: var(--stage-ink);
  text-align: center;
  transition: opacity var(--t) var(--ease);
}
.edit-caption-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.edit-caption-meta { font-size: 12px; color: var(--stage-ink-2); }
.chrome-hidden .edit-caption { opacity: 0.0; }

/* View bar: small floating toolbar inside In app and Compare */
.view-bar {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--s2);
  padding: 6px;
  background: var(--chrome);
  border: 1px solid var(--hair);
  border-radius: 16px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  max-width: calc(100% - 16px);
  overflow-x: auto;
  scrollbar-width: none;
}
.view-bar::-webkit-scrollbar { display: none; }
.view-bar .select { height: 30px; }
.view-bar .btn { height: 30px; }
.bar-sep { width: 1px; height: 18px; background: var(--hair-strong); margin: 0 2px; flex: none; }
.bar-label { color: var(--text-2); font-size: 12px; padding-left: 8px; }

/* ================================================================== */
/* 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: var(--s3);
  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);
}
.view-pill { position: absolute; left: 50%; transform: translateX(-50%); padding: 0 5px; }
.brand-pill { padding-left: 14px; }
.brand { display: inline-flex; align-items: center; gap: 8px; padding-right: 6px; }
.brand img { width: 18px; height: 18px; border-radius: 4px; filter: saturate(1.2) brightness(1.35); }
.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 0 12px;
  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 .icon { width: 14px; height: 14px; }
.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; }

/* Background swatches */
.bg-swatches { display: inline-flex; align-items: center; gap: 4px; padding: 0 4px; }
.bg-swatch {
  width: 22px; height: 22px;
  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);
  transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.bg-swatch:hover { transform: scale(1.08); }
.bg-swatch[data-bg="light"] { background: #f4f6fa; }
.bg-swatch[data-bg="dark"] { background: #071a31; }
.bg-swatch[data-bg="custom"] { background: conic-gradient(from 210deg, #ff9b8a, #ffd36e, #8be3a8, #7fb6ff, #c49bff, #ff9b8a); }
.bg-swatch[data-bg="custom"].has-custom { background: var(--custom); }
.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), box-shadow var(--t-fast);
}
.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; }
.view-switch { background: transparent; padding: 0; gap: 2px; }
.view-switch .seg { min-height: 32px; padding: 0 14px; border-radius: var(--r-pill); }
.view-switch .seg:hover:not([aria-pressed="true"]) { background: var(--fill); }

/* ================================================================== */
/* Version selector (ui/version.js) · shared by index.html and v3.html */
/* Self-contained: uses only the tokens in :root above.                */
/* ================================================================== */

.version-slot { display: inline-flex; align-items: center; flex: none; }
.version-picker { position: relative; display: inline-flex; }
/* The button: a recessed pill that names the current version, like a quiet select. */
.version-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 8px 0 10px;
  border-radius: var(--r-pill);
  background: var(--fill);
  box-shadow: inset 0 0 0 1px var(--hair);
  color: var(--text);
  font-size: 12.5px; font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.version-btn:hover { background: var(--fill-hover); }
.version-btn[aria-expanded="true"] { background: var(--fill-active); }
.version-btn:focus-visible { outline-offset: 1px; border-radius: var(--r-pill); }
.version-btn-label { font: 600 11.5px/1 var(--font); letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.version-btn-sep { color: var(--text-3); }
.version-btn-chev { display: inline-grid; place-items: center; width: 12px; height: 12px; color: var(--text-3); transition: transform var(--t) var(--ease); }
.version-btn[aria-expanded="true"] .version-btn-chev { transform: rotate(180deg); }
/* The menu: same language as the Panels menu. */
.version-menu {
  position: absolute; z-index: 55;
  top: calc(100% + 14px); left: -8px;
  width: 300px;
  padding: 6px;
  background: var(--chrome-raised);
  border: 1px solid var(--hair-strong);
  border-radius: 16px;
  box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(-6px) scale(0.985);
  transform-origin: top left;
  transition: opacity var(--t-fast) var(--ease), transform var(--t) var(--ease);
}
.version-menu.open { opacity: 1; transform: none; }
.version-item {
  display: grid; grid-template-columns: 16px 1fr auto; align-items: start; gap: 10px;
  width: 100%; padding: 8px 10px 9px 8px;
  border-radius: 10px;
  color: var(--text); text-align: left; text-decoration: none;
  transition: background-color var(--t-fast) var(--ease);
}
.version-item:hover, .version-item:focus-visible { background: var(--fill-hover); outline: none; }
.version-item:focus-visible { box-shadow: inset 0 0 0 1.5px var(--accent-ring); }
.version-item:active { background: var(--fill-active); }
.version-check { display: inline-grid; place-items: center; width: 16px; height: 18px; color: var(--text); }
.version-item[aria-checked="false"] .version-check svg { visibility: hidden; }
.version-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.version-title { display: flex; align-items: baseline; gap: 5px; font-size: 13px; font-weight: 500; line-height: 18px; }
.version-title-label { font: 600 11.5px/18px var(--font); letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.version-title-sep { color: var(--text-3); }
.version-desc { font-size: 12px; line-height: 1.4; color: var(--text-3); }
.version-item[aria-checked="true"] .version-desc { color: var(--text-2); }
.version-kbd { margin-top: 0; height: 18px; min-width: 18px; font-size: 10px; color: var(--text-2); }
/* In the top-left pill: a little air after the brand. */
.brand-pill .version-slot { margin-left: 2px; }

/* ================================================================== */
/* Panels                                                              */
/* ================================================================== */

.panel {
  position: fixed; z-index: 20;
  top: var(--panel-top);
  /* --drag-down: how far a dragged panel sits below its home; it shortens so it still ends inside the viewport. */
  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) var(--ease), translate var(--t-slow) var(--ease), box-shadow var(--t) var(--ease), visibility 0s;
}
.panel-left { left: 12px; width: var(--lib-w); }
.panel-right { right: 12px; width: var(--par-w); }
.panel.collapsed { height: 50px; }

.panel-head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between;
  height: 48px; padding: 0 8px 0 6px;
  cursor: grab;
  touch-action: none;
}
.panel-head .panel-actions { cursor: default; }
.panel-close .icon svg { stroke-width: 1.75; }
.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);
}
.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; 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;
}
.panel-scroll::-webkit-scrollbar { width: 10px; }
.panel-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
.panel-scroll::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.22); }
.panel-scroll::-webkit-scrollbar-track { background: transparent; }

/* Footer: sticky at the bottom of Parameters */
.panel-foot {
  flex: none;
  position: relative;
  border-top: 1px solid var(--hair);
  background: var(--chrome);
  padding: 10px 12px 12px;
}
.foot-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.changed-count {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 10px;
  border-radius: 10px;
  color: var(--text-3);
  font-size: 12px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.changed-count .changed-dot { display: inline-block; opacity: 0.35; background: var(--text-3); }
.changed-count.has-changes { color: var(--text); }
.changed-count.has-changes .changed-dot { opacity: 1; background: var(--accent); }
.changed-count:hover:not(:disabled) { background: var(--fill); }
.changed-count[aria-expanded="true"] { background: var(--fill-hover); }

.changed-list {
  position: absolute; left: 8px; right: 8px; bottom: calc(100% + 6px);
  max-height: 300px; overflow-y: auto;
  padding: 6px;
  background: var(--chrome-raised);
  border: 1px solid var(--hair-strong);
  border-radius: 16px;
  box-shadow: var(--shadow-pop);
  animation: pop-in var(--t) var(--ease);
}
.changed-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 8px; font-size: 11px; color: var(--text-2); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.changed-row {
  width: 100%;
  display: grid; grid-template-columns: 1fr auto 16px; align-items: center; gap: 10px;
  min-height: 34px; padding: 0 8px 0 10px;
  border-radius: 10px;
  text-align: left;
}
.changed-row:hover { background: var(--fill-hover); }
.changed-row .icon { width: 14px; height: 14px; color: var(--text-3); }
.changed-row:hover .icon { color: var(--text); }
.changed-label { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.changed-val { font: 11px var(--mono); color: var(--text-2); white-space: nowrap; }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(4px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* ================================================================== */
/* Sections                                                            */
/* ================================================================== */

.section + .section { border-top: 1px solid var(--hair); }
.section-head { display: flex; align-items: center; padding: 0 8px; }
.section-toggle {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 8px;
  border-radius: 10px;
  text-align: left;
}
.section-title {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color var(--t-fast);
}
.section-meta {
  margin-left: auto;
  font-size: 12px; color: var(--text-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.section-toggle .icon { width: 14px; height: 14px; color: var(--text-3); transition: transform var(--t) var(--ease), color var(--t-fast); 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; color: var(--text-3); margin: -2px 0 12px; }
.empty-note { font-size: 12px; color: var(--text-3); line-height: 1.5; margin: 4px 0 8px; }

/* ================================================================== */
/* Controls                                                            */
/* ================================================================== */

.ctl { position: relative; }
.ctl + .ctl { margin-top: 14px; }
.ctl-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); 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 > .ctl-head .changed-dot,
.ctl.changed > .ctl-label .changed-dot { opacity: 1; transform: none; }

/* Value chip */
.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;
  transition: background-color var(--t-fast);
  cursor: text;
}
.chip-value:hover { background: var(--fill-hover); }
.chip-unit { color: var(--text-3); font-size: 11px; }
.chip-unit:empty { display: none; }
.chip-input {
  width: 84px;
  border: 1px solid var(--accent-ring);
  background: var(--chrome-sunk);
  text-align: right;
  outline: none;
}

/* Slider: tall rounded track, light pill thumb, subtle fill */
.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-slider.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);
  min-width: 0;
  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), width var(--t-fast) var(--ease);
}
.slider-track:hover .slider-thumb, .ctl-slider.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-slider.changed .slider-default { opacity: 0.9; }
.slider-track:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-ctl); }

/* Toggle */
.ctl-toggle { display: flex; align-items: center; justify-content: space-between; min-height: 32px; }
.ctl-toggle .ctl-label { cursor: pointer; }
.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); }

/* Segmented control row */
.ctl-segmented { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ctl-segmented > .ctl-label { flex: none; }
.ctl-segmented > .segmented { flex: 0 1 auto; }
.ctl-segmented.stack { flex-direction: column; align-items: stretch; }
.ctl > .segmented, .section-inner > .segmented { display: flex; width: 100%; }
.section-inner > .segmented + .easing-editor { margin-top: 12px; }

/* Colour */
.ctl-color { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }
.color-field { display: flex; align-items: center; gap: 0; 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 {
  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);
}
.swatch:hover { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4); }
.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; }

/* Number field (seed) */
.ctl-number { display: flex; align-items: center; justify-content: space-between; min-height: 32px; }
.ctl-number-right { display: inline-flex; align-items: center; gap: 4px; }

/* Easing graph */
.easing-editor { position: relative; margin: 0 0 4px; }
.easing-graph {
  display: block; width: 100%; height: auto;
  border-radius: var(--r-ctl);
  background: var(--chrome-sunk);
  box-shadow: inset 0 0 0 1px var(--hair);
  touch-action: none;
}
.eg-grid { stroke: rgba(255, 255, 255, 0.06); stroke-width: 1; fill: none; }
.eg-linear { stroke: rgba(255, 255, 255, 0.12); stroke-width: 1; stroke-dasharray: 3 4; fill: none; }
.eg-curve { stroke: var(--text); stroke-width: 2; fill: none; stroke-linecap: round; }
.eg-tangents { stroke: var(--accent); stroke-width: 1.25; fill: none; opacity: 0.8; }
.eg-end { fill: var(--text-2); }
.eg-handle { fill: var(--chrome); stroke: var(--accent); stroke-width: 2; cursor: grab; transition: r var(--t-fast); }
.eg-handle:hover, .eg-handle:focus-visible { r: 7.5; fill: var(--accent); outline: none; }
.eg-handle:active { cursor: grabbing; }
.easing-readout { margin-top: 8px; font: 11px var(--mono); color: var(--text-3); text-align: center; }

/* ================================================================== */
/* Library                                                             */
/* ================================================================== */

.state-list { display: flex; flex-direction: column; margin: 0 -8px; }
.state-group {
  padding: 8px 10px 2px;
  font-size: 11px; color: var(--text-3);
}
.state-group:first-child { padding-top: 0; }
.state-row {
  display: flex; align-items: center; gap: 10px;
  height: 28px; padding: 0 10px;
  border-radius: 9px;
  color: var(--text-2);
  text-align: left;
  transition: background-color var(--t-fast), color var(--t-fast);
}
.state-row:hover { background: var(--fill); color: var(--text); }
.state-row[aria-pressed="true"] { background: var(--fill-hover); color: var(--text); }
.mini-mark { width: 14px; height: 14px; flex: none; fill: currentColor; opacity: 0.55; transition: opacity var(--t-fast), fill var(--t-fast); }
.state-row[aria-pressed="true"] .mini-mark { fill: var(--accent); opacity: 1; }
.state-name { flex: 1; min-width: 0; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.state-count { font: 10px var(--mono); color: var(--text-3); }
.state-kind { font-size: 11px; color: var(--text-3); min-width: 30px; text-align: right; }

.dir-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.dir-band { grid-column: 1 / -1; font-size: 11px; color: var(--text-3); margin: 4px 0 -2px; }
.dir-band:first-child { margin-top: 0; }
.dir-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--stage);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.dir-tile canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.dir-tile:hover { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.dir-tile[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--chrome), 0 0 0 3.5px var(--accent); }
.dir-tile:focus-visible { outline-offset: 3px; border-radius: 10px; }
.dir-level {
  position: absolute; left: 5px; top: 4px;
  font: 600 10px/1 var(--mono);
  color: var(--stage-ink-2);
  opacity: 0.85;
  pointer-events: none;
}
.dir-dot { position: absolute; right: 5px; top: 5px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); opacity: 0; }
.dir-tile.edited .dir-dot { opacity: 1; }
.dir-tile.empty {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--hair);
  border: 0;
}
.dir-tile.empty .dir-level { color: var(--text-3); opacity: 0.6; }

.dir-info { margin-top: 14px; min-height: 92px; }
.dir-info-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dir-info-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.band-chip {
  flex: none;
  height: 20px; padding: 0 8px;
  border-radius: var(--r-pill);
  background: var(--fill);
  font: 500 11px/20px var(--font);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.band-chip.band-wild { color: #ffc58a; background: rgba(255, 170, 90, 0.12); }
.band-chip.band-bold { color: #f2b8ff; background: rgba(230, 150, 255, 0.11); }
.band-chip.band-expressive { color: #a9c0ff; background: var(--accent-soft); }
.dir-info-summary { margin-top: 6px; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.dir-info-meta { margin-top: 6px; font-size: 12px; color: var(--text-3); }

/* Collection switch (Parts | Shapes) at the top of the Library */
.collection-block { padding: 2px 16px 14px; border-bottom: 1px solid var(--hair); }
.collection-caption { font-size: 12px; line-height: 1.45; color: var(--text-3); }
.collection-caption-name { display: block; margin-bottom: 2px; color: var(--text-2); font-weight: 600; }
.dir-empty { grid-column: 1 / -1; margin: 2px 0 4px; }

/* Emotion and physics of a shapes direction: quiet small-caps chips */
.dir-tags, .caption-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.dir-tags { margin-top: 8px; }
.tag {
  height: 20px; padding: 0 8px;
  border-radius: var(--r-pill);
  background: var(--fill);
  font: 500 12px/19px var(--font);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.05em;
  color: var(--text-2);
  white-space: nowrap;
}
.edit-caption-tags { display: flex; justify-content: center; margin-top: 3px; }
.edit-caption-tags:empty { display: none; }
.caption-tags .tag { background: transparent; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--stage-ink-2) 40%, transparent); color: var(--stage-ink-2); }
.saved-coll {
  display: inline-block; vertical-align: 1px;
  margin-right: 6px; padding: 0 5px;
  border-radius: 5px;
  background: var(--fill-hover);
  font: 500 11px/16px var(--font);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.05em;
  color: var(--text-2);
}
.saved-coll.coll-shapes { color: #a9c0ff; background: var(--accent-soft); }
.saved-load:disabled { opacity: 0.5; cursor: default; }

.save-row { display: flex; gap: 6px; }
.save-row .text-field { flex: 1; }
.saved-list { margin: 10px -6px 0; display: flex; flex-direction: column; gap: 2px; }
.saved-list:empty { display: none; }
.saved-item { display: flex; align-items: center; gap: 2px; border-radius: 10px; }
.saved-item:hover { background: var(--fill); }
.saved-load { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 7px 8px; text-align: left; border-radius: 10px; }
.saved-name { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-meta { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-item .icon-btn { opacity: 0; }
.saved-item:hover .icon-btn, .saved-item .icon-btn:focus-visible { opacity: 1; }
.lib-saved-foot { margin-top: 8px; }
#libraryScroll .btn.wide { margin-top: 10px; }

/* ================================================================== */
/* Parameters                                                          */
/* ================================================================== */

.look-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 8px; }
.look-tile { display: flex; flex-direction: column; align-items: stretch; gap: 6px; border-radius: 12px; }
.look-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-ctl);
  background: var(--stage);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: box-shadow var(--t-fast) var(--ease);
}
.look-thumb canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.look-tile:hover .look-thumb { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2); }
.look-tile[aria-pressed="true"] .look-thumb { box-shadow: 0 0 0 2px var(--chrome), 0 0 0 3.5px var(--accent); }
.look-name { font-size: 12px; color: var(--text-2); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color var(--t-fast); }
.look-tile[aria-pressed="true"] .look-name { color: var(--text); font-weight: 500; }
.look-tile:focus-visible { outline-offset: 3px; border-radius: 12px; }

/* ================================================================== */
/* Dock                                                                */
/* ================================================================== */

.dock {
  position: fixed; z-index: 20;
  left: calc(var(--lib-w) + 24px); right: calc(var(--par-w) + 24px); bottom: 12px;
  max-width: 820px; margin: 0 auto;
  padding: 10px 12px 10px;
  background: var(--chrome);
  border: 1px solid var(--hair);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
  container-type: inline-size;
  transition: left var(--t-slow) var(--ease), right var(--t-slow) var(--ease), opacity var(--t) var(--ease), transform var(--t) var(--ease), translate var(--t-slow) var(--ease), box-shadow var(--t) var(--ease), visibility 0s;
}
/* Grip: a quiet handle along the dock's top edge; the only place the dock drags from. */
.dock-grip {
  position: absolute; top: 0; left: 50%;
  width: 64px; height: 11px; margin-left: -32px;
  display: grid; place-items: center;
  border-radius: 0 0 var(--r-chip) var(--r-chip);
  cursor: grab;
  touch-action: none;
}
.dock-grip::before {
  content: ""; width: 28px; height: 3px; border-radius: 3px;
  background: var(--hair-strong);
  transition: background-color var(--t-fast) var(--ease), width var(--t-fast) var(--ease);
}
.dock-grip:hover::before, .dock.dragging .dock-grip::before { background: rgba(255, 255, 255, 0.32); width: 36px; }
.dock-grip:focus-visible { outline-offset: -2px; }
.timeline {
  position: relative;
  height: 26px;
  margin: 0 2px 8px;
  border-radius: var(--r-chip);
  cursor: ew-resize;
  touch-action: none;
}
.timeline-bands { position: absolute; inset: 0; display: flex; gap: 2px; }
.band {
  flex: 1 1 0; min-width: 0;
  display: flex; align-items: center;
  padding: 0 7px;
  background: var(--fill);
  overflow: hidden;
}
.band:first-child { border-radius: var(--r-chip) 3px 3px var(--r-chip); }
.band:last-child { border-radius: 3px var(--r-chip) var(--r-chip) 3px; }
.band:not(:first-child):not(:last-child) { border-radius: 3px; }
.band-active { background: rgba(255, 255, 255, 0.09); }
.band-rest { background: rgba(255, 255, 255, 0.03); }
.band-label { font-size: 10px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); white-space: nowrap; }
.band.tight .band-label { display: none; }
.timeline-head {
  position: absolute; top: -3px; bottom: -3px;
  width: 2px; margin-left: -1px;
  border-radius: 2px;
  background: var(--text);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.timeline-head::before {
  content: ""; position: absolute; left: 50%; top: -1px;
  width: 8px; height: 8px; margin-left: -4px;
  border-radius: 50%;
  background: var(--text);
}
.timeline:hover .band, .timeline.scrubbing .band { filter: brightness(1.25); }
.timeline:focus-visible { outline-offset: 3px; }

.dock-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.dock-group { display: flex; align-items: center; gap: 2px; }
.dock-right { margin-left: auto; }
.play-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; margin: 0 2px;
  border-radius: 50%;
  background: var(--light); color: var(--on-light);
  transition: transform var(--t-fast) var(--ease), background-color var(--t-fast);
}
.play-btn .icon { width: 18px; height: 18px; }
.play-btn:hover { background: #fff; }
.play-btn:active { transform: scale(0.94); }
.play-btn:focus-visible { border-radius: 50%; }
.time-readout {
  min-width: 104px;
  font: 500 12px var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  white-space: nowrap;
}
.speed-btn {
  height: 32px; min-width: 44px; padding: 0 8px;
  border-radius: 10px;
  font: 500 12px var(--mono);
  color: var(--text-2);
}
.speed-btn:hover { background: var(--fill-hover); color: var(--text); }

.size-strip {
  display: flex; align-items: flex-end; gap: 4px;
  padding: 4px 8px 3px;
  margin-left: 4px;
  border-radius: var(--r-ctl);
  background: var(--stage);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.size-cell { display: flex; flex-direction: column; align-items: center; gap: 0; }
.size-cell canvas { display: block; }
.size-label { font: 500 9px/11px var(--mono); color: var(--stage-ink-2); }

@container (max-width: 548px) {
  .size-strip { display: none; }
}
@container (max-width: 640px) {
  .time-readout { min-width: 88px; font-size: 11px; }
  .dock-row { gap: 6px; }
  .speed-btn { min-width: 36px; }
}
@container (max-width: 430px) {
  .time-readout { min-width: 0; font-size: 11px; }
  .dock-group .icon-btn[aria-label="Replay"] { display: none; }
}

/* ================================================================== */
/* In app                                                              */
/* ================================================================== */

/* The device is a 393 × 852 pt iPhone screen at 1 CSS px per point. app.js
   (fitDevice) sets --device-scale ≤ 1 only when the stage is too small. */
.inapp-view {
  position: relative;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  padding: 56px 16px 8px;
  --spring: cubic-bezier(0.2, 0.9, 0.25, 1.1);
  --spring-t: 420ms;
  --fade: cubic-bezier(0.2, 0.7, 0.2, 1);
}
.device-area {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
}
.device-frame { position: relative; flex: none; width: 411px; height: 870px; }
.device-chip {
  flex: none;
  font: 500 11px/20px var(--mono);
  padding: 0 9px;
  border-radius: 10px;
  color: var(--stage-ink-2);
  background: var(--stage-tile, rgba(0, 0, 0, 0.04));
  box-shadow: inset 0 0 0 1px var(--stage-tile-line, rgba(0, 0, 0, 0.06));
  white-space: nowrap;
}

/* Device: 9 px bezel around a 393 × 852 screen, 55 px screen radius. */
.phone {
  position: absolute; left: 50%; top: 50%;
  width: 411px; height: 870px;
  padding: 9px;
  border-radius: 64px;
  background: #0d0f14;
  box-shadow: inset 0 0 0 1.5px #3a3f4b, 0 40px 80px -36px rgba(16, 24, 56, 0.45), 0 2px 10px rgba(16, 24, 56, 0.12);
  transform: translate(-50%, -50%) scale(var(--device-scale, 1));
  transform-origin: center;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-size: 17px;
  --screen: #f1f1f6;
  --ink: #1a1f5c;
  --muted: #5b6b8c;
  --accent-ios: #1a6bff;
  --skel: #dfe0ea;
  --skel-2: #e8e9f1;
  --tile: rgba(255, 255, 255, 0.78);
  --tile-line: rgba(255, 255, 255, 0.9);
  --tray: rgba(255, 255, 255, 0.55);
  --tray-line: rgba(255, 255, 255, 0.95);
  --bar: rgba(255, 255, 255, 0.7);
  --bar-line: rgba(26, 31, 92, 0.08);
  --raised: #fff;
  --status: #0b0d14;
}
.phone-screen {
  position: relative;
  width: 393px; height: 852px;
  border-radius: 55px;
  overflow: hidden;
  background: var(--screen);
  color: var(--ink);
  isolation: isolate;
}
.phone-island {
  position: absolute; z-index: 8; top: 11px; left: 50%;
  width: 126px; height: 37px; margin-left: -63px;
  border-radius: 19px;
  background: #000;
}
.phone-status {
  position: absolute; z-index: 7; top: 0; left: 0; right: 0;
  height: 59px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 30px 0 52px;
  color: var(--status);
}
.status-time { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.status-icons { display: flex; align-items: center; gap: 6px; }
.status-icons svg { display: block; fill: currentColor; }

/* Wireframe content: neutral skeleton blocks only. */
.wireframe { position: absolute; inset: 59px 0 0; padding: 10px 20px 0; transition: filter var(--spring-t) var(--fade); }
.wf-heading { font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.wf-line { display: block; border-radius: 6px; background: var(--skel); }
.wf-xl { height: 26px; border-radius: 9px; }
.wf-xl + .wf-xl { margin-top: 10px; }
.wf-lg { height: 18px; margin-top: 10px; }
.wf-md { height: 12px; }
.wf-sm { height: 9px; margin-top: 8px; background: var(--skel-2); }
.wf-card {
  background: var(--tile);
  border: 1px solid var(--tile-line);
  border-radius: 24px;
  box-shadow: 0 1px 2px rgba(26, 31, 92, 0.04), 0 8px 24px -16px rgba(26, 31, 92, 0.18);
}
.wf-hero { margin-top: 22px; height: 190px; padding: 20px; display: flex; flex-direction: column; }
.wf-hero > .wf-sm { margin-top: 0; }
.wf-bars { margin-top: auto; height: 62px; display: flex; align-items: flex-end; gap: 10px; }
.wf-bars span { flex: 1; border-radius: 6px; background: var(--skel-2); }
.wf-bars span:nth-child(6) { background: var(--skel); }
.wf-pair { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.wf-small { height: 108px; padding: 16px; border-radius: 20px; }
.wf-dot { display: block; width: 28px; height: 28px; border-radius: 9px; background: var(--skel); margin-bottom: 14px; }
.wf-list { margin-top: 18px; }
.wf-row { display: flex; align-items: center; gap: 14px; height: 64px; border-bottom: 1px solid var(--skel-2); }
.wf-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--skel); }
.wf-row-lines { flex: 1; }
.phone-scrim {
  position: absolute; inset: 0; z-index: 3;
  background: rgba(14, 18, 48, 0.2);
  opacity: 0; pointer-events: none;
  transition: opacity 320ms var(--fade);
}
.phone[data-surface="sheet"] .phone-scrim { opacity: 1; }
.phone[data-surface="sheet"] .wireframe { filter: saturate(0.85); }

/* Bottom tray: Sidekick bar above three tabs. */
.phone-tray {
  position: absolute; z-index: 2; left: 0; right: 0; bottom: 0;
  height: 182px;
  border-radius: 44px 44px 0 0;
  background: var(--tray);
  border: 1px solid var(--tray-line);
  border-bottom: 0;
  box-shadow: 0 -10px 34px -14px rgba(26, 31, 92, 0.16);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  backdrop-filter: blur(24px) saturate(1.5);
  transition: height var(--spring-t) var(--spring);
}
.phone[data-surface="card"] .phone-tray { height: 234px; }
.phone-tabs {
  position: absolute; left: 14px; right: 14px; bottom: 34px;
  height: 66px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.phone-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-radius: 22px;
  font-size: 13px; font-weight: 500; letter-spacing: -0.005em;
  color: var(--ink);
}
.phone-tab svg, .surface-icons svg {
  width: 26px; height: 26px;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.phone-tab.is-selected {
  background: var(--raised);
  color: var(--accent-ios);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(26, 31, 92, 0.06), 0 6px 16px -6px rgba(26, 31, 92, 0.16);
}
.home-indicator {
  position: absolute; z-index: 9; left: 50%; bottom: 8px;
  width: 134px; height: 5px; margin-left: -67px;
  border-radius: 3px;
  background: var(--status);
}

/* Adaptive surface: Bar (pill) → Card → Sheet, one element that changes size. */
.adaptive-surface {
  position: absolute; z-index: 4;
  left: 14px; right: 14px; bottom: 110px;
  height: 56px;
  border-radius: 28px;
  background: var(--bar);
  border: 1px solid var(--bar-line);
  box-shadow: 0 1px 2px rgba(26, 31, 92, 0.04);
  overflow: visible;
  transition:
    left var(--spring-t) var(--spring), right var(--spring-t) var(--spring),
    bottom var(--spring-t) var(--spring), height var(--spring-t) var(--spring),
    border-radius var(--spring-t) var(--spring),
    background-color 240ms var(--fade), box-shadow 240ms var(--fade), border-color 240ms var(--fade);
}
.adaptive-surface[data-surface="card"] {
  height: 108px;
  background: var(--raised);
  border-color: var(--tile-line);
  box-shadow: 0 1px 2px rgba(26, 31, 92, 0.05), 0 14px 34px -14px rgba(26, 31, 92, 0.28);
}
.adaptive-surface[data-surface="sheet"] {
  left: 0; right: 0; bottom: 0;
  height: 469px;
  border-radius: 36px 36px 0 0;
  background: var(--raised);
  border-color: var(--tile-line);
  box-shadow: 0 -12px 40px -12px rgba(14, 18, 48, 0.28);
}
.surface-content {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 88px 0 14px;
  transition: padding var(--spring-t) var(--spring);
}
.adaptive-surface[data-surface="card"] .surface-content { padding: 16px 20px 0 18px; }
.adaptive-surface[data-surface="sheet"] .surface-content { padding: 30px 24px 0; }
/* The canvas is twice the mark so motion beyond the 24u box is not clipped. */
.mark-slot { position: relative; flex: none; width: 28px; height: 28px; }
.mark-slot canvas { position: relative; display: block; width: 56px; height: 56px; margin: -14px; }
.mark-slot::before {
  content: ""; position: absolute; left: -6px; top: -6px; width: 40px; height: 40px;
  border-radius: 50%;
  background: #eef2ff;
  opacity: 0;
  transition: opacity 240ms var(--fade);
}
.surface-text { flex: 1; min-width: 0; }
.surface-text strong {
  display: block;
  font-size: 17px; line-height: 28px; font-weight: 400; letter-spacing: -0.01em;
  color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.adaptive-surface:not([data-surface="bar"]) .surface-text strong { color: var(--ink); font-weight: 600; }
.adaptive-surface[data-surface="sheet"] .surface-text strong { font-size: 20px; }
.surface-text p {
  font-size: 15px; line-height: 20px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  max-height: 0; opacity: 0;
  transition: opacity 200ms var(--fade), max-height var(--spring-t) var(--spring);
}
.adaptive-surface[data-surface="card"] .surface-text p { max-height: 40px; opacity: 1; transition-delay: 120ms, 0ms; }
.surface-icons {
  position: absolute; top: 0; right: 18px; height: 54px;
  display: flex; align-items: center; gap: 16px;
  color: var(--muted);
  transition: opacity 180ms var(--fade);
}
.surface-icons svg { width: 24px; height: 24px; }
.adaptive-surface:not([data-surface="bar"]) .surface-icons { opacity: 0; }
.sheet-handle {
  position: absolute; top: 8px; left: 50%;
  width: 36px; height: 5px; margin-left: -18px;
  border-radius: 3px;
  background: rgba(60, 68, 110, 0.28);
  opacity: 0;
  transition: opacity 200ms var(--fade);
}
.sheet-content {
  position: absolute; left: 24px; right: 24px; top: 78px; bottom: 42px;
  display: flex; flex-direction: column;
  font-size: 17px; line-height: 1.45;
  color: var(--muted);
  opacity: 0; visibility: hidden;
  transition: opacity 200ms var(--fade), visibility 0s linear 200ms;
}
.adaptive-surface[data-surface="sheet"] .sheet-handle { opacity: 1; }
.adaptive-surface[data-surface="sheet"] .sheet-content {
  opacity: 1; visibility: visible;
  transition: opacity 260ms var(--fade) 140ms, visibility 0s;
}
.sheet-content button {
  margin-top: auto;
  height: 52px; border-radius: 26px;
  background: #1660e6; color: #fff;
  font-size: 17px; font-weight: 600;
}
.sheet-content button:focus-visible { outline: 2px solid #1660e6; outline-offset: 3px; border-radius: 26px; }

/* Dark screen: deep navy, translucent lighter-navy tray and tiles. */
body.stage-dark .phone {
  background: #05070c;
  box-shadow: inset 0 0 0 1.5px #2a3142, 0 40px 80px -36px rgba(0, 0, 0, 0.75), 0 2px 10px rgba(0, 0, 0, 0.3);
  --screen: #0b1230;
  --ink: #e6ebfa;
  --muted: #b3bfdc;
  --accent-ios: #8db4ff;
  --skel: rgba(170, 190, 255, 0.16);
  --skel-2: rgba(170, 190, 255, 0.09);
  --tile: rgba(64, 82, 150, 0.22);
  --tile-line: rgba(170, 190, 255, 0.1);
  --tray: rgba(40, 54, 112, 0.55);
  --tray-line: rgba(170, 190, 255, 0.14);
  --bar: rgba(120, 140, 220, 0.14);
  --bar-line: rgba(170, 190, 255, 0.14);
  --raised: #28356f;
  --status: #f4f6ff;
}
body.stage-dark .phone-scrim { background: rgba(2, 4, 16, 0.45); }
body.stage-dark .sheet-handle { background: rgba(200, 212, 255, 0.35); }
body.stage-dark .sheet-content button { background: #8db4ff; color: #0b1230; }
body.stage-dark .sheet-content button:focus-visible { outline-color: #8db4ff; }
/* Keep the mark legible without touching its colours: a quiet disc appears
   behind it only when the mark tone and the screen tone are too close. */
body.stage-dark .phone[data-mark-tone="dark"] .mark-slot::before { opacity: 1; background: #e9eeff; }
body:not(.stage-dark) .phone[data-mark-tone="light"] .mark-slot::before { opacity: 1; background: #1a1f5c; }

@media (prefers-reduced-motion: reduce) {
  .phone-tray, .adaptive-surface, .surface-content, .surface-text p,
  .surface-icons, .sheet-handle, .sheet-content, .phone-scrim, .wireframe { transition: none !important; }
}

/* ================================================================== */
/* Compare                                                             */
/* ================================================================== */

.compare-view {
  position: relative;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  padding: 56px 16px 16px;
}
.compare-cards { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.compare-card {
  display: flex; flex-direction: column; min-height: 0;
  border-radius: 20px;
  background: var(--stage-tile);
  box-shadow: inset 0 0 0 1px var(--stage-tile-line);
  overflow: hidden;
}
.compare-card canvas { flex: 1; min-height: 0; width: 100%; display: block; }
.compare-card figcaption {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 16px 14px;
  color: var(--stage-ink);
  font-size: 13px; font-weight: 500;
}
.compare-kicker { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--stage-ink-2); }

/* ================================================================== */
/* Grid mode                                                           */
/* ================================================================== */

.grid-view {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: var(--stage);
  opacity: 0;
  transition: opacity var(--t-slow) var(--ease);
}
.grid-view.shown { opacity: 1; }
.grid-tiles {
  --tile: 160px;
  --gap: 14px;
  display: grid;
  grid-template-columns: repeat(4, var(--tile));
  grid-auto-rows: var(--tile);
  gap: var(--gap);
  margin-top: 8px;
}
.grid-tile {
  position: relative;
  border-radius: 18px;
  background: var(--stage-tile);
  box-shadow: inset 0 0 0 1px var(--stage-tile-line);
  overflow: hidden;
  color: var(--stage-ink);
  text-align: left;
  transition: box-shadow var(--t-fast) var(--ease), transform var(--t) var(--ease);
}
body.stage-light .grid-tile { box-shadow: inset 0 0 0 1px var(--stage-tile-line), 0 1px 2px rgba(20, 32, 60, 0.04); }
.grid-tile canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.grid-tile:hover { box-shadow: inset 0 0 0 1px rgba(124, 155, 255, 0.45); }
.grid-tile.selected { box-shadow: 0 0 0 2px var(--stage), 0 0 0 4px var(--accent); }
body.stage-light .grid-tile.selected { box-shadow: 0 0 0 2px var(--stage), 0 0 0 4px #3d64e0; }
.grid-tile:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--stage), 0 0 0 4px var(--accent); }
.gt-cap {
  position: absolute; left: 12px; right: 12px; top: 10px;
  display: flex; align-items: baseline; gap: 8px;
  pointer-events: none;
}
.gt-level { font: 600 11px var(--mono); color: var(--stage-ink-2); font-variant-numeric: tabular-nums; }
.gt-name { font-size: 13px; font-weight: 500; letter-spacing: -0.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gt-summary {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 26px 12px 10px;
  font-size: 12px; line-height: 1.4;
  color: var(--stage-ink-2);
  background: linear-gradient(to top, var(--stage) 30%, transparent);
  opacity: 0; transform: translateY(6px);
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
  pointer-events: none;
}
body.stage-light .gt-summary { background: linear-gradient(to top, #fff 35%, rgba(255, 255, 255, 0)); }
.grid-tile:hover .gt-summary { opacity: 1; transform: none; }
.grid-tile.empty { box-shadow: inset 0 0 0 1px var(--stage-tile-line); background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.grid-tile.empty .gt-level { opacity: 0.6; }
.gt-empty { font-size: 11px; color: var(--stage-ink-2); opacity: 0.6; }
.gt-emotion { margin-left: auto; flex: none; font-size: 12px; font-variant-caps: all-small-caps; letter-spacing: 0.05em; color: var(--stage-ink-2); }
.gt-emotion-line { display: block; margin-bottom: 2px; font-variant-caps: all-small-caps; letter-spacing: 0.05em; color: var(--stage-ink); }
.grid-tiles.compact .gt-name, .grid-tiles.compact .gt-summary, .grid-tiles.compact .gt-empty, .grid-tiles.compact .gt-emotion { display: none; }
.grid-tiles.compact .gt-cap { left: 8px; top: 6px; }

.grid-label {
  position: fixed; top: 20px; left: 50%;
  transform: translate(-50%, -4px);
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: var(--chrome);
  border: 1px solid var(--hair);
  box-shadow: var(--shadow);
  font-size: 13px; color: var(--text-2);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 400ms var(--ease), transform 400ms var(--ease);
  pointer-events: none;
}
.grid-label.visible { opacity: 1; transform: translate(-50%, 0); transition-duration: var(--t-fast); }
.gl-state { color: var(--text); font-weight: 600; }
.gl-sep { color: var(--text-3); }
.gl-note { color: var(--accent); margin-left: 4px; }
.grid-exit {
  position: fixed; top: 16px; right: 16px;
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 8px 0 14px;
  border-radius: var(--r-pill);
  background: var(--chrome); color: var(--text);
  border: 1px solid var(--hair);
  box-shadow: var(--shadow);
  font-size: 13px; font-weight: 500;
  opacity: 0.82;
  transition: opacity var(--t-fast);
}
.grid-exit:hover, .grid-exit:focus-visible { opacity: 1; }
.grid-exit kbd { height: 20px; font-size: 10px; }
.grid-hint {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 16px;
  font-size: 11px; color: var(--stage-ink-2);
  opacity: 0.55;
  white-space: nowrap;
  transition: opacity var(--t);
}
.grid-hint:hover { opacity: 1; }
.grid-hint kbd { background: transparent; border-color: currentColor; color: inherit; opacity: 0.8; height: 18px; min-width: 18px; font-size: 10px; }

/* ================================================================== */
/* Popover · export sheet                                              */
/* ================================================================== */

.popover {
  position: fixed; z-index: 50;
  top: calc(var(--top) + var(--bar-h) + 8px); right: 12px;
  width: 360px; max-width: calc(100vw - 24px);
  max-height: calc(100dvh - var(--top) - var(--bar-h) - 20px);
  overflow-y: auto;
  padding: 8px;
  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);
  transform-origin: top right;
  transition: opacity var(--t-fast) var(--ease), transform var(--t) var(--ease);
}
.popover.open { opacity: 1; transform: none; }
.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-list { display: flex; flex-direction: column; gap: 2px; }
.export-row {
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 12px;
  min-height: 52px; padding: 8px 12px 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-row:disabled { opacity: 0.5; }
.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 { font-size: 14px; font-weight: 500; }
.export-desc { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.export-ext { font: 11px var(--mono); color: var(--text-3); }
.sheet-options { margin: 6px 4px 0; padding: 12px 8px 4px; border-top: 1px solid var(--hair); display: flex; flex-direction: column; gap: 10px; }
.sheet-options .ctl + .ctl { margin-top: 0; }
.sheet-options .ctl-label { font-size: 13px; }
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 6px; }
.export-status { font-size: 12px; color: var(--text-2); min-height: 1em; }
.export-status.error { color: var(--danger); }

/* ================================================================== */
/* Modal · shortcuts                                                   */
/* ================================================================== */

.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; }

/* ================================================================== */
/* Toast, tooltip, hints                                               */
/* ================================================================== */

.toast {
  position: fixed; z-index: 70;
  left: 50%; top: calc(var(--panel-top) + 4px);
  transform: translate(-50%, -6px);
  max-width: min(460px, calc(100vw - 32px));
  padding: 9px 16px;
  border-radius: var(--r-pill);
  background: var(--chrome-raised);
  border: 1px solid var(--hair-strong);
  box-shadow: var(--shadow-pop);
  font-size: 13px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.view-grid .toast, .chrome-hidden .toast { top: 64px; }

.tooltip {
  position: fixed; z-index: 80;
  display: flex; align-items: center; gap: 8px;
  max-width: 260px;
  padding: 6px 9px;
  border-radius: var(--r-chip);
  background: #0e0e10;
  border: 1px solid var(--hair-strong);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  font-size: 12px; line-height: 1.4; color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.tooltip.visible { opacity: 1; }
.tooltip kbd { height: 18px; min-width: 18px; font-size: 10px; }

.chrome-hint {
  position: fixed; z-index: 15; left: 50%; bottom: 20px;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 12px; color: var(--stage-ink-2);
  opacity: 0; pointer-events: none;
  transition: opacity 500ms var(--ease);
}
.chrome-hint.visible { opacity: 0.85; transition-duration: var(--t); }
.chrome-hint kbd { background: transparent; border-color: currentColor; color: inherit; }

/* ================================================================== */
/* Hidden chrome (\) and grid                                          */
/* ================================================================== */

.chrome-hidden .topbar { opacity: 0; transform: translateY(-10px); pointer-events: none; }
.chrome-hidden .topbar .pill { pointer-events: none; }

/* Closed panels (close button, Panels menu, \): gone from view and from focus order. */
.panel.is-closed, .dock.is-closed {
  opacity: 0; pointer-events: none; visibility: hidden;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease), visibility 0s linear var(--t);
}
.panel-left.is-closed { transform: translateX(-14px); }
.panel-right.is-closed { transform: translateX(14px); }
.dock.is-closed { transform: translateY(14px); }

/* Dragging */
.panel.raised, .dock.raised { z-index: 21; }
.panel.dragging, .dock.dragging {
  transition: opacity var(--t) var(--ease), box-shadow var(--t) var(--ease);
  box-shadow: var(--shadow-pop);
  cursor: grabbing;
}
.panel.dragging .panel-head, .dock.dragging .dock-grip { cursor: grabbing; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.view-grid .topbar, .view-grid .panel, .view-grid .dock { opacity: 0; pointer-events: none; }
.view-grid .topbar .pill { pointer-events: none; }
.view-grid .main-canvas, .view-grid .viewport { visibility: hidden; }

/* ================================================================== */
/* Responsive: drawers at ≤ 900 px                                     */
/* ================================================================== */

.drawer-scrim { position: fixed; inset: 0; z-index: 19; background: rgba(5, 6, 10, 0.3); }

/* Panels menu (top left) */
.panels-menu {
  right: auto; width: 220px;
  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-sep { height: 1px; margin: 5px 6px; background: var(--hair); }
#panelsButton[aria-expanded="true"] { background: var(--fill-active); color: var(--text); }

@media (max-width: 1180px) {
  :root { --lib-w: 264px; --par-w: 300px; }
}

/* The version button gives up its name ("Shapes") before the brand gives up its words. */
@media (max-width: 1080px) {
  .version-btn-sep, .version-btn-name { display: none; }
  .version-btn { padding: 0 7px 0 9px; gap: 4px; }
}
/* Only then do the brand's words step aside (the mark stays). */
@media (max-width: 960px) {
  .brand-name { display: none; }
  .brand { padding-right: 0; }
}

@media (max-width: 900px) {
  :root { --panel-top: calc(var(--top) + var(--bar-h) + 8px); }
  .drawer-btn { display: inline-grid; }
  .brand-name { display: none; }
  .brand { padding-right: 0; }
  .brand-pill { padding-left: 6px; }
  .panel {
    height: calc(100dvh - var(--panel-top) - 12px);
    z-index: 25;
    transition: transform var(--t-slow) var(--ease), opacity var(--t) var(--ease), visibility 0s linear var(--t-slow);
    visibility: hidden;
  }
  .panel-left { transform: translateX(calc(-100% - 24px)); }
  .panel-right { transform: translateX(calc(100% + 24px)); }
  .drawer-library .panel-left, .drawer-params .panel-right { transform: none; visibility: visible; transition-delay: 0s; }
  .panel-title .icon { display: none; }
  .dock { left: 8px; right: 8px; bottom: 8px; max-width: none; }
  /* Drawers and the full-width dock do not drag; stored positions wait for a wide window. */
  .panel, .dock { translate: none !important; --drag-down: 0px !important; }
  .panel-head { cursor: default; }
  .dock-grip { display: none; }
  /* Top bar: the view switch flows between the side pills instead of overlapping them. */
  .view-pill { position: static; transform: none; margin: 0 auto; }
  .view-switch .seg { padding: 0 10px; }
  #historyButtons, .brand-pill .pill-sep:not(.panels-sep), #toolButtons .icon-btn:last-child { display: none; }
}

@media (max-width: 760px) {
  .bg-swatches, .tools-pill .pill-sep { display: none; }
}

@media (max-width: 640px) {
  :root { --top: 8px; --bar-h: 40px; }
  .topbar { left: 8px; right: 8px; gap: 6px; }
  .pill { padding: 0 4px; }
  .topbar { flex-wrap: wrap; height: auto; row-gap: 8px; }
  .view-pill { position: static; transform: none; order: 2; flex: 1 1 100%; justify-content: center; }
  .view-switch { flex: 1; }
  .brand-pill { order: 0; }
  .tools-pill { order: 1; }
  .brand, .brand-pill .pill-sep { display: none; }
  .version-btn { height: 26px; }
  .version-menu { position: fixed; top: calc(var(--top) + var(--bar-h) + 8px); left: 8px; }
  :root { --panel-top: calc(var(--top) + var(--bar-h) * 2 + 16px); }
  #historyButtons { display: none; }
  .view-switch .seg { padding: 0 6px; font-size: 13px; min-height: 30px; }
  .bg-swatches { display: none; }
  .tools-pill .pill-sep { display: none; }
  #toolButtons .icon-btn:last-child { display: none; }
  .export-btn { margin-left: 2px; padding: 0 10px; height: 30px; }
  .export-btn .icon { display: none; }
  .icon-btn { width: 30px; height: 30px; }
  .panel { left: 8px; right: 8px; width: auto; }
  .panel-left, .panel-right { width: auto; }
  .compare-cards { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; gap: 10px; }
  .compare-view, .inapp-view { padding-top: 52px; }
  .view-bar { gap: 4px; padding: 4px; }
  .view-bar .btn-ghost { display: none; }
  .bar-label { display: none; }
  .edit-caption { bottom: 12px; }
  .grid-exit {
  position: fixed; top: 16px; right: 16px;
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 8px 0 14px;
  border-radius: var(--r-pill);
  background: var(--chrome); color: var(--text);
  border: 1px solid var(--hair);
  box-shadow: var(--shadow);
  font-size: 13px; font-weight: 500;
  opacity: 0.6;
  transition: opacity var(--t-fast);
}
.grid-exit:hover, .grid-exit:focus-visible { opacity: 1; }
.grid-exit kbd { height: 20px; font-size: 10px; }
.grid-hint { gap: 10px; font-size: 10px; }
  .grid-hint span:nth-child(n+4) { display: none; }
  .popover { left: 8px; right: 8px; width: auto; }
  .panels-menu { right: auto; width: 220px; }
}

@media (max-width: 380px) {
  .view-switch .seg { padding: 0 7px; }
}

/* ================================================================== */
/* Reduced motion: keep the chrome calm                                */
/* ================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
}
