/* Drive Sound · "Halo" shell: page, layout, controls, dialogs.
   The ring (css/ring.css) and the sound selector (css/selector.css) style themselves.
   Platform floor ≈ Chromium 90: no container queries, color-mix(), :has() or nesting.
   Motion uses transform / opacity only; glows are gradients, never filter blur. */

@font-face {
  font-family: 'Sora';
  src: url(../fonts/sora-latin.woff2) format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  /* theme: set by js/app.js whenever the sound changes */
  --accent: #ff6a2b;
  --accent-rgb: 255, 106, 43;
  --regen: #5fd6ff;
  --regen-rgb: 95, 214, 255;

  --bg: #05070b;
  --text: #eef3f8;
  --text-rgb: 238, 243, 248;
  --muted: rgba(238, 243, 248, 0.6);
  --line: rgba(255, 255, 255, 0.08);
  --surface: rgba(255, 255, 255, 0.04);
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #ff5d6c;
  --font: 'Sora', 'Segoe UI', system-ui, sans-serif;

  --head-h: 74px; /* header height, for the ring budgets below */
  --sel-h: 302px; /* selector height when it runs full width under the ring (half-screen) */
  /* ring size: up to 600 px, and never taller than the viewport allows
     (leaves room for the header and, in Pure mode, the scaled ring + Start row) */
  --ring-max: max(240px, min(600px, calc(90vh - 170px)));
  --side-w: 300px;
  --pad-x: 32px;
  --gap-x: 32px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button, input, output { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; }
svg { flex: none; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.muted { color: var(--muted); }

/* The page clips its own overflow (ambient glow, 3D panels) without becoming a scroller. */
.page {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  contain: paint;
}

/* ---- header ------------------------------------------------------------------- */

/* Three columns: the outer two always share the width equally, so the display switch sits in
   the middle and never moves; a long status wraps (two lines at most) instead of pushing it. */
.top {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 20px;
  padding: 18px max(var(--pad-x), env(safe-area-inset-right)) 0 max(var(--pad-x), env(safe-area-inset-left));
}
.brand {
  min-width: 0;
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 600; letter-spacing: .02em; white-space: nowrap;
}
.brand-mark { width: 28px; height: 28px; }
.brand-glow { fill: rgb(var(--accent-rgb)); transition: fill .8s; }
.top-right {
  min-width: 0;
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
}

.icon-btn {
  position: relative;
  flex: none;
  width: 48px; height: 48px; padding: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .1);
  background-color: var(--surface);
  transition: background-color .2s, border-color .2s;
}
/* 56 px touch target (offsets count from the padding box, inside the 1 px border) */
.icon-btn::before { content: ''; position: absolute; top: -5px; right: -5px; bottom: -5px; left: -5px; border-radius: 50%; }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { border-color: rgba(255, 255, 255, .22); }
.icon-btn:active { background-color: rgba(255, 255, 255, .1); }

/* status chip (not a live region: #status-live announces changes of kind) */
.status {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  min-height: 40px;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; line-height: 16px;
}
.status span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2; /* a safety net: the header layouts leave room for every message */
  overflow: hidden;
}
.status i {
  flex: none; width: 8px; height: 8px; border-radius: 50%;
  background-color: rgba(238, 243, 248, .5);
  transition: background-color .3s, box-shadow .3s;
}
.status[data-tone="good"] i { background-color: var(--good); box-shadow: 0 0 10px var(--good); }
.status[data-tone="warn"] i { background-color: var(--warn); box-shadow: 0 0 10px rgba(251, 191, 36, .6); animation: shBlink 1.2s ease-in-out infinite; }
.status[data-tone="bad"] i { background-color: var(--bad); box-shadow: 0 0 10px rgba(255, 93, 108, .6); }
.status[data-tone="cool"] i { background-color: rgb(var(--accent-rgb)); box-shadow: 0 0 10px rgba(var(--accent-rgb), .8); }

/* ---- segmented controls (sliding thumb) ----------------------------------------------- */

