/* FUN60 MAX driver — flat surfaces, hairlines, spring motion. No gradients. */

@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212, U+2215;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ------------------------------------------------------------------ tokens */
:root {
  interpolate-size: allow-keywords;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f0f0f3;
  --surface-3: #e5e5ea;
  --hover: rgba(0, 0, 0, 0.035);
  --press: rgba(0, 0, 0, 0.06);
  --case: #dfe0e5;
  --case-edge: rgba(0, 0, 0, 0.06);
  --case-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 24px 48px -24px rgba(0, 0, 0, 0.28);
  --cap: #ffffff;
  --cap-edge: rgba(0, 0, 0, 0.06);
  --cap-drop: 0 1px 0 rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.06);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #aeaeb2;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #0071e3;
  --accent-ink: #ffffff;
  --accent-soft: rgba(0, 113, 227, 0.11);
  --danger: #e30000;
  --ok: #30b350;
  --warn: #ff9f0a;
  --switch-off: #e3e3e8;
  --thumb: #ffffff;
  --bar: rgba(245, 245, 247, 0.8);
  --hud: rgba(29, 29, 31, 0.92);
  --hud-ink: #f5f5f7;
  --group-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  --pop-shadow: 0 2px 6px rgba(0, 0, 0, 0.06), 0 24px 64px rgba(0, 0, 0, 0.18);

  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --out: cubic-bezier(0.22, 1, 0.36, 1);
  --snap: cubic-bezier(0.2, 0.9, 0.3, 1.25);
  --gutter: 28px;
  --max: 1240px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #3a3a3c;
  --hover: rgba(255, 255, 255, 0.04);
  --press: rgba(255, 255, 255, 0.08);
  --case: #121214;
  --case-edge: rgba(255, 255, 255, 0.07);
  --case-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 30px 60px -30px rgba(0, 0, 0, 0.9);
  --cap: #232325;
  --cap-edge: rgba(255, 255, 255, 0.06);
  --cap-drop: 0 1px 0 rgba(0, 0, 0, 0.7), 0 2px 4px rgba(0, 0, 0, 0.3);
  --text: #f5f5f7;
  --muted: #98989d;
  --faint: #5a5a5f;
  --line: rgba(255, 255, 255, 0.09);
  --accent: #2997ff;
  --accent-soft: rgba(41, 151, 255, 0.17);
  --danger: #ff453a;
  --ok: #30d158;
  --switch-off: #39393d;
  --thumb: #636366;
  --bar: rgba(0, 0, 0, 0.72);
  --hud: rgba(245, 245, 247, 0.94);
  --hud-ink: #1d1d1f;
  --group-shadow: none;
  --pop-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 64px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --surface-3: #3a3a3c;
    --hover: rgba(255, 255, 255, 0.04);
    --press: rgba(255, 255, 255, 0.08);
    --case: #121214;
    --case-edge: rgba(255, 255, 255, 0.07);
    --case-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 30px 60px -30px rgba(0, 0, 0, 0.9);
    --cap: #232325;
    --cap-edge: rgba(255, 255, 255, 0.06);
    --cap-drop: 0 1px 0 rgba(0, 0, 0, 0.7), 0 2px 4px rgba(0, 0, 0, 0.3);
    --text: #f5f5f7;
    --muted: #98989d;
    --faint: #5a5a5f;
    --line: rgba(255, 255, 255, 0.09);
    --accent: #2997ff;
    --accent-soft: rgba(41, 151, 255, 0.17);
    --danger: #ff453a;
    --ok: #30d158;
    --switch-off: #39393d;
    --thumb: #636366;
    --bar: rgba(0, 0, 0, 0.72);
    --hud: rgba(245, 245, 247, 0.94);
    --hud-ink: #1d1d1f;
    --group-shadow: none;
    --pop-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 64px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-feature-settings: "cv11", "ss01", "ss03";
  letter-spacing: -0.009em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 400ms var(--out), color 400ms var(--out);
}
body.busy { cursor: progress; }
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.num, output, .li-value, .stat b, .mono-chip { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.muted { color: var(--muted); margin: 0; }
.center { text-align: center; }
.spacer { flex: 1; }
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  box-shadow: inset 0 -1px 0 var(--line);
  font: 600 12px/1.5 inherit;
  color: var(--text);
  text-align: center;
}

