/* The SMC-Mixer configuration editor. iPad landscape first (1180 x 820 and up), then portrait, phone and desktop.

   The look: a quiet, neutral interface in "ink" (near black, or near white in dark), with colour
   kept for what matters: the message types on the panel, Shift (amber), and the mixer's state.
   Hairlines instead of boxes, filled fields instead of outlined ones, the system font. */

:root {
  /* neutrals */
  --bg: #f3f3f5;
  --surface: #ffffff;
  --surface-2: #f8f8fa;
  --fill: rgba(118, 118, 128, .12);
  --fill-2: rgba(118, 118, 128, .2);
  --line: rgba(60, 60, 67, .12);
  --line-strong: rgba(60, 60, 67, .26);
  --text: #1c1c1e;
  --muted: #6c6c74;
  --faint: #a3a3ab;
  --ink: #1c1c1e;
  --on-ink: #ffffff;
  --thumb: #ffffff;
  /* colour with a meaning */
  --accent: oklch(.56 .17 256);
  --accent-text: oklch(.5 .17 256);
  --accent-soft: oklch(.95 .03 256);
  --on-accent: #ffffff;
  --shift: oklch(.68 .16 62);
  --shift-text: oklch(.55 .14 60);
  --shift-soft: oklch(.96 .04 75);
  --danger: oklch(.58 .2 27);
  --danger-soft: oklch(.95 .03 27);
  --ok: oklch(.66 .15 152);
  /* the mixer */
  --panel: #e8e8ec;
  --panel-edge: rgba(0, 0, 0, .05);
  --tile: #ffffff;
  --tile-shadow: 0 0 0 .5px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .08);
  --knob: #2b2b30;
  --knob-ind: #ffffff;
  --cap: #3a3a40;
  --track: #c9c9d0;
  --sel: var(--ink);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
  --pop: 0 0 0 .5px rgba(0, 0, 0, .08), 0 12px 40px rgba(0, 0, 0, .16);
  /* message types: one lightness and chroma, hues spread round the wheel */
  --t-none: #c4c4cb;
  --t-cc7: oklch(.62 .15 256);
  --t-cc14: oklch(.64 .11 200);
  --t-nrpn: oklch(.6 .16 296);
  --t-rpn: oklch(.6 .16 336);
  --t-note: oklch(.64 .14 150);
  --t-pitchbend: oklch(.65 .15 42);
  --t-program: oklch(.72 .13 95);
  --t-aftertouch: oklch(.62 .17 8);
  --t-rel: oklch(.66 .11 228);
  --radius: 12px;
  --tap: 36px;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='none' stroke='%238e8e96' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0d0f; --surface: #17171a; --surface-2: #1c1c20; --fill: rgba(118, 118, 128, .22); --fill-2: rgba(118, 118, 128, .32);
    --line: rgba(255, 255, 255, .08); --line-strong: rgba(255, 255, 255, .18); --text: #f2f2f4; --muted: #9b9ba5; --faint: #66666f;
    --ink: #f2f2f4; --on-ink: #111113; --thumb: #46464d;
    --accent: oklch(.68 .15 256); --accent-text: oklch(.78 .12 256); --accent-soft: oklch(.3 .06 256);
    --shift: oklch(.74 .15 66); --shift-text: oklch(.8 .13 70); --shift-soft: oklch(.3 .05 66);
    --danger: oklch(.7 .17 27); --danger-soft: oklch(.3 .07 27); --ok: oklch(.74 .15 152);
    --panel: #111114; --panel-edge: rgba(255, 255, 255, .06); --tile: #222226;
    --tile-shadow: inset 0 .5px 0 rgba(255, 255, 255, .06), 0 1px 2px rgba(0, 0, 0, .5);
    --knob: #0b0b0d; --knob-ind: #f2f2f4; --cap: #6a6a73; --track: #3a3a41;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    --pop: 0 0 0 .5px rgba(255, 255, 255, .1), 0 16px 48px rgba(0, 0, 0, .55);
    --t-none: #4a4a52; --t-cc7: oklch(.72 .14 256); --t-cc14: oklch(.74 .1 200); --t-nrpn: oklch(.72 .14 296);
    --t-rpn: oklch(.72 .14 336); --t-note: oklch(.74 .14 150); --t-pitchbend: oklch(.74 .14 42);
    --t-program: oklch(.8 .12 95); --t-aftertouch: oklch(.72 .15 8); --t-rel: oklch(.76 .1 228);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0d0f; --surface: #17171a; --surface-2: #1c1c20; --fill: rgba(118, 118, 128, .22); --fill-2: rgba(118, 118, 128, .32);
  --line: rgba(255, 255, 255, .08); --line-strong: rgba(255, 255, 255, .18); --text: #f2f2f4; --muted: #9b9ba5; --faint: #66666f;
  --ink: #f2f2f4; --on-ink: #111113; --thumb: #46464d;
  --accent: oklch(.68 .15 256); --accent-text: oklch(.78 .12 256); --accent-soft: oklch(.3 .06 256);
  --shift: oklch(.74 .15 66); --shift-text: oklch(.8 .13 70); --shift-soft: oklch(.3 .05 66);
  --danger: oklch(.7 .17 27); --danger-soft: oklch(.3 .07 27); --ok: oklch(.74 .15 152);
  --panel: #111114; --panel-edge: rgba(255, 255, 255, .06); --tile: #222226;
  --tile-shadow: inset 0 .5px 0 rgba(255, 255, 255, .06), 0 1px 2px rgba(0, 0, 0, .5);
  --knob: #0b0b0d; --knob-ind: #f2f2f4; --cap: #6a6a73; --track: #3a3a41;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  --pop: 0 0 0 .5px rgba(255, 255, 255, .1), 0 16px 48px rgba(0, 0, 0, .55);
  --t-none: #4a4a52; --t-cc7: oklch(.72 .14 256); --t-cc14: oklch(.74 .1 200); --t-nrpn: oklch(.72 .14 296);
  --t-rpn: oklch(.72 .14 336); --t-note: oklch(.74 .14 150); --t-pitchbend: oklch(.74 .14 42);
  --t-program: oklch(.8 .12 95); --t-aftertouch: oklch(.72 .15 8); --t-rel: oklch(.76 .1 228);
  color-scheme: dark;
}