/* The buttons fill the whole control (no dead ring around them); the thumb is inset 4 px. */
.seg {
  position: relative;
  flex: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0;
  border-radius: 999px;
  background-color: var(--surface);
  border: 1px solid var(--line);
}
.seg button {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 54px; padding: 0 12px;
  border: 0; border-radius: 0; background: transparent;
  font-size: 14px; font-weight: 600; white-space: nowrap;
  color: rgba(238, 243, 248, .6);
  transition: color .3s;
}
.seg button:focus-visible { outline-offset: -5px; border-radius: 999px; }
.seg button[aria-checked="true"] { color: var(--text); }
.seg button svg { width: 18px; height: 18px; }
.seg-thumb {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px;
  width: calc(50% - 4px);
  border-radius: 999px;
  background-color: rgba(255, 255, 255, .12);
  border: 1px solid transparent;
  transition: transform .5s cubic-bezier(.3, 1.3, .5, 1), border-color .6s, background-color .6s;
}
.seg button:nth-of-type(2)[aria-checked="true"] ~ .seg-thumb { transform: translateX(100%); }
.seg button:nth-of-type(3)[aria-checked="true"] ~ .seg-thumb { transform: translateX(200%); }
.seg-display { width: 220px; }
.seg-mode button { height: 60px; }
.seg-mode .seg-thumb { border-color: rgba(var(--accent-rgb), .53); background-color: rgba(var(--accent-rgb), .12); }

/* ---- stage: selector | halo | controls ------------------------------------------------ */

.stage {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px var(--gap-x);
  padding: 8px max(var(--pad-x), env(safe-area-inset-right)) 28px max(var(--pad-x), env(safe-area-inset-left));
}

.side {
  flex: 0 0 var(--side-w);
  max-width: var(--side-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: opacity .5s ease, transform .7s cubic-bezier(.6, 0, .2, 1), visibility 0s linear 0s;
}
/* the selector keeps its 3D-lift room (its own padding) outside the 300 px column */
#selector > .sel {
  --sel-px: 10px;
  --sel-pad: 10px var(--sel-px) 16px;
  width: calc(var(--side-w) + 2 * var(--sel-px));
  margin: -10px calc(-1 * var(--sel-px)) -16px;
}
/* the selector comes last in the DOM (Tab order: controls first) but first in the row */
.side-left { order: -1; transform-origin: 0% 50%; }
.side-right { transform-origin: 100% 50%; gap: 12px; }

/* Pure: both panels swing away in 3D and fade (transform + opacity only). Their columns stay
   reserved, so the ring keeps its size and place; it grows by scale. Unreachable once hidden:
   visibility after the transition, plus inert from js. */
.pure .side {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition-delay: 0s, 0s, .7s;
}
.pure .side-left { transform: perspective(1000px) rotateY(58deg) translateX(-40px); }
.pure .side-right { transform: perspective(1000px) rotateY(-58deg) translateX(40px); }

/* ---- halo: ambient glow, ring, readout ------------------------------------------------ */

.halo {
  position: relative;
  flex: 0 1 600px;
  min-width: 0;
  transition: transform .8s cubic-bezier(.3, 1.2, .4, 1);
}
.pure .halo { transform: translateY(-37px) scale(1.1); }

/* Positioned square that holds the glow, the ring's layers (the svg and any sibling layer
   ring.js adds, e.g. the spin layer) and the readout. Nothing in it is clipped. */
.halo-box {
  --rs: 520px; /* ring size in px, kept current by a ResizeObserver in js/app.js */
  position: relative;
  width: 100%;
  max-width: var(--ring-max);
  margin: 0 auto;
  aspect-ratio: 1 / 1;
}
@supports not (aspect-ratio: 1 / 1) {
  .halo-box::before { content: ''; display: block; padding-top: 100%; }
}
.halo-box .ring {
  position: absolute; left: 0; top: 0;
  width: 100%; height: 100%;
  overflow: visible;
}