/* ------------------------------------------------------------------ header */
.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 max(var(--gutter), env(safe-area-inset-left));
  background: var(--bar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  view-transition-name: bar;
}
.bar-side { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-side.end { justify-content: flex-end; }
.brand { display: inline-flex; align-items: baseline; gap: 6px; font-size: 17px; letter-spacing: -0.02em; user-select: none; }
.brand b { font-weight: 700; }
.brand span { font-weight: 500; color: var(--muted); }
.bar-center { display: flex; justify-content: center; transition: opacity 400ms var(--out), transform 600ms var(--spring); }
body:not(.ready) .bar-center { opacity: 0; transform: translateY(-4px); pointer-events: none; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  transition: background-color 200ms, color 200ms, transform 300ms var(--spring);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(0.9); }
.icon-btn svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-btn .rays { transform-origin: 12px 12px; transition: transform 600ms var(--spring), opacity 300ms; }
.icon-btn .sun { transition: r 500ms var(--spring), fill 300ms; }
:root[data-theme="dark"] .icon-btn .rays { transform: rotate(90deg) scale(0.4); opacity: 0; }
:root[data-theme="dark"] .icon-btn .sun { fill: currentColor; r: 6px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn .rays { transform: rotate(90deg) scale(0.4); opacity: 0; }
  :root:not([data-theme="light"]) .icon-btn .sun { fill: currentColor; r: 6px; }
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 12px 0 10px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 200ms, opacity 300ms, transform 300ms var(--spring);
  animation: pop-in 500ms var(--spring) both;
}
.pill:hover { background: var(--surface-3); }
.pill:active { transform: scale(0.96); }
.pill.off { opacity: 0.55; }
.bat { position: relative; width: 20px; height: 10px; border: 1.5px solid currentColor; border-radius: 3px; opacity: 0.8; }
.bat::after { content: ""; position: absolute; right: -4px; top: 2px; width: 2px; height: 3px; border-radius: 0 1px 1px 0; background: currentColor; }
.bat > i { position: absolute; inset: 1px; border-radius: 1px; background: var(--ok); transform-origin: left; transform: scaleX(var(--bat, 1)); transition: transform 600ms var(--spring); }

.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; overflow: hidden; opacity: 0; transition: opacity 300ms; }
.progress::after { content: ""; position: absolute; top: 0; bottom: 0; width: 28%; background: var(--accent); border-radius: 2px; animation: indet 1.1s var(--out) infinite; }
body.loading .progress, body.connecting .progress { opacity: 1; }
@keyframes indet { from { transform: translateX(-110%); } to { transform: translateX(380%); } }

/* ------------------------------------------------------------------ stage */
.stage {
  width: 100%;
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter) 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero {
  display: grid;
  grid-template-rows: 1fr;
  width: 100%;
  text-align: center;
  transition: grid-template-rows 700ms var(--spring), opacity 400ms var(--out);
}
.hero-inner { min-height: 0; overflow: hidden; padding: 11vh 0 52px; transition: padding 700ms var(--spring); }
body.ready .hero-inner { padding: 0; }
.hero h1 { margin: 0; font-size: clamp(34px, 5vw, 52px); font-weight: 650; letter-spacing: -0.035em; line-height: 1.06; }
.hero p { margin: 14px auto 30px; max-width: 470px; color: var(--muted); font-size: 18px; letter-spacing: -0.015em; }
.hero-error { color: var(--danger) !important; font-size: 14px !important; margin-top: 16px !important; }
body.ready .hero { grid-template-rows: 0fr; opacity: 0; pointer-events: none; }
.hero-inner > * { transition: transform 800ms var(--spring), opacity 600ms var(--out); }
body:not(.booted) .hero-inner > * { opacity: 0; transform: translateY(14px); }
.hero-inner > :nth-child(2) { transition-delay: 60ms; }
.hero-inner > :nth-child(3) { transition-delay: 120ms; }

/* ------------------------------------------------------------------ keyboard */
.board { width: 100%; padding-top: 36px; transition: padding 700ms var(--spring); }
body:not(.ready) .board { padding-top: 0; }
.case {
  padding: 1.15%;
  border-radius: clamp(14px, 2.3vw, 28px);
  background: var(--case);
  box-shadow: inset 0 0 0 1px var(--case-edge), var(--case-shadow);
  transition: background-color 600ms var(--out), box-shadow 600ms var(--out);
}
body:not(.ready) .case { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }

.kb {
  position: relative;
  width: 100%;
  aspect-ratio: 15 / 5;
  container-type: inline-size;
  view-transition-name: board;
  touch-action: none;
  user-select: none;
}
.key {
  --u: calc(100cqw / 15);
  --g: calc(var(--u) * 0.045);
  position: absolute;
  left: calc(var(--x) * var(--u) + var(--g));
  top: calc(var(--y) * var(--u) + var(--g));
  width: calc(var(--w) * var(--u) - 2 * var(--g));
  height: calc(var(--u) - 2 * var(--g));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(var(--u) * 0.12) calc(var(--u) * 0.15);
  border: 0;
  border-radius: calc(var(--u) * 0.17);
  overflow: hidden;
  background: var(--cap);
  box-shadow: inset 0 0 0 1px var(--cap-edge), var(--cap-drop);
  color: var(--text);
  font-size: max(9px, calc(var(--u) * 0.2));
  font-weight: 500;
  line-height: 1.1;
  text-align: left;
  transition:
    transform 320ms var(--spring),
    background-color 260ms var(--out),
    box-shadow 260ms var(--out),
    color 260ms var(--out),
    opacity 600ms var(--out);
}
.key > span { position: relative; z-index: 1; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: clip; }
.key.long .k-l { font-size: 0.78em; letter-spacing: -0.02em; }
.k-s { font-size: 0.74em; font-weight: 500; color: var(--muted); transition: color 260ms; }
@container (max-width: 560px) { .k-s { display: none; } }
.k-fill {
  position: absolute !important;
  inset: 0;
  z-index: 0 !important;
  background: var(--accent-soft);
  transform-origin: bottom;
  transform: scaleY(var(--f, 0));
  transition: transform 520ms var(--spring);
}
.kb.live .k-fill { background: var(--accent); opacity: 0.5; transition: transform 90ms linear; }
/* depth gauge: a slim track on the right edge of each cap */
.kb.gauge .key::before {
  content: "";
  position: absolute;
  top: calc(var(--u) * 0.16);
  bottom: calc(var(--u) * 0.16);
  right: calc(var(--u) * 0.1);
  width: max(2px, calc(var(--u) * 0.045));
  border-radius: 2px;
  background: var(--line);
}
.kb.gauge .k-fill {
  inset: calc(var(--u) * 0.16) calc(var(--u) * 0.1) auto auto;
  width: max(2px, calc(var(--u) * 0.045));
  height: calc(100% - var(--u) * 0.32);
  border-radius: 2px;
  background: var(--accent);
  transform-origin: top;
}
.kb.gauge .key.mod::after { display: none; }

