/* Shyoy: one pane of backlit yellow-green LCD glass in a black bezel (after Johnny's Elixir Mobile screen).
   One ink for the segments, a faint ghost of the unlit ones, the offset shadow LCD type casts on its backplane,
   a pixel font throughout. Every panel is headed by an inverted label strip, like silkscreen on the hardware;
   buttons are outlined boxes that invert when on; faders are segmented bar graphs that grow to fill the view.
   One stylesheet, all sizes from the tokens below. Since v0.16.0 the screen is one fixed 1400 x 906 pane scaled to the
   window (js/app/fit.js and the html.fit rules at the end): every device gets this one layout, a phone just smaller. */
:root {
  --case: #161815;
  --bezel: #0b0c0a;
  /* the glass: every colour on it comes from these triplets, so a theme only swaps them (see the themes below) */
  --glass-rgb: 195 216 58;   /* yellow-green backlit LCD (Johnny, v0.9.1) */
  --ink-rgb: 10 15 4;
  --hl1-rgb: 255 252 195; --hl2-rgb: 250 255 200;            /* the backlight's pale haze */
  --dk1-rgb: 40 50 25; --dk2-rgb: 30 38 20; --dk3-rgb: 20 26 12;  /* shade at the top and in the corners */
  --acc: #5f7f00;            /* the spot colour this swatch brings to Grey + colour */
  --dirt: 1; --grain: 1; --glow: 0;   /* Options › Colours look sliders (1 = stock); Glow is fixed at 0 (v0.17.2, slider hidden); Brightness and Saturation reset --glass-rgb */
  --glass: rgb(var(--glass-rgb));
  --ink: rgb(var(--ink-rgb));
  --muted: rgb(var(--ink-rgb) / .72);
  --ghost: rgb(var(--ink-rgb) / .13);
  --tint: rgb(var(--ink-rgb) / .07);
  --lit: rgb(var(--glass-rgb) / .72);   /* glass-coloured text on an ink strip, dimmed */
  --line: rgb(var(--ink-rgb) / .42);
  --rule: 1px solid var(--line);
  --shadow: 2px 2px 0 rgb(var(--ink-rgb) / calc(.17 * var(--glow)));
  --f-lcd: "VT323", ui-monospace, "SF Mono", Menlo, monospace;
  /* scale */
  --bw: 2px;          /* outline weight */
  --r: 3px;           /* corner radius */
  --pad: 16px;        /* panel padding */
  --gap: 12px;        /* gap between groups */
  --gap-s: 6px;       /* gap inside a group */
  --h: 28px; --menu-h: 22px;          /* control height */
  --h-top: 34px;      /* header control height */
  --fs-xs: 18px; --fs-s: 21px; --fs: 23px; --fs-l: 25px; --fs-xl: 40px;
  --trk: 22px;        /* fader width */
  --trk-min: 56px;    /* shortest a fader may get */
  color-scheme: light;
}

/* ---------- glass themes: Options › Colours ----------
   Mono: one ink on one coloured glass (the swatch is the glass). Grey + colour (the default): black ink on grey glass,
   and the swatch is one deep spot colour, like a printed filter on a real LCD, on a few small things only:
   Run while running, the open tab, the pattern in use and the step playing, lit switch LEDs.
   Dials, faders and sliders always stay ink. The head script sets data-lcd and data-lcdmode before first paint. */