/* ambient glow: a masked colour field (soft like a blur, but a plain gradient) */
.amb {
  position: absolute;
  left: -50%; top: -50%; width: 200%; height: 200%;
  pointer-events: none;
  opacity: .17;
  background-color: rgb(var(--accent-rgb));
  -webkit-mask-image: radial-gradient(closest-side, #000 0%, rgba(0, 0, 0, .96) 22%, rgba(0, 0, 0, .62) 42%, rgba(0, 0, 0, .28) 62%, rgba(0, 0, 0, .08) 82%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 0%, rgba(0, 0, 0, .96) 22%, rgba(0, 0, 0, .62) 42%, rgba(0, 0, 0, .28) 62%, rgba(0, 0, 0, .08) 82%, transparent 100%);
  transition: background-color 1s ease;
  will-change: transform;
}

.read {
  position: absolute; left: 0; right: 0;
  display: flex;
  pointer-events: none;
  white-space: nowrap;
}
.read-top { top: 25%; flex-direction: column; align-items: center; gap: 2px; }
.read-bottom { bottom: 9%; justify-content: center; align-items: center; gap: calc(var(--rs) * .0231); }

.ro-kind {
  font-size: max(10px, calc(var(--rs) * .0231));
  font-weight: 600; letter-spacing: .2em; text-transform: uppercase;
  color: rgba(238, 243, 248, .6);
  transition: color .6s;
}
.ro-kind.is-power { color: rgb(var(--regen-rgb)); }
.ro-speed {
  font-size: calc(var(--rs) * .2846); /* 148 px on a 520 px ring */
  font-weight: 300; line-height: 1; letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.ro-unit { font-size: max(11px, calc(var(--rs) * .0269)); font-weight: 600; color: rgba(238, 243, 248, .62); }
.ro-gear {
  min-width: calc(var(--rs) * .0923);
  height: calc(var(--rs) * .0923);
  padding: 0 calc(var(--rs) * .0231);
  border-radius: 999px;
  display: grid; place-items: center;
  font-size: calc(var(--rs) * .0462); font-weight: 700; line-height: 1;
  color: #05070b;
  background-color: rgb(var(--accent-rgb));
  box-shadow: 0 0 24px rgba(var(--accent-rgb), .4);
  transition: background-color .6s, box-shadow .6s;
}
/* wide enough for "10,000 rpm" / "100% power" / "Regen 100%", so the gear pill never shifts */
.ro-rpm {
  min-width: 6.6em;
  font-size: max(12px, calc(var(--rs) * .0346));
  color: rgba(238, 243, 248, .82);
  font-variant-numeric: tabular-nums;
}

/* Pure row: sound name + Start / Stop under the ring */
.pure-row {
  position: absolute; left: 0; right: 0; top: 100%;
  margin-top: 12px;
  display: flex; justify-content: center; align-items: center; gap: 14px;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  visibility: hidden;
  transition: opacity .45s ease, transform .6s cubic-bezier(.2, .9, .2, 1), visibility 0s linear .6s;
}
.pure .pure-row {
  opacity: 1; transform: none; pointer-events: auto; visibility: visible;
  transition-delay: .35s, .35s, 0s;
}
.pure-name { font-size: 16px; font-weight: 600; white-space: nowrap; }
.pure-power {
  height: 56px; min-width: 104px; padding: 0 24px;
  border-radius: 28px;
  font-size: 15px; font-weight: 700;
  border: 1.5px solid rgb(var(--accent-rgb));
  background-color: rgb(var(--accent-rgb));
  color: #05070b;
  transition: background-color .45s, color .45s, border-color .6s;
}
.pure-power.is-on { background-color: transparent; color: rgb(var(--accent-rgb)); }

/* ---- controls panel --------------------------------------------------------------- */

.np-group {
  font-size: 12px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase;
  color: rgb(var(--accent-rgb));
  transition: color .6s;
  transform-origin: 0 50%;
}
.np-name { margin: 6px 0 0; font-size: 32px; font-weight: 600; line-height: 1.1; letter-spacing: -.02em; }
.np-tag { margin: 6px 0 0; font-size: 14px; line-height: 1.45; color: rgba(238, 243, 248, .68); }
.np-meta {
  margin: 6px 0 0; font-size: 12px; font-weight: 600; letter-spacing: .04em;
  color: rgba(238, 243, 248, .6); font-variant-numeric: tabular-nums;
}

.power {
  position: relative;
  height: 76px;
  border-radius: 38px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  font-size: 18px; font-weight: 700; letter-spacing: .02em;
  border: 1.5px solid rgb(var(--accent-rgb));
  background-color: rgb(var(--accent-rgb));
  color: #05070b;
  box-shadow: 0 0 34px rgba(var(--accent-rgb), .33);
  transition: background-color .45s, color .45s, border-color .6s, box-shadow .6s, transform .1s;
}
.power svg { width: 22px; height: 22px; }
.power:active { transform: scale(.985); }
.power:disabled { cursor: progress; }
.power.is-on { background-color: transparent; color: rgb(var(--accent-rgb)); box-shadow: none; }
/* a few pulses invite the first tap, then it rests (no endless animation while idle) */
.power-pulse {
  position: absolute; top: -2px; right: -2px; bottom: -2px; left: -2px;
  border-radius: inherit;
  border: 1.5px solid rgb(var(--accent-rgb));
  pointer-events: none;
  opacity: 0;
  animation: shPulse 1.7s ease-out 6;
}
.power.is-on .power-pulse { display: none; }

.rev {
  position: relative;
  overflow: hidden;
  height: 96px;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, .1);
  background-color: var(--surface);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  text-align: left;
  touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: opacity .3s, border-color .2s;
}
.rev-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 100%;
  opacity: .22;
  background-color: rgb(var(--accent-rgb));
  transform-origin: 0 50%;
  transform: scaleX(0);
  pointer-events: none;
  transition: background-color .6s;
}
.rev-icon {
  position: relative;
  flex: 0 0 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid rgb(var(--accent-rgb));
  box-shadow: 0 0 18px rgba(var(--accent-rgb), .27);
  transition: border-color .6s, box-shadow .6s;
}
.rev-icon svg { width: 22px; height: 22px; }
.rev-text { position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.rev-text b { font-size: 17px; font-weight: 700; line-height: 1.25; }
.rev-text small { font-size: 13px; line-height: 1.35; color: rgba(238, 243, 248, .68); }
.rev.down { border-color: rgba(var(--accent-rgb), .7); }
.rev:disabled { opacity: .5; }

.pedals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  animation: shDown .4s cubic-bezier(.2, .9, .2, 1) both;
}
.pedal {
  height: 76px;
  border-radius: 22px;
  font-size: 16px; font-weight: 700;
  touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: background-color .15s, color .15s, box-shadow .15s, opacity .3s, border-color .6s;
}
.pedal.brake { border: 1px solid rgba(255, 255, 255, .12); background-color: var(--surface); }
.pedal.brake.down { background-color: rgba(255, 255, 255, .2); }
.pedal.gas { border: 1px solid rgb(var(--accent-rgb)); background-color: rgba(var(--accent-rgb), .1); color: var(--text); }
.pedal.gas.down { background-color: rgb(var(--accent-rgb)); color: #05070b; box-shadow: 0 0 30px rgba(var(--accent-rgb), .4); }
.pedal:disabled { opacity: .45; }

.volume {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px;
  color: rgba(238, 243, 248, .75);
}
.volume svg { width: 22px; height: 22px; }
.volume output { width: 44px; text-align: right; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* range: 56 px tall hit area, accent track fill (--v = 0..1, set from js), round thumb */
.range {
  --v: .5;
  flex: 1; min-width: 0; width: 100%;
  height: 56px; margin: 0;
  background: transparent;
  -webkit-appearance: none; appearance: none;
  cursor: pointer;
  touch-action: pan-y;
}
.range::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, rgb(var(--accent-rgb)) 0 calc(var(--v) * 100%), rgba(255, 255, 255, .14) calc(var(--v) * 100%) 100%);
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: -9px;
  border-radius: 50%; border: 0;
  background: #eef3f8;
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .35);
}
.range::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .14); }
.range::-moz-range-progress { height: 4px; border-radius: 2px; background: rgb(var(--accent-rgb)); }
.range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; border: 0; background: #eef3f8; box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .35); }