@media (hover: hover) {
  body.ready .key:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 1px var(--cap-edge), 0 6px 16px rgba(0, 0, 0, 0.1); }
}
.key:active { transform: scale(0.96); transition-duration: 90ms; }
.key.sel { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 calc(var(--u) * 0.05) var(--accent-soft); }
.key.mod::after {
  content: "";
  position: absolute;
  top: calc(var(--u) * 0.12);
  right: calc(var(--u) * 0.12);
  width: calc(var(--u) * 0.075);
  height: calc(var(--u) * 0.075);
  border-radius: 50%;
  background: var(--accent);
  animation: pop-in 420ms var(--snap) both;
}
.key.rt .k-s { color: var(--accent); }
.key.off .k-l { color: var(--faint); }
.key.special .k-s { color: var(--accent); font-weight: 650; }
.key.down { transform: scale(0.93); background: var(--accent); color: var(--accent-ink); transition-duration: 70ms; }
.key.down .k-s { color: var(--accent-ink); }
.key.flash { animation: flash 900ms var(--out); }
@keyframes flash {
  0% { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 0 var(--accent-soft); }
  40% { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 calc(var(--u) * 0.14) var(--accent-soft); }
  100% { box-shadow: inset 0 0 0 1px var(--cap-edge), 0 0 0 calc(var(--u) * 0.2) transparent; }
}
.key.todo .k-l { color: var(--muted); }
.key.done { background: color-mix(in srgb, var(--ok) 20%, var(--cap)); box-shadow: inset 0 0 0 1.5px var(--ok); }

/* lighting: solid per-key tint + LED bloom; .fx drops colour transitions so frames are crisp */
.key.lit {
  background: color-mix(in srgb, var(--kc, transparent) 72%, var(--cap));
  box-shadow: inset 0 0 0 1px var(--cap-edge), 0 0 calc(var(--u) * 0.32) color-mix(in srgb, var(--kc, transparent) 42%, transparent);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}
.kb.fx .key { transition: transform 320ms var(--spring), opacity 600ms var(--out); }
.key.lit.down { background: var(--accent); }