:root[data-lcd=green] { --glass-rgb: 195 216 58; --ink-rgb: 10 15 4; --hl1-rgb: 255 252 195; --hl2-rgb: 250 255 200;
  --dk1-rgb: 40 50 25; --dk2-rgb: 30 38 20; --dk3-rgb: 20 26 12; --acc: #5f7f00; }
:root[data-lcd=orange] { --glass-rgb: 250 161 66; --ink-rgb: 28 10 0; --hl1-rgb: 255 236 200; --hl2-rgb: 255 228 190;
  --dk1-rgb: 64 32 10; --dk2-rgb: 48 24 6; --dk3-rgb: 32 14 2; --acc: #d0600a; }
:root[data-lcd=amber] { --glass-rgb: 244 194 74; --ink-rgb: 30 21 0; --hl1-rgb: 255 246 200; --hl2-rgb: 255 240 190;
  --dk1-rgb: 62 46 12; --dk2-rgb: 46 34 8; --dk3-rgb: 30 22 4; --acc: #b58300; }
:root[data-lcd=blue] { --glass-rgb: 123 182 226; --ink-rgb: 3 17 42; --hl1-rgb: 225 242 255; --hl2-rgb: 215 236 255;
  --dk1-rgb: 20 40 70; --dk2-rgb: 14 30 55; --dk3-rgb: 8 20 40; --acc: #2a63ae; }
:root[data-lcd=red] { --glass-rgb: 242 107 82; --ink-rgb: 34 4 3; --hl1-rgb: 255 225 210; --hl2-rgb: 255 215 200;
  --dk1-rgb: 70 20 14; --dk2-rgb: 52 14 10; --dk3-rgb: 36 8 6; --acc: #c2352a; }
:root[data-lcd=grey] { --glass-rgb: 211 214 204; --ink-rgb: 18 20 16; --hl1-rgb: 255 255 248; --hl2-rgb: 250 252 244;
  --dk1-rgb: 45 48 40; --dk2-rgb: 34 36 30; --dk3-rgb: 22 24 18; --acc: var(--ink); }
:root[data-lcdmode=colour] { --glass-rgb: 211 214 204; --ink-rgb: 18 20 16; --hl1-rgb: 255 255 248; --hl2-rgb: 250 252 244;
  --dk1-rgb: 45 48 40; --dk2-rgb: 34 36 30; --dk3-rgb: 22 24 18; --accent: var(--acc); }
[data-lcdmode=colour] .btn.play.on, [data-lcdmode=colour] .slots button[aria-pressed=true],
[data-lcdmode=colour] .roll .hd.cur { background: var(--accent); color: var(--glass); }
[data-lcdmode=colour] .sw button[aria-pressed="true"] .led { background: var(--accent); }

* { box-sizing: border-box; }
html, body { background: var(--case); color: var(--glass); margin: 0; }
body { background-image: radial-gradient(120% 60% at 50% 0%, #2a2d28, var(--case)); background-repeat: no-repeat;
  font-family: var(--f-lcd); font-size: var(--fs); line-height: 1.15;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); }
button, table, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px dashed var(--ink); outline-offset: 2px; }

/* ---------- the glass ---------- */
.unit { display: flex; flex-direction: column; height: calc(100vh - 24px); height: calc(100dvh - 24px); min-height: 560px; max-width: 1480px; margin: 0 auto; overflow: hidden;
  color: var(--ink); text-shadow: var(--shadow); border: 6px solid var(--bezel); border-radius: 12px;
  background-color: var(--glass);
  background-image: linear-gradient(170deg, rgba(255,255,255,.14), rgba(255,255,255,0) 38%, rgba(0,0,0,.05)),
    repeating-linear-gradient(0deg, rgb(0 0 0 / calc(.03 * var(--grain))) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgb(0 0 0 / calc(.03 * var(--grain))) 0 1px, transparent 1px 3px),
    radial-gradient(60% 30% at 10% 100%, rgb(var(--hl1-rgb) / .55), rgb(var(--hl1-rgb) / 0) 70%),
    radial-gradient(50% 28% at 90% 102%, rgb(var(--hl2-rgb) / .4), rgb(var(--hl2-rgb) / 0) 70%),
    radial-gradient(38% 20% at 70% 30%, rgb(var(--dk1-rgb) / calc(.14 * var(--dirt))), rgb(var(--dk1-rgb) / 0) 70%),
    linear-gradient(180deg, rgb(var(--dk2-rgb) / calc(.2 * var(--dirt))) 0%, rgb(var(--dk2-rgb) / 0) 22%),
    radial-gradient(130% 100% at 50% 60%, rgb(var(--dk3-rgb) / 0) 60%, rgb(var(--dk3-rgb) / calc(.28 * var(--dirt))) 100%);
  box-shadow: inset 0 6px 14px rgba(0,0,0,.35), inset -4px 0 10px rgba(0,0,0,.15), 0 18px 40px rgba(0,0,0,.5); }
.lower { display: contents; }

/* ---------- shared controls ---------- */
.btn, .acts button, .slots button, .rm-btn, .chain-read button,
.pm button, .pm-foot button, .pm input[type=text], .pm-foot input[type=text] {
  appearance: none; background: none; border: var(--bw) solid var(--ink); border-radius: var(--r); color: var(--ink);
  height: var(--h); padding: 0 calc(var(--gap-s) + 4px); font-family: var(--f-lcd); font-size: var(--fs); line-height: 1;
  cursor: pointer; text-transform: lowercase; text-shadow: var(--shadow); white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--gap-s); -webkit-tap-highlight-color: transparent; }
.btn { box-shadow: var(--shadow); }
.btn:active, .btn.held, .btn[aria-pressed="true"], .btn.on,
.acts button:active, .rm-btn:active, .rm-btn[aria-expanded=true], .chain-read button:active,
.slots button[aria-pressed=true], .slots button:active { background: var(--ink); color: var(--glass); text-shadow: none; }
button:disabled { opacity: .35; cursor: default; }
@media (hover: hover) {
  .btn:hover:not(:disabled):not(.on):not([aria-pressed="true"]), .acts button:hover:not(:disabled),
  .slots button:hover:not([aria-pressed=true]), .rm-btn:hover:not([aria-expanded=true]), .tabs button:hover:not([aria-selected="true"]),
  .sw button:hover:not([aria-pressed="true"]), .pm-foot button:hover { background: var(--tint); }
}
.led { display: inline-block; width: 9px; height: 9px; background: var(--ghost); flex: none; }
.btn.on .led { background: var(--glass); }
.led.on { background: var(--ink); }
select.btn { padding-right: 6px; }
select.btn option { color: #000; }

/* number box, e.g. tempo */
.num { display: flex; align-items: center; gap: var(--gap-s); font-size: var(--fs-s); color: var(--muted); text-transform: lowercase; }
.num input { width: 3.2em; height: var(--h-top); font-size: var(--fs-l); background: none; color: var(--ink); border: var(--bw) solid var(--ink); border-radius: var(--r);
  padding: 0 4px; text-align: center; text-shadow: var(--shadow); font-variant-numeric: tabular-nums; }

/* label strip: the one heading style for every module, group and effect */
.mod h2, .bend-grp h3, .perf101 h3 {
  margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: calc(var(--fs-l) + 4px);
  padding: 0 var(--gap-s) 0 calc(var(--gap-s) + 2px); background: var(--ink); color: var(--glass); text-shadow: none; border-radius: var(--r);
  font-size: var(--fs-l); font-weight: 400; line-height: 1.1; text-transform: lowercase; letter-spacing: .03em; white-space: nowrap; }
.mod h2 small { color: var(--lit); font-size: var(--fs-xs); letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; }

/* faders: a column of LCD segments, lit up to the value; they stretch to the height of their row */
.ctrls { display: flex; gap: var(--gap); align-items: stretch; flex: 1 1 auto; min-height: 0; }
.fdr { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: calc(var(--trk) + 18px); }
.fdr .track { position: relative; flex: 1 1 0; width: var(--trk); min-height: var(--trk-min); cursor: ns-resize; touch-action: none;
  background: repeating-linear-gradient(0deg, var(--ghost) 0 5px, transparent 5px 7px); }
.fdr .fill { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--v, 0) * 100%);
  background: repeating-linear-gradient(0deg, var(--ink) 0 5px, transparent 5px 7px); background-position: bottom; filter: drop-shadow(var(--shadow)); }
.fdr .ticks, .fdr .cap { display: none; }
.fdr label { font-size: var(--fs-s); text-transform: lowercase; text-align: center; line-height: 1; white-space: nowrap; margin-top: 2px; }
.fdr output { font-size: var(--fs-xs); color: var(--muted); min-height: 1em; line-height: 1; white-space: nowrap; text-shadow: none; font-variant-numeric: tabular-nums; }
.fdr.bend output.off { color: var(--ink); text-decoration: underline; }
.dial { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1 1 0; min-width: 0; min-height: 0; }
.dial .knob { flex: 1 1 0; min-height: var(--trk-min); width: 100%; max-width: 150px; cursor: ns-resize; touch-action: none; display: flex; align-items: center; justify-content: center; }
.dial .knob svg { height: 100%; max-width: 100%; aspect-ratio: 1; display: block; overflow: visible; }
.dial .knob .trk { fill: var(--ghost); }
.dial .knob .arc { fill: var(--ink); }
.dial .knob:focus-visible { outline: 2px dashed var(--ink); outline-offset: 2px; }
.dial label { font-size: var(--fs-s); text-transform: lowercase; text-align: center; line-height: 1; white-space: nowrap; margin-top: 2px; }
.dial output { font-size: var(--fs-s); color: var(--ink); min-height: 1em; line-height: 1; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* switches: an LED list, the chosen one shown by its lit LED only */
.sw { display: flex; flex-direction: column; gap: 2px; }
.sw .lab { font-size: var(--fs-s); color: var(--muted); text-transform: lowercase; margin-bottom: 2px; }
.sw button { appearance: none; border: 0; background: none; padding: 1px 6px 1px 4px; cursor: pointer; display: flex; align-items: center; gap: 6px;
  font-size: var(--fs); line-height: 1.05; color: var(--ink); text-align: left; text-transform: lowercase; text-shadow: var(--shadow); border-radius: 2px; white-space: nowrap; }
.sw button .led { width: 8px; height: 8px; }
.sw button[aria-pressed="true"] .led { background: var(--ink); }
.sw .btn { justify-content: flex-start; border: var(--bw) solid var(--ink); height: var(--h); padding: 0 10px; box-shadow: var(--shadow); margin-bottom: 4px; }

/* horizontal sliders (sequencer, bridges depth): a segmented strip with an ink block */
.sld { display: grid; grid-template-columns: auto 120px 2.6em; align-items: center; gap: 0 8px; font-size: var(--fs-s); text-transform: lowercase; }
.sld[hidden] { display: none; }
.sld output { text-align: right; font-size: var(--fs); font-variant-numeric: tabular-nums; }
.sld input { -webkit-appearance: none; appearance: none; width: 100%; height: var(--h); margin: 0; background: none; cursor: pointer; touch-action: none; }
/* the track is a row of LCD segments lit up to the value, like the Synth page faders (--v is 0..1, set in controls.js) */
.sld input { --seg: repeating-linear-gradient(90deg, var(--ink) 0 5px, transparent 5px 7px); --off: repeating-linear-gradient(90deg, var(--ghost) 0 5px, transparent 5px 7px); }
.sld input::-webkit-slider-runnable-track { height: 16px; border: 0; background: var(--seg) left / calc(var(--v, 0) * 100%) 100% no-repeat, var(--off); filter: drop-shadow(var(--shadow)); }
.sld input::-moz-range-track { height: 16px; border: 0; background: var(--seg) left / calc(var(--v, 0) * 100%) 100% no-repeat, var(--off); }
.sld input::-webkit-slider-thumb { -webkit-appearance: none; width: 2px; height: 16px; margin: 0; background: transparent; border: 0; box-shadow: none; }
.sld input::-moz-range-thumb { width: 2px; height: 16px; background: transparent; border: 0; }
.sld input:focus-visible { outline: 2px dashed var(--ink); outline-offset: 2px; }

/* ---------- header ---------- */
.top { order: 0; flex: none; display: flex; align-items: center; gap: var(--gap) calc(var(--gap) + 8px); padding: calc(var(--pad) - 4px) var(--pad); border-bottom: var(--bw) solid var(--ink); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand b { display: inline-flex; align-items: flex-start; gap: 6px; padding: 2px 10px 0 12px; background: var(--ink); color: var(--glass); text-shadow: none; border-radius: var(--r);
  font-size: var(--fs-xl); font-weight: 400; letter-spacing: .14em; line-height: 1; }
.ver { font-style: normal; font-size: var(--fs-xs); letter-spacing: 0; color: var(--lit); margin-top: 3px; }
/* v0.22.11: logo from Johnny's PSD (icons/logo.png, black art on transparent) used as a mask, so it is drawn in the current
   ink colour and multiplied onto the glass like the rest of the LCD; the version sits top right in muted ink */
.brand b:has(.logo) { align-items: center; gap: 8px; padding: 0; background: none; color: var(--ink); }
.brand .logo { display: block; height: 46px; width: 125.8px; aspect-ratio: 547 / 200; max-width: none; background: var(--ink); mix-blend-mode: multiply;
  -webkit-mask: url(../icons/logo.png) center / contain no-repeat; mask: url(../icons/logo.png) center / contain no-repeat; }
.brand b:has(.logo) .ver { align-self: flex-end; margin-bottom: 4px; color: var(--muted); }   /* v0.23.0: on the logo's baseline */
.brand > span { font-size: var(--fs-s); color: var(--muted); line-height: 1.05; max-width: 22ch; }
.psu[hidden] { display: none; } .brand:has(+ .psu[hidden]) { margin-right: auto; }
.psu { display: inline-flex; align-items: center; gap: 8px; height: var(--h); padding: 0 10px; margin-right: auto; border: var(--bw) solid var(--ink); border-radius: var(--r);
  font-size: var(--fs-s); white-space: nowrap; font-variant-numeric: tabular-nums; }
.psu::before { content: ""; width: 14px; height: 8px; border: var(--bw) solid var(--ink); border-radius: 1px; background: linear-gradient(90deg, var(--ink) 70%, transparent 70%); box-shadow: 2px 0 0 -0.5px var(--ink); }
.transport { display: flex; align-items: center; gap: var(--gap-s) var(--gap); }
.top .btn { height: var(--h-top); font-size: var(--fs-l); }
.btn.play { min-width: 5.2em; justify-content: flex-start; }
.btn.gear { width: var(--h-top); padding: 0; }
.btn.gear svg { width: 62%; height: 62%; fill: currentColor; filter: drop-shadow(var(--shadow)); }

/* ---------- Options sheet (the gear): a modal piece of the same glass, from the TB-303 app's dialog#options ---------- */
html:has(dialog#options[open]) { overflow: hidden; }
dialog#options { width: min(940px, calc(100vw - 32px)); height: min(600px, calc(100vh - 32px)); height: min(600px, calc(100dvh - 32px)); max-width: none; max-height: none; margin: auto; padding: 0;
  flex-direction: column; overflow: hidden; color: var(--ink); text-shadow: var(--shadow); border: 6px solid var(--bezel); border-radius: 12px;
  background-color: var(--glass);
  background-image: linear-gradient(170deg, rgba(255,255,255,.14), rgba(255,255,255,0) 38%, rgba(0,0,0,.05)),
    repeating-linear-gradient(0deg, rgb(0 0 0 / calc(.03 * var(--grain))) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgb(0 0 0 / calc(.03 * var(--grain))) 0 1px, transparent 1px 3px),
    radial-gradient(60% 30% at 10% 100%, rgb(var(--hl1-rgb) / .55), rgb(var(--hl1-rgb) / 0) 70%),
    radial-gradient(50% 28% at 90% 102%, rgb(var(--hl2-rgb) / .4), rgb(var(--hl2-rgb) / 0) 70%),
    linear-gradient(180deg, rgb(var(--dk2-rgb) / calc(.2 * var(--dirt))) 0%, rgb(var(--dk2-rgb) / 0) 22%),
    radial-gradient(130% 100% at 50% 60%, rgb(var(--dk3-rgb) / 0) 60%, rgb(var(--dk3-rgb) / calc(.28 * var(--dirt))) 100%);
  box-shadow: inset 0 6px 14px rgba(0,0,0,.35), inset -4px 0 10px rgba(0,0,0,.15), 0 18px 40px rgba(0,0,0,.5); }
dialog#options[open] { display: flex; }
/* v0.22.19: older WebKit (Safari before 15.4, e.g. an un-updated macOS 11 / 12, which is what a plugin's web view uses) has no
   <dialog>: it drew both sheets open over the screen. Closed ones are hidden here (what the browser does anyway), and with
   no <dialog> (fit.js sets html.nodialog) an open one is placed as the browser would. */
dialog:not([open]) { display: none; }
html.nodialog dialog { position: fixed; z-index: 100; }
dialog#options::backdrop { background: rgb(var(--ink-rgb) / .3); }
.opt-head { flex: none; display: flex; align-items: flex-end; gap: var(--gap) calc(var(--gap) + 12px); padding: calc(var(--pad) - 4px) var(--pad) 0; border-bottom: 2px solid var(--ink); }
.opt-head h2 { margin: 0; padding-bottom: var(--gap-s); font-size: var(--fs-l); font-weight: 400; line-height: 1.1; letter-spacing: .03em; text-transform: lowercase; }
.otabs { flex: 1; min-width: 0; display: flex; gap: var(--gap-s); }
.otabs button { appearance: none; background: none; color: var(--ink); border: 2px solid var(--ink); border-bottom: 0; border-radius: var(--r) var(--r) 0 0;
  height: var(--h); padding: 0 calc(var(--gap-s) + 8px); font: inherit; font-size: var(--fs); line-height: 1; text-transform: lowercase; text-shadow: var(--shadow); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.otabs button[aria-selected="true"] { background: var(--ink); color: var(--glass); text-shadow: none; }
/* v0.23.0: no spot colour on the selected tab, as on the main tabs (Johnny, v0.20.1) */
.otabs button:focus-visible { outline-offset: -5px; outline-color: currentColor; }
.xbtn { align-self: center; flex: none; appearance: none; background: none; border: 0; color: var(--ink); width: var(--h); height: var(--h); padding: 3px; margin-bottom: var(--gap-s); cursor: pointer; }
.xbtn svg { width: 100%; height: 100%; display: block; filter: drop-shadow(var(--shadow)); }
.opt-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: calc(var(--pad) + 4px) calc(var(--pad) + 4px) calc(var(--pad) + 8px);
  font-size: var(--fs); scrollbar-width: thin; scrollbar-color: var(--ink) transparent; }
.osec { display: grid; gap: calc(var(--gap) + 4px); align-content: start; min-width: 0; }
.osec[hidden] { display: none; }
/* MIDI: one status line, then the CC map flowing into columns */
.opt-status { margin: 0; font-size: var(--fs-s); color: var(--muted); }
.opt-h { margin: 0; padding-bottom: 4px; border-bottom: var(--rule); font-size: var(--fs); font-weight: 400; text-transform: lowercase; color: var(--ink); }
.opt-h small { font-size: var(--fs-s); color: var(--muted); margin-left: 8px; }
.ccmap + .opt-h { margin-top: var(--gap); }
.ccmap { margin: 0; padding: 0; list-style: none; columns: 4 170px; column-gap: calc(var(--gap) + 16px); }
.ccmap li { display: grid; grid-template-columns: 3.4em 1fr; gap: var(--gap-s); padding: 2px 0; break-inside: avoid; }
.ccmap b { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.ccmap span { text-transform: lowercase; white-space: nowrap; }
.ccmap.bs2 { column-gap: calc(var(--gap) + 6px); }
.ccmap.bs2 li { grid-template-columns: 8.6em 1fr; }
.ccmap.bs2 b { text-transform: lowercase; }
/* About: Install and Check for update side by side, the version, then the notes */
.opt-acts { display: flex; flex-wrap: wrap; gap: var(--gap-s) var(--gap); }
.opt-ver { margin: calc(var(--gap) * -1 + 2px) 0 0; font-size: var(--fs-s); color: var(--muted); }
.notes { columns: 2 300px; column-gap: calc(var(--gap) + 20px); }
.notes p { margin: 0 0 calc(var(--gap-s) + 4px); break-inside: avoid; line-height: 1.15; }
.notes strong { font-weight: 400; background: var(--ink); color: var(--glass); text-shadow: none; padding: 0 4px; border-radius: 2px; }

/* Options › Colours: mode switch and six swatches, each drawn in its own Mono glass and ink */
.lcd-mode { display: flex; align-items: center; gap: var(--gap); font-size: var(--fs-s); text-transform: lowercase; }
.lcd-mode .lab { color: var(--muted); }
.lcd-seg { display: inline-flex; }
.lcd-seg button { appearance: none; background: none; border: var(--bw) solid var(--ink); border-right-width: 0; border-radius: 0; color: var(--ink); height: var(--h);
  padding: 0 calc(var(--gap-s) + 6px); font: inherit; font-size: var(--fs); line-height: 1; text-transform: lowercase; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.lcd-seg button:first-child { border-radius: var(--r) 0 0 var(--r); } .lcd-seg button:last-child { border-right-width: var(--bw); border-radius: 0 var(--r) var(--r) 0; }
.lcd-seg button[aria-pressed="true"] { background: var(--ink); color: var(--glass); }
.lcd-sws { display: flex; gap: var(--gap-s); }
.lcd-sw { appearance: none; position: relative; display: flex; flex-direction: column; gap: 4px; width: calc(var(--fs) * 4.2); padding: 4px 5px 3px; cursor: pointer;
  background: var(--sg); color: var(--si); border: var(--bw) solid rgb(var(--ink-rgb) / .2); border-radius: var(--r); font: inherit; font-size: var(--fs-s); line-height: 1;
  text-transform: lowercase; text-align: left; -webkit-tap-highlight-color: transparent; }
.lcd-sw[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.lcd-sw[aria-checked="true"]::after { content: "✓"; position: absolute; top: -7px; right: -6px; padding: 1px 3px; background: var(--ink); color: var(--glass); border-radius: 2px; font-size: var(--fs-xs); line-height: 1; }
.lcd-sw:focus-visible { outline: 2px dashed var(--ink); outline-offset: 2px; }
.lcd-sw .bars { display: flex; align-items: flex-end; gap: 3px; height: calc(var(--fs) * 1.4); }
.lcd-sw .bars i { flex: 1; height: var(--b); background: repeating-linear-gradient(0deg, var(--si) 0 3px, transparent 3px 5px); background-position: bottom; }
.lcd-sw[data-t=green] { --sg: #c3d83a; --si: #0a0f04; } .lcd-sw[data-t=orange] { --sg: #faa142; --si: #1c0a00; }
.lcd-sw[data-t=amber] { --sg: #f4c24a; --si: #1e1500; } .lcd-sw[data-t=blue] { --sg: #7bb6e2; --si: #03112a; }
.lcd-sw[data-t=red] { --sg: #f26b52; --si: #220403; } .lcd-sw[data-t=grey] { --sg: #d3d6cc; --si: #121410; }
/* look sliders (from the TB-303 app): brightness, saturation, dirt, grain, glow, then Reset */
.lcd-look { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(var(--fs) * 17), 1fr)); gap: var(--gap-s) calc(var(--gap) * 2); align-items: center; max-width: 900px; }
.lcd-look .sld { grid-template-columns: calc(var(--fs) * 5) 1fr 3em; }
.lcd-look #lcd-look-reset { justify-self: start; }

/* preset menu (from the 303 app), drawn as LCD */
.presets { position: relative; display: flex; align-items: center; gap: var(--gap-s); }
.pm { position: relative; display: flex; min-width: 0; }
.pm button, .pm-foot button, .pm input[type=text], .pm-foot input[type=text] { text-shadow: none; }
.pm input[type=text], .pm-foot input[type=text] { cursor: text; text-transform: none; justify-content: flex-start; }
.top .pm .pm-btn, .top .pm .pm-step { height: var(--h-top); }
.pm .pm-btn { min-width: 190px; max-width: 260px; justify-content: space-between; text-align: left; font-size: var(--fs); border-radius: var(--r) 0 0 var(--r); }
.pm-btn .cur { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm .pm-btn::after { content: "▾"; margin-left: 8px; }
.pm .pm-step { padding: 0 8px; font-size: var(--fs-xs); border-left-width: 0; border-radius: 0; }
.pm .pm-step:last-of-type { border-radius: 0 var(--r) var(--r) 0; }
.pm-pop { position: absolute; z-index: 40; top: calc(100% + 6px); right: 0; width: 340px; max-height: 460px; display: flex; flex-direction: column;
  background: var(--glass); color: var(--ink); border: var(--bw) solid var(--ink); border-radius: var(--r); box-shadow: 4px 4px 0 rgb(var(--ink-rgb) / .25), 0 10px 30px rgba(0,0,0,.45); text-shadow: none; }
.pm-pop[hidden] { display: none; }
.pm .pm-qrow { display: flex; gap: 6px; margin: 6px; }
.pm .pm-q { flex: 1; min-width: 0; }
.pm .pm-favf { opacity: .5; } .pm .pm-favf[aria-pressed=true] { opacity: 1; background: var(--ink); color: var(--glass); }
.pm-list { overflow-y: auto; overscroll-behavior: contain; padding-bottom: 4px; scrollbar-width: thin; }
.pm .pm-g { display: flex; justify-content: flex-start; width: 100%; height: auto; border: 0; border-top: var(--rule); border-radius: 0; padding: 3px 8px; padding-left: calc(8px + var(--d, 0) * 14px); font-size: var(--fs-s); }
.pm .pm-g.sub { border-top-color: transparent; }
.pm-g::before { content: "▸"; margin-right: 8px; } .pm-g[aria-expanded=true]::before { content: "▾"; }
.pm-g .n { margin-left: auto; color: var(--muted); }
.pm-row { display: flex; align-items: stretch; }
.pm .pm-i { flex: 1; min-width: 0; height: auto; min-height: var(--h); border: 0; border-radius: 0; padding: 0 10px; padding-left: calc(10px + var(--d, 0) * 14px); justify-content: flex-start;
  text-align: left; font-size: var(--fs); text-transform: none; overflow: hidden; text-overflow: ellipsis; gap: 8px; }
.pm .pm-i[aria-selected=true] { background: var(--ink); color: var(--glass); }
.pm-i.act, .pm-i:hover, .pm-g.act, .pm-g:hover { background: var(--ghost); }
.pm-path { margin-left: auto; color: var(--muted); font-size: var(--fs-xs); flex: none; }
.pm .pm-star { flex: none; width: 30px; height: auto; padding: 0; border: 0; color: var(--muted); font-size: var(--fs-xs); }
.pm .pm-star[aria-pressed=true] { color: var(--ink); }
/* unticked stars are an outline ☆, faint until hovered; each row ends with its own × (from the TB-303 app) */
.pm .pm-star[aria-pressed=false] { color: var(--ink); opacity: .28; }
.pm .pm-row:hover .pm-star[aria-pressed=false] { opacity: .55; }
.pm .pm-star[aria-pressed=false]:hover { opacity: 1; }
.pm .pm-del { flex: none; min-width: 26px; height: auto; min-height: var(--menu-h); padding: 0 6px; border: 0; border-radius: 0; background: transparent; color: var(--ink); opacity: .45; font-size: var(--fs); text-shadow: none; }
.pm .pm-row:hover .pm-del { opacity: .75; }
.pm .pm-del:hover { opacity: 1; }
.pm .pm-del[aria-pressed=true] { opacity: 1; background: var(--ink); color: var(--glass); font-size: var(--fs-xs); text-transform: lowercase; }
.pm .pm-restore { display: flex; justify-content: flex-start; width: 100%; height: auto; min-height: var(--h); border: 0; border-radius: 0; background: transparent; padding: 0 10px; padding-left: calc(10px + var(--d, 0) * 14px);
  font-size: var(--fs-s); color: var(--muted); text-transform: lowercase; text-shadow: none; }
.pm .pm-restore:hover { color: var(--ink); background: var(--tint); }
.pm-sum, .pm-none { padding: 4px 10px; font-size: var(--fs-xs); color: var(--muted); }
.pm-foot { display: none; }
.pm-pop .pm-foot { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border-top: var(--bw) solid var(--ink); }
.pm-foot input[type=text] { flex: 1 1 140px; min-width: 0; }
.pm-opt { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-s); cursor: pointer; }
.pm-opt input { accent-color: var(--ink); }

/* ---------- performance strip (v0.18.0): eight assignable dials under the header, on every page (strip.js) ---------- */
.mstrip { order: 0; flex: none; display: flex; justify-content: space-around; align-items: flex-start; padding: 14px var(--pad) 12px; border-bottom: var(--bw) solid var(--ink); }
.mslot { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 150px; }
.mslot .dial { flex: none; gap: 6px; }
.mslot .dial .knob { flex: none; width: 64px; height: 64px; min-height: 0; }
.mpick > .rm-btn { font-size: var(--fs); padding: 0 10px; }
/* the pick menu: two columns, module headings kept with their first control */
.mpick .fn-menu { left: 50%; right: auto; transform: translateX(-50%); display: block; columns: 2; column-gap: 0; min-width: 380px; }
.mpick .fn-menu[hidden] { display: none; }
.mpick .fn-menu .mh { display: block; break-after: avoid; }
.mpick .fn-menu button { break-inside: avoid; }
.mslot:first-child .mpick .fn-menu { left: 0; transform: none; }
.mslot:last-child .mpick .fn-menu { left: auto; right: 0; transform: none; }

/* ---------- tabs: folder tabs under the strip (v0.19.1, after the TB-303 app). The active tab is open into the page below,
   with no line under it and a coloured top edge; the others sit lower, shaded and recessed ---------- */
.tabs { order: 1; flex: none; display: flex; align-items: flex-end; gap: 6px; padding: 8px var(--pad) 0; counter-reset: tab;
  background: linear-gradient(var(--ink), var(--ink)) bottom / 100% var(--bw) no-repeat; }
.tabs button { appearance: none; position: relative; flex: 0 0 auto; width: 124px; min-width: 0; margin: 0; border: var(--bw) solid var(--ink); border-bottom: 0; border-radius: 8px 8px 0 0;
  padding: calc(var(--gap-s) + 1px) 6px calc(var(--gap-s) + 3px);
  background: rgb(var(--ink-rgb) / .1); box-shadow: inset 0 4px 7px rgb(0 0 0 / .2);
  display: flex; align-items: baseline; justify-content: center; gap: 6px; color: var(--muted); font-size: var(--fs-l); line-height: 1; text-transform: lowercase;
  white-space: nowrap; cursor: pointer; text-shadow: var(--shadow); -webkit-tap-highlight-color: transparent; }
.tabs button[hidden] { display: none; }
/* v0.20.0: the tab numbers are gone and each tab is half its old width (Johnny) */
.tabs button::before { content: none; }
.tabs button[aria-selected="true"] { background: none; box-shadow: none; color: var(--ink); border-top: 5px solid var(--ink);   /* v0.20.1: ink, no spot colour (Johnny) */
  padding-top: calc(var(--gap-s) + 8px); padding-bottom: calc(var(--gap-s) + 3px + var(--bw)); margin-bottom: 0; }
/* the active tab hides the base line under it, so it opens into the page */
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: var(--bw); background: var(--glass); }
.tabs button:focus-visible { outline-offset: -4px; }

/* ---------- views: exactly one fills the space under the tabs ---------- */
.rack, .panel, .perf101 { order: 2; flex: 1 1 auto; min-height: 0; overflow: auto; }
.panel { display: flex; flex-direction: column; gap: var(--gap); padding: var(--pad); }
.panel[hidden] { display: none !important; }
.unit:not([data-view="tab-synth"]) .rack { display: none; }
.unit:not([data-view="tab-perf"]) .perf101 { display: none; }
.sec-h { flex: none; display: flex; flex-wrap: wrap; gap: var(--gap-s) var(--gap); align-items: center; }
.sec-h .tools { margin-left: auto; display: flex; gap: var(--gap-s) var(--gap); flex-wrap: wrap; align-items: center; }

/* synth: the rack of modules in signal-flow order, every row stretched to the bottom of the glass */
/* v0.20.0: the rack keeps the same 16 px gutter as the other pages (margin plus each module's padding); the rules on its
   outer edges fall just outside and are clipped, so only the rules between modules show */
.rack { display: flex; flex-wrap: wrap; align-content: stretch; margin: 6px 4px; overflow: hidden; }
.rack > .mod { margin: 0 -1px -1px 0; }
.mod { flex: 1 1 auto; display: flex; flex-direction: column; gap: calc(var(--gap-s) + 2px); min-width: 0; padding: calc(var(--pad) - 6px) calc(var(--pad) - 4px) calc(var(--pad) - 6px);
  border-right: var(--rule); border-bottom: var(--rule); }

/* bend board */
.bend-vals { flex: 1 1 auto; min-height: 0; display: flex; flex-wrap: wrap; align-items: stretch; gap: var(--gap) 0; }
.bend-grp { flex: 1 1 auto; display: flex; flex-direction: column; gap: calc(var(--gap-s) + 2px); padding: 0 calc(var(--gap) + 4px); border-right: var(--rule); }
.bend-grp:first-child { padding-left: 0; } .bend-grp:last-child { border-right: 0; padding-right: 0; }
.bend-grp .ctrls { gap: var(--gap); }

/* bridges: a patch matrix the width of the glass */
.br-depth { grid-template-columns: auto 140px 2.6em; }
.scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
table.mx { width: 100%; border-collapse: separate; border-spacing: 4px; font-size: var(--fs-s); }
.mx th { font-size: var(--fs-s); font-weight: 400; text-transform: lowercase; padding: 0 4px 2px; text-align: center; white-space: nowrap; }
.mx th.src { text-align: left; width: 1%; padding-right: calc(4.2em + 28px); position: relative; }
.mx .jack { width: 9px; height: 9px; display: inline-block; border: var(--bw) solid var(--ink); margin-right: 6px; vertical-align: middle; }
.cell { width: 64px; height: 28px; border: var(--bw) solid var(--ink); border-radius: var(--r); position: relative; cursor: ns-resize; touch-action: none; user-select: none;
  display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted); }
.mx .cell { width: 100%; min-width: 44px; height: 52px; }
.cell .fill { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(90deg, var(--ink) 0 4px, transparent 4px 6px); opacity: .9; }
.cell span { position: relative; z-index: 1; }
.cell.active { color: var(--ink); }
.cell.active span { background: var(--glass); padding: 0 3px; }
.mx .volt { font-size: var(--fs-s); color: var(--muted); position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 4.2em; text-align: right; font-variant-numeric: tabular-nums; }

.dial[hidden] { display: none; }
.dial.dim { opacity: .4; }
/* the type menus (the 303 app's .tmenu): a button with the current choice and ▾, the menu below it at its left edge */
.tmenu > .rm-btn { font-size: var(--fs); padding: 0 12px; }
.tmenu .fn-menu { left: 0; right: auto; min-width: 200px; }
.tmenu .fn-menu button { position: relative; justify-content: flex-start; padding: 0 14px 0 28px; }
.tmenu .fn-menu button[aria-checked=true]::before { content: "✓"; position: absolute; left: 8px; }
.mod .ctrls, .bend-grp .ctrls { justify-content: space-evenly; }
.fdr[hidden] { display: none; }

/* ---------- perform: the bender and transpose (arpeggio and the 101 sequencer were taken off in v0.13.2) ---------- */
/* v0.23.0: laid out like the Synth rack: three modules across the glass, rules between them, the same 16 px gutter.
   The bender's three depth faders run full height; the lever and transpose sit centred in their own modules. */
.perf101 { display: flex; align-items: stretch; margin: 6px 4px; overflow: hidden; }
.perf101 .grp { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: calc(var(--gap-s) + 2px);
  padding: calc(var(--pad) - 6px) calc(var(--pad) - 4px); border-right: var(--rule); margin-right: -1px; }
.perf101 .g-bend { flex-grow: 5; } .perf101 .g-lever { flex-grow: 4; } .perf101 .g-tr { flex-grow: 2; }
.perf101 h3 small { color: var(--lit); font-size: var(--fs-xs); letter-spacing: 0; }
.perf101 .row { flex: 1 1 auto; min-height: 0; display: flex; gap: var(--gap); }
#benderSlot { align-items: stretch; flex-wrap: nowrap; justify-content: space-evenly; }
#benderSlot .fdr { width: 5em; }
.perf101 .row:has(.lever) { flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--gap) * 2.5); }
.perf101 .g-tr .row { align-items: center; justify-content: center; }
.g-tr .sw button { font-size: var(--fs-l); padding: 4px 8px 4px 6px; gap: 10px; }
.g-tr .sw .lab { display: none; }   /* the strip above names it */
#modPush { min-width: 9em; height: var(--h-top); font-size: var(--fs-l); }
.lever { width: 100%; max-width: 380px; height: 64px; border: var(--bw) solid var(--ink); border-radius: var(--r); position: relative; touch-action: none; cursor: ew-resize;
  background: repeating-linear-gradient(90deg, var(--ghost) 0 4px, transparent 4px 7px); }
.lever::after { content: ""; position: absolute; left: 50%; top: 4px; bottom: 4px; width: 2px; background: var(--muted); }
.lever i { position: absolute; top: 4px; bottom: 4px; width: 22px; background: var(--ink); left: calc(50% - 11px); box-shadow: var(--shadow); }
.readout { align-self: flex-start; font-size: calc(var(--fs-l) + 6px); padding: 2px 14px; min-width: 7em; background: var(--ink); color: var(--glass); text-shadow: none; border-radius: var(--r);
  font-variant-numeric: tabular-nums; }
.status { font-size: var(--fs-s); color: var(--muted); }

/* ---------- portrait on a touch screen: the same scaled screen, just small, so a quiet hint under it says to turn it
   (from the TB-303 app's responsive.css; nothing is covered or hidden) ---------- */
.rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  .rotate { position: fixed; left: 0; right: 0; bottom: max(16px, env(safe-area-inset-bottom, 0px)); z-index: 1; display: flex; justify-content: center; align-items: center; gap: 8px;
    pointer-events: none; color: rgb(var(--glass-rgb) / .55); font-size: 16px; }
  .rotate svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
  .rotate p { margin: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- one fixed screen, scaled to fit the window (js/app/fit.js sets --k; after the TB-303 app's html.fit) ----------
   The glass is always 1400 x 906 (1.545:1, Johnny's MacBook Pro display) and scaled as a whole, with the dark case round it.
   Pop-ups inside the glass scale with it; the Options sheet sits in the top layer, so it gets its own fixed size and the same scale. */
html.fit, html.fit body { height: 100vh; height: 100dvh; overflow: hidden; }
html.fit body { padding: 0; position: relative; }
/* v0.17.3: the page round the screen is flat near-black, so the screen's edge reads as the shape of the plugin window. */
html.fit, html.fit body { background: #111; background-image: none; }
html.fit .unit { position: absolute; left: 50%; top: 50%; width: 1400px; height: 906px; max-width: none; min-height: 0; margin: 0;
  transform: translate(-50%, -50%) scale(var(--k, 1)); }
html.fit dialog#options { width: 1344px; height: 842px; inset: auto; left: 50%; top: 50%; margin: 0; max-width: none; max-height: none;
  transform: translate(-50%, -50%) scale(var(--k, 1)); }
html.fit { touch-action: pan-x pan-y; overscroll-behavior: none; }
/* v0.20.2: text isn't selectable (Johnny); typing boxes still are */
body, body *:not(input):not(textarea) { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