/* ---- toast ---------------------------------------------------------------------------- */

.toast {
  position: fixed; z-index: 40; top: 84px; left: 50%;
  max-width: calc(100vw - 32px);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: #05070b;
  background: #eef3f8;
  box-shadow: 0 0 40px rgba(var(--accent-rgb), .33);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 0);
  transition: opacity .2s ease, visibility 0s linear .2s;
}
.toast.show0, .toast.show1 { visibility: visible; }
.toast.show0 { animation: shToast0 2.4s ease both; }
.toast.show1 { animation: shToast1 2.4s ease both; }
/* calm / reduced motion: a short fade in and out, no movement */
.toast.on { opacity: 1; visibility: visible; transition: opacity .2s ease, visibility 0s; }

/* ---- dialogs ------------------------------------------------------------------------------ */

dialog {
  border: 0; padding: 0; background: transparent; color: var(--text);
  max-width: calc(100vw - 24px); max-height: calc(100vh - 24px);
  font-family: var(--font);
}
dialog::backdrop { background: rgba(2, 3, 6, .74); }
dialog[open] .sheet { animation: shSheet .32s cubic-bezier(.2, .9, .2, 1) both; }
.sheet {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #0b0f15;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px 24px 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .65), 0 0 60px rgba(var(--accent-rgb), .07);
}
.sheet.wide { width: min(720px, calc(100vw - 24px)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.sheet-head h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.sheet h3 {
  margin: 22px 0 8px;
  font-size: 12px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: rgb(var(--accent-rgb));
}
.setting {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  min-height: 72px; padding: 14px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.setting.column { flex-direction: column; align-items: stretch; gap: 4px; padding-bottom: 6px; }
.setting b { font-weight: 600; }
.setting small { display: block; margin-top: 2px; font-size: 13px; line-height: 1.45; color: var(--muted); }
/* A live note under a setting (outside its label, so it isn't part of the switch's name and a
   tap on it doesn't flip the switch). Always rendered, so screen readers hear each change. */
.setting-note { margin: -6px 0 14px; font-size: 13px; line-height: 1.45; color: rgba(var(--text-rgb), .82); }
.setting-note:empty { margin: 0; }
.setting-note[data-tone="good"] { color: var(--good); }
.setting-note[data-tone="warn"] { color: var(--warn); }
.setting-note[data-tone="bad"] { color: var(--bad); }
.seg-units { flex: none; width: 240px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg-units .seg-thumb { width: calc((100% - 8px) / 3); }
@media (max-width: 599px) {
  .setting-units { flex-direction: column; align-items: stretch; gap: 12px; }
  .seg-units { width: 100%; }
}
.range-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }

.switch {
  -webkit-appearance: none; appearance: none;
  position: relative; flex: none;
  width: 56px; height: 32px; margin: 0;
  border-radius: 999px;
  background-color: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .12);
  cursor: pointer;
  transition: background-color .2s, border-color .2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(238, 243, 248, .7);
  transition: transform .2s cubic-bezier(.3, 1.3, .5, 1), background-color .2s;
}
.switch:checked { background-color: rgb(var(--accent-rgb)); border-color: transparent; }
.switch:checked::after { transform: translateX(24px); background: #05070b; }
.switch:disabled, .switch[aria-disabled="true"] { opacity: .55; cursor: progress; }

.steps, .notes { margin: 8px 0 0; padding-left: 22px; display: grid; gap: 10px; font-size: 15px; line-height: 1.55; }
.steps li::marker { color: rgb(var(--accent-rgb)); font-weight: 700; }
.notes { color: rgba(238, 243, 248, .72); }
.notes b, .steps b { color: var(--text); font-weight: 600; }
kbd {
  display: inline-block; min-width: 1.9em; padding: 1px 7px;
  border-radius: 7px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .06);
  font: 600 13px/1.6 var(--font); text-align: center; color: var(--text);
}
.sheet-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px;
  margin-top: 22px; padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: rgba(238, 243, 248, .6);
}

/* ---- motion: intro, sound switch, pops ---------------------------------------------------- */

@keyframes shDrop { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: none; } }
@keyframes shBloom { from { opacity: 0; transform: scale(.5); } to { opacity: .17; transform: none; } }
@keyframes shRead { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes shLeft { from { opacity: 0; transform: perspective(1000px) rotateY(40deg) translateX(-30px); } to { opacity: 1; transform: none; } }
@keyframes shRight { from { opacity: 0; transform: perspective(1000px) rotateY(-40deg) translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes shPulse { 0% { opacity: .8; transform: scale(1); } 100% { opacity: 0; transform: scale(1.06, 1.4); } }
@keyframes shDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes shBlink { 50% { opacity: .3; } }
@keyframes shSheet { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes shToast0 { 0% { opacity: 0; transform: translate(-50%, -12px); } 12% { opacity: 1; transform: translate(-50%, 0); } 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -8px); } }
@keyframes shToast1 { 0% { opacity: 0; transform: translate(-50%, -12px); } 12% { opacity: 1; transform: translate(-50%, 0); } 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -8px); } }
/* two identical copies each, so alternating the class restarts the animation without a reflow */
@keyframes shFlare0 { 0% { opacity: .17; } 25% { opacity: .42; } 100% { opacity: .17; } }
@keyframes shFlare1 { 0% { opacity: .17; } 25% { opacity: .42; } 100% { opacity: .17; } }
@keyframes shName0 { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes shName1 { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes shPop0 { 0% { opacity: .4; transform: scale(.85); } 60% { transform: scale(1.06); } 100% { opacity: 1; transform: none; } }
@keyframes shPop1 { 0% { opacity: .4; transform: scale(.85); } 60% { transform: scale(1.06); } 100% { opacity: 1; transform: none; } }

/* intro (body.intro, removed ~3.2 s after load, or at once when the display is changed) */
.intro .top { animation: shDrop .6s .2s cubic-bezier(.2, .8, .2, 1) backwards; }
.intro .amb { animation: shBloom 1.2s .7s ease backwards; }
.intro .read { animation: shRead .7s 1.5s cubic-bezier(.2, .8, .2, 1) backwards; }
.intro:not(.pure) .side-left { animation: shLeft .8s 1.15s cubic-bezier(.2, .8, .2, 1) backwards; }
.intro:not(.pure) .side-right { animation: shRight .8s 1.25s cubic-bezier(.2, .8, .2, 1) backwards; }

/* sound switch (classes set and cleared by js, after the intro rules so they win) */
.amb.sw0 { animation: shFlare0 1.1s ease; }
.amb.sw1 { animation: shFlare1 1.1s ease; }
.np-slide.sw0 { animation: shName0 .6s .08s cubic-bezier(.2, .9, .2, 1) backwards; }
.np-slide.sw1 { animation: shName1 .6s .08s cubic-bezier(.2, .9, .2, 1) backwards; }
.np-group.sw0, .ro-kind.sw0 { animation: shPop0 .5s .2s cubic-bezier(.2, .9, .2, 1) backwards; }
.np-group.sw1, .ro-kind.sw1 { animation: shPop1 .5s .2s cubic-bezier(.2, .9, .2, 1) backwards; }
/* gear change and speed-source change */
.ro-gear.pop0 { animation: shPop0 .3s cubic-bezier(.2, .9, .2, 1); }
.ro-gear.pop1 { animation: shPop1 .3s cubic-bezier(.2, .9, .2, 1); }
.status.pop0, .ro-unit.pop0 { animation: shPop0 .45s cubic-bezier(.2, .9, .2, 1); }
.status.pop1, .ro-unit.pop1 { animation: shPop1 .45s cubic-bezier(.2, .9, .2, 1); }

/* calm (driving): no flourishes; every transition or animation left is ≤ .25 s, undelayed.
   Listed per element: a bare duration on an element whose transition-property is the
   default `all` would start animating everything. */
.calm .amb { animation: none !important; }
.calm .sw0, .calm .sw1, .calm .pop0, .calm .pop1 { animation-duration: .25s !important; animation-delay: 0s !important; }
.calm .brand-glow, .calm .icon-btn, .calm .status i, .calm .seg button, .calm .seg-thumb,
.calm .side, .calm .halo, .calm .amb, .calm .ro-kind, .calm .ro-gear, .calm .pure-row, .calm .pure-power,
.calm .np-group, .calm .power, .calm .rev, .calm .rev-fill, .calm .rev-icon, .calm .pedal {
  transition-duration: .25s !important;
  transition-delay: 0s !important;
}

/* switches off every transition for one frame at boot (restored display mode etc.) */
.boot *, .boot *::before, .boot *::after { transition: none !important; }

/* ---- responsive ------------------------------------------------------------------------ */

/* narrower three-column screens: slimmer side panels so the ring keeps its size
   (288 px still fits two selector columns) */
@media (max-width: 1279px) {
  :root { --side-w: 288px; --pad-x: 24px; --gap-x: 24px; }
}

/* 900–1099 px: a centred switch would leave the status too little room, so the right column
   gets a larger share; the switch's place still depends only on the viewport width */
@media (min-width: 900px) and (max-width: 1099px) {
  .top { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.4fr); column-gap: 16px; }
  .seg-display { width: 200px; }
}

/* Below 1100 px the panels stack (grid) and Pure simply hides them; the Pure row is then in
   the flow (reachable by scrolling) and the ring grows to the space left instead of scaling. */
@media (max-width: 1099px) {
  :root { --side-w: 300px; }
  .stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    align-content: center;
    gap: 20px 24px;
    padding-bottom: 20px;
  }
  .halo { grid-area: halo; }
  .side-right { grid-area: right; }
  .side-left { grid-area: left; }
  .side { max-width: none; }
  #selector > .sel { width: auto; margin: 0; }
  .pure { --ring-max: max(200px, min(640px, calc(100vh - var(--head-h) - 112px))); }
  .pure .stage { grid-template-columns: minmax(0, 1fr); grid-template-areas: "halo"; }
  .pure .side { display: none; }
  .pure .halo { transform: none; }
  .pure .pure-row { position: static; margin-top: 16px; }
}

