/* App shell styles: design tokens, dark theme, safe areas, phone landscape / portrait / desktop layouts.
   Owner: ui-shell. Contracts: CONTRACTS §A1 (no inline styles; dynamic values via style.setProperty), §C6.
   Console strip styles live in css/console.css (ui-console). */

:root {
  --bg: #0f1215;
  --bg2: #151a1f;
  --panel: #1b2128;
  --panel2: #222a32;
  --line: #2e3742;
  --line2: #3b4653;
  --text: #e7ebf0;
  --muted: #8f9aa8;
  --dim: #5f6a77;
  --accent: #f2b33d;      /* amber, LED-like */
  --accent2: #4fb3ff;     /* selection blue */
  --ok: #43d17a;
  --warn: #f2c23d;
  --bad: #ff5252;
  --danger: #d62f2f;
  --radius: 10px;
  --radius-s: 7px;
  --tap: 44px;            /* minimum touch target */
  --tap-s: 38px;
  --font: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --topbar-h: 48px;
  --rail-w: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text); }
html.pa-app, html.pa-app body { overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
.noscript { padding: 2rem; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.3; font-weight: 650; }
h2 { font-size: 1.15rem; } h3 { font-size: 1.02rem; } h4 { font-size: .95rem; }
p { margin: .4em 0 .8em; }
a { color: var(--accent2); }
.muted { color: var(--muted); font-size: .88em; }
.small { font-size: .82em; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }
.hidden-file { display: none; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.play-btn .icon path { fill: currentColor; }

/* ---------------------------------------------------------------- buttons & form controls */
.btn, .icon-btn, .seg-btn, .tab, .sec-chip, .panic {
  -webkit-user-select: none; user-select: none; touch-action: manipulation; cursor: pointer;
}
.btn {
  min-height: var(--tap-s); padding: 6px 14px; border-radius: var(--radius-s);
  border: 1px solid var(--line2); background: var(--panel2); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #1a1406; border-color: var(--accent); font-weight: 650; }
.btn.danger { background: #3a1517; border-color: var(--danger); color: #ffd6d6; }
.btn.big { min-height: var(--tap); padding: 10px 16px; font-size: 1rem; }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: .85rem; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn {
  width: var(--tap-s); height: var(--tap-s); border-radius: var(--radius-s); border: 1px solid transparent;
  background: transparent; color: var(--text); display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.icon-btn:hover { background: var(--panel2); }
.icon-btn.on { color: var(--accent); background: #2b2412; border-color: #5a4518; }
/* 見本 (reference mix) A/B button in the transport bar: text button, strongly lit while the reference is heard */
.icon-btn.ref-btn { width: auto; min-width: var(--tap-s); padding: 0 7px; font-size: 13px; font-weight: 650; letter-spacing: .02em; border-color: var(--line2); -webkit-touch-callout: none; }
.icon-btn.ref-btn.on { color: #10161a; background: #7fd3ff; border-color: #bfe9ff; box-shadow: 0 0 10px #7fd3ff99; }
.icon-btn.ref-btn.official.on { background: #9be87a; border-color: #d4f7c4; box-shadow: 0 0 10px #9be87a99; }
.icon-btn.ref-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.sel, input[type=number], input[type=text], input[type=search], textarea {
  background: var(--bg2); border: 1px solid var(--line2); border-radius: var(--radius-s); color: var(--text);
  min-height: 34px; padding: 4px 8px; font-size: 16px; /* ≥16px: no iOS zoom on focus */
}
textarea { width: 100%; font-family: var(--mono); font-size: 13px; min-height: 160px; resize: vertical; }
@media (pointer: coarse) { textarea { font-size: 16px; } }
.sel { padding-right: 24px; max-width: 100%; }
input[type=range].rng {
  -webkit-appearance: none; appearance: none; background: transparent; height: 32px; min-width: 80px; flex: 1;
  touch-action: none; margin: 0;
}
input[type=range].rng::-webkit-slider-runnable-track { height: 6px; background: var(--line2); border-radius: 3px; }
input[type=range].rng::-moz-range-track { height: 6px; background: var(--line2); border-radius: 3px; }
input[type=range].rng::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%;
  background: var(--text); border: 3px solid var(--accent); box-shadow: 0 1px 3px #0008;
}
input[type=range].rng::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--text); border: 3px solid var(--accent); }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; flex: none; }

.row { display: flex; align-items: center; gap: 6px 8px; min-height: 40px; }
.row:not(.slider-row) { flex-wrap: wrap; }
.row .lbl { flex: none; min-width: 6.5em; color: var(--text); font-size: .92rem; }
.slider-row .lbl { width: 6.5em; }
.slider-row .numwrap { display: inline-flex; align-items: center; gap: 3px; flex: none; }
.slider-row input.num { width: 4.8em; text-align: right; padding: 3px 6px; }
.slider-row .unit { color: var(--muted); font-size: .8rem; min-width: 2em; }
.slider-row .fmt { color: var(--muted); font-size: .8rem; min-width: 4em; font-variant-numeric: tabular-nums; }
.toggle { cursor: pointer; }
.toggle .lbl { min-width: 0; }

.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: var(--radius-s); overflow: hidden; flex-wrap: wrap; }
.seg-btn { min-height: 36px; min-width: 44px; padding: 4px 10px; border: 0; border-right: 1px solid var(--line2); background: var(--bg2); color: var(--muted); }
.seg-btn:last-child { border-right: 0; }
.seg-btn.on { background: var(--accent); color: #1a1406; font-weight: 650; }

/* ---------------------------------------------------------------- shell layout */
.app-root { height: 100%; }
.shell {
  height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  padding: var(--safe-t) var(--safe-r) 0 var(--safe-l); background: var(--bg);
}
.body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mainwrap { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.views { flex: 1; min-height: 0; position: relative; }
.view { position: absolute; inset: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.view.loading::after { content: "読み込み中…"; position: absolute; top: 40%; left: 0; right: 0; text-align: center; color: var(--muted); }
.view.fill { overflow: hidden; }

/* tab bar: portrait = bottom bar */
.tabbar {
  order: 2; display: flex; background: var(--bg2); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); flex: none;
}
.tab {
  flex: 1; min-height: 52px; border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px 2px;
  font-size: 11px; line-height: 1.1;
}
.tab .icon { width: 22px; height: 22px; }
.tab.on { color: var(--accent); }
.tab.on .icon { stroke-width: 2.4; }

/* top bar (portrait: two rows via flex-wrap; landscape/desktop: one row) */
.topbar {
  flex: none; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; padding: 4px 8px;
  background: var(--bg2); border-bottom: 1px solid var(--line); position: relative; z-index: 20;
}
.tb-transport { display: contents; }
.tb-left { order: 1; flex: 1 1 auto; display: flex; align-items: center; gap: 2px; min-width: 0; }
.tb-right { order: 2; display: flex; align-items: center; gap: 0; flex: none; margin-left: auto; }
.seek { order: 3; flex: 1 1 calc(100% - 4.5em); position: relative; min-width: 0; height: 40px; }
.time { order: 4; display: flex; flex-direction: column; align-items: flex-end; font-family: var(--mono); font-size: 12px; line-height: 1.2; font-variant-numeric: tabular-nums; min-width: 3.6em; flex: none; }
.time .t-tot { color: var(--muted); }
.song-sel { flex: 1 1 8.5em; width: 8.5em; min-width: 4.5em; font-size: 14px; min-height: 36px; }
@media (pointer: coarse) { .song-sel { font-size: 16px; } }
@media (max-width: 420px) {
  .topbar { --tap-s: 34px; padding: 3px 4px; }
  .tb-right .icon-btn { width: 34px; }
  .tier-badge { display: none; }
  .song-sel { flex: 1 1 4.5em; width: 4.5em; }
  .panic { font-size: 11px; padding: 3px 4px; margin-left: 2px; letter-spacing: -.02em; }
  .tb-left .icon-btn { width: 34px; }
  .tb-left .icon-btn.ref-btn { width: auto; min-width: 34px; padding: 0 4px; font-size: 12px; }
  .tb-redo { display: none; }
}

.panic {
  min-height: var(--tap-s); padding: 4px 10px; border-radius: var(--radius-s); border: 2px solid var(--danger);
  background: #3a1214; color: #ffdede; font-weight: 700; font-size: 13px; white-space: nowrap; margin-left: 4px;
}
.panic.active { background: var(--danger); color: #fff; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { 50% { background: #7a1010; } }
.tb-menu { width: auto; padding: 0 4px; }
.menu-inner { display: inline-flex; align-items: center; gap: 3px; }
.tier-badge { font-size: 9px; font-weight: 700; letter-spacing: .03em; color: var(--muted); border: 1px solid var(--line2); border-radius: 4px; padding: 0 3px; line-height: 14px; }

/* seek bar */
.seek-lane { position: absolute; left: 0; right: 0; top: 0; height: 16px; }
.sec-chip {
  position: absolute; top: 0; height: 16px; border: 0; margin: 0; padding: 0 3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: 10px; line-height: 16px; color: var(--muted); background: #222a33; border-left: 1px solid var(--line2); text-align: left;
}
.sec-chip.odd { background: #1d242c; }
.sec-chip.cur { color: var(--text); background: #2c3540; }
.seek-track { position: absolute; left: 0; right: 0; top: 18px; height: 22px; border-radius: 5px; background: #0b0e11; border: 1px solid var(--line); touch-action: none; cursor: pointer; }
.seek-fill { position: absolute; left: 0; top: 0; bottom: 0; background: #2a3a4a; border-radius: 5px 0 0 5px; pointer-events: none; }
.seek-loop { position: absolute; top: 0; bottom: 0; background: #f2b33d22; border-left: 1px solid #f2b33d66; border-right: 1px solid #f2b33d66; pointer-events: none; display: none; }
.seek-head { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--accent2); pointer-events: none; }
.seek-handle {
  position: absolute; top: 1px; width: 20px; height: 18px; margin-left: -10px; border-radius: 4px; display: none;
  background: var(--accent); color: #1a1406; font-size: 10px; font-weight: 800; line-height: 18px; text-align: center; touch-action: none; cursor: ew-resize; z-index: 2;
}
.seek-handle::before { content: ""; position: absolute; left: -10px; right: -10px; top: -12px; bottom: -12px; } /* bigger hit area */
.seek.looping .seek-loop, .seek.looping .seek-handle { display: block; }
.load-prog {
  position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; gap: 6px; padding: 0 8px 4px;
  background: #151a1ff2; border: 1px solid #2f4d66; border-radius: 6px; font-size: 12px; color: var(--text); overflow: hidden;
}
.load-prog .load-txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.load-prog .load-pct { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--accent2); font-weight: 700; }
.load-prog .load-track { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: #0008; }
.load-prog .load-bar { height: 100%; width: 0; background: var(--accent2); transition: width .2s; }
.load-prog.indet .load-bar { animation: indet 1.2s ease-in-out infinite; }
.load-prog.error { border-color: var(--danger); }
.load-prog.error .load-txt { color: #ffb4b4; }
.load-prog.error .spinner { display: none; }
@keyframes indet { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.spinner { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #4fb3ff44; border-top-color: var(--accent2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.play-btn:disabled { opacity: .4; }
.load-toast {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 40; max-width: calc(100% - 16px);
  display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 18px; font-size: 13px;
  background: #182029f2; border: 1px solid #3d5266; box-shadow: 0 6px 20px #0008; pointer-events: auto;
}
.load-toast .lt-main { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.load-toast.error { border-color: var(--danger); }
.load-toast.error .spinner { display: none; }

/* ---- phone landscape: rail on the left, one-row top bar */
@media (orientation: landscape) and (max-height: 560px) {
  :root { --tap-s: 36px; }
  .topbar { flex-wrap: nowrap; padding: 3px 6px; gap: 6px; }
  .tb-left { flex: 0 1 auto; } .seek { order: 2; flex: 1 1 auto; } .time { order: 3; } .tb-right { order: 4; margin-left: 0; }
  .seek { height: 38px; }
  .seek-track { height: 20px; }
  .body { flex-direction: row; }
  .tabbar { order: 0; flex-direction: column; width: var(--rail-w); border-top: 0; border-right: 1px solid var(--line); padding-bottom: var(--safe-b); overflow-y: auto; }
  .tab { min-height: 44px; font-size: 10px; flex: 1 0 auto; }
  .shell { padding-right: var(--safe-r); }
  .panic { font-size: 12px; padding: 3px 8px; }
  .song-sel { width: 7.5em; flex: 0 1 7.5em; }
}
/* ---- desktop: tabs on top */
@media (min-width: 1000px) and (min-height: 600px) {
  .topbar { flex-wrap: nowrap; padding: 6px 12px; gap: 10px; --tap-s: 40px; }
  .tb-left { flex: 0 1 auto; } .seek { order: 2; flex: 1 1 auto; } .time { order: 3; } .tb-right { order: 4; margin-left: 0; }
  .seek { height: 42px; }
  .seek-track { height: 24px; }
  .tabbar { order: 0; border-top: 0; border-bottom: 1px solid var(--line); padding: 0 8px; }
  .tab { flex: 0 0 auto; flex-direction: row; gap: 6px; min-height: 42px; padding: 0 16px; font-size: 14px; border-bottom: 2px solid transparent; }
  .tab.on { border-bottom-color: var(--accent); }
  .song-sel { width: 14em; flex: 0 1 14em; }
}

/* ---------------------------------------------------------------- generic panels */
.panel-page { padding: 12px 14px calc(16px + var(--safe-b)); max-width: 1100px; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.card > h3:first-child, .card > h2:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.card-head h3 { margin: 0; flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 12px; }
.placeholder { padding: 40px 20px; text-align: center; color: var(--muted); }
.placeholder h2 { color: var(--text); }
.badge { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 9px; background: var(--panel2); border: 1px solid var(--line2); color: var(--muted); line-height: 18px; }
.badge.ok { color: #0d2416; background: var(--ok); border-color: var(--ok); }
.badge.warn { color: #2a2005; background: var(--warn); border-color: var(--warn); }
.badge.bad { color: #fff; background: var(--bad); border-color: var(--bad); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: .9rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* popover / modal / toast */
.popover {
  position: absolute; right: 8px; top: calc(var(--safe-t) + 50px); z-index: 60; width: min(360px, calc(100vw - 16px));
  background: var(--panel); border: 1px solid var(--line2); border-radius: var(--radius); padding: 10px 12px; box-shadow: 0 10px 30px #000a;
  max-height: calc(100dvh - 70px); overflow: auto;
}
.modal-back { position: fixed; inset: 0; background: #000a; z-index: 100; display: flex; align-items: center; justify-content: center; padding: calc(8px + var(--safe-t)) calc(8px + var(--safe-r)) calc(8px + var(--safe-b)) calc(8px + var(--safe-l)); }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; width: min(560px, 100%); max-height: 100%; display: flex; flex-direction: column; box-shadow: 0 20px 60px #000c; }
.modal.wide { width: min(900px, 100%); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 6px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; margin: 0; }
.modal-body { padding: 12px 16px 16px; overflow: auto; }
.warn-big { font-size: 1.1rem; font-weight: 700; color: var(--warn); }
.menu-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 8px; }
.menu-grid .btn { justify-content: flex-start; white-space: normal; text-align: left; }
.toast-host { position: fixed; left: 50%; bottom: calc(70px + var(--safe-b)); transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: #000d; color: #fff; border: 1px solid var(--line2); padding: 6px 14px; border-radius: 18px; font-size: 14px; transition: opacity .4s; max-width: 90vw; }
.toast.out { opacity: 0; }

/* ---------------------------------------------------------------- lesson HUD (visible on every tab) */
.lesson-hud {
  position: absolute; right: 8px; bottom: 8px; z-index: 30; width: min(340px, calc(100% - 16px));
  background: #182029ee; border: 1px solid #3d5266; border-radius: var(--radius); box-shadow: 0 6px 24px #0009; font-size: 13px;
}
.lesson-hud .hud-head { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; cursor: pointer; }
.lesson-hud .hud-title { flex: 1; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-hud .hud-count { color: var(--accent); font-variant-numeric: tabular-nums; }
.lesson-hud .hud-body { padding: 0 10px 8px; max-height: 40dvh; overflow: auto; }
.lesson-hud.collapsed .hud-body { display: none; }
.lesson-hud .hud-next { display: none; padding: 0 10px 6px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.lesson-hud.collapsed .hud-next { display: block; }
.lesson-hud.collapsed { width: min(340px, calc(100% - 16px)); }
.goal { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; }
.goal .mark { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line2); display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.goal .mark .icon { width: 14px; height: 14px; stroke-width: 3; }
.goal.done .mark { background: var(--ok); border-color: var(--ok); color: #0d2416; }
.goal.done .gtext { color: var(--muted); }
.goal .gprog { height: 3px; background: var(--line); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.goal .gprog > div { height: 100%; background: var(--accent); width: 0; }
.goal .manual-btn { margin-left: auto; }
.hud-allclear { color: var(--ok); font-weight: 700; padding: 4px 0; }

/* lessons panel */
.panel-page > h3 { margin-top: 18px; }
.lesson-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.lesson-item { text-align: left; display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); color: var(--text); cursor: pointer; min-height: 64px; }
.lesson-item:hover { border-color: var(--line2); }
.lesson-item.current { border-color: var(--accent); }
.lesson-item .num { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--panel2); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent); }
.lesson-item.done .num { background: var(--ok); color: #0d2416; }
.lesson-item .lt { font-weight: 650; }
.lesson-item .ld { color: var(--muted); font-size: .85rem; }
.lesson-detail .intro p { margin: .3em 0 .7em; }
.lesson-detail .tips li { margin: .2em 0; }
.lesson-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.lvl { font-size: 11px; color: var(--muted); }

/* ---------------------------------------------------------------- stage editor */
.stage-view { position: absolute; inset: 0; display: flex; flex-direction: column; min-width: 0; }
.stage-view > * { min-width: 0; }
.stage-toolbar { flex: none; display: flex; align-items: center; gap: 6px; padding: 4px 8px; background: var(--bg2); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.stage-toolbar::-webkit-scrollbar { display: none; }
.stage-toolbar .sel { font-size: 14px; min-height: 34px; flex: none; max-width: 16em; }
.stage-toolbar > * { flex: none; }
@media (pointer: coarse) { .stage-toolbar .sel { font-size: 16px; } }
.stage-main { flex: 1; min-height: 0; display: flex; position: relative; }
.stage-canvas-wrap { flex: 1; min-width: 0; position: relative; touch-action: none; }
.stage-canvas-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.stage-inspector { flex: none; width: 300px; border-left: 1px solid var(--line); background: var(--panel); overflow: auto; padding: 8px 10px 16px; overscroll-behavior: contain; }
.stage-inspector.empty { color: var(--muted); font-size: .9rem; }
.stage-inspector h3 { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.stage-inspector h3 .grow { flex: 1; }
.stage-inspector .slider-row .lbl { width: 5.6em; font-size: .85rem; }
.stage-inspector .slider-row input.num { width: 4.6em; }
.stage-inspector .row .lbl { min-width: 5.6em; font-size: .85rem; }
.stage-inspector .sec { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 6px; }
.stage-legend { position: absolute; left: 8px; bottom: 8px; font-size: 11px; color: var(--muted); background: #0f1215cc; border-radius: 6px; padding: 3px 8px; pointer-events: none; max-width: calc(100% - 16px); }
.phantom-warn { color: var(--bad); font-weight: 700; }
.phantom-ok { color: var(--ok); font-weight: 700; }
.bleed-list { font-size: .85rem; font-variant-numeric: tabular-nums; }
.bleed-list .row { min-height: 24px; }
.bleed-list .bar { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bleed-list .bar > div { height: 100%; background: var(--accent2); width: 0; }
.stage-inspector .close-insp { display: none; }
@media (max-width: 700px) and (orientation: portrait) {
  .stage-main { flex-direction: column; }
  .stage-inspector { width: auto; border-left: 0; border-top: 1px solid var(--line); max-height: 45%; }
  .stage-inspector.empty { max-height: 64px; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .stage-inspector { width: 260px; }
  .stage-toolbar { padding: 2px 6px; }
}

/* ---------------------------------------------------------------- listen / RTA */
.rta-wrap { position: relative; height: 220px; background: #0a0d10; border: 1px solid var(--line); border-radius: var(--radius-s); touch-action: pan-y; }
.rta-wrap canvas { width: 100%; height: 100%; display: block; }
@media (orientation: landscape) and (max-height: 560px) { .rta-wrap { height: 170px; } }
.ear-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.answer-box { font-family: var(--mono); font-size: 13px; background: var(--bg2); border-radius: var(--radius-s); padding: 6px 10px; white-space: pre-wrap; margin-top: 6px; }
.shortcuts { display: flex; flex-wrap: wrap; gap: 6px; }
.phones-pop .slider-row .lbl { width: 6.5em; }

/* ---------------------------------------------------------------- settings */
.sim-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.sim-tools input[type=search] { flex: 1; min-width: 160px; }
.sim-group > summary { cursor: pointer; font-weight: 650; padding: 6px 0; display: flex; align-items: center; gap: 8px; list-style: none; }
.sim-group > summary::-webkit-details-marker { display: none; }
.sim-group > summary::before { content: "▸"; color: var(--muted); }
.sim-group[open] > summary::before { content: "▾"; }
.sim-group > summary .grow { flex: 1; }
.sim-param { border-top: 1px solid var(--line); padding: 6px 0; }
.sim-param .pkey { font-family: var(--mono); font-size: 11px; color: var(--dim); word-break: break-all; }
.sim-param .pdesc { font-size: .82rem; color: var(--muted); margin: 0; }
.sim-param.changed .lbl { color: var(--accent); }
.sim-param .slider-row .lbl { width: 11em; }
.row > .slider-row { flex: 1 1 auto; min-width: 0; }
.sim-param .reset { flex: none; }
.env-diff { max-height: 40dvh; overflow: auto; font-size: 12px; }
.env-diff .row { min-height: 22px; gap: 10px; }
.env-card textarea { min-height: 140px; }
.json-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }

/* ---------------------------------------------------------------- presets */
.scene-list { display: grid; gap: 6px; }
.scene-row { display: flex; gap: 6px; align-items: center; padding: 6px 8px; background: var(--bg2); border-radius: var(--radius-s); }
.scene-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene-row .dt { color: var(--muted); font-size: 12px; }
.autogain-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.autogain-table .ag { display: flex; justify-content: space-between; gap: 6px; padding: 2px 6px; background: var(--bg2); border-radius: 5px; }
.autogain-table .ag.skip { color: var(--dim); }
.autogain-table .ag.ok { color: var(--ok); }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ---------------------------------------------------------------- help */
.help-page h2 { margin-top: .6em; }
.help-page dl.gloss { display: grid; grid-template-columns: minmax(7em, auto) 1fr; gap: 4px 14px; }
.help-page dl.gloss dt { font-weight: 650; color: var(--accent); }
.help-page dl.gloss dd { margin: 0; }
.flow-wrap { overflow-x: auto; background: #0a0d10; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; }
.flow-wrap svg { display: block; min-width: 720px; width: 100%; height: auto; }
.flow-box { fill: #1e2731; stroke: #46576a; stroke-width: 1.2; }
.flow-box.eq { fill: #232b1d; stroke: #6c8a3e; }
.flow-box.bus { fill: #2b2412; stroke: #a37b23; }
.flow-box.out { fill: #251a26; stroke: #8b5a91; }
.flow-box.tap { fill: #13262b; stroke: #3f8ea0; }
.flow-txt { fill: var(--text); font-size: 12px; font-family: var(--font); }
.flow-sub { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.flow-line { stroke: #8f9aa8; stroke-width: 1.5; fill: none; }
.flow-line.pre { stroke: #3f8ea0; stroke-dasharray: 4 3; }
.flow-line.post { stroke: #a37b23; }
.flow-arrow { fill: #8f9aa8; }
.help-toc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

/* master view container (console UI fills it) */
.master-layout { display: flex; flex-direction: column; gap: 8px; min-height: 100%; }
.master-display:empty, .master-main:empty { display: none; }
.load-prog.error .load-track { display: none; }
.sc-chip { flex: none; min-height: 30px; padding: 2px 10px; border-radius: 15px; border: 1px solid var(--warn); background: #2b2412; color: var(--warn); font-size: 12px; font-weight: 700; white-space: nowrap; cursor: pointer; animation: scpulse 1.6s ease-in-out infinite; }
@keyframes scpulse { 50% { background: #4a3a10; } }
.map-table .row { border-top: 1px solid var(--line); }
.map-table .map-file { flex: 1 1 12em; min-width: 0; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12px; }
