/* Engraved legends: Libre Caslon Text (SIL OFL 1.1, fonts/LibreCaslonText-OFL.txt), bundled so
   labels look the same on every system. Variable font, weights 400-700. */
@font-face {
  font-family: "Libre Caslon Text";
  src: url("fonts/LibreCaslonText.ttf") format("truetype");
  font-weight: 400 700;
  font-style: normal;
  font-display: block;
}
:root {
  color-scheme: light;
  /* Brushed aluminium faceplate */
  --metal-hi: #ece5d8;
  --metal: #d8cdb9;
  --metal-lo: #bcae96;
  --metal-edge: #8d7f6a;
  --engrave: #2b2118;
  --engrave-soft: #5c4c3b;
  /* Walnut cheeks and espresso cabinet */
  --wood: #6a3a1f;
  --wood-dark: #3b1d0e;
  --cabinet: #1b1410;
  /* Smoked glass display */
  --glass: #1c1814;
  --glass-raised: #26201a;
  --glass-line: #3b3229;
  --glass-text: #eadcc6;
  --glass-muted: #b4a48b;
  --wave: #e7c9a1;
  /* Parchment meter faces */
  --parchment: #f0deb6;
  --parchment-lo: #dcc290;
  /* Burnt orange: lit keys, pointers, playhead, readout numerals */
  --accent: #c4561b;
  --accent-hi: #e8803d;
  --accent-lo: #8c3a0f;
  --readout: #f39046;
  --redline: #b8321f;
  /* Cream keycaps */
  --key: #f3ebdd;
  --key-lo: #d9ccb6;
  --key-edge: #9a8970;

  --serif: "Libre Caslon Text", "Iowan Old Style", "Charter", ui-serif, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Design units: real viewport units on phones; on the desktop hardware unit they are pinned
     to the 1060x790 design, and the whole unit scales as one (see the head script). */
  --vh: 1vh;
  --vw: 1vw;
  --gap: clamp(6px, calc(0.9 * var(--vh)), 10px);
  --radius: 7px;

  --brushed: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.0025 0.95' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0.33 0 0 0 0 0.28 0 0 0 0 0.22 0 0 0 0.4 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --brushed-fine: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='200'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.012 1.9' numOctaves='1' seed='3'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 0.97 0 0 0 0 0.92 0 0 0 0.28 -0.04'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='900'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.09 0.0045' numOctaves='3' seed='11'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.04 0 0 0 0 0.015 0 0 0 1.9 -0.45'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)'/%3E%3C/svg%3E");

  font: 14px/1.4 var(--sans);
  color: var(--engrave);
  background: var(--cabinet);
}
* { box-sizing: border-box }
/* ---------- Hardware unit (desktop) ----------
   One fixed design, scaled uniformly by window height (or width on narrow windows). The plates
   stretch to fill the window so there are never empty bars; only spacing adapts, never size. */