/* ---- base ---- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.42 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  letter-spacing: -.003em;
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

button {
  border: 0; background: var(--fill); border-radius: 9px;
  padding: 6px 12px; min-height: var(--tap); cursor: pointer; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  transition: background-color .12s, color .12s, box-shadow .12s;
}
button:hover:not(:disabled) { background: var(--fill-2); }
button:active:not(:disabled) { transform: translateY(.5px); }
button.primary { background: var(--ink); color: var(--on-ink); }
button.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); }
button.danger { color: var(--danger); }
button.danger-fill { background: var(--danger); color: #fff; }
button.danger-fill:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, #000); }
button:disabled { opacity: .45; cursor: default; }
button.icon-only { padding: 0; width: var(--tap); }

input[type=number], input[type=text], input[type=search], input:not([type]), select, textarea {
  border: 0; background-color: var(--fill); border-radius: 9px; outline: 0;
  padding: 7px 10px; min-height: var(--tap); width: 100%; min-width: 0;
  transition: box-shadow .12s, background-color .12s;
}
input[type=number] { font-variant-numeric: tabular-nums; }
select { appearance: none; -webkit-appearance: none; background-image: var(--chev); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus) { background-color: var(--fill-2); }
input:focus, select:focus, textarea:focus { background-color: var(--surface); box-shadow: 0 0 0 2px var(--accent); }
input::placeholder { color: var(--faint); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; flex: none; }
input:disabled, select:disabled { opacity: .5; cursor: default; }
button:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ic { display: inline-flex; flex: none; line-height: 0; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }
h3 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: color-mix(in oklab, var(--muted), var(--text) 35%); margin: 24px 0 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.help { font-size: 12px; color: var(--muted); margin: 4px 0 0; line-height: 1.4; }
p.help { margin: 4px 0 12px; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ---- top bars ---- */
#topbar { background: var(--surface); border-bottom: 1px solid var(--line); flex: none; position: relative; z-index: 3; }
.bar { display: flex; align-items: center; gap: 4px; padding: 6px 12px; min-width: 0; }
.bar-2 { padding-top: 0; padding-bottom: 8px; gap: 16px; }
.tb { background: transparent; padding: 6px 10px; color: var(--text); }
.tb .ic { color: var(--muted); }
.tb:hover:not(:disabled) { background: var(--fill); }
.tb:hover:not(:disabled) .ic { color: var(--text); }
.tb.on { background: var(--fill); }
.tb-group { display: inline-flex; }
/* Only the name gives way when the bar is short; the buttons keep their size. */
.bar-1 > :not(.title-input):not(.spacer) { flex: none; }
.title-input { min-width: 0; text-overflow: ellipsis; }
.title-input:focus { text-overflow: clip; }
.title-input {
  font-weight: 650; font-size: 17px; letter-spacing: -.015em; background-color: transparent !important;
  max-width: 340px; flex: 0 1 340px; margin-left: 4px;
}
.title-input:hover:not(:focus) { background-color: var(--fill) !important; }
.title-input:focus { background-color: var(--surface) !important; }
.badge { font-size: 12px; min-height: 24px; padding: 2px 10px; border-radius: 99px; background: var(--danger); color: #fff; font-weight: 600; }
.badge:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, #000); }
.pill { gap: 8px; border-radius: 99px; padding: 4px 14px 4px 12px; color: var(--muted); background: var(--fill); margin-left: 6px; font-weight: 500; }
.pill .ic { color: var(--muted); }
.pill.ok { color: var(--text); }
.pill .ptext { min-width: 92px; text-align: left; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--t-none); flex: none; }
.pill.ok .dot, .dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.pill.wait .dot { background: var(--shift); box-shadow: 0 0 0 3px color-mix(in srgb, var(--shift) 22%, transparent); animation: pulse 1s infinite; }
.pill.bad .dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

.navgroup { display: flex; align-items: center; gap: 8px; min-width: 0; }
.navgroup > .lbl { font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; flex: none; }
.tabs { display: flex; gap: 2px; align-items: center; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs .tab {
  position: relative; min-height: 34px; padding: 4px 11px; border-radius: 9px; background: transparent;
  gap: 6px; flex: none; color: var(--muted); font-weight: 500;
}
.tabs .tab:hover:not(:disabled) { background: var(--fill); color: var(--text); }
.tabs .tab small { color: var(--faint); font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; }
.tabs .tab.on { background: var(--fill); color: var(--text); font-weight: 600; }
.tabs .tab.on .ic { color: var(--muted); }
.tabs .tab .tname { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.tabs .tab .live { position: absolute; top: 6px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

/* segmented controls: a track with a raised thumb */
.seg { display: inline-flex; background: var(--fill); border-radius: 10px; padding: 2px; gap: 2px; flex: none; }
.seg button { background: transparent; border-radius: 8px; min-height: 32px; padding: 4px 12px; color: var(--muted); }
.seg button:hover:not(:disabled):not(.on) { background: transparent; color: var(--text); }
.seg button.on { background: var(--thumb); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); }
.seg button.on:hover:not(:disabled) { background: var(--thumb); }
.seg.small button { min-height: 28px; font-size: 13px; padding: 2px 10px; }
.seg.full { display: flex; }
.seg.full button { flex: 1; padding: 6px 4px; min-width: 0; }
.learn-banner { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 0 0 12px; }
.learn-banner .row { align-items: flex-start; gap: 10px; }
.learn-banner .grow { flex: 1; min-width: 0; }
.learn-banner .pretend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; }
.learn-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); margin-top: 5px; flex: none; animation: learn-pulse 1.2s ease-in-out infinite; }
#panel .ctl.learning { outline: 2px solid var(--danger); outline-offset: 2px; animation: learn-pulse 1.2s ease-in-out infinite; }
@keyframes learn-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .learn-dot, #panel .ctl.learning { animation: none; } }
.learn-row { margin: 0 0 4px; }
.learn-row > button { flex: 1; }
.list-head { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 13px; }
.link-seg { margin-left: 6px; }
.link-seg button { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; }
.link-seg:not(.off) button.on .ic { color: var(--ok); }
.link-seg[hidden] { display: none; }
#layer-seg button[data-layer=shift].on, .layer-seg button:last-child.on { background: var(--shift); color: #fff; }

