/* Layout: a dark page (dark only, v31); the instrument (scope, sequencer,
   level panel) sits on dark hardware panels. One accent at a time, the ping:
   each kit has its own (House magenta, Trap green, Boom bap yellow, Lo-fi blue),
   set by app.js as data-kit on <html>; a sonar wave carries a change across the page. */
:root {
  --bg: #0a1519;
  --surface: #0f1e24;
  --ink: #e1ebee;
  --muted: #93a8b0;
  --line: #213740;
  /* kit accent, House by default: the ping, its lighter page shade
     (pings, accent text), the filled-control gradient and its text */
  --k-ping: #ff2f72;
  --k-ping-d: #ff4f8b;
  --accent-hi: #f0246a;
  --accent-lo: #d4145c;
  --accent-top: #ff5c93;
  --now-hi: #ffa3c2;
  --on-accent: #ffffff;
  --accent-shade: rgb(120 0 40 / 0.25);
  --ping: var(--k-ping-d);
  --ping-ink: #0e1c23;
  --accent-text: var(--k-ping-d);
  --page-glow: 1;
  --kit-on: #13262e;
  --track: #2a4552;

  --device: #13262e;
  --device-2: #1b313b;
  --device-2b: #213943;
  --device-3: #2b4957;
  --device-line: #2a4552;
  --device-ink: #dce8eb;
  --device-muted: #8ba3ab;
  --ok: #7fd1a8;

  --scope-bg: #0b1a20;
  --scope-bg-2: #12303a;
  --scope-grid: #1d3540;
  --scope-line: #355a6a;
  --scope-dim: #3a5966;
  --scope-text: #6f8e99;

  --display: 'Big Shoulders Display', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --ui: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Plus Jakarta Sans', system-ui, sans-serif;

  --gutter: clamp(16px, 3.2vw, 64px);
  --max: 1920px;
  --head: clamp(61px, 3.7vw, 95px); /* header height */
  --r: 10px;
  color-scheme: dark;
}
:root[data-kit='trap'] {
  --k-ping: #02e36a; --k-ping-d: #04ee70;
  /* neon green and yellow are too light for white text, so their filled controls take dark text */
  --accent-hi: #02e36a; --accent-lo: #02c55c; --accent-top: #5af88a; --now-hi: #acf6bb;
  --on-accent: #052a14; --accent-shade: rgb(255 255 255 / 0.25);
}
:root[data-kit='boombap'] {
  --k-ping: #ffe318; --k-ping-d: #ffea6b;
  --accent-hi: #fbdf0a; --accent-lo: #ecc300; --accent-top: #fff19c; --now-hi: #fff4b1;
  --on-accent: #2a2200; --accent-shade: rgb(255 255 255 / 0.3);
}
:root[data-kit='lofi'] {
  --k-ping: #508cfe; --k-ping-d: #6197fe;
  --accent-hi: #3d7fff; --accent-lo: #2369f2; --accent-top: #699dfe; --now-hi: #a3c3fe;
  --on-accent: #ffffff; --accent-shade: rgb(10 40 110 / 0.25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--ui);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ping); outline-offset: 2px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 0.9; letter-spacing: 0.01em; text-transform: uppercase; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(34px, 4.6vw, 96px); line-height: 0.92; }
h1 span { display: block; white-space: nowrap; }
h2 { font-size: clamp(40px, 5vw, 72px); }
h3 { font-size: 30px; letter-spacing: 0.02em; }
.mono-label { font: 500 11px/1.2 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

/* ---------- header ---------- */
.site-head {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--head);
  padding: 0 max(var(--gutter), calc((100% - var(--max)) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; font: 800 clamp(30px, 2.34vw, 60px)/1 var(--display); letter-spacing: 0.07em; text-transform: uppercase; }
.site-nav { display: flex; gap: clamp(4px, 1.9vw, 48px); }
.site-nav a { color: var(--ink); text-decoration: none; font: 500 clamp(12px, 0.94vw, 24px)/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; padding: 0.84em 1em; border-radius: 8px; }
.site-nav a:hover { background: var(--surface); }

main > section { scroll-margin-top: var(--head);
  padding: clamp(40px, 6vw, 88px) var(--gutter) 0; max-width: calc(var(--max) + 2 * var(--gutter)); margin: 0 auto; }

/* ---------- hero: fits one screen ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
  gap: clamp(32px, 5vw, 112px);
  align-items: center;
  min-height: calc(100svh - var(--head));
  /* sits a little above the middle of the screen */
  padding-top: 0 !important;
  padding-bottom: clamp(20px, 4vw, 104px) !important;
}
/* The intro grows with its column: --s is a scaled pixel, 1px at a 669px
   column up to 1.5px on wide screens (zan's sizes at 2560 px); the kit cards
   grow a bit less (--sk) and the kit label a bit more (--sl). */
.intro { display: grid; gap: clamp(26px, 1.55vw, 40px); min-width: 0; container-type: inline-size; }
.intro > * { --s: clamp(1px, calc(100cqi / 669), 1.5px); --sk: calc(1px + (var(--s) - 1px) * 0.54); --sl: calc(1px + (var(--s) - 1px) * 1.02); }
.hero h1 { font-size: clamp(34px, calc(100cqi / 9.45), 112px); }
.lede { margin: 0; max-width: 31em; font-size: clamp(17px, calc(2.493cqi - 0.675px), 26px); line-height: 1.6; color: var(--muted); }

.transport { display: flex; flex-wrap: wrap; align-items: center; gap: calc(14 * var(--s)) calc(28 * var(--s)); }
.hero .btn-play { height: calc(54 * var(--s)); padding: 0 calc(26 * var(--s)) 0 calc(8 * var(--s)); border-radius: calc(27 * var(--s)); gap: calc(12 * var(--s)); font-size: calc(17 * var(--s)); }
.hero .play-ico { width: calc(38 * var(--s)); height: calc(38 * var(--s)); }
.hero .play-ico::before { border-left-width: calc(12 * var(--s)); border-top-width: calc(7.5 * var(--s)); border-bottom-width: calc(7.5 * var(--s)); margin-left: calc(3 * var(--s)); }
.hero .btn-play[aria-pressed='true'] .play-ico::before { width: calc(11 * var(--s)); height: calc(11 * var(--s)); margin-left: 0; }
.hero .knob { min-width: calc(170 * var(--s)); gap: calc(8 * var(--s)); }
.hero .knob-name { font-size: calc(11 * var(--s)); }
.hero .knob-val { font-size: calc(13 * var(--s)); }
.hero input[type='range'] { height: calc(22 * var(--s)); }
.hero input[type='range']::-webkit-slider-runnable-track { height: calc(4 * var(--s)); border-radius: calc(2 * var(--s)); }
.hero input[type='range']::-webkit-slider-thumb { width: calc(20 * var(--s)); height: calc(20 * var(--s)); margin-top: calc(-8 * var(--s)); box-shadow: inset 0 0 0 calc(5 * var(--s)) var(--accent-hi), 0 2px 6px rgb(14 28 35 / 0.3); }
.hero input[type='range']::-moz-range-track, .hero input[type='range']::-moz-range-progress { height: calc(4 * var(--s)); }
.hero input[type='range']::-moz-range-thumb { width: calc(20 * var(--s)); height: calc(20 * var(--s)); box-shadow: inset 0 0 0 calc(5 * var(--s)) var(--accent-hi), 0 2px 6px rgb(14 28 35 / 0.3); }
.btn-play, .btn-solid {
  border: 0;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
  color: var(--on-accent);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.28), 0 10px 22px -12px color-mix(in srgb, var(--accent-lo) 75%, transparent);
  text-shadow: 0 1px 0 var(--accent-shade);
}
.btn-play:hover, .btn-solid:hover { filter: brightness(1.07); }
.btn-play:active, .btn-solid:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.2), 0 4px 10px -6px color-mix(in srgb, var(--accent-lo) 70%, transparent); }
.btn-play {
  display: inline-flex; align-items: center; gap: 12px;
  height: 54px; padding: 0 26px 0 8px;
  border-radius: 27px;
  font-weight: 700; font-size: 17px; letter-spacing: 0.01em;
}

