/* Lowkey app shell. Tokens live in tokens.css. */
*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }
body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--chalk);
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: 1.45;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--ash); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: var(--r1); }

/* App grid: phone */
#app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  grid-template-areas: 'top' 'screen' 'transport' 'tabs';
  user-select: none;
  -webkit-user-select: none;
}

.topbar {
  grid-area: top;
  padding-top: var(--safe-top);
  background: var(--ink);
  border-bottom: 1px solid var(--line);
}
.topbar-row {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--s2) 0 var(--gutter);
  padding-left: max(var(--gutter), var(--safe-left));
  padding-right: max(var(--s2), var(--safe-right));
}
.topbar-title { font-size: 20px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 0; }

.screen {
  grid-area: screen;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: var(--s5) max(var(--gutter), var(--safe-right)) var(--s6) max(var(--gutter), var(--safe-left));
}

/* Transport */
.transport {
  grid-area: transport;
  height: var(--transport-h);
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 max(var(--s3), var(--safe-right)) 0 max(var(--s3), var(--safe-left));
  background: var(--slate);
  border-top: 1px solid var(--line);
}
.tbtn {
  width: var(--tap); height: var(--tap);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink);
  border: 1px solid var(--line);
  color: var(--chalk);
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  flex: none;
}
.tbtn:active { transform: scale(0.94); }
.tbtn-play[aria-pressed='true'] { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.tbtn-rec svg { stroke: var(--record); fill: none; }
.tbtn-rec[aria-pressed='true'] { border-color: var(--record); }
.tbtn-rec[aria-pressed='true'] svg { fill: var(--record); }

.readout {
  height: var(--tap);
  min-width: 52px;
  padding: 0 var(--s2);
  border-radius: var(--r1);
  border: 1px solid var(--line);
  background: var(--ink);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1.1;
  color: var(--chalk);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  flex: none;
}
.readout:active { border-color: var(--amber); }
.readout .value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--t-title); font-weight: 600; letter-spacing: -0.01em; }
.readout .label { font-size: 10px; color: var(--ash); margin-top: 2px; letter-spacing: 0.02em; }
.readout-bpm { min-width: 64px; }
.readout-key { min-width: 60px; }
.readout-swing { min-width: 56px; }
.readout[aria-disabled='true'] { color: var(--ash); }

.master-meter {
  margin-left: auto;
  width: 48px; height: var(--tap);
  border: 1px solid var(--line);
  border-radius: var(--r1);
  background: var(--ink);
  display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 0 6px;
  flex: none;
}
.master-meter .bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.master-meter .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ash), var(--amber)); }
.master-meter .bar.clip i { background: var(--record); }

/* Tab bar */
.tabbar {
  grid-area: tabs;
  background: var(--slate);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.tabbar ul { list-style: none; margin: 0; padding: 0 max(0px, var(--safe-right)) 0 max(0px, var(--safe-left)); display: flex; height: var(--tabbar-h); }
.tabbar li { flex: 1; min-width: 0; }
.tab {
  height: 100%; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ash);
  font-size: var(--t-cap);
  font-weight: 500;
  transition: color var(--t-fast) var(--ease);
  border-radius: var(--r1);
}
.tab svg.icon { width: 22px; height: 22px; }
.tab[aria-current='page'] { color: var(--amber); }
.tab:active { color: var(--chalk); }

/* Buttons */
.btn {
  min-height: var(--tap);
  padding: 0 var(--s4);
  border-radius: var(--r1);
  border: 1px solid var(--line);
  background: var(--slate);
  color: var(--chalk);
  font-size: var(--t-body);
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.btn-ghost { background: transparent; }
.btn-icon { width: var(--tap); height: var(--tap); padding: 0; border-radius: var(--r1); border: 0; background: transparent; color: var(--chalk); display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:active { background: var(--amber-tint); }
.btn[disabled], .btn[aria-disabled='true'] { opacity: 0.5; pointer-events: none; }
.btn .spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty states */
.empty {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: var(--s3);
  padding: var(--s6) 0;
  max-width: 420px;
  margin: 0 auto;
}
.empty .glyph {
  width: 72px; height: 72px; border-radius: var(--r2);
  border: 1px solid var(--line);
  background: var(--slate);
  display: flex; align-items: center; justify-content: center;
  color: var(--amber);
  margin-bottom: var(--s2);
}
.empty .glyph svg.icon { width: 32px; height: 32px; }
.empty h2 { margin: 0; font-size: var(--t-head); line-height: 1.3; font-weight: 600; }
.empty p { margin: 0; color: var(--ash); max-width: 32ch; }
.empty .btn { margin-top: var(--s2); }

/* Lists and rows */
.group { border: 1px solid var(--line); border-radius: var(--r2); background: var(--slate); overflow: hidden; }
.group + .group, .section + .section { margin-top: var(--s5); }
.section-title { font-size: var(--t-label); color: var(--ash); margin: 0 0 var(--s2) var(--s1); font-weight: 500; }
.row {
  min-height: 52px;
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s4);
  width: 100%; text-align: left;
  border-top: 1px solid var(--line);
  color: var(--chalk);
  font-size: var(--t-body);
}
.row:first-child { border-top: 0; }
.row .row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row .row-sub { color: var(--ash); font-size: var(--t-label); }
.row .row-value { color: var(--ash); font-size: var(--t-label); }
.row .row-value.mono { color: var(--chalk); }
.row svg.icon.lead { color: var(--ash); }
.row svg.icon.trail { color: var(--ash); width: 18px; height: 18px; }
button.row:active { background: var(--amber-tint); }

/* Sheets */
dialog.sheet {
  border: 1px solid var(--line);
  background: var(--slate);
  color: var(--chalk);
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: 100%;
  max-height: calc(100dvh - var(--safe-top) - var(--s7));
  position: fixed;
  inset: auto 0 0 0;
  border-radius: var(--r3) var(--r3) 0 0;
  box-shadow: none;
}
dialog.sheet::backdrop { background: var(--scrim); }
dialog.sheet:focus, dialog.sheet:focus-visible { outline: none; }
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in var(--t-sheet) var(--ease); }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: var(--s2) auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s2) 0 var(--s4); min-height: 48px; flex: none; }
.sheet-head h2 { margin: 0; font-size: var(--t-title); font-weight: 600; flex: 1; }
.sheet-body { padding: var(--s3) var(--s4) calc(var(--s5) + var(--safe-bottom)); overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.sheet-body:focus-visible { outline-offset: -2px; border-radius: 0; }
.sheet-body p { margin: 0 0 var(--s3); color: var(--ash); }
.sheet-body p:last-child { margin-bottom: 0; }
.sheet-actions { display: flex; gap: var(--s2); margin-top: var(--s4); }
.sheet-body .knob-row { justify-content: space-evenly; }
.sheet-actions .btn { flex: 1; }

/* Toasts */
#toasts {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--transport-h) + var(--tabbar-h) + var(--safe-bottom) + var(--s3));
  display: flex; flex-direction: column; align-items: center; gap: var(--s2);
  pointer-events: none;
  padding: 0 var(--gutter);
  z-index: 20;
}
.toast {
  pointer-events: auto;
  max-width: 480px; width: 100%;
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--slate);
  color: var(--chalk);
  font-size: var(--t-body);
  animation: toast-in var(--t-fast) var(--ease);
}
.toast .toast-text { flex: 1; }
.toast .toast-action { color: var(--amber); font-weight: 600; padding: var(--s2) var(--s1); min-height: var(--tap); display: inline-flex; align-items: center; }
.toast svg.icon { width: 20px; height: 20px; color: var(--ash); }
.toast.ok svg.icon { color: var(--confirm); }
.toast.warn svg.icon { color: var(--amber); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
/* On Play the surfaces reach the bottom of the screen and a toast there would
   cover the pads at the moment they are being hit ("Recording into the
   loop"), so toasts sit at the top, over the spectrum, on every layout. */
body:has(#screen[data-screen='play']) #toasts { top: calc(var(--safe-top) + var(--topbar-h) + var(--s3)); bottom: auto; }

/* Stepper and slider controls in sheets */
.stepper { display: flex; align-items: center; justify-content: center; gap: var(--s4); padding: var(--s3) 0; }
.stepper .big { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--t-hero); font-weight: 600; min-width: 4ch; text-align: center; line-height: 1; }
.stepper .unit { font-size: var(--t-label); color: var(--ash); text-align: center; margin-top: var(--s1); }
.stepper .btn-icon { border: 1px solid var(--line); background: var(--ink); width: 52px; height: 52px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chips-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.chips-grid .chip { padding: 0; width: 100%; }
.chip {
  min-height: var(--tap); min-width: var(--tap);
  padding: 0 var(--s3);
  border-radius: var(--rp);
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--chalk);
  font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center;
}
.chip[aria-pressed='true'] { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: var(--tap); background: transparent; margin: 0; }
.slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--line); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: var(--amber); border: 0; margin-top: -11px; }
.slider::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
.slider::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: var(--amber); border: 0; }
.slider-row { display: flex; align-items: center; gap: var(--s3); }
.slider-row .value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; min-width: 4ch; text-align: right; }

