/* MIT License - Copyright (c) fintonlabs.com */

/* ═══════════════════════════════════════════════════════════════════════
   TOKENS
   Every token is defined on bare :root. The dark blocks redefine only what
   changes — a colour whose sole definition lives in a media query has no
   value in the other theme.
   ═══════════════════════════════════════════════════════════════════════ */
:root {
  /* Ground and surfaces */
  --bg:            #e9ebef;
  --bg-panel:      #f6f7f9;
  --bg-raised:     #ffffff;
  --bg-inset:      #dee2e8;
  --bg-sunk:       #d4d9e0;

  /* Structure */
  --border:        #ccd2da;
  --border-strong: #aab3bf;
  --grid:          rgba(18, 21, 26, .038);
  --hi:            rgba(255, 255, 255, .9);   /* faceplate top highlight */
  --overlay:       rgba(16, 19, 24, .5);

  /* Ink */
  --text:          #12151a;
  --text-2:        #414b58;
  /* --text-3 and the accents below are solved, not eyeballed: each clears
     4.5:1 against every ground it lands on (--bg, --bg-panel, --bg-inset,
     --bg-sunk). They carry 9–11px mono labels, so AA-large is not enough. */
  --text-3:        #57606a;

  /* Duotone accents — sections rebind --accent to one of these */
  --audio:         #a84f0a;
  --audio-soft:    rgba(168, 79, 10, .12);
  --app:           #0c6780;
  --app-soft:      rgba(12, 103, 128, .12);
  --live:          #147a3a;
  --accent:        var(--audio);
  --accent-soft:   var(--audio-soft);

  /* Type */
  --display: 'Bricolage Grotesque', 'SF Pro Display', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Radius, by role */
  --r-struct: 2px;
  --r-ctrl:   6px;
  --r-pill:   999px;
  --r-dialog: 12px;

  /* Motion */
  --dur:   .34s;
  --dur-s: .16s;
  --ease:  cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --rail-w: 264px;
  --shadow-pop: 0 24px 60px -20px rgba(10, 13, 18, .45), 0 2px 8px -2px rgba(10, 13, 18, .2);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg:            #0b0d11;
    --bg-panel:      #14171d;
    --bg-raised:     #1c2026;
    --bg-inset:      #080a0d;
    --bg-sunk:       #05070a;
    --border:        #262b33;
    --border-strong: #39404a;
    --grid:          rgba(255, 255, 255, .028);
    --hi:            rgba(255, 255, 255, .055);
    --overlay:       rgba(3, 5, 8, .72);
    --text:          #eef1f5;
    --text-2:        #b3bcc8;
    --text-3:        #828d9a;
    --audio:         #ffb340;
    --audio-soft:    rgba(255, 179, 64, .14);
    --app:           #3ad3e6;
    --app-soft:      rgba(58, 211, 230, .14);
    --live:          #3ddc84;
    --shadow-pop: 0 24px 60px -18px rgba(0, 0, 0, .8), 0 2px 10px -2px rgba(0, 0, 0, .6);
  }
}

:root[data-theme='dark'] {
  --bg:            #0b0d11;
  --bg-panel:      #14171d;
  --bg-raised:     #1c2026;
  --bg-inset:      #080a0d;
  --bg-sunk:       #05070a;
  --border:        #262b33;
  --border-strong: #39404a;
  --grid:          rgba(255, 255, 255, .028);
  --hi:            rgba(255, 255, 255, .055);
  --overlay:       rgba(3, 5, 8, .72);
  --text:          #eef1f5;
  --text-2:        #b3bcc8;
  --text-3:        #828d9a;
  --audio:         #ffb340;
  --audio-soft:    rgba(255, 179, 64, .14);
  --app:           #3ad3e6;
  --app-soft:      rgba(58, 211, 230, .14);
  --live:          #3ddc84;
  --shadow-pop: 0 24px 60px -18px rgba(0, 0, 0, .8), 0 2px 10px -2px rgba(0, 0, 0, .6);
}

/* ═══ RESET ═══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 92px;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--display);
  font-variation-settings: 'wdth' 100;
  font-optical-sizing: auto;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

/* Ground: graph grid + two slow washes. The only ambient loops on the page,
   and they sit in a decorative background layer, never on chrome. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
}
body::after {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  opacity: .55;
  background:
    radial-gradient(38% 34% at 14% 12%, var(--audio-soft), transparent 70%),
    radial-gradient(42% 38% at 86% 62%, var(--app-soft), transparent 72%);
  animation: drift 34s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(2%, -2%, 0) scale(1.06); }
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--bg-panel); }

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

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 200;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-ctrl);
  padding: 10px 16px;
  font-size: 13px;
}
.skip:focus { left: 8px; }

/* ═══ SIGNATURE MOTION — the sweep ════════════════════════════════════
   A left-to-right reveal. Reused on module entry, filter re-runs, rail
   items and section headers. One gesture, everywhere.
   ═══════════════════════════════════════════════════════════════════ */
@keyframes sweep-in {
  from { opacity: 0; transform: translateY(12px); clip-path: inset(0 100% 0 0); }
  to   { opacity: 1; transform: none;             clip-path: inset(0 0 0 0); }
}
@keyframes sweep-line {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(.96) translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.reveal {
  opacity: 0;
}
.reveal.in {
  animation: sweep-in .62s var(--ease-out) both;
  animation-delay: var(--d, 0ms);
}

/* ═══ TYPE PRIMITIVES ═════════════════════════════════════════════════ */
.kicker {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: var(--accent);
}
.kicker__rule {
  height: 1px;
  width: 56px;
  background: currentColor;
  opacity: .5;
  transform-origin: left;
  animation: sweep-line .8s var(--ease-out) both .2s;
}

.ul { position: relative; }
.ul::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--dur) var(--ease);
}
.ul:hover::after { transform: scaleX(1); transform-origin: left; }

/* ═══ CONTROLS ════════════════════════════════════════════════════════ */
.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: var(--r-ctrl);
  background: var(--bg-panel);
  box-shadow: inset 0 1px 0 var(--hi);
  color: var(--text-3);
  cursor: pointer;
  transition: color var(--dur-s) var(--ease), background-color var(--dur-s) var(--ease),
              border-color var(--dur-s) var(--ease), transform var(--dur-s) var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--bg-raised); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0) scale(.94); }