.play-ico {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: rgb(255 255 255 / 0.17); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.25);
}
.play-ico::before { content: ''; width: 0; height: 0; border-left: 12px solid currentColor; border-top: 7.5px solid transparent; border-bottom: 7.5px solid transparent; margin-left: 3px; }
.btn-play[aria-pressed='true'] .play-ico::before { width: 11px; height: 11px; border: 0; background: currentColor; border-radius: 2px; margin-left: 0; }
.knob { display: grid; gap: 8px; min-width: 170px; }
.knob label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.knob-name { font: 500 11px/1.2 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.knob-val { font: 400 13px/1.2 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.knob output { color: var(--ink); font-weight: 600; }

/* sliders: a thin track filled in magenta up to a white thumb (--fill is set by app.js) */
input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; --fill: 50%; }
input[type='range']::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-hi) 0 var(--fill), var(--track) var(--fill) 100%);
}
input[type='range']::-moz-range-track { height: 4px; border-radius: 2px; background: var(--track); }
input[type='range']::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent-hi); }
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; border: 0;
  background: #fff; box-shadow: inset 0 0 0 5px var(--accent-hi), 0 2px 6px rgb(14 28 35 / 0.3);
}
input[type='range']::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; border: 0;
  background: #fff; box-shadow: inset 0 0 0 5px var(--accent-hi), 0 2px 6px rgb(14 28 35 / 0.3);
}

