/* Instrument Sans + Instrument Serif, self-hosted (OFL, licences in fonts/). Latin subset. */
@font-face { font-family: 'Instrument Sans'; font-style: normal; font-weight: 400 700; font-display: swap; src: url(fonts/InstrumentSans-latin.woff2) format('woff2'); }
@font-face { font-family: 'Instrument Sans'; font-style: italic; font-weight: 400 700; font-display: swap; src: url(fonts/InstrumentSans-Italic-latin.woff2) format('woff2'); }
@font-face { font-family: 'Instrument Serif'; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/InstrumentSerif-Italic-latin.woff2) format('woff2'); }

:root {
  --bg: #0d0c0b;
  --bg-2: #141311;
  --surface: #1a1917;
  --surface-2: #22201d;
  --line: #2c2a26;
  --line-2: #3a3732;
  --ink: #ece6dc;
  --ink-2: #a8a197;
  --ink-3: #6f6a62;
  --accent: #ff6a3d;          /* replaced live by the keyboard's own colour */
  --accent-ink: #160b07;
  --ok: #8fd18b;
  --warn: #ffb35c;
  --radius: 14px;
  --font: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
  --serif: 'Instrument Serif', Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* A warm pool of the current key colour behind everything, very low. */
body::before {
  content: '';
  position: fixed;
  inset: -20% -10% auto;
  height: 70vh;
  background: radial-gradient(60% 60% at 50% 40%, color-mix(in oklab, var(--accent) 16%, transparent), transparent 70%);
  pointer-events: none;
  z-index: -1;
  transition: background 600ms ease;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px clamp(16px, 4vw, 40px);
}
.mark { display: inline-flex; align-items: baseline; gap: 6px; text-decoration: none; color: var(--ink); }
.mark-x { font-weight: 700; font-size: 22px; letter-spacing: -0.04em; }
.mark-s { font-family: var(--serif); font-style: italic; font-size: 22px; color: var(--ink-2); }

.profiles { display: flex; align-items: center; gap: 4px; margin-left: auto; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-2); }
.profiles-label { font-size: 12px; color: var(--ink-3); padding: 0 8px 0 10px; text-transform: uppercase; letter-spacing: .08em; }
.profiles button {
  width: 32px; height: 28px; border-radius: 999px; border: 0; background: transparent;
  color: var(--ink-2); font-weight: 600; cursor: pointer; transition: background 160ms, color 160ms;
}
.profiles button:hover { color: var(--ink); }
.profiles button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.profiles button.has-name, .profiles button.has-colour { width: auto; min-width: 32px; max-width: 132px; padding: 0 11px; display: inline-flex; align-items: center; gap: 7px; }
.profiles .pn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdot { display: none; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 6px color-mix(in oklab, var(--pc) 70%, transparent); }
.profiles button.has-colour .pdot { display: block; }
.profiles button[aria-checked="true"] .pdot { box-shadow: 0 0 0 1.5px color-mix(in oklab, var(--pc) 35%, var(--ink)); }