/* Wordmark */
.wordmark { font-weight: 700; letter-spacing: -0.02em; font-size: var(--t-title); }
.wordmark i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); margin-left: 4px; vertical-align: 2px; font-style: normal; }

/* Tablet: sidebar plus two-pane content */
@media (min-width: 640px) {
  #app {
    grid-template-columns: calc(var(--sidebar-w) + var(--safe-left)) 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: 'side top' 'side screen' 'side transport';
  }
  .tabbar {
    grid-area: side;
    border-top: 0;
    border-right: 1px solid var(--line);
    padding: calc(var(--safe-top) + var(--s3)) 0 var(--safe-bottom) var(--safe-left);
    display: flex; flex-direction: column;
  }
  .tabbar .brand { display: flex; align-items: center; justify-content: center; height: 40px; margin-bottom: var(--s3); }
  .tabbar ul { flex-direction: column; height: auto; padding: 0 var(--s2); gap: var(--s1); }
  .tabbar li { flex: none; }
  .tab { height: 56px; }
  .tab[aria-current='page'] { background: var(--amber-tint); }
  .topbar-row { padding-left: var(--s5); }
  .screen { padding-left: var(--s5); padding-right: max(var(--s5), var(--safe-right)); }
  .transport { padding-left: var(--s5); height: calc(var(--transport-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom); }
  .master-meter { width: 96px; }
  .readout-bpm { min-width: 80px; }
  dialog.sheet {
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: min(480px, calc(100vw - var(--s6)));
    border-radius: var(--r3);
    max-height: calc(100dvh - var(--s7));
  }
  dialog.sheet[open] { animation: dialog-in var(--t-sheet) var(--ease); }
  @keyframes dialog-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)); } to { opacity: 1; transform: translate(-50%, -50%); } }
  .sheet-handle { display: none; }
  #toasts { left: calc(var(--sidebar-w) + var(--safe-left)); bottom: calc(var(--transport-h) + var(--safe-bottom) + var(--s3)); }
}

/* The phone on its side: the sidebar keeps the tabs, the transport joins
   the top row so the screen gets the height, and every surface fits a
   380 px tall viewport. The Dynamic Island insets sit outside the sidebar
   and the transport. */
@media (min-width: 640px) and (max-height: 500px) {
  :root { --topbar-h: 52px; }
  #app {
    grid-template-columns: calc(var(--sidebar-w) + var(--safe-left)) minmax(0, 1fr) auto;
    grid-template-rows: auto 1fr;
    grid-template-areas: 'side top transport' 'side screen screen';
  }
  .topbar-row { padding-left: var(--s4); padding-right: var(--s2); }
  .transport {
    height: auto; padding: 0 max(var(--s2), var(--safe-right)) 0 var(--s2);
    background: var(--ink); border-top: 0; border-bottom: 1px solid var(--line);
  }
  .master-meter { margin-left: 0; width: 48px; }
  .readout-bpm { min-width: 64px; }
  .screen { padding: var(--s3) max(var(--s4), var(--safe-right)) calc(var(--s4) + var(--safe-bottom)) var(--s4); }
  .tabbar { padding-top: var(--s2); }
  .tabbar .brand { display: none; }
  .tabbar ul { flex: 1; justify-content: center; }
  .tabbar li { flex: 0 1 64px; min-height: var(--tap); }
  .tab { height: 100%; }
  #toasts { left: calc(var(--sidebar-w) + var(--safe-left)); bottom: calc(var(--safe-bottom) + var(--s3)); }
  dialog.sheet { max-height: calc(100dvh - var(--s5)); width: min(560px, calc(100vw - var(--safe-left) - var(--safe-right) - var(--s6))); }
  dialog.sheet.sheet-wide { width: min(640px, calc(100vw - var(--safe-left) - var(--safe-right) - var(--s6))); }
}
@media (max-width: 639px) { .tabbar .brand { display: none; } }
@media (max-width: 359px) { .readout-swing, .master-meter { display: none; } }

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