/* connect state: outline caps with a slow wave */
body:not(.ready) .key {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--faint);
  animation: wave 3.2s ease-in-out infinite;
  animation-delay: calc(var(--d) * 70ms);
}
body:not(.ready) .key .k-l { opacity: 0.7; }
@keyframes wave { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
body:not(.booted) .key { transform: translateY(10px) scale(0.97); }
body.booted .key { transition-delay: calc(var(--d) * 14ms); }
body.booted.ready .key { transition-delay: 0ms; }
body.connecting .key { animation-duration: 0.9s; }

/* ------------------------------------------------------------------ strip under the board */
.strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin: 22px 0 28px;
  padding: 0 4px;
  min-height: 40px;
}
.strip-side { display: flex; gap: 28px; min-width: 0; }
.strip-side.end { justify-content: flex-end; text-align: right; }
.stat { display: flex; flex-direction: column-reverse; gap: 1px; min-width: 0; animation: rise 500ms var(--spring) both; }
.strip-side > .stat:nth-child(2) { animation-delay: 40ms; }
.stat b { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; white-space: nowrap; }
.stat span { font-size: 11.5px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.stat.accent b { color: var(--accent); }
.toolbar { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
body:not(.ready) .view { display: none; }
.view { width: 100%; view-transition-name: view; }
.panel { position: relative; width: 100%; }
.panel > * { animation: rise 640ms var(--spring) both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ layout */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.cols > .col:nth-child(2) > * { animation: rise 640ms var(--spring) both; animation-delay: 50ms; }
.inactive { opacity: 0.38; pointer-events: none; filter: saturate(0.4); transition: opacity 360ms var(--out), filter 360ms; }

/* ------------------------------------------------------------------ grouped lists */
.group { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.group-title { margin: 0 16px; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: -0.005em; }
.group-box {
  position: relative;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--group-shadow);
  overflow: hidden;
  transition: opacity 360ms var(--out), filter 360ms;
}
.group-box > *, .mode-box > *, .collapse > * { position: relative; padding: 13px 16px; }
.group-box > .mode-box, .group-box > .collapse { padding: 0; }
.group-box > * + *::before, .mode-box > *::before, .collapse > *::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 1px;
  background: var(--line);
}
.group-box > .mode-box::before, .group-box > .collapse::before { display: none; }
.collapse { overflow: hidden; height: auto; transition: height 460ms var(--spring), opacity 300ms var(--out); }
.collapse.closed { height: 0; opacity: 0; }

.li { display: flex; align-items: center; gap: 16px; min-height: 50px; }
.li.stack { flex-direction: column; align-items: stretch; gap: 10px; }
.li-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.li-label { font-size: 15px; }
.li-sub { font-size: 13px; color: var(--muted); line-height: 1.38; }
.li-sub.help { margin: 0; }
.li-ctrl { display: flex; align-items: center; justify-content: flex-end; flex: none; max-width: 65%; }
.li-value { color: var(--muted); font-size: 14px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li.tap, .li.action { cursor: pointer; transition: background-color 160ms; user-select: none; }
.li.tap:hover, .li.action:hover { background: var(--hover); }
.li.tap:active, .li.action:active { background: var(--press); }
.li.tap::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: -6px;
  border-right: 1.5px solid var(--faint);
  border-top: 1.5px solid var(--faint);
  transform: rotate(45deg);
  flex: none;
}
.li.current .li-label { color: var(--accent); font-weight: 600; }
.li.action .li-label { color: var(--accent); }
.li.action.danger .li-label { color: var(--danger); }
.li.live .li-label { animation: breathe 1.2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.45; } }

/* fields inside lists */
.field { display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field-head > span { font-size: 15px; }
.field-head output { font-size: 14px; font-weight: 600; color: var(--text); }
.field.slider.disabled { opacity: 0.35; pointer-events: none; }
.field.toggle { flex-direction: row; justify-content: space-between; align-items: center; min-height: 50px; padding-top: 8px !important; padding-bottom: 8px !important; }
.group-box > .field.toggle > span { font-size: 15px; }

.callout {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  height: auto;
  transition: height 460ms var(--spring), opacity 300ms var(--out), padding 460ms var(--spring), margin 460ms var(--spring);
}
.callout.closed { height: 0; padding-block: 0; opacity: 0; margin-bottom: -22px; }
.callout-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; animation: breathe 1.6s ease-in-out infinite; }
.skeleton { height: 120px; margin: 13px 16px; border-radius: 12px; background: var(--surface-2); animation: breathe 1.4s ease-in-out infinite; }

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 180ms, color 180ms, transform 280ms var(--spring), opacity 200ms, box-shadow 200ms;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.96); transition-duration: 80ms; }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.btn.large { height: 48px; padding: 0 30px; font-size: 17px; }
.btn.wide { width: 100%; height: 48px; border-radius: 14px; font-size: 15px; font-weight: 600; }
.btn.small { height: 30px; padding: 0 14px; font-size: 13px; }
.btn.quiet { background: transparent; color: var(--accent); }
.btn.quiet:hover { background: var(--accent-soft); }
.btn.danger { background: var(--surface); color: var(--danger); box-shadow: var(--group-shadow); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.btn.icon { width: 30px; height: 30px; padding: 0; font-size: 18px; color: var(--muted); }
.btn.live { background: var(--accent); color: var(--accent-ink); animation: live 1.6s var(--out) infinite; }
.btn.working { pointer-events: none; animation: breathe 0.9s ease-in-out infinite; }
@keyframes live {
  0% { box-shadow: 0 0 0 0 var(--accent-soft); }
  70% { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-row .btn { height: 44px; border-radius: 14px; background: var(--surface); box-shadow: var(--group-shadow); }
.btn-row .btn:hover { background: var(--hover); }

.btn-group { display: inline-flex; padding: 2px; border-radius: 10px; background: var(--surface-2); }
.seg-btn { height: 30px; padding: 0 14px; border: 0; border-radius: 8px; background: none; font-size: 13px; font-weight: 500; transition: background-color 160ms, transform 260ms var(--spring); }
.seg-btn:hover { background: var(--surface-3); }
.seg-btn:active { transform: scale(0.94); }
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 200ms, color 200ms, transform 260ms var(--spring);
}
.chip-btn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); transition: background-color 200ms; }
.chip-btn.on { background: var(--accent-soft); color: var(--accent); }
.chip-btn.on::before { background: var(--accent); animation: breathe 1s ease-in-out infinite; }
.chip-btn:active { transform: scale(0.95); }

.rec { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px 0 12px; border: 0; border-radius: 999px; background: var(--surface-2); font-size: 13px; font-weight: 600; transition: background-color 200ms, color 200ms, transform 260ms var(--spring); }
.rec::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); transition: border-radius 300ms var(--spring); }
.rec.on { background: var(--danger); color: #fff; }
.rec.on::before { background: #fff; border-radius: 2px; animation: breathe 1s ease-in-out infinite; }
.rec:active { transform: scale(0.95); }

/* segmented control with sliding thumb */
.seg {
  position: relative;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 2px;
  border-radius: 10px;
  background: var(--surface-2);
  isolation: isolate;
}
.seg-thumb {
  position: absolute;
  z-index: -1;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc((100% - 4px) / var(--n, 1));
  border-radius: 8px;
  background: var(--thumb);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1), 0 1px 1px rgba(0, 0, 0, 0.04), inset 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform 460ms var(--spring), opacity 200ms;
}
.seg.none .seg-thumb { opacity: 0; }
.seg > button {
  min-width: 0;
  padding: 6px 16px;
  border: 0;
  background: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: opacity 200ms, transform 300ms var(--spring);
}
.seg > button[aria-selected="true"] { font-weight: 600; }
.seg > button:active { transform: scale(0.95); }
.seg.small > button { padding: 5px 10px; font-size: 12.5px; }
.seg.nav > button { padding: 6px 18px; }
.li.stack > .seg, .picker > .seg { width: 100%; }

/* range: solid track + solid fill (no gradients) */
.range { position: relative; height: 24px; display: flex; align-items: center; }
.range::before { content: ""; position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--surface-3); }
.range-fill { position: absolute; left: 0; height: 4px; width: calc(var(--p, 0) * (100% - 22px) + 11px); border-radius: 2px; background: var(--accent); }
.range.tween .range-fill { transition: width 460ms var(--spring); }
.range input { position: relative; width: 100%; height: 24px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; }
.range input::-webkit-slider-runnable-track { height: 24px; background: transparent; }
.range input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0.5px 4px rgba(0, 0, 0, 0.12), 0 6px 13px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  transition: transform 300ms var(--spring);
}
.range input:active::-webkit-slider-thumb { transform: scale(1.12); }
.range input::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0.5px 4px rgba(0, 0, 0, 0.12), 0 6px 13px rgba(0, 0, 0, 0.12); }