.kits { border: 0; padding: 0; margin: calc((var(--s) - 1px) * 40) 0 0; min-width: 0; }
.hero .kits legend { font-size: calc(11 * var(--sl)); margin-bottom: calc(10 * var(--sl)); }
.hero .kit-list { gap: calc(8 * var(--sk)); }
.hero .kit { padding: calc(12 * var(--sk)) calc(12 * var(--sk)) calc(13 * var(--sk)); gap: calc(4 * var(--sk)); }
.hero .kit-name { font-size: calc(15 * var(--sk)); gap: calc(8 * var(--sk)); }
.hero .kit-name::before { width: calc(7 * var(--sk)); height: calc(7 * var(--sk)); }
.hero .kit-meta { font-size: calc(11 * var(--sk)); padding-left: calc(15 * var(--sk)); }
.kits legend { font: 500 11px/1.2 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: 0; margin-bottom: 10px; }
.kit-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.kit {
  display: grid; gap: 4px; text-align: left; align-content: start; min-width: 0;
  padding: 12px 12px 13px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface);
}
.kit:hover { border-color: var(--muted); }
.kit.on { background: var(--kit-on); border-color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent-text), 0 8px 18px -12px color-mix(in srgb, var(--accent-lo) 60%, transparent); }
.kit-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.kit-name::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none; }
.kit.on .kit-name::before { background: var(--accent-hi); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-hi) 18%, transparent); }
.kit-meta { font: 400 11px/1.3 var(--mono); color: var(--muted); padding-left: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.scope-wrap { display: grid; justify-items: end; min-width: 0; }
.scope { width: min(100%, 470px); aspect-ratio: 1; max-width: 100%; display: block; }
/* round shadows as box shadows: a filter shadow was re-blurred on every frame the sonar drew */
.scope-wrap .scope { width: min(100%, 820px, calc(100svh - var(--head) - 64px)); border-radius: 50%; box-shadow: 0 26px 34px rgb(14 28 35 / 0.28); }
.scope-wrap .scope, .scope.mini { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* ---------- editor: heading, grid, mini sonar and live mix in one screen ---------- */
.studio { padding-top: clamp(20px, 2.4svh, 32px) !important; }
.studio h2 { font-size: clamp(32px, 4vw, 64px); }
.device-foot {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(16px, 2.4vw, 32px); align-items: center;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--device-line);
}
.scope.mini { width: clamp(150px, 22svh, 240px); border-radius: 50%; box-shadow: 0 12px 18px rgb(0 0 0 / 0.35); }

/* live mix: one pad per slice of the scope, in the same order */
.mix { min-width: 0; color: var(--device-ink); }
.mix-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.mix-title { font: 600 13px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; }
.snap { display: flex; align-items: center; gap: 4px; }
.snap-label { font: 400 11.5px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--device-muted); margin-right: 6px; white-space: nowrap; }
.snap label { position: relative; display: block; }
.snap input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.snap .opt {
  display: flex; align-items: center; height: 32px; padding: 0 11px; border-radius: 7px;
  border: 1px solid var(--device-line); color: var(--device-muted);
  font: 500 11.5px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
}
.snap input:hover + .opt { border-color: var(--device-muted); }
.snap input:checked + .opt { background: var(--device-3); border-color: var(--device-muted); color: var(--device-ink); }
.snap input:focus-visible + .opt { outline: 2px solid var(--ping); outline-offset: 2px; }
.mix-pads { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.pad {
  position: relative; display: grid; justify-items: center; align-content: center; gap: 8px; min-width: 0;
  height: clamp(58px, 8.4svh, 86px); padding: 0 6px; border-radius: 12px; gap: 10px;
  border: 1px solid var(--device-line);
  background: linear-gradient(180deg, var(--device-2b), var(--device-2));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06), 0 3px 8px -4px rgb(0 0 0 / 0.5);
  color: var(--device-ink); touch-action: manipulation;
  font: 500 12.5px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
}
.pad:hover { border-color: var(--device-muted); }
.pad-name { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pad-key { position: absolute; top: 7px; right: 8px; font: 400 10.5px/1 var(--mono); color: var(--device-muted); opacity: 0.8; }
.led { width: 10px; height: 10px; border-radius: 50%; background: var(--ping); box-shadow: 0 0 0 3px color-mix(in srgb, var(--k-ping) 16%, transparent), 0 0 10px color-mix(in srgb, var(--k-ping) 85%, transparent); }
.pad.out { background: var(--scope-bg); border-color: var(--scope-grid); color: var(--device-muted); box-shadow: inset 0 2px 8px rgb(0 0 0 / 0.45); }
.pad.out .led { background: transparent; box-shadow: inset 0 0 0 1.5px var(--scope-line); }
.pad.pending .led { animation: led-blink 0.42s steps(1, end) infinite; }
@keyframes led-blink { 50% { opacity: 0.15; } }
.pad.all { background: transparent; box-shadow: none; border-style: dashed; color: var(--device-ink); }
.pad.all:hover:not(:disabled) { border-style: solid; }
@media (hover: none) { .pad-key { display: none; } }
@media (prefers-reduced-motion: reduce) { .pad.pending .led { animation: none; opacity: 0.5; } }
.seq .out { opacity: 0.32; }

/* ---------- device panel ---------- */
.device {
  margin-top: clamp(28px, 4vw, 48px);
  scroll-margin-top: 80px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--device) 88%, #2a4a58), var(--device) 140px);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05), 0 30px 60px -36px rgb(8 20 26 / 0.6);
  color: var(--device-ink);
  border-radius: 16px;
  padding: clamp(16px, 2vw, 28px);
  border: 1px solid var(--device-line);
}
.device-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; margin-bottom: 14px; }
.studio .device { margin-top: 14px; padding: clamp(14px, 1.6vw, 22px) clamp(16px, 2vw, 28px); }
.device-lead { display: flex; align-items: center; gap: 16px; flex: 1 1 0; }
.device-title { flex: 0 1 auto; min-width: 150px; }
.device-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-title { position: relative; }
.device-name .nm { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: top; transform-origin: 50% 55%; }
/* the name morph: the words flatten into a white soundwave drawn here */
.name-wave { position: absolute; pointer-events: none; }
.kit-tabs { display: flex; flex: none; gap: 2px; padding: 3px; margin-left: 8px; border-radius: 10px; border: 1px solid var(--device-line); }
.kit-tab { height: 32px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent; color: var(--device-muted); font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.kit-tab:hover { color: var(--device-ink); }
.kit-tab.on { background: var(--device-3); color: var(--device-ink); box-shadow: inset 0 0 0 1px var(--device-muted); }
.btn-play.sm { height: 42px; padding: 0 18px 0 5px; gap: 9px; border-radius: 21px; font-size: 15px; }
.btn-play.sm .play-ico { width: 32px; height: 32px; }
.btn-play.sm .play-ico::before { border-left-width: 10px; border-top-width: 6px; border-bottom-width: 6px; margin-left: 2px; }
.btn-play.sm[aria-pressed='true'] .play-ico::before { width: 9px; height: 9px; margin-left: 0; }
.device-title { display: grid; gap: 2px; min-width: 0; }
.device-name { font: 800 30px/1 var(--display); letter-spacing: 0.03em; text-transform: uppercase; }
.device-meta { margin: 0; font: 400 12px/1.4 var(--mono); color: var(--device-muted); font-variant-numeric: tabular-nums; }
.device-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.save { display: flex; gap: 8px; }
.save input {
  width: 190px; height: 40px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--device-line);
  background: var(--device-2); color: var(--device-ink);
}
.save input::placeholder { color: var(--device-muted); }
.btn-ghost, .btn-solid {
  height: 40px; padding: 0 16px; border-radius: 8px; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
}
.btn-ghost { border: 1px solid var(--device-line); background: transparent; color: var(--device-ink); }
.btn-ghost:hover { border-color: var(--device-muted); }
button:disabled { cursor: default; opacity: 0.45; }
.device-hint { margin: 12px 0 0; font-size: 13.5px; line-height: 1.45; color: var(--device-muted); }