.icon-btn[aria-pressed='true'], .icon-btn.on { color: var(--accent); border-color: var(--accent); }

/* Icon swapping: sun/moon and play/stop live in the same button */
.i-moon, .i-stop { display: none; }
:root[data-theme='dark'] .i-sun { display: none; }
:root[data-theme='dark'] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .i-sun { display: none; }
  :root:not([data-theme='light']) .i-moon { display: block; }
}
:root[data-theme='light'] .i-sun { display: block; }
:root[data-theme='light'] .i-moon { display: none; }
.playing .i-play { display: none; }
.playing .i-stop { display: block; }

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-ctrl);
  background: var(--bg-panel);
  box-shadow: inset 0 1px 0 var(--hi);
  color: var(--text-2);
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .4px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--dur-s) var(--ease), background-color var(--dur-s) var(--ease),
              border-color var(--dur-s) var(--ease), transform var(--dur-s) var(--ease);
}
/* the sweep, as a hover highlight */
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, var(--accent-soft) 50%, transparent 80%);
  transform: translateX(-100%);
  transition: transform .55s var(--ease);
  pointer-events: none;
}
.btn:hover { color: var(--text); border-color: var(--border-strong); }
.btn:hover::after { transform: translateX(100%); }
.btn:active { transform: scale(.97); }
.btn--primary { color: var(--text); border-color: var(--border-strong); background: var(--bg-raised); }
.btn--primary[aria-pressed='true'] { color: var(--accent); border-color: var(--accent); }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-raised);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
}

/* ═══ RAIL ════════════════════════════════════════════════════════════ */
.rail {
  position: fixed;
  z-index: 60;
  top: 0; left: 0; bottom: 0;
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 26px 22px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* The rail rebinds its accent to whichever section is in view, so the
   transport LEDs shift amber → cyan as you move down the page. */
.rail[data-accent='audio'] { --accent: var(--audio); --accent-soft: var(--audio-soft); }
.rail[data-accent='app']   { --accent: var(--app);   --accent-soft: var(--app-soft); }

/* Vertical rail: mark on its own line, controls beneath. Four 32px buttons
   plus the wordmark do not fit across 220px of usable width. */
.rail__top { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }

.mark { display: inline-flex; align-items: center; gap: 10px; }
.mark__glyph { display: flex; align-items: flex-end; gap: 2.5px; height: 17px; }
.mark__glyph i {
  display: block;
  width: 3.5px;
  border-radius: 1px;
  background: var(--audio);
  transition: height var(--dur) var(--ease-out), background-color var(--dur) var(--ease);
}
.mark__glyph i:nth-child(1) { height: 8px; }
.mark__glyph i:nth-child(2) { height: 16px; }
.mark__glyph i:nth-child(3) { height: 5px; background: var(--app); }
.mark:hover .mark__glyph i:nth-child(1) { height: 15px; }
.mark:hover .mark__glyph i:nth-child(2) { height: 7px; }
.mark:hover .mark__glyph i:nth-child(3) { height: 13px; }
.mark__text {
  font-weight: 620;
  font-size: 15.5px;
  letter-spacing: -.3px;
  font-variation-settings: 'wdth' 92;
}

.rail__quick { display: flex; gap: 6px; }

/* The 16-LED playhead strip */
.rail__meter {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 2px;
  height: 20px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-struct);
  background: var(--bg-inset);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .14);
}
.rail__meter i {
  display: block;
  border-radius: 1px;
  background: var(--border-strong);
  opacity: .38;
  transition: opacity .1s linear, background-color .1s linear, transform .1s linear;
}
.rail__meter i.beat { opacity: .6; }
.rail__meter i.hit  { background: var(--accent); opacity: 1; transform: scaleY(1.15); }

.rail__nav { display: flex; flex-direction: column; gap: 2px; }
.rail__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-ctrl);
  font-size: 13.5px;
  color: var(--text-2);
  transition: background-color var(--dur-s) var(--ease), color var(--dur-s) var(--ease);
}
.rail__link:hover { background: var(--bg-panel); color: var(--text); }
.rail__link.active { color: var(--text); background: var(--bg-panel); }
.rail__link.active::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 2px; height: 18px;
  margin-top: -9px;
  border-radius: var(--r-pill);
  background: var(--accent);
}
.rail__link-t { flex: 1; }
.rail__link-n { font-family: var(--mono); font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.dot { width: 7px; height: 7px; border-radius: var(--r-pill); flex: none; }
.dot--audio { background: var(--audio); }
.dot--app   { background: var(--app); }

.rail__label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg-panel);
  color: var(--text-3);
  padding: 3px 9px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .2px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-s) var(--ease), background-color var(--dur-s) var(--ease),
              border-color var(--dur-s) var(--ease), transform var(--dur-s) var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.chip[aria-pressed='true'] {
  color: var(--bg-panel);
  background: var(--text);
  border-color: var(--text);
}

/* Overflow stacks, folded away until asked for */
#stack-chips .chip--extra { display: none; }
#stack-chips.open .chip--extra { display: block; animation: pop-in .3s var(--ease-out) both; }
.chip--more { border-style: dashed; color: var(--text-2); }
#stack-chips.open .chip--more { order: 99; }

.reset {
  margin-top: 12px;
  border: 0;
  background: none;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 0;
}
.reset:hover { text-decoration: underline; }

.rail__foot { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--border); }
.keys { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.keys li { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-3); }
.keys li span { margin-left: 6px; }
.rail__sig { margin-top: 18px; font-family: var(--mono); font-size: 10.5px; color: var(--text-3); }

/* ═══ STAGE ═══════════════════════════════════════════════════════════ */
.stage {
  position: relative;
  z-index: 1;
  margin-left: var(--rail-w);
  max-width: 1000px;
  padding: 0 40px 80px;
}

/* ═══ HERO ════════════════════════════════════════════════════════════ */
.hero { padding: 72px 0 0; }