/* iOS-style switch */
input[role="switch"] {
  position: relative;
  flex: none;
  width: 48px;
  height: 29px;
  margin: 0;
  border-radius: 15px;
  background: var(--switch-off);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: background-color 300ms var(--out);
}
input[role="switch"]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 25px;
  height: 25px;
  border-radius: 13px;
  background: #ffffff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.06);
  transition: transform 420ms var(--spring), width 260ms var(--spring);
}
input[role="switch"]:active::before { width: 31px; }
input[role="switch"]:checked { background: var(--ok); }
input[role="switch"]:checked::before { transform: translateX(19px); }
input[role="switch"]:checked:active::before { transform: translateX(13px); }

.select, .input {
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: var(--surface-2);
  font-size: 14px;
  outline-offset: 0;
}
.select {
  max-width: 100%;
  padding-right: 30px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238e8e93' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 10px 6px;
  cursor: pointer;
}
.input.num { width: 92px; text-align: right; }
.input.small { width: 70px; height: 28px; padding: 0 8px; font-size: 13px; }
.input.hex { width: 104px; font-family: var(--mono); font-size: 13px; text-transform: uppercase; text-align: center; }
.search {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='7' cy='7' r='5' fill='none' stroke='%238e8e93' stroke-width='1.7'/%3E%3Cpath d='M11 11l3.5 3.5' stroke='%238e8e93' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 12px center / 14px;
  font-size: 14px;
  outline-offset: 0;
}
.search::placeholder { color: var(--muted); }

/* ------------------------------------------------------------------ keymap */
.key-hero { display: flex; align-items: center; gap: 20px; padding: 20px 18px !important; }
.hero-cap {
  display: grid;
  place-items: center;
  min-width: 88px;
  height: 88px;
  padding: 0 18px;
  border-radius: 20px;
  background: var(--cap);
  box-shadow: inset 0 0 0 1px var(--cap-edge), 0 1px 0 rgba(0, 0, 0, 0.06), 0 8px 20px rgba(0, 0, 0, 0.1);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.hero-cap.long { font-size: 19px; }
.hero-cap.pop { animation: cap-pop 560ms var(--snap); }
@keyframes cap-pop { from { transform: translateY(6px) scale(0.9); opacity: 0.3; } to { transform: none; opacity: 1; } }
.key-hero-text { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.hero-name { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.mono-chip { margin-top: 8px; padding: 3px 8px; border-radius: 6px; background: var(--surface-2); font: 500 12px/1.4 var(--mono); color: var(--muted); }

/* picker */
.picker { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.picker-body { display: flex; flex-direction: column; gap: 16px; height: 392px; overflow: auto; padding: 2px 4px 2px 2px; margin: 0 -4px 0 -2px; scrollbar-width: thin; }
.picker-body > * { animation: rise 420ms var(--spring) both; }
.pick-sec { display: flex; flex-direction: column; gap: 8px; }
.label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.caps { display: flex; flex-wrap: wrap; gap: 6px; }
.caps.grid10 { display: grid; grid-template-columns: repeat(10, 1fr); }
.caps.wide { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.cap {
  position: relative;
  min-width: 40px;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: var(--cap);
  box-shadow: inset 0 0 0 1px var(--cap-edge), var(--cap-drop);
  font-size: 13px;
  font-weight: 500;
  transition: transform 260ms var(--spring), background-color 160ms, box-shadow 200ms;
}
.cap:hover { background: var(--surface-2); }
.cap:active { transform: scale(0.93); transition-duration: 70ms; }
.cap.named { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px; text-align: left; }
.cap.named b { min-width: 42px; font-weight: 600; }
.cap.named span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cap.slot { height: 32px; min-width: 64px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 28px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--muted); transition: background-color 200ms, color 200ms, transform 260ms var(--spring); }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chip:active { transform: scale(0.94); }

/* ------------------------------------------------------------------ performance */
.travel-wrap { padding: 16px 12px 10px !important; }
.travel { display: block; width: 100%; height: auto; overflow: visible; }
.travel text { font: 500 11px "Inter", sans-serif; fill: var(--muted); letter-spacing: 0; }
.travel .strong { fill: var(--text); font-weight: 600; font-size: 12px; }
.travel .accent { fill: var(--accent); font-weight: 600; }
.travel .small { font-size: 10.5px; }
.tv-ruler line { stroke: var(--faint); stroke-width: 1; }
.tv-dz { fill: var(--surface-2); }
.tv-act { stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.tv-rel { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; transition: opacity 300ms; }
.tv-rt { stroke: var(--accent); stroke-width: 5; stroke-linecap: round; opacity: 0.85; }
.tv-rt.up { opacity: 0.4; }
.tv-rt-g { transition: opacity 300ms; }
.tv-rail { stroke: var(--line); stroke-width: 2; stroke-linecap: round; }
.tv-plate { fill: var(--surface-3); }
.tv-capbody { fill: var(--cap); stroke: var(--line); stroke-width: 1; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.12)); }
.tv-capdish { fill: var(--surface-2); }
.tv-guide { stroke: var(--accent); stroke-dasharray: 2 3; stroke-width: 1.2; }
.tv-cap, .tv-guide { transition: transform 700ms var(--spring); }
.tv-cap.live, .tv-guide.live { transition: transform 120ms linear; }

.dks { display: grid; grid-template-columns: 72px repeat(4, 1fr); gap: 6px; align-items: center; }
.dks-h { text-align: center; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.dks-c { position: relative; height: 32px; border: 0; border-radius: 8px; background: var(--surface-2); transition: transform 240ms var(--spring), background-color 200ms; }
.dks-c:hover { background: var(--surface-3); }
.dks-c:active { transform: scale(0.92); }
.dks-c::after { content: ""; position: absolute; top: 50%; left: 50%; width: 8px; height: 8px; border-radius: 4px; background: var(--accent); transform: translate(-50%, -50%) scale(0); transition: transform 360ms var(--snap), width 300ms var(--spring); }
.dks-c[data-v="1"]::after { transform: translate(-50%, -50%) scale(1); }
.dks-c[data-v="2"]::after { transform: translate(-50%, -50%) scale(1); width: 50%; }
.dks-c[data-v="3"]::after { transform: translate(-50%, -50%) scale(1); width: 82%; }

/* ------------------------------------------------------------------ lighting */
.stack-lg { display: flex; flex-direction: column; gap: 22px; }
.tiles { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 72px;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  transition: transform 260ms var(--spring), background-color 200ms, box-shadow 220ms, color 200ms;
}
.tile:hover { background: var(--surface-3); }
.tile:active { transform: scale(0.95); }
.tile.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); font-weight: 600; }
.tile-tag { position: absolute; top: 8px; right: 8px; width: 6px; height: 6px; border-radius: 50%; box-shadow: 0 0 0 1.5px currentColor; opacity: 0.5; }
.dots { display: grid; grid-template-columns: repeat(5, 5px); gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 1.5px; background: currentColor; opacity: 0.22; }
.dots.static i { opacity: 0.75; }
.dots.off i { opacity: 0.12; }
.tile:hover .dots:not(.static, .off) i, .tile.on .dots:not(.static, .off) i { animation: dot 1.5s ease-in-out infinite; animation-delay: var(--dl); }
@keyframes dot { 0%, 100% { opacity: 0.18; } 35% { opacity: 1; } }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; transition: opacity 300ms; }
.swatches.disabled { opacity: 0.3; pointer-events: none; }
.swatch { position: relative; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); transition: transform 300ms var(--spring), box-shadow 200ms; }
.swatch:hover { transform: scale(1.1); }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.swatch.none { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); overflow: hidden; }
.swatch.none::after { content: ""; position: absolute; left: 50%; top: 3px; bottom: 3px; width: 1.5px; background: var(--danger); transform: rotate(45deg); }
.swatch.none.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.swatch.custom { -webkit-appearance: none; appearance: none; cursor: pointer; background: none; box-shadow: inset 0 0 0 1.5px var(--line); }
.swatch.custom::-webkit-color-swatch-wrapper { padding: 4px; }
.swatch.custom::-webkit-color-swatch { border: 0; border-radius: 50%; }