/* Tesla half-screen and tablets: ring + controls on top, selector full width below.
   The ring gets the height left over by the header and the selector row. */
/* From ~924 px the selector's 6 + 5 chips fit in two rows (six columns); 940 leaves room
   for a classic scrollbar. Narrower, it takes three or four rows. */
@media (min-width: 940px) and (max-width: 1099px) {
  :root { --sel-h: 230px; }
}

@media (min-width: 700px) and (max-width: 1099px) {
  :root { --ring-max: max(300px, min(600px, calc(100vh - var(--head-h) - var(--sel-h) - 48px))); }
  .stage {
    grid-template-columns: minmax(0, 1fr) clamp(260px, 32vw, 300px);
    grid-template-areas: "halo right" "left left";
  }
}

/* ... and on shorter screens in that band, a compact controls column */
@media (min-width: 900px) and (max-width: 1099px) and (max-height: 963px),
  (min-width: 700px) and (max-width: 899px) and (max-height: 1015px) {
  :root { --head-h: 68px; --ring-max: max(300px, min(600px, calc(100vh - var(--head-h) - var(--sel-h) - 28px))); }
  .top { padding-top: 12px; }
  .stage { padding-top: 4px; padding-bottom: 8px; row-gap: 16px; }
  .side-right { gap: 8px; }
  .np-tag, .np-meta { display: none; }
  .np-name { margin-top: 4px; font-size: 26px; }
  .power { height: 64px; border-radius: 32px; }
  .rev { height: 72px; border-radius: 22px; gap: 12px; padding: 0 14px; }
  .rev-icon { flex-basis: 42px; height: 42px; }
  .rev-text b { font-size: 16px; }
  .rev-text small { font-size: 12px; line-height: 1.3; }
  .seg-mode button { height: 56px; }
  .pedal { height: 56px; border-radius: 20px; }
}