.hero__h {
  margin-top: 26px;
  font-size: clamp(38px, 5.6vw, 70px);
  font-weight: 640;
  line-height: 1.02;
  letter-spacing: -2.4px;
  font-variation-settings: 'wdth' 88, 'opsz' 72;
  text-wrap: balance;
  animation: sweep-in .8s var(--ease-out) both .08s;
}
.hero__h em {
  font-style: normal;
  color: var(--accent);
  font-variation-settings: 'wdth' 82, 'opsz' 72;
}

.hero__copy { margin-top: 26px; max-width: 62ch; animation: sweep-in .8s var(--ease-out) both .18s; }
.hero__copy p { color: var(--text-2); font-size: 17px; }
.hero__copy p + p { margin-top: 13px; }
.hero__copy strong { color: var(--text); font-weight: 600; }

/* ═══ PANEL — the faceplate surface used by the sequencer ═════════════ */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--r-struct);
  background: var(--bg-panel);
  box-shadow: inset 0 1px 0 var(--hi);
}
.panel__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  height: 40px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(var(--bg-raised), var(--bg-panel));
}
.panel__t {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--text);
}
.panel__sub { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); }
.panel__spacer { flex: 1; }

/* Rack screws — small hardware detail at each end of a faceplate */
.screw {
  width: 6px; height: 6px;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--bg-inset);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, .3), 0 1px 0 var(--hi);
}

.badge {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 2px 9px;
  transition: color var(--dur-s) var(--ease), border-color var(--dur-s) var(--ease);
}
.badge.on { color: var(--live); border-color: var(--live); }

/* ═══ SEQUENCER ═══════════════════════════════════════════════════════ */
.seq { margin-top: 44px; animation: sweep-in .8s var(--ease-out) both .28s; }
.seq__body { padding: 18px; }

.seq__grid-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-struct);
  background: var(--bg-inset);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .13);
  padding: 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.seq__ruler,
.seq__lane-cells {
  display: grid;
  grid-template-columns: repeat(16, minmax(19px, 1fr));
  gap: 4px;
}
.seq__ruler { margin-left: 62px; margin-bottom: 6px; min-width: 380px; }
.seq__ruler span {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-3);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.seq__ruler span.q { color: var(--text-2); font-weight: 500; }

.seq__lanes { display: flex; flex-direction: column; gap: 5px; min-width: 442px; }
.seq__lane { display: flex; align-items: center; gap: 8px; }
.seq__lane-name {
  width: 54px;
  flex: none;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--text-3);
}
.seq__lane-cells { flex: 1; }

.cell {
  aspect-ratio: 1;
  min-height: 19px;
  border: 1px solid var(--border);
  border-radius: var(--r-struct);
  background: var(--bg-panel);
  cursor: pointer;
  padding: 0;
  transition: background-color .1s linear, border-color .1s linear, transform .1s var(--ease);
}
.cell:hover { border-color: var(--border-strong); transform: scale(1.09); }
.cell.q { background: var(--bg-raised); }
.cell[aria-pressed='true'] {
  background: var(--lane, var(--audio));
  border-color: var(--lane, var(--audio));
}
.cell.now { box-shadow: 0 0 0 2px var(--text); }
.cell.fire { transform: scale(1.22); }

.seq__lane[data-lane='kick'] { --lane: var(--audio); }
.seq__lane[data-lane='hat']  { --lane: var(--text-2); }
.seq__lane[data-lane='acid'] { --lane: var(--app); }

.seq__swipe {
  display: none;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-3);
}

.seq__controls {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.tempo { display: flex; align-items: center; gap: 10px; }
.tempo__l {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-3);
}
.tempo__v {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 62px;
}
.tempo__v i { font-style: normal; font-size: 9.5px; color: var(--text-3); margin-left: 3px; }

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 116px;
  height: 20px;
  background: none;
  cursor: pointer;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--bg-sunk);
  border: 1px solid var(--border);
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  margin-top: -6px;
  border-radius: var(--r-pill);
  background: var(--accent);
  border: 2px solid var(--bg-panel);
  transition: transform var(--dur-s) var(--ease);
}
input[type='range']:hover::-webkit-slider-thumb { transform: scale(1.18); }
input[type='range']::-moz-range-track {
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--bg-sunk);
  border: 1px solid var(--border);
}
input[type='range']::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: var(--r-pill);
  background: var(--accent);
  border: 2px solid var(--bg-panel);
}

.seq__btns { display: flex; gap: 8px; margin-left: auto; }
.seq__note {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-3);
  max-width: 68ch;
}

/* ═══ STATS ═══════════════════════════════════════════════════════════ */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-top: 40px;
  border: 1px solid var(--border);
  border-radius: var(--r-struct);
  background: var(--border);
  overflow: hidden;
}
.stat { background: var(--bg-panel); padding: 16px 18px; transition: background-color var(--dur-s) var(--ease); }
.stat:hover { background: var(--bg-raised); }
.stat dt {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-3);
}
.stat dd {
  margin-top: 4px;
  font-size: 27px;
  font-weight: 620;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'wdth' 88;
}

/* ═══ SECTIONS ════════════════════════════════════════════════════════ */
.section[data-accent='audio'] { --accent: var(--audio); --accent-soft: var(--audio-soft); }
.section[data-accent='app']   { --accent: var(--app);   --accent-soft: var(--app-soft); }

.chapter {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin: 88px 0 22px;
  padding-top: 20px;
  border-top: 2px solid var(--text);
}
.chapter h2 {
  font-size: clamp(22px, 3vw, 29px);
  font-weight: 640;
  letter-spacing: -1px;
  font-variation-settings: 'wdth' 90;
}
.chapter__n {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--accent);
  border-radius: var(--r-pill);
  padding: 1px 8px;
}
.chapter__b {
  margin-left: auto;
  max-width: 36ch;
  text-align: right;
  font-size: 13.5px;
  color: var(--text-3);
}

.modules { display: flex; flex-direction: column; gap: 18px; }

.empty {
  padding: 34px 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
}