/* ---------- sequencer grid ---------- */
.seq {
  --lab: 104px;
  display: grid;
  grid-template-columns: var(--lab) repeat(16, minmax(0, 1fr));
  gap: 4px;
  align-items: stretch;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.seq-count { font: 400 11px/1.4 var(--mono); text-align: center; color: var(--device-muted); padding-bottom: 4px; }
.seq-count.beat { color: var(--device-ink); font-weight: 600; }
.seq-count.now { color: var(--ping); }
.seq .gap { margin-left: 6px; }
/* the count row is also the loop switch: one button per beat, lit while that beat plays in the loop */
.seq-loop-label { align-self: center; font: 500 10.5px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--device-muted); }
.seq-loop {
  grid-column: span 4; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 4px; align-items: center;
  height: 22px; margin-bottom: 4px; padding: 0; border-radius: 6px;
  border: 1px solid var(--device-line); background: transparent; color: inherit;
}
.seq-loop .seq-count { padding: 0; line-height: 1; }
.seq-loop:hover { border-color: var(--device-muted); }
.seq-loop.on { border-color: color-mix(in srgb, var(--k-ping-d) 40%, transparent); background: color-mix(in srgb, var(--k-ping) 10%, transparent); }
.seq.looping .seq-loop.on { border-color: color-mix(in srgb, var(--k-ping-d) 70%, transparent); background: color-mix(in srgb, var(--k-ping) 22%, transparent); }
.seq.looping .seq-loop:not(.on) { border-style: dashed; }
.seq .skip { opacity: 0.35; }
.seq-label {
  border: 0; background: transparent; color: var(--device-ink);
  text-align: left; font-weight: 600; font-size: 14px; padding: 0 6px 0 0;
  display: flex; align-items: center; gap: 6px; min-height: 34px; border-radius: 6px; min-width: 0;
}
.seq-label:hover { color: var(--ping); }
.seq-label.note { font: 400 12px/1 var(--mono); color: var(--device-muted); min-height: 22px; }
.seq-sep { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--device-line); font: 500 11px/1.2 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--device-muted); }
.cell {
  border: 0; padding: 0; border-radius: 6px;
  background: var(--device-2);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.035);
  min-height: 34px;
}
#seq .cell:not(.bass) { min-height: clamp(20px, 3svh, 34px); }
#seq .cell.bass { min-height: clamp(12px, 1.8svh, 22px); }
#seq .seq-label { min-height: clamp(20px, 3svh, 34px); }
#seq .seq-label.note { min-height: clamp(12px, 1.8svh, 22px); }
#seq .seq-sep { margin-top: 6px; padding-top: 8px; }
.cell.g2 { background: var(--device-2b); }
.cell.bass { min-height: 22px; border-radius: 4px; }
.cell.bass.root { box-shadow: inset 0 -2px 0 var(--device-line); }
@media (hover: hover) { .seq .cell:hover:not(:disabled) { background: var(--device-3); } }
.seq .cell.now:not(.on) { background: var(--device-3); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--k-ping-d) 40%, transparent); }
.seq .cell.on, .seq .cell.on:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--accent-top), var(--accent-hi) 55%, var(--accent-lo));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.35), 0 4px 14px -6px color-mix(in srgb, var(--k-ping) 75%, transparent);
}
.seq .cell.now.on { background: linear-gradient(180deg, var(--now-hi), var(--k-ping-d)); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.5), 0 0 18px -2px color-mix(in srgb, var(--k-ping-d) 85%, transparent); }
.seq .cell.given.on { background: var(--device-muted); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.2); }
.cell:disabled { cursor: default; }
@media (prefers-reduced-motion: reduce) { .cell { transition: none; } }
.badge { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 10px; line-height: 1.5; white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--ok) 25%, transparent); color: var(--ok); }
.badge.off { background: color-mix(in srgb, var(--ping) 25%, transparent); color: var(--ping); }