/* ---- Make screen ---- */
.make { display: flex; flex-direction: column; gap: var(--s4); }
.make-left, .make-right { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }

.inst-row { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.inst-tabs { display: flex; gap: var(--s2); }
.inst-row::-webkit-scrollbar { display: none; }
.inst-chip {
  min-height: var(--tap); padding: 0 var(--s3); border-radius: var(--rp);
  border: 1px solid var(--line); background: var(--slate); color: var(--ash);
  font-weight: 600; display: inline-flex; align-items: center; gap: var(--s2); white-space: nowrap; flex: none;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.inst-chip .inst-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.inst-chip[aria-selected='true'] { color: var(--chalk); border-color: var(--amber); background: var(--amber-tint); }
.inst-chip[aria-selected='true'] .inst-dot { background: var(--amber); }
.inst-chip.inst-add { width: var(--tap); padding: 0; justify-content: center; color: var(--chalk); }

/* Grids */
.grid-wrap { min-width: 0; }
.grid { display: flex; flex-direction: column; gap: 3px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.grid-row { display: grid; grid-template-columns: 48px repeat(var(--steps), minmax(0, 1fr)); gap: 3px; align-items: stretch; }
.grid-head { display: flex; min-width: 0; }
.grid-lane {
  font-size: 11px; font-weight: 600; color: var(--ash); text-align: left; padding: 0 4px; border-radius: 4px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-height: 30px; min-width: 0; width: 100%;
}
.grid-lane:active { color: var(--chalk); background: var(--amber-tint); }
.note-grid .grid-lane { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 11px; }
.note-grid .grid-row.root .grid-lane { color: var(--amber); }
.note-grid .grid-row.outside .grid-lane { color: var(--ash); font-weight: 400; opacity: 0.85; }
.note-grid .grid-row.outside .cell { background: var(--ink); }
.cell {
  position: relative; min-height: 30px; border-radius: 4px; background: var(--slate); border: 1px solid var(--line);
  overflow: hidden; transition: background var(--t-fast) var(--ease);
}
.cell.beat { border-color: #343a47; }
.cell i { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--v, 0) * 100%); background: var(--amber); border-radius: 2px; display: block; opacity: 0; }
.cell.on { border-color: var(--amber); }
.cell.on i { opacity: 1; }
.cell.prob i { opacity: 0.55; }
.note-grid .cell.on i { height: 100%; width: calc(var(--len, 1) * 100% + (var(--len, 1) - 1) * 3px); right: auto; opacity: calc(0.55 + var(--v, 1) * 0.45); }
.note-grid .cell.on { overflow: visible; z-index: 1; }
.note-grid .cell.tail { background: var(--amber-tint); }
.cell.playing { background: var(--amber-tint-strong); }
.cell.playing.on { background: var(--slate); }
.cell.playing.on i { filter: brightness(1.25); }
.cell:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
.drum-grid .cell { min-height: 38px; }
@media (min-width: 640px) { .cell { min-height: 36px; } .grid-row { grid-template-columns: 64px repeat(var(--steps), minmax(0, 1fr)); gap: 4px; } .grid-lane { font-size: 12px; } }

.pager { display: flex; align-items: center; gap: var(--s1); min-height: var(--tap); }
.pager.empty { display: none; }
.pager-label { color: var(--ash); font-size: var(--t-label); min-width: 4ch; text-align: center; }
.pager-spacer { flex: 1; }
.chip-small { padding: 0 var(--s3); font-size: var(--t-label); gap: 6px; }
.chip-small svg.icon { width: 16px; height: 16px; }
.chip.off { color: var(--ash); }
svg.icon.flip { transform: rotate(180deg); }

/* Instrument panel */
.inst-panel { display: flex; flex-direction: column; gap: var(--s3); border: 1px solid var(--line); border-radius: var(--r2); background: var(--slate); padding: var(--s3); }
.preset-row { display: flex; align-items: center; gap: var(--s3); width: 100%; text-align: left; min-height: 52px; padding: var(--s1) var(--s1); border-radius: var(--r1); color: var(--chalk); }
.preset-row:active { background: var(--amber-tint); }
.preset-row .row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.preset-row .preset-name { font-weight: 600; }
.preset-row .row-sub { color: var(--ash); font-size: var(--t-label); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.preset-row svg.icon.lead { color: var(--amber); }
.preset-row svg.icon.trail { color: var(--ash); width: 18px; height: 18px; }
.lane-chips { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; }
.lane-chips::-webkit-scrollbar { display: none; }
.lane-chips .chip { flex: none; }
.lane-chips .chip[aria-selected='true'] { background: var(--amber); border-color: var(--amber); color: var(--ink); }

.knob-row { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s1); justify-content: space-between; }
.knob { position: relative; width: 56px; min-height: 68px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 2px; border-radius: var(--r1); touch-action: none; }
.knob-dial { display: block; }
.knob-track { fill: none; stroke: var(--line); stroke-width: 3; stroke-linecap: round; }
.knob-fill { fill: none; stroke: var(--amber); stroke-width: 3; stroke-linecap: round; }
.knob-dot { fill: var(--chalk); }
.knob-label { font-size: 11px; color: var(--ash); white-space: nowrap; max-width: 60px; overflow: hidden; text-overflow: ellipsis; }
.knob-readout {
  position: absolute; top: -30px; left: 50%; transform: translateX(-50%);
  background: var(--ink); border: 1px solid var(--line); color: var(--chalk); border-radius: var(--r1);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--t-cap); padding: 2px 6px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity var(--t-fast) var(--ease); z-index: 3;
}
.knob.dragging .knob-readout, .knob:focus-visible .knob-readout { opacity: 1; }
.knob.dragging .knob-dot { fill: var(--amber); }

/* Scenes */
.scenes { display: flex; align-items: center; gap: var(--s2); overflow-x: auto; scrollbar-width: none; }
.scenes::-webkit-scrollbar { display: none; }
.scenes-label { font-size: var(--t-label); color: var(--ash); margin-right: var(--s1); flex: none; }
.scene-chip {
  min-height: var(--tap); min-width: 52px; padding: 0 var(--s3); border-radius: var(--r1);
  border: 1px solid var(--line); background: var(--slate); color: var(--chalk);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; flex: none;
}
.scene-chip .scene-name { font-weight: 700; font-size: var(--t-body); }
.scene-chip .scene-bars { font-size: 10px; color: var(--ash); }
.scene-chip[aria-pressed='true'] { border-color: var(--amber); background: var(--amber-tint); }
.scene-chip[aria-pressed='true'] .scene-bars { color: var(--amber); }
.scene-chip.scene-add { min-width: var(--tap); padding: 0; }

/* Resume banner */
.banner {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); margin-bottom: var(--s4);
  border: 1px solid var(--amber); border-radius: var(--r2); background: var(--amber-tint);
}
.banner[hidden] { display: none; }
.banner .banner-text { flex: 1; }
.banner svg.icon { color: var(--amber); }