/* ═══ MODULE — one project, as a rack unit ═══════════════════════════ */
.module {
  border: 1px solid var(--border);
  border-radius: var(--r-struct);
  background: var(--bg-panel);
  box-shadow: inset 0 1px 0 var(--hi);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.module:hover { border-color: var(--border-strong); background: var(--bg-raised); }
.module[hidden] { display: none; }

.module__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(var(--bg-raised), transparent);
}
.module__num {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: .6px;
}
.module__name {
  font-size: 17px;
  font-weight: 620;
  letter-spacing: -.5px;
  font-variation-settings: 'wdth' 92;
}
.module__name a { position: relative; }
.module__name a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -3px;
  height: 1.5px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur) var(--ease);
}
.module:hover .module__name a::after { transform: scaleX(1); }

/* Level meter — animates on hover/focus only, never on a loop */
.meter { display: flex; align-items: flex-end; gap: 2px; height: 14px; margin-left: auto; }
.meter i {
  width: 2.5px;
  height: 3px;
  border-radius: .5px;
  background: var(--border-strong);
  transition: height .28s var(--ease), background-color .28s var(--ease);
}
.module:hover .meter i, .module:focus-within .meter i { background: var(--accent); }
.module:hover .meter i:nth-child(1), .module:focus-within .meter i:nth-child(1) { height: 6px;  transition-delay: 0ms; }
.module:hover .meter i:nth-child(2), .module:focus-within .meter i:nth-child(2) { height: 11px; transition-delay: 40ms; }
.module:hover .meter i:nth-child(3), .module:focus-within .meter i:nth-child(3) { height: 14px; transition-delay: 80ms; }
.module:hover .meter i:nth-child(4), .module:focus-within .meter i:nth-child(4) { height: 8px;  transition-delay: 120ms; }
.module:hover .meter i:nth-child(5), .module:focus-within .meter i:nth-child(5) { height: 4px;  transition-delay: 160ms; }

.led {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--text-3);
}
.led::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: var(--r-pill);
  background: var(--live);
  transition: box-shadow var(--dur) var(--ease);
}
.module:hover .led::before { box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 26%, transparent); }
.led--ver::before { background: var(--text-3); }
.module:hover .led--ver::before { box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-3) 26%, transparent); }

.module__main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 400px);
  gap: 28px;
  padding: 22px;
}
.module__info { display: flex; flex-direction: column; align-items: flex-start; }
.module__desc { color: var(--text-2); font-size: 15px; max-width: 48ch; }

.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 16px; }
.tag {
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg-raised);
  color: var(--text-3);
  padding: 2px 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .2px;
  cursor: pointer;
  transition: color var(--dur-s) var(--ease), border-color var(--dur-s) var(--ease), transform var(--dur-s) var(--ease);
}
.tag:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }
.tag[aria-pressed='true'] { color: var(--accent); border-color: var(--accent); }

.aside {
  margin-top: 16px;
  padding-left: 12px;
  border-left: 2px solid var(--accent);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-3);
  max-width: 46ch;
}

/* Bottom-aligned so the action row lands level with the plate's caption.
   The hairline turns the space that leaves above it into a deliberate
   module footer rather than a hole. */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.go {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-ctrl);
  background: var(--bg-raised);
  color: var(--text);
  padding: 8px 13px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .5px;
  text-transform: uppercase;
  transition: color var(--dur-s) var(--ease), border-color var(--dur-s) var(--ease), transform var(--dur-s) var(--ease);
}
.go svg { transition: transform var(--dur) var(--ease); }
.go:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }
.go:hover svg { transform: translateX(4px); }
.go:active { transform: translateY(0) scale(.97); }
.go--ghost { background: none; border-color: var(--border); color: var(--text-2); }

/* ── Plate: the screenshot, mounted in a recessed well ─────────────── */
.plate { position: relative; }
.plate__mount {
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-struct);
  background: var(--bg-inset);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .16);
  padding: 8px;
}
.plate__mount img {
  width: 100%;
  /* height:auto is load-bearing — the width/height attributes that stop the
     layout shifting also pin a used height of 750px, which aspect-ratio
     cannot override while both dimensions are non-auto. */
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top center;
  border-radius: 1px;
  background: var(--bg-sunk);
  transition: transform .7s var(--ease-out), filter var(--dur) var(--ease);
  filter: saturate(.92);
}
.module:hover .plate__mount img { transform: scale(1.035); filter: saturate(1); }

/* the sweep, again — a light bar crossing the plate on hover */
.plate__mount::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(104deg, transparent 34%, color-mix(in srgb, var(--accent) 22%, transparent) 50%, transparent 66%);
  transform: translateX(-110%);
  transition: transform .85s var(--ease);
  pointer-events: none;
}
.module:hover .plate__mount::after { transform: translateX(110%); }

.plate__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
}
.plate__host { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peek {
  margin-left: auto;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: var(--r-ctrl);
  background: var(--bg-raised);
  color: var(--text-3);
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .6px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--dur-s) var(--ease), border-color var(--dur-s) var(--ease);
}
.peek:hover { color: var(--accent); border-color: var(--accent); }

