* { box-sizing: border-box; }
/* Dark shell with light picture panels, after the web setting pages of keyboards. */
:root {
  color-scheme: dark;
  --bg: #1a1a1c; --side: #232326; --card: #2a2a2e; --text: #ececf1; --muted: #a4a4b0; --line: #3d3d44; --field: #1f1f22;
  --btn: #3a3a41; --accent: #5c6ac4; --accent-text: #ffffff; --title: #9aa5ee; --focus: #9aa6ff; --reset: #b5403a;
  --ok: #4cc06b; --err: #ff7b6e; --hit: #e0574d;
  --req-bg: #45201d; --req: #ffb3aa; --rec-bg: #3e3115; --rec: #f2c766; --opt-bg: #35353b; --opt: #c8c8d2;
  --drum-bg: #272c4d; --drum: #aab4ff; --active: #3e3115;
}
.stage {
  color-scheme: light;
  --card: #ffffff; --text: #1b1d22; --muted: #565d6b; --line: #cfd3dd; --field: #ffffff; --btn: #ffffff; --focus: #2a3bb0;
  --err: #b42318; --req-bg: #fde7e5; --req: #a1201a; --opt-bg: #e4e7ee; --opt: #4b5260; --drum-bg: #e3e8fb; --drum: #3a4aa0;
}
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 system-ui, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; }
h2 { margin: 0; padding: 10px 0; color: var(--title); font-size: 1.05rem; }
p { margin: 8px 0; }
button, input, select { font: inherit; color: inherit; }
button { padding: 7px 14px; border: 1px solid transparent; border-radius: 8px; background: var(--btn); color: var(--text); cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
button.reset { background: var(--reset); color: #ffffff; }
button:disabled { opacity: 0.45; cursor: default; }
input[type="number"], input[type="text"], select { width: 100%; min-width: 0; max-width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); }
input:disabled, select:disabled { opacity: 0.6; }
input.switch { appearance: none; position: relative; flex: none; width: 46px; height: 24px; margin: 0; border-radius: 7px; background: #4c4c55; cursor: pointer; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 5px; background: var(--bg); transition: left 0.12s; }
input.switch:checked { background: var(--accent); }
input.switch:checked::after { left: 25px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.defs { position: absolute; }

.app { display: grid; grid-template-columns: 190px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; display: flex; flex-direction: column; gap: 18px; height: 100vh; padding: 24px 16px; background: var(--side); }
.brand b { display: block; font-size: 1.35rem; letter-spacing: -0.01em; }
.brand span, .now .label { color: var(--muted); font-size: 0.85rem; }
.conn { display: flex; flex-direction: column; gap: 8px; }
.mode { margin: 2px 0 0; font-weight: 600; }
main { width: 100%; max-width: 900px; margin: 0 auto; padding: 16px 20px 40px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: #0d0d0f; overflow-x: auto; }
.tabs button { flex: 1 0 auto; padding: 9px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tabs button:hover:not(:disabled) { color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--accent); color: #ffffff; }
.banner { margin: 12px 0; padding: 9px 14px; border-radius: 10px; background: var(--side); }
.banner.error, .error { color: var(--err); }
.stage { margin: 12px 0; padding: 14px 16px; border-radius: 14px; background: #f1f2f6; color: var(--text); }
.stage.two { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 24px; }
.stage-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.panel { margin: 12px 0; padding: 4px 18px 14px; border-radius: 14px; background: var(--card); }
.empty { margin: 12px 0; padding: 48px 16px; border-radius: 14px; background: var(--card); color: var(--muted); text-align: center; }
#usb-panel:not([hidden]) + .empty { display: none; }
.set-row { display: grid; grid-template-columns: 190px minmax(0, 1fr) auto; align-items: center; gap: 6px 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.set-name { font-weight: 600; }
.set-desc { color: var(--muted); font-size: 0.87rem; }
.set-row select { width: auto; min-width: 180px; }
.set-row input[type=number] { width: 90px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.actions { margin-top: 14px; }
.unit { color: var(--muted); font-weight: normal; font-size: 0.85rem; }
.field { display: flex; flex-direction: column; gap: 4px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 8px 0; }
.hint { color: var(--muted); font-size: 0.87rem; }
.knob-read { align-items: center; margin-bottom: 0; }
.notice { width: min(420px, calc(100vw - 32px)); padding: 8px 20px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); }
.notice::backdrop { background: rgba(0, 0, 0, 0.7); }
.notice .actions { justify-content: flex-end; }
.device { margin: 0; font-weight: 600; }

/* Pictures: the drum with its gains, the board from above and the mode switch. */
.gain-drum { flex: 1 1 320px; min-width: 0; max-width: 500px; height: auto; }
.gain-drum .rim { fill: #dbe5fb; stroke: #3d5fc4; stroke-width: 2; }
.gain-drum .skin { fill: #f8dedb; stroke: #c2473f; stroke-width: 2; }
.gain-drum .lead { stroke: #9aa0b2; stroke-width: 1.5; }
.gain-drum .name { fill: var(--muted); font-size: 12.5px; }
.gain-drum .value { fill: var(--text); font-size: 24px; font-weight: 700; }
.gain-drum .keycap { fill: #5c6ac4; }
.gain-drum .keytext { fill: #ffffff; font-size: 13px; font-weight: 700; }
.board { flex: 0 1 290px; width: 290px; min-width: 0; max-width: 100%; height: auto; }
.b-plate { fill: #e2e5ed; stroke: #9aa0b2; stroke-width: 0.5; }
.b-hole circle { fill: #f6f7fa; stroke: #9aa0b2; stroke-width: 0.4; }
.b-part, .b-vol rect { fill: #c3c8d6; stroke: #8a90a3; stroke-width: 0.4; }
.b-vol circle { fill: #eef0f6; stroke: #8a90a3; stroke-width: 0.4; }
.b-label { fill: #4b5263; font-size: 4.3px; }
.b-knob rect { fill: var(--knob-fill, #c3c8d6); stroke: var(--knob-line, #8a90a3); stroke-width: 0.4; }
.b-knob text { fill: var(--knob-text, #4b5263); font-size: 4.2px; font-weight: 700; }
.b-dip rect { fill: var(--dip-fill, #c3c8d6); stroke: var(--dip-line, #8a90a3); stroke-width: 0.4; }
.b-dip path { fill: none; stroke: var(--dip-mark, #6b7186); stroke-width: 1.1; stroke-linecap: round; }
.board.hl-knob { --knob-fill: #5c6ac4; --knob-line: #3c4796; --knob-text: #ffffff; }
.board.hl-dip { --dip-fill: #c2473f; --dip-line: #8c2620; --dip-mark: #ffffff; }
.dip-box { flex: 1 1 280px; max-width: 360px; text-align: center; }
.dip { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto; }
.dip-body { fill: #c2473f; }
.dip-on { fill: #ffffff; font-size: 13px; font-weight: 700; }
.dip-sw { outline: none; }
.dip-sw.site { cursor: pointer; }
.dip-sw.site .knob { fill: #c9d0ff; stroke: #3c4796; stroke-width: 2; }
.dip.idle { opacity: 0.45; }
.dip-sw .slot { fill: #7d2620; }
.dip-sw .knob { fill: #ffffff; transform: translateY(36px); transition: transform 0.15s; }
.dip-sw.on .knob { transform: none; }
.dip-sw:focus-visible .slot { stroke: var(--focus); stroke-width: 3; }
.dip-sw .num { fill: var(--text); font-size: 15px; font-weight: 700; text-anchor: middle; }
.dip-sw .what { fill: var(--muted); font-size: 12px; text-anchor: middle; }
.dip-sw.on .what { fill: #3c4796; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .dip-sw .knob, input.switch::after { transition: none; } }
.dip-mode { margin: 2px 0 8px; font-size: 1.15rem; font-weight: 700; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.badge.required { background: var(--req-bg); color: var(--req); }
.badge.recommended { background: var(--rec-bg); color: var(--rec); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { padding: 6px 16px; border: 0; border-radius: 0; background: transparent; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #ffffff; font-weight: 600; }
.picture svg { display: block; width: 100%; max-width: 580px; height: auto; margin: 6px auto; touch-action: manipulation; }
.picture .art { fill: var(--opt-bg); stroke: var(--line); stroke-width: 1.5; }
.picture .art.deep { fill: var(--line); stroke: none; }
.pad-btn { cursor: pointer; outline: none; }
.pad-btn .shape { fill: var(--card); stroke: var(--text); stroke-width: 1.5; }
.pad-btn text { fill: var(--text); font-weight: 600; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.pad-btn text.sub { fill: var(--muted); font-weight: normal; }
.pad-btn[data-kind="drum"] .shape { fill: var(--drum-bg); stroke: var(--drum); }
.pad-btn[data-kind="drum"] text.name { fill: var(--drum); }
.pad-btn.missing .shape { fill: var(--req-bg); stroke: var(--err); stroke-dasharray: 4 3; }
.pad-btn.missing text.name { fill: var(--req); }
.pad-btn.down .shape { fill: var(--hit); stroke: var(--hit); stroke-dasharray: none; }
.pad-btn.down text.name, .pad-btn.down text.sub { fill: #ffffff; }
.pad-btn.selected .shape, .pad-btn:focus-visible .shape { stroke: var(--focus); stroke-width: 3.5; stroke-dasharray: none; }
.pad-btn .tag rect { fill: var(--text); }
.pad-btn .tag text { fill: var(--card); }
.picture.waiting .pad-btn.selected .shape { animation: usb-wait 0.7s ease-in-out infinite alternate; }
@keyframes usb-wait { to { stroke-opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .picture.waiting .pad-btn.selected .shape { animation: none; } }
.picture.locked .pad-btn { cursor: default; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-bottom: 0; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.key { display: inline-block; width: 14px; height: 14px; border: 1.5px solid var(--text); border-radius: 4px; font-style: normal; }
.key.tag { width: auto; padding: 0 5px; border: 0; border-radius: 999px; background: var(--text); color: var(--card); font-size: 0.7rem; font-weight: 600; line-height: 14px; }
.key.drum { background: var(--drum-bg); border-color: var(--drum); }
.key.missing { background: var(--req-bg); border-color: var(--err); border-style: dashed; }
.key.down { background: var(--hit); border-color: var(--hit); }
.pick { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--focus); border-radius: 10px; }
.pick-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.pick-title b { font-size: 1.05rem; }
.pick-title .use { color: var(--muted); font-size: 0.87rem; }
.pick select { width: auto; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; }
.chip { padding: 2px 10px; border-color: transparent; border-radius: 999px; background: var(--opt-bg); color: var(--opt); font-size: 0.87rem; }

details { margin-top: 12px; }
details > summary { color: var(--muted); cursor: pointer; }
details > :not(summary) { margin-top: 8px; }

table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
thead th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
.timing { table-layout: fixed; border-top: 1px solid var(--line); }
.timing tbody th { font-weight: normal; }
.table-wrap { overflow-x: auto; }
.mapping td[data-kind="required"]::after, .mapping td[data-kind="recommended"]::after, .mapping td[data-kind="drum"]::after {
  display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.mapping td[data-kind="required"]::after { content: "필수"; background: var(--req-bg); color: var(--req); }
.mapping td[data-kind="recommended"]::after { content: "권장"; background: var(--rec-bg); color: var(--rec); }
.mapping td[data-kind="drum"]::after { content: "북과 겹침"; background: var(--drum-bg); color: var(--drum); }
.usb-active { background: var(--active); font-weight: 600; }
.invalid { outline: 2px solid var(--err); outline-offset: 0; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; font-size: 0.88rem; overflow-wrap: anywhere; }
dd { margin: 0; }
.state { font-size: 0.88rem; }
.state div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 2px 0; border-bottom: 1px dashed var(--line); }
[hidden] { display: none !important; }
@media (max-width: 760px) {
  .app { display: block; }
  .side { position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 16px; height: auto; padding: 12px 16px; }
  .conn { flex-direction: row; }
  .now { flex: 1 1 100%; }
  main { padding: 12px 16px 32px; }
}
@media (max-width: 520px) {
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
  .set-row { grid-template-columns: minmax(0, 1fr) auto; }
  .set-desc { grid-column: 1 / -1; order: 3; }
}

/* Input test: lanes over the drum, hits rise in their lane; the list beside it. */
.stage.input-test { display: flex; flex-wrap: wrap; align-items: stretch; justify-content: center; gap: 12px 28px; }
.input-view { flex: 0 1 300px; width: 300px; max-width: 100%; height: auto; }
.input-view .lane { fill: var(--opt-bg); opacity: 0.55; }
.input-view .in-face { stroke: var(--card); stroke-width: 1.5; transition: fill 0.3s ease-out; }
.input-view .in-face.don { fill: #f3c9c4; }
.input-view .in-face.ka { fill: #c5d8f1; }
.input-view .in-face.on { transition: none; }
.input-view .in-face.don.on, .input-view .bar.don { fill: #e0452f; }
.input-view .in-face.ka.on, .input-view .bar.ka { fill: #2f7fd6; }
.input-log { flex: 1 1 250px; min-width: 230px; max-width: 420px; display: flex; flex-direction: column; }
.input-log h2 { color: var(--text); }
.input-scroll { flex: 1 1 auto; height: 440px; max-height: 60vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.input-scroll table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.input-scroll th { position: sticky; top: 0; background: var(--card); color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.input-scroll th, .input-scroll td { padding: 4px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.input-scroll th:nth-child(2), .input-scroll td:nth-child(2) { text-align: left; }
.input-scroll td:nth-child(2) { padding-top: 2px; padding-bottom: 2px; }
/* Advanced view of the input list: the note column and the faces that were not sent out. */
.input-advanced { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.87rem; }
.input-buttons { display: inline-flex; gap: 8px; }
.input-scroll .note, .input-scroll tr.miss { display: none; }
.input-log.advanced { max-width: 600px; }
.input-log.advanced .input-scroll .note { display: table-cell; text-align: left; white-space: normal; color: var(--muted); }
.input-log.advanced .input-scroll tr.miss { display: table-row; color: var(--muted); }
.input-scroll tr.miss .face-mark .on { fill: #9aa0a6; }
.face-mark { display: block; width: 26px; height: 26px; }
.face-mark path { fill: var(--opt-bg); }
.face-mark .don.on { fill: #e0452f; }
.face-mark .ka.on { fill: #2f7fd6; }
@media (prefers-reduced-motion: reduce) { .input-view .in-face { transition: none; } }