/* Transport playing state */
.transport .tbtn-play[aria-pressed='true'] svg { fill: var(--ink); }
.transport .readout-bpm.live .value { color: var(--amber); }
.topbar-actions .btn-icon[disabled] { opacity: 0.35; pointer-events: none; }

/* Two panes on the iPad */
@media (min-width: 640px) {
  .make { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: var(--s5); align-items: start; }
  .make-right { position: sticky; top: 0; }
  .knob-row { justify-content: flex-start; gap: var(--s3) var(--s2); }
}
@media (min-width: 900px) { .make { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); } }
@media (min-width: 640px) and (max-height: 500px) {
  .make { grid-template-columns: minmax(0, 1.5fr) minmax(240px, 1fr); gap: var(--s4); }
  .cell, .drum-grid .cell { min-height: 30px; }
  .grid-row { grid-template-columns: 52px repeat(var(--steps), minmax(0, 1fr)); gap: 3px; }
}
.input { width: 100%; min-height: var(--tap); padding: 0 var(--s3); border-radius: var(--r1); border: 1px solid var(--line); background: var(--ink); color: var(--chalk); font-size: var(--t-body); }
.input:focus-visible { border-color: var(--amber); outline: none; }

/* Learn sheet */
.learn-what { color: var(--chalk) !important; font-weight: 600; }
.learn-ab { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s3); flex-wrap: wrap; }
.learn-ab .btn[aria-pressed='true'] { border-color: var(--amber); background: var(--amber-tint); }
.learn-status { color: var(--ash); font-size: var(--t-label); }

/* Coach card */
.coach {
  display: grid; grid-template-columns: 24px 1fr; gap: var(--s2) var(--s3); align-items: start;
  padding: var(--s3) var(--s4); margin-bottom: var(--s4);
  border: 1px solid var(--line); border-radius: var(--r2); background: var(--slate);
}
.coach[hidden] { display: none; }
.coach > svg.icon { color: var(--amber); margin-top: 2px; }
.coach-text { color: var(--chalk); }
.coach-actions { grid-column: 2; display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }

/* Generate row */
.gen-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.gen-row .btn { min-width: 0; padding: 0 var(--s3); }
@media (min-width: 900px) { .gen-row { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 640px) and (max-height: 500px) { .gen-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.gen-row .btn svg.icon { width: 20px; height: 20px; }

/* Vibe cards */
.sheet-wide { --sheet-max: 640px; }
@media (min-width: 640px) { dialog.sheet.sheet-wide { width: min(640px, calc(100vw - var(--s6))); } }
.vibe-grid { display: grid; grid-template-columns: 1fr; gap: var(--s2); }
@media (min-width: 480px) { .vibe-grid { grid-template-columns: 1fr 1fr; } }
.vibe-card {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  padding: var(--s3) var(--s4); min-height: 96px;
  border: 1px solid var(--line); border-radius: var(--r3); background: var(--ink); color: var(--chalk);
  transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.vibe-card:active { transform: scale(0.98); }
.vibe-card[aria-pressed='true'] { border-color: var(--amber); background: var(--amber-tint); }
.vibe-name { font-size: var(--t-title); font-weight: 700; }
.vibe-line { color: var(--ash); font-size: var(--t-label); line-height: 1.35; }
.vibe-meta { color: var(--amber); font-size: var(--t-cap); margin-top: 2px; }

/* Why panel and Better */
.why-list { margin: 0 0 var(--s3); padding-left: 18px; color: var(--ash); }
.why-list li { margin-bottom: 6px; }
.why-list li::marker { color: var(--amber); }
.why-prog { color: var(--chalk); background: var(--ink); border: 1px solid var(--line); border-radius: var(--r1); padding: var(--s2) var(--s3); font-size: var(--t-label); overflow-x: auto; white-space: nowrap; }
.better-row { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3) 0; border-top: 1px solid var(--line); }
.better-row:first-of-type { border-top: 0; }
.better-row.done { opacity: 0.6; }
.better-main { display: flex; flex-direction: column; gap: 2px; }
.better-title { font-weight: 600; }
.better-why { color: var(--ash); font-size: var(--t-label); }
.better-actions { display: flex; gap: var(--s2); }
.better-actions .btn { flex: 1; }
.better-actions .btn[aria-pressed='true'] { border-color: var(--amber); background: var(--amber-tint); }
.health-row.ok svg.icon.lead { color: var(--confirm); }
.health-row.fix svg.icon.lead { color: var(--amber); }
.health-row .btn { flex: none; }

/* Tutorial card: above the screen content, one step at a time. The ring
   marks the control the step means. */
.tutorial {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s2) var(--s2); align-items: start;
  padding: var(--s3) var(--s3) var(--s3) var(--s4); margin-bottom: var(--s4);
  border: 1px solid var(--amber); border-radius: var(--r2); background: var(--amber-tint);
}
.tutorial[hidden] { display: none; }
.tutorial-meta { grid-column: 1; display: flex; align-items: center; gap: var(--s2); color: var(--amber); font-size: var(--t-cap); }
.tutorial-bar { flex: 1; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; min-width: 40px; }
.tutorial-bar i { display: block; height: 100%; background: var(--amber); }
.tutorial-close { grid-column: 2; grid-row: 1 / span 4; align-self: start; }
.tutorial-title { grid-column: 1; margin: 0; font-size: var(--t-title); font-weight: 700; line-height: 1.3; }
.tutorial-text { grid-column: 1; margin: 0; color: var(--chalk); }
.tutorial-actions { grid-column: 1; display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.tutorial-actions .btn { min-width: 120px; }
.tutorial-skip { min-height: var(--tap); padding: 0 var(--s2); color: var(--ash); font-weight: 500; border-radius: var(--r1); }
.tutorial-skip:active { color: var(--chalk); }
.tutorial-done { display: inline-flex; align-items: center; gap: var(--s2); color: var(--confirm); }
.tutorial-done svg.icon { color: var(--confirm); }
.tutorial-target { box-shadow: 0 0 0 3px var(--amber); border-radius: var(--r1); }
.tutorial-target.tbtn { border-radius: 50%; }
.tutorial-target.tab { box-shadow: inset 0 0 0 3px var(--amber); }
/* On the phone on its side the card keeps to three short lines with the
   action beside them, so the surface it points at stays on screen. */
@media (min-width: 640px) and (max-height: 500px) {
  .tutorial { grid-template-columns: minmax(0, 1fr) auto auto; gap: var(--s1) var(--s3); padding: var(--s2) var(--s3); margin-bottom: var(--s3); }
  .tutorial-meta { font-size: 11px; }
  .tutorial-title { font-size: var(--t-body); }
  .tutorial-text { font-size: var(--t-label); }
  .tutorial-actions { grid-column: 2; grid-row: 2 / span 2; align-self: center; }
  .tutorial-actions .btn { min-width: 0; }
  .tutorial-close { grid-column: 3; grid-row: 1 / span 3; }
}
.welcome-how { display: inline-flex; align-items: center; gap: var(--s2); min-height: var(--tap); color: var(--amber); font-weight: 600; }

/* The generator moment: an amber sweep across the grid, once. */
@keyframes sweep { from { transform: translateX(-100%); opacity: 0.9; } to { transform: translateX(100%); opacity: 0; } }
.grid-wrap { position: relative; overflow: hidden; }
.grid-wrap.moment::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, transparent 0%, var(--amber-tint-strong) 50%, transparent 100%);
  animation: sweep var(--t-moment) var(--ease) 1;
}