/* ---- main ---- */
#main { flex: 1; display: flex; min-height: 0; }
#work { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 12px; gap: 10px; overflow: auto; }
#side { width: clamp(300px, 28vw, 380px); flex: none; background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; gap: 6px; margin: 10px 12px 4px; }
.side-title { display: flex; flex: 1; align-items: center; gap: 8px; min-width: 0; }
.side-title:empty { display: none; }
.side-title b { flex: 1; font-size: 13px; }
#sheet-toggle { display: none; }
#sheet-toggle .ic { transition: transform .15s; }
body.sheet-min #sheet-toggle .ic { transform: rotate(180deg); }
.side-body { flex: 1; overflow: auto; padding: 8px 16px 40px; overscroll-behavior: contain;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 24px), transparent); mask-image: linear-gradient(#000 calc(100% - 24px), transparent); }
body.shift-view #panel-wrap, body.shift-view #table-wrap { background: color-mix(in srgb, var(--shift-soft) 55%, var(--bg)); border-radius: var(--radius); box-shadow: 0 0 0 6px color-mix(in srgb, var(--shift-soft) 55%, var(--bg)); }

#selbar { display: flex; gap: 8px; align-items: center; min-width: 0; }
.chips { display: flex; gap: 4px; align-items: center; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
/* More chips past an edge (js/app.js, fadeChips): the edge fades, so the row says it scrolls. */
.chips.more-end { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
.chips.more-start { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent); }
.chips.more-start.more-end { -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent); }
.chip { min-height: 30px; padding: 3px 12px; border-radius: 99px; font-size: 13px; background: transparent; gap: 4px; flex: none; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-strong); }
.chip:hover:not(:disabled) { background: var(--fill); color: var(--text); }
.chip.on, .chip.on:hover:not(:disabled) { background: var(--ink); color: var(--on-ink); box-shadow: none; }
.chip.ghost { color: var(--text); background: var(--fill); box-shadow: none; }
.chip.toggle.on, .chip.toggle.on:hover:not(:disabled) { background: var(--fill); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--ink); }

/* ---- the panel: the mixer's face (docs/hardware.md) ---- */
#panel-wrap { position: relative; flex: 1 0 auto; max-height: 820px; display: flex; flex-direction: column; }
#panel {
  flex: 1; background: var(--panel); border-radius: 22px;
  box-shadow: inset 0 0 0 1px var(--panel-edge), inset 0 1px 3px rgba(0, 0, 0, .05);
  padding: 12px 14px 14px; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)) minmax(56px, .5fr);
  grid-template-rows: minmax(0, 1fr) auto;
  column-gap: 8px; row-gap: 6px; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
#panel.sim { box-shadow: inset 0 0 0 2px var(--ok); }
#panel.armed { box-shadow: inset 0 0 0 2px var(--ink); animation: armed 1.6s ease-in-out infinite; }
@keyframes armed { 50% { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ink) 30%, transparent); } }
#panel.armed .ctl:not(.nav-fixed) { cursor: copy; }
#panel.lassoing { touch-action: none; }
.strip { display: grid; grid-template-rows: auto auto 1fr; gap: 6px; min-width: 0; }
.strip-head {
  min-height: 24px; padding: 0; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: color-mix(in oklab, var(--muted), var(--text) 15%); /* 11 px on the panel: 5.2:1 light, 6.7:1 dark */
  background: transparent; border-radius: 7px;
}
.strip-head:hover:not(:disabled) { background: var(--fill); color: var(--text); }
.strip-body { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 6px; min-height: 0; }
.btn-col { display: grid; grid-template-rows: repeat(4, 1fr); gap: 6px; min-width: 0; }
.side-col { display: flex; flex-direction: column; gap: 6px; align-items: stretch; padding-top: 30px; }
.side-col .fixed-btn { min-height: 39px; }