.halves { display: none; gap: 6px; margin-bottom: 12px; }
.half { flex: 1; height: 36px; border-radius: 8px; border: 1px solid var(--device-line); background: transparent; color: var(--device-muted); font-weight: 600; font-size: 14px; }
.half.on { background: var(--device-2); color: var(--device-ink); border-color: var(--device-muted); }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 20;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  margin: 0; padding: 10px 16px; border-radius: 10px; max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600;
  transition: opacity 160ms, transform 160ms;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- train ---------- */
.section-head { display: grid; gap: 14px; max-width: 760px; }
.section-head p { margin: 0; font-size: 17px; color: var(--muted); max-width: 40em; }
.train .section-head, .loops .section-head { max-width: none; }
.loops .section-head p { max-width: none; }
.train .section-head p { max-width: 810px; }
.train-body { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; margin-top: 32px; align-items: start; }
.levels { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lvl {
  width: 100%; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r); text-align: left;
  border: 1px solid transparent; background: transparent; color: var(--ink);
}
.lvl:hover:not(:disabled) { background: var(--surface); }
.lvl.on { background: var(--surface); border-color: var(--line); }
.lvl:disabled { opacity: 0.5; }
.lvl-num { font: 800 22px/1 var(--display); color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.lvl.on .lvl-num { color: var(--accent-text); }
.lvl-text { display: grid; min-width: 0; }
.lvl-name { font-weight: 700; font-size: 15px; }
.lvl-meta { font-size: 12px; color: var(--muted); }
.star-row { display: inline-flex; gap: 3px; }
.star { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--muted); }
.star.on { background: var(--accent-text); border-color: var(--accent-text); }
.level .star { border-color: var(--device-muted); width: 12px; height: 12px; }
.level .star.on { border-color: var(--ping); }
.device.level { margin-top: 0; }
.level-head { display: flex; justify-content: space-between; gap: 16px; align-items: start; margin-bottom: 18px; }
.level-head > div { display: grid; gap: 6px; min-width: 0; }
.level-head .stars { flex: none; }
.level-about { margin: 0; color: var(--device-ink); max-width: 46em; }
.level-main { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.level-scope { display: grid; gap: 8px; }
.level-scope .scope { width: 100%; }
.scope-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--device-muted); }
.level-work { min-width: 0; display: grid; gap: 14px; align-content: start; }
.level-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.counts { margin-left: auto; font: 400 12px/1.4 var(--mono); color: var(--device-muted); }
.level-result { margin: 0; min-height: 1.55em; font-weight: 600; }
.level-after { display: flex; flex-wrap: wrap; gap: 8px; }
.level-after[hidden] { display: none; }
.level .halves { margin-bottom: 0; }