/* Why strip under the generate row */
.why-strip { display: flex; align-items: center; gap: var(--s2); min-height: var(--tap); padding: 0 var(--s1); }
.why-strip[hidden] { display: none; }
.why-strip-prog { color: var(--ash); font-size: var(--t-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.why-strip-btn { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 var(--s2); color: var(--amber); font-weight: 600; font-size: var(--t-label); border-radius: var(--r1); white-space: nowrap; flex: none; }
.why-strip-btn svg.icon { width: 18px; height: 18px; }
.why-strip-btn svg.icon.trail { width: 16px; height: 16px; }

/* ---- Arrange ---- */
.arrange { display: flex; flex-direction: column; gap: var(--s4); }
.arrange .empty .btn-ghost { margin-top: 0; }
.arr-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: var(--tap); }
.arr-head[hidden], .timeline-wrap[hidden], .arr-tools[hidden], .sec-panel[hidden], .empty[hidden] { display: none; }
.arr-length { color: var(--ash); font-size: var(--t-label); }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r2); background: var(--ink); padding: 0; gap: 0; overflow: hidden; }
.seg {
  min-height: var(--tap); min-width: 80px; padding: 0 var(--s3); border-radius: 0;
  border: 0; background: transparent; color: var(--ash); font-weight: 600; font-size: var(--t-label);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg[aria-checked='true'] { background: var(--amber-tint); color: var(--amber); box-shadow: inset 0 -2px 0 var(--amber); }
.seg:active { color: var(--chalk); }

.timeline-wrap { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; border: 1px solid var(--line); border-radius: var(--r2); background: var(--ink); padding: var(--s2); touch-action: pan-x; }
.timeline-wrap::-webkit-scrollbar { display: none; }
.timeline-inner { position: relative; display: flex; align-items: stretch; gap: 3px; width: max-content; min-width: 100%; }
.timeline { display: flex; gap: 3px; --zoom: 9; }
.sec-block {
  position: relative; display: flex; width: calc(var(--bars) * var(--zoom) * 1px); min-width: 72px; height: 72px; flex: none;
  border: 1px solid var(--line); border-radius: var(--r1); background: var(--slate); overflow: hidden;
  transition: border-color var(--t-fast) var(--ease);
}
.sec-block.selected { border-color: var(--amber); }
.sec-block.playing { background: var(--amber-tint); }
.sec-block.resizing { border-color: var(--amber); background: var(--amber-tint-strong); }
.sec-main { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 0 6px; border: 0; background: transparent; color: var(--chalk); text-align: left; overflow: hidden; }
.sec-main:active { background: var(--amber-tint); }
.sec-name { font-weight: 700; font-size: var(--t-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-meta { color: var(--ash); font-size: var(--t-cap); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-meta .sec-scene { color: var(--amber); margin-left: 6px; }
.sec-handle { width: 14px; flex: none; cursor: ew-resize; touch-action: none; background: linear-gradient(90deg, transparent, var(--line)); }
.sec-handle::after { content: ''; position: absolute; right: 5px; top: 50%; width: 3px; height: 20px; margin-top: -10px; border-radius: 2px; background: var(--ash); }
.sec-block.selected .sec-handle::after, .sec-block.resizing .sec-handle::after { background: var(--amber); }
.tl-add { flex: none; width: var(--tap); height: 72px; border: 1px dashed var(--line); border-radius: var(--r1); background: transparent; color: var(--ash); }
.tl-add:active { color: var(--amber); border-color: var(--amber); }
.tl-playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--amber); left: calc(var(--pos, 0) * var(--zoom, 6) * 1px); pointer-events: none; transition: left 80ms linear; z-index: 2; }
.tl-playhead[hidden] { display: none; }
.arr-tools { display: flex; flex-direction: column; gap: var(--s2); }
.arr-hint { color: var(--ash); font-size: var(--t-label); margin: 0; padding: 0 var(--s1); }
.arr-hint[hidden] { display: none; }
/* Quiet chips: the arrangement is full of choices, so a chosen one is an
   amber outline, not a fill. The one filled amber thing on the screen is
   Auto-arrange. */
.arrange .chip[aria-pressed='true'], .aa-row .chip[aria-pressed='true'] { background: var(--amber-tint); border-color: var(--amber); color: var(--chalk); }
.arrange .chip[aria-pressed='true'] svg.icon, .aa-row .chip[aria-pressed='true'] svg.icon { color: var(--amber); }
.arr-tools-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.arr-zoom { display: flex; gap: 0; }
.arr-tools .why-strip-btn { width: 100%; justify-content: flex-start; }
.arr-tools .why-strip-btn[hidden] { display: none; }
.why-strip-btn { display: inline-flex; align-items: center; gap: var(--s2); min-height: var(--tap); padding: 0 var(--s2); border: 0; background: transparent; color: var(--amber); font-weight: 600; font-size: var(--t-label); border-radius: var(--r1); }
.why-strip-btn svg.icon.trail { color: var(--ash); width: 18px; height: 18px; margin-left: auto; }

.sec-panel { display: flex; flex-direction: column; gap: var(--s3); border: 1px solid var(--line); border-radius: var(--r2); background: var(--slate); padding: var(--s3) var(--s4) var(--s4); }
.sec-panel-head { display: flex; align-items: center; justify-content: space-between; }
.sec-panel-head .section-title { margin: 0; }
.sec-group { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--line); }
.sec-group > .chips, .sec-group > .lane-editor, .sec-group > .btn { align-self: stretch; }
.aa-label { font-size: var(--t-cap); color: var(--ash); letter-spacing: 0.04em; text-transform: uppercase; }
.aa-row { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s3); }
.aa-line { color: var(--ash); margin: -4px 0 var(--s3) !important; font-size: var(--t-label); }
.stepper-inline { justify-content: flex-start; flex-wrap: wrap; }
.stepper-inline .chips { margin-left: var(--s2); }
.chip.off { color: var(--ash); }
.chip.off svg.icon { color: var(--ash); }
.sec-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--line); }
.sec-actions .btn { min-width: 0; padding: 0 var(--s2); }
@media (min-width: 640px) { .sec-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.lane-editor { position: relative; display: block; height: 112px; border: 1px solid var(--line); border-radius: var(--r1); background: var(--ink); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.lane-editor:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
.lane-svg { display: block; width: 100%; height: 100%; }
.lane-grid { stroke: var(--line); stroke-width: 1; }
.lane-zero { stroke: var(--ash); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.6; }
.lane-line { fill: none; stroke: var(--amber); stroke-width: 2; vector-effect: non-scaling-stroke; }
.lane-point { fill: var(--chalk); stroke: var(--amber); stroke-width: 2; vector-effect: non-scaling-stroke; }
.lane-readout { position: absolute; right: 8px; top: 6px; font-size: var(--t-cap); color: var(--ash); background: var(--ink); padding: 2px 6px; border-radius: 4px; pointer-events: none; }

/* ---- Export sheet ---- */
.options { display: flex; flex-direction: column; gap: var(--s2); }
.option { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 64px; padding: var(--s3) var(--s3); border: 1px solid var(--line); border-radius: var(--r2); background: var(--ink); color: var(--chalk); text-align: left; }
.option[aria-checked='true'] { border-color: var(--amber); background: var(--amber-tint); }
.option svg.icon.lead { color: var(--amber); flex: none; }
.option svg.icon.trail { color: var(--amber); width: 18px; height: 18px; flex: none; opacity: 0; }
.option[aria-checked='true'] svg.icon.trail { opacity: 1; }
.option .row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.option-title { font-weight: 600; }
.progress { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--amber); transition: width 200ms var(--ease); }
.progress-row { display: flex; align-items: center; justify-content: space-between; min-height: 24px; margin-bottom: var(--s2); }
.progress-label { color: var(--chalk); font-size: var(--t-label); }
.progress-pct { color: var(--ash); font-size: var(--t-label); }
.export .row .btn-ghost { flex: none; padding: 0 var(--s2); }
.sheet-body .group .row { min-height: var(--tap); }

/* ---- Mix ---- */
.mix { display: flex; flex-direction: column; gap: var(--s3); }
.strips { display: flex; flex-direction: column; gap: var(--s2); }
@media (min-width: 900px) { .strips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.strip { display: flex; flex-direction: column; gap: var(--s2); border: 1px solid var(--line); border-radius: var(--r2); background: var(--slate); padding: var(--s2) var(--s3) var(--s3); }
.strip.muted { opacity: 0.6; }
.strip-head { display: flex; align-items: center; gap: var(--s2); min-height: var(--tap); }
.strip-name { display: inline-flex; align-items: center; gap: var(--s2); flex: 1; min-width: 0; min-height: var(--tap); padding: 0 var(--s1); border: 0; background: transparent; color: var(--chalk); font-weight: 700; text-align: left; border-radius: var(--r1); }
.strip-name:active { background: var(--amber-tint); }
.strip-name .inst-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); flex: none; }
.strip-name svg.icon.trail { color: var(--ash); width: 18px; height: 18px; }
.strip-label { flex: 1; font-weight: 700; padding: 0 var(--s1); }
.strip-db { color: var(--ash); font-size: var(--t-label); min-width: 7ch; text-align: right; }
.chip-ms { width: var(--tap); padding: 0; justify-content: center; font-weight: 700; }
.chip-ms[aria-pressed='true'] { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.fader { min-height: var(--tap); }
.strip-meter { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.strip-meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ash), var(--amber)); transition: width 60ms linear; }
.master { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3) var(--s4) var(--s4); }
.master .viz { height: 56px; }
.ro-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2); }
.ro { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--s2) 0; border: 1px solid var(--line); border-radius: var(--r1); background: var(--ink); min-width: 0; }
.ro-value { font-size: var(--t-title); font-weight: 600; color: var(--chalk); }
.ro-value.clip { color: var(--record); }
.ro-label { font-size: var(--t-cap); color: var(--ash); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 4px; }
.ro-unit { color: var(--ash); font-size: 10px; letter-spacing: 0.04em; }
.row-switch { border-top: 1px solid var(--line); margin-top: var(--s2); padding-left: 0; padding-right: 0; }
.switch { display: flex; align-items: center; justify-content: center; width: 60px; height: var(--tap); flex: none; border: 0; background: transparent; padding: 0; }
.switch-track { position: relative; display: block; width: 52px; height: 32px; border-radius: 16px; border: 1px solid var(--line); background: var(--ink); transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--ash); transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.switch[aria-checked='true'] .switch-track { background: var(--amber); border-color: var(--amber); }
.switch[aria-checked='true'] .switch-knob { transform: translateX(20px); background: var(--ink); }
.master-actions { display: flex; gap: var(--s2); margin-top: var(--s2); }
.master-actions .btn { flex: 1; }