/* two-row header: brand + Help / Settings, then the display switch + status */
@media (max-width: 899px) and (min-height: 501px), (max-width: 599px) {
  :root { --head-h: 126px; }
  .top {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "brand brand help settings" "seg status status status";
    column-gap: 12px;
    row-gap: 10px;
    padding-top: 12px;
  }
  .top-right { display: contents; }
  .brand { grid-area: brand; }
  #open-help { grid-area: help; }
  #open-settings { grid-area: settings; }
  /* the status has its own row here: up to three lines, growing downwards (the switch stays put) */
  .seg-display { grid-area: seg; width: 180px; align-self: start; }
  .status { grid-area: status; justify-self: end; padding: 8px 12px; gap: 8px; }
  .status span { -webkit-line-clamp: 3; }
  .toast { top: max(12px, env(safe-area-inset-top)); }
}

/* short landscape (phones on their side): one-row header; brand and switch at their own
   widths on the left (so the switch never moves), the status takes all the width left over */
@media (min-width: 600px) and (max-width: 899px) and (max-height: 500px) {
  :root { --head-h: 64px; }
  .top { grid-template-columns: auto auto minmax(0, 1fr); column-gap: 16px; padding-top: 8px; }
  .seg-display { width: 148px; }
  .status { padding: 8px 12px; gap: 8px; }
  .toast { top: 8px; }
}
@media (min-width: 600px) and (max-width: 699px) and (max-height: 500px) {
  .brand span { display: none; } /* logo only: the room goes to the status */
}

/* phones: one column (ring, controls, selector); the ring also fits the height */
@media (max-width: 699px) {
  :root { --pad-x: 16px; --ring-max: max(240px, min(600px, calc(100vh - var(--head-h) - 40px))); }
  .stage {
    grid-template-areas: "halo" "right" "left";
    gap: 24px;
    padding-top: 4px;
  }
  .side-right { width: 100%; max-width: 520px; justify-self: center; }
  .np-name { font-size: 28px; }
}

@media (max-width: 439px) {
  .seg-display { width: 160px; }
}
@media (max-width: 379px) {
  .seg-display { width: 148px; }
}

@media (hover: none) {
  .icon-btn:hover { border-color: rgba(255, 255, 255, .1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .toast.show0, .toast.show1 { opacity: 1; transform: translate(-50%, 0); }
  .pure .side-left, .pure .side-right { transform: none; }
}
