/* VUM Controller — dark game-room theme */
:root {
  --bg: #070b14;
  --panel: #0e1627;
  --panel-2: #142036;
  --panel-3: #1a2945;
  --border: #203050;
  --border-2: #2c3f66;
  --text: #e8eef8;
  --muted: #8d9bb7;
  --dim: #5b6a88;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(1100px 520px at 75% -12%, #1b1442 0%, transparent 62%), var(--bg);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
a { color: #93c5fd; }
h1, h2 { margin: 0; }
h2 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.okc { color: var(--warn); }
code { background: var(--panel-3); border-radius: 5px; padding: 1px 5px; font-size: 12px; word-break: break-word; }
.spacer { flex: 1; }

/* ---------- icons ---------- */
.ico { width: 1em; height: 1em; flex: none; vertical-align: -0.14em; }
.btn .ico { width: 15px; height: 15px; }
.btn.small .ico { width: 13px; height: 13px; }
.icon-btn .ico { width: 17px; height: 17px; }

/* ---------- basic controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 9px;
  padding: 7px 13px; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text);
  transition: background .15s, border-color .15s, filter .15s;
}
.btn:hover { background: var(--panel-3); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.primary { background: linear-gradient(135deg, #7c3aed, #4f46e5); border-color: transparent; color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel-3); }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn.live { background: linear-gradient(135deg, #dc2626, #b91c1c); border-color: transparent; color: #fff; animation: live 1.8s ease-in-out infinite; }
@keyframes live { 50% { box-shadow: 0 0 16px rgba(220, 38, 38, .6); } }
.icon-btn {
  display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; padding: 0;
  background: none; border: 0; border-radius: 8px; color: var(--muted); cursor: pointer; list-style: none;
}
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:hover { color: var(--text); background: var(--panel-3); }
.icon-btn.on { color: var(--accent-2); background: var(--panel-3); }
.icon-btn.boxed { width: 34px; height: 34px; border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text); }
.icon-btn.boxed:hover { background: var(--panel-3); }
.select, .text {
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 8px;
  padding: 6px 8px; max-width: 100%; min-width: 0;
}
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 1px; }
input[type="range"] { accent-color: var(--accent); cursor: pointer; }

/* segmented choice */
.seg { display: flex; gap: 3px; padding: 3px; border-radius: 10px; background: var(--panel); border: 1px solid var(--border); }
.seg button {
  flex: 1; min-width: 0; padding: 6px 8px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-2); font-weight: 600; }

/* switch */
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { position: relative; flex: none; width: 34px; height: 20px; border-radius: 10px; background: var(--panel-3); transition: background .15s; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .switch-ui { background: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(14px); background: #fff; }
.switch input:focus-visible + .switch-ui { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); }

/* progress bars, live dots */
.prog { display: inline-block; vertical-align: middle; width: 110px; height: 5px; border-radius: 3px; background: var(--panel-3); overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: #f87171; }
.live-dot { display: inline-block; flex: none; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: currentColor; animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }
.rec { color: #f87171; font-weight: 600; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 18px; background: rgba(7, 11, 20, .88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: .4px; font-size: 15px; margin-right: 10px; white-space: nowrap; }
.brand b { font-weight: 500; color: var(--muted); }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px; position: relative;
  background: conic-gradient(from 210deg, var(--accent), var(--accent-2), var(--accent));
  box-shadow: 0 0 16px rgba(139, 92, 246, .55);
}
.brand-mark::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--bg); }
.profile-picker { display: flex; align-items: center; gap: 6px; min-width: 0; }
.profile-picker .select { max-width: 240px; height: 34px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; white-space: nowrap; cursor: pointer; list-style: none;
  padding: 0 12px; height: 34px; border-radius: 999px; border: 1px solid var(--border-2); color: var(--muted);
}
.pill::-webkit-details-marker { display: none; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.pill:hover { color: var(--text); }
.pill.online { color: var(--text); }
.pill.online::before { background: var(--good); box-shadow: 0 0 8px var(--good); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.level-btn {
  display: inline-flex; align-items: center; gap: 9px; height: 34px; padding: 0 11px; cursor: pointer;
  border-radius: 9px; border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text); font-size: 12.5px;
}
.level-btn:hover { background: var(--panel-3); }
.level-btn.attn { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.meter { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.meter i { width: 3px; border-radius: 1.5px; background: var(--panel-3); transition: background .06s; }
.meter i.on { background: var(--good); }
.meter i.on.quiet { background: #64748b; }
.meter i.on.hot { background: var(--warn); }
.meter i.gate { background: rgba(251, 191, 36, .4); }
#mic-btn .short { display: none; }
.session-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.session-code {
  padding: 6px 12px; border-radius: 8px; background: var(--panel-3); border: 1px solid var(--border-2);
  font: 700 19px ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 3px; color: var(--text);
}
.pop-sep { height: 1px; margin: 2px 0; background: var(--border); }

/* popovers */
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 180px;
  display: flex; flex-direction: column; padding: 6px;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
}
.menu.right .menu-pop { left: auto; right: 0; }
.menu-pop > button { text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 7px; cursor: pointer; }
.menu-pop > button:hover { background: var(--panel-3); }
.menu-pop .danger { color: #fca5a5; }
.menu-pop.wide { width: 330px; padding: 14px; gap: 10px; font-size: 13px; }
.pop-title { font-weight: 700; }
.pop-list { margin: 0; padding-left: 18px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.pop-list b { color: var(--text); }
.menu-pop.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.menu-pop.form .select { width: 100%; color: var(--text); }
.slider-row { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.slider-row input { flex: 1; }
.menu-pop .btn { align-self: flex-start; }

/* ---------- layout ---------- */
.app {
  display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start;
  max-width: 1600px; margin: 0 auto; padding: 16px 18px 40px;
}
@media (max-width: 1100px) { .app { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.stage { min-width: 0; }

.game-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.game-icon {
  flex: none; width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 11px; color: var(--accent-2);
}
.game-icon .ico { width: 22px; height: 22px; }
.game-head h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#guide-menu .menu-pop { width: 360px; }

/* ---------- scene ---------- */
.scene-wrap {
  position: relative; height: calc(100vh - 140px); min-height: 380px; max-height: 860px; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: radial-gradient(ellipse at 50% 120%, #14214a 0%, #080d1a 70%);
}
.scene-wrap canvas { display: block; width: 100%; height: 100%; }
.hud {
  position: absolute; top: 12px; left: 12px; min-width: 190px; max-width: 45%;
  padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border-2);
  background: rgba(12, 18, 34, .84); backdrop-filter: blur(6px);
}
.hud-gesture { display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; }
.hud-gesture i { flex: none; width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--border-2); box-shadow: 0 0 10px currentColor; }
.hud-gesture b { overflow: hidden; text-overflow: ellipsis; }
.hud-gesture span { font-size: 12px; }
.hud-bar { height: 4px; margin-top: 6px; background: var(--panel-3); border-radius: 2px; overflow: hidden; }
.hud-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7c3aed, #22d3ee); transition: width .12s linear; }
.hud-score { position: absolute; top: 14px; right: 16px; font-weight: 650; font-size: 14px; font-variant-numeric: tabular-nums; text-shadow: 0 1px 6px #000; text-align: right; white-space: pre; }
.teach-banner {
  --c: #dc2626;
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); min-width: 280px; text-align: center;
  padding: 16px 24px; border-radius: 16px; border: 1px solid var(--c);
  background: rgba(10, 15, 30, .92); box-shadow: 0 0 50px color-mix(in srgb, var(--c) 35%, transparent);
}
.tb-kicker { display: inline-flex; align-items: center; color: #fca5a5; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.tb-title { font-size: 20px; margin: 4px 0 12px; }
.tb-title b { color: var(--c); }
.tb-prog { height: 6px; border-radius: 3px; background: var(--panel-3); overflow: hidden; }
.tb-prog i { display: block; height: 100%; width: 0; background: var(--c); }

/* ---------- recognition test ---------- */
.drill { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(5, 8, 16, .66); backdrop-filter: blur(3px); }
.drill-card {
  --c: var(--accent);
  width: min(520px, 100%); max-height: 100%; overflow: auto; padding: 16px 20px;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.drill-card.go { border-color: var(--c); box-shadow: 0 0 40px color-mix(in srgb, var(--c) 30%, transparent); }
.drill-card.hit { border-color: var(--good); }
.drill-card.miss { border-color: var(--bad); }
.drill-card p { margin: 10px 0; }
.drill-top { display: flex; align-items: center; gap: 10px; }
.drill-title { font-weight: 700; flex: 1; }
.drill-prompt { font-size: 28px; margin: 14px 0 4px; }
.drill-prompt b { color: var(--c); }
.drill-sug { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.drill-sug .ico { width: 15px; height: 15px; }
.drill-timer { height: 6px; margin: 16px 0 10px; border-radius: 3px; background: var(--panel-3); overflow: hidden; }
.drill-timer i { display: block; height: 100%; background: var(--c); }
.drill-status { min-height: 22px; font-weight: 600; display: flex; align-items: center; }
.drill-status .ico { width: 16px; height: 16px; margin-right: 4px; vertical-align: -3px; }
.drill-score { display: flex; align-items: baseline; gap: 10px; margin: 12px 0; }
.drill-score b { font-size: 36px; }
.drill-table-wrap { overflow-x: auto; }
.drill-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.drill-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 5px 6px; border-bottom: 1px solid var(--border); }
.drill-table td { padding: 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.drill-table tr.weak td { background: rgba(248, 113, 113, .06); }
.drill-table .ico { width: 14px; height: 14px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.drill-advice { color: var(--muted); }
.drill-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---------- controller view ---------- */
.pad { flex: none; padding: 10px 24px 10px; border-top: 1px solid var(--border); background: radial-gradient(ellipse at 50% 100%, rgba(139, 92, 246, .08), transparent 70%); }
.pad svg { display: block; width: 100%; height: auto; max-height: 196px; margin: 0 auto; }
.face text, .bumper text, .trigger text { font-size: 10px; }
.ctl text.tiny { font-size: 7px; letter-spacing: .4px; }
.pad-body { fill: url(#vum-body); stroke: #2c3f66; stroke-width: 2; }
.logo { fill: #33466f; font: 800 13px system-ui, sans-serif; letter-spacing: 4px; text-anchor: middle; }
.ctl { --c: #64748b; cursor: pointer; outline: none; }
.ctl .base { fill: #18233d; stroke: #31456e; stroke-width: 1.5; transition: fill .07s, stroke .15s; }
.ctl text { fill: #7282a6; font: 700 11px system-ui, sans-serif; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.ctl text.tiny { font-size: 8px; letter-spacing: .5px; }
.ctl:hover .base, .ctl:focus-visible .base { stroke: #cbd5e1; }
.ctl.mapped .base { stroke: var(--c); stroke-width: 2.4; }
.ctl.mapped text { fill: #e8eef8; }
.face text { fill: color-mix(in srgb, var(--lc) 55%, #1a2440); }
.face.mapped text { fill: var(--lc); }
.ctl.on .base { fill: var(--c); filter: drop-shadow(0 0 7px var(--c)); }
.ctl.on text, .face.on text { fill: #0a0f1d; }
.ctl.selected .base { stroke: #fff; stroke-dasharray: 5 3; }
.trigger .fill { fill: var(--c); opacity: .9; pointer-events: none; }
.stick .base { fill: #0f182c; }
.stick.on .base { fill: #0f182c; filter: none; }
.stick .wedge { fill: transparent; pointer-events: none; transition: fill .08s; }
.stick .wedge.enabled { fill: color-mix(in srgb, var(--c) 28%, transparent); }
.stick .wedge.push { fill: rgba(34, 211, 238, .35); }
.stick .wedge.enabled.push { fill: color-mix(in srgb, var(--c) 60%, transparent); }
.stick .wedge.heard { fill: var(--c); filter: drop-shadow(0 0 6px var(--c)); }
.knob-c { fill: #24345a; stroke: #4a5f8f; stroke-width: 2; }
.stick.mapped .knob-c { stroke: var(--c); }
.stick.on .knob-c { fill: #33477a; }
.center-mark { fill: transparent; }
.stick.has-center .center-mark { fill: color-mix(in srgb, var(--cc) 45%, transparent); }
.stick .knob.heard .center-mark { fill: var(--cc); }
.stick-label { opacity: 0; }
.orb-ring { fill: #0c1426; stroke: #2c3f66; stroke-width: 1.5; }
.orb-core { fill: url(#vum-orb); opacity: .45; }
.orb-core.sounding { opacity: 1; }

/* ---------- controls panel ---------- */
.panel {
  position: sticky; top: 64px; display: flex; flex-direction: column; overflow: hidden;
  height: calc(100vh - 80px); max-height: 876px;
}
.panel-body { flex: 1; min-height: 0; overflow-y: auto; }
@media (max-width: 1100px) {
  .panel { position: static; height: auto; max-height: none; overflow: visible; }
  .panel-body { overflow: visible; }
  .scene-wrap { height: 56vh; }
}
.panel-head {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.panel-head h2 { flex: 1; }
.progress { width: 70px; height: 5px; border-radius: 3px; background: var(--panel-3); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--good); }
.badge {
  display: inline-flex; align-items: center; gap: 2px; flex: none; height: 22px; padding: 0 7px;
  border-radius: 7px; font-size: 11px; font-weight: 800; letter-spacing: .2px; white-space: nowrap;
  background: var(--panel-3); border: 1px solid var(--border-2); color: var(--text);
}
.badge.stick { border-radius: 11px; }
.badge .ico { width: 12px; height: 12px; }

.guide {
  margin: 12px 12px 4px; padding: 12px 14px; border-radius: 12px;
  background: linear-gradient(160deg, rgba(124, 58, 237, .18), rgba(34, 211, 238, .05));
  border: 1px solid rgba(139, 92, 246, .45);
}
.guide.teaching { border-color: #dc2626; background: linear-gradient(160deg, rgba(220, 38, 38, .16), rgba(220, 38, 38, .03)); }
.guide.warn { border-color: rgba(251, 191, 36, .6); background: linear-gradient(160deg, rgba(251, 191, 36, .12), transparent); }
.guide.done { border-color: rgba(52, 211, 153, .5); background: linear-gradient(160deg, rgba(52, 211, 153, .12), transparent); }
.guide-kicker { display: flex; align-items: center; gap: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.guide.teaching .guide-kicker { color: #fca5a5; }
.guide.done .guide-kicker { color: var(--good); }
.guide.warn .guide-kicker { color: var(--warn); }
.guide-kicker .ico { width: 13px; height: 13px; }
.guide-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 17px; font-weight: 650; margin: 4px 0 2px; }
.guide-sug { display: flex; align-items: flex-start; gap: 7px; color: var(--muted); font-size: 13px; }
.guide-sug .ico { width: 15px; height: 15px; margin-top: 2px; color: var(--accent-2); }
.guide-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.guide-actions .prog { flex: 1; width: auto; }

.rows { list-style: none; margin: 0; padding: 8px 6px 4px; }
.row {
  --c: #64748b;
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 20px 32px; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 10px; cursor: pointer;
}
.row:hover { background: var(--panel-2); }
.row.active { background: color-mix(in srgb, var(--c) 16%, transparent); }
.row-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.row.untaught .row-dot { background: transparent; box-shadow: inset 0 0 0 2px var(--c); }
.row.active .row-dot, .row.on .row-dot { box-shadow: 0 0 10px var(--c); }
.row-main { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.row-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 11.5px; font-weight: 400; color: var(--muted); }
.row-meter { height: 3px; border-radius: 2px; background: var(--panel-3); overflow: hidden; }
.row-meter i { display: block; height: 100%; width: 0; background: var(--c); transition: width .1s linear; }
.row.teaching .row-meter i { background: #f87171; }
.st { display: inline-grid; place-items: center; width: 20px; height: 20px; }
.st .ico { width: 15px; height: 15px; }
.st.good { color: var(--good); }
.st.ok, .st.warn { color: var(--warn); }
.st.auto { color: var(--accent-2); }
.st.todo::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.row-teach { width: 32px; height: 32px; border-radius: 50%; color: #f87171; }
.row-teach:hover { background: rgba(248, 113, 113, .14); color: #fca5a5; }
.row-teach.cal { color: var(--accent-2); }
.row-teach.cal:hover { background: rgba(34, 211, 238, .12); color: var(--accent-2); }
.row-teach.live { background: #dc2626; color: #fff; animation: live 1.8s ease-in-out infinite; }
span.row-teach { display: inline-grid; place-items: center; color: var(--dim); }
span.row-teach .ico { width: 15px; height: 15px; }
.mini-range { position: relative; height: 3px; border-radius: 2px; background: var(--panel-3); }
.mini-range i, .range-track i {
  position: absolute; top: 50%; left: 50%; border-radius: 50%; background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2); opacity: .25; transition: left .06s linear;
}
.mini-range i { width: 8px; height: 8px; margin: -4px 0 0 -4px; }
.panel-foot { margin: 4px 16px 14px; font-size: 12px; color: var(--dim); }
.empty-map {
  display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 16px 12px; padding: 28px 16px;
  border: 1px dashed var(--border-2); border-radius: 12px; color: var(--muted); text-align: center;
}
.empty-map .ico { width: 30px; height: 30px; color: var(--dim); }

/* control detail */
.detail-head { gap: 8px; }
.name-input {
  flex: 1; min-width: 0; font-weight: 700; font-size: 15px; padding: 4px 8px;
  background: transparent; border: 1px solid transparent; border-radius: 8px;
}
.name-input:hover { border-color: var(--border-2); }
.name-input:focus { background: var(--panel-2); border-color: var(--border-2); outline: none; }
.name-input.small { font-size: 13.5px; font-weight: 600; padding: 2px 6px; }
.detail { display: flex; flex-direction: column; gap: 14px; padding: 14px; }
.field-label { margin-bottom: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.field .range { margin-top: 12px; }
.note {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); font-size: 13px;
}
.note .ico { width: 16px; height: 16px; color: var(--accent-2); }
.detect-dot { margin-left: auto; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--panel-3); }
.detect-dot.on { background: var(--accent-2); box-shadow: 0 0 10px var(--accent-2); }
.dir-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.dir-chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 4px 10px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px dashed var(--border-2); color: var(--muted);
}
.dir-chip .ico { width: 13px; height: 13px; }
.dir-chip.on { border-style: solid; color: var(--text); background: var(--panel-3); }

.sound-card, .axis-card { padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--border); }
.sound-card { --c: #64748b; }
.sound-card.active { border-color: var(--c); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 30%, transparent); }
.sound-card.teaching { border-color: #dc2626; }
.sound-top { display: flex; align-items: center; gap: 8px; }
.sound-name { flex: 1; display: flex; align-items: center; gap: 4px; min-width: 0; font-weight: 600; }
.sound-name .ico { width: 15px; height: 15px; color: var(--muted); }
.sound-status { font-size: 12px; white-space: nowrap; display: inline-flex; align-items: center; }
.sound-status .ico { width: 13px; height: 13px; margin-right: 3px; }
.sound-sug { margin: 6px 0 8px; color: var(--muted); font-size: 13px; }
.sound-meter { height: 4px; border-radius: 2px; background: var(--panel-3); overflow: hidden; }
.sound-meter i { display: block; height: 100%; width: 0; background: var(--c); transition: width .1s linear; }
.sound-actions { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.more { position: relative; margin-left: auto; }
.more summary { list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more-pop {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; width: 250px; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
}
.more-pop label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.more-pop .select { width: 100%; color: var(--text); }
.axis-card .seg { background: var(--panel); }

.range-track { position: relative; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--panel-3), #2a3b63, var(--panel-3)); }
.range-track i { width: 14px; height: 14px; margin: -7px 0 0 -7px; }
.range-labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.range-now { color: var(--text); }
.range-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.range-actions .prog { flex: 1; width: auto; }

/* ---------- soundcheck ---------- */
.label-row { display: flex; justify-content: space-between; }
.label-row b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.sc-big { display: flex; align-items: center; gap: 8px; font-size: 26px; font-weight: 700; margin: 12px 0 2px; }
.sc-big .ico { width: 24px; height: 24px; }
.sc-level { position: relative; height: 10px; margin: 16px 0 8px; border-radius: 5px; background: var(--panel-3); overflow: hidden; }
.sc-level i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #22d3ee, #a78bfa, #f472b6); transition: width .05s linear; }
.sc-steps { display: flex; gap: 6px; margin-top: 12px; }
.sc-steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--panel-3); }
.sc-steps span.on { background: var(--accent); }
.sc-steps span.done { background: var(--good); }
.sc .drill-timer { margin-top: 8px; }
.sc-scale { position: relative; height: 22px; margin: 18px 0 6px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--border); }
.sc-band { position: absolute; top: 4px; bottom: 4px; border-radius: 4px; background: linear-gradient(90deg, rgba(167, 139, 250, .55), rgba(244, 114, 182, .75)); }
.sc-mark { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; border-radius: 2px; }
.sc-mark.noise, .sc-legend i.noise { background: #94a3b8; }
.sc-mark.gate, .sc-legend i.gate { background: var(--warn); }
.sc-legend i.band { background: #c084fc; }
.sc-ticks { display: flex; justify-content: space-between; font-size: 10px; color: var(--dim); }
.sc-legend { display: flex; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.sc-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 3px; vertical-align: -1px; }
.sc-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.sc-facts div { padding: 8px 10px; border-radius: 10px; background: var(--panel-2); }
.sc-facts b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.sc-facts span { font-size: 11px; color: var(--muted); }
.sc-warn { display: flex; align-items: flex-start; gap: 8px; color: var(--warn); font-size: 13px; }
.sc-warn .ico { width: 16px; height: 16px; margin-top: 2px; }
.drill-card.sc p { margin: 12px 0 0; }

/* ---------- gallery ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(3, 6, 12, .72); backdrop-filter: blur(5px); }
.modal-card {
  width: min(980px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 20px 22px;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.modal-head { display: flex; justify-content: space-between; gap: 12px; }
.modal-head h2 { font-size: 22px; }
.modal-head p { margin: 4px 0 0; }
.gal-source {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px;
  padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--border); font-size: 13px;
}
.gal-source .select { min-width: 190px; }
.gal-label { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.tpl-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; cursor: pointer;
  padding: 14px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--border);
  transition: transform .12s, border-color .12s, background .12s;
}
.tpl-card:hover { transform: translateY(-2px); border-color: var(--accent); background: var(--panel-3); }
.tpl-icon {
  display: inline-grid; place-items: center; width: 44px; height: 44px; margin-bottom: 6px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 18%, var(--panel)); color: #c4b5fd;
}
.tpl-icon .ico { width: 24px; height: 24px; }
.tpl-card.from-game { border-color: rgba(34, 211, 238, .5); }
.tpl-card.from-game .tpl-icon { color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 14%, var(--panel)); }
.tpl-name { font-weight: 700; font-size: 15px; }
.tpl-blurb { color: var(--muted); font-size: 12px; }
.tpl-meta { margin-top: 6px; font-size: 11px; color: var(--accent-2); }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 9px 12px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border-2); box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  animation: toast-in .2s ease-out; transition: opacity .35s, transform .35s;
}
.toast.good { border-left: 3px solid var(--good); }
.toast.bad { border-left: 3px solid var(--bad); }
.toast.warn { border-left: 3px solid var(--warn); }
.toast.info { border-left: 3px solid var(--accent-2); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  input, select, .select { font-size: 16px; }          /* no zoom-on-focus on iOS */
  .topbar { padding: 8px 10px; gap: 6px; }
  .brand { font-size: 0; gap: 0; margin-right: 2px; }
  .profile-picker { flex: 1 1 0; min-width: 0; }
  .profile-picker .select { flex: 1; min-width: 0; max-width: none; }
  .topbar > .spacer { display: none; }
  .topbar-actions { flex: 1 1 100%; min-width: 0; gap: 6px; }   /* second row, never wraps */
  #bridge-menu { display: none; }
  .level-btn { flex: 0 1 auto; min-width: 0; }
  .level-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #mic-btn { margin-left: auto; flex: none; }
  #mic-btn .long { display: none; }
  #mic-btn .short { display: inline; }
  .menu .menu-pop, .menu.right .menu-pop, #guide-menu .menu-pop {
    position: fixed; left: 10px; right: 10px; top: 102px; width: auto;
    max-height: calc(100vh - 120px); overflow-y: auto;
  }
  .app { padding: 10px; gap: 10px; }
  .game-head { gap: 8px; }
  .game-icon { width: 34px; height: 34px; }
  .game-head h1 { font-size: 16px; }
  #drill-btn { padding: 7px 10px; }
  .scene-wrap { height: 50vh; min-height: 300px; }
  .hud { max-width: 64%; min-width: 0; padding: 6px 10px; }
  .hud-score { top: 58px; left: 12px; right: auto; text-align: left; font-size: 12px; }
  .teach-banner { min-width: 0; width: calc(100% - 32px); padding: 12px 16px; }
  .tb-title { font-size: 17px; }
  .drill { padding: 10px; }
  .drill-card { padding: 14px; }
  .drill-prompt { font-size: 22px; }
  .sc-big { font-size: 21px; }
  .pad { padding: 10px 44px 6px; }
  .row { gap: 8px; padding: 8px 6px; }
  .detail { padding: 12px; }
  .seg button { font-size: 12px; padding: 7px 4px; }
  .modal { padding: 8px; }
  .modal-card { padding: 16px 14px; max-height: calc(100vh - 16px); border-radius: 14px; }
  .modal-head h2 { font-size: 19px; }
  .tpl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tpl-card { padding: 12px; }
  .tpl-blurb { display: none; }
  .toasts { left: 10px; right: 10px; bottom: 10px; align-items: stretch; }
  .toast { max-width: none; }
}

/* ---------- very narrow phones ---------- */
@media (max-width: 360px) {
  .meter i:nth-child(-n+4) { display: none; }         /* 10 bars instead of 14 */
  .level-btn { padding: 0 8px; gap: 6px; }
  #drill-btn { padding: 0; width: 34px; height: 34px; }
  #drill-btn .lbl { display: none; }
}