/* ---- Library ---- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s2); }
.section-head .section-title { margin: 0; }
.row-project { padding: 0; gap: 0; }
.row-open { display: flex; align-items: center; gap: var(--s3); flex: 1; min-width: 0; min-height: 64px; padding: var(--s2) var(--s2) var(--s2) var(--s3); border: 0; background: transparent; color: var(--chalk); text-align: left; }
.row-open:active { background: var(--amber-tint); }
.row-project.current .row-open svg.icon.lead { color: var(--amber); }
.row-project .btn-icon { margin-right: var(--s1); }

/* Track mode shows on the play button as a small amber dot. */
.tbtn-play { position: relative; }
.tbtn-play[data-mode='track']::after { content: ''; position: absolute; right: 2px; top: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); border: 2px solid var(--ink); }
.tbtn-play[data-mode='track'][aria-pressed='true']::after { background: var(--ink); border-color: var(--amber); }

/* ---- Play ---- */
.play { display: flex; flex-direction: column; gap: var(--s3); }
.viz-wrap { border: 1px solid var(--line); border-radius: var(--r2); background: var(--ink); padding: var(--s2); }
.viz { display: block; width: 100%; height: 72px; }
@media (max-width: 639px) {
  .play .viz-wrap { padding: 6px var(--s2); }
  .play .viz { height: 48px; }
  /* The screen's height is the surface's: sixteen pads fill it instead of
     scrolling, the recording row stays in view above them, and the XY pad
     comes before its destination chips. */
  .play { min-height: 100%; }
  .play .viz-wrap { order: 0; } .play .segmented { order: 1; } .play .rec-row { order: 2; }
  .play .play-target { order: 3; } .play .play-tools { order: 4; } .play .surface { order: 5; }
  .play:has(.surface[data-surface='xy']) .surface { order: 3; }
  .play:has(.surface[data-surface='xy']) .play-target { order: 4; }
  .play:has(.surface[data-surface='xy']) .play-tools { order: 5; }
  .play:has(.pads) .surface { flex: 1 0 auto; display: flex; flex-direction: column; }
  .pads { flex: 1 0 auto; grid-template-rows: repeat(4, minmax(56px, 1fr)); min-height: 248px; max-height: 424px; }
  .pad { aspect-ratio: auto; min-height: 0; }
}
.segmented.seg-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
.segmented.seg-4 .seg { min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 var(--s2); }
.segmented.seg-4 .seg svg.icon { width: 18px; height: 18px; }
.play-target[hidden] { display: none; }
.play-tools { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; min-height: var(--tap); }
.play-tools .stepper-inline { gap: var(--s2); }
.play-tools .stepper .big { font-size: 24px; }
.play-hint { margin: 0; color: var(--ash); font-size: var(--t-label); }
.surface { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.pads { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2); }
.pad {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 2px;
  aspect-ratio: 1.15; min-height: 64px; padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: var(--r2);
  background: var(--slate); color: var(--chalk); font-weight: 700; text-align: left;
  touch-action: none; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.pad.ghost { background: var(--ink); color: var(--ash); }
.pad.active { background: var(--amber-tint-strong); border-color: var(--amber); color: var(--chalk); }
.pad-name { font-size: var(--t-body); }
.pad-tag { font-size: var(--t-cap); color: var(--ash); font-weight: 500; }
.pad-key { position: absolute; top: 6px; right: 8px; font-family: var(--font-mono); font-size: 10px; color: var(--ash); opacity: 0.7; }
@media (hover: none) { .pad-key { display: none; } }
.pad:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.chord-pads { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.chord-pads .pad { aspect-ratio: auto; min-height: 88px; }
@media (min-width: 640px) { .chord-pads { grid-template-columns: repeat(4, minmax(0, 1fr)); } .chord-pads .pad { min-height: 104px; } }
.keys { display: grid; grid-template-columns: repeat(7, minmax(44px, 1fr)); gap: 3px; overflow-x: auto; }
@media (min-width: 640px) { .keys { grid-template-columns: repeat(14, minmax(44px, 1fr)); } }
.key {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px;
  height: 132px; min-width: 0; padding: var(--s2) 0; border: 1px solid var(--line); border-radius: var(--r1);
  background: var(--slate); color: var(--chalk); font-weight: 600;
  touch-action: none; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}
.key.root { color: var(--amber); }
.key.root::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--amber); border-radius: 2px 2px 0 0; }
.key.active { background: var(--amber-tint-strong); border-color: var(--amber); }
.key-name { font-size: var(--t-body); }
.key-oct { font-size: var(--t-cap); color: var(--ash); font-family: var(--font-mono); }
.key .pad-key { top: auto; bottom: 8px; right: auto; left: 50%; transform: translateX(-50%); }
@media (min-width: 640px) { .key { height: 180px; } }
.xy { position: relative; width: 100%; max-width: 420px; aspect-ratio: 1; margin: 0 auto; border: 1px solid var(--line); border-radius: var(--r2); background: var(--ink); overflow: hidden; touch-action: none; }
.xy:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.xy-canvas { display: block; width: 100%; height: 100%; }
.xy-readout { position: absolute; left: 8px; top: 6px; font-size: var(--t-cap); color: var(--ash); pointer-events: none; white-space: pre; }
.xy-dests { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--s2) var(--s3); width: 100%; }
.xy-reset { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
.rec-row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; min-height: var(--tap); padding: var(--s2) var(--s3); border: 1px solid var(--record); border-radius: var(--r2); }
.rec-row[hidden] { display: none; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--record); flex: none; }
.rec-text { color: var(--chalk); font-size: var(--t-label); }
/* Wide screens: the surface on the left, its instrument and tools beside it. */
@media (min-width: 900px) {
  .play { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); grid-template-rows: auto auto auto minmax(0, 1fr) auto; grid-template-areas: 'viz viz' 'seg seg' 'surface target' 'surface tools' 'rec rec'; align-items: start; column-gap: var(--s5); }
  .play .viz-wrap { grid-area: viz; }
  .play .segmented { grid-area: seg; }
  .play .surface { grid-area: surface; }
  .play .play-target { grid-area: target; }
  .play .play-tools { grid-area: tools; flex-direction: column; align-items: flex-start; }
  .play .rec-row { grid-area: rec; }
  /* The keyboard wants the whole width; its tools sit under it. */
  .play:has(.surface[data-surface='keys']) { grid-template-areas: 'viz viz' 'seg seg' 'surface surface' 'target target' 'tools tools' 'rec rec'; grid-template-rows: auto; }
  .play:has(.surface[data-surface='keys']) .play-tools { flex-direction: row; align-items: center; }
  /* Sixteen pads fill the height on a tablet on its side instead of scrolling. */
  .pads { grid-template-rows: repeat(4, minmax(64px, 1fr)); height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 340px); min-height: 280px; max-height: 620px; }
  .pad { aspect-ratio: auto; min-height: 0; }
}
/* The phone on its side: no spectrum, the tools beside the instrument chips,
   pads in two rows of eight, keys and the XY pad bound to the height. */
