:root {
  --bg: #0f1216; --panel: #181d23; --panel2: #1f262e; --line: #2a333d;
  --text: #e9eef3; --muted: #8b97a4; --accent: #ff7ab6; --err: #ff6b6b;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
       font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- layout: sampler left, mocap right ---------- */
#app { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; height: 100vh; }
#sampler { display: flex; flex-direction: column; gap: 12px; padding: 18px 16px; overflow-y: auto;
           border-right: 1px solid var(--line); background: var(--panel); }
#mocap { display: flex; align-items: center; justify-content: center; padding: 16px; min-width: 0; }
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; }
  #mocap { order: -1; padding: 12px 16px 0; }
  #sampler { border-right: 0; }
}

header h1 { margin: 0; font-size: 22px; letter-spacing: .01em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.status { margin: 6px 0 0; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 6px; }
.hint { color: var(--muted); font-size: 12px; }
.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; align-self: flex-start; }
.ghost:disabled { opacity: .4; cursor: default; }

/* ---------- sound boxes ---------- */
#boxes { display: grid; gap: 10px; }
.box { --c: #888; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 10px;
       transition: border-color .15s, opacity .15s; position: relative; overflow: hidden; }
.box.off { opacity: .55; }
.box.on { border-color: color-mix(in srgb, var(--c) 55%, var(--line)); }
.box::after { content: ""; position: absolute; inset: 0; background: var(--c); opacity: 0; pointer-events: none; transition: opacity .35s ease-out; }
.box.hit::after { opacity: .22; transition: none; }
.box .top { display: flex; align-items: center; gap: 10px; }
.box .name { font-weight: 700; font-size: 16px; }
.box .name .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: 1px; }
.box .how { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.box .stats { margin-left: auto; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.35; }
.box .stats b { color: var(--text); font-weight: 600; }
.box canvas { display: block; width: 100%; height: 46px; margin-top: 6px; border-radius: 6px; background: #12161b; }
.box .marker { color: var(--muted); font-size: 11px; margin-top: 4px; letter-spacing: .02em; }

/* switch */
.switch { flex: 0 0 auto; width: 44px; height: 26px; border-radius: 13px; border: 0; padding: 0; background: #3a4450; position: relative; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--c); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- mocap stage ---------- */
.stage { position: relative; width: min(100%, calc((100vh - 32px) * var(--ar, 1.3333))); aspect-ratio: var(--ar, 4 / 3);
         background: #000; border-radius: 14px; overflow: hidden; }
@media (max-width: 860px) { .stage { width: 100%; } }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stageMsg { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: #000a; color: #fff;
            padding: 10px 16px; border-radius: 10px; font-size: 15px; text-align: center; max-width: 90%; }
.stageMsg .bar { height: 4px; background: #fff3; border-radius: 2px; margin-top: 8px; overflow: hidden; }
.stageMsg .bar i { display: block; height: 100%; width: 0; background: var(--accent); }

/* ---------- onboarding ---------- */
.onboard { position: fixed; inset: 0; background: #0b0e12e6; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; backdrop-filter: blur(4px); }
.card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.card h2 { margin: 0 0 8px; font-size: 24px; }
.card p { margin: 0 0 14px; color: #c9d2db; line-height: 1.45; font-size: 15px; }
.steps { margin: 0 0 18px; padding: 0; list-style: none; display: grid; gap: 7px; font-size: 14px; color: var(--muted); }
.steps li { display: flex; gap: 10px; align-items: baseline; }
.steps li::before { content: "○"; width: 14px; flex: 0 0 14px; text-align: center; }
.steps li.doing { color: var(--text); }
.steps li.doing::before { content: "◌"; display: inline-block; animation: spin 1s linear infinite; }
.steps li.done { color: var(--text); }
.steps li.done::before { content: "✓"; color: #4fd69c; }
.steps li.fail { color: var(--err); }
.steps li.fail::before { content: "✕"; }
@keyframes spin { to { transform: rotate(360deg); } }
.big { width: 100%; background: var(--accent); color: #1a0d14; border: 0; border-radius: 10px; padding: 14px; font-size: 17px; font-weight: 700; }
.big:disabled { opacity: .5; cursor: wait; }
.err { color: var(--err) !important; font-size: 14px !important; margin: 12px 0 0 !important; min-height: 1em; }
