:root {
  --bg: #0c0d0f;
  --bg2: #141518;
  --line: #24262b;
  --text: #e9e7e2;
  --mute: #8d8b86;
  --hot: #f2a33a;
  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--ui); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; overflow-x: hidden; padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left); }
/* viewport-fit=cover: in the installed app (black-translucent status bar) the page runs under the status bar and the home
   indicator — the header, the keyboard panel, dialogs and full-screen layers keep their content inside the safe area
   (a scrolled-to element stops below the status bar); a browser tab's insets are 0 */
html { scroll-padding-top: env(safe-area-inset-top); }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd { font-family: var(--mono); font-size: 0.85em; padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--bg2); }

/* ---------------------------------------------------------- top bar */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; padding: calc(14px + env(safe-area-inset-top)) 24px 14px; border-bottom: 1px solid var(--line); background: linear-gradient(#111215, #0c0d0f); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark { width: 34px; height: 34px; color: var(--hot); }
.logo { font-weight: 800; letter-spacing: 0.32em; font-size: 18px; }
.sub { font-size: 11px; color: var(--mute); letter-spacing: 0.06em; }
.engine { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 10px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.08em; }
.field select { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 12px; text-transform: none; letter-spacing: 0; }
.field.range input { width: 110px; accent-color: var(--hot); }
.power { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 8px; border: 1px solid #3a3326; background: #1a1712; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; font-size: 12px; }
.power .led, .hold .led { width: 9px; height: 9px; border-radius: 50%; background: #3a1a12; box-shadow: inset 0 0 2px #000; }
.power[aria-pressed="true"] .led, .hold[aria-pressed="true"] .led { background: #ff4a2a; box-shadow: 0 0 8px #ff4a2a, 0 0 2px #fff inset; }
.power[aria-pressed="true"] { border-color: #6b3b20; }
.meter { display: flex; flex-direction: column; font-family: var(--mono); font-size: 11px; color: var(--mute); min-width: 210px; line-height: 1.3; }
.meter #rate { color: var(--text); }
.meter .warn { color: #ff6a4a; }
/* Output latency (main.js initLatency): the meter's third line, a compact button (a field of its own widened the header
   to two rows at 1280–1400 px); its popover under it, kept inside the viewport */
.latf { position: relative; display: flex; align-items: center; gap: 6px; }
.latf > button { position: relative; background: var(--bg2); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; font: 11px/12px var(--mono); color: var(--text); min-width: 0; text-align: left; -webkit-tap-highlight-color: transparent; }
.latf > button[aria-expanded="true"] { border-color: var(--hot); }
.latpop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: min(320px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid #3a3c42; border-radius: 10px; background: var(--bg2); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55); color: var(--text); text-transform: none; letter-spacing: 0; font-family: var(--ui); font-size: 12px; line-height: 1.4; }
.latpop[hidden] { display: none; }
.latnote { margin: 0; color: var(--mute); line-height: 1.45; }
.latpre { display: flex; gap: 6px; flex-wrap: wrap; }
.latpop button { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font-size: 12px; -webkit-tap-highlight-color: transparent; }
.latpop button[aria-pressed="true"] { border-color: var(--hot); color: var(--hot); background: #1d1810; }
.latpop button:disabled { opacity: 0.45; cursor: default; }
.latrow { display: flex; align-items: center; gap: 6px; }
.latrow input { flex: 1 1 auto; min-width: 0; accent-color: var(--hot); }
.latrow button { width: 30px; padding: 4px 0; }
.latrow output { font-family: var(--mono); min-width: 58px; text-align: right; }
.latinfo { margin: 0; font-family: var(--mono); font-size: 11px; line-height: 1.5; color: var(--mute); white-space: pre-wrap; }
/* touch targets: the header button stays one meter line tall (taller would grow the header row) — a larger hit area */
@media (pointer: coarse) { .latf > button::after { content: ''; position: absolute; inset: -9px -10px; } .latpop button { min-height: 34px; } .latrow button { width: 38px; } .latrow input { height: 32px; } }
.boot { margin: 0; font-size: 13px; color: var(--label); line-height: 1.5; }
/* Install app / Full screen (pwa.js shows the ones this browser offers; none in the installed app) */
.appctl { display: flex; align-items: center; gap: 8px; }
.appbtn { display: flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); font-size: 12px; font-weight: 600; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.appbtn[hidden] { display: none; }
.appbtn:hover { border-color: #3a3c42; }
.appbtn:focus-visible { outline: 2px solid var(--hot); outline-offset: 1px; }
.appbtn svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.appbtn.ico { width: 34px; padding: 0; }
#install { color: var(--hot); border-color: #5a4320; background: #1d1810; }
/* a touch screen: Install as an icon (its aria-label says it) — one header row less */
@media (pointer: coarse) { #install { width: 34px; padding: 0; } #install > span { display: none; } }
#fullscreen .i-exit, #fullscreen[aria-pressed="true"] .i-enter { display: none; }
#fullscreen[aria-pressed="true"] .i-exit { display: inline; }
#fullscreen[aria-pressed="true"] { color: var(--hot); border-color: #5a4320; }

/* ---------------------------------------------------------- model nav */
.models { display: flex; gap: 8px; padding: 14px 24px; overflow-x: auto; scrollbar-width: thin; border-bottom: 1px solid var(--line); }
.models button { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); text-align: left; min-width: 112px; transition: border-color 0.15s, background 0.15s; }
.models button:hover { border-color: #3a3c42; }
.models button .yr { font-family: var(--mono); font-size: 10px; color: var(--mute); }
.models button .nm { font-weight: 700; font-size: 13px; white-space: nowrap; }
.models button .mk { font-size: 10px; color: var(--mute); white-space: nowrap; }
.models button.on { border-color: var(--hot); background: #1d1810; }
.models button.on .yr { color: var(--hot); }

main { padding: 18px 24px 8px; max-width: 1600px; margin: 0 auto; }

/* ---------------------------------------------------------- instrument */
.inst {
  --panel: #151515; --face: #0e0e0e; --ink: #eee; --label: #ccc; --accent: #f2a33a; --cap: #eee; --capline: #111;
  position: relative; background: var(--panel); color: var(--ink); border-radius: 10px; padding: 18px 22px 22px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, 0 20px 50px -20px rgba(0,0,0,0.8), 0 0 0 1px rgba(0,0,0,0.6);
  font-family: 'Helvetica Neue', Helvetica, Arial, var(--ui);
}
.inst.wood { margin: 0 22px; border-radius: 4px; }
.inst.wood::before, .inst.wood::after {
  content: ''; position: absolute; top: -6px; bottom: -6px; width: 22px; border-radius: 6px;
  background: linear-gradient(90deg, rgba(0,0,0,0.35), rgba(255,255,255,0.06) 40%, rgba(0,0,0,0.3)),
    repeating-linear-gradient(176deg, #5a3218 0 3px, #6e3e1e 3px 7px, #4d2a14 7px 9px, #66391c 9px 14px);
  box-shadow: 0 10px 30px -10px #000;
}
.inst.wood::before { left: -22px; }
.inst.wood::after { right: -22px; }

.plate { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid rgba(127,127,127,0.25); }
.nameplate { display: flex; flex-direction: column; }
.nameplate .maker { font-size: 11px; letter-spacing: 0.28em; text-transform: uppercase; color: var(--label); opacity: 0.85; }
.nameplate .mname { font-size: 34px; font-weight: 800; letter-spacing: 0.02em; line-height: 1.05; }
.nameplate .mmodel { font-size: 12px; color: var(--label); letter-spacing: 0.08em; margin-top: 2px; }
.plate .tag { font-size: 12px; color: var(--label); max-width: 520px; flex: 1 1 260px; opacity: 0.9; }
.stripes { display: flex; height: 6px; gap: 0; margin-top: 8px; width: 160px; }
.stripes i { flex: 1; }

.presets { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.presets select { background: rgba(0,0,0,0.35); color: var(--ink); border: 1px solid rgba(127,127,127,0.4); border-radius: 6px; padding: 6px 8px; font-size: 13px; max-width: 220px; }
.presets select option, .presets select optgroup { background: #1a1a1a; color: #eee; }
.presets button { background: rgba(0,0,0,0.25); border: 1px solid rgba(127,127,127,0.4); border-radius: 6px; padding: 6px 10px; font-size: 12px; color: var(--ink); }
.presets button:hover { border-color: var(--accent); }

.secs { display: flex; flex-wrap: wrap; gap: 10px; }
.sec { background: var(--face); border-radius: 6px; padding: 9px 12px 12px; border: 1px solid rgba(127,127,127,0.18); flex: 0 1 auto; }
.sec h3 { margin: 0 0 9px; font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--label); padding-bottom: 5px; border-bottom: 2px solid var(--accent); }
.ctls { display: flex; flex-wrap: wrap; gap: 10px 10px; align-items: flex-start; }
.ctl { display: flex; flex-direction: column; align-items: center; width: 60px; }
.ctl > label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--label); text-align: center; line-height: 1.15; margin-top: 5px; user-select: none; }
.ctl.t-s { width: auto; min-width: 60px; }

/* knobs */
.knob { width: 50px; height: 50px; touch-action: none; cursor: ns-resize; outline: none; border-radius: 50%; }
.knob:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.knob svg { width: 100%; height: 100%; display: block; overflow: visible; }
.knob .ticks line { stroke: var(--label); stroke-width: 1.2; opacity: 0.7; }
.knob .skirt { fill: #1a1a1a; }
.knob .cap { fill: #111; }
.knob .ind { stroke: #fff; stroke-width: 2.6; stroke-linecap: round; }
.knob .shine { fill: url(#knobShine); }
/* Moog: black cap, ridged aluminium skirt */
.knob-moog .knob .skirt { fill: #b9b9b6; stroke: #6b6b68; stroke-width: 1; stroke-dasharray: 1.4 1.4; }
.knob-moog .knob .cap { fill: #121212; }
/* Prophet: black with silver insert */
.knob-prophet .knob .skirt { fill: #0b0b0b; stroke: #333; }
.knob-prophet .knob .cap { fill: #9fa2a5; stroke: #222; stroke-width: 2; }
.knob-prophet .knob .ind { stroke: #111; }
/* Korg MS-20: plain black */
.knob-korg .knob .skirt { fill: #050505; stroke: #2c2c2c; }
.knob-korg .knob .cap { fill: #141414; }
.knob-korg .knob .ind { stroke: #fff; }
/* TB-303: black on silver */
.knob-tb .knob .skirt { fill: #1a1a1a; stroke: #000; }
.knob-tb .knob .cap { fill: #262626; }
.knob-tb .knob .ticks line { stroke: #222; }
/* Oberheim */
.knob-ob .knob .skirt { fill: #0a0a0a; stroke: #2a2f35; }
.knob-ob .knob .cap { fill: #1c2024; }
.knob-ob .knob .ind { stroke: #58b2ff; }
/* Solina */
.knob-solina .knob .skirt { fill: #c9c4b8; stroke: #6d675c; }
.knob-solina .knob .cap { fill: #1b1714; }
.knob-solina .knob .ind { stroke: #f2a33a; }

/* sliders */
.slider { width: 26px; height: 104px; position: relative; touch-action: none; cursor: ns-resize; outline: none; }
.slider:focus-visible { box-shadow: 0 0 0 2px var(--accent); border-radius: 3px; }
.slider .groove { position: absolute; left: 50%; top: 6px; bottom: 6px; width: 4px; margin-left: -2px; background: #050505; border-radius: 2px; box-shadow: inset 0 1px 2px #000, 0 1px 0 rgba(255,255,255,0.08); }
.slider .sticks { position: absolute; inset: 6px 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.slider .sticks i { display: block; height: 1px; background: var(--label); opacity: 0.45; margin: 0 1px; }
.slider .cap { position: absolute; left: 1px; right: 1px; height: 14px; border-radius: 2px; background: var(--cap); box-shadow: 0 2px 3px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.4); }
.slider .cap::after { content: ''; position: absolute; left: 2px; right: 2px; top: 6px; height: 2px; background: var(--capline); }

/* numeric (DX7 membrane / LCD) */
.num { min-width: 42px; padding: 5px 4px; text-align: center; font-family: var(--mono); font-size: 14px; font-weight: 600; color: #8ff5e3; background: #0c1715; border: 1px solid #1d3a35; border-radius: 3px; text-shadow: 0 0 6px rgba(80,240,210,0.45); touch-action: none; cursor: ns-resize; user-select: none; outline: none; }
.num:focus-visible { border-color: var(--accent); }
.ctl-num .ctl { width: 52px; }
.ctl-num .num { min-width: 48px; font-size: 13px; }
/* the six operator rows scroll together in one container, so row 1's labels stay over every column */
.ctl-num .opswrap { flex: 1 1 100%; min-width: 0; overflow-x: auto; display: flex; flex-direction: column; gap: 6px; scrollbar-width: thin; }
.ctl-num .sec.op { flex: none; width: max-content; min-width: 100%; display: flex; align-items: center; gap: 12px; padding: 6px 12px; }
.ctl-num .sec.op h3 { margin: 0; border: 0; padding: 0 6px 0 0; width: 64px; flex: 0 0 auto; color: var(--accent); position: sticky; left: 0; z-index: 1; background: var(--face); align-self: stretch; display: flex; align-items: center; }
.ctl-num .sec.op .ctls { gap: 6px; flex-wrap: nowrap; }
.ctl-num .num { touch-action: pan-x; }
.ctl-num .sec.op .ctl > label { order: -1; margin: 0 0 4px; }
.ctl-num .sec.op + .sec.op .ctl > label { display: none; }
.ctl-num .sec.op .ctl:nth-child(4), .ctl-num .sec.op .ctl:nth-child(8), .ctl-num .sec.op .ctl:nth-child(12) { margin-right: 10px; }

/* selectors & toggles */
.sel { display: flex; flex-direction: column; gap: 3px; }
.sel .opt, .tog { display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,0.3); border: 1px solid rgba(127,127,127,0.35); border-radius: 4px; padding: 3px 7px 3px 5px; font-size: 10.5px; color: var(--ink); text-align: left; white-space: nowrap; }
.sel .opt .led, .tog .led { width: 7px; height: 7px; border-radius: 50%; background: rgba(127,127,127,0.25); flex: 0 0 auto; }
.sel .opt.on { border-color: var(--accent); }
.sel .opt.on .led, .tog.on .led { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.sel.two { flex-direction: row; }
.tog { width: 34px; height: 26px; justify-content: center; padding: 0; }
.tog .led { width: 9px; height: 9px; }
.tog.on { border-color: var(--accent); }
.sel .opt:hover, .tog:hover { border-color: var(--accent); }

/* light panels (TB-303, ARP 2600) */
.m-tb303 .sel .opt, .m-tb303 .tog, .m-arp2600 .sel .opt, .m-arp2600 .tog, .m-tb303 .presets select, .m-tb303 .presets button, .m-arp2600 .presets select, .m-arp2600 .presets button { background: rgba(255,255,255,0.45); }
.m-tb303 .presets select option, .m-arp2600 .presets select option { background: #eee; color: #111; }

/* TB-303 sequencer */
.sec.seq { flex: 1 1 100%; }
.seqbar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 10px; }
.seqbtn { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.5); border: 1px solid rgba(0,0,0,0.3); border-radius: 4px; padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--ink); }
.seqbtn:hover { border-color: var(--accent); }
.seqbtn.run { min-width: 76px; }
.seqbtn .led { width: 9px; height: 9px; border-radius: 50%; background: rgba(0,0,0,0.25); }
.seqbtn.run[aria-pressed="true"] .led { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.seqnum { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.seqnum label { font-size: 9.5px; text-transform: uppercase; color: var(--label); letter-spacing: 0.05em; }
.seqnum .num { min-width: 52px; }
.seqhint { font-size: 11px; color: #444; flex: 1 1 220px; }
.steps { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 4px; }
.step { display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding: 4px 3px; border-radius: 4px; background: rgba(0,0,0,0.06); border: 1px solid transparent; }
.step.beat { background: rgba(0,0,0,0.12); }
.step.now { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.step .snum { font-size: 9px; text-align: center; color: #555; font-family: var(--mono); }
.step .sled { height: 10px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.35); background: #7a1d10; padding: 0; }
.step.now .sled { background: #ff4a2a; box-shadow: 0 0 8px #ff4a2a; }
.step.rest .sled { background: rgba(0,0,0,0.15); }
.step .snote { font-family: var(--mono); font-weight: 700; font-size: 13px; text-align: center; padding: 6px 0; border-radius: 3px; background: #1a1a1a; color: #f2f2f2; cursor: ns-resize; touch-action: none; user-select: none; outline: none; }
.step .snote:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.step.rest .snote { color: #666; }
.step .sbtn { font-size: 9px; font-weight: 700; padding: 3px 0; border-radius: 3px; border: 1px solid rgba(0,0,0,0.3); background: rgba(255,255,255,0.55); color: #333; letter-spacing: 0.03em; }
.step .sbtn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
@media (max-width: 760px) { .steps { grid-template-columns: repeat(8, minmax(0, 1fr)); } }

/* DX7 algorithm diagram */
.algo { margin: 12px 0 4px; }
.algo svg { max-width: 100%; height: auto; }
.algo .op rect { fill: #14201e; stroke: #2bb3a3; stroke-width: 1.4; }
.algo .op.car rect { fill: #1e3a35; }
.algo .op text { fill: #c9fff5; font-family: var(--mono); font-size: 13px; font-weight: 600; text-anchor: middle; dominant-baseline: central; }
.algo path, .algo line { stroke: #6fd9c9; stroke-width: 1.4; fill: none; }
.algo .bus { stroke: #2bb3a3; stroke-width: 2; }

/* ---------------------------------------------------------- studio */
.studio { max-width: 1600px; margin: 0 auto; padding: 14px 24px 0; }
.transport { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; background: #101114; border: 1px solid var(--line); border-radius: 10px 10px 0 0; padding: 10px 12px; }
.tgrp { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tb { width: 38px; height: 34px; display: grid; place-items: center; background: var(--bg2); border: 1px solid var(--line); border-radius: 7px; padding: 0; }
.tb svg { width: 18px; height: 18px; fill: var(--text); }
.tb.sm { width: 32px; height: 30px; }
.tb:hover { border-color: #3a3c42; }
.tb:disabled { opacity: 0.35; cursor: default; }
#tPlay .i-stop { display: none; }
#tPlay.on .i-play { display: none; }
#tPlay.on .i-stop { display: inline; }
#tPlay.on { border-color: #2d5a42; background: #10241a; }
#tPlay.on svg { fill: #7cffb5; }
.tb.rec svg { fill: #b33a2a; }
.tb.rec[aria-pressed="true"] { background: #3a1410; border-color: #ff4a2a; animation: recpulse 1s infinite; }
.tb.rec[aria-pressed="true"] svg { fill: #ff4a2a; }
@keyframes recpulse { 50% { box-shadow: 0 0 0 3px rgba(255,74,42,0.25); } }
.tpos { display: flex; flex-direction: column; font-family: var(--mono); line-height: 1.15; min-width: 104px; padding: 3px 10px; background: #07090a; border: 1px solid #1d2a24; border-radius: 6px; }
.tpos #tBBT { font-size: 17px; font-weight: 600; color: #7cffb5; }
.tpos #tTime { font-size: 11px; color: #4f8f6c; }
.tfield { display: flex; flex-direction: column; gap: 2px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--mute); }
.tfield input, .tfield select, .tgrp select, .rolltools select, .rolltools input[type=number], .head select, .head input.hname { background: var(--bg2); border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; font-size: 12px; color: var(--text); }
.tfield input { width: 68px; font-family: var(--mono); }
.tfield .sig { display: flex; align-items: center; gap: 3px; }
.tfield .sig input { width: 42px; }
.tt { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: 12px; font-weight: 600; }
.tt[aria-pressed="true"] { border-color: var(--hot); color: var(--hot); background: #1d1810; }
.tgrp.file button, .arrbar button, .rolltools button { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font-size: 12px; }
.tgrp.file button:hover, .arrbar button:hover, .rolltools button:hover { border-color: #3a3c42; }
button.hot { border-color: #6b4a1c !important; color: var(--hot); }
.arrbar button:disabled, .rolltools button:disabled { opacity: 0.4; cursor: default; }
.tgrp.file { margin-left: auto; }
.arrbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; padding: 8px 12px; background: #0e0f12; border-left: 1px solid var(--line); border-right: 1px solid var(--line); font-size: 12px; }
.arrbar .sep { flex: 0 0 8px; }
.rangeinfo { font-family: var(--mono); font-size: 11px; color: var(--mute); margin-right: 4px; }
.arrwrap { display: flex; border: 1px solid var(--line); border-radius: 0 0 10px 10px; background: #0f1013; max-height: 340px; overflow-y: auto; overflow-x: hidden; }
.heads { flex: 0 0 auto; width: 380px; border-right: 1px solid var(--line); background: #101114; }
.hruler { height: 24px; border-bottom: 1px solid var(--line); font-size: 10px; color: var(--mute); padding: 5px 10px; text-transform: uppercase; letter-spacing: 0.08em; }
.head { height: 56px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 4px 8px 4px 12px; border-bottom: 1px solid #191b20; position: relative; cursor: pointer; }
.head::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tc); opacity: 0.85; }
.head.sel { background: color-mix(in srgb, var(--tc) 12%, #101114); }
.head.sel::before { width: 6px; opacity: 1; }
.hrow { display: flex; align-items: center; gap: 4px; min-width: 0; }
.head input.hname { flex: 1 1 auto; min-width: 0; font-weight: 600; padding: 2px 6px; background: transparent; border-color: transparent; }
.head input.hname:hover, .head input.hname:focus { border-color: var(--line); background: var(--bg2); }
.head select { padding: 2px 4px; font-size: 11px; min-width: 0; }
.head .hmodel { flex: 0 1 98px; } .head .hpreset { flex: 1 1 90px; } .head .hch { flex: 0 0 62px; }
.hb { flex: 0 0 auto; width: 24px; height: 22px; padding: 0; font-size: 11px; font-weight: 700; background: var(--bg2); border: 1px solid var(--line); border-radius: 4px; color: var(--mute); }
.hb:hover { border-color: #3a3c42; color: var(--text); }
.hb.m[aria-pressed="true"] { background: #3a3326; color: #f2c23a; border-color: #6b5a26; }
.hb.s[aria-pressed="true"] { background: #1c3324; color: #7cffb5; border-color: #2d5a42; }
.hb.r[aria-pressed="true"] { background: #3a1410; color: #ff4a2a; border-color: #8a2a1a; }
.head input[type=range] { accent-color: var(--tc); min-width: 0; }
.head .hvol { flex: 1 1 60px; } .head .hpan { flex: 0 1 44px; }
.hmeter { flex: 0 0 46px; height: 6px; background: #07090a; border-radius: 3px; overflow: hidden; }
.hmeter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #3fae5a, #9bd16a 70%, #f5d22e 90%, #ff4a2a); }
.hmeter i.clip { box-shadow: 0 0 6px #ff4a2a; }
.lanes { flex: 1 1 auto; min-width: 0; position: relative; }
.lanes canvas { display: block; width: 100%; touch-action: pan-y; }
body.recording .transport { border-color: #6b2a1c; }

.tabs { max-width: 1600px; margin: 16px auto 0; padding: 0 24px; display: flex; align-items: flex-end; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { background: transparent; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; padding: 8px 16px; font-weight: 700; font-size: 13px; color: var(--mute); margin-bottom: -1px; }
.tabs button.on { background: var(--bg); border-color: var(--line); color: var(--text); }
.tabtrack { margin-left: auto; padding: 0 4px 8px; font-size: 12px; color: var(--mute); font-family: var(--mono); }
#tab-inst .models { border-bottom: 0; }
#tab-roll { max-width: 1600px; margin: 0 auto; padding: 12px 24px 0; }
/* FX tab: the selected track's rack (fx-ui.js styles its own .fxr-root) */
#tab-fx { max-width: 1600px; margin: 0 auto; padding: 12px 24px 18px; }
.fxbar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 10px; }
#fxtitle { font-weight: 700; font-size: 14px; }
.fxhint { font-size: 12px; color: var(--mute); }
.fxtab { min-height: 240px; border-radius: 10px; background: #0f1216; border: 1px solid var(--line); overflow: hidden; }
.fxtab > .boot { padding: 18px; }
/* custom panels (Serum): the panel draws its own surface */
.inst.custom { padding: 0; background: #0f1216; overflow: hidden; }
.inst.custom .sxhost { min-height: 320px; }
.inst.custom .sxhost > .boot { padding: 18px 22px; color: #7f8b98; }
.head .hpname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--mute); padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg2); line-height: 1.6; }
.rolltools { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-bottom: 10px; font-size: 12px; }
.rgrp { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 4px 6px; border: 1px solid var(--line); border-radius: 7px; background: #101114; }
.rlab { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--mute); margin: 0 2px; }
.rolltools button.on { border-color: var(--hot); color: var(--hot); background: #1d1810; }
.rolltools button { padding: 4px 8px; }
@media (pointer: coarse) { .rolltools button { min-height: 36px; min-width: 36px; } } /* touch targets */
.rchk { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text); padding: 0 4px; cursor: pointer; }
.rchk input { accent-color: var(--hot); }
.rsel { font-family: var(--mono); font-size: 11px; color: var(--mute); margin-left: auto; }
.rollwrap { height: clamp(300px, calc(100vh - 400px), 640px); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #0c0d0f; position: relative; touch-action: none; } /* also on the box: WebKit 218015 (double-tap zoom through an absolute canvas) */
.rollwrap canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.rollhelp { font-size: 12px; color: var(--mute); line-height: 1.6; margin: 8px 0 0; }
.playing { font-family: var(--mono); font-size: 11px; color: var(--hot); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.seqbtn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.seqbtn:disabled { opacity: 0.45; cursor: default; }

.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.6); display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); overflow: auto; }
.modal[hidden] { display: none; }
.dlg { width: min(460px, 100%); background: #15161a; border: 1px solid #2a2c32; border-radius: 12px; padding: 18px 20px; box-shadow: 0 30px 80px rgba(0,0,0,0.7); }
.dlg h2 { margin: 0 0 12px; font-size: 17px; }
.dlgbody { display: flex; flex-direction: column; gap: 10px; }
.dlgbody label { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; color: #c9c6bf; }
.dlgbody select { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 13px; max-width: 250px; }
.dlgbody label.chk { justify-content: flex-start; }
.dlgnote { font-size: 12px; color: var(--mute); margin: 4px 0 0; line-height: 1.5; min-height: 2.6em; }
.dlgbtns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dlgbtns button { background: var(--bg2); border: 1px solid var(--line); border-radius: 7px; padding: 7px 14px; font-weight: 600; }
.dlgbtns button:disabled { opacity: 0.5; }
/* the Add to Home Screen sheet (pwa.js installSteps) */
.insteps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; line-height: 1.5; color: #d9d6cf; }
.insteps b { color: var(--text); }
.insico { width: 18px; height: 18px; margin: 0 3px -4px 2px; fill: none; stroke: var(--hot); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#installSheet .dlgnote { min-height: 0; margin-top: 14px; }
/* "Update available — Reload": small, at the top, never in the way of the keys */
.toast { position: fixed; z-index: 70; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); padding: 6px 6px 6px 14px; border-radius: 10px; background: #1b1c20; border: 1px solid #5a4320; box-shadow: 0 12px 32px rgba(0,0,0,0.6); font-size: 13px; white-space: nowrap; }
.toast[hidden] { display: none; }
.toast span { overflow: hidden; text-overflow: ellipsis; }
.toast button { background: var(--bg2); border: 1px solid var(--line); border-radius: 7px; padding: 6px 12px; font-weight: 600; min-height: 32px; }
.toast button.tx { padding: 6px 10px; color: var(--mute); }
.toast button:disabled { opacity: 0.5; }

/* ---------------------------------------------------------- performance */
.perf { position: sticky; bottom: 0; z-index: 15; max-width: 1600px; margin: 18px auto 0; background: #101114; border: 1px solid var(--line); border-radius: 12px 12px 0 0; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -14px 30px rgba(0,0,0,0.55); }
.kbrow[hidden] { display: none; }
/* minimised: the toolbar stays, the keys and the height grip go */
.perf.min { padding-top: 7px; padding-bottom: calc(7px + env(safe-area-inset-bottom)); }
.perf.min .kbgrip, .perf.min .kbsize { display: none; }
/* height grip: a tab on the panel's top edge (32 px tall touch target, half above the panel) */
.kbgrip { position: absolute; top: -20px; left: 50%; width: 88px; height: 32px; margin-left: -44px; z-index: 1; touch-action: none; cursor: ns-resize; outline: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.kbgrip::before { content: ''; position: absolute; left: 16px; right: 16px; top: 6px; height: 15px; background: #101114; border: 1px solid var(--line); border-bottom: 0; border-radius: 9px 9px 0 0; box-shadow: 0 -4px 8px -2px rgba(0,0,0,0.4); }
.kbgrip::after { content: ''; position: absolute; left: 50%; top: 11px; width: 26px; height: 3px; margin-left: -13px; border-top: 2px solid #55575e; border-bottom: 2px solid #55575e; }
.kbgrip.drag::after, .kbgrip:focus-visible::after { border-color: var(--hot); }
.kbgrip:focus-visible::before { border-color: var(--hot); }
@media (hover: hover) { .kbgrip:hover::after { border-color: #8d8b86; } .kbgrip.drag::after { border-color: var(--hot); } }
.kbctl button.kbhide { display: flex; align-items: center; gap: 5px; padding: 5px 10px 5px 8px; white-space: nowrap; }
.kbhide svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.15s; }
.perf.min .kbhide { color: var(--hot); border-color: #5a4320; }
.perf.min .kbhide svg { transform: rotate(180deg); }
.kbsize input { width: 100px; accent-color: var(--hot); touch-action: manipulation; }
@media (max-width: 1100px) { .perf .midi.unsup { display: none; } } /* (a disabled "not supported" note would wrap the toolbar) */
@media (pointer: coarse) { .kbsize input { height: 32px; } .kbctl button { min-height: 32px; } } /* touch targets */
.kbctl { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; font-size: 12px; color: var(--mute); }
.kbrow { margin-top: 8px; }
.kbctl .grp { display: flex; align-items: center; gap: 6px; }
.kbctl button { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font-size: 12px; }
.kbctl button:hover { border-color: #3a3c42; }
.octv { font-family: var(--mono); min-width: 52px; text-align: center; color: var(--text); }
.vel input { width: 100px; accent-color: var(--hot); }
#velv { font-family: var(--mono); width: 26px; color: var(--text); }
.kbctl button.midi { font-family: var(--mono); font-size: 11px; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 340px; color: var(--mute); }
.kbctl .hold { margin-left: auto; } /* Hold, Panic, Hide keys to the right (also with the MIDI button hidden) */
.kbctl button.midi:disabled { cursor: default; border-color: transparent; background: transparent; }
.notice { margin: 0 0 8px; padding: 6px 10px; border-radius: 6px; background: #2a1712; border: 1px solid #6b2a1c; color: #ffb59a; font-size: 12px; line-height: 1.4; }
.notice[hidden] { display: none; }
.notice[data-gen], .notice[data-act] { cursor: pointer; background: #12202a; border-color: #1f4a66; color: #9fd6ff; } /* factory generation progress (tap cancels), notices with an action */
/* Serum channel colours (SPEC-serum2 §13.1): page-level copies of the panel's tokens, for the track header and notices */
:root { --sx-osc-a: #4fb3ff; --sx-osc-b: #6fe3a1; --sx-osc-c: #f7c948; --sx-sub: #a78bfa; --sx-noise: #94a3b8; --sx-f1: #ff8a5b;
  --sx-f2: #ff5b8a; --sx-bus1: #c084fc; --sx-bus2: #f472b6; --sx-arp: #b07cff; --sx-clip: #3ddc84; }
.hold { display: flex; align-items: center; gap: 6px; }
.kbrow { display: flex; gap: 10px; }
.wheels { display: flex; gap: 8px; }
.wheel { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 10px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.08em; }
.wheel .slot { width: 30px; flex: 1; min-height: 40px; background: #050506; border-radius: 6px; position: relative; touch-action: none; cursor: ns-resize; box-shadow: inset 0 2px 6px #000; overflow: hidden; }
.wheel .thumb { position: absolute; left: 3px; right: 3px; height: 26px; border-radius: 4px; background: repeating-linear-gradient(0deg, #2a2b2f 0 2px, #1b1c1f 2px 4px); border: 1px solid #3a3b40; }
.keys { position: relative; flex: 1; height: var(--kbh, 170px); touch-action: none; user-select: none; -webkit-user-select: none; }
.key { position: absolute; top: 0; border-radius: 0 0 5px 5px; }
.key.w { height: 100%; background: linear-gradient(#f4f2ec, #e4e1d8); border: 1px solid #9c988e; box-shadow: inset 0 -6px 0 #d2cec3; z-index: 1; }
.key.b { height: 62%; background: linear-gradient(#2a2a2c, #101012); border: 1px solid #000; box-shadow: inset 0 -5px 0 #000, 0 3px 4px rgba(0,0,0,0.5); z-index: 2; border-radius: 0 0 3px 3px; }
.key.w.down { background: linear-gradient(#e6dccb, #d9cdb6); box-shadow: inset 0 -2px 0 #c8bea9; }
.key.b.down { background: linear-gradient(#3a3226, #1a160f); box-shadow: inset 0 -2px 0 #000; }
.key.w.down::after, .key.b.down::after { content: ''; position: absolute; left: 25%; right: 25%; bottom: 10px; height: 4px; border-radius: 2px; background: var(--hot); box-shadow: 0 0 8px var(--hot); }
.key .nm { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; font-size: 10px; color: #8a867d; font-family: var(--mono); pointer-events: none; }
.key .kb { position: absolute; top: 8px; left: 0; right: 0; text-align: center; font-size: 9px; color: #a8a49a; font-family: var(--mono); pointer-events: none; text-transform: uppercase; }
.key.b .kb { color: #6f6c66; }
.perf.short .wheel span { display: none; } /* short keys: the wheels keep their whole height */

/* ---------------------------------------------------------- console */
.console { display: grid; grid-template-columns: minmax(280px, 1.2fr) 1fr; gap: 18px; margin-top: 18px; }
main { padding-top: 0; }
.scope { position: relative; background: #07090a; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; min-height: 220px; }
.scope canvas { display: block; width: 100%; height: 100%; min-height: 220px; }
.scope-ctl { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; }
.scope-ctl button { background: rgba(0,0,0,0.5); border: 1px solid var(--line); color: var(--mute); border-radius: 5px; padding: 3px 9px; font-size: 11px; }
.scope-ctl button.on { color: #7cffb5; border-color: #2d5a42; }
.about { background: #101114; border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; }
.about h2 { margin: 0 0 6px; font-size: 16px; }
.about p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.55; color: #c9c6bf; }
.about .help { font-size: 12.5px; color: var(--mute); }

.foot { max-width: 1600px; margin: 0 auto; padding: 10px 24px 40px; }
.foot p { font-size: 12px; color: #6f6d68; line-height: 1.6; max-width: 980px; }

.tip { position: fixed; pointer-events: none; z-index: 50; background: #000; color: #fff; font-family: var(--mono); font-size: 11.5px; padding: 4px 8px; border-radius: 5px; border: 1px solid #333; white-space: nowrap; opacity: 0; transform: translate(-50%, -100%); transition: opacity 0.08s; }
.tip.show { opacity: 1; }
/* full-screen layers of the panels below 1100 px (wk.js .gx-overlay, sx-ui-seq.js .sx-seqov): clear of the status bar */
@media (max-width: 1099px) {
  body .gx-overlay { padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  body .sx-seqov { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}

@media (max-width: 900px) {
  .console { grid-template-columns: 1fr; }
  .top { padding: calc(10px + env(safe-area-inset-top)) 16px 10px; position: static; }
  /* the header scrolls away here: in the installed app (black-translucent status bar) a backdrop under the status bar
     keeps the scrolled page from showing beneath the clock (0 px high in a browser tab) */
  body::before { content: ''; position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top); background: var(--bg); z-index: 1001; pointer-events: none; }
  .perf { padding: 12px 10px calc(10px + env(safe-area-inset-bottom)); }
  .perf.min { padding-top: 7px; padding-bottom: calc(7px + env(safe-area-inset-bottom)); }
  .perf.min .kbctl { margin-bottom: 0; }
  .kbsize input { width: 84px; }
  .studio, #tab-roll, #tab-fx { padding-left: 12px; padding-right: 12px; }
  .tabs { padding: 0 12px; }
  .heads { width: 230px; }
  .head .hpreset, .head .hpan, .head .hb[title="Duplicate track"] { display: none; }
  .tgrp.file { margin-left: 0; }
  .perf .vel { display: none; }
  .kbctl button.midi { max-width: 140px; }
  .kbctl { margin-bottom: 6px; gap: 8px; }
  .keys { height: var(--kbh, 128px); }
  .models { padding: 10px 16px; }
  main { padding: 14px 16px 8px; }
  .inst { padding: 14px 14px 16px; }
  .inst.wood { margin: 0 12px; }
  .inst.wood::before, .inst.wood::after { width: 12px; }
  .inst.wood::before { left: -12px; }
  .inst.wood::after { right: -12px; }
  .nameplate .mname { font-size: 26px; }
  .meter { min-width: 0; }
}
@media (max-width: 560px) {
  .ctl { width: 54px; }
  .knob { width: 44px; height: 44px; }
  .field.range input { width: 84px; }
  .wheel .slot { width: 22px; }
  .sec { flex: 1 1 100%; }
  /* the toolbar in one row on a phone: Key size takes the room left, Hide keys is an icon (both keep their names) */
  .kbctl { gap: 6px; }
  .octv { min-width: 44px; }
  .perf .playing:empty { display: none; }
  .kbsize { flex: 1 1 56px; min-width: 0; max-width: 150px; }
  .kbsize input { width: 100%; min-width: 0; }
  .kbsize .lbl, .kbhide span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .kbctl button.kbhide { padding: 5px 9px; }
}