@media (min-width: 640px) and (max-height: 500px) {
  .play { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-areas: 'seg seg' 'target tools' 'surface surface' 'rec rec'; align-items: start; column-gap: var(--s3); row-gap: var(--s2); }
  .play .viz-wrap { display: none; }
  .play .segmented { grid-area: seg; }
  .play .play-target { grid-area: target; }
  .play .play-tools { grid-area: tools; flex-direction: row; align-items: center; }
  .play .surface { grid-area: surface; }
  .play .rec-row { grid-area: rec; }
  .play:has(.surface[data-surface='keys']) { grid-template-areas: 'seg seg' 'target tools' 'surface surface' 'rec rec'; grid-template-rows: auto auto minmax(0, 1fr) auto; }
  .play:has(.surface[data-surface='xy']) { grid-template-areas: 'seg seg' 'surface target' 'surface tools' 'rec rec'; grid-template-rows: auto auto minmax(0, 1fr) auto; }
  .pads { grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(52px, 1fr)); height: calc(100dvh - var(--safe-bottom) - 195px); min-height: 112px; max-height: 260px; }
  .pad { aspect-ratio: auto; min-height: 0; padding: var(--s1) var(--s2); }
  .pad-name { font-size: var(--t-label); }
  .chord-pads { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .chord-pads .pad { min-height: 88px; }
  .key { height: clamp(96px, calc(100dvh - var(--safe-bottom) - 195px), 200px); }
  .xy { width: calc(100dvh - var(--safe-bottom) - 143px); min-width: 160px; max-width: 100%; margin: 0; }
  /* While recording, the quantise row takes 52 px from the surface. */
  .play:has(.rec-row:not([hidden])) .pads { height: calc(100dvh - var(--safe-bottom) - 247px); }
  .play:has(.rec-row:not([hidden])) .key { height: clamp(96px, calc(100dvh - var(--safe-bottom) - 247px), 200px); }
  .play:has(.rec-row:not([hidden])) .xy { width: calc(100dvh - var(--safe-bottom) - 195px); }
}