html.hardware { --vh: 7.9px; --vw: 10.6px }
html.hardware, html.hardware body { height: 100%; overflow: hidden }
html.hardware .cabinet {
  position: fixed; left: 0; top: 0;
  width: calc(100vw / var(--scale, 1)); height: calc(100vh / var(--scale, 1));
  min-height: 0; max-width: none; margin: 0;
  transform: scale(var(--scale, 1)); transform-origin: 0 0;
  container-type: inline-size;
}
html, body { margin: 0; min-height: 100% }
body { accent-color: var(--accent) }
::selection { background: var(--accent-hi); color: #fff }
:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px }
button, select, input { font: inherit; color: inherit }
h1, h2, p, figure { margin: 0 }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden }
.icon { width: 18px; height: 18px; flex: none }
::-webkit-scrollbar { width: 10px; height: 10px }
::-webkit-scrollbar-thumb { background: #5a4636; border-radius: 6px; border: 2px solid var(--cabinet) }
::-webkit-scrollbar-track { background: var(--cabinet) }

/* ---------- Cabinet: walnut cheeks around a stack of faceplates ---------- */
.cabinet {
  position: relative;
  max-width: 1480px;
  min-height: 100vh;
  margin: 0 auto;
  padding: var(--gap) 30px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  background: linear-gradient(#2a211a, #1d1611);
}
.cabinet::before, .cabinet::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 20px;
  background: var(--grain), linear-gradient(90deg, var(--wood-dark), #8a4f2c 30%, var(--wood) 55%, #94582f 75%, var(--wood-dark));
  background-size: 120px 900px, auto;
  box-shadow: inset -2px 0 3px rgba(0, 0, 0, .45), inset 2px 0 2px rgba(255, 220, 180, .12);
}
.cabinet::before { left: 0 }
.cabinet::after { right: 0; transform: scaleX(-1) }

.plate {
  position: relative;
  border-radius: var(--radius);
  background: var(--brushed-fine), var(--brushed), linear-gradient(180deg, var(--metal-hi), var(--metal) 42%, var(--metal-lo));
  background-size: 400px 200px, 600px 300px, auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .75), inset 0 -1px 0 rgba(60, 40, 20, .28),
              0 1px 0 rgba(0, 0, 0, .5), 0 4px 10px -2px rgba(0, 0, 0, .55);
}
.screw {
  position: absolute;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fbf6ee, #b5a68e 55%, #786a56);
  box-shadow: 0 1px 1px rgba(255, 255, 255, .6), inset 0 -1px 1px rgba(0, 0, 0, .35);
}
.screw::after {
  content: "";
  position: absolute;
  left: 2px; right: 2px; top: 5px;
  height: 1.5px;
  background: rgba(60, 45, 30, .7);
  transform: rotate(-35deg);
}
.screw.tl { left: 9px; top: 9px } .screw.tr { right: 9px; top: 9px }
.screw.bl { left: 9px; bottom: 9px } .screw.br { right: 9px; bottom: 9px }

/* ---------- Keys ---------- */
.key {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 16px;
  border: 1px solid var(--key-edge);
  border-radius: 5px;
  background: linear-gradient(180deg, #faf5ec, var(--key) 45%, var(--key-lo));
  color: var(--engrave);
  font-weight: 560;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 1px 0 rgba(70, 50, 30, .35), 0 3px 6px -2px rgba(0, 0, 0, .45);
  transition: transform .08s ease-out, box-shadow .08s ease-out, background-color .15s;
}
.key:hover { background: linear-gradient(180deg, #fffaf2, #f6efe2 45%, #ded2bd) }
.key:active, .key[aria-pressed="true"] {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .3);
}
.key[aria-pressed="true"], .key-play {
  border-color: var(--accent-lo);
  background: linear-gradient(180deg, #b4501c, #a2461a 55%, #873912);
  color: #fffaf3;
  text-shadow: 0 1px 0 rgba(90, 30, 0, .45);
}
.key-play:hover, .key[aria-pressed="true"]:hover { background: linear-gradient(180deg, #bd5720, #a94a1b 55%, #8e3c13) }
.key:disabled { cursor: default; color: var(--engrave-soft); transform: none; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 1px 0 rgba(70, 50, 30, .25) }
.key:disabled .icon { opacity: .7 }
.key-quiet { background: linear-gradient(180deg, #f3ece0, #e4d9c6); font-weight: 520 }
.key-small { min-height: 28px; padding: 3px 12px; font-size: 13px }
.key-file { overflow: hidden }
.key-file input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none }
.key-file:has(input:focus-visible) { outline: 2px solid var(--accent-hi); outline-offset: 2px }
.key-file:has(input:disabled) { color: var(--engrave-soft); cursor: default }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 9px 14px 9px 22px;
}
.brand { display: flex; align-items: baseline; gap: 10px; padding-right: 22px; border-right: 1px solid rgba(80, 60, 40, .35); box-shadow: 1px 0 0 rgba(255, 255, 255, .5) }
.wordmark a { color: inherit; text-decoration: none }
.wordmark a:hover { text-decoration: underline }
.wordmark { font: 700 27px/1 var(--serif); letter-spacing: -0.01em; color: var(--engrave); text-shadow: 0 1px 0 rgba(255, 255, 255, .6) }
#tier {
  font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase;
  color: var(--engrave-soft); border: 1px solid rgba(90, 70, 50, .45); border-radius: 4px; padding: 1px 6px;
}
.presets { display: flex; align-items: center; gap: 14px; min-width: 0 }
.legend-small { font-weight: 600; color: var(--engrave-soft) }
.keys { display: flex; gap: 4px }
.keys .key { min-width: 104px }
.topbar-actions { margin-left: auto; display: flex; gap: 8px }

/* ---------- Display ---------- */
.display {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 12px 16px 10px 18px;
  border-radius: 9px;
  background: radial-gradient(120% 140% at 30% 0%, #2c251e, var(--glass) 60%);
  color: var(--glass-text);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, .7), inset 0 0 0 1px #0d0a08, 0 1px 0 rgba(255, 255, 255, .08),
              0 0 0 4px #4a3d31, 0 0 0 5px #6b5a48;
  margin: 4px 4px 2px;
  flex: 1 1 auto;
  min-height: 0;
}
.display-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 6px }
.display-head { display: flex; align-items: center; gap: 12px }
.icon-file { width: 30px; height: 30px; color: var(--glass-muted) }
.track-id { min-width: 0; flex: 1 }
#title { font: 600 19px/1.2 var(--sans); letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--glass-muted); min-width: 0 }
.meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; flex: none }
#meta { white-space: nowrap }
#status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--glass-text) }
#clock {
  font: 600 15px/1 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: .02em;
  color: var(--readout); padding: 6px 10px; border-radius: 5px;
  background: #120f0c; box-shadow: inset 0 1px 3px rgba(0, 0, 0, .8), 0 1px 0 rgba(255, 255, 255, .06);
}
.scope { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column }
#wave { display: block; width: 100%; flex: 1 1 0; min-height: clamp(58px, calc(9 * var(--vh)), 104px); cursor: crosshair; touch-action: none; border-radius: 3px }
#wave:focus-visible { outline-offset: 3px }
#ruler { position: relative; flex: none; height: 24px; margin-top: 2px; border-top: 1px solid var(--glass-line); font-size: 11px; color: var(--glass-muted); font-variant-numeric: tabular-nums }
#ruler span { position: absolute; top: 0; transform: translateX(-50%); padding-top: 7px }
#ruler span::before { content: ""; position: absolute; left: 50%; top: -1px; width: 1px; height: 6px; background: var(--glass-muted) }
#ruler span:first-child { transform: none } #ruler span:first-child::before { left: 0 }
#ruler span.last { transform: translateX(-100%) } #ruler span.last::before { left: auto; right: 0 }

.meters { display: flex; gap: 10px; align-items: stretch; align-self: center }
.vu { display: flex; flex-direction: column; align-items: center; gap: 4px }
.vu figcaption { font-size: 12px; font-weight: 600; color: var(--glass-muted) }
.vu-face {
  width: clamp(130px, calc(13 * var(--vw)), 176px); height: auto; border-radius: 5px;
  background: radial-gradient(130% 120% at 50% 110%, var(--parchment-lo), var(--parchment) 60%, #f6e8c8);
  box-shadow: inset 0 0 0 1px rgba(80, 55, 25, .5), inset 0 2px 6px rgba(70, 40, 10, .35), 0 0 0 3px #3a2f25, 0 0 0 4px #5e4e3e;
}

/* ---------- Transport ---------- */
.transport {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 28px;
  padding: 8px 52px;
}
.reel-window {
  height: clamp(52px, calc(8 * var(--vh)), 74px);
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  background: linear-gradient(#1b1612, #2a211a);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, .75), inset 0 0 0 1px #0d0a08, 0 1px 0 rgba(255, 255, 255, .6), 0 0 0 3px #4a3d31;
  display: grid;
  place-items: center;
}
.reel-window::after {
  /* glass reflection */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(165deg, rgba(255, 245, 230, .14), rgba(255, 245, 230, 0) 38%);
}
.reel { height: 190%; width: auto; aspect-ratio: 1; display: block }
.transport-keys { display: flex; gap: 12px; align-items: center }
.key-transport {
  flex-direction: column; gap: 4px;
  min-width: clamp(104px, calc(11 * var(--vw)), 150px); min-height: clamp(50px, calc(6.8 * var(--vh)), 72px);
  font-size: 15px; border-radius: 7px;
}
.key-transport .icon { width: 22px; height: 22px }
.key-play { min-width: clamp(132px, calc(14 * var(--vw)), 190px) }
/* While playing, Play stays latched down and lit rather than greying out. */
.key-play:disabled { color: #fffaf3; transform: translateY(1px); box-shadow: inset 0 3px 6px rgba(0, 0, 0, .4) }
.key-play:disabled .icon { opacity: 1 }

/* ---------- Rack ---------- */
.rack-main {
  display: grid;
  grid-template-columns: 250px repeat(3, minmax(0, 1fr));
  align-items: start;
  padding: 10px 24px 12px;
}
.mode-col {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding-right: 22px; margin-right: 6px; align-self: stretch;
  border-right: 1px solid rgba(80, 60, 40, .3); box-shadow: 1px 0 0 rgba(255, 255, 255, .45);
}
.keys-mode { gap: 0 }
.keys-mode .key { min-width: 0; padding-inline: 12px; border-radius: 0 }
.keys-mode .key:first-child { border-radius: 5px 0 0 5px }
.keys-mode .key:last-child { border-radius: 0 5px 5px 0 }
.keys-mode .key + .key { margin-left: -1px }

.knob { position: relative; display: grid; justify-items: center; gap: 6px; --d: 120px }
.knob-lg { --d: clamp(92px, calc(15 * var(--vh)), 184px) }
.knob-sm { --d: clamp(54px, calc(8 * var(--vh)), 92px) }
.knob-xs { --d: clamp(40px, calc(5.9 * var(--vh)), 64px); gap: 4px }
/* Readout tucks into the open notch at the bottom of the scale, between the end labels,
   so each knob needs no separate readout row. */
.knob-lg, .knob-sm {
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "legend legend legend" "dial dial dial" "lo out hi";
  align-items: center;
  column-gap: 8px;
}
.knob-lg .legend, .knob-sm .legend { grid-area: legend }
.knob-lg .dial, .knob-sm .dial { grid-area: dial }
.knob-lg .ends, .knob-sm .ends { display: contents }
.knob-lg .ends span, .knob-sm .ends span { margin-top: calc(var(--d) * -.2) }
.knob-lg .ends span:first-child, .knob-sm .ends span:first-child { grid-area: lo; justify-self: end }
.knob-lg .ends span:last-child, .knob-sm .ends span:last-child { grid-area: hi; justify-self: start }
.knob-lg .readout, .knob-sm .readout { grid-area: out; margin-top: calc(var(--d) * -.2) }
.legend { font: 700 clamp(18px, calc(2.6 * var(--vh)), 23px)/1 var(--serif); color: var(--engrave); text-shadow: 0 1px 0 rgba(255, 255, 255, .55); cursor: default }
.knob-sm .legend { font-size: 18px }
.knob-xs .legend { font: 600 12.5px/1.1 var(--sans); color: var(--engrave-soft); text-shadow: none }
.dial {
  position: relative;
  width: calc(var(--d) * 1.32); height: calc(var(--d) * 1.32);
  display: grid; place-items: center;
  cursor: grab; touch-action: none; user-select: none;
}
.dial:active { cursor: grabbing }
.dial .ticks { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--engrave) }
.cap {
  position: relative;
  width: var(--d); height: var(--d);
  border-radius: 50%;
  /* knurled skirt */
  background: linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(40, 25, 10, .38)), repeating-conic-gradient(#d6ccbb 0 1deg, #7a6d59 1deg 2deg);
  box-shadow: 0 calc(var(--d) * .06) calc(var(--d) * .1) rgba(0, 0, 0, .45), 0 2px 3px rgba(0, 0, 0, .4),
              inset 0 0 0 1px rgba(60, 45, 30, .55), 0 0 0 2px #5a4b3a;
}
.cap::before {
  /* machined face: the sheen stays put like real light while the pointer turns */
  content: "";
  position: absolute; inset: 7%;
  border-radius: 50%;
  background: conic-gradient(from 12deg, #f7f1e6, #b8aa92 22%, #f1e9dc 38%, #a5967e 58%, #ede4d5 76%, #b3a58d 90%, #f7f1e6);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .9), inset 0 -2px 3px rgba(60, 40, 20, .35), 0 0 0 1px rgba(70, 55, 40, .4);
}
.pointer { position: absolute; inset: 0; transform: rotate(var(--angle, -135deg)) }
.pointer::after {
  content: "";
  position: absolute; left: 50%; top: 12%;
  width: max(3px, calc(var(--d) * .035)); height: 26%;
  transform: translateX(-50%);
  border-radius: 2px;
  background: linear-gradient(var(--accent-hi), var(--accent));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .3);
}
.knob-xs .pointer::after { top: 9%; height: 32% }
.dial-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none }
.knob:has(.dial-input:focus-visible) .cap { outline: 2px solid var(--accent-hi); outline-offset: 5px }
.knob:has(.dial-input:disabled) .dial { cursor: not-allowed }
.knob:has(.dial-input:disabled) .pointer::after { background: var(--engrave-soft); box-shadow: none }
.knob:has(.dial-input:disabled) .readout { color: #9c8872 }
.ends { display: flex; justify-content: space-between; width: min(100%, calc(var(--d) * 1.6)); margin-top: calc(var(--d) * -.2); font-size: 12.5px; color: var(--engrave-soft); font-variant-numeric: tabular-nums }
.readout {
  min-width: 84px; padding: 5px 12px;
  border-radius: 5px; text-align: center;
  font: 600 clamp(15px, calc(2.2 * var(--vh)), 20px)/1.15 var(--sans); font-variant-numeric: tabular-nums;
  color: var(--readout);
  background: linear-gradient(#17130f, #231c16);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .85), 0 1px 0 rgba(255, 255, 255, .55);
}
.knob-sm .readout { min-width: 72px; font-size: 15px }
.knob-xs .readout { min-width: 58px; padding: 3px 6px; font-size: 12.5px }

.rack-row {
  display: grid; gap: 8px; align-items: stretch;
  /* rack-main: 24px padding + 250px mode column + three equal knob columns */
  grid-template-columns: calc(270px + (100cqw - 298px) / 3) calc((100cqw - 298px) / 3 - 8px) minmax(0, 1fr);
}
.module { padding: 8px 30px 10px 22px; display: flex; flex-direction: column; gap: 4px }
.module { min-width: 0 }
.module fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: contents }
.module-head { display: flex; align-items: center; gap: 8px 10px; padding-left: 8px }
.module-head select { min-width: 0; flex: 0 1 auto; text-overflow: ellipsis }
.module-voice .module-head select { flex: none }
.module-head h2 { font: 700 18px/1 var(--serif); margin-right: auto; white-space: nowrap; text-shadow: 0 1px 0 rgba(255, 255, 255, .55) }
.module-knobs { display: flex; justify-content: space-evenly; gap: 14px }
.pro-keys { display: flex; flex-direction: column; justify-content: center; gap: 6px }
.module-pro .module-knobs { gap: 10px }
.module-pro:has(#paid:disabled) .module-head h2::after { content: " · locked"; font: 500 12.5px var(--sans); color: var(--engrave-soft) }
select {
  appearance: none;
  min-height: 30px; padding: 4px 30px 4px 10px;
  border: 1px solid var(--key-edge); border-radius: 5px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%232b2118' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") right 10px center no-repeat,
              linear-gradient(#faf5ec, var(--key-lo));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 1px 3px rgba(0, 0, 0, .25);
  font-size: 13px; cursor: pointer;
}
select:disabled { color: var(--engrave-soft); cursor: not-allowed }

/* ---------- Session strip ---------- */
.session {
  display: flex; align-items: center; gap: 14px;
  margin-top: auto;
  padding: 4px 14px 4px 22px;
  border-radius: var(--radius);
  background: linear-gradient(#2a221b, #1e1813);
  color: var(--glass-text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 2px 6px rgba(0, 0, 0, .5);
}
.session h2 { font: 600 15px/1.2 var(--sans); white-space: nowrap }
#tracks { display: flex; gap: 8px; overflow-x: auto; flex: 1; min-width: 0; padding: 3px }
#tracks button {
  display: flex; align-items: center; gap: 10px;
  min-width: 170px; max-width: 260px; padding: 4px 12px;
  border: 1px solid #4b3f33; border-radius: 6px;
  background: linear-gradient(#30271f, #261f19);
  color: var(--glass-text); text-align: left; cursor: pointer;
}
#tracks button:hover { border-color: #6b5948 }
#tracks button[aria-current="true"] { border-color: var(--accent-hi); box-shadow: inset 0 0 0 1px rgba(232, 128, 61, .35) }
#tracks button .icon { width: 22px; height: 22px; color: var(--glass-muted) }
#tracks button[aria-current="true"] .icon { color: var(--accent-hi) }
#tracks .name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
#tracks .length { display: block; font-size: 12px; color: var(--glass-muted); font-variant-numeric: tabular-nums }
.session .add { flex: none }
.privacy { font-size: 12px; color: var(--glass-muted); white-space: nowrap }

/* ---------- Unlock dialog ---------- */
.key[hidden], #activation[hidden] { display: none }
dialog {
  width: min(420px, calc(100vw - 32px));
  border: 0; padding: 26px 26px 22px;
  color: var(--engrave);
}
dialog::backdrop { background: rgba(15, 10, 6, .6) }
dialog h2 { font: 700 24px/1.1 var(--serif); margin-bottom: 8px }
dialog p { color: var(--engrave-soft); margin-bottom: 14px }
dialog .close { position: absolute; right: 12px; top: 12px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; cursor: pointer; display: grid; place-items: center }
dialog .close .icon { transform: rotate(45deg) }
dialog .close:hover { background: rgba(60, 40, 20, .1) }
#activation { display: grid; gap: 8px; margin: 14px 0 6px }
#activation label { font-weight: 600 }
#key {
  min-height: 36px; padding: 6px 10px;
  border: 1px solid var(--key-edge); border-radius: 5px;
  background: #fbf7f0; box-shadow: inset 0 1px 3px rgba(60, 40, 20, .25);
  caret-color: var(--accent);
}
#message { font-size: 13px; margin: 6px 0 0 }

/* ---------- Narrower windows ---------- */
/* Design-width refinements (the hardware unit is laid out at 1060 wide). */
.keys .key { min-width: 0; padding-inline: 13px }
.keys-mode .key { padding-inline: 9px }
.mode-col { padding-right: 14px }

/* ---------- Phone mode (narrow screens reflow; desktop scales as one unit) ---------- */
html.phone .topbar { flex-wrap: wrap; gap: 12px }
html.phone .rack-main { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 14px }
html.phone .mode-col { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 24px; border-right: 0; box-shadow: none; padding: 0 0 12px; margin: 0; border-bottom: 1px solid rgba(80, 60, 40, .3) }
html.phone .rack-row { display: flex; flex-direction: column }
html.phone .privacy { display: none }

html.phone .cabinet { padding-inline: 26px }
html.phone .display { grid-template-columns: 1fr }
html.phone .meters { justify-content: center }
html.phone .display-head { flex-wrap: wrap }
html.phone .track-id { flex-basis: calc(100% - 42px) }
html.phone #clock { order: 3; margin-left: 42px }
html.phone .meta .dot { display: none }
html.phone #status { flex-basis: 100% }
html.phone .presets .legend-small { display: none }
html.phone .meta { flex-wrap: wrap; row-gap: 2px }
html.phone #meta, html.phone #status { white-space: normal }
html.phone .transport { grid-template-columns: 1fr 1fr; grid-template-areas: "reelL reelR" "keys keys"; gap: 10px; padding: 14px 16px }
html.phone .transport > div:first-of-type { grid-area: reelL }
html.phone .transport > div:last-of-type { grid-area: reelR }
html.phone .transport-keys { grid-area: keys; justify-content: center }
html.phone .reel-window { height: 44px }
html.phone .rack-main { grid-template-columns: 1fr 1fr; grid-template-areas: "mode mode" "speed reverb" "pitch grit"; padding-inline: 12px }
html.phone .mode-col { display: contents }
html.phone .keys-mode { grid-area: mode; justify-self: center }
html.phone .mode-col .knob { grid-area: pitch }
html.phone .rack-main > .knob:has(#speed) { grid-area: speed }
html.phone .rack-main > .knob:has(#space) { grid-area: reverb }
html.phone .rack-main > .knob:has(#grit) { grid-area: grit }
html.phone .mode-col .knob, html.phone .rack-main > .knob:has(#grit) { align-self: end }
/* Narrow cells: end labels on their own row above the readout. */
html.phone .knob-lg, html.phone .knob-sm { grid-template-areas: "legend legend legend" "dial dial dial" "lo . hi" "out out out"; row-gap: 2px }
html.phone .knob-lg .readout, html.phone .knob-sm .readout { margin-top: 2px }
html.phone .module-space .module-knobs { display: grid; grid-template-columns: repeat(3, 1fr) }
/* Knobs size from the width on phones, not the (tall) height. */
html.phone .knob-lg { --d: clamp(70px, calc(22 * var(--vw)), 104px) }
html.phone .knob-sm { --d: 56px }
html.phone .knob-xs { --d: 44px }
html.phone .module { padding: 8px 26px 10px 14px }
html.phone .module-head { flex-wrap: wrap }
html.phone .module-knobs { flex-wrap: wrap; row-gap: 10px }
html.phone .key-transport { min-width: 0; flex: 1; padding-inline: 8px }
html.phone .key-play { min-width: 0; flex: 1.4 }
html.phone .transport-keys { width: 100% }
html.phone .session { flex-wrap: wrap; padding: 10px 14px }
html.phone .session h2 { margin-right: auto }
html.phone #tracks { order: 3; flex-basis: 100% }
html.phone .brand { border: 0; box-shadow: none; padding: 0 }

@media (prefers-reduced-motion: reduce) {
  .key { transition: none }
}