.ctl {
  --tc: var(--t-none);
  position: relative; border-radius: 10px; background: var(--tile); box-shadow: var(--tile-shadow);
  cursor: pointer; min-width: 0; overflow: hidden; transition: box-shadow .12s;
}
.ctl::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 3px; border-radius: 2px; background: var(--tc); }
.ctl .lbl { display: block; font-size: 12px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; font-variant-numeric: tabular-nums; }
.ctl .sub { display: block; font-size: 10.5px; color: color-mix(in oklab, var(--muted), var(--text) 18%); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ctl:hover { box-shadow: var(--tile-shadow), 0 0 0 1px var(--line-strong); }
.ctl.sel, .ctl.sel:hover { box-shadow: 0 0 0 2px var(--sel), 0 4px 12px rgba(0, 0, 0, .12); }
.ctl.flash { animation: flash .8s; }
@keyframes flash { 0% { box-shadow: 0 0 0 5px var(--ok); } 100% { box-shadow: var(--tile-shadow); } }
.ctl.t-none::before { opacity: .6; }
.ctl.t-none .lbl { color: var(--faint); font-weight: 500; }
.ctl.ghost { opacity: .4; box-shadow: inset 0 0 0 1px var(--line-strong); background: transparent; }
.ctl.ghost.sel { opacity: .85; box-shadow: 0 0 0 2px var(--sel); }
.ctl.block { background: repeating-linear-gradient(135deg, transparent 0 5px, var(--fill) 5px 10px); box-shadow: inset 0 0 0 1px var(--line); }
.ctl.block::before { display: none; }
.ctl.block .lbl { color: var(--muted); font-weight: 500; font-style: italic; }
.ctl.nav-fixed { cursor: default; background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.ctl.nav-fixed::before { display: none; }
.ctl.nav-fixed .lbl { color: var(--muted); }
.ctl .tag { position: absolute; right: 4px; top: 4px; font-size: 9.5px; line-height: 14px; padding: 0 5px; border-radius: 5px; background: var(--shift-soft); color: var(--shift-text); font-weight: 650; letter-spacing: .02em; z-index: 1; }
.ctl .share { position: absolute; right: 4px; bottom: 4px; color: var(--muted); line-height: 0; }
.ctl .lock { position: absolute; right: 5px; top: 5px; color: var(--faint); line-height: 0; }

.enc { padding: 8px 4px 6px 10px; display: grid; gap: 4px; justify-items: center; text-align: center; }
.enc .knob {
  width: 34px; height: 34px; border-radius: 50%; position: relative;
  background: conic-gradient(from 225deg, var(--tc) calc(var(--v, 0) * 270deg), var(--track) 0 270deg, transparent 0);
}
.enc .knob::after {
  content: ""; position: absolute; inset: 4px; border-radius: 50%;
  background: linear-gradient(var(--knob-ind), var(--knob-ind)) 50% 3px / 2px 8px no-repeat, radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--knob) 80%, #fff), var(--knob) 70%);
  transform: rotate(calc(-135deg + var(--v, 0) * 270deg));
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
.enc .txt { min-width: 0; max-width: 100%; }
.enc .tag { position: static; display: inline-block; margin-top: 1px; }

.fader { padding: 8px 2px 8px 6px; display: flex; flex-direction: row; gap: 2px; min-height: 170px; }
.fader .vtxt { writing-mode: vertical-rl; transform: rotate(180deg); flex: none; display: flex; overflow: hidden; text-align: left; }
.fader .vtxt .lbl { max-height: 100%; }
.fader .track { flex: 1; position: relative; margin: 4px 0; min-width: 14px; }
.fader .track::before { content: ""; position: absolute; left: calc(50% - 2px); width: 4px; top: 0; bottom: 0; background: var(--track); border-radius: 2px; }
.fader .track::after { content: ""; position: absolute; left: calc(50% - 2px); width: 4px; bottom: 0; height: calc(var(--v, 0) * (100% - 22px) + 11px); background: var(--tc); border-radius: 2px; }
.fader::before { display: none; }
.fader .cap { z-index: 1; }
.fader .cap {
  position: absolute; left: calc(50% - 9px); width: 18px; height: 22px; border-radius: 5px;
  /* The cap carries the control's type colour, as the knobs' arc and the buttons' bar do; the grip
     line stays light so the cap reads as a fader cap. */
  background: linear-gradient(rgba(255, 255, 255, .85), rgba(255, 255, 255, .85)) 50% 50% / 12px 2px no-repeat,
    linear-gradient(color-mix(in oklab, var(--tc) 82%, #fff), color-mix(in oklab, var(--tc) 88%, #000));
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35); bottom: calc(var(--v, 0) * (100% - 22px));
}
/* Narrow strips (phones, portrait tablets, small windows): the fader tile is only 25-40 px wide,
   too narrow for the label, the track and an 18 px cap side by side. The tile tightens its
   padding and label, and the cap fills the track's width, so the whole slider stays inside. */
.strip-body { container-type: inline-size; }
@container (max-width: 100px) {
  .fader { padding: 6px 2px 6px 2px; gap: 1px; }
  .fader .vtxt { line-height: 1.1; }
  .fader .vtxt .lbl { font-size: 11px; }
  .fader .track { min-width: 8px; }
  .fader .cap { left: 0; right: 0; width: auto; max-width: 18px; margin: 0 auto; border-radius: 4px;
    background-size: 70% 2px, auto; }
}

.btn { padding: 3px 3px 3px 12px; display: flex; flex-direction: column; justify-content: center; min-height: 44px; }
.btn-col .btn { padding: 3px 2px 3px 11px; }
.btn-col .btn .lbl { font-size: 11px; white-space: normal; overflow-wrap: anywhere; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.btn .face { position: absolute; right: 6px; top: 6px; color: var(--faint); line-height: 0; }
.btn.lit { background: color-mix(in srgb, var(--tc) 20%, var(--tile)); }
.btn.lit::after { content: ""; position: absolute; right: 6px; bottom: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--tc); box-shadow: 0 0 6px var(--tc); }

.row-btns { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 6px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--panel-edge); }
.row-btns .btn { min-height: 52px; padding-top: 16px; justify-content: flex-start; }
.row-btns .btn .lbl { font-size: 11.5px; }
.row-note { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; margin: -2px 0 0; font-size: 11px; font-weight: 600;
  color: color-mix(in oklab, var(--muted), var(--text) 15%); letter-spacing: .01em; }
.row-note .ic { line-height: 0; }
.fixed-btn {
  border-radius: 10px; cursor: default; padding: 6px 4px; min-height: 44px; box-shadow: inset 0 0 0 1px var(--line-strong);
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  color: color-mix(in oklab, var(--muted), var(--text) 15%); /* 11 px on the panel: 5.2:1 light, 6.7:1 dark */
}
.fixed-btn.shift-on { background: var(--shift); color: #fff; box-shadow: 0 0 12px color-mix(in srgb, var(--shift) 50%, transparent); }
#panel.sim .fixed-btn.shift { cursor: pointer; }

#lasso { position: absolute; border: 1px solid var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); pointer-events: none; border-radius: 6px; }

#legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: color-mix(in oklab, var(--muted), var(--text) 15%); align-items: center; padding: 0 2px; }
#legend > span { display: inline-flex; align-items: center; gap: 6px; }
#legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
#legend .sep { width: 1px; height: 14px; background: var(--line-strong); }
#legend i.lg-ghost { width: 10px; height: 10px; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--line-strong); }
#legend i.lg-block { width: 10px; height: 10px; border-radius: 3px; background: repeating-linear-gradient(135deg, transparent 0 2px, var(--line-strong) 2px 3.5px); box-shadow: inset 0 0 0 1px var(--line); }

/* ---- list view ---- */
#table-wrap { overflow: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); flex: 1; min-height: 240px; }
table.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 4px 8px; text-align: left; white-space: nowrap; }
table.grid th { position: sticky; top: 0; background: var(--surface); font-weight: 600; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; z-index: 1; padding: 10px 8px; }
table.grid tbody tr:hover td { background: var(--surface-2); }
table.grid tr.sel td { background: color-mix(in srgb, var(--ink) 6%, var(--surface)); }
table.grid tr.group td { background: var(--surface-2); font-weight: 600; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 8px; }
table.grid input:not([type=checkbox]), table.grid select { min-height: 30px; padding: 3px 8px; background-color: transparent; }
table.grid select { padding-right: 26px; }
table.grid input:not([type=checkbox]):hover, table.grid select:hover { background-color: var(--fill); }
table.grid td.n input { width: 80px; }
table.grid .tdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
table.grid td:nth-child(3) input { min-width: 140px; }
table.grid td:nth-child(4) select { min-width: 150px; }
table.grid td:last-child { white-space: normal; min-width: 160px; }
.inline-ic { display: inline-flex; vertical-align: -2px; margin-right: 6px; }

/* ---- inspector ---- */
.empty h2 { font-size: 20px; font-weight: 650; letter-spacing: -.015em; margin: 12px 0 4px; }
.empty p { margin: 0 0 14px; color: var(--muted); }
.empty ul { padding-left: 18px; margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.empty li { margin-bottom: 8px; }
.empty li b { color: var(--text); font-weight: 600; }
.insp-head { margin: 8px 0 12px; }
.insp-head .where { font-size: 12px; color: var(--muted); }
.insp-head h2 { margin: 2px 0 10px; font-size: 20px; font-weight: 650; letter-spacing: -.015em; }
.field { margin: 14px 0; }
.field > label, .field > .flabel { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.flabel { font-size: 12px; font-weight: 600; color: var(--muted); }
.row { display: flex; gap: 6px; align-items: center; min-width: 0; }
.row > input, .row > select { flex: 1; }
.row > button { flex: none; }
.row .eq { flex: none; color: var(--faint); font-size: 12px; }
.row.unit > span { flex: none; color: var(--muted); font-size: 13px; min-width: 24px; }
.field.mixed input, .field.mixed select { font-style: italic; }
.row.slider { gap: 12px; padding-bottom: 4px; }
.row.slider input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); }
.row.slider output.level { flex: none; min-width: 4.5em; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: 10px; margin: 12px 0; cursor: pointer; }
.sends { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 16px 0; }
.stext { margin: 4px 0 8px; font-size: 13px; }
.bytes { display: flex; flex-wrap: wrap; gap: 4px; }
.bytes code { font-size: 11.5px; padding: 2px 6px; border-radius: 6px; background: var(--fill); color: var(--text); }
.note { display: flex; gap: 10px; align-items: flex-start; border-radius: var(--radius); padding: 10px 12px; margin: 12px 0; font-size: 13px; background: var(--fill); color: var(--text); }
.note .ic { margin-top: 1px; color: var(--muted); }
.note.warn { background: var(--shift-soft); }
.note.warn .ic { color: var(--shift-text); }
.shift-box { border-radius: var(--radius); padding: 6px 12px 10px; margin: 14px 0; background: var(--shift-soft); }
.shift-box .flabel { color: var(--shift-text); }
.shift-box .seg { background: color-mix(in srgb, var(--shift) 16%, transparent); }
.shift-box .seg button.on { background: var(--shift); color: #fff; }
.shift-box .help { color: color-mix(in srgb, var(--shift-text) 70%, var(--muted)); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; align-items: center; }
.soon { display: inline-block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 5px; background: var(--fill); color: var(--muted); }
details.more, details.shared { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 2px; }
details > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: var(--tap); font-weight: 600; font-size: 13px; list-style: none; border-radius: 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; margin: 0 4px 0 2px; }
details[open] > summary::before { transform: rotate(45deg); }
details.shared ul { margin: 2px 0 8px; padding-left: 20px; font-size: 13px; }
details.bt-help ul { margin: 2px 0 8px; padding-left: 20px; }
details.bt-help p { margin: 6px 0; }
details.shared li button { min-height: 28px; padding: 0 6px; background: transparent; color: var(--accent-text); }

/* ---- parameters ---- */
.steps { padding-left: 20px; margin: 6px 0 14px; color: var(--muted); font-size: 13px; }
.steps li { margin-bottom: 4px; }
.armed-bar { position: sticky; top: 0; z-index: 2; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); color: var(--text); margin: 8px 0; box-shadow: inset 0 0 0 1.5px var(--ink), var(--shadow); }
.ab-next small { display: block; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; opacity: .65; }
.ab-next b { font-size: 17px; font-weight: 650; overflow-wrap: anywhere; }
.ab-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.armed-bar button { min-height: 30px; }
#psearch { margin: 4px 0 0; }
.plist { list-style: none; margin: 8px -6px; padding: 0; }
.plist li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.plist li:hover { background: var(--fill); }
.plist li.armed { background: var(--fill); box-shadow: inset 0 0 0 1.5px var(--ink); }
.plist li.used .pn { color: var(--muted); }
.plist li .pdot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.plist li .pn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist li .pm { font-size: 11.5px; color: var(--faint); font-family: ui-monospace, "SF Mono", Menlo, monospace; white-space: nowrap; }
.plist li .ic { color: var(--ok); }
.plist li .pg { font-size: 11px; color: var(--muted); white-space: nowrap; padding: 1px 6px; border-radius: 5px; background: var(--fill); }

/* ---- monitor ---- */
#monitor { background: var(--surface); border-top: 1px solid var(--line); flex: none; padding-bottom: env(safe-area-inset-bottom); }
#monitor-bar { display: flex; align-items: center; gap: 10px; padding: 4px 12px; font-size: 13px; min-height: 44px; min-width: 0; }
#monitor-bar .state { font-weight: 600; white-space: nowrap; }
#monitor-bar .last { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
#monitor-bar > button:not(.tb):not(.chip) { min-height: 28px; padding: 2px 10px; font-size: 13px; }
.sim-sep { width: 1px; height: 20px; background: var(--line-strong); flex: none; }
.chip.sim-toggle.on, .chip.sim-toggle.on:hover:not(:disabled) { background: var(--ok); color: #fff; box-shadow: none; }
#monitor-list { height: 190px; overflow: auto; padding: 0 12px 8px; border-top: 1px solid var(--line); }
table.mon { border-collapse: collapse; width: 100%; font-size: 12px; }
table.mon td { padding: 3px 10px 3px 0; white-space: nowrap; vertical-align: top; border-bottom: 1px solid var(--line); }
table.mon td.t, table.mon td.b { font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted); font-size: 11.5px; }
table.mon tr.in td:nth-child(2), table.mon tr.in td:nth-child(4) { color: var(--t-note); }
table.mon td.who { color: var(--muted); width: 100%; white-space: normal; }

/* ---- dialogs, menus, toast ---- */
dialog { border: 0; border-radius: 18px; padding: 0; background: var(--surface); color: var(--text); width: min(640px, calc(100vw - 24px)); max-height: min(88vh, 900px); box-shadow: var(--pop); }
dialog[open] { animation: rise .18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.985); } }
dialog::backdrop { background: rgba(0, 0, 0, .32); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#dlg-body { --dlg-pad: 20px; padding: var(--dlg-pad) 22px var(--dlg-pad); overflow: auto; max-height: min(88vh, 900px); }
/* The title (and the settings' tabs) stay in view while a long sheet scrolls. */
#dlg-body > div > .dlg-head:first-child, .dlg-top { position: sticky; top: calc(-1 * var(--dlg-pad)); z-index: 3; background: var(--surface); margin-top: calc(-1 * var(--dlg-pad)); padding-top: var(--dlg-pad); }
.dlg-top { padding-bottom: 10px; box-shadow: 0 1px 0 var(--line); margin-bottom: 12px; }
#dlg-body h2 { margin: 0 0 12px; font-size: 19px; font-weight: 650; letter-spacing: -.015em; }
.dlg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.dlg-head h2 { flex: 1; margin: 0 !important; }
.dlg-head button { background: transparent; color: var(--muted); }
.dlg-head button:hover:not(:disabled) { background: var(--fill); color: var(--text); }
.settings { min-height: min(62vh, 560px); display: flex; flex-direction: column; }
.settings > .dlg-foot { margin-top: auto; }
details.later h3 { margin-top: 14px; }
.dlg-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin: 20px 0 calc(-1 * var(--dlg-pad)); position: sticky; bottom: calc(-1 * var(--dlg-pad)); z-index: 2; background: var(--surface); padding: 16px 0 var(--dlg-pad); box-shadow: 0 -1px 0 var(--line-strong), 0 -12px 16px -12px rgba(0, 0, 0, .12); }
.form3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.preview { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.preview > * { font: 11.5px ui-monospace, "SF Mono", Menlo, monospace; background: var(--fill); border-radius: 6px; padding: 2px 6px; }
.preview.fill { gap: 6px; max-height: 40vh; overflow: auto; }
.preview.fill .pv { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 64px; padding: 4px 8px; position: relative; }
.preview.fill .pv small { font-family: system-ui, sans-serif; font-size: 10.5px; line-height: 1.2; color: var(--muted); }
.preview.fill .pv b { font-weight: 600; font-variant-numeric: tabular-nums; }
.preview.fill .pv.skip { opacity: .45; }
.preview.fill .pv.err { background: color-mix(in oklab, var(--danger) 16%, transparent); box-shadow: inset 0 0 0 1px var(--danger); }
.preview.fill .pv.clash { box-shadow: inset 0 0 0 1px var(--shift-text); }
.preview.fill .pv svg { position: absolute; top: 4px; right: 4px; color: var(--shift-text); }
.fill-sum.bad { color: var(--danger); }
.conn { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); margin: 4px 0 14px; }
.kv { display: grid; grid-template-columns: minmax(120px, 160px) 1fr; gap: 6px 12px; font-size: 13px; margin: 4px 0 8px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.meter { display: inline-block; width: 120px; height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ink); }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.switch-row > span { flex: 1; display: flex; flex-direction: column; }
.switch-row b { font-weight: 500; }
input[role=switch] { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 13px; background: var(--fill-2); position: relative; cursor: pointer; transition: background .18s; flex: none; }
input[role=switch]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .18s; }
input[role=switch]:checked { background: var(--ok); }
input[role=switch]:checked::after { transform: translateX(18px); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 10px; }
.card { border-radius: var(--radius); padding: 12px 14px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: 6px; }
.card b { font-size: 14px; font-weight: 600; }
.card p { margin: 0; font-size: 12px; color: var(--muted); flex: 1; }
.card button { align-self: flex-start; }
/* A card's actions: the main button takes the room left and shortens its label; an icon button
   (Remove) keeps its size, so neither leaves the card. */
