:root {
  --page: #6f7072;          /* round the panel: a neutral mid grey */
  --bg: #0b0d11;            /* insets inside the panel */
  --body: #15181e;          /* the panel's face */
  --panel-2: #1f232c;       /* buttons */
  --pad: #22262f;
  --line: #2a2f3a;
  --text: #e6e8ec;
  --muted: #7d8594;
  --accent: #f2b33d;
  --rec: #ff5f5f;
  --go: #4fd16b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body.kb-open { --kb-h: 162px; }               /* the playing panel's height + gap (see .app) */
[hidden] { display: none !important; }

html, body { min-height: 100%; margin: 0; }
html { height: 100%; }

/* The looper sits in the middle of the window, both ways (scrolling if the window is too small). */
body {
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--text);
  font: 14px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
  user-select: none;
}

/* The panel's pads are square, so its height follows its width. The width is capped so the
   whole page fits the window's height (but no narrower than 980px, where button labels
   start to be cut; shorter windows scroll): 400px is everything that isn't one of the five square
   rows (track buttons + 4 pad rows), 332px + 32px the panel's fixed widths and the page padding. */
.app {
  container-type: inline-size;
  min-width: 820px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  width: 100%;
  max-width: min(1180px, max(980px, calc((100vh - 400px - var(--kb-h, 0px)) * 1.6 + 364px)));
  margin: auto;
}

/* ---- transport, in the sequencer's header: status, bar.beat, beat dots ---- */