/* ---------- loops ---------- */
.loop-list { list-style: none; margin: 32px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.loop {
  display: grid; gap: 12px; padding: 16px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--device) 88%, #2a4a58), var(--device) 90px); color: var(--device-ink);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05), 0 20px 40px -30px rgb(8 20 26 / 0.6);
  border-radius: 14px; border: 1px solid var(--device-line);
}
.wave { width: 100%; height: 56px; display: block; }
.loop-head { display: grid; gap: 2px; min-width: 0; }
.loop-name { font-size: 26px; overflow-wrap: anywhere; }
.loop-meta { margin: 0; font: 400 12px/1.4 var(--mono); color: var(--device-muted); }
.loop-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.loop-actions button { height: 34px; padding: 0 12px; font-size: 13px; }
.danger.armed { border-color: var(--ping); color: var(--ping); }
.loops-empty { margin-top: 24px; padding: 28px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); }
.loops-empty p { margin: 0; }
.loops-empty[hidden] { display: none; }
.loops-tools { margin-top: 16px; }
.file-btn { border-color: var(--line); color: var(--ink); cursor: pointer; }
.file-btn:hover { border-color: var(--muted); }
#importFile:focus-visible + * , .loops-tools:focus-within .file-btn { outline: 2px solid var(--ping); outline-offset: 2px; }