.card .row { align-self: stretch; }
.card .row > button:not(.icon-only), .card > button { flex: 0 1 auto; min-width: 0; max-width: 100%; }
.card .ell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .row > button.icon-only { flex: none; margin-left: auto; }
.errlist { font: 12px/1.5 ui-monospace, "SF Mono", Menlo, monospace; max-height: 50vh; overflow: auto; background: var(--surface-2); padding: 10px 10px 10px 24px; border-radius: var(--radius); }
pre.json { font: 11.5px/1.5 ui-monospace, "SF Mono", Menlo, monospace; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); padding: 12px; border-radius: var(--radius); max-height: 50vh; overflow: auto; margin: 0 0 8px; }
.logs { font: 11.5px/1.5 ui-monospace, "SF Mono", Menlo, monospace; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); padding: 10px; border-radius: var(--radius); max-height: 220px; overflow: auto; }
.menu {
  position: fixed; z-index: 50; border-radius: 14px; padding: 6px; min-width: 230px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow: auto;
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: var(--pop); animation: rise .12s ease-out;
}
.menu button { display: flex; justify-content: flex-start; width: 100%; text-align: left; background: transparent; min-height: 36px; gap: 10px; border-radius: 8px; font-weight: 450; }
.menu button .ic { width: 16px; justify-content: center; color: var(--muted); }
.menu button:hover:not(:disabled) { background: var(--fill); }
.menu button.on { font-weight: 600; }
.menu button.danger .ic { color: var(--danger); }
.menu button.danger:hover:not(:disabled) { background: var(--danger-soft); }
.menu .sep { border-top: 1px solid var(--line); margin: 5px 8px; }
.menu .mh { font-size: 11px; font-weight: 600; color: var(--faint); padding: 8px 12px 3px; text-transform: uppercase; letter-spacing: .07em; }
#toast {
  position: fixed; inset: auto; margin: 0; border: 0; left: 50%; top: 104px; transform: translateX(-50%); z-index: 60; max-width: min(88vw, 560px);
  display: flex; align-items: flex-start; gap: 10px;
  background: color-mix(in srgb, var(--ink) 92%, transparent); color: var(--on-ink); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: 10px 8px 10px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 500; box-shadow: var(--pop); line-height: 1.4;
}
#toast:not(:popover-open):not([hidden]) { display: none; }
#toast span { padding-top: 2px; }
#toast button { color: inherit; background: transparent; min-height: 24px; width: 24px; padding: 0; opacity: .7; flex: none; }
#toast button:hover { opacity: 1; background: transparent; }