/* ---- Suggestion box ---- */
.feedback-form { display: flex; flex-direction: column; gap: var(--s3); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: var(--t-label); color: var(--ash); }
.textarea { min-height: 120px; padding: var(--s2) var(--s3); resize: vertical; line-height: 1.4; font: inherit; }
.field-check { flex-direction: row; align-items: center; gap: var(--s3); min-height: var(--tap); color: var(--chalk); font-size: var(--t-body); cursor: pointer; }
.check-box { width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 6px; background: var(--ink); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.check-box svg.icon { width: 16px; height: 16px; color: var(--ink); opacity: 0; }
.check:checked + .check-box { background: var(--amber); border-color: var(--amber); }
.check:checked + .check-box svg.icon { opacity: 1; }
.check:focus-visible + .check-box { outline: 2px solid var(--amber); outline-offset: 2px; }
.field-hint { margin: 0; color: var(--ash); font-size: var(--t-label); min-height: 20px; }
.sheet-feedback .sheet-actions { margin-top: var(--s2); }

/* ---- Welcome: a cover with no chrome ---- */
body.cover .topbar, body.cover .transport, body.cover .tabbar { display: none; }
body.cover #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); grid-template-areas: 'screen'; }
body.cover .screen { padding: calc(var(--safe-top) + var(--s6)) max(var(--s5), var(--safe-right)) calc(var(--s6) + var(--safe-bottom)) max(var(--s5), var(--safe-left)); }
.welcome { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; justify-content: center; gap: var(--s5); }
.welcome-hero { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s3); }
.welcome-mark { width: 72px; height: 72px; display: block; }
.welcome-name { margin: 0; font-size: var(--t-hero); font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.welcome-name i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--amber); margin-left: 6px; vertical-align: 4px; }
.welcome-line { margin: 0; font-size: var(--t-head); line-height: 1.3; }
.welcome-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s4); }
.welcome-points li { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: var(--s3); align-items: start; }
.welcome-glyph { width: 44px; height: 44px; border-radius: var(--r2); border: 1px solid var(--line); background: var(--slate); display: inline-flex; align-items: center; justify-content: center; color: var(--amber); flex: none; }
.welcome-points strong { display: block; font-size: var(--t-title); font-weight: 600; margin-bottom: 2px; }
.welcome-points p { margin: 0; color: var(--ash); }
.welcome-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.welcome-actions .btn { flex: 1 1 160px; }
.welcome-install { display: flex; gap: var(--s3); align-items: flex-start; margin: 0; padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r2); color: var(--ash); font-size: var(--t-label); line-height: 1.4; }
.welcome-install svg.icon { color: var(--amber); flex: none; }
.welcome-foot { margin: 0; color: var(--ash); font-size: var(--t-cap); }
@media (min-width: 640px) {
  .welcome { max-width: 880px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--s7); row-gap: var(--s5); align-content: center; }
  .welcome-hero, .welcome-actions, .welcome-install { grid-column: 1; }
  .welcome-points { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
  .welcome-foot { grid-column: 1 / -1; }
}

/* ---- About: the manual ---- */
.topbar-back { margin-left: calc(var(--s2) * -1); }
.topbar-back[hidden] { display: none; }
.about { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s5); }
.about-intro { margin: 0; font-size: var(--t-title); line-height: 1.45; }
.about-text { margin: 0; color: var(--ash); }
.about-screens { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.about-screens li { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: var(--s3); align-items: start; padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r2); background: var(--slate); }
.about-screens strong { display: block; font-size: var(--t-title); font-weight: 600; }
.about-screens p { margin: 4px 0 0; color: var(--ash); }
.about-gestures { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r2); background: var(--slate); }
.about-gestures li { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); }
.about-gestures li:first-child { border-top: 0; }
.about-gestures strong { font-weight: 600; }
.about-gestures span { color: var(--ash); }
.about .section + .section { margin-top: 0; }
