:root {
  --bg: #0f1418; --panel: #172026; --panel2: #1e2a31; --line: #2c3b44; --ink: #e6eef0; --mut: #8ea3ab;
  --acc: #3fd0b8; --acc2: #f2a541; --warn: #ef6f6c;
  font: 13px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
body { display: grid; grid-template-rows: auto 1fr auto; height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
button, select, input { font: inherit; color: var(--ink); background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; min-height: 28px; }
button:active { background: var(--line); }
header { display: flex; gap: 6px; align-items: flex-end; padding: 4px 8px 0; border-bottom: 1px solid var(--line); }
header > select, header > button, header > b, header > span { margin-bottom: 4px; }
.logo { font-size: 15px; letter-spacing: .08em; color: var(--acc); margin-right: 4px; }
.grow { flex: 1; }
#version { color: var(--mut); font-size: 12px; }
#presetSel { max-width: 170px; }
nav { display: flex; gap: 2px; overflow-x: auto; }
nav button { border-radius: 6px 6px 0 0; border-bottom: 0; background: transparent; color: var(--mut); white-space: nowrap; }
nav button.on { background: var(--panel); color: var(--ink); }
main { overflow: auto; padding: 5px 8px; }
.page { display: none; gap: 8px; }
.page.on { display: flex; flex-wrap: wrap; align-items: flex-start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; display: flex; flex-direction: column; gap: 4px; }
.panel h3 { margin: 0; font-size: 12px; font-weight: 600; color: var(--mut); display: flex; gap: 6px; align-items: center; text-transform: uppercase; letter-spacing: .06em; }
.row { display: flex; gap: 4px; align-items: flex-end; flex-wrap: wrap; }
.knob { width: 50px; display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: ns-resize; touch-action: none; }
.knob canvas { width: 34px; height: 34px; }
.knob .lbl { font-size: 10.5px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50px; }
.knob .val { font-size: 10.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.knob.modded canvas { filter: drop-shadow(0 0 3px var(--acc2)); }
.sel { display: flex; flex-direction: column; gap: 1px; font-size: 10.5px; color: var(--mut); }
.sel select { font-size: 12px; padding: 2px 4px; min-height: 26px; }
.tog { width: 22px; height: 22px; min-height: 0; padding: 0; border-radius: 50%; }
.tog.on { background: var(--acc); border-color: var(--acc); }
canvas.scope { background: #0b1013; border: 1px solid var(--line); border-radius: 6px; width: 150px; height: 60px; }
canvas.envc { background: #0b1013; border: 1px solid var(--line); border-radius: 6px; width: 200px; height: 44px; }
/* matrix */
#matrix { border-collapse: collapse; font-size: 11.5px; }
#matrix th { font-weight: 500; color: var(--mut); padding: 2px 4px; white-space: nowrap; }
#matrix th.src { writing-mode: vertical-rl; transform: rotate(180deg); height: 64px; }
#matrix td { padding: 1px; }
#matrix td.cell { width: 34px; height: 22px; text-align: center; border: 1px solid var(--line); background: #0b1013; cursor: ns-resize; touch-action: none; font-variant-numeric: tabular-nums; }
#matrix td.cell.pos { color: var(--acc); } #matrix td.cell.neg { color: var(--acc2); }
#matrix td.name { white-space: nowrap; padding-right: 6px; }
footer { display: flex; gap: 6px; align-items: stretch; padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); height: 74px; }
.strips { display: flex; gap: 4px; }
.strip { width: 30px; background: #0b1013; border: 1px solid var(--line); border-radius: 6px; position: relative; touch-action: none; display: flex; align-items: flex-start; justify-content: center; }
.strip span { font-size: 9px; color: var(--mut); margin-top: 2px; }
.strip i { position: absolute; left: 3px; right: 3px; height: 4px; background: var(--acc); border-radius: 2px; }
#octDown, #octUp { width: 30px; padding: 0; }
#kbd { flex: 1; position: relative; touch-action: none; }
#kbd .k { position: absolute; border: 1px solid #0b1013; border-radius: 0 0 4px 4px; }
#kbd .w { background: #dfe7ea; top: 0; bottom: 0; }
#kbd .b { background: #1b2328; top: 0; height: 58%; z-index: 1; }
#kbd .w.down { background: var(--acc); } #kbd .b.down { background: #2a8f80; }
#kbd .c { position: absolute; bottom: 2px; left: 3px; font-size: 9px; color: #5b6b72; }
#start { position: fixed; inset: 0; background: rgba(8, 12, 14, .82); display: grid; place-items: center; z-index: 5; }
#start button { font-size: 18px; padding: 14px 26px; background: var(--acc); color: #062520; border: 0; }
dialog { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; max-width: min(640px, 94vw); max-height: 88dvh; }
dialog table { border-collapse: collapse; font-size: 12px; }
dialog td, dialog th { padding: 2px 8px 2px 0; text-align: left; vertical-align: top; }
dialog menu { display: flex; gap: 8px; justify-content: flex-end; padding: 0; margin: 10px 0 0; }
.note { color: var(--mut); font-size: 12px; }