/* ---- touch: 44 pt targets ---- */
@media (pointer: coarse) {
  :root { --tap: 44px; }
  .chip { min-height: 40px; }
  .tabs .tab { min-height: 44px; }
  .seg button { min-height: 40px; }
  .seg.small button { min-height: 36px; }
  .strip-head { min-height: 32px; }
}

/* ---- narrower windows ---- */
@media (max-width: 1240px) {
  .tabs .tab small { display: none; }
}
@media (max-width: 1100px) {
  #btn-map .tb-label, .navgroup > .lbl { display: none; }
  #side { width: 290px; }
  #topbar .link-seg button:not(.on) span:not(.ic) { display: none; }
}
@media (max-width: 1000px) {
  /* Portrait iPads and small windows: the inspector becomes a bottom sheet. The four preset tabs
     stay: they fit down to a phone, long names shortened. */
  #main { flex-direction: column; }
  #side { width: auto; border-left: 0; border-top: 1px solid var(--line); height: 36vh; flex: none; box-shadow: 0 -8px 24px rgba(0, 0, 0, .06); border-radius: 16px 16px 0 0; }
  .side-head { margin: 8px 12px 4px; }
  #sheet-toggle { display: inline-flex; }
  body.sheet-min #side { height: auto; }
  body.sheet-min .side-body { display: none; }
  .fader { min-height: 130px; }
  .bar-2 { flex-wrap: wrap; row-gap: 4px; }
  .title-input { max-width: none; }
}
@media (max-width: 900px) {
  /* Portrait iPads and phones: the top bar takes two lines, so every button keeps a full tap size
     and the name stays readable: the name with the link and the mixer, then the tools. */
  .bar-1 { flex-wrap: wrap; row-gap: 2px; }
  .bar-1 > * { flex: none; }
  .bar-1 > .spacer { order: 1; flex: 1 1 100%; height: 0; }
  .bar-1 > .title-input { flex: 1 1 60px; min-width: 0; margin: 0; }
  .bar-1 > .tb-group, .bar-1 > .tb { order: 2; }
  .bar-1 > .tb-group { margin-right: auto; }
}
@media (max-width: 600px) {
  /* Phones: the panel keeps a workable size and scrolls sideways. */
  #work { padding: 10px 12px; }
  #panel-wrap { overflow-x: auto; margin: 0 -12px; padding: 0 12px 4px; flex: none; scroll-padding: 0 12px; scrollbar-width: none; }
  #panel-wrap::-webkit-scrollbar { display: none; }
  .side-body { scrollbar-width: none; padding-left: 12px; padding-right: 12px; }
  .side-head { margin-left: 8px; margin-right: 8px; }
  .side-body::-webkit-scrollbar { display: none; }
  #panel { min-width: 760px; }
  .bar { padding: 4px 12px; gap: 2px; }
  .bar-2 { gap: 4px 8px; }
  .bar-2 > .spacer { display: none; }
  .page-bar { gap: 4px 8px; }
  .page-bar .lvl-page { flex: 1 1 100%; }
  #topbar .link-seg button span:not(.ic) { display: none; }
  .pill-act span { display: none; }
  #topbar .link-seg { margin-left: 2px; }
  #topbar .link-seg button { padding: 0 8px; }
  .mixer { margin-left: 2px; }
  .mixer .pill { padding: 4px 8px; }
  .pill .upd { padding: 1px 5px; }
  #topbar .tb-label, .pill .ptext { display: none; }
  #topbar .tb { padding: 0; width: var(--tap); }
  .title-input { flex: 1 1 60px; font-size: 15px; }
  .pill { padding: 4px 10px; }
  .tabs .tab { padding: 4px 8px; }
  .tabs .tab .tname { max-width: 90px; }
  #side { height: 45vh; }
  #monitor-bar .last, #monitor-bar .state { display: none; }
  #monitor-bar { gap: 6px; padding: 4px 12px; overflow-x: auto; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
  #dlg-body { --dlg-pad: 14px; padding: var(--dlg-pad) 16px 0; }
}
.offset-prev { max-height: 34vh; overflow: auto; margin: 10px 0 4px; border-radius: 8px; box-shadow: inset 0 0 0 1px var(--line); }
.offset-prev table.grid td { padding: 3px 8px; font-variant-numeric: tabular-nums; }
.offset-prev tr.err td { background: var(--danger-soft); }
.offset-prev .bad { color: var(--danger); }
.fwcard { border-radius: var(--radius); padding: 10px 12px; margin: 0 0 10px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.fwcard .row { display: flex; align-items: center; gap: 8px; }
.fwcard.warn { background: var(--shift-soft); }
.fwcard.warn .ic { color: var(--shift-text); }
.fwcard.bad { background: var(--danger-soft); }
.fwcard.bad .ic { color: var(--danger); }
.fwcard ul { margin: 6px 0; padding-left: 18px; }
.fwcard .actions { margin-top: 10px; }
.pill .upd { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; font-weight: 650; padding: 1px 7px 1px 5px; border-radius: 99px; background: var(--ink); color: var(--on-ink); font-variant-numeric: tabular-nums; }
.pill .upd .ic { color: inherit; }
.pill .psep { width: 1px; align-self: stretch; margin: 4px 2px; background: var(--line-strong); }
.fwsteps { display: grid; gap: 16px; margin-top: 14px; }
.fwsteps .step { display: grid; grid-template-columns: 26px 1fr; gap: 12px; align-items: start; position: relative; color: var(--muted); }
.fwsteps .step.now, .fwsteps .step.done { color: var(--text); }
.fwsteps .step:not(:last-child)::after { content: ""; position: absolute; left: 11px; top: 28px; bottom: -12px; width: 2px; border-radius: 1px; background: var(--line-strong); }
.fwsteps .step.done:not(:last-child)::after { background: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.step .num { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; background: var(--surface); color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.step.now .num { background: var(--ink); color: var(--on-ink); box-shadow: none; }
.step.done .num { background: var(--ok); color: #fff; box-shadow: none; }
.step .help { margin: 4px 0; }
.prog progress { width: 100%; height: 8px; accent-color: var(--ink); }
.plist li.pgroup { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 8px 2px; cursor: default; background: none; }

/* Mapping an instrument: a mode of its own */
body.mapping #btn-map, body.mapping #btn-map:hover:not(:disabled) { background: var(--ink); color: var(--on-ink); }
body.mapping #btn-map .ic { color: var(--on-ink); }
.plist li.pgroup { justify-content: space-between; }
.plist li.pgroup .chip { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 11.5px; min-height: 24px; padding: 2px 8px; }
.inst-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; border-radius: var(--radius); padding: 10px 12px 11px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); margin: 4px 0 10px; }
.inst-card small { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.inst-card .inst-change { grid-row: 1 / 3; grid-column: 2; min-height: 28px; padding: 2px 12px; font-size: 13px; }
.inst-card b { font-size: 15px; font-weight: 650; grid-column: 1; }
.inst-card p { grid-column: 1 / 3; margin: 4px 0 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.inst-card .inst-src a { color: inherit; white-space: nowrap; }
.inst-card .inst-src a .ic { margin-left: 2px; vertical-align: -1px; }
#panel .ctl.target { outline: 2px dashed var(--ink); outline-offset: 2px; }
.inst-dlg { width: min(520px, 100%); }
.inst-dlg input[type=search] { width: 100%; margin: 4px 0 8px; }
.inst-list { display: flex; flex-direction: column; gap: 2px; max-height: min(52vh, 460px); overflow: auto; }
.inst-list > * { flex: none; }
.inst-list h3 { margin: 12px 0 2px; }
.inst-list .help { margin: 0 0 4px; }
.inst-list .maker { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px 2px; }
button.inst { flex: none; display: flex; align-items: center; gap: 10px; text-align: left; background: none; padding: 8px 10px; border-radius: 9px; min-height: 0; width: 100%; }
button.inst:hover { background: var(--fill); }
button.inst .grow { flex: 1; display: flex; flex-direction: column; min-width: 0; }
button.inst small { color: var(--muted); font-size: 12px; font-weight: 400; }
.inst-status:empty { display: none; }
.inst-status .loading { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; background: var(--fill); font-size: 13px; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ink); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 6px; }
.compare > div { padding: 2px 12px 2px 14px; background: transparent; box-shadow: inset 3px 0 0 var(--line-strong); }
.compare b { font-size: 13px; }
.compare p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
@media (max-width: 600px) { .compare { grid-template-columns: 1fr; } }
button.inst > .ic { transform: rotate(-90deg); color: var(--faint); }

/* ---- the levels: the presets are folder tabs; the work area under the open one is its page block
   (pages, layers, the selection and the view) ---- */
#topbar { border-bottom-color: var(--line-strong); }
.bar-2 { padding-bottom: 0; align-items: flex-end; min-height: 44px; }
.lvl-preset { align-items: flex-end; }
.lvl-preset > .lbl { padding-bottom: 11px; }
#presets { overflow: visible; align-items: flex-end; gap: 4px; }
#presets .tab { border-radius: 10px 10px 0 0; min-height: 36px; padding: 4px 14px; background: var(--fill); color: var(--muted); }
#presets .tab:hover:not(:disabled) { background: var(--fill-2); color: var(--text); }
#presets .tab.on, #presets .tab.on:hover:not(:disabled) {
  background: var(--bg); color: var(--text); margin-bottom: -1px; padding-bottom: 5px; z-index: 1;
  box-shadow: inset 1px 0 var(--line-strong), inset -1px 0 var(--line-strong), inset 0 2px var(--ink);
}
@media (max-width: 600px) { #presets { gap: 2px; } #presets .tab { padding: 4px 9px; } #presets .tab .tname { max-width: 64px; } }
.page-bar { display: flex; align-items: center; gap: 6px 20px; flex-wrap: wrap; padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.page-bar #pages .tab { border-radius: 8px 8px 0 0; background: transparent; }
.page-bar #pages .tab:hover:not(:disabled) { background: var(--fill); }
.page-bar #pages .tab.on { background: transparent; box-shadow: inset 0 -2px var(--ink); }
#selbar .view-bar { display: flex; gap: 6px; flex: none; margin-left: auto; }
.list-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 8px 10px 4px; }
.list-tools .lbl { font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; }

/* ---- saving (A-12) ---- */
.mixer { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 99px; background: var(--fill); margin-left: 6px; flex: none; }
.mixer .pill { background: transparent; margin-left: 0; min-height: 32px; }
.mixer .pill:hover:not(:disabled) { background: var(--fill); }
.pill-act { border-radius: 99px; padding: 2px 12px; min-height: 30px; background: var(--ink); color: var(--on-ink); font-weight: 600; }
.pill-act .ic { color: inherit; }
.pill-bt { background: var(--fill); color: var(--ink); margin-left: 4px; }
.pill-bt:hover:not(:disabled) { background: color-mix(in srgb, var(--fill) 80%, var(--ink)); }
.pill-act:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); }
.copies { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 10px; }
.copies > div { border-radius: var(--radius); padding: 10px 12px; background: var(--fill); display: flex; flex-direction: column; gap: 2px; justify-content: flex-start; }
.copies small { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.copies b { font-size: 14px; }
.copies p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.choices { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 16px; }
button.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; white-space: normal; padding: 10px 14px; }
button.choice small { font-weight: 400; font-size: 12.5px; opacity: .8; }
@media (max-width: 600px) { .copies { grid-template-columns: 1fr; } }

/* ---- links: the text's colour with a quiet underline, never the browser's blue ---- */
a, button.link { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover, button.link:hover:not(:disabled) { text-decoration-color: currentColor; }
button.link { background: none; padding: 0; min-height: 0; font: inherit; font-weight: 500; border-radius: 0; }
button.link:hover:not(:disabled) { background: none; }
.help.row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.chev { display: inline-flex; transition: transform .15s; }
.chev.up { transform: rotate(180deg); }
.notice { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px; border-radius: var(--radius); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font-size: 13px; }
.notice.warn { background: var(--shift-soft); box-shadow: none; }
.notice .ghost { background: transparent; color: var(--muted); min-height: 28px; }
.notice .ic { flex: none; color: var(--muted); }
.notice span { flex: 1; min-width: 0; }
.notice button { flex: none; min-height: 30px; background: var(--surface); }
.notice[hidden] { display: none; }
/* the firmware sheets: titles on the step numbers' line, lists in line with the text, room below */
.fwsteps { margin-bottom: 4px; }
.fwsteps .step > div > b { display: block; line-height: 24px; }
.fwsteps ul { margin: 4px 0 8px; padding-left: 18px; }
.fwsteps ul li + li { margin-top: 2px; }
.fwsteps .actions { margin-top: 10px; }
.fwsteps .note { margin: 8px 0; }