/* ── The one plate with no screenshot: Aether's live CC readout ─────── */
.cc {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 1px;
  background:
    repeating-linear-gradient(90deg, transparent 0 23px, color-mix(in srgb, var(--text) 5%, transparent) 23px 24px),
    var(--bg-sunk);
  cursor: crosshair;
  touch-action: none;
}
.cc__rings { position: absolute; inset: 0; display: grid; place-items: center; }
.cc__rings span {
  position: absolute;
  width: 50%;
  aspect-ratio: 1;
  border: 1px solid var(--app);
  border-radius: var(--r-pill);
  opacity: .3;
  transition: transform .4s var(--ease-out), opacity .4s var(--ease);
}
.cc__rings span:nth-child(2) { width: 34%; opacity: .45; }
.cc__rings span:nth-child(3) { width: 18%; opacity: .6; }
.cc__cross {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--app);
  opacity: .55;
  transform: translateX(-50%);
  transition: left .06s linear;
}
.cc__read {
  position: absolute;
  left: 12px; bottom: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--app);
  font-variant-numeric: tabular-nums;
  letter-spacing: .5px;
}
.cc__bar {
  position: absolute;
  left: 12px; right: 12px; bottom: 6px;
  height: 2px;
  background: color-mix(in srgb, var(--app) 22%, transparent);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.cc__bar i { display: block; height: 100%; background: var(--app); width: 50%; transition: width .06s linear; }
.cc__hint {
  position: absolute;
  top: 10px; left: 12px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ═══ INLINE CONTROLS (mobile only) ══════════════════════════════════ */
.inline-controls { display: none; }
.chips--scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips--scroll::-webkit-scrollbar { display: none; }

/* ═══ COLOPHON ════════════════════════════════════════════════════════ */
.colophon {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 88px;
  padding-top: 26px;
  border-top: 2px solid var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-3);
}
.colophon b {
  display: block;
  margin-bottom: 4px;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 620;
  letter-spacing: -.3px;
  color: var(--text);
}
.colophon__r { display: flex; flex-direction: column; gap: 3px; text-align: right; }

/* ═══ DIALOGS ═════════════════════════════════════════════════════════ */
dialog { border: 0; padding: 0; color: var(--text); background: transparent; }
dialog::backdrop { background: var(--overlay); backdrop-filter: blur(3px); }
dialog[open] { animation: pop-in .26s var(--ease-out); }

/* Command palette */
.palette {
  width: min(560px, calc(100vw - 32px));
  margin: 12vh auto auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-dialog);
  background: var(--bg-panel);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.palette__in {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
}
.palette__in input {
  flex: 1;
  border: 0;
  background: none;
  outline: none;
  font-size: 15px;
  color: var(--text);
}
.palette__in input::placeholder { color: var(--text-3); }
.palette__list { list-style: none; max-height: 46vh; overflow-y: auto; padding: 6px; }
.palette__row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--r-ctrl);
  cursor: pointer;
  font-size: 14px;
}
.palette__row[aria-selected='true'] { background: var(--bg-raised); }
.palette__row[aria-selected='true'] .palette__k { color: var(--accent); }
.palette__row-t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette__row-s { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); flex: none; }
.palette__k { color: var(--text-3); display: flex; flex: none; }
.palette__none { padding: 26px 12px; text-align: center; font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.palette__foot {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-3);
}

/* Lightbox */
.light {
  width: min(1100px, calc(100vw - 32px));
  margin: auto;
  background: transparent;
}
.light__f {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-dialog);
  background: var(--bg-panel);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.light__f img { width: 100%; height: auto; background: var(--bg-sunk); }
.light__f figcaption {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 15px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
}
.light__f figcaption span:first-child { color: var(--text); font-weight: 500; }
.light__x {
  position: fixed;
  top: 18px; right: 18px;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--r-ctrl);
  background: var(--bg-panel);
  color: var(--text-2);
  cursor: pointer;
}
.light__x:hover { color: var(--text); border-color: var(--border-strong); }