.site-foot { padding: clamp(56px, 7vw, 96px) var(--gutter) 40px; max-width: calc(var(--max) + 2 * var(--gutter)); margin: 0 auto; }
.site-foot p { margin: 0; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); max-width: 60em; }

/* ---------- short laptop screens: the editor still fits ---------- */
@media (max-height: 820px) and (min-width: 721px) {
  .studio h2 { font-size: 42px; }
  .seq-loop { height: 20px; margin-bottom: 2px; }
  .studio .device-name { font-size: 25px; }
  .studio .device-bar { margin-bottom: 10px; }
  .scope.mini { width: 150px; }
  .pad { height: 54px; gap: 8px; }
  .mix-head { margin-bottom: 8px; }
  .device-foot { margin-top: 10px; padding-top: 10px; }
}

/* ---------- narrower ---------- */
@media (max-width: 1100px) {
  .train-body { grid-template-columns: 1fr; }
  .levels { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: 0; padding-top: 28px !important; }
  .scope-wrap { justify-items: center; }
  .scope-wrap .scope { width: min(100%, 470px); }
  .level-main { grid-template-columns: 1fr; }
  .level-scope { grid-template-columns: 140px minmax(0, 1fr); align-items: center; }
}
@media (max-width: 720px) {
  .seq { --lab: 64px; grid-template-columns: var(--lab) repeat(8, minmax(0, 1fr)); gap: 4px; }
  .seq .gap { margin-left: 0; }
  .seq[data-half='0'] .h1, .seq[data-half='1'] .h0 { display: none; }
  .seq .cell:not(.bass) { min-height: 40px; }
  .seq .cell.bass { min-height: 30px; }
  .seq-label { font-size: 13px; }
  .halves { display: flex; }
  .kit-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .save { flex: 1 1 100%; }
  .save input { flex: 1; width: auto; min-width: 0; }
  .device-actions { width: 100%; }
  .device-lead { flex-wrap: wrap; gap: 12px 14px; }
  .device-title { flex: 1 1 0; min-width: 0; }
  .kit-tabs { width: 100%; margin-left: 0; }
  .kit-tab { flex: 1; padding: 0 4px; }
  .device-hint { font-size: 12px; }
  .device-foot { grid-template-columns: 1fr; justify-items: center; }
  .device-foot .mix { width: 100%; }
  .scope.mini { width: 180px; }
  .mix-pads { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pad { height: 54px; }
  #seq .cell:not(.bass), #seq .seq-label { min-height: 40px; }
  #seq .cell.bass, #seq .seq-label.note { min-height: 28px; }
  .counts { margin-left: 0; flex-basis: 100%; }
  .site-nav a { padding: 8px 8px; }
  .lede { font-size: 16px; }
  .intro { gap: 18px; }
  .transport { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
  .knob, .hero .knob { min-width: 0; }
  .btn-play { height: 50px; padding: 0 20px 0 6px; }
  .device { margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); border-radius: 0; border-left: 0; border-right: 0; padding: 18px 12px; }
  .seq { --lab: 78px; }
  .seq-label { font-size: 12.5px; overflow-wrap: anywhere; line-height: 1.2; }
  .levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lvl { grid-template-columns: 20px minmax(0, 1fr); padding: 8px; gap: 6px; }
  .lvl .star-row, .lvl-meta { display: none; }
  .level-head h3 { font-size: 26px; }
}

/* ---------- kit colour wave (js/wave.js) ---------- */
/* the old page stays as a still picture; the recoloured page shows through a growing circle */
::view-transition { pointer-events: none; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.kit-waving::view-transition-new(root) { clip-path: circle(0px at 50% 50%); }
/* the ring at the wave front: a soft glow in the new colour, and (Chromium) a ripple
   that warps the page under it; it fades as it spreads */
.kit-wave {
  position: fixed; z-index: 60; pointer-events: none; border-radius: 50%;
  background: radial-gradient(closest-side, transparent 70%, color-mix(in srgb, var(--ping) 12%, transparent) 82%, color-mix(in srgb, var(--ping) 55%, transparent) 85.6%, transparent 86.2%);
  -webkit-mask: radial-gradient(closest-side, transparent 56%, #000 60%, #000 86.5%, transparent 88%);
  mask: radial-gradient(closest-side, transparent 56%, #000 60%, #000 86.5%, transparent 88%);
}

/* ---------- beat light (js/wave.js) ---------- */
/* while a beat plays the titles take the kit colour and glow softly: titles on the
   page take the readable accent shade, titles on the dark panels the ping itself */
.logo, .site-nav a, #heroTitle span, #studioTitle, #trainTitle, #loopsTitle { --lit: var(--accent-text); --unlit: var(--ink); --glow: var(--page-glow); }
#patternName .nm, .loop-name { --lit: var(--ping); --unlit: var(--device-ink); --glow: 1; }
.beat-lit :is(.logo, .site-nav a, #heroTitle span, #studioTitle, #trainTitle, #loopsTitle, #patternName .nm, .loop-name),
:is(.logo, .site-nav a, #heroTitle span, #studioTitle, #trainTitle, #loopsTitle, #patternName .nm, .loop-name).lit-t {
  color: var(--lit);
  /* a text shadow is painted once with the letters; a filter glow was redrawn every frame */
  text-shadow: 0 0 0.05em color-mix(in srgb, var(--ping) calc(60% * var(--glow)), transparent),
    0 0 0.3em color-mix(in srgb, var(--ping) calc(42% * var(--glow)), transparent);
  /* their own layer, so the kick shake (app.js) moves them without repainting */
  will-change: translate;
}
/* the glow comes up quickly as the ring finishes crossing a title */
:is(.logo, .site-nav a, #heroTitle span, #studioTitle, #trainTitle, #loopsTitle, #patternName .nm, .loop-name).lit-t { transition: text-shadow 0.3s ease-out; }
/* while the ring moves, a title the ring is crossing (wave.js) is a gradient centred
   on the sonar (--bx, --by in its own box), coloured inside the ring (--br) and clipped
   to the letters; it glows once the colour covers all of it (lit-t). A glow while it
   is crossed would have to be a filter (a text shadow sits on top of letters clipped
   from the background), and that was redrawn every frame */
:is(.logo, .site-nav a, #heroTitle span, #studioTitle, #trainTitle, #loopsTitle, #patternName .nm, .loop-name).lit-x {
  color: transparent;
  background: radial-gradient(circle at var(--bx, 50%) var(--by, 50%), var(--lit) calc(var(--br, 0px) - 18px), var(--unlit) calc(var(--br, 0px) + 18px));
  -webkit-background-clip: text;
  background-clip: text;
}
/* the pattern name's boxes would cut its glow off */
.beat-lit :is(#patternName, #patternName .nm), .beat-moving :is(#patternName, #patternName .nm) { overflow: clip; overflow-clip-margin: 0.4em; }
.beat-ring { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 59; pointer-events: none; }