/* ------------------------------------------------------------------ macros */
.slots { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.slot-cell {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  border: 0;
  border-radius: 9px;
  background: var(--surface-2);
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  transition: transform 240ms var(--spring), background-color 200ms, color 200ms;
}
.slot-cell:hover { background: var(--surface-3); color: var(--text); }
.slot-cell:active { transform: scale(0.9); }
.slot-cell.used { color: var(--text); font-weight: 600; }
.slot-cell.used::after { content: ""; position: absolute; left: 50%; bottom: 5px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
.slot-cell.on { background: var(--accent); color: var(--accent-ink); }
.slot-cell.on::after { background: var(--accent-ink); }
.editor-head { min-height: 64px; }
.editor-title { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }

.timeline { display: grid; gap: 7px; }
.lane { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 10px; }
.lane-name { font-size: 12px; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-track { position: relative; height: 14px; border-radius: 7px; background: var(--surface-2); }
.lane-track i {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: calc(var(--a) * 100%);
  width: calc(var(--b) * 100%);
  min-width: 6px;
  border-radius: 4px;
  background: var(--accent);
  transform-origin: left;
  animation: bar-in 600ms var(--spring) both;
  animation-delay: calc(var(--n) * 50ms);
}
@keyframes bar-in { from { transform: scaleX(0); opacity: 0; } }
.tl-axis { display: flex; justify-content: space-between; padding-left: 62px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.events { display: flex; flex-direction: column; max-height: 232px; min-height: 64px; margin: -4px -8px; padding: 0; overflow: auto; list-style: none; scrollbar-width: thin; }
.events li { display: grid; grid-template-columns: 22px 1fr auto auto; align-items: center; gap: 10px; min-height: 38px; padding: 0 4px 0 10px; border-radius: 9px; font-size: 14px; animation: rise 360ms var(--spring) both; }
.events li:hover { background: var(--hover); }
.events li.empty { display: block; padding: 22px 10px; text-align: center; color: var(--muted); animation: none; }
.ev-dir { color: var(--accent); font-weight: 700; }
.events li.up .ev-dir { color: var(--faint); }
.ev-delay { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ system */
.device-hero { display: flex; align-items: center; gap: 18px; padding: 20px 18px !important; }
.device-name { font-size: 22px; font-weight: 650; letter-spacing: -0.025em; }
.ring-wrap { position: relative; width: 64px; height: 64px; flex: none; }
.ring { width: 64px; height: 64px; }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 6; }
.ring-fg { fill: none; stroke: var(--ok); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset 1.4s var(--spring); }
.ring-val { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress-fill { display: block; height: 100%; background: var(--ok); transform-origin: left; transform: scaleX(0); transition: transform 500ms var(--spring); }

/* ------------------------------------------------------------------ sheet / toasts / dialog */
.sheet {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 30;
  width: min(720px, calc(100vw - 32px));
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--pop-shadow);
  transform: translateX(-50%);
  animation: sheet-in 560ms var(--spring) both;
}
.sheet.out { animation: sheet-out 220ms var(--out) both; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h3 { margin: 0; font-size: 17px; font-weight: 650; }
@keyframes sheet-in { from { opacity: 0; transform: translate(-50%, 40px) scale(0.98); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes sheet-out { to { opacity: 0; transform: translate(-50%, 24px) scale(0.98); } }

.toasts { position: fixed; left: 0; right: 0; bottom: 24px; z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--hud);
  color: var(--hud-ink);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: toast-in 520ms var(--spring) both;
  transition: opacity 300ms var(--out), transform 400ms var(--spring);
}
.toast.err { background: var(--danger); color: #fff; }
.toast.warn::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--warn); }
.toast.out { opacity: 0; transform: translateY(8px) scale(0.96); }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.92); } to { opacity: 1; transform: none; } }

.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 26px;
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--pop-shadow);
  animation: dlg-in 460ms var(--spring) both;
}
.dialog h3 { margin: 0 0 8px; font-size: 19px; letter-spacing: -0.02em; }
.dialog p { margin: 0 0 22px; color: var(--muted); }
.dialog .row { display: flex; gap: 8px; justify-content: flex-end; }
.dialog .btn.danger { background: var(--danger); color: #fff; box-shadow: none; }
.dialog::backdrop { background: rgba(0, 0, 0, 0.32); backdrop-filter: blur(4px); animation: fade 300ms var(--out) both; }
.dialog.out { animation: dlg-out 150ms var(--out) both; }
@keyframes dlg-in { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes dlg-out { to { opacity: 0; transform: scale(0.97); } }
@keyframes fade { from { opacity: 0; } }

/* ------------------------------------------------------------------ view transitions */
::view-transition-old(view) { animation: vt-out 180ms var(--out) both; height: auto; }
::view-transition-new(view) { animation: vt-in 520ms var(--spring) both; height: auto; }
::view-transition-group(view) { animation-duration: 460ms; animation-timing-function: var(--spring); }
::view-transition-image-pair(view) { overflow: hidden; }
::view-transition-old(board), ::view-transition-new(board) { animation-duration: 260ms; animation-timing-function: var(--out); }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 420ms; animation-timing-function: var(--out); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 860px) {
  :root { --gutter: 16px; }
  .bar { grid-template-columns: auto 1fr auto; height: auto; min-height: 56px; padding-top: 8px; padding-bottom: 8px; row-gap: 8px; }
  .bar-center { grid-column: 1 / -1; grid-row: 2; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  .bar-center .seg { margin: 0 auto; min-width: max-content; }
  body:not(.ready) .bar-center { display: none; }
  .seg > button, .seg.nav > button { padding: 6px 10px; font-size: 12.5px; }
  .seg.small > button { padding: 5px 6px; }
  .cols { grid-template-columns: 1fr; }
  .strip { grid-template-columns: 1fr 1fr; row-gap: 16px; }
  .toolbar { grid-column: 1 / -1; order: -1; }
  .strip-side { gap: 18px; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .slots, .caps.grid10 { grid-template-columns: repeat(5, 1fr); }
  .hero-inner { padding-top: 8vh; }
  .brand span { display: none; }
  .board { padding-top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
  }
}
.unit-input { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.li.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
.li.pair > .field { padding: 0; }
.collapse.closed { min-height: 0; }

/* ------------------------------------------------------------------ 3D board
   The board is a real 3D object: the case tilts back in perspective, the
   case and every keycap have a solid side wall (offset shadow) and a front
   lip, and a press pushes the cap down onto its wall. No images, no WebGL. */
:root {
  --rx: 24deg;
  --ry: 0deg;
  --cap-side: #cdced5;
  --cap-lip: rgba(0, 0, 0, 0.06);
  --case-side: #b8b9c1;
  --case-depth: clamp(8px, 1.3vw, 16px);
}
:root[data-theme="dark"] { --cap-side: #0b0b0d; --cap-lip: rgba(0, 0, 0, 0.4); --case-side: #050506; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --cap-side: #0b0b0d; --cap-lip: rgba(0, 0, 0, 0.4); --case-side: #050506; }
}
.board { perspective: 2600px; perspective-origin: 50% 20%; padding-bottom: calc(var(--case-depth) + 1.6vw); }
.case {
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transform-origin: 50% 55%;
  box-shadow:
    inset 0 0 0 1px var(--case-edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 var(--case-depth) 0 var(--case-side),
    0 calc(var(--case-depth) + 26px) 60px -22px rgba(0, 0, 0, 0.5);
  transition: transform 1100ms var(--spring), background-color 600ms var(--out), box-shadow 600ms var(--out);
  will-change: transform;
}
body:not(.ready) .case { box-shadow: inset 0 0 0 1px var(--line), 0 var(--case-depth) 0 transparent; }

.key {
  --lift: calc(var(--u) * 0.075);
  --skirt: 0 var(--lift) 0 var(--cap-side);
  --drop: 0 calc(var(--lift) + var(--u) * 0.05) calc(var(--u) * 0.14) rgba(0, 0, 0, 0.26);
  box-shadow: inset 0 0 0 1px var(--cap-edge), inset 0 calc(var(--u) * -0.055) 0 var(--cap-lip), var(--skirt), var(--drop);
}
@media (hover: hover) {
  body.ready .key:hover {
    transform: translateY(calc(var(--u) * -0.02));
    box-shadow: inset 0 0 0 1px var(--cap-edge), inset 0 calc(var(--u) * -0.055) 0 var(--cap-lip), 0 calc(var(--lift) + var(--u) * 0.02) 0 var(--cap-side), var(--drop);
  }
}
.key:active, .key.down {
  transform: translateY(calc(var(--lift) * 0.85));
  box-shadow: inset 0 0 0 1px var(--cap-edge), inset 0 calc(var(--u) * -0.03) 0 var(--cap-lip), 0 calc(var(--lift) * 0.15) 0 var(--cap-side), 0 2px 4px rgba(0, 0, 0, 0.2);
  transition-duration: 70ms;
}
.key.sel { box-shadow: inset 0 0 0 1.5px var(--accent), inset 0 calc(var(--u) * -0.055) 0 var(--cap-lip), var(--skirt), 0 0 0 calc(var(--u) * 0.05) var(--accent-soft), var(--drop); }
.key.done { box-shadow: inset 0 0 0 1.5px var(--ok), var(--skirt), var(--drop); }
.key.lit {
  --skirt: 0 var(--lift) 0 color-mix(in srgb, var(--kc, transparent) 45%, var(--cap-side));
  box-shadow:
    inset 0 0 0 1px var(--cap-edge),
    inset 0 calc(var(--u) * -0.055) 0 var(--cap-lip),
    var(--skirt),
    0 0 calc(var(--u) * 0.32) color-mix(in srgb, var(--kc, transparent) 42%, transparent);
}
@keyframes flash {
  0% { box-shadow: inset 0 0 0 1.5px var(--accent), var(--skirt), 0 0 0 0 var(--accent-soft), var(--drop); }
  40% { box-shadow: inset 0 0 0 1.5px var(--accent), var(--skirt), 0 0 0 calc(var(--u) * 0.14) var(--accent-soft), var(--drop); }
  100% { box-shadow: inset 0 0 0 1px var(--cap-edge), var(--skirt), 0 0 0 calc(var(--u) * 0.2) transparent, var(--drop); }
}
@media (max-width: 860px) { :root { --rx: 14deg; } }
@media (prefers-reduced-motion: reduce) { .case { transition: none; } }
@media (hover: hover) {
  body.ready .key.sel:hover { box-shadow: inset 0 0 0 1.5px var(--accent), inset 0 calc(var(--u) * -0.055) 0 var(--cap-lip), var(--skirt), 0 0 0 calc(var(--u) * 0.05) var(--accent-soft), var(--drop); }
  body.ready .key.lit:hover { box-shadow: inset 0 0 0 1px var(--cap-edge), var(--skirt), 0 0 calc(var(--u) * 0.32) color-mix(in srgb, var(--kc, transparent) 42%, transparent); }
}

/* ------------------------------------------------------------------ WebGL board */
.board.three {
  position: relative;
  aspect-ratio: 16 / 6.5;
  padding: 0;
  margin-top: 8px;
  perspective: none;
}
.board.three .case { position: absolute; inset: 0; opacity: 0; pointer-events: none; transform: none; }
.board.three .kb { position: absolute; inset: 0; }
.gl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
  outline: none;
  animation: gl-in 900ms var(--out) both;
}
@keyframes gl-in { from { opacity: 0; } }
body:not(.ready) .board.three { aspect-ratio: 16 / 6.6; }
@media (max-width: 860px) { .board.three { aspect-ratio: 16 / 9; } }

/* ------------------------------------------------------------------ large screens
   Scale the whole interface up on wide displays (1440p, 4K at 100 %) so it
   keeps the same proportion of the screen instead of shrinking into a strip. */
@media (min-width: 1700px) { body { zoom: 1.12; } }
@media (min-width: 1950px) { body { zoom: 1.25; } }
@media (min-width: 2300px) { body { zoom: 1.4; } }
@media (min-width: 2900px) { body { zoom: 1.6; } }
@media (min-width: 3500px) { body { zoom: 1.9; } }

/* capsule over the board (performance: single / multi select) */
.board { position: relative; }
.board-pill {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 18px 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--hud);
  color: var(--hud-ink);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transform: translateX(-50%);
  animation: pill-in 520ms var(--spring) both;
  transition: background-color 220ms, color 220ms, transform 300ms var(--spring);
}
.board-pill::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px currentColor, 4px -4px 0 -1px var(--hud), 4px -4px 0 1px currentColor;
}
.board-pill.on { background: var(--accent); color: var(--accent-ink); }
.board-pill.on::before { box-shadow: inset 0 0 0 2px currentColor, 4px -4px 0 -1px var(--accent), 4px -4px 0 1px currentColor; }
.board-pill:active { transform: translateX(-50%) scale(0.95); }
.board-pill[hidden] { display: none !important; }
@keyframes pill-in { from { opacity: 0; transform: translate(-50%, -8px) scale(0.94); } to { opacity: 1; transform: translateX(-50%); } }
.gl-fg { pointer-events: none; animation: none; }
.gl { will-change: filter; }