/* About */
.about {
  width: min(340px, calc(100vw - 32px));
  margin: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-dialog);
  background: var(--bg-panel);
  box-shadow: var(--shadow-pop);
  padding: 26px 28px;
  text-align: left;
}
.about h2 { font-size: 20px; font-weight: 620; letter-spacing: -.5px; }
.about__v { margin-top: 4px; font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.about__c { margin-top: 18px; font-size: 14px; color: var(--text-2); }
.about__c a { color: var(--accent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.about__c a:hover { border-bottom-color: var(--accent); }
.about__x { margin-top: 22px; }

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════ */

/* Tablet: keep the rail, tighten the module split */
@media (max-width: 1180px) {
  .module__main { grid-template-columns: minmax(0, 1fr) minmax(0, 330px); gap: 22px; }
  .stage { padding: 0 28px 72px; }
}

/* The rail flattens into a sticky top bar */
@media (max-width: 1080px) {
  html { scroll-padding-top: 78px; }

  .rail {
    position: sticky;
    top: 0; left: auto; bottom: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    width: auto;
    padding: 10px 18px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow: visible;
  }
  .rail__top { flex: 1; flex-direction: row; align-items: center; justify-content: space-between; gap: 14px; }
  .rail__meter { width: 132px; height: 18px; flex: none; }
  .rail__nav, .rail__filters, .rail__foot { display: none; }

  .stage { margin-left: 0; padding: 0 22px 72px; max-width: none; }
  .hero { padding: 40px 0 0; }

  .inline-controls {
    display: block;
    margin-top: 34px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
  }

  .module__main { grid-template-columns: 1fr; gap: 20px; }
  .plate { order: -1; }           /* image first — it is the strongest hook */
  .actions { padding-top: 18px; }
  .module__desc, .aside { max-width: none; }
}

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .chapter { flex-wrap: wrap; margin-top: 64px; }
  .chapter__b { margin: 6px 0 0; text-align: left; max-width: none; }
  .seq__swipe { display: block; }
  .seq__controls { gap: 14px; }
  .seq__btns { margin-left: 0; width: 100%; }
  .seq__btns .btn { flex: 1; justify-content: center; }
  .colophon__r { text-align: left; }
}

@media (max-width: 560px) {
  .stage { padding: 0 16px 56px; }
  .rail { padding: 9px 14px; }
  .rail__meter { display: none; }   /* the transport button stays; the strip does not fit */
  .mark__text { font-size: 14px; }
  .hero__h { letter-spacing: -1.4px; }
  .seq__body { padding: 13px; }
  .module__bar { height: auto; padding: 10px 12px; flex-wrap: wrap; gap: 8px 10px; }
  .meter { display: none; }
  .module__main { padding: 16px; }
  .light__x { top: auto; bottom: 18px; right: 50%; transform: translateX(50%); }
}

/* ═══ REDUCED MOTION ══════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .reveal, .reveal.in { opacity: 1; animation: none; }
  body::after { animation: none; }
}

/* ═══ TR-808 GRID ═════════════════════════════════════════════════════
   Seventeen lanes — the accent track plus all sixteen voices. Lanes are
   coloured by family, so the panel reads by function the way the real
   machine's colour-coded groups do.
   ═══════════════════════════════════════════════════════════════════ */
.seq__lane[data-fam='accent'] { --lane: var(--text); }
.seq__lane[data-fam='drum']   { --lane: var(--audio); }
.seq__lane[data-fam='tom']    { --lane: color-mix(in srgb, var(--audio) 74%, var(--bg-panel)); }
.seq__lane[data-fam='conga']  { --lane: color-mix(in srgb, var(--audio) 48%, var(--bg-panel)); }
.seq__lane[data-fam='perc']   { --lane: var(--text-2); }
.seq__lane[data-fam='metal']  { --lane: var(--app); }

/* A hairline where the family changes — grouping without extra chrome */
.seq__lane[data-lane='bd'],
.seq__lane[data-lane='lt'],
.seq__lane[data-lane='lc'],
.seq__lane[data-lane='rs'],
.seq__lane[data-lane='cy'] {
  padding-top: 5px;
  margin-top: 1px;
  border-top: 1px solid var(--border);
}

/* The accent row is a control track, not a voice — hold it slightly apart */
.seq__lane[data-lane='ac'] .seq__lane-name { color: var(--text); font-weight: 700; }
.seq__lane[data-lane='ac'] .cell[aria-pressed='true'] { opacity: .78; }

.seq__lane-name abbr { text-decoration: none; cursor: help; }

/* Seventeen rows need tighter cells than three did. aspect-ratio:1 was
   right for three lanes; here it made every cell 52px square and the panel
   over 1100px tall, so the step height is fixed and the width just stretches
   — which is how a step sequencer with this many lanes normally reads. */
.seq__lane-cells .cell { aspect-ratio: auto; height: 21px; min-height: 0; }
.seq__lanes { gap: 2px; }
.seq__lane { gap: 7px; }
.seq__lane-name { width: 30px; letter-spacing: .8px; }
.seq__ruler { margin-left: 37px; }
.seq__ruler, .seq__lane-cells { gap: 3px; }
.cell { min-height: 17px; border-radius: 1px; }

.seq__source {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
}
.linkish {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.linkish:hover { border-bottom-color: var(--accent); }

@media (max-width: 720px) {
  .seq__lane-name { width: 26px; font-size: 9px; }
  .seq__ruler { margin-left: 33px; }
}

/* "TR-808" must not break across two lines when the bar gets tight */
.panel__t { white-space: nowrap; }
@media (max-width: 560px) {
  .panel__sub { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════
   ROLAND TR-808 FACEPLATE
   The instrument stops being a page panel and becomes hardware. Its
   colours are fixed in both themes on purpose — a drum machine does not
   have a light mode, and a dark instrument sitting on a light desk reads
   as a product shot rather than a bug. The page around it still themes.

   The signature detail is the step buttons: on the real machine the
   sixteen keys run RED / ORANGE / YELLOW / IVORY in groups of four, which
   is exactly how a 16-step grid wants to be divided anyway.
   ═══════════════════════════════════════════════════════════════════════ */
:root {
  --tr-face-hi:   #4a4e56;
  --tr-face:      #3b3f46;
  --tr-face-lo:   #303338;
  --tr-well:      #17181c;
  --tr-edge:      #121316;
  --tr-silk:      #e6e3da;   /* silkscreen white */
  --tr-silk-dim:  #c4c2ba;
  --tr-orange:    #ef6a24;   /* the TR accent stripe — decorative only */
  --tr-orange-tx: #f7b18c;   /* the same accent, lifted to clear AA as text */
  --tr-lamp:      #ff4632;

  --tr-red:       #d8452d;
  --tr-red-tx:    #dc5741;   /* step numeral; the cap colour is too dark to read */
  --tr-amber:     #e5812c;
  --tr-yellow:    #dfb236;
  --tr-ivory:     #ddd7c6;
}

/* ── The case ────────────────────────────────────────────────────────── */
.seq.panel {
  border: 1px solid var(--tr-edge);
  border-radius: 4px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.016) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, var(--tr-face-hi) 0%, var(--tr-face) 14%, var(--tr-face-lo) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.14),
    inset 0 -1px 0 rgba(0,0,0,.5),
    0 22px 44px -26px rgba(0,0,0,.75);
}

/* ── Branding strip ──────────────────────────────────────────────────── */
.tr__bar {
  height: auto;
  gap: 14px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--tr-edge);
  background: linear-gradient(180deg, rgba(255,255,255,.05), transparent);
}
.tr__bar .screw {
  background: #24262a;
  box-shadow: inset 0 1px 1px rgba(0,0,0,.7), 0 1px 0 rgba(255,255,255,.12);
}
.tr__brand { display: flex; flex-direction: column; line-height: 1.15; }
.tr__maker {
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -.2px;
  color: var(--tr-silk);
}
.tr__kind {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--tr-silk-dim);
}
/* The model number, sat on the orange stripe the way the hardware wears it */
.tr__model {
  position: relative;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 2.4px;
  color: var(--tr-silk);
  padding: 3px 10px 3px 12px;
  white-space: nowrap;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.18));
  border-left: 3px solid var(--tr-orange);
  border-radius: 0 2px 2px 0;
}
/* Run lamp */
.tr__power {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--tr-silk-dim);
}
.tr__power::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: var(--r-pill);
  background: #4d2620;
  box-shadow: inset 0 1px 1px rgba(0,0,0,.6);
  transition: background-color var(--dur-s) var(--ease), box-shadow var(--dur-s) var(--ease);
}
.tr__power.on { color: var(--tr-silk); }
.tr__power.on::before {
  background: var(--tr-lamp);
  box-shadow: 0 0 8px rgba(255,70,50,.85), inset 0 1px 1px rgba(255,255,255,.35);
}

/* ── The step panel: a recessed black well, as on the machine ────────── */
.seq .seq__grid-wrap {
  border: 1px solid var(--tr-edge);
  border-radius: 3px;
  background: var(--tr-well);
  box-shadow: inset 0 3px 10px rgba(0,0,0,.75), 0 1px 0 rgba(255,255,255,.07);
  padding: 12px 12px 10px;
}

