:root {
  --bg: #15171a;
  --panel: #1d2024;
  --panel-2: #24282d;
  --line: #31363c;
  --text: #e8eaed;
  --muted: #9aa1a9;
  --accent: #ff7a1a;
  --accent-dim: #8a4512;
  --ok: #3ddc84;
  --danger: #ff5b5b;
  color-scheme: dark;
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); display: flex; flex-direction: column; overflow: hidden; }
body.busy { cursor: progress; }
h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 10px; }

button, select, input[type="number"], input:not([type]) {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
}
button { padding: 6px 12px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }
button.active { background: var(--accent-dim); border-color: var(--accent); }
select, input[type="number"], input:not([type]) { padding: 5px 8px; }
input[type="range"] { accent-color: var(--accent); width: 100%; margin: 0; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 800; letter-spacing: 0.12em; }
.brand span { font-weight: 400; color: var(--muted); letter-spacing: 0.04em; }
.brand .beta { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #111; background: var(--accent); border-radius: 4px; padding: 2px 6px; margin: 0 4px; vertical-align: 2px; }
.github { color: var(--muted); text-decoration: none; font-size: 13px; }
.github:hover { color: var(--text); text-decoration: underline; }
.device { color: var(--muted); }
.spacer { flex: 1; }
.status { color: var(--muted); font-size: 13px; }

.main { flex: 1; display: grid; grid-template-columns: 300px 1fr; min-height: 0; }
.main.disconnected .sidebar .panel:not(:first-child) { display: none; }
.sidebar { border-right: 1px solid var(--line); overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }

.banks { display: flex; flex-direction: column; gap: 4px; }
.bank-label { font-size: 11px; color: var(--muted); margin: 8px 0 2px; text-transform: uppercase; letter-spacing: 0.06em; }
.slot { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 7px 10px; background: transparent; border: 1px solid transparent; border-radius: 6px; }
.slot:hover { background: var(--panel-2); }
.slot.current { background: var(--panel-2); border-color: var(--accent); }
.slot-no { width: 18px; color: var(--muted); font-variant-numeric: tabular-nums; }
.slot-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--accent-dim); color: var(--text); margin-left: 8px; vertical-align: middle; font-weight: 500; }
.preset-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.undo { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.undo[hidden] { display: none; }
.undo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.tuner-display { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 10px; }
.note { font-size: 34px; font-weight: 700; height: 44px; color: var(--muted); }
.note.in-tune { color: var(--ok); }
.meter { position: relative; width: 100%; height: 18px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); }
.meter .zone { position: absolute; left: 46%; width: 8%; top: 0; bottom: 0; background: rgba(61, 220, 132, 0.25); }
.needle { position: absolute; top: -3px; bottom: -3px; width: 3px; margin-left: -1px; background: var(--accent); border-radius: 2px; transition: left 0.1s linear; }
.needle.in-tune { background: var(--ok); }
.needle.hidden { visibility: hidden; }
.row { display: flex; align-items: center; gap: 10px; }
.hint { color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.field { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; margin: 8px 0; }
.field select, .field input { color: var(--text); font-size: 14px; }

.editor { overflow-y: auto; padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 18px; }
.welcome { margin: auto; max-width: 460px; text-align: center; color: var(--muted); }
.welcome h1 { color: var(--text); margin-bottom: 10px; }
.welcome .hint { margin-top: 28px; }
.welcome .hint + .hint { margin-top: 10px; }
.welcome a { color: var(--accent); }
.preset-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.preset-header .sub { color: var(--muted); margin-top: 4px; }
.tempo { display: flex; align-items: center; gap: 8px; }
.tempo label { color: var(--muted); }
.tempo input { width: 72px; }

.amp-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; display: grid; grid-template-columns: 260px 1fr; grid-template-areas: "art knobs" "head knobs" "character knobs"; gap: 14px 28px; }
.amp-panel .amp-art { grid-area: art; width: 100%; height: auto; }
.amp-head { grid-area: head; }
.amp-name { font-size: 18px; font-weight: 600; }
.cat { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.knobs { grid-area: knobs; display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; align-self: center; }
.knob { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.knob .plabel { font-weight: 600; letter-spacing: 0.06em; font-size: 12px; }
.knob .pvalue { font-variant-numeric: tabular-nums; color: var(--muted); }
.character { grid-area: character; display: flex; flex-direction: column; gap: 10px; }
.segmented { display: flex; flex-direction: column; gap: 4px; }
.segmented .plabel { color: var(--muted); font-size: 12px; }
.segments { display: flex; }
.segments button { flex: 1; border-radius: 0; margin-left: -1px; padding: 5px 4px; }
.segments button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.segments button:last-child { border-radius: 0 6px 6px 0; }

.chain { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.block { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.block.off { opacity: 0.55; }
.block.selected { border-color: var(--accent); }
.amp-block { justify-content: center; background: var(--panel-2); }
.amp-block .amp-art { width: 100%; max-width: 170px; height: auto; align-self: center; }
.pedal-art { display: block; width: 64px; height: 96px; margin: 2px auto; }
.block-head { display: flex; align-items: center; gap: 8px; }
.block-head .cat { flex: 1; }
.moves button { padding: 0 8px; font-size: 16px; line-height: 22px; }
.power { width: 22px; height: 22px; padding: 0; border-radius: 50%; background: var(--panel-2); position: relative; }
.power::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--line); }
.power.on::after { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.model-select { width: 100%; font-weight: 600; }
.params { display: flex; flex-direction: column; gap: 8px; }
.param { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "label value" "control control"; gap: 2px 8px; font-size: 12px; }
.param .plabel { grid-area: label; color: var(--muted); }
.param .pvalue { grid-area: value; font-variant-numeric: tabular-nums; }
.param input, .param select { grid-area: control; }
.param.choice { grid-template-areas: "label control"; align-items: center; }
.param.choice select { grid-area: control; font-size: 12px; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: 420px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.slot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.slot-grid .slot { border: 1px solid var(--line); }
.slot-grid .slot.chosen { border-color: var(--accent); background: var(--panel-2); }
.warning { color: var(--muted); min-height: 20px; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 8px; max-width: 420px; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4); }
.toast.error { border-left-color: var(--danger); }

main.selftest { flex: 1; overflow-y: auto; padding: 20px 24px; color: var(--muted); max-width: 980px; }
main.selftest pre { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; color: var(--text); font-size: 12px; white-space: pre-wrap; min-height: 200px; }