.link { position: relative; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); margin-left: auto; }
.profiles:not([hidden]) + .link { margin-left: 0; }
.link-dot { position: relative; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.link[data-state="on"] .link-dot { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in oklab, var(--ok) 18%, transparent); }
.link[data-state="demo"] .link-dot { background: var(--warn); }
.link[data-state="busy"] .link-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.link-batt {
  display: inline-flex; align-items: center; gap: 6px; margin: -4px 0; padding: 4px 7px; border: 0; border-radius: 8px;
  background: none; color: inherit; font-size: 13px; cursor: pointer; transition: background 140ms, color 140ms;
}
.link-batt:hover, .link-batt[aria-expanded="true"] { background: var(--surface); color: var(--ink); }
.link-batt b { font-weight: 500; font-variant-numeric: tabular-nums; }
.link-batt.is-low .batt i { background: var(--warn); }
.batt { width: 22px; height: 11px; border: 1.5px solid var(--ink-3); border-radius: 3px; padding: 1px; position: relative; }
.batt::after { content: ''; position: absolute; right: -4px; top: 3px; width: 2px; height: 4px; background: var(--ink-3); border-radius: 0 1px 1px 0; }
.batt i { display: block; height: 100%; width: var(--lvl, 50%); background: var(--ink-2); border-radius: 1px; }
.link-btn { border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: 4px 12px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.link-btn:hover:not(:disabled) { color: var(--ink); border-color: var(--ink-3); }
.link-btn:disabled { opacity: .4; cursor: wait; }

@keyframes pulse { 50% { opacity: .35; } }

/* ---------- stage + keyboard ---------- */
main { padding: 0 clamp(16px, 4vw, 40px) 64px; max-width: 1280px; margin: 0 auto; }
.stage { position: relative; padding-top: clamp(8px, 3vw, 28px); }

.board {
  --u: 1cqw;
  container-type: inline-size;
  position: relative;
  aspect-ratio: 1004 / 318;
  border-radius: 2.2cqw;
  background:
    linear-gradient(180deg, #2b2926 0%, #1d1c1a 6%, #191816 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.07),
    inset 0 -2px 0 rgba(0,0,0,.6),
    0 40px 80px -30px rgba(0,0,0,.9),
    0 0 0 1px #0a0908;
  transform: perspective(1800px) rotateX(9deg);
  transform-origin: 50% 100%;
  transition: transform 700ms cubic-bezier(.2,.7,.2,1);
}
.board::after {             /* light leaking out from under the caps onto the case */
  content: '';
  position: absolute;
  inset: 4% 3%;
  border-radius: 2cqw;
  background: radial-gradient(70% 90% at 50% 60%, color-mix(in oklab, var(--accent) 22%, transparent), transparent 75%);
  filter: blur(18px);
  opacity: var(--leak, .6);
  pointer-events: none;
  z-index: 0;
}
.plate { position: absolute; inset: 1.3cqw 1.3cqw 1.3cqw 1.3cqw; z-index: 1; }

.key {
  position: absolute;
  padding: 0.12cqw;
  cursor: pointer;
  --c: 40 38 35;
  --a: 0;
  border: 0;
  background: none;
  -webkit-tap-highlight-color: transparent;
}
.key::before {               /* the LED glow between the caps */
  content: '';
  position: absolute;
  inset: 4%;
  border-radius: 0.8cqw;
  background: rgb(var(--c));
  opacity: calc(var(--a) * .95);
  filter: blur(0.55cqw);
}
.cap {
  position: relative;
  height: 100%;
  border-radius: 0.55cqw;
  background: linear-gradient(180deg, #34312d 0%, #262421 18%, #1f1d1b 100%);
  box-shadow:
    inset 0 0.08cqw 0 rgba(255,255,255,.09),
    inset 0 -0.28cqw 0 #12110f,
    0 0.12cqw 0.2cqw rgba(0,0,0,.6);
  display: grid;
  place-items: center;
  transition: transform 90ms ease, box-shadow 90ms ease;
}
.cap::after {                /* concave top face */
  content: '';
  position: absolute;
  inset: 8% 10% 22%;
  border-radius: 0.4cqw;
  background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(0,0,0,.08));
}
.legend-t {
  position: relative;
  z-index: 1;
  font-size: 1.12cqw;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.05;
  text-align: center;
  padding: 0 0.3cqw 0.25cqw;
  /* shine-through legend: lit by the same LED as the gap around the key */
  color: color-mix(in srgb, rgb(var(--c)) calc(var(--a) * 100%), #8d877e);
  text-shadow: 0 0 calc(var(--a) * 0.6cqw) rgb(var(--c) / .8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.key.is-wide .legend-t { font-size: 1.02cqw; }
.key .was {
  position: absolute; left: 0.45cqw; top: 0.3cqw; z-index: 1;
  font-size: 0.72cqw; color: #6c675f; font-weight: 500;
}
.key.is-mod .cap { box-shadow: inset 0 0.08cqw 0 rgba(255,255,255,.09), inset 0 -0.28cqw 0 #12110f, 0 0 0 0.12cqw var(--accent); }
.key.is-off .legend-t { color: #4b4741; text-decoration: line-through; text-shadow: none; }
.key:hover .cap { transform: translateY(-0.06cqw); }
.key.is-down .cap, .key:active .cap { transform: translateY(0.18cqw); box-shadow: inset 0 0.08cqw 0 rgba(255,255,255,.06), inset 0 -0.1cqw 0 #12110f; }
.key.is-sel .cap {
  transform: translateY(-0.25cqw);
  box-shadow: inset 0 0.08cqw 0 rgba(255,255,255,.12), inset 0 -0.28cqw 0 #12110f, 0 0 0 0.2cqw var(--ink), 0 0.8cqw 1.4cqw rgba(0,0,0,.6);
}

.screen {
  position: absolute; z-index: 1;
  left: calc(1.3cqw + 801 / 979 * (100% - 2.6cqw));
  top: calc(1.3cqw + 9 / 291 * (100% - 2.6cqw));
  width: 12.6cqw; height: 4.4cqw;
  border-radius: 0.5cqw;
  background: #050505;
  box-shadow: inset 0 0 0 0.15cqw #2a2825, inset 0 0 1.4cqw color-mix(in oklab, var(--accent) 25%, transparent);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.1cqw;
  font-size: 1.25cqw; font-weight: 600; font-variant-numeric: tabular-nums;
  color: color-mix(in oklab, var(--accent) 70%, white);
}
.screen-p { font-size: 1cqw; opacity: .7; }
.hint { margin: 22px 0 0; text-align: center; color: var(--ink-3); font-size: 13px; min-height: 20px; }

/* ---------- gate (not connected) ---------- */
.gate {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: linear-gradient(180deg, color-mix(in oklab, var(--bg) 35%, transparent), color-mix(in oklab, var(--bg) 88%, transparent) 70%);
  backdrop-filter: blur(2px);
  z-index: 5;
  transition: opacity 500ms ease, visibility 500ms;
}
.gate[hidden] { display: grid !important; opacity: 0; visibility: hidden; pointer-events: none; }
.gate-card { max-width: 520px; text-align: center; padding: 24px; }
.gate-kicker { margin: 0 0 14px; font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-3); }
.gate h1 { margin: 0; font-size: clamp(34px, 5.4vw, 60px); line-height: .98; letter-spacing: -0.035em; font-weight: 600; }
.gate h1 em { font-family: var(--serif); font-weight: 400; color: var(--accent); }
.gate-copy { color: var(--ink-2); margin: 18px auto 26px; max-width: 42ch; }
.gate-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.gate-note { margin: 18px 0 0; font-size: 13px; color: var(--ink-3); }
.gate-note b { color: var(--ink-2); font-weight: 600; }
.gate-note.is-error { color: var(--warn); }

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: 999px; padding: 12px 22px; font-weight: 600; cursor: pointer;
  transition: transform 140ms cubic-bezier(.3,1.6,.5,1), background 160ms, opacity 160ms;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .35; cursor: default; transform: none; }
.btn-main { background: var(--accent); color: var(--accent-ink); }
.btn-main:hover:not(:disabled) { background: color-mix(in oklab, var(--accent) 88%, white); }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-ghost:hover { box-shadow: inset 0 0 0 1px var(--ink-3); }
.btn-quiet { background: var(--surface-2); color: var(--ink-2); padding: 10px 16px; font-size: 14px; }
.btn-quiet:hover { color: var(--ink); }

/* ---------- deck ---------- */
.deck { margin-top: 26px; border: 1px solid var(--line); border-radius: 20px; background: var(--bg-2); overflow: clip; }
.tabs { display: flex; align-items: center; gap: 4px; padding: 10px 12px 0; border-bottom: 1px solid var(--line); }
.tabs [role="tab"] {
  border: 0; background: none; padding: 10px 14px 12px; font-weight: 600; color: var(--ink-3); cursor: pointer;
  position: relative;
}
.tabs [role="tab"][aria-selected="true"] { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"]::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.tabs-meta { margin-left: auto; font-size: 12px; color: var(--ink-3); padding-right: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tab-tool {
  flex: none; display: inline-flex; align-items: center; gap: 6px; margin: 0 0 7px; padding: 6px 11px 6px 9px;
  border: 0; border-radius: 999px; background: none; color: var(--ink-2); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: color 160ms, background 160ms, opacity 160ms;
}
.tab-tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab-tool:hover:not(:disabled) { color: var(--ink); background: var(--surface); }
.tab-tool:disabled { opacity: .32; cursor: default; }
.undo-n { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center; background: color-mix(in oklab, var(--accent) 22%, var(--surface-2)); color: var(--ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.undo-n:empty { display: none; }
.tab-help { width: 30px; height: 30px; padding: 0; justify-content: center; box-shadow: inset 0 0 0 1px var(--line-2); font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 18px; line-height: 1; }

.panel { padding: 22px; }
#panel-keys:not([hidden]) { display: grid; grid-template-columns: minmax(230px, 290px) 1fr; gap: 22px; }

/* inspector */
.inspect { border-right: 1px solid var(--line); padding-right: 22px; }
.inspect-empty .big { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 6px; }
.inspect-empty p { margin: 0; color: var(--ink-2); }
.legend { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 8px; font-size: 13px; color: var(--ink-3); }
.legend li { display: flex; align-items: center; gap: 10px; }
.dot { width: 12px; height: 12px; border-radius: 3px; background: var(--surface-2); }
.dot-mod { box-shadow: 0 0 0 2px var(--accent); }
.dot-off { background: repeating-linear-gradient(45deg, var(--surface-2) 0 2px, transparent 2px 4px); box-shadow: inset 0 0 0 1px var(--line-2); }

.sel-head { display: flex; align-items: center; gap: 14px; }
.mini-cap {
  min-width: 56px; height: 56px; padding: 0 12px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(180deg, #34312d, #1f1d1b); box-shadow: inset 0 -4px 0 #12110f, inset 0 1px 0 rgba(255,255,255,.1);
  font-weight: 600; font-size: 17px;
}
.sel-name { font-size: 13px; color: var(--ink-3); }
.sel-name b { display: block; font-size: 19px; color: var(--ink); font-weight: 600; letter-spacing: -0.01em; }
.sel-now { margin: 20px 0 0; padding: 14px; border-radius: 12px; background: var(--surface); }
.sel-now span { display: block; font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.sel-now b { font-size: 17px; font-weight: 600; }
.sel-now .tag { display: inline-block; margin-left: 8px; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: color-mix(in oklab, var(--accent) 22%, transparent); color: color-mix(in oklab, var(--accent) 60%, white); vertical-align: 2px; }
.sel-tip { margin: 14px 0 0; font-size: 13px; color: var(--ink-3); }

/* picker */
.pick { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pick-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border-radius: 999px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-3); cursor: pointer; }
.seg button[aria-selected="true"], .seg button[aria-checked="true"] { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.combo { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; color: var(--ink-3); }
.combo .chip { background: var(--ink); color: var(--bg); }
.combo .plus { color: var(--ink-3); }
.combo .clear { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

.pick-body { display: grid; gap: 14px; max-height: 300px; overflow: auto; padding-right: 4px; }
.group h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 0; min-width: 36px; height: 34px; padding: 0 11px; border-radius: 8px;
  background: var(--surface-2); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.35);
  transition: background 120ms, transform 120ms;
}
.chip:hover { background: var(--line-2); }
.chip:active { transform: translateY(1px); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.pick-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 16px; }
.pick-foot .btn-main { padding: 10px 20px; }

/* light panel */
.fx { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.fx button {
  position: relative; border: 0; text-align: left; padding: 10px 12px 11px; border-radius: 12px;
  background: var(--surface); cursor: pointer; overflow: hidden; color: var(--ink-2); font-size: 13px; font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--line);
}
.fx button canvas { display: block; width: 100%; height: 34px; border-radius: 6px; margin-bottom: 8px; background: #0b0a09; }
.fx button .blank { display: grid; place-items: center; height: 34px; margin-bottom: 8px; border-radius: 6px; background: #0b0a09; color: var(--ink-3); font-size: 11px; font-weight: 500; }
.fx button:hover { color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.fx button[aria-checked="true"] { color: var(--ink); box-shadow: inset 0 0 0 2px var(--accent); }

.tune { display: grid; gap: 14px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.tune-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tune-row[hidden] { display: none; }
.tune-label { width: 92px; font-size: 13px; color: var(--ink-3); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 0; cursor: pointer; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); transition: transform 140ms; }
.swatches button:hover { transform: scale(1.1); }
.swatches button[aria-checked="true"] { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 4px var(--ink); }
.custom { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.custom input { width: 28px; height: 28px; border: 0; padding: 0; background: none; cursor: pointer; }
.custom input::-webkit-color-swatch-wrapper { padding: 0; }
.custom input::-webkit-color-swatch { border: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; margin-left: auto; }
.toggle input { position: absolute; opacity: 0; }
.toggle-ui { width: 34px; height: 20px; border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); position: relative; transition: background 160ms; }
.toggle-ui::after { content: ''; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink-2); transition: transform 180ms cubic-bezier(.3,1.4,.5,1), background 160ms; }
.toggle input:checked + .toggle-ui { background: conic-gradient(from 90deg, #ff3d3d, #ffd23d, #3dff7a, #3dc8ff, #b03dff, #ff3d3d); }
.toggle input:checked + .toggle-ui::after { transform: translateX(14px); background: #fff; }
.toggle input:focus-visible + .toggle-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
/* app.js also sets inert on a disabled row, so it is out of reach for the keyboard too. */
.tune-row.row-disabled { opacity: .35; pointer-events: none; }

.steps { display: inline-flex; gap: 4px; }
.steps button {
  width: 44px; height: 30px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-3); font-size: 12px; font-weight: 600;
  position: relative; overflow: hidden;
}
.steps button::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: var(--h); background: color-mix(in oklab, var(--accent) 22%, transparent); }
.steps button span { position: relative; }
.steps button.on { color: var(--ink); }
.steps button.on::before { background: color-mix(in oklab, var(--accent) 55%, transparent); }

/* ---------- knob ---------- */
.key.is-knob { padding: 0; }
.key.is-knob::before { border-radius: 50%; inset: 10%; }
.key.is-knob .cap {
  background: conic-gradient(from 20deg, #3d3a35, #1c1b19 25%, #3d3a35 50%, #1c1b19 75%, #3d3a35);
  box-shadow: 0 0.3cqw 0.6cqw rgba(0,0,0,.7), inset 0 0 0 0.12cqw #11100e;
}
.key.knob-l .cap { border-radius: 2.4cqw 0 0 2.4cqw; background-position: left; }
.key.knob-r .cap { border-radius: 0 2.4cqw 2.4cqw 0; }
.key.is-knob .cap::after { display: none; }
.key.is-knob .legend-t { font-size: 1.3cqw; }
.key.is-knob:hover .cap, .key.is-knob.is-sel .cap { transform: none; }
.key.is-knob.is-sel .cap { box-shadow: 0 0 0 0.2cqw var(--ink); }

/* Fn layer: keys without a Fn action fade back */
.board.is-fn .key.is-blank .legend-t { color: #4a463f; text-shadow: none; }
.board.is-fn .key.is-blank::before { opacity: calc(var(--a) * .25); }
.board.is-painting .key { cursor: crosshair; }
.board.is-painting .key .cap { background: linear-gradient(180deg, #2c2a27 0%, #1e1d1b 100%); }

/* ---------- keys extras ---------- */
.layer-seg { margin-bottom: 18px; }
.seg button[role="radio"] { cursor: pointer; }
.muted { color: var(--ink-3); margin: 0; }

.macro { display: grid; gap: 14px; }
.macro-rec { display: flex; align-items: center; gap: 14px; }
.macro-rec p { margin: 0; color: var(--ink-2); font-size: 14px; }
.rec {
  display: inline-flex; align-items: center; gap: 9px; flex: none;
  border: 0; border-radius: 999px; padding: 10px 18px 10px 14px; font-weight: 600; cursor: pointer;
  background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2);
}
.rec i { width: 12px; height: 12px; border-radius: 50%; background: #ff3b3b; }
.rec.is-on { background: #ff3b3b; color: #fff; box-shadow: 0 0 0 6px rgba(255,59,59,.15); }
.rec.is-on i { background: #fff; border-radius: 2px; animation: pulse 1s ease-in-out infinite; }
.evs { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ev { display: inline-flex; align-items: center; gap: 8px; padding: 5px 6px 5px 10px; border-radius: 8px; background: var(--surface); font-size: 13px; }
.ev span { font-weight: 600; }
.ev-up span { color: var(--ink-2); font-weight: 500; }
.ev em { font-style: normal; color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.ev button { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; }
.ev button:hover { color: var(--ink); }
.macro-opts { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.num { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.num input { width: 64px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; }
.size { margin-left: auto; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.size.over { color: var(--warn); }

.overview h3 { margin: 0 0 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); font-weight: 600; }
.ov-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 300px; overflow: auto; }
.ov-list button {
  width: 100%; display: grid; grid-template-columns: 9.5em 1.2em 1fr; gap: 10px; align-items: center;
  border: 0; background: var(--surface); border-radius: 10px; padding: 10px 14px; text-align: left; cursor: pointer; font-size: 14px;
}
.ov-list button:hover { background: var(--surface-2); }
.ov-key { font-weight: 600; }
.ov-arrow { color: var(--ink-3); }
.ov-now { color: var(--ink-2); }

/* ---------- paint ---------- */
.paint { margin-top: 20px; padding: 18px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); }
.paint-head { display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.paint-title { margin: 0; font-weight: 600; font-size: 16px; }
.paint-sub { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; }
.paint-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#brush-swatches button[data-rgb="0"] { box-shadow: inset 0 0 0 1px var(--ink-3); background: repeating-linear-gradient(45deg, #000 0 3px, #222 3px 6px); }

/* ---------- screen ---------- */
.scr { display: grid; grid-template-columns: minmax(0, 520px) 1fr; gap: 28px; align-items: start; }
.scr-frame {
  padding: 14px; border-radius: 16px; background: #050505;
  box-shadow: inset 0 0 0 2px #2a2825, 0 20px 40px -20px rgba(0,0,0,.8);
}
.scr-frame canvas { display: block; width: 100%; aspect-ratio: 240 / 135; image-rendering: pixelated; border-radius: 4px; }
.scr-cap { margin: 10px 0 0; font-size: 13px; color: var(--ink-3); }
.scr-side { display: grid; gap: 16px; }
.drop {
  display: grid; place-items: center; gap: 2px; padding: 26px 16px; border-radius: 14px; cursor: pointer; text-align: center;
  border: 1.5px dashed var(--line-2); background: var(--surface); transition: border-color 160ms, background 160ms, opacity 160ms;
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 6%, var(--surface)); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop b { font-weight: 600; }
.drop span { font-size: 13px; color: var(--ink-3); }
.scr-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.scr-note { margin: 0; font-size: 13px; color: var(--warn); }
.scr-note:empty { display: none; }
.progress { position: relative; height: 32px; border-radius: 999px; background: var(--surface); overflow: hidden; }
.progress i { position: absolute; inset: 0 auto 0 0; width: var(--p, 0%); background: var(--accent); transition: width 200ms linear; }
.progress span { position: relative; display: grid; place-items: center; height: 100%; font-size: 13px; font-weight: 600; mix-blend-mode: difference; color: #fff; }

.danger { border-top: 1px solid var(--line); padding-top: 14px; }
.danger summary { cursor: pointer; color: var(--ink-3); font-size: 13px; }
.danger summary:hover { color: var(--warn); }
.danger p { margin: 10px 0; font-size: 13px; color: var(--ink-2); }
.danger .btn { color: var(--warn); }
.danger-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.danger #reset-backup { color: var(--ink); }

/* ---------- settings ---------- */
.set { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.set-card { padding: 20px; border-radius: 16px; background: var(--surface); display: grid; gap: 12px; align-content: start; }
.set-card h3 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.set-card > p { margin: 0; color: var(--ink-2); font-size: 14px; }
.steps-wide { display: flex; gap: 3px; }
.steps-wide button { flex: 1; width: auto; min-width: 0; height: 40px; }
.sliders { display: grid; gap: 12px; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; font-size: 13px; color: var(--ink-2); }
.slider input { grid-column: 1 / -1; accent-color: var(--accent); width: 100%; }
.slider b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; grid-row: 1; grid-column: 2; }
.set-card .btn-main { justify-self: start; padding: 10px 20px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 31;
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 200ms, transform 260ms cubic-bezier(.2,1.2,.4,1);
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--warn); }
.toast.has-act { pointer-events: auto; padding: 6px 6px 6px 18px; }
.toast-act {
  flex: none; border: 0; border-radius: 999px; padding: 6px 13px; background: var(--bg); color: var(--ink);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: background 140ms;
}
.toast-act:hover { background: #2b2825; }
.toast-act:focus-visible { outline-color: var(--bg); }

/* ---------- Mac-modus card ---------- */
.mac {
  position: relative; margin: 0 0 22px; padding: 16px; border-radius: 16px; overflow: hidden;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
}
/* the same warm pool the page uses, here coming off the little ⌘ cap */
.mac::before {
  content: ''; position: absolute; left: -40px; top: -60px; width: 220px; height: 180px; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in oklab, var(--accent) 14%, transparent), transparent);
}
.mac > * { position: relative; }
.mac.is-compact { display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 12px; }
.mac-head { display: flex; align-items: center; gap: 14px; }
.mac-glyph {
  flex: none; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(180deg, #34312d, #1f1d1b);
  box-shadow: inset 0 -4px 0 #12110f, inset 0 1px 0 rgba(255,255,255,.1), 0 6px 14px -6px rgba(0,0,0,.7);
}
.mac-glyph span {
  font-size: 19px; line-height: 1; margin-top: -3px; color: color-mix(in oklab, var(--accent) 80%, white);
  text-shadow: 0 0 10px color-mix(in oklab, var(--accent) 70%, transparent);
}
.mac.is-done .mac-glyph span { color: var(--ok); text-shadow: 0 0 10px color-mix(in oklab, var(--ok) 50%, transparent); }
.mac-text { min-width: 0; }
.mac-text h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; text-transform: none; color: var(--ink); }
.mac-text p { margin: 1px 0 0; font-size: 13px; color: var(--ink-2); }
.mac-open { margin-left: auto; flex: none; padding: 8px 15px; font-size: 13px; }
.mac-x {
  margin-left: auto; align-self: flex-start; flex: none; width: 30px; height: 30px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-3); font-size: 20px; line-height: 1; cursor: pointer; transition: color 140ms, background 140ms;
}
.mac-x:hover { color: var(--ink); background: var(--surface-2); }
.mac-warn { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 13px; color: var(--warn); background: color-mix(in oklab, var(--warn) 8%, transparent); }
.mac-wait { margin: 16px 0 4px; }
.mac-cols, .mac-rows li { display: grid; grid-template-columns: 56px minmax(0, 15em) 16px minmax(0, 1fr); gap: 12px; align-items: center; }
.mac-cols { margin: 18px 0 6px; padding: 0 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
.mac-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.mac-rows li {
  padding: 7px 10px; border-radius: 11px; background: var(--bg-2); font-size: 13.5px; cursor: default;
  transition: background 140ms; animation: row-in 380ms cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--j, 0) * 60ms);
}
.mac-rows li:hover { background: var(--surface-2); }
.kc {
  position: relative; display: inline-grid; place-items: center; min-width: 46px; height: 32px; padding: 3px 8px 0;
  border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--ink);
  background: linear-gradient(180deg, #34312d 0%, #262421 22%, #1f1d1b 100%);
  box-shadow: inset 0 -3px 0 #12110f, inset 0 1px 0 rgba(255,255,255,.09);
}
.kc i { position: absolute; left: 5px; top: 2px; font-style: normal; font-size: 8.5px; font-weight: 700; letter-spacing: .04em; color: color-mix(in oklab, var(--accent) 85%, white); }
.mac-now { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mac-arrow { color: var(--accent); font-weight: 600; }
.mac-new { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mac-empty { margin: 16px 0 4px; font-weight: 600; color: var(--ok); }
.mac .mac-swap { margin: 18px 0 0; color: var(--ink); font-size: 14px; }
.mac .toggle input:checked + .toggle-ui { background: var(--accent); }
.mac-note { margin: 6px 0 0 42px; font-size: 12.5px; color: var(--ink-3); }
.mac-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.mac-time { font-size: 13px; color: var(--ink-3); }
.mac-foot .btn-main { padding: 10px 22px; }

/* the preview drawn on the keyboard itself: a pin, a dashed ring and a second legend */
.sub {
  position: absolute; left: 0; right: 0; bottom: 0.42cqw; z-index: 1;
  padding: 0 0.3cqw; text-align: center; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 0.8cqw; font-weight: 700; letter-spacing: .01em; color: color-mix(in oklab, var(--accent) 85%, white);
  text-shadow: 0 0 0.6cqw color-mix(in oklab, var(--accent) 60%, transparent);
}
.sub:empty { display: none; }
.sub i { font-style: normal; font-weight: 600; font-size: 0.64cqw; text-transform: uppercase; opacity: .7; margin-right: 0.22cqw; }
.legend-t { transition: transform 220ms cubic-bezier(.2,.8,.2,1); }
.key.is-mark .legend-t { transform: translateY(-0.5cqw); }
.key.is-mark .cap {
  outline: 0.11cqw dashed color-mix(in oklab, var(--accent) 85%, transparent); outline-offset: 0.14cqw;
  animation: mark-in 460ms cubic-bezier(.2,1.2,.4,1) both; animation-delay: calc(var(--mi, 0) * 80ms);
}
.key.is-mark .cap::before {
  content: ''; position: absolute; right: -0.38cqw; top: -0.38cqw; z-index: 2; width: 0.82cqw; height: 0.82cqw; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 0.16cqw #191816, 0 0 1cqw var(--accent);
  animation: pin-in 420ms cubic-bezier(.2,1.5,.4,1) both; animation-delay: calc(var(--mi, 0) * 80ms + 120ms);
}
.key.is-hl .cap { transform: translateY(-0.3cqw); outline-style: solid; }
.key.is-landed .cap { animation: land 1s cubic-bezier(.2,.8,.2,1); }
@keyframes mark-in { from { outline-color: transparent; outline-offset: 0.6cqw; } }
@keyframes pin-in { from { transform: scale(0); } 60% { transform: scale(1.3); } }
@keyframes land {
  0% { background: color-mix(in oklab, var(--accent) 55%, #262421); box-shadow: 0 0 0 0.25cqw var(--accent), 0 0 2cqw var(--accent); }
  100% { }
}
@keyframes row-in { from { opacity: 0; transform: translateY(4px); } }

/* ---------- gate intro ---------- */
.gate-card:has(.intro:not([hidden])) { max-width: 620px; }
.gate-nohid { margin: -8px auto 22px; max-width: 42ch; font-size: 14px; font-weight: 600; color: var(--warn); }
.intro {
  list-style: none; margin: 24px auto 0; padding: 0; max-width: 600px; counter-reset: st;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: left;
}
.intro li {
  position: relative; display: grid; gap: 2px; align-content: start; padding: 12px 12px 13px; border-radius: 12px;
  background: color-mix(in oklab, var(--surface) 86%, transparent); box-shadow: inset 0 0 0 1px var(--line);
  animation: row-in 520ms cubic-bezier(.2,.8,.2,1) both;
}
.intro li:nth-child(2) { animation-delay: 90ms; }
.intro li:nth-child(3) { animation-delay: 180ms; }
.intro li::after { counter-increment: st; content: counter(st); position: absolute; right: 11px; top: 7px; font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--ink-3); }
.intro svg { width: 22px; height: 22px; margin-bottom: 6px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.intro b { font-size: 13px; font-weight: 600; }
.intro span { font-size: 12px; line-height: 1.35; color: var(--ink-3); }
.gate-more { margin: 10px 0 0; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; color: var(--ink-3); }
.gate-link {
  position: relative; padding: 0; border: 0; background: none; font: inherit; color: var(--ink-2); cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px;
}
.gate-link:hover { color: var(--ink); text-decoration-color: var(--ink-3); }
.gate-link input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.gate-link:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ---------- shared setup banner ---------- */
.shared {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px 11px 22px; border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--accent) 8%, var(--bg-2));
}
.shared p { margin: 0; flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shared-mark { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 22%, transparent); }
.btn-sm { padding: 8px 15px; font-size: 13px; }

/* ---------- backup and profiles ---------- */
.set-card .bk-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bk-file { position: relative; display: inline-flex; align-items: center; }
.bk-file input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.bk-file:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.cfg-status { padding: 10px 12px; border-radius: 10px; background: var(--bg-2); font-size: 13px; color: var(--ink-2); animation: row-in 300ms both; }
.cfg-status:empty { display: none; }
.cfg-status span { overflow-wrap: anywhere; }
.cfg-status details { margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.cfg-status summary { cursor: pointer; }
.cfg-status ul { margin: 6px 0 0; padding-left: 16px; }
.bk-share { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.bk-share .btn { justify-self: start; }
.bk-url {
  width: 100%; min-width: 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2);
  color: var(--ink-2); font: 500 12px/1.3 var(--font); text-overflow: ellipsis;
}
.bk-url:focus { outline: none; border-color: var(--accent); color: var(--ink); }
.bk-note { margin: 0; font-size: 12px; color: var(--ink-3); }

.pnames { display: grid; gap: 12px; }
.pname { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 7px 10px; align-items: center; }
.pname-n {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: var(--pc); color: var(--ink-2); box-shadow: inset 0 -3px 0 rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,255,255,.08);
  transition: background 200ms;
}
.pname.has-colour .pname-n { color: #120a06; }
.pname input {
  min-width: 0; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2);
  color: var(--ink); font: inherit; font-size: 14px;
}
.pname input::placeholder { color: var(--ink-3); }
.pname input:focus { outline: none; border-color: var(--accent); }
.pname-sw { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; }
.pname-sw button {
  width: 18px; height: 18px; border: 0; border-radius: 50%; padding: 0; background: var(--sw); cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); transition: transform 140ms;
}
.pname-sw button:hover { transform: scale(1.15); }
.pname-sw button[data-c="none"] { position: relative; background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-2); }
.pname-sw button[data-c="none"]::after { content: ''; position: absolute; left: 3px; right: 3px; top: 50%; height: 1.5px; background: var(--ink-3); transform: rotate(-45deg); }
.pname-sw button[aria-checked="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ink); }

/* ---------- run pill ---------- */
.run {
  position: fixed; left: 50%; bottom: 24px; z-index: 30; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; width: max-content; min-width: min(300px, calc(100vw - 32px)); max-width: calc(100vw - 32px);
  padding: 11px 18px 13px 15px; border-radius: 14px; overflow: hidden;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2), 0 24px 48px -16px rgba(0,0,0,.85);
  font-size: 13px; font-weight: 600; animation: run-in 220ms cubic-bezier(.2,.8,.2,1) both;
}
.run-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.run-count { margin-left: auto; padding-left: 12px; font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.run-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: var(--p, 0%); background: var(--accent); transition: width 260ms cubic-bezier(.2,.8,.2,1); }
.run.is-indet .run-bar { width: 32%; animation: indet 1.3s ease-in-out infinite; }
@keyframes run-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes indet { from { left: -32%; } to { left: 100%; } }

/* ---------- dialogs ---------- */
.dlg {
  width: min(540px, calc(100vw - 32px)); max-height: 90dvh; overflow: auto; padding: 26px; margin: auto;
  border: 0; border-radius: 22px; background: var(--bg-2); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-2), 0 40px 90px -24px rgba(0,0,0,.95);
}
.dlg[open] { animation: dlg-in 160ms cubic-bezier(.2,.8,.2,1) both; }
.dlg::backdrop { background: rgba(9, 8, 7, .64); backdrop-filter: blur(3px); }
.dlg[open]::backdrop { animation: fade-in 160ms both; }
.dlg.is-closing { animation: dlg-out 140ms ease-in both; }
.dlg.is-closing::backdrop { animation: fade-out 140ms both; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes dlg-out { to { opacity: 0; transform: translateY(4px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.dlg-kicker { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); overflow-wrap: anywhere; }
.dlg h2 { margin: 0; font-size: 30px; line-height: 1.02; letter-spacing: -0.03em; font-weight: 600; }
.dlg h2 em { font-family: var(--serif); font-weight: 400; color: var(--accent); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 24px; }
.dlg-foot .btn { padding: 11px 20px; }
.dlg-warn { margin: 16px 0 0; font-size: 13px; color: var(--warn); }

/* Long screen upload: the floor in big type next to the part of the screen that gets sent. */
.slow-fig { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 22px 0 6px; }
.slow-time { margin: 0; display: grid; grid-template-columns: auto auto; justify-content: start; align-items: baseline; column-gap: 4px; }
.slow-time em { grid-column: 1 / -1; font-style: normal; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.slow-time b { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 64px; line-height: .9; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--accent); }
.slow-time span { font-size: 18px; color: var(--ink-2); }
.slow-scr {
  position: relative; flex: 0 0 auto; width: 160px; aspect-ratio: 240 / 135; margin: 0 7px 0 0; border-radius: 6px;
  background: #050505; box-shadow: 0 0 0 6px #121110, 0 0 0 7px var(--line);
}
.slow-box {
  position: absolute; border-radius: 2px;
  background: color-mix(in oklab, var(--accent) 22%, transparent);
  box-shadow: inset 0 0 0 1.5px var(--accent);
  animation: slow-pulse 2.4s cubic-bezier(.45,0,.55,1) infinite;
}
@keyframes slow-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.slow-what { margin: 14px 0 0; color: var(--ink-2); font-size: 14px; }
.slow-what b { color: var(--ink); font-weight: 600; }
.slow-faster { margin: 16px 0 6px; font-size: 13px; font-weight: 600; }
.slow-tips { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.slow-tips li { position: relative; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
.slow-tips li::before { content: ''; position: absolute; left: 3px; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.slow-tips b { color: var(--ink); font-weight: 600; }
.btn[aria-busy="true"] { cursor: progress; opacity: .75; }

.imp-board {
  position: relative; aspect-ratio: 979 / 291; margin: 26px 10px 14px; border-radius: 6px;
  background: #121110; box-shadow: 0 0 0 10px #121110, 0 0 0 11px var(--line);
}
.imp-board i { position: absolute; border-radius: 3px; background: #2a2825; transform: scale(.82); }
.imp-board i.on { background: var(--accent); box-shadow: 0 0 8px color-mix(in oklab, var(--accent) 60%, transparent); animation: pop-in 320ms cubic-bezier(.2,1.4,.4,1) both; animation-delay: calc(var(--j, 0) * 22ms + 80ms); }
.imp-board i.fn { background: transparent; box-shadow: inset 0 0 0 1.5px var(--accent); animation: pop-in 320ms cubic-bezier(.2,1.4,.4,1) both; animation-delay: calc(var(--j, 0) * 22ms + 80ms); }
/* In the file, but X98 Studio does not know that function: struck through, never written. */
.imp-board i.skip { background: repeating-linear-gradient(-45deg, #4a4540 0 2px, #2a2825 2px 5px); box-shadow: inset 0 0 0 1px #6b645c; animation: pop-in 320ms cubic-bezier(.2,1.4,.4,1) both; animation-delay: calc(var(--j, 0) * 22ms + 80ms); }
@keyframes pop-in { from { transform: scale(.3); opacity: 0; } }
.imp-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0 0 16px; font-size: 12px; color: var(--ink-3); }
.imp-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.imp-legend .lg[hidden] { display: none; }
.imp-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.imp-legend .sw-on { background: var(--accent); }
.imp-legend .sw-fn { box-shadow: inset 0 0 0 1.5px var(--accent); }
.imp-legend .sw-skip { background: repeating-linear-gradient(-45deg, #4a4540 0 2px, #2a2825 2px 4px); box-shadow: inset 0 0 0 1px #6b645c; }
.imp-rows { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.imp-rows li { display: flex; align-items: baseline; gap: 10px; padding: 11px 13px; border-radius: 12px; background: var(--surface); animation: row-in 360ms both; }
.imp-rows b { min-width: 1ch; font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 28px; line-height: .9; color: var(--accent); font-variant-numeric: tabular-nums; }
.imp-rows span { font-size: 13px; color: var(--ink-2); }
.imp-skip { margin-top: 12px; font-size: 13px; color: var(--ink-3); }
.imp-skip summary { cursor: pointer; }
.imp-skip ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 3px; }
.imp-time { margin: 14px 0 0; font-size: 13px; color: var(--ink-2); }
.imp-none { margin: 22px 0 0; font-size: 18px; font-weight: 600; color: var(--ok); }
.imp-none.is-partial { color: var(--ink); }
.imp-skip.is-skip summary { color: var(--ink-2); }

.keys-help { margin: 22px 0 0; display: grid; }
.keys-help > div { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); animation: row-in 320ms both; }
.keys-help > div:nth-child(2) { animation-delay: 30ms; } .keys-help > div:nth-child(3) { animation-delay: 60ms; }
.keys-help > div:nth-child(4) { animation-delay: 90ms; } .keys-help > div:nth-child(5) { animation-delay: 120ms; }
.keys-help > div:nth-child(6) { animation-delay: 150ms; } .keys-help > div:nth-child(7) { animation-delay: 180ms; }
.keys-help dt { display: flex; align-items: center; gap: 5px; }
.keys-help dd { margin: 0; font-size: 14px; color: var(--ink-2); }
.kh-to { margin: 0 2px; font-size: 12px; color: var(--ink-3); }
kbd {
  min-width: 28px; height: 28px; padding: 1px 7px 0; display: inline-grid; place-items: center; border-radius: 7px;
  background: linear-gradient(180deg, #34312d 0%, #262421 22%, #1f1d1b 100%);
  box-shadow: inset 0 -3px 0 #12110f, inset 0 1px 0 rgba(255,255,255,.1);
  font: 600 13px/1 var(--font); color: var(--ink);
}
kbd.kw { min-width: 46px; font-size: 12px; }
kbd.kin { min-width: 20px; height: 20px; padding: 0 4px; font-size: 11px; box-shadow: inset 0 -2px 0 #12110f; vertical-align: 1px; margin-left: 2px; }

/* ---------- live ---------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; margin: 0; }
/* The board did something by itself: the status dot rings once, the case breathes the accent once. */
.link.is-ping .link-dot::after {
  content: ''; position: absolute; inset: -1px; border-radius: 50%; border: 1.5px solid var(--accent);
  animation: ring 600ms cubic-bezier(.2,.7,.2,1) forwards;
}
@keyframes ring { from { transform: scale(1); opacity: .9; } to { transform: scale(3.4); opacity: 0; } }
.board::before { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 0; }
.board.is-ping::before { animation: case-ping 640ms cubic-bezier(.2,.7,.2,1) forwards; }
@keyframes case-ping {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 50%, transparent), inset 0 0 0 0.12cqw color-mix(in oklab, var(--accent) 70%, transparent); }
  100% { box-shadow: 0 0 0 1.8cqw transparent, inset 0 0 0 0.12cqw transparent; }
}
.live-note {
  display: flex; align-items: baseline; gap: 10px; margin: 0; padding: 10px 22px; border-bottom: 1px solid var(--line);
  font-size: 13px; line-height: 1.45; color: var(--ink-2);
}
.live-note::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--ink-3); transform: translateY(-1px); }

/* Mac or Windows stand, next to how it is connected */
.tabs-meta { display: inline-flex; align-items: center; gap: 10px; }
.os-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px; border-radius: 999px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink-2); font-weight: 600; font-size: 11.5px;
}
.os-badge svg { width: 10px; height: 10px; fill: currentColor; opacity: .8; }
.os-badge i { font-style: normal; font-size: 12px; line-height: 1; color: color-mix(in oklab, var(--accent) 80%, white); }

/* battery popover by the icon in the bar */
.batt-pop {
  position: absolute; right: 0; top: calc(100% + 12px); z-index: 40; width: min(290px, calc(100vw - 32px));
  padding: 14px 16px 12px; border-radius: 16px; background: var(--surface); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-2), 0 24px 48px -16px rgba(0,0,0,.85);
  display: grid; gap: 8px; animation: pop-down 180ms cubic-bezier(.2,.8,.2,1) both;
}
.batt-pop::before { content: ''; position: absolute; right: 64px; top: -5px; width: 10px; height: 10px; background: var(--surface); box-shadow: -1px -1px 0 0 var(--line-2); transform: rotate(45deg); }
.pop-kicker { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); }
@keyframes pop-down { from { opacity: 0; transform: translateY(-4px); } }
.batt-now { margin: 0; display: flex; align-items: baseline; gap: 3px; }
.batt-now b { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 52px; line-height: .85; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.batt-pop .batt-now b { font-size: 40px; }
.batt-now span { font-size: 17px; color: var(--ink-2); }
.batt-now em { margin-left: 10px; font-style: normal; font-size: 12px; color: var(--ink-3); }
.batt-last { margin: 0; font-size: 14px; color: var(--ink-2); }
.batt-last b { color: var(--ink); font-weight: 600; }
.batt-graph { margin: 2px 0 0; }
.batt-graph figcaption { display: flex; justify-content: space-between; margin-top: 4px; font-size: 11px; color: var(--ink-3); }
.spark { display: block; width: 100%; height: auto; overflow: visible; }
.spark-ticks line { stroke: var(--ink-3); stroke-width: 1; }
.spark-low { stroke: color-mix(in oklab, var(--warn) 55%, var(--line-2)); stroke-width: 1; stroke-dasharray: 2 3; }
.spark-area { fill: color-mix(in oklab, var(--accent) 9%, transparent); }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }

/* ---------- under the board: hint + heatmap toggle ---------- */
.under { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 22px; min-height: 20px; }
.under .hint { margin: 0; }
.heat-btn {
  flex: none; display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px 5px 9px; border: 0; border-radius: 999px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink-3); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: color 140ms, box-shadow 140ms;
}
.heat-btn svg { width: 15px; height: 15px; fill: var(--ink-3); }
.heat-btn[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 60%, var(--line-2)); }
.heat-btn[aria-pressed="true"] rect { fill: var(--accent); }
.heat-btn[aria-pressed="true"] rect:nth-child(1), .heat-btn[aria-pressed="true"] rect:nth-child(6) { fill-opacity: .3; }
.heat-btn[aria-pressed="true"] rect:nth-child(3), .heat-btn[aria-pressed="true"] rect:nth-child(4) { fill-opacity: .6; }

/* heatmap on the caps: the busiest key glows hottest, the LED glow steps back while it shows */
.key .heat {
  position: absolute; inset: 7%; border-radius: 0.42cqw; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in oklab, var(--accent) 60%, #fff), var(--accent));
  opacity: 0; transition: opacity 240ms ease-out;
}
.plate.is-heat .key .heat { opacity: calc(var(--heat, 0) * .9); }
.plate.is-heat .key::before { opacity: calc(var(--a) * .2); }
.plate.is-heat .legend-t { color: color-mix(in srgb, var(--ink) calc(40% + var(--heat, 0) * 60%), #6f6a62); text-shadow: none; }
.heat-n {
  position: absolute; right: 0.32cqw; top: 0.22cqw; z-index: 2; font-size: 0.7cqw; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--ink); text-shadow: 0 0 0.4cqw rgba(0,0,0,.6);
}
.heat-n:empty { display: none; }

/* ---------- gate: install as app ---------- */
.gate-install { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 8px; margin: 14px 0 0; font-size: 13px; color: var(--ink-3); }
.gate-install svg { width: 17px; height: 17px; fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.gate-install .gate-link { color: var(--ink); font-weight: 600; }
.gate-x { width: 24px; height: 24px; border: 0; border-radius: 999px; background: none; color: var(--ink-3); font-size: 16px; line-height: 1; cursor: pointer; }
.gate-x:hover { color: var(--ink); background: var(--surface); }

/* ---------- knob presets ---------- */
.knob-presets { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.kp-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
.kp-title svg { width: 16px; height: 16px; fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.kp-list { display: grid; gap: 5px; }
.kp {
  position: relative; display: grid; gap: 3px; padding: 9px 12px 10px; border: 0; border-radius: 12px; text-align: left; cursor: pointer;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); transition: box-shadow 140ms, background 140ms;
}
.kp:hover:not(:disabled) { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.kp:disabled { opacity: .4; cursor: default; }
.kp-name { font-weight: 600; font-size: 14px; }
.kp-dir { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12px; color: var(--ink-3); }
.kp-dir i { font-style: normal; margin-right: 4px; color: color-mix(in oklab, var(--accent) 85%, white); }
.kp[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent); background: color-mix(in oklab, var(--accent) 6%, var(--surface)); }
.kp[aria-pressed="true"]::after { content: ''; position: absolute; right: 12px; top: 12px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.kp-note { margin: 8px 0 0; font-size: 12px; color: var(--ink-3); }

/* ---------- macro: text mode + library ---------- */
.pick-body:has(.macro) { max-height: 520px; }
.m-src { justify-self: start; }
.m-text textarea {
  display: block; width: 100%; min-height: 86px; resize: vertical; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink); font: 500 15px/1.45 var(--font);
}
.m-text textarea:focus { outline: none; border-color: var(--accent); }
.m-text textarea::placeholder { color: var(--ink-3); }
.m-skip { margin: 8px 0 0; font-size: 13px; color: var(--warn); }
.m-note { margin: 6px 0 0; font-size: 12px; color: var(--ink-3); }
.m-typed { margin: 0; font-size: 13px; color: var(--ink-2); }
.m-typed b { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 24px; line-height: 1; color: var(--accent); margin-right: 3px; font-variant-numeric: tabular-nums; }
.lib { display: grid; gap: 10px; margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--line); }
.lib-head { display: flex; align-items: baseline; gap: 10px; }
.lib-head h3 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); font-weight: 600; }
.lib-head span { font-size: 12px; color: var(--ink-3); }
.lib-empty { font-size: 13px; }
.lib-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.lib-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 10px;
  padding: 5px 5px 5px 12px; border-radius: 10px; background: var(--surface); animation: row-in 280ms both;
}
.lib-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-units { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.btn-xs { padding: 6px 12px; font-size: 12.5px; }
.lib-x { width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--ink-3); font-size: 16px; line-height: 1; cursor: pointer; }
.lib-x:hover { color: var(--ink); background: var(--surface-2); }
.lib-save { display: flex; gap: 8px; flex-wrap: wrap; }
.lib-save input {
  flex: 1; min-width: 160px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--ink); font: inherit; font-size: 14px;
}
.lib-save input:focus { outline: none; border-color: var(--accent); }
.lib-save input::placeholder { color: var(--ink-3); }

/* ---------- paint toolbar ---------- */
.paint-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin-top: 16px; }
.paint.is-loading .pattern-grid, .paint.is-loading .paint-fills { opacity: .55; cursor: progress; }
.patterns { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.pattern-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
.pattern-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.anim-text { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.anim-text input { flex: 1 1 220px; min-width: 0; max-width: 420px; height: 34px; padding: 0 12px; border: 0; border-radius: 9px; background: var(--surface-2); color: var(--ink); font: inherit; box-shadow: inset 0 0 0 1px var(--line); }
.anim-text input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.anim .live-foot { margin-top: 14px; }
.pat[hidden] { display: none; }
.pat { min-width: 0; }
.pat canvas { min-width: 0; }
.pat {
  position: relative; display: grid; gap: 7px; padding: 8px 8px 9px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--surface-2); color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 600; text-align: left;
  box-shadow: inset 0 0 0 1px var(--line); transition: transform 160ms cubic-bezier(.3,1.4,.5,1), box-shadow 160ms, color 160ms;
}
.pat canvas { display: block; width: 100%; aspect-ratio: 979 / 291; border-radius: 6px; background: #0b0a09; }
.pat:hover { color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); transform: translateY(-2px); }
.pat:active { transform: translateY(0) scale(.98); }
.pat[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 0 0 2px var(--accent); }
.pat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.paint-fills { gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.paint-label { margin-right: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
.paint-sep { width: 1px; height: 20px; margin: 0 2px; background: var(--line-2); }
.tools button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px 7px 10px; }
.tools svg, .seg button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tools button[aria-checked="true"] svg { stroke: var(--accent); }
.pchip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border: 0; border-radius: 999px;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 140ms, transform 140ms cubic-bezier(.3,1.6,.5,1);
}
.pchip:hover:not(:disabled) { background: var(--line-2); }
.pchip:active:not(:disabled) { transform: scale(.96); }
.pchip:disabled { opacity: .35; cursor: default; }
.pchip svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.grad { display: inline-flex; align-items: center; gap: 8px; }
.grad-to { gap: 6px; font-size: 12px; }
.grad-sw, .rb-sw { width: 20px; height: 10px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.grad-sw { background: linear-gradient(90deg, var(--b1, #ff6a3d), var(--b2, #3d6bff)); }
.rb-sw { background: linear-gradient(90deg, #ff2a2a, #ffd23d, #4dff7a, #3dd6ff, #3d6bff, #b23dff); }
.board.is-painting[data-tool="pick"] .key { cursor: copy; }
.board.is-painting[data-tool="row"] .key, .board.is-painting[data-tool="col"] .key { cursor: cell; }
.key.is-reach .cap { box-shadow: inset 0 0.08cqw 0 rgba(255,255,255,.09), inset 0 -0.28cqw 0 #12110f, 0 0 0 0.12cqw color-mix(in oklab, var(--ink) 55%, transparent); }

/* ---------- screen: designer, preview, gallery ---------- */
.scr-frame { position: relative; }
.scr-glass { position: relative; border-radius: 4px; overflow: hidden; }
.scr-glass canvas { touch-action: none; border-radius: 0; }
.scr-frame.is-dragging canvas { cursor: grabbing !important; }
.scr-sel {
  position: absolute; pointer-events: none; border-radius: 3px;
  outline: 1px dashed color-mix(in oklab, var(--accent) 85%, white); outline-offset: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,.55);
}
.scr-sel::before, .scr-sel::after { content: ''; position: absolute; width: 5px; height: 5px; border-radius: 1px; background: var(--accent); box-shadow: 0 0 0 1px #050505; }
.scr-sel::before { left: -3px; top: -3px; }
.scr-sel::after { right: -3px; bottom: -3px; }
.scr-frame.snap-x .scr-glass::before, .scr-frame.snap-y .scr-glass::after { content: ''; position: absolute; z-index: 2; background: color-mix(in oklab, var(--accent) 80%, white); opacity: .7; pointer-events: none; }
.scr-frame.snap-x .scr-glass::before { left: 50%; top: 0; bottom: 0; width: 1px; }
.scr-frame.snap-y .scr-glass::after { top: 50%; left: 0; right: 0; height: 1px; }
.scr-move { position: absolute; right: 22px; bottom: 22px; padding: 3px 9px; border-radius: 999px; background: rgba(13,12,11,.82); box-shadow: inset 0 0 0 1px var(--line-2); font-size: 11.5px; color: var(--ink-2); }
.scr-cap.is-bad { color: var(--warn); }
.scr-mode { display: flex; }
.scr-mode button { flex: 1; }
.ready:not([hidden]) { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ready-cats { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.ready-cats .pchip[aria-checked="true"], .pattern-cats .pchip[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.ready-cats small { opacity: .6; font-weight: 500; margin-left: 2px; }
.scene {
  display: grid; gap: 2px; padding: 8px 8px 10px; border: 0; border-radius: 12px; cursor: pointer; text-align: left;
  background: var(--surface-2); color: var(--ink-2); font: inherit; box-shadow: inset 0 0 0 1px var(--line);
  transition: transform 160ms cubic-bezier(.3,1.4,.5,1), box-shadow 160ms, color 160ms;
}
.scene canvas { display: block; width: 100%; aspect-ratio: 240 / 135; margin-bottom: 6px; border-radius: 6px; background: #000;
  box-shadow: inset 0 0 0 1px #2a2825; image-rendering: pixelated; }
.scene-name { font-size: 13px; font-weight: 600; }
.scene.is-pending canvas { background: linear-gradient(110deg, #0b0a09 30%, #1d1b18 50%, #0b0a09 70%) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.scene-meta { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.scene:hover { color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); transform: translateY(-2px); }
.scene:active { transform: translateY(0) scale(.98); }
.scene[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 0 0 2px var(--accent); }
.scene:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#scr-upload { display: inline-flex; align-items: baseline; gap: 10px; }
#scr-upload small { font-size: 12px; font-weight: 500; opacity: .72; font-variant-numeric: tabular-nums; }
#scr-upload small:empty { display: none; }
.clock-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.clock-row .btn { display: inline-flex; align-items: center; gap: 7px; }
.clock-row svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.clock-row p { flex: 1; min-width: 180px; margin: 0; font-size: 12.5px; color: var(--ink-3); }
.drop svg { width: 30px; height: 30px; margin-bottom: 6px; fill: none; stroke: var(--ink-3); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

.gallery-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 24px 0 10px; }
.gallery-head h3 { margin: 0; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
.gallery-head span { font-size: 12px; color: var(--ink-3); }
.gallery { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.tile {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 5px 6px; padding: 6px 7px 8px;
  border: 0; border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); text-align: left; cursor: pointer;
  transition: box-shadow 140ms, background 140ms, transform 160ms cubic-bezier(.2,.8,.2,1);
}
button.tile:hover:not(:disabled) { background: var(--surface-2); transform: translateY(-1px); }
.tile:disabled { opacity: .4; cursor: default; }
.tile-img {
  grid-column: 1 / -1; display: grid; place-items: center; aspect-ratio: 120 / 68; overflow: hidden; border-radius: 6px;
  background: #050505; box-shadow: inset 0 0 0 1px #24221f;
}
.tile:not(.has-img) .tile-img { background: repeating-linear-gradient(-45deg, #0a0908 0 4px, #0e0d0b 4px 8px); }
.tile-img img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.tile-img svg { width: 22px; height: 22px; fill: none; stroke: var(--ink-3); stroke-width: 1.4; stroke-linejoin: round; }
.tile-n { font-family: var(--serif); font-style: italic; font-size: 21px; line-height: .9; color: var(--ink); padding-left: 2px; }
.tile-at { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile[aria-checked="true"], .tile-anim.is-target { box-shadow: inset 0 0 0 2px var(--accent); }
.tile[aria-checked="true"] .tile-n, .tile-anim.is-target .tile-n { color: var(--accent); }
.tile-anim { cursor: default; }
.tile-anim .tile-n { font-size: 16px; }
.gallery-note { margin: 8px 0 0; font-size: 12px; color: var(--ink-3); }

.designer { display: grid; gap: 14px; }
.dz-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.dz-head h3 { margin: 0; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
.dz-head span { font-size: 12px; color: var(--ink-3); text-align: right; }
.dz-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.dz-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-radius: 11px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); animation: row-in 280ms both; animation-delay: calc(var(--j, 0) * 30ms);
  transition: box-shadow 140ms, background 140ms;
}
.dz-list li.is-sel { background: color-mix(in oklab, var(--accent) 7%, var(--surface)); box-shadow: inset 0 0 0 1.5px var(--accent); }
.dz-pick { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 7px 10px; border: 0; background: none; color: var(--ink); text-align: left; cursor: pointer; }
.dz-ico { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--surface-2); box-shadow: inset 0 -2px 0 rgba(0,0,0,.3); }
.dz-ico svg { width: 15px; height: 15px; fill: none; stroke: var(--ink-2); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.is-sel .dz-ico svg { stroke: var(--accent); }
.dz-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.dz-tag { flex: none; font-style: normal; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: color-mix(in oklab, var(--accent) 20%, transparent); color: color-mix(in oklab, var(--accent) 70%, white); }
.dz-x { width: 30px; height: 30px; margin-right: 4px; border: 0; border-radius: 8px; background: none; color: var(--ink-3); font-size: 16px; line-height: 1; cursor: pointer; }
.dz-x:hover { color: var(--ink); background: var(--surface-2); }
.dz-empty { font-size: 13px; }
.dz-add { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dz-edit { display: grid; gap: 11px; padding: 14px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); animation: row-in 220ms both; }
.dz-text {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2);
  color: var(--ink); font: 600 16px/1.3 var(--font);
}
.dz-text:focus { outline: none; border-color: var(--accent); }
.dz-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.dz-label { flex: none; width: 74px; font-size: 12px; color: var(--ink-3); }
.dz-l2 { width: auto; margin-left: 6px; }
.dz-range input { flex: 1; min-width: 110px; accent-color: var(--accent); }
.dz-range output { width: 3.2ch; text-align: right; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dz-fonts .f-serif { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 15px; }
.dz-fonts .f-mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.dz-align button, .dz-edit .seg button:has(svg) { display: inline-grid; place-items: center; padding: 6px 9px; }
.seg button:disabled { opacity: .35; cursor: default; }
.swatches-sm { flex-wrap: wrap; }
.swatches-sm button { width: 22px; height: 22px; }
.dz-bg .swatches button[aria-label="zwart"] { box-shadow: inset 0 0 0 1px var(--line-2); }
.dz-bg .swatches button[aria-label="zwart"][aria-checked="true"] { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 4px var(--ink); }
.dz-emoji { align-items: flex-start; }
.dz-char { width: 64px; flex: none; text-align: center; font-size: 22px; padding: 6px; }
.dz-emojis { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 0; }
.dz-emojis button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: var(--surface-2); font-size: 18px; line-height: 1; cursor: pointer; transition: transform 140ms cubic-bezier(.3,1.6,.5,1); }
.dz-emojis button:hover { transform: scale(1.08); }
.dz-emojis button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent); }
.dz-marq .toggle { margin-left: 0; color: var(--ink); }
.designer .toggle { margin-left: 0; }
.designer .toggle input:checked + .toggle-ui { background: var(--accent); }
.dz-hint { font-size: 12px; color: var(--ink-3); }
.steps-sm button { width: 28px; height: 26px; font-size: 11px; }

/* ---------- settings: battery + typing test ---------- */
.set-batt { align-content: start; }
.type-pad {
  display: flex; align-items: baseline; gap: 10px; padding: 16px 18px; border-radius: 14px; cursor: text; outline: none;
  background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow 200ms;
}
.type-pad b { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 44px; line-height: .9; font-variant-numeric: tabular-nums; }
.type-pad span { font-size: 13px; color: var(--ink-3); }
.type-pad.is-on { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px color-mix(in oklab, var(--accent) 12%, transparent); }
.type-pad.is-on::after { content: ''; align-self: center; width: 2px; height: 20px; margin-left: -4px; background: var(--accent); animation: caret 1.05s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.type-hint { display: grid; gap: 6px; margin: 0; padding: 10px 12px; border-radius: 10px; font-size: 13px; color: var(--warn); background: color-mix(in oklab, var(--warn) 8%, transparent); }
.type-hint .gate-link { justify-self: start; color: var(--ink); }
.type-actions { display: flex; gap: 8px; }
.set-card .type-actions .btn { justify-self: auto; padding: 10px 20px; }
.steps button.is-suggest { box-shadow: inset 0 0 0 2px var(--accent); animation: suggest 1.2s ease-in-out 2; }
@keyframes suggest { 50% { box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 5px color-mix(in oklab, var(--accent) 22%, transparent); } }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .bar { flex-wrap: wrap; gap: 12px; }
  .profiles { order: 3; margin-left: 0; }
  .board { transform: none; }
  #panel-keys:not([hidden]) { grid-template-columns: 1fr; }
  .scr { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; }
  .inspect { border-right: 0; padding-right: 0; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
  .tune-label { width: 100%; }
  .toggle { margin-left: 0; }
  .gate { position: relative; inset: auto; margin-top: -40px; background: none; backdrop-filter: none; }
  /* In the flow a faded gate would still take its height; here it simply goes. Desktop keeps the fade. */
  .gate[hidden] { display: none !important; }
  /* in the flow the gate sits right under the board, where the hint line would be */
  .stage:has(> .gate:not([hidden])) .hint { display: none; }
  .stage:has(> .gate:not([hidden])) .gate { margin-top: 8px; }
  .sub { display: none; }
  .key.is-mark .legend-t { transform: none; }
  .mac-cols { display: none; }
  .mac-rows li { grid-template-columns: 52px minmax(0, 1fr); gap: 2px 12px; }
  .mac-rows .mac-k { grid-row: span 2; }
  .mac-rows .mac-arrow { display: none; }
  .mac-rows .mac-now { font-size: 12px; }
  .mac-note { margin-left: 0; }
  .intro { grid-template-columns: 1fr; }
  .undo-t { display: none; }
  .tab-tool { padding: 6px 8px; }
  .shared { padding-left: 16px; flex-wrap: wrap; }
  .shared p { white-space: normal; }
  .profiles button.has-name, .profiles button.has-colour { max-width: 100px; }
  .dlg { padding: 20px; }
  .dlg h2 { font-size: 26px; }
  .imp-board { margin: 20px 8px 12px; }
  .slow-time b { font-size: 52px; }
  .slow-scr { width: 120px; }
  .keys-help > div { grid-template-columns: 1fr; gap: 6px; }
  .pname-sw { gap: 4px; }
  .pname-sw button { width: 16px; height: 16px; }
  .under { flex-direction: column; gap: 10px; }
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .paint-sep { display: none; }
  .paint-label { width: 100%; }
  .paint-head .btn-main { width: 100%; }
  .tools { width: 100%; }
  .tools button { flex: 1; justify-content: center; padding: 7px 6px; }
  .dz-head span { display: none; }
  .tabs-meta .meta-t { display: none; }
  .live-note { padding: 10px 16px; }
  .lib-list li { grid-template-columns: minmax(0, 1fr) auto auto; }
  .lib-units { display: none; }
  .scr-move { right: 14px; bottom: 14px; }
  /* Phone: the preview stays in view while you scroll through the designer. */
  .scr { gap: 0; }
  .scr-preview { display: contents; }
  .scr-frame { position: sticky; top: 8px; z-index: 4; padding: 8px; box-shadow: inset 0 0 0 2px #2a2825, 0 18px 30px -12px rgba(0,0,0,.9); }
  .scr-side { margin-top: 22px; }
  /* Patroon opslaan comes after the tools, where your thumb already is. */
  .paint { display: flex; flex-direction: column; }
  .paint-head { display: contents; }
  #paint-save { order: 3; margin-top: 16px; }
}

/* ---------- locks and notes ---------- */
/* During a screen upload the rest of the page is inert; read-only and unknown effects say why. */
.profiles, .plate, .panel, #gallery { transition: opacity 160ms ease; }
[inert], .is-locked { opacity: .5; }
.is-locked { pointer-events: none; }
.ro-note, .light-note, .macro-note {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--warn);
}
.ro-note { padding: 12px 22px; border-bottom: 1px solid var(--line); background: color-mix(in oklab, var(--warn) 7%, transparent); }
.light-note { margin-top: 14px; }
.macro-note { margin: 12px 0 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation: none !important; }
  .dlg::backdrop { backdrop-filter: none; }
  .run.is-indet .run-bar { width: 100%; opacity: .35; left: 0; }
  .board { transform: none; }
  [inert], .is-locked, .profiles, .plate, .panel, .drop, #gallery { transition: none; }
  .key .heat, .tile, .pchip, .kp, .pat, .scene { transition: none; }
  .scene:hover { transform: none; }
  .pat:hover { transform: none; }
  .type-pad.is-on::after { opacity: 1; }
}

/* ---------- live light: music and screen colour ---------- */
.fx button { position: relative; }
.fx-live {
  position: absolute; top: 14px; right: 16px; padding: 1px 6px; border-radius: 999px;
  font: 600 9.5px/1.5 var(--font); font-style: normal; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink); background: rgba(13,12,11,.72); box-shadow: inset 0 0 0 1px var(--line-2);
}
.live-card {
  margin-top: 16px; padding: 18px; border-radius: 14px; display: grid; gap: 14px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2);
  transition: box-shadow 300ms ease;
}
.live-card.is-on { box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 70%, var(--line-2)), 0 0 0 4px color-mix(in oklab, var(--accent) 10%, transparent); }
.live-head { display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.live-title { margin: 0; font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.live-tag { padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--warn); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--warn) 45%, transparent); }
.live-sub { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; max-width: 56ch; }
.live-head .btn { min-width: 96px; }
.live-range input[type="range"] { flex: 1 1 180px; max-width: 320px; accent-color: var(--accent); }
.live-chip { width: 28px; height: 28px; border-radius: 50%; background: #0b0a09; box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
.live-hint { font-size: 12.5px; color: var(--ink-3); }
.live-state { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
.live-card.is-on .live-dot { background: var(--accent); box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 22%, transparent); animation: pulse 1.6s ease-in-out infinite; }
.live-foot { margin: 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); }
.pchip-file { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.pchip-file input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pchip-file:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .live-card.is-on .live-dot { animation: none; } }

.pchip-file { position: relative; }

/* ---------- sliding tab underline, pointer light on the effect tiles ---------- */
.tabs { position: relative; }
.tabs [role="tab"][aria-selected="true"]::after { display: none; }
.tab-ink {
  position: absolute; left: 0; bottom: -1px; height: 2px; width: 0; border-radius: 2px; background: var(--accent);
  opacity: 0; pointer-events: none;
  transition: transform 420ms cubic-bezier(.2,.8,.2,1), width 420ms cubic-bezier(.2,.8,.2,1), background 600ms ease;
}
.tab-ink.is-set { opacity: 1; }
.fx button::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0;
  background: radial-gradient(140px circle at var(--mx, -200px) var(--my, -200px), rgba(255,255,255,.07), transparent 70%);
  transition: opacity 240ms ease;
}
.fx:hover button::after { opacity: 1; }
.podium-btn svg { width: 15px; height: 15px; fill: none; }
@media (prefers-reduced-motion: reduce) { .tab-ink { transition: none; } }
@media (hover: none) { .fx button::after { display: none; } }

/* ---------- podium: the way back ---------- */
.podium-exit {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60;
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border: 0; border-radius: 999px; cursor: pointer;
  font: 600 13px/1 var(--font); color: var(--ink-2); background: rgba(20,19,17,.72);
  box-shadow: inset 0 0 0 1px var(--line-2); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  opacity: .0; animation: podium-exit 5s ease forwards;
}
.podium-exit kbd { font: 600 11px/1 var(--font); padding: 3px 6px; border-radius: 5px; background: var(--surface-2); color: var(--ink-3); }
.podium-exit:hover, .podium-exit:focus-visible { opacity: 1 !important; color: var(--ink); animation: none; }
/* Shown on arrival, then it steps back so only the board is left; it returns on hover or focus. */
@keyframes podium-exit { 0%, 55% { opacity: .9; } 100% { opacity: .16; } }
@media (prefers-reduced-motion: reduce) { .podium-exit { animation: none; opacity: .6; } }