/* ── LED strip + step numbers ────────────────────────────────────────── */
.seq .seq__ruler { align-items: end; margin-bottom: 8px; }
.seq .seq__ruler .rul {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.seq .seq__ruler .lamp {
  width: 6px; height: 6px;
  border-radius: var(--r-pill);
  background: #401f1b;
  box-shadow: inset 0 1px 1px rgba(0,0,0,.7);
  transition: background-color .07s linear, box-shadow .07s linear;
}
.seq .seq__ruler .lamp.lit {
  background: var(--tr-lamp);
  box-shadow: 0 0 7px rgba(255,70,50,.9), inset 0 1px 1px rgba(255,255,255,.4);
}
.seq .seq__ruler b {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 500;
  color: var(--tr-silk-dim);
  font-variant-numeric: tabular-nums;
}
.seq .seq__ruler .rul[data-g='0'] b { color: var(--tr-red-tx); }
.seq .seq__ruler .rul[data-g='1'] b { color: var(--tr-amber); }
.seq .seq__ruler .rul[data-g='2'] b { color: var(--tr-yellow); }
.seq .seq__ruler .rul[data-g='3'] b { color: var(--tr-ivory); }

/* ── Step buttons: the 808's four-colour banding ─────────────────────── */
.seq .cell[data-g='0'] { --step: var(--tr-red); }
.seq .cell[data-g='1'] { --step: var(--tr-amber); }
.seq .cell[data-g='2'] { --step: var(--tr-yellow); }
.seq .cell[data-g='3'] { --step: var(--tr-ivory); }

.seq .seq__lane-cells .cell {
  border: 0;
  border-radius: 2px;
  height: 21px;
  background: color-mix(in srgb, var(--step) 9%, #1e2025);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.09),
    inset 0 -1px 0 rgba(0,0,0,.55);
  transition: background-color .09s linear, box-shadow .09s linear, transform .09s var(--ease);
}
.seq .seq__lane-cells .cell:hover {
  background: color-mix(in srgb, var(--step) 30%, #1e2025);
  transform: none;
}
.seq .seq__lane-cells .cell[aria-pressed='true'] {
  background: var(--step);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.45),
    inset 0 -2px 3px rgba(0,0,0,.28),
    0 0 9px color-mix(in srgb, var(--step) 40%, transparent);
}
/* Playhead reads as the lamp above it: a bright rim, not a colour change */
.seq .seq__lane-cells .cell.now {
  box-shadow:
    inset 0 0 0 1.5px rgba(255,255,255,.42),
    inset 0 1px 0 rgba(255,255,255,.22);
}
.seq .seq__lane-cells .cell[aria-pressed='true'].now {
  box-shadow:
    inset 0 0 0 1.5px #fff,
    0 0 14px color-mix(in srgb, var(--step) 70%, transparent);
}
.seq .cell.fire { transform: scale(1.14); }

/* Accent is a control track, not a voice — ivory across the whole row */
.seq .seq__lane[data-lane='ac'] .cell { --step: var(--tr-ivory); }

/* ── Silkscreen voice labels ─────────────────────────────────────────── */
.seq .seq__lane-name {
  color: var(--tr-silk-dim);
  font-weight: 700;
  font-size: 9px;
}
.seq .seq__lane[data-lane='ac'] .seq__lane-name { color: var(--tr-orange); }
.seq .seq__lane[data-fam='drum'] .seq__lane-name,
.seq .seq__lane[data-fam='metal'] .seq__lane-name { color: var(--tr-silk); }
.seq .seq__lane { border-top-color: rgba(255,255,255,.07) !important; }

/* ── Controls, as hardware ───────────────────────────────────────────── */
.seq .btn {
  border: 1px solid var(--tr-edge);
  border-radius: 3px;
  color: var(--tr-silk);
  background: linear-gradient(180deg, #52565e, #3f434a);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 1px 2px rgba(0,0,0,.5);
  font-size: 10px;
  letter-spacing: 1px;
}
.seq .btn:hover { background: linear-gradient(180deg, #5c6068, #474b53); color: #fff; border-color: var(--tr-edge); }
.seq .btn:active { background: linear-gradient(180deg, #3a3e45, #4a4e56); box-shadow: inset 0 2px 4px rgba(0,0,0,.55); transform: none; }
.seq .btn::after { display: none; }

/* Start/stop is the one ivory key on the panel */
.seq .btn--primary {
  color: #22242a;
  background: linear-gradient(180deg, #f2eee1, #d9d3c1);
  border-color: #a49d89;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 2px 3px rgba(0,0,0,.45);
}
.seq .btn--primary:hover { background: linear-gradient(180deg, #fffdf5, #e4dfcf); color: #000; }
.seq .btn--primary[aria-pressed='true'] {
  color: #fff;
  background: linear-gradient(180deg, #f0703a, #d9501f);
  border-color: #8f3512;
}

/* Tempo, as a panel fader */
.seq .tempo__l, .seq .seq__note, .seq .seq__swipe, .seq .seq__source { color: var(--tr-silk-dim); }
.seq .tempo__v { color: var(--tr-silk); }
.seq .tempo__v i { color: var(--tr-silk-dim); }
.seq input[type='range']::-webkit-slider-runnable-track {
  background: #16171b;
  border: 1px solid var(--tr-edge);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.8);
}
.seq input[type='range']::-webkit-slider-thumb {
  width: 13px; height: 20px;
  margin-top: -9px;
  border-radius: 2px;
  background: linear-gradient(180deg, #f2eee1, #cfc9b7);
  border: 1px solid #8d8674;
  box-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.seq input[type='range']::-moz-range-track { background: #16171b; border: 1px solid var(--tr-edge); }
.seq input[type='range']::-moz-range-thumb {
  width: 11px; height: 18px; border-radius: 2px;
  background: linear-gradient(180deg, #f2eee1, #cfc9b7); border: 1px solid #8d8674;
}
.seq .linkish { color: var(--tr-orange-tx); border-bottom-color: rgba(239,106,36,.6); }
.seq .linkish:hover { border-bottom-color: var(--tr-orange-tx); }

@media (max-width: 560px) {
  .tr__model { font-size: 11px; letter-spacing: 1.6px; }
  .tr__kind { display: none; }
}

/* ═══ SEGMENTED CONTROLS ══════════════════════════════════════════════ */
.seg {
  display: inline-flex;
  flex: none;
  border: 1px solid var(--tr-edge);
  border-radius: 3px;
  overflow: hidden;
  background: #16171b;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.6);
}
.seg__b {
  border: 0;
  padding: 5px 11px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #b4b1a9;
  background: transparent;
  cursor: pointer;
  transition: color var(--dur-s) var(--ease), background-color var(--dur-s) var(--ease);
}
.seg__b + .seg__b { border-left: 1px solid var(--tr-edge); }
.seg__b:hover { color: #fff; background: rgba(255,255,255,.08); }
.seg__b[aria-pressed='true'] {
  color: #1b1d21;
  background: linear-gradient(180deg, #f2eee1, #d9d3c1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.85);
}
.seg--machine .seg__b[aria-pressed='true'] {
  color: #fff;
  /* darkened from the panel orange so white type clears AA on it */
  background: linear-gradient(180deg, #ba572d, #c94a1d);
}

.seg-pair { display: inline-flex; flex: none; align-items: center; gap: 8px; }
.seg-pair__l {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--tr-silk-dim);
}
.src-note {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .6px;
  color: var(--tr-silk-dim);
  min-width: 0;
}

/* ═══ TR-909: the other machine wears the other case ══════════════════
   Where the 808 is charcoal with warm step caps, the 909 is the pale
   silver box with a near-black step well — so switching machines is
   visible before a note is played.
   ═══════════════════════════════════════════════════════════════════ */
.seq[data-machine='909'] {
  --tr-face-hi:  #cfccc5;
  --tr-face:     #bcb9b2;
  --tr-face-lo:  #a9a69f;
  --tr-edge:     #6b6862;
  --tr-silk:     #1c1e22;      /* dark silkscreen on a light panel */
  --tr-silk-dim: #3a3b3e;
  --tr-orange:   #d2401d;
  --tr-orange-tx:#6e1f0a;

  /* The 909's step keys are not banded like the 808's — they are uniform
     caps that light. One accent colour across all sixteen. */
  --tr-red:      #e8e4d8;
  --tr-amber:    #e8e4d8;
  --tr-yellow:   #e8e4d8;
  --tr-ivory:    #e8e4d8;
  --tr-red-tx:   #d8d4c8;
}
.seq[data-machine='909'] .tr__bar .screw { background: #8f8c85; box-shadow: inset 0 1px 1px rgba(0,0,0,.45), 0 1px 0 rgba(255,255,255,.5); }
.seq[data-machine='909'] .tr__model { color: #f4f1e8; background: linear-gradient(180deg, #3a3c40, #2a2c30); border-left-color: var(--tr-orange); }
.seq[data-machine='909'] .seq__lane-name { color: #cdc9bf; }
.seq[data-machine='909'] .seq__lane[data-fam='drum'] .seq__lane-name,
.seq[data-machine='909'] .seq__lane[data-fam='metal'] .seq__lane-name { color: #f2efe6; }
.seq[data-machine='909'] .seq__lane[data-lane='ac'] .seq__lane-name { color: #ff8b5e; }
.seq[data-machine='909'] .cell[aria-pressed='true'] {
  background: linear-gradient(180deg, #ff7a45, #e04a18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), inset 0 -2px 3px rgba(0,0,0,.3), 0 0 9px rgba(224,74,24,.45);
}
.seq[data-machine='909'] .seq__lane[data-lane='ac'] .cell[aria-pressed='true'] {
  background: linear-gradient(180deg, #f2eee1, #d5cfbd);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9), inset 0 -2px 3px rgba(0,0,0,.22);
}
.seq[data-machine='909'] .btn {
  color: var(--tr-silk);
  background: linear-gradient(180deg, #e6e3da, #c8c5bd);
  border-color: #6b6862;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 1px 2px rgba(0,0,0,.35);
}
.seq[data-machine='909'] .btn:hover { background: linear-gradient(180deg, #f2efe8, #d4d1c9); color: #000; }
.seq[data-machine='909'] .btn--primary { background: linear-gradient(180deg, #3d4046, #2b2e33); color: #f4f1e8; border-color: #23262a; }
.seq[data-machine='909'] .btn--primary:hover { background: linear-gradient(180deg, #4a4d54, #35383e); color: #fff; }
.seq[data-machine='909'] .btn--primary[aria-pressed='true'] { background: linear-gradient(180deg, #f0703a, #d9501f); color: #fff; }
.seq[data-machine='909'] .seg__b[aria-pressed='true'] { color: #1b1d21; background: linear-gradient(180deg, #ffffff, #e2dfd6); }
.seq[data-machine='909'] input[type='range']::-webkit-slider-thumb { background: linear-gradient(180deg, #3d4046, #2b2e33); border-color: #23262a; }
.seq[data-machine='909'] input[type='range']::-moz-range-thumb { background: linear-gradient(180deg, #3d4046, #2b2e33); border-color: #23262a; }

@media (max-width: 720px) {
  .seg-pair { gap: 6px; }
  .src-note { flex-basis: 100%; }
}
@media (max-width: 560px) {
  .tr__bar { flex-wrap: wrap; row-gap: 8px; }
  .tr__bar .panel__spacer { display: none; }
  .seg__b { padding: 5px 9px; }
}

/* ═══ 32 STEPS, SHOWN SIXTEEN AT A TIME ═══════════════════════════════
   All 32 cells are in the DOM; the half you are not looking at is simply
   not displayed. Keeping them all rendered means the cell list and the
   playhead index stay valid across an A/B flip — nothing is rebuilt.
   ═══════════════════════════════════════════════════════════════════ */
#seq-lanes[data-view='0'] .cell[data-h='1'] { display: none; }
#seq-lanes[data-view='1'] .cell[data-h='0'] { display: none; }

/* The A/B keys show which half is currently sounding */
.seg__b.live::after {
  content: "";
  display: inline-block;
  width: 4px; height: 4px;
  margin-left: 5px;
  vertical-align: middle;
  border-radius: var(--r-pill);
  background: var(--tr-lamp);
  box-shadow: 0 0 5px rgba(255,70,50,.9);
}

/* Waiting on the sample kit before the first bar */
.btn.busy { opacity: .65; pointer-events: none; }
.btn.busy .transport__t::after {
  content: "…";
}