.status { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
body[data-rec="armed"] .status,
body[data-rec="recording"] .status,
body[data-rec="closing"] .status { color: var(--rec); }
body[data-rec="overdub"] .status { color: var(--accent); }
.pos { font: 600 14px ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.beats { display: flex; gap: 5px; }
.beats i { width: 8px; height: 8px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); }
.beats i.on { background: var(--text); }
.beats i.on:first-child { background: var(--accent); }

body:not(.ready) .app { visibility: hidden; }     /* until main.js has built the panel: no layout shift */
/* Floats over the page (bottom centre), so showing and hiding it moves nothing. */
.sound-gate {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 25;
  max-width: calc(100% - 32px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  padding: 10px 14px;
  border: 1px solid #6b5420;
  border-radius: 10px;
  background: #332a14;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

/* ---- the panel, laid out like the Circuit ----
   Columns: 1 = left of the tracks, 2-9 = the eight track columns, 10 = right of them.
   Rows: 1 logo, 2 knobs, 3 the row above the tracks, 4 track buttons, 5-8 the pad rows. On the
   Looper page: 5 mute and solo as two half-height strips, 6-8 the sequencer. The Presets and
   Kits pages fill rows 5-8. Buttons outside the 8 columns are placed by main.js.
   Rows 4-8 are square: as tall as a track column is wide (the panel's width less its padding,
   border, two side columns and nine gaps, over 8). */

.device {
  --sq: calc((100cqw - 332px) / 8);
  display: grid;
  grid-template-columns: 104px repeat(8, minmax(0, 1fr)) 104px;
  grid-template-rows: auto auto auto repeat(5, var(--sq));
  gap: 10px;
  padding: 16px;
  background: var(--body);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.knob-cell { grid-row: 2; display: flex; justify-content: center; }
.master-vol { grid-column: 1; }
.master-int { grid-column: 10; }
.knobs, .row8 { grid-column: 2 / 10; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; }
.knobs { grid-row: 2; }
.aux { grid-row: 3; }
.tracks { grid-row: 4; }
.mute-row, .solo-row { grid-row: 5; height: calc((var(--sq) - 6px) / 2); }
.mute-row { align-self: start; }
.solo-row { align-self: end; }
.seq { grid-row: 6 / 9; grid-column: 2 / 10; }
.page { grid-row: 5 / 9; grid-column: 2 / 10; min-height: 0; overflow: auto; }

/* ---- pages other than the Looper ---- */

/* Note's picture: a keyboard on synth tracks, kit pads on drum tracks (none on audio tracks). */
/* Pictures for instrument types: a keyboard (melodic instruments), kit pads (kits), a waveform
   (audio). Used on Note (the selected track's type), Instrument, Kits and the track buttons. */
:root {
  --icon-keys: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 14'%3E%3Crect x='0.75' y='0.75' width='26.5' height='12.5' rx='1.5' fill='none' stroke='black' stroke-width='1.5'/%3E%3Cpath d='M4.75 8v5M8.75 8v5M12.75 1v12M16.75 8v5M20.75 8v5M24.75 8v5' stroke='black' stroke-width='1'/%3E%3Crect x='3.45' y='1' width='2.6' height='7.5' rx='0.4'/%3E%3Crect x='7.45' y='1' width='2.6' height='7.5' rx='0.4'/%3E%3Crect x='15.45' y='1' width='2.6' height='7.5' rx='0.4'/%3E%3Crect x='19.45' y='1' width='2.6' height='7.5' rx='0.4'/%3E%3Crect x='23.45' y='1' width='2.6' height='7.5' rx='0.4'/%3E%3C/svg%3E");
  --icon-pads: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 14'%3E%3Crect x='0.25' y='0.25' width='6' height='6' rx='1.3'/%3E%3Crect x='7.50' y='0.25' width='6' height='6' rx='1.3'/%3E%3Crect x='14.75' y='0.25' width='6' height='6' rx='1.3'/%3E%3Crect x='22.00' y='0.25' width='6' height='6' rx='1.3'/%3E%3Crect x='0.25' y='7.50' width='6' height='6' rx='1.3'/%3E%3Crect x='7.50' y='7.50' width='6' height='6' rx='1.3'/%3E%3Crect x='14.75' y='7.50' width='6' height='6' rx='1.3'/%3E%3Crect x='22.00' y='7.50' width='6' height='6' rx='1.3'/%3E%3C/svg%3E");
  --icon-midi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 14'%3E%3Ccircle cx='14' cy='7' r='6.2' fill='none' stroke='black' stroke-width='1.4'/%3E%3Crect x='12.7' y='0.3' width='2.6' height='2.6' fill='black'/%3E%3Ccircle cx='10.40' cy='7.00' r='1'/%3E%3Ccircle cx='11.45' cy='9.55' r='1'/%3E%3Ccircle cx='14.00' cy='10.60' r='1'/%3E%3Ccircle cx='16.55' cy='9.55' r='1'/%3E%3Ccircle cx='17.60' cy='7.00' r='1'/%3E%3C/svg%3E");
  --icon-synth: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 14'%3E%3Cpath d='M1 12L7 2V12L13 2V12H15.5V2H21V12H26.5V2' fill='none' stroke='black' stroke-width='1.6' stroke-linejoin='round' stroke-linecap='round'/%3E%3C/svg%3E");
  --icon-cog: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath fill-rule='evenodd' d='M11.76 5.45L13.45 5.59L13.45 8.41L11.76 8.55L11.46 9.27L12.56 10.56L10.56 12.56L9.27 11.46L8.55 11.76L8.41 13.45L5.59 13.45L5.45 11.76L4.73 11.46L3.44 12.56L1.44 10.56L2.54 9.27L2.24 8.55L0.55 8.41L0.55 5.59L2.24 5.45L2.54 4.73L1.44 3.44L3.44 1.44L4.73 2.54L5.45 2.24L5.59 0.55L8.41 0.55L8.55 2.24L9.27 2.54L10.56 1.44L12.56 3.44L11.46 4.73ZM9.2 7A2.2 2.2 0 1 0 4.8 7A2.2 2.2 0 1 0 9.2 7Z'/%3E%3C/svg%3E");
  --icon-wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 14'%3E%3Cpath d='M1 7h3l2-5 3 10 3-12 3 12 3-9 2 6 2-3h5' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.pbtn.note::after, .pbtn.preset::after, .pbtn.kits::after, .pbtn.audio::after, .pbtn.midi::after, .pbtn.synth::after, .pbtn.settings::after, .ticon {
  content: "";
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.pbtn.note::after, .pbtn.preset::after, .pbtn.kits::after { width: 28px; height: 14px; margin-top: 4px; }
.pbtn.note::after, .pbtn.preset::after { --icon: var(--icon-keys); }
.pbtn.kits::after, body[data-inst="drums"] .pbtn.note::after { --icon: var(--icon-pads); }
.pbtn.audio::after { width: 28px; height: 14px; margin-top: 4px; --icon: var(--icon-wave); }
.pbtn.midi::after { width: 28px; height: 14px; margin-top: 4px; --icon: var(--icon-midi); }
.pbtn.synth::after { width: 28px; height: 14px; margin-top: 4px; --icon: var(--icon-synth); }
.tbtn[data-type="synth"] .ticon { --icon: var(--icon-synth); }
/* Settings: just a cog */
.pbtn.settings { justify-content: center; }
.pbtn.settings .plabel { display: none; }
.pbtn.settings::after { width: 26px; height: 26px; --icon: var(--icon-cog); }
/* Jam: track "0", right of the track buttons, in dark grey; a pair of quavers */
.tbtn.jam { --c: #5d6574; background: #181b21; border-color: var(--line); }
.tbtn.jam .tnum { color: #7d8594; }
.tbtn.jam .tname { color: var(--muted); }
.tbtn.jam.on { --c: #c9ced8; background: #2a2e36; border-color: #c9ced8; box-shadow: 0 0 0 1px #c9ced8; }
.tbtn.jam.on .tnum, .tbtn.jam.on .tname { color: var(--text); }
.tbtn.jam .ticon {
  width: 10px; height: 10px;
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cellipse cx='4' cy='14.2' rx='3.1' ry='2.4' transform='rotate(-20 4 14.2)'/%3E%3Cellipse cx='14' cy='12.2' rx='3.1' ry='2.4' transform='rotate(-20 14 12.2)'/%3E%3Cpath d='M6.3 13.6V3.6L16.3 1.6V11.6' fill='none' stroke='black' stroke-width='1.6'/%3E%3Cpath d='M6.3 3.6L16.3 1.6V4.6L6.3 6.6Z'/%3E%3C/svg%3E");
}
body.jam .seq-head .inst, body.jam .seq-oct, body.jam .seq-len { visibility: hidden; }   /* no track to set */
.tbtn[data-type="midi"] .ticon { --icon: var(--icon-midi); }
body[data-inst="audio"] .pbtn.note::after { display: none; }

/* the button whose page is open */
.pbtn.page-on { border-color: var(--text); background: #2c313c; }
/* Pages: square cards on the top two pad rows (like the Circuit's pads), notes and "＋ New"
   below; editors fill the whole pad area in a panel of their own. */
.page { display: flex; flex-direction: column; gap: 10px; }
.cards { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(2, var(--sq)); gap: 10px; }
.card {
  --c: var(--text);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  padding: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--pad);
  color: var(--muted);
  cursor: pointer;
}
.card:hover { border-color: #464d5c; }
.card .card-num { position: absolute; top: 6px; left: 8px; font: 10px ui-monospace, Menlo, monospace; color: #4d5462; }
.card .card-dot { position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: #343a46; }
.card .card-name { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .card-use { font: 10px ui-monospace, Menlo, monospace; color: #5d6574; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.2em; }
.card.on { background: color-mix(in srgb, var(--c) 16%, var(--panel-2)); border-color: color-mix(in srgb, var(--c) 45%, var(--line)); }
.card.on .card-dot { background: var(--c); box-shadow: 0 0 6px var(--c); }
.card.on .card-name { color: var(--text); }
.card.current { box-shadow: 0 0 0 2px var(--text); }
.card .card-edit {
  position: absolute; top: 4px; right: 22px; width: 20px; height: 20px; padding: 0;
  border: none; border-radius: 5px; background: none; color: #5d6574; font-size: 12px; cursor: pointer; display: none;
}
.card:hover .card-edit { display: block; }
.card .card-edit:hover { color: var(--text); background: #00000044; }
.cards-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.cards-note { color: var(--muted); }
.page .kit-edit { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; height: 100%; }
.page-head h2 { margin: 0 0 4px; font-size: 16px; }
.page-head p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.preset-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.preset-card {
  --c: var(--text);
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.preset-card:hover { border-color: #464d5c; }
.preset-card .swatch { grid-row: 1 / 3; width: 12px; height: 32px; border-radius: 4px; background: var(--c); }
.preset-card .pc-name { font-weight: 600; }
.preset-card .pc-use { grid-column: 2; font: 11px ui-monospace, Menlo, monospace; color: var(--muted); }
.preset-card .pc-switch { grid-row: 1 / 3; grid-column: 3; width: 34px; height: 20px; border-radius: 10px; background: #343a46; position: relative; transition: background 120ms; }
.preset-card .pc-switch i { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #8a919e; transition: transform 120ms, background 120ms; }
.preset-card.on .pc-switch { background: color-mix(in srgb, var(--c) 55%, #343a46); }
.preset-card.on .pc-switch i { transform: translateX(14px); background: #fff; }
.preset-card:not(.on) .pc-name, .preset-card:not(.on) .swatch { opacity: 0.45; }
.preset-card.current { border-color: var(--c); box-shadow: 0 0 0 1px var(--c); }

/* ---- logo: bold ZERKIT, thin LOOPER, and a badge on the right ---- */

.brand { grid-row: 1; grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 2px 6px 4px; }
.brand-right { display: flex; align-items: center; justify-content: flex-end; min-width: 0; }

/* The tempo readout: an old calculator's orange seven-segment digits behind dark glass */
.lcd {
  display: flex; align-items: flex-end; gap: 7px;
  padding: 5px 9px 5px 11px;
  background: linear-gradient(#0b0705, #160d07);
  border: 1px solid #000;
  border-radius: 5px;
  box-shadow: inset 0 2px 6px #000c, 0 1px 0 #ffffff14;
}
.lcd-digits { display: flex; gap: 5px; }
.lcd-digits svg { width: 19px; height: 33px; transform: skewX(-7deg); overflow: visible; }
.lcd-digits polygon { fill: #ff8a1e14; }
.lcd-digits polygon.on { fill: #ff9a2e; filter: drop-shadow(0 0 2.5px #ff7a10b0); }
.lcd-unit { font: 700 9px/1 ui-monospace, Menlo, monospace; letter-spacing: 0.1em; color: #ff9a2e; opacity: 0.75; width: 32px; padding-bottom: 1px; }
.lcd.swing .lcd-unit { color: #ffb45e; }
.wordmark { font: 30px/1 "Helvetica Neue", "SF Pro Display", system-ui, sans-serif; letter-spacing: 0.01em; color: #eef0f3; }
.wordmark b { font-weight: 800; }
.wordmark span { font-weight: 200; margin-left: 10px; }
.brand-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.gh { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: #5d6470; transition: color .15s; }
.gh:hover, .gh:focus-visible { color: #eef0f3; }
.gh svg { width: 18px; height: 18px; fill: currentColor; }
.badge { width: 38px; height: 38px; border-radius: 6px; background: #e8eaee; display: grid; place-items: center; }
.badge svg { width: 30px; height: 15px; overflow: visible; }
.badge path { fill: none; stroke: var(--body); stroke-width: 9; stroke-linejoin: round; }
/* Circuit connected: the badge breathes a soft green glow */
.badge.on { animation: badge-glow 2.8s ease-in-out infinite; }
@keyframes badge-glow {
  0%, 100% { box-shadow: 0 0 0 1px #5fc47a55, 0 0 6px 0 #5fc47a33; }
  50%      { box-shadow: 0 0 0 1px #5fc47aaa, 0 0 14px 2px #5fc47a66; }
}
@media (prefers-reduced-motion: reduce) { .badge.on { animation: none; box-shadow: 0 0 0 1px #5fc47aaa, 0 0 10px 1px #5fc47a55; } }

/* ---- knobs ---- */

.knob { --c: var(--text); --v: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dial {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  cursor: ns-resize;
  touch-action: none;
  /* a 270° track with the value filled in, starting bottom-left */
  background:
    radial-gradient(circle, #2b303a 0 54%, transparent 55%),
    conic-gradient(from 225deg, var(--c) 0 calc(var(--v) * 270deg), #343a46 0 270deg, transparent 0);
}
.dial i {
  position: absolute;
  left: 50%;
  top: 7px;
  width: 3px;
  height: 14px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--text);
  transform-origin: 50% 19px;
  transform: rotate(calc(-135deg + var(--v) * 270deg));
}
/* Left-right position under each track knob: a strip with a centre mark, filled from the
   centre to the position. Brighter while Shift is down (Shift + knob moves it). */
.pan { --p: 0; position: relative; width: 46px; height: 6px; margin-top: 2px; border-radius: 3px; background: #2b303a; }
.pan::before { content: ""; position: absolute; left: 50%; top: -2px; width: 1px; height: 10px; background: #4d5462; }
.pan i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% + min(0, var(--p)) * 50%);
  width: calc(max(var(--p), -1 * var(--p)) * 50%);
  background: color-mix(in srgb, var(--c) 65%, transparent);
  border-radius: 3px;
}
.pan b { position: absolute; top: -2px; left: calc(50% + var(--p) * 50% - 2px); width: 4px; height: 10px; border-radius: 2px; background: var(--text); }
body.shift .pan { background: #3a4150; box-shadow: 0 0 0 1px #c9ced855; }

.master-vol .dial, .master-int .dial { width: 60px; height: 60px; }
.master-vol .dial i, .master-int .dial i { top: 8px; transform-origin: 50% 22px; }
.klabel { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); text-align: center; line-height: 1.2; }

/* ---- panel buttons (aux row and side columns) ---- */

.pbtn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  min-width: 0;
  min-height: 40px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.pbtn:hover:not(.idle):not(:disabled) { border-color: #464d5c; }
/* A button's actions, top to bottom: Shift (small grey), hold (small blue), tap (the main
   label), then a readout. While Shift is down, buttons with a Shift action light up; while a
   button is held on the Circuit, its hold action lights up. */
.pbtn .pfn { font-size: 9px; color: #7d8594; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pbtn .phold { font-size: 9px; color: #4aa8c4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pbtn .pfn:empty, .pbtn .phold:empty { display: none; }
/* Icons before the Shift and hold actions (and on the Shift button): drawn in the text colour. */
.pbtn .pfn, .pbtn .phold { display: inline-flex; align-items: center; gap: 3px; }
.pbtn .pfn:empty, .pbtn .phold:empty { display: none; }
.pbtn .pfn::before, .pbtn .phold::before, .pbtn.shift .plabel::before {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.pbtn .pfn::before, .pbtn.shift .plabel::before {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.5 1.5 8.5H5v5.5h6V8.5h3.5Z' fill='none' stroke='black' stroke-width='1.7' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.pbtn .pfn .ihold { flex: none; width: 9px; height: 9px; margin-left: -1px; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.pbtn .phold::before, .pbtn .pfn .ihold {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='6.2' fill='none' stroke='black' stroke-width='1.7'/%3E%3Cpath d='M8 4.3V8l2.6 1.7' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.pbtn.shift .plabel { display: inline-flex; align-items: center; gap: 5px; }
.pbtn.shift .plabel::before { width: 12px; height: 12px; }
body.shift .pbtn.has-shift { border-color: #c9ced8; box-shadow: 0 0 0 1px #c9ced855; }
body.shift .pbtn.has-shift .pfn { color: #ffffff; font-weight: 600; }
body.shift .pbtn.has-shift .plabel, body.shift .pbtn.has-shift .phold { opacity: 0.4; }
.pbtn.holding { border-color: #4aa8c4; box-shadow: 0 0 0 1px #4aa8c455, 0 0 12px #4aa8c433; }
.pbtn.holding .phold { color: #7fd3ee; font-weight: 600; }
.pbtn.holding .plabel, .pbtn.holding .pfn { opacity: 0.4; }
.pbtn .plabel { font-size: 11px; letter-spacing: 0.02em; text-align: center; line-height: 1.2; max-width: 100%; }
.pbtn .pval { font: 600 12px ui-monospace, Menlo, monospace; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pbtn .pval:empty { display: none; }
.pbtn.idle { color: #4d5462; cursor: default; background: #1a1d24; }
.pbtn.preset, .pbtn.patterns { aspect-ratio: auto; }
.pbtn:disabled { opacity: 0.35; cursor: default; }
.pbtn.on { border-color: #6a7280; }

.pbtn.preset .pval { color: var(--c); }
.pbtn.play.on { background: #1d3320; border-color: #3f6b3b; }
.pbtn.play.on .pval { color: var(--go); }
.pbtn.record .pval:empty { display: none; }
.pbtn.record::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #3a2323; }
.pbtn.record.has-loop::after { background: #5d6574; }
.pbtn.record[data-state="armed"]::after { background: var(--rec); animation: blink 0.6s steps(1) infinite; }
.pbtn.record[data-state="recording"],
.pbtn.record[data-state="closing"] { background: #3a1a1d; border-color: var(--rec); }
.pbtn.record[data-state="recording"]::after { background: var(--rec); }
.pbtn.record[data-state="closing"]::after { background: var(--rec); animation: blink 0.25s steps(1) infinite; }
.pbtn.record[data-state="overdub"] { background: #332a14; border-color: var(--accent); }
.pbtn.record[data-state="overdub"]::after { background: var(--accent); }
@keyframes blink { 50% { opacity: 0.15; } }

.pbtn.tempo.on { border-color: #6b5420; }
.pbtn.tempo.beat { background: #332a14; }
.pbtn.quant .plabel { font: 600 18px ui-monospace, Menlo, monospace; }
.pbtn.undo.on { border-color: #4d5462; }
.pbtn.shift.on { background: #2c313c; border-color: #c9ced8; }

/* ---- track buttons: square, in the track's colour ---- */

.tbtn {
  --c: var(--text);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  padding: 8px;
  min-width: 0;
  text-align: left;
  background: color-mix(in srgb, var(--c) 10%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--c) 35%, var(--line));
  border-radius: 9px;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.tbtn .tnum { position: absolute; top: 6px; left: 9px; font: 600 18px ui-monospace, Menlo, monospace; color: var(--c); }
.tbtn .tdot { position: absolute; top: 10px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: #2a2f39; }
.tbtn .tdot.on { background: var(--c); box-shadow: 0 0 6px var(--c); }
.tbtn .tfx { position: absolute; top: 6px; right: 22px; padding: 1px 4px; border-radius: 4px; font: 700 9px system-ui, sans-serif; letter-spacing: 0.06em; color: #10141a; background: #a58af5; }
.tbtn .tinst { display: flex; align-items: center; gap: 5px; min-width: 0; }
.tbtn .tname { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbtn .ticon { flex: none; display: block; width: 16px; height: 8px; color: var(--c); opacity: 0.9; --icon: var(--icon-keys); }
.tbtn[data-type="kit"] .ticon { --icon: var(--icon-pads); }
.tbtn[data-type="audio"] .ticon { --icon: var(--icon-wave); }
.tbtn .tlen { font: 11px ui-monospace, Menlo, monospace; }
.tbtn .tmini { position: absolute; left: 9px; top: 32px; width: calc(100% - 18px); height: calc(100% - 32px - 46px); pointer-events: none; }
/* record quantise, bottom-right: the Circuit's colours (red off, amber 32nds, green 16ths) */
.tbtn .tq { position: absolute; right: 7px; bottom: 7px; font: 600 10px ui-monospace, Menlo, monospace; }
.tbtn .tq[data-q="off"] { color: #5d6574; }
.tbtn .tq[data-q="mid"] { color: var(--accent); }
.tbtn .tq[data-q="strong"] { color: var(--go); }
.tbtn.empty .tname { color: var(--muted); }
.tbtn.selected { background: color-mix(in srgb, var(--c) 32%, var(--panel-2)); border-color: var(--c); box-shadow: 0 0 0 1px var(--c); }
.tbtn.rec { outline: 2px solid var(--rec); outline-offset: 2px; }
.tbtn.silent .tnum, .tbtn.silent .tname { opacity: 0.4; }

/* ---- pads: mute row and solo row ---- */

.pads { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; }
.pad {
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--pad);
  color: #4d5462;
  font: 600 13px ui-monospace, Menlo, monospace;
  cursor: pointer;
}
.pad:hover { border-color: #464d5c; }
/* mute: a crossed-out speaker; solo: headphones. In the text colour (dim off, dark when lit). */
.pad { display: grid; place-items: center; color: #636b7a; }
.pad.mute::before, .pad.solo::before {
  content: "";
  width: 21px;
  height: 21px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.pad.mute::before { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9h4l5-4v14l-5-4H4z' fill='black'/%3E%3Cpath d='M17 9l5 6M22 9l-5 6'/%3E%3C/svg%3E"); }
.pad.solo::before { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 15v-3a8 8 0 0 1 16 0v3'/%3E%3Crect x='3' y='14' width='4.5' height='7' rx='1.5' fill='black'/%3E%3Crect x='16.5' y='14' width='4.5' height='7' rx='1.5' fill='black'/%3E%3C/svg%3E"); }
.pad.mute.on { background: var(--rec); border-color: var(--rec); color: #1a0606; box-shadow: 0 0 10px #ff5f5f55; }
.pad.solo.on { background: var(--go); border-color: var(--go); color: #06180b; box-shadow: 0 0 10px #4fd16b55; }

/* ---- the selected track's sequencer (bottom half of the pad area) ---- */

.seq {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: inset 0 3px 0 var(--lane-color);
}
.seq-head { display: flex; align-items: center; gap: 12px; padding: 9px 12px 7px; border-bottom: 1px solid var(--line); }
.seq-title { font-weight: 600; }
.seq-oct { font: 12px ui-monospace, Menlo, monospace; color: var(--muted); }
.seq-len { margin-left: auto; font: 12px ui-monospace, Menlo, monospace; color: var(--muted); }
.inst {
  width: auto;
  min-width: 120px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--lane-color);
  font: 12px system-ui, sans-serif;
  cursor: pointer;
}
.inst option { color: var(--text); background: var(--panel-2); }
.roll-wrap { position: relative; min-height: 0; }
.roll { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

/* ---- playing panel under the looper (Note): keyboard or kit ----
   Same columns as the panel above, so the kit's 8 columns sit under the 8 tracks. */

.keys-area {
  display: none;
  grid-template-columns: 104px repeat(8, minmax(0, 1fr)) 104px;
  gap: 10px;
  height: 150px;
  padding: 12px 17px;
  background: var(--body);
  border: 1px solid var(--line);
  border-radius: 14px;
}
body.kb-open .keys-area { display: grid; }
.kb-side { grid-column: 1; display: flex; flex-direction: column; justify-content: center; gap: 3px; font-size: 12px; color: var(--muted); }
.kb-side b { color: var(--text); font-size: 13px; }
.kb-side span:first-of-type { color: var(--kb-color); }
.kb-main { grid-column: 2 / 10; min-width: 0; display: flex; }
.kb-main > * { flex: 1; }
.kb-audio { display: grid; place-items: center; color: var(--muted); font-size: 13px; }

.keyboard { position: relative; display: flex; min-width: 0; }
.key {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  padding-bottom: 8px;
  cursor: pointer;
  transition: background 60ms;
}
.key .letter { font: 600 13px ui-monospace, Menlo, monospace; }
.key .name { font-size: 10px; color: #8a8f99; white-space: nowrap; }
.key.black .name { display: none; }
.key.white {
  flex: 1;
  background: #eceef2;
  color: #2a2e36;
  border: 1px solid #0b0d11;
  border-radius: 0 0 6px 6px;
}
.key.black {
  position: absolute;
  top: 0;
  width: 4.4%;
  height: 60%;
  background: #1d2129;
  color: #9aa1ad;
  border: 1px solid #000;
  border-radius: 0 0 4px 4px;
  z-index: 1;
}
.key.white.loop { background: color-mix(in srgb, var(--kb-color) 45%, #eceef2); }
.key.black.loop { background: color-mix(in srgb, var(--kb-color) 55%, #1d2129); color: #fff; }
.key.down { background: var(--kb-color); color: #1d2129; }

.kit { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: 1fr 1fr; gap: 10px; }
.kpad {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--kb-color) 35%, var(--line));
  border-radius: 7px;
  background: color-mix(in srgb, var(--kb-color) 12%, var(--pad));
  cursor: pointer;
  touch-action: none;
}
.kpad .kname { font-size: 12px; color: var(--text); }
.kpad .knum { position: absolute; top: 4px; left: 6px; font: 10px ui-monospace, Menlo, monospace; color: var(--muted); }
.kpad.loop { background: color-mix(in srgb, var(--kb-color) 35%, var(--pad)); }
.kpad.down { background: var(--kb-color); }
.kpad.down .kname, .kpad.down .knum { color: #10141a; }

/* ---- projects: name in the logo row, screens, saved notice ---- */

.project { flex: 1; min-width: 0; margin: 0 14px; text-align: right; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project.dirty::after { content: " •"; color: var(--accent); }
.pbtn.save.on { border-color: #6a7280; }

.dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: start center;
  padding: max(12vh, 60px) 16px 16px;
  background: rgba(6, 8, 11, 0.62);
  backdrop-filter: blur(3px);
  animation: dlg-fade 120ms ease-out;
}
.dlg {
  width: min(460px, 100%);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 20px 16px;
  background: var(--body);
  border: 1px solid #343a46;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: dlg-rise 140ms ease-out;
}
@keyframes dlg-fade { from { opacity: 0; } }
@keyframes dlg-rise { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.dlg h3 { margin: 0; font-size: 15px; letter-spacing: 0.02em; }
.dlg-name {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #3a4150;
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font: 600 18px system-ui, sans-serif;
  outline: none;
}
.dlg-name:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #f2b33d22; }
.dlg-note { margin: 0; font-size: 12px; color: var(--muted); }
.dlg-note .warn, .dlg-note.warn { color: var(--accent); }
.dlg-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dlg-hint { margin-right: auto; font-size: 11px; color: #5d6574; }
.dlg-btn {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: 600 13px system-ui, sans-serif;
  cursor: pointer;
}
.dlg-btn:hover { border-color: #464d5c; }
.dlg-btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1406; }
.dlg-btn.primary:hover { filter: brightness(1.08); }

.dlg-list { display: flex; flex-direction: column; gap: 4px; overflow: auto; margin: 0 -6px; padding: 0 6px; }
.dlg-list > .dlg-btn { align-self: flex-start; }
.dlg-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 5px 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.dlg-item.sel { background: var(--panel-2); border-color: #3a4150; }
.dlg-item.current .di-when { color: var(--accent); }
.di-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.di-when { font-size: 12px; color: var(--muted); text-align: right; }
.di-tracks { display: flex; gap: 4px; align-items: center; }
.di-tracks i { width: 14px; height: 6px; border-radius: 2px; background: color-mix(in srgb, var(--c) 18%, #2b303a); }
.di-tracks i.on { background: var(--c); }
.di-tempo { font: 11px ui-monospace, Menlo, monospace; color: var(--muted); text-align: right; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 30;
  padding: 9px 16px 9px 14px;
  border-radius: 10px;
  background: #1f2a22;
  border: 1px solid #3f6b3b;
  color: #bff0c8;
  font: 600 13px system-ui, sans-serif;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.ok::before { content: "✓  "; color: var(--go); }
.toast.warn { background: #332a14; border-color: #6b5420; color: var(--accent); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.gated .toast { bottom: 72px; }                  /* above the sound notice */

/* ---- Kits page: kit cards and the kit editor ---- */

.kit-list .kit-card { cursor: pointer; }
.kit-card .pc-switch { border: none; padding: 0; cursor: pointer; }
.kit-card.on .pc-switch { background: color-mix(in srgb, var(--c) 55%, #343a46); }
.kit-card.on .pc-switch i { transform: translateX(14px); background: #fff; }
.kit-card:not(.on) .pc-name, .kit-card:not(.on) .swatch { opacity: 0.45; }
.kit-new { grid-template-columns: auto 1fr; border-style: dashed; color: var(--muted); }
.kit-new .kn-plus { grid-row: 1 / 3; font-size: 22px; line-height: 1; color: var(--accent); width: 12px; text-align: center; }
.kit-new:hover .pc-name { color: var(--text); }
.kit-empty { display: grid; justify-items: start; gap: 12px; color: var(--muted); font-size: 13px; }
.kit-empty p { margin: 0; }

.kit-edit { display: flex; flex-direction: column; gap: 10px; height: 100%; }
.ke-head { display: flex; gap: 8px; align-items: center; }
.ke-head .ke-name { flex: 1; font-size: 16px; padding: 8px 11px; }
.ke-pads { flex: 1; min-height: 160px; }
.ke-pad { --kb-color: #8a93a3; overflow: hidden; border-style: dashed; background: var(--pad); }
.ke-pad.filled { border-style: solid; background: #262b35; cursor: grab; }
.ke-pad.drop { border-color: var(--accent); box-shadow: 0 0 0 2px #f2b33d55 inset; }
.ke-pad canvas { position: absolute; inset: 18px 6px 18px; width: calc(100% - 12px); height: calc(100% - 36px); pointer-events: none; }
.ke-pad .kname { position: absolute; left: 6px; right: 6px; bottom: 5px; font-size: 11px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ke-pad .ke-hint { font-size: 11px; color: #4d5462; }
.ke-pad.filled .ke-hint { display: none; }
.ke-clear {
  position: absolute; top: 3px; right: 4px; width: 18px; height: 18px; padding: 0;
  border: none; border-radius: 4px; background: #00000055; color: var(--muted); font-size: 11px; cursor: pointer; display: none;
}
.ke-pad.filled:hover .ke-clear { display: block; }
.ke-clear:hover { color: var(--rec); }

/* sample kits in the playing panel: empty pads stay dim */
.kpad.empty .kname { color: #4d5462; }
.kit-tag { font-size: 10px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0.04em; }
.kit-banner { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; color: var(--muted); }
.kit-banner span { flex: 1; }

/* Audio page editor */
.ae-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.ae-row .ae-input { flex: 1; min-width: 0; color: var(--text); font-size: 13px; padding: 7px 8px; }
.ae-row .me-ch { flex: none; width: auto; min-width: 0; color: var(--text); font-size: 13px; padding: 7px 8px; }

/* ---- FX page: presets and bypass on top, then 8 pedals, one per pad column ---- */

.fxp { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.fx-head { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); min-width: 0; }
.fx-head b { color: var(--text); white-space: nowrap; }
.fx-preset { color: var(--text); }
.fx-hint { font-size: 11px; color: #5d6574; }
/* Shift: the 32 presets on the pad grid, in place of everything else on the page */
.fxp { position: relative; }
.fx-grid { position: absolute; inset: 0; display: none; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(4, var(--sq)); gap: 10px; }
.fxp.presets-shown .fx-grid { display: grid; }
.fxp.presets-shown > :not(.fx-grid) { visibility: hidden; }
.fx-pre {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; padding: 8px; min-width: 0;
  border: 1px solid color-mix(in srgb, var(--c) 35%, var(--line)); border-radius: 9px;
  background: color-mix(in srgb, var(--c) 12%, var(--pad)); color: var(--text); font: 600 12px system-ui, sans-serif; text-align: left; cursor: pointer;
}
.fx-pre:hover { border-color: var(--c); }
.fx-pre .card-num { position: absolute; top: 6px; left: 8px; font: 10px ui-monospace, Menlo, monospace; color: #5d6574; }
.fx-pre .fx-kind { position: absolute; top: 6px; right: 8px; font: 700 9px system-ui, sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: var(--c); }
.fx-pre-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-pre.on { background: color-mix(in srgb, var(--c) 40%, var(--panel-2)); border-color: #fff; box-shadow: 0 0 0 1px #fff; }
.fx-bypass { margin-left: auto; padding: 3px 10px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; color: var(--go); white-space: nowrap; }
.fx-bypass.off { color: var(--rec); border-color: #5a2a2a; }
.fx-pedals { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; }
.pedal {
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 4px;
  padding: 8px 2px 10px; min-width: 0; min-height: 0;
  border: 1px solid color-mix(in srgb, var(--c) 30%, var(--line)); border-radius: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 14%, #1b1f27), #14171d);
}
.pedal-name { font: 800 10px system-ui, sans-serif; letter-spacing: 0.14em; text-transform: uppercase; color: color-mix(in srgb, var(--c) 70%, var(--text)); }
.pk { gap: 1px; }
.pk .dial { width: 30px; height: 30px; }
.pk .dial i { top: 4px; height: 8px; transform-origin: 50% 11px; }
.pk.pk-mix .dial { width: 42px; height: 42px; }
.pk.pk-mix .dial i { top: 5px; height: 11px; transform-origin: 50% 16px; }
.pk .klabel { font-size: 9px; letter-spacing: 0.04em; }
.pk .kval { font: 10px ui-monospace, Menlo, monospace; color: var(--text); }
.pk.held .dial { box-shadow: 0 0 0 2px var(--text); border-radius: 50%; }
.pk.held .klabel { color: var(--text); }
.pedal:not(.on) .pk { opacity: 0.45; }
.pedal-led { width: 8px; height: 8px; border-radius: 50%; background: #3a2323; flex: none; }
.pedal.on .pedal-led { background: #ff4b4b; box-shadow: 0 0 8px #ff4b4b; }
.pedal-switch {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  border: 2px solid #4d5462; background: radial-gradient(circle at 40% 35%, #5d6574, #262b35 70%);
  cursor: pointer; box-shadow: 0 3px 0 #0b0d11;
}
.pedal-switch:active { transform: translateY(2px); box-shadow: 0 1px 0 #0b0d11; }
.pedal .pk { --c: inherit; }                        /* knob arcs in the pedal's colour */

/* ---- instrument maker: source, the 8 settings (Circuit knobs 1-8), the sampled notes ---- */
.inst-edit { display: flex; flex-direction: column; gap: 10px; }
.ie-source { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.ie-source .inst { min-width: 0; max-width: 200px; color: var(--text); font-size: 13px; padding: 6px 8px; }
.ie-run { font: 12px ui-monospace, Menlo, monospace; color: var(--muted); }
.ie-knobs { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; }
.ie-knobs .pk { --c: var(--accent); }
.ie-zones { display: flex; flex-wrap: wrap; gap: 5px; align-content: flex-start; min-height: 40px; overflow: auto; flex: 1; }
.ie-zone {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 8px; border: 1px solid #3a4150; border-radius: 6px;
  background: var(--panel-2); font: 12px ui-monospace, Menlo, monospace; color: var(--text); cursor: pointer;
}
.ie-zone:hover { border-color: var(--accent); }
.ie-zone small { color: var(--muted); }
.ie-x { font-weight: 400; color: var(--muted); padding: 0 3px; }
.ie-x:hover { color: var(--rec); }

/* ---- Synth page: like the FX page, with section headings over the columns and the voice
   settings (mode, glide, velocity, volume) in the header ---- */
.syn-head { min-height: 30px; }
.syn-voice { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.syn-modes { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.syn-mode { padding: 4px 9px; border: 0; background: transparent; color: var(--muted); font: 600 11px system-ui, sans-serif; cursor: pointer; }
.syn-mode + .syn-mode { border-left: 1px solid var(--line); }
.syn-mode.on { background: #f07acb33; color: #ffd3ef; }
.vk { --c: #f07acb; flex-direction: row; gap: 6px; }
.vk .dial { width: 26px; height: 26px; }
.vk .dial i { top: 3px; height: 7px; transform-origin: 50% 10px; }
.vk-text { display: flex; flex-direction: column; align-items: flex-start; }
.vk .klabel { font-size: 9px; }
.vk .kval { font: 10px ui-monospace, Menlo, monospace; color: var(--text); }
.syn-secs { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; }
.syn-sec {
  font: 800 9px system-ui, sans-serif; letter-spacing: 0.16em; text-transform: uppercase; color: var(--c);
  border-bottom: 2px solid color-mix(in srgb, var(--c) 55%, transparent); padding-bottom: 2px; text-align: center;
}
.syn-wave { width: 14px; height: 9px; margin-right: 4px; vertical-align: -1px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }
.syn-grid .fx-kind { left: 28px; right: auto; letter-spacing: 0.06em; white-space: nowrap; }

/* ---- Settings (the cog): the track buttons pick its page; a list per page ---- */

.tbtn .tpage { display: none; }
body[data-page="settings"] .tbtn { --c: #5d6574; background: #181b21; border-color: var(--line); box-shadow: none; outline: none; }
body[data-page="settings"] .tbtn > :not(.tnum, .tpage) { display: none; }
body[data-page="settings"] .tbtn .tnum { color: #5d6574; }
body[data-page="settings"] .tbtn .tpage { display: block; font: 600 13px system-ui, sans-serif; color: var(--muted); }
body[data-page="settings"] .tbtn.nopage { opacity: 0.35; cursor: default; }
body[data-page="settings"] .tbtn.setpage { background: #2a2e36; border-color: #c9ced8; box-shadow: 0 0 0 1px #c9ced8; }
body[data-page="settings"] .tbtn.setpage .tnum, body[data-page="settings"] .tbtn.setpage .tpage { color: var(--text); }

.set { display: flex; flex-direction: column; gap: 10px; height: 100%; min-height: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.set-list { display: flex; flex-direction: column; gap: 4px; overflow: auto; min-height: 0; }
.set-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto 64px 80px 104px 72px;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
}
.set-row.sel { background: var(--panel-2); border-color: #3a4150; }
.sr-star { color: transparent; font-size: 14px; text-align: center; }
.set-row.dflt .sr-star { color: var(--accent); }
.sr-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-tempo, .sr-when { font: 11px ui-monospace, Menlo, monospace; color: var(--muted); text-align: right; }
.sr-btn {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font: 600 12px system-ui, sans-serif;
  cursor: pointer;
}
.sr-btn:hover { border-color: #464d5c; color: var(--text); }
.set-row.dflt .sr-default { border-color: #6b5420; color: var(--accent); }
.sr-del.armed { border-color: var(--rec); background: color-mix(in srgb, var(--rec) 20%, transparent); color: var(--text); }

/* Settings › MIDI: laid out like the pads (inputs, Omni, channels 1-16) */
.set-pads { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(4, var(--sq)); gap: 10px; }
.set-pad { --c: var(--accent); font: inherit; text-align: left; }
.set-pad.ch .card-name { font: 600 18px ui-monospace, Menlo, monospace; }
.set-pad.sel { border-color: #c9ced8; box-shadow: 0 0 0 1px #c9ced8; }
.set-pad.gone .card-name { text-decoration: line-through; }
.set-pad .card-name { white-space: normal; }

/* Settings › Firmware */
.fw-row { display: flex; align-items: center; gap: 12px; }
.fw-dev { font-size: 13px; color: var(--muted); }
.fw-dev.ok, .fw-log .ok, .fw-phase.ok { color: var(--go); }
.fw-dev.bad, .fw-log .bad, .fw-phase.bad { color: var(--rec); }
.fw-dev.warn, .fw-phase.warn { color: var(--accent); }
.fw-files { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-auto-rows: var(--sq); gap: 10px; align-items: center; }
.fw-file { --c: var(--accent); font: inherit; text-align: left; height: 100%; }
.fw-file:disabled { opacity: 0.35; cursor: default; }
.fw-files .sr-btn { justify-self: start; }
.fw-phase { font-weight: 600; font-size: 14px; }
.fw-bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.fw-bar i { display: block; height: 100%; background: var(--accent); }
.fw-get { justify-self: start; font-size: 13px; color: var(--muted); }
.fw-get:hover { color: var(--text, #eef0f3); }
.fw-log { font: 12px/1.5 ui-monospace, Menlo, monospace; color: var(--muted); }

/* Settings › Monitor */
.mon { gap: 0; overflow: auto; font: 12px/1.7 ui-monospace, Menlo, monospace; }
.mon-row { display: grid; grid-template-columns: 96px minmax(0, 220px) 28px minmax(0, 1fr) auto; gap: 12px; color: var(--text); }
.mon-row > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mon-t, .mon-ch { color: var(--muted); }
.mon-port { color: var(--muted); }
.mon-row.ignored { color: #5d6574; }
.mon-why { color: #5d6574; font-style: italic; }

/* ---- the guide: a spotlight on one part of the panel, and a card beside it ---- */
.tour { position: fixed; inset: 0; z-index: 40; }
.tour-dim { position: fixed; inset: 0; width: 100%; height: 100%; }
.tour-dim path { fill: rgba(6, 8, 11, 0.72); }
.tour-rings i { position: fixed; border-radius: 10px; box-shadow: 0 0 0 2px var(--accent); pointer-events: none; }
.tour-card {
  position: fixed;
  width: min(340px, calc(100vw - 24px));
  padding: 16px 18px 14px;
  background: var(--body);
  border: 1px solid #343a46;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  transition: left 220ms ease, top 220ms ease;
}
.tour-num { font: 600 11px ui-monospace, Menlo, monospace; color: var(--accent); letter-spacing: 0.06em; }
.tour-card h3 { margin: 4px 0 6px; font-size: 16px; }
.tour-card p { margin: 0; font-size: 13.5px; line-height: 1.5; color: #c3c8d1; }
.tour-card .tour-hw { margin-top: 10px; padding-top: 9px; border-top: 1px solid #2b303a; font-size: 12.5px; color: #aab1bd; }
.tour-hw b { display: inline-block; margin-right: 7px; padding: 1px 6px; border-radius: 4px; background: #2b303a; color: var(--accent); font: 600 10px ui-monospace, Menlo, monospace; letter-spacing: 0.06em; text-transform: uppercase; vertical-align: 1px; }
.tour-x { position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 13px; cursor: pointer; }
.tour-x:hover { background: var(--panel-2); color: var(--text); }
.tour-foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.tour-hide { margin-right: auto; display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); cursor: pointer; }
.tour-hide input { accent-color: var(--accent); margin: 0; }
.tour-btn { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--text); font: 600 13px system-ui, sans-serif; cursor: pointer; }
.tour-btn:disabled { opacity: 0.35; cursor: default; }
.tour-btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1406; }
/* Settings › Guide */
.tour-row { grid-template-columns: minmax(0, 1fr) auto; }
.tour-toggle { font: 600 12px system-ui, sans-serif; color: var(--muted); padding: 4px 10px; border: 1px solid var(--line); border-radius: 7px; }
.tour-toggle.on { color: var(--accent); border-color: #6b5420; }
