/* ============================================================
   IC Trainer: dark workbench design system
   Dense, tool-like UI. Base 12px, 26px controls, 14px icons.
   ============================================================ */
:root {
  --bg: #0d1117;
  --panel: #151a22;
  --panel-2: #1a2029;
  --panel-3: #222a35;
  --panel-hover: #1f2731;
  --border: #262e3a;
  --border-2: #333d4b;
  --text: #e8edf4;
  --text-2: #b8c2d0;
  --muted: #7c8899;
  --muted-2: #5b6778;
  --red: #e5243f;
  --red-dark: #b81a31;
  --red-soft: rgba(229,36,63,0.14);
  --red-border: rgba(229,36,63,0.45);
  --blue: #4f8cff;
  --blue-soft: rgba(79,140,255,0.16);
  --blue-border: rgba(79,140,255,0.5);
  --success: #3ecf6b;
  --success-soft: rgba(62,207,107,0.14);
  --warning: #f5b23c;
  --warning-soft: rgba(245,178,60,0.14);
  --danger: #ff5d6c;
  --danger-soft: rgba(255,93,108,0.14);
  --input-bg: #0f141b;
  --fs: 12px;
  --fs-sm: 11px;
  --fs-xs: 10px;
  --ctl: 26px;
  --ctl-sm: 22px;
  --r: 4px;
  --r-lg: 6px;
  --header-h: 40px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-display: 'Oswald', 'Arial Narrow', Impact, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Cascadia Mono', Consolas, monospace;
  color-scheme: dark;
  --red-fg: #ff8091;
  --blue-fg: #8fb6ff;
  --prompt-fg: #ffd3da;
  --scene-bg: #05080d;
  --scene-dot: #141b26;
}

/* ---------- Light theme (used for the trainee exam player by default) ---------- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-2: #f5f7fa;
  --panel-3: #e9edf2;
  --panel-hover: #f1f4f8;
  --border: #d9dfe7;
  --border-2: #c5cdd8;
  --text: #1f2937;
  --text-2: #475569;
  --muted: #6b7a90;
  --muted-2: #9aa6b5;
  --red: #c8102e;
  --red-dark: #a00d25;
  --red-soft: rgba(200,16,46,0.09);
  --red-border: rgba(200,16,46,0.35);
  --red-fg: #b00f28;
  --blue: #2563eb;
  --blue-soft: rgba(37,99,235,0.1);
  --blue-border: rgba(37,99,235,0.4);
  --blue-fg: #1d4ed8;
  --success: #1f8a3c;
  --success-soft: rgba(31,138,60,0.12);
  --warning: #b45309;
  --warning-soft: rgba(217,119,6,0.12);
  --danger: #b91c1c;
  --danger-soft: rgba(185,28,28,0.1);
  --input-bg: #ffffff;
  --prompt-fg: #9f0d25;
  --scene-bg: #0b1220;
  --scene-dot: #182236;
}
:root[data-theme="light"] .btn { background: linear-gradient(#fff, #f5f7fa); }
:root[data-theme="light"] .btn:hover { background: #eef2f7; border-color: #aab7c6; }
:root[data-theme="light"] .btn.primary { background: var(--red); border-color: var(--red-dark); color: #fff; }
:root[data-theme="light"] .btn.primary:hover { background: var(--red-dark); }
:root[data-theme="light"] .btn.blue { background: var(--blue); border-color: #1d4ed8; color: #fff; }
:root[data-theme="light"] .btn.blue:hover { background: #1d4ed8; }
:root[data-theme="light"] .btn.danger { background: var(--red-soft); border-color: var(--red-border); }
:root[data-theme="light"] .btn.danger:hover { background: rgba(200,16,46,0.16); }
:root[data-theme="light"] .btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
:root[data-theme="light"] .btn.ghost:hover { background: rgba(15,23,42,0.06); }
:root[data-theme="light"] .btn.on { background: var(--blue-soft); border-color: var(--blue-border); }
:root[data-theme="light"] .rec-button { background: var(--red); color: #fff; }
:root[data-theme="light"] .rec-button.recording { background: #fff; color: var(--red-fg); }
:root[data-theme="light"] .btn.dark { background: #1f2937; border-color: #111827; color: #fff; }
:root[data-theme="light"] .btn.on { color: var(--blue-fg); }
:root[data-theme="light"] .badge.red { color: var(--red-fg); }
:root[data-theme="light"] .badge.blue { color: var(--blue-fg); }
:root[data-theme="light"] .badge.dark { background: #1f2937; color: #fff; border: none; }
:root[data-theme="light"] .notice.info { color: #1e3a8a; }
:root[data-theme="light"] .notice.success { color: #14532d; }
:root[data-theme="light"] .notice.warn { color: #7c2d12; }
:root[data-theme="light"] .notice.danger { color: #7f1d1d; }
:root[data-theme="light"] .toast { background: #1f2937; color: #fff; border-color: #111827; }
:root[data-theme="light"] .skill-chip.on { color: var(--blue-fg); }
:root[data-theme="light"] .btn.danger { color: var(--red-fg); }
:root[data-theme="light"] .ai-assist p { color: #3730a3; }
:root[data-theme="light"] .ai-assist { background: linear-gradient(135deg, #eef2ff, #f5f3ff); border-color: #c7d2fe; }
:root[data-theme="light"] .log-entry summary { color: var(--blue-fg); }
:root[data-theme="light"] .radio-msg { background: #1f2937; color: #d1fae5; border-color: #111827; }
:root[data-theme="light"] .debrief-hero { background: linear-gradient(135deg, #1f2937, #26384d); border-color: #111827; }
:root[data-theme="light"] .debrief-hero p { color: #cbd5e1; }
:root[data-theme="light"] .score-ring::before { background: #fff; }
:root[data-theme="light"] .fire-presets button.on { color: var(--red-fg); }
:root[data-theme="light"] .ov-toolbar { background: rgba(255,255,255,0.97); }
:root[data-theme="light"] .steps .stp.active { background: #fff; }
:root[data-theme="light"] .app-header { border-bottom-color: #0a0e14; }
:root[data-theme="light"] .brand p { color: #8fa0b5; }
:root[data-theme="light"] .nav a, :root[data-theme="light"] .nav button { color: #b9c5d4; }
:root[data-theme="light"] .status-pill { color: #cbd5e1; border-color: rgba(255,255,255,0.18); }
:root[data-theme="light"] .app-header .btn.ghost { color: #b9c5d4; }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; font-size: var(--fs); line-height: 1.4; -webkit-font-smoothing: antialiased; }
body.app-body { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
.mono { font-family: var(--font-mono); }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #364154; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #4a566b; background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }
svg { display: block; }
b, strong { font-weight: 600; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; } }

/* ---------- Chrome bar ---------- */
.app-header { background: #0a0e14; color: #fff; border-bottom: 1px solid var(--border); flex-shrink: 0; height: var(--header-h); }
.header-inner { padding: 0 12px; height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: #fff; min-width: 0; }
.brand-icon { width: 22px; height: 22px; border-radius: 5px; background: var(--red); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-icon svg { width: 14px; height: 14px; }
.brand h1 { font-family: var(--font-display); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; line-height: 1; white-space: nowrap; }
.brand p { color: var(--muted); font-size: 10px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1; }
.nav { display: flex; gap: 2px; align-items: center; flex-shrink: 0; }
.nav a, .nav button { color: var(--text-2); text-decoration: none; padding: 0 10px; height: 26px; border-radius: var(--r); font-weight: 600; font-size: var(--fs-sm); border: 1px solid transparent; background: transparent; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; line-height: 1; }
.nav a:hover, .nav button:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav a.active { background: rgba(255,255,255,0.1); color: #fff; }
.nav button svg { width: 14px; height: 14px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; background: rgba(255,255,255,0.05); border: 1px solid var(--border-2); padding: 0 9px; height: 24px; border-radius: 999px; font-size: var(--fs-xs); white-space: nowrap; font-weight: 600; color: var(--text-2); letter-spacing: 0.02em; }
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; }
.status-pill.ok .dot { background: var(--success); box-shadow: 0 0 0 2px rgba(62,207,107,0.25); }
.status-pill.warn .dot { background: var(--warning); }

/* ---------- Layout ---------- */
.page { max-width: 1800px; margin: 0 auto; padding: 14px 16px 40px; width: 100%; }
.app-shell { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 8px; width: 100%; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.page-title h2 { font-family: var(--font-display); font-size: 17px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; color: var(--text); line-height: 1; }
.page-title p { color: var(--muted); margin-top: 3px; font-size: var(--fs-sm); }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.stack { display: grid; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.sep-v { width: 1px; height: 18px; background: var(--border-2); flex-shrink: 0; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.panel-header { padding: 0 8px 0 10px; border-bottom: 1px solid var(--border); background: var(--panel-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-shrink: 0; height: 30px; }
.panel-header h3 { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-2); line-height: 1; }
.panel-header p { font-size: var(--fs-xs); color: var(--muted); margin-top: 0; display: none; }
.panel-header.tall, .panel-header:has(p) { height: auto; min-height: 30px; padding: 6px 10px; }
.panel-header.tall p, .panel-header:has(p) p { display: block; margin-top: 2px; font-size: var(--fs-sm); text-transform: none; letter-spacing: 0; }
.panel-body { padding: 10px; }
.panel-body.tight { padding: 4px; }
.panel-body.scroll { overflow: auto; flex: 1; min-height: 0; }

/* ---------- Metrics ---------- */
.metrics { display: flex; gap: 0; margin-bottom: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.metric { padding: 8px 14px; flex: 1; border-right: 1px solid var(--border); min-width: 0; }
.metric:last-child { border-right: none; }
.metric-label { color: var(--muted); font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 2px; }
.metric-value { font-family: var(--font-mono); font-size: 16px; font-weight: 600; line-height: 1.1; }
.metric-sub { color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--border-2); background: var(--panel-3); color: var(--text); height: var(--ctl); padding: 0 9px; border-radius: var(--r); cursor: pointer; font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; text-decoration: none; line-height: 1; transition: background 0.1s, border-color 0.1s; }
.btn:hover { background: #2a3442; border-color: #445064; }
.btn:active { background: #1c232d; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn.primary { background: var(--red); border-color: var(--red-dark); color: #fff; }
.btn.primary:hover { background: #f03a53; }
.btn.blue { background: var(--blue); border-color: #3b74d9; color: #fff; }
.btn.blue:hover { background: #5f98ff; }
.btn.dark { background: #0a0e14; border-color: var(--border-2); color: var(--text); }
.btn.dark:hover { background: #12171f; }
.btn.danger { background: var(--red-soft); color: #ff6b7e; border-color: var(--red-border); }
.btn.danger:hover { background: rgba(229,36,63,0.25); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: rgba(255,255,255,0.07); border-color: transparent; color: var(--text); }
.btn.sm { height: 24px; padding: 0 8px; font-size: var(--fs-sm); }
.btn.xs { height: var(--ctl-sm); padding: 0 6px; font-size: var(--fs-xs); }
.btn.xs svg { width: 12px; height: 12px; }
.btn.icon { padding: 0; width: var(--ctl); }
.btn.icon.xs { width: var(--ctl-sm); }
.btn.icon.sm { width: 24px; }
.btn.block { width: 100%; }
.btn.lg { height: 34px; padding: 0 18px; font-size: 12.5px; }
.btn.on { background: var(--blue-soft); border-color: var(--blue-border); color: #8fb6ff; }
.btn-group { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.btn-group.joined { gap: 0; }
.btn-group.joined .btn { border-radius: 0; margin-left: -1px; }
.btn-group.joined .btn:first-child { border-radius: var(--r) 0 0 var(--r); margin-left: 0; }
.btn-group.joined .btn:last-child { border-radius: 0 var(--r) var(--r) 0; }
.toolbar { display: flex; align-items: center; gap: 4px; }
kbd { font-family: var(--font-mono); font-size: 9px; background: var(--panel-3); border: 1px solid var(--border-2); border-bottom-width: 2px; border-radius: 3px; padding: 0 4px; color: var(--text-2); line-height: 14px; display: inline-block; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 3px; margin-bottom: 8px; }
.field label, .field .label { font-weight: 600; font-size: var(--fs-sm); color: var(--text-2); display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.field .hint { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.field small { color: var(--muted); font-size: var(--fs-xs); line-height: 1.4; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--border-2); border-radius: var(--r); padding: 0 7px; height: var(--ctl); background: var(--input-bg); font-size: var(--fs); min-width: 0; color: var(--text); }
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.select { appearance: none; -webkit-appearance: none; padding-right: 22px; background-image: linear-gradient(45deg, transparent 50%, #8b98aa 50%), linear-gradient(135deg, #8b98aa 50%, transparent 50%); background-position: right 11px top 55%, right 7px top 55%; background-size: 4px 4px, 4px 4px; background-repeat: no-repeat; cursor: pointer; }
.select option { background: var(--panel-2); color: var(--text); }
.textarea { height: auto; min-height: 60px; padding: 6px 7px; resize: vertical; line-height: 1.45; font-family: inherit; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(79,140,255,0.25); }
button:focus-visible { outline: 2px solid rgba(79,140,255,0.6); outline-offset: 1px; }
.input.sm, .select.sm { height: var(--ctl-sm); font-size: var(--fs-sm); padding: 0 6px; }
.select.sm { padding-right: 20px; }
.input.num { width: 52px; text-align: right; font-family: var(--font-mono); font-size: var(--fs-sm); padding: 0 5px; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
input[type="range"] { width: 100%; accent-color: var(--red); height: 16px; margin: 0; }
.check { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap; color: var(--text-2); }
.check input { width: 13px; height: 13px; accent-color: var(--red); margin: 0; }
.toggle { position: relative; display: inline-block; width: 30px; height: 16px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track { position: absolute; inset: 0; background: var(--border-2); border-radius: 34px; cursor: pointer; transition: .15s; }
.toggle .track::before { content: ""; position: absolute; height: 12px; width: 12px; left: 2px; bottom: 2px; background: #fff; border-radius: 50%; transition: .15s; }
.toggle input:checked + .track { background: var(--red); }
.toggle input:checked + .track::before { transform: translateX(14px); }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: var(--fs); font-weight: 500; padding: 4px 0; }
.slider-row { display: grid; grid-template-columns: 1fr 52px; gap: 6px; align-items: center; margin-bottom: 6px; }
.slider-row .top { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.slider-row .top .hint { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }

/* ---------- Chips / badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; height: 18px; border-radius: 3px; font-size: var(--fs-xs); font-weight: 700; background: var(--panel-3); color: var(--text-2); white-space: nowrap; letter-spacing: 0.02em; }
.badge.red { background: var(--red-soft); color: #ff8091; }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.amber { background: var(--warning-soft); color: var(--warning); }
.badge.grey { background: var(--panel-3); color: var(--muted); }
.badge.dark { background: #0a0e14; color: var(--text-2); border: 1px solid var(--border-2); }
.badge.blue { background: var(--blue-soft); color: #8fb6ff; }
.rag { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: var(--fs-sm); }
.rag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; flex-shrink: 0; }
.rag.green::before { background: var(--success); }
.rag.amber::before { background: var(--warning); }
.rag.red::before { background: var(--danger); }

/* ---------- Notices ---------- */
.notice { padding: 7px 10px; border-radius: var(--r); border: 1px solid var(--border); background: var(--panel-2); font-size: var(--fs-sm); line-height: 1.5; color: var(--text-2); }
.notice.info { background: var(--blue-soft); border-color: var(--blue-border); color: #bcd3ff; }
.notice.success { background: var(--success-soft); border-color: rgba(62,207,107,0.4); color: #9ae8b4; }
.notice.warn { background: var(--warning-soft); border-color: rgba(245,178,60,0.4); color: #f8d38f; }
.notice.danger { background: var(--danger-soft); border-color: rgba(255,93,108,0.4); color: #ffb3bb; }
.help { font-size: var(--fs-xs); color: var(--muted); line-height: 1.5; }

/* ---------- Toasts ---------- */
.toast-host { position: fixed; bottom: 12px; right: 12px; display: grid; gap: 5px; z-index: 9999; max-width: 340px; }
.toast { background: var(--panel-3); color: var(--text); padding: 8px 11px; border-radius: var(--r); font-size: var(--fs-sm); box-shadow: 0 8px 24px rgba(0,0,0,0.5); border: 1px solid var(--border-2); border-left: 3px solid #94a3b8; animation: toast-in 0.15s ease; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; backdrop-filter: blur(2px); }
.modal { background: var(--panel); border-radius: var(--r-lg); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; box-shadow: 0 24px 70px rgba(0,0,0,0.6); border: 1px solid var(--border-2); }
.modal.wide { max-width: 880px; }
.modal-header { padding: 0 8px 0 14px; height: 36px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--panel-2); z-index: 2; }
.modal-header h3 { font-size: var(--fs-sm); text-transform: uppercase; font-weight: 700; letter-spacing: 0.09em; color: var(--text-2); }
.modal-body { padding: 14px; }
.modal-footer { padding: 8px 14px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 5px; background: var(--panel-2); position: sticky; bottom: 0; }

/* ---------- Tabs (segmented) ---------- */
.tabs { display: flex; gap: 2px; padding: 5px; background: var(--panel-2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.tab { flex: 1; height: 22px; border: 1px solid transparent; background: transparent; font-weight: 600; font-size: var(--fs-xs); color: var(--muted); cursor: pointer; border-radius: var(--r); text-transform: uppercase; letter-spacing: 0.07em; }
.tab:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.tab.active { color: var(--text); background: var(--panel-3); border-color: var(--border-2); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs); }
.table th, .table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); background: var(--panel-2); height: 28px; font-weight: 700; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--panel-hover); }
.table td.num { font-family: var(--font-mono); }
.table .thumb { width: 60px; height: 34px; object-fit: cover; border-radius: 3px; background: #0a0e14; display: block; }
.table .thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--muted-2); font-size: 9px; font-weight: 700; border: 1px dashed var(--border-2); }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { vertical-align: middle; }
.table .title { font-weight: 600; }
.table .sub { color: var(--muted); font-size: var(--fs-xs); margin-top: 1px; max-width: 480px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Empty / template picker ---------- */
.empty-state { text-align: center; padding: 36px 20px; color: var(--muted); border: 1px dashed var(--border-2); border-radius: var(--r-lg); background: var(--panel); font-size: var(--fs); }
.empty-state strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px; font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.06em; }
.template-list { display: grid; gap: 6px; }
.template-item { display: flex; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r); cursor: pointer; background: var(--panel-2); text-align: left; align-items: flex-start; width: 100%; }
.template-item:hover { border-color: var(--border-2); background: var(--panel-3); }
.template-item.active { border-color: var(--blue); background: var(--blue-soft); }
.template-item .t-icon { width: 26px; height: 26px; border-radius: var(--r); background: var(--panel-3); color: var(--text); display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: 1px solid var(--border-2); }
.template-item .t-icon svg { width: 14px; height: 14px; }
.template-item strong { display: block; font-size: var(--fs); }
.template-item span { font-size: var(--fs-sm); color: var(--muted); }

/* ============================================================
   BUILDER
   ============================================================ */
.builder-topbar { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; margin-bottom: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 4px 6px; flex-shrink: 0; height: 38px; }
.builder-topbar .title-input { font-weight: 600; font-size: 13px; border: 1px solid transparent; height: var(--ctl); padding: 0 6px; border-radius: var(--r); flex: 1; min-width: 120px; background: transparent; color: var(--text); }
.builder-topbar .title-input:hover { border-color: var(--border-2); }
.builder-topbar .title-input:focus { border-color: var(--blue); background: var(--input-bg); box-shadow: 0 0 0 2px rgba(79,140,255,0.25); outline: none; }
.builder-topbar .select { max-width: 180px; height: var(--ctl-sm); font-size: var(--fs-sm); }
.save-state { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; white-space: nowrap; min-width: 90px; justify-content: flex-end; }
.save-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.save-state.dirty { color: var(--warning); }
.save-state.dirty::before { background: var(--warning); }
.readiness { display: inline-flex; align-items: center; gap: 6px; height: var(--ctl-sm); padding: 0 8px; border-radius: 999px; border: 1px solid var(--border-2); background: var(--panel-2); font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.readiness:hover { border-color: #445064; }
.readiness .bar { width: 54px; height: 4px; background: var(--border-2); border-radius: 2px; overflow: hidden; }
.readiness .bar div { height: 100%; background: var(--success); }
.readiness.partial .bar div { background: var(--warning); }
.checklist { display: grid; gap: 4px; }
.checklist .item { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: var(--r); background: var(--panel-2); border: 1px solid var(--border); font-size: var(--fs-sm); }
.checklist .item .st { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; font-weight: 800; }
.checklist .item.ok .st { background: var(--success-soft); color: var(--success); }
.checklist .item.todo .st { background: var(--warning-soft); color: var(--warning); }
.checklist .item .miss { color: var(--muted); font-size: var(--fs-xs); }

.builder-shell { flex: 1; min-height: 0; display: grid; grid-template-columns: 224px minmax(0, 1fr) 336px; grid-template-rows: minmax(0, 1fr); gap: 8px; align-items: stretch; }
.builder-col { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; }
.builder-col .panel.assets { flex: 1 1 0; }
@media (max-width: 1500px) { .builder-shell { grid-template-columns: 208px minmax(0, 1fr) 316px; } }
@media (max-width: 1150px) {
  body.app-body { height: auto; overflow: auto; }
  .builder-shell { grid-template-columns: 1fr; }
  .scene-shell { height: 56vh; }
  .builder-topbar { flex-wrap: wrap; height: auto; }
}

/* Filmstrip (stages) */
.filmstrip-wrap { border-top: 1px solid var(--border); background: var(--panel-2); flex-shrink: 0; display: flex; flex-direction: column; }
.filmstrip-head { display: flex; align-items: center; justify-content: space-between; height: 26px; padding: 0 8px; }
.filmstrip-head h3 { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-2); }
.filmstrip { display: flex; gap: 6px; padding: 0 8px 8px; overflow-x: auto; overflow-y: hidden; scroll-behavior: smooth; }
.film { flex: 0 0 auto; width: 118px; border-radius: var(--r); border: 1px solid var(--border-2); background: var(--panel); cursor: pointer; user-select: none; overflow: hidden; position: relative; transition: border-color 0.1s; }
.film:hover { border-color: #4a566b; }
.film.active { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.film.dragging { opacity: 0.4; }
.film.drop-before::before, .film.drop-after::after { content: ""; position: absolute; top: 0; bottom: 0; width: 3px; background: var(--blue); z-index: 2; }
.film.drop-before::before { left: -4px; }
.film.drop-after::after { right: -4px; }
.film .thumb { width: 100%; height: 64px; object-fit: cover; display: block; background: #0a0e14; }
.film .thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--muted-2); font-size: 9px; font-weight: 700; letter-spacing: 0.05em; }
.film .num { position: absolute; top: 4px; left: 4px; background: rgba(10,14,20,0.85); color: var(--text); font-family: var(--font-mono); font-size: 9.5px; font-weight: 600; padding: 1px 5px; border-radius: 3px; }
.film.active .num { background: var(--blue); color: #fff; }
.film .flags { position: absolute; top: 4px; right: 4px; display: flex; gap: 2px; }
.film .flags span { width: 14px; height: 14px; border-radius: 3px; background: rgba(10,14,20,0.85); display: grid; place-items: center; }
.film .flags svg { width: 9px; height: 9px; }
.film .flags .twist { color: #ff8091; }
.film .flags .warn { color: var(--warning); }
.film .cap { padding: 4px 6px 5px; }
.film .name { font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.film .phase { font-size: 9px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.film.add { border-style: dashed; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 4px; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; height: 98px; background: transparent; }
.film.add:hover { color: var(--text); border-color: var(--blue); }
.film.add svg { width: 16px; height: 16px; }

/* Asset list */
.asset-section-title { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 8px 6px 3px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.asset-section-title .chev { transition: transform 0.15s; opacity: 0.6; }
.asset-section-title .chev svg { width: 10px; height: 10px; }
.asset-section-title.collapsed .chev { transform: rotate(-90deg); }
.asset-section-title.collapsed + .asset-list { display: none; }
.asset-list { display: grid; gap: 1px; }
.asset-row { display: flex; align-items: center; gap: 7px; height: 24px; padding: 0 6px; border-radius: var(--r); cursor: grab; border: 1px solid transparent; background: transparent; width: 100%; text-align: left; color: var(--text); }
.asset-row:hover { background: var(--panel-hover); border-color: var(--border); }
.asset-row:active { cursor: grabbing; }
.asset-row svg { width: 18px; height: 18px; flex-shrink: 0; }
.asset-row span { font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-row .add { margin-left: auto; opacity: 0; color: var(--muted); }
.asset-row:hover .add { opacity: 1; }
.asset-row .add svg { width: 12px; height: 12px; }

/* Canvas / scene */
.scene-panel { display: flex; flex-direction: column; min-height: 0; }
.scene-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; padding: 4px 6px; border-bottom: 1px solid var(--border); background: var(--panel-2); flex-shrink: 0; min-height: 34px; }
.scene-toolbar .group { display: flex; gap: 3px; align-items: center; }
.scene-toolbar .group .check { padding: 0 4px; }
.scene-toolbar input[type="range"] { width: 60px; }
.scene-shell { position: relative; background: var(--scene-bg); flex: 1; min-height: 260px; overflow: hidden; background-image: radial-gradient(var(--scene-dot) 1px, transparent 1px); background-size: 18px 18px; }
.scene-shell.drop-active { outline: 2px dashed var(--blue); outline-offset: -5px; }
.scene-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px; height: 26px; border-top: 1px solid var(--border); background: var(--panel-2); flex-shrink: 0; font-size: var(--fs-xs); color: var(--muted); }
.scene-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); text-align: center; padding: 30px; font-size: var(--fs); }
.scene-empty strong { color: var(--text); font-size: 13px; font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.08em; }
.onboard { display: grid; gap: 8px; max-width: 420px; }
.onboard .steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: left; margin-top: 8px; }
.onboard .step { background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--r); padding: 8px; font-size: var(--fs-xs); color: var(--text-2); }
.onboard .step b { display: block; color: var(--text); font-size: var(--fs-sm); margin-bottom: 2px; }
.onboard .step i { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--red); color: #fff; font-style: normal; font-size: 9px; font-weight: 800; margin-right: 4px; }
.scene-box { position: absolute; overflow: visible; }
.scene-box img.scene-img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; pointer-events: none; -webkit-user-drag: none; }
.scene-box canvas.scene-particles { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.scene-box .scene-overlays { position: absolute; inset: 0; z-index: 6; }
.scene-chip { position: absolute; top: 8px; left: 8px; z-index: 20; background: rgba(5,8,13,0.85); color: var(--text-2); font-family: var(--font-mono); font-size: 9.5px; font-weight: 600; letter-spacing: 0.06em; padding: 3px 7px; border-radius: 3px; pointer-events: none; text-transform: uppercase; }
.scene-chip.right { left: auto; right: 8px; }

/* Floating element toolbar */
.ov-toolbar { position: absolute; z-index: 50; display: flex; gap: 2px; padding: 3px; background: rgba(21,26,34,0.96); border: 1px solid var(--border-2); border-radius: 5px; box-shadow: 0 6px 20px rgba(0,0,0,0.5); transform: translate(-50%, -100%); }
.ov-toolbar .btn { height: 22px; width: 22px; padding: 0; border-color: transparent; background: transparent; color: var(--text-2); }
.ov-toolbar .btn:hover { background: var(--panel-3); color: var(--text); }
.ov-toolbar .btn.danger { color: #ff6b7e; }
.ov-toolbar .lbl { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); padding: 0 6px; display: flex; align-items: center; max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--border-2); margin-right: 2px; }

/* Overlays */
.ov { position: absolute; transform: translate(-50%, -50%); touch-action: none; user-select: none; }
.ov .ov-visual { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5)); }
.ov .ov-visual svg { width: 100%; height: 100%; display: block; }
.ov .ov-label { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 3px; background: rgba(5,8,13,0.85); color: #fff; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 3px; white-space: nowrap; pointer-events: none; }
.ov.type-emitter .ov-visual { opacity: 0.85; }
.ov.type-emitter .ov-visual svg { filter: none; }
.ov.type-zone .ov-visual { border: 2px dashed rgba(255,255,255,0.9); border-radius: 50%; background: rgba(229,36,63,0.18); box-shadow: 0 0 0 2px rgba(229,36,63,0.5); filter: none; }
.ov.type-zone.zone-warm .ov-visual { background: rgba(245,178,60,0.18); box-shadow: 0 0 0 2px rgba(245,178,60,0.7); }
.ov.type-zone.zone-cold .ov-visual { background: rgba(79,140,255,0.15); box-shadow: 0 0 0 2px rgba(79,140,255,0.7); }
.ov.type-text .ov-visual { background: rgba(5,8,13,0.85); color: #fff; font-weight: 600; padding: 4px 8px; border-radius: 4px; font-size: 12px; text-align: center; white-space: pre-wrap; line-height: 1.3; filter: none; }
.ov.type-text .ov-visual.sector { background: var(--red); font-family: var(--font-display); font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; }
.ov.editable { cursor: grab; }
.ov.editable:active { cursor: grabbing; }
.ov.selected { outline: 1.5px solid var(--blue); outline-offset: 4px; border-radius: 3px; z-index: 999 !important; }
.ov.hidden-trainee .ov-visual { opacity: 0.45; }
.ov.hidden-trainee::after { content: "HIDDEN"; position: absolute; top: -8px; right: -8px; background: #475569; color: #fff; font-size: 7.5px; font-weight: 800; padding: 1px 4px; border-radius: 3px; }
.ov.delayed::before { content: attr(data-delay); position: absolute; top: -8px; left: -8px; background: var(--blue); color: #fff; font-size: 7.5px; font-weight: 800; padding: 1px 4px; border-radius: 3px; font-family: var(--font-mono); }
.ov-handle { position: absolute; width: 9px; height: 9px; background: #fff; border: 1.5px solid var(--blue); border-radius: 2px; display: none; z-index: 30; }
.ov.selected .ov-handle { display: block; }
.ov-handle.se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.ov-handle.sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.ov-handle.ne { right: -8px; top: -8px; cursor: nesw-resize; }
.ov-handle.nw { left: -8px; top: -8px; cursor: nwse-resize; }
.ov-handle.rot { left: 50%; top: -24px; transform: translateX(-50%); cursor: grab; border-radius: 50%; background: var(--blue); }
.ov-handle.rot::before { content: ""; position: absolute; left: 50%; top: 100%; width: 1.5px; height: 12px; background: var(--blue); transform: translateX(-50%); }

/* Properties panel */
#propsPanel { display: flex; flex-direction: column; min-height: 0; }
#propsPanel .tab-pane.active { display: block; overflow: auto; flex: 1; min-height: 0; }
.props-section { border-bottom: 1px solid var(--border); padding: 8px 10px 10px; }
.props-section:last-child { border-bottom: none; }
.props-section h4 { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin-bottom: 7px; display: flex; justify-content: space-between; align-items: center; min-height: 22px; }
.props-section .field:last-child { margin-bottom: 0; }
.kp-list { display: grid; gap: 4px; }
.kp-item { display: flex; gap: 4px; align-items: center; }
.kp-item .input { flex: 1; }
.kp-item .req { display: flex; align-items: center; gap: 3px; font-size: var(--fs-xs); color: var(--muted); font-weight: 700; white-space: nowrap; cursor: pointer; }
.kp-item .req input { accent-color: var(--red); margin: 0; }
.inject-item { display: grid; grid-template-columns: 52px 1fr auto; gap: 4px; align-items: center; margin-bottom: 4px; }
.skill-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.skill-chip { display: flex; align-items: center; gap: 5px; height: 24px; padding: 0 7px; border: 1px solid var(--border-2); border-radius: var(--r); font-size: var(--fs-xs); font-weight: 600; cursor: pointer; line-height: 1.1; color: var(--text-2); background: var(--panel-2); }
.skill-chip input { accent-color: var(--red); margin: 0; flex-shrink: 0; width: 12px; height: 12px; }
.skill-chip.on { border-color: var(--blue-border); background: var(--blue-soft); color: #8fb6ff; }
.props-empty { padding: 26px 14px; color: var(--muted); font-size: var(--fs-sm); text-align: center; line-height: 1.6; }
.range-row { margin-bottom: 2px; }
.range-row .field { margin: 0; gap: 0; }
.fire-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.fire-presets button { font-size: 9.5px; padding: 0 2px; white-space: normal; line-height: 1.1; height: 28px; }
.fire-presets button.on { background: var(--red-soft); border-color: var(--red-border); color: #ff8091; }
.ai-assist { background: linear-gradient(135deg, rgba(79,140,255,0.12), rgba(139,92,246,0.12)); border: 1px solid rgba(120,130,255,0.35); border-radius: var(--r); padding: 7px 8px; }
.ai-assist p { font-size: var(--fs-xs); color: #c3cdfa; margin-bottom: 5px; line-height: 1.4; }

/* ============================================================
   PLAYER
   ============================================================ */
.player-shell { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: minmax(0, 1fr); gap: 8px; align-items: stretch; }
.player-left { display: flex; flex-direction: column; min-height: 0; gap: 4px; }
.player-right { display: flex; flex-direction: column; min-height: 0; overflow: auto; gap: 8px; padding-right: 2px; }
.player-scene { position: relative; background: var(--scene-bg); flex: 1; min-height: 300px; overflow: hidden; border-radius: var(--r-lg); border: 1px solid var(--border); }
@media (max-width: 1150px) {
  .player-shell { grid-template-columns: 1fr; }
  .player-scene { height: 56vh; flex: none; }
  .player-right { overflow: visible; }
}
.player-hud { position: absolute; left: 0; right: 0; bottom: 0; z-index: 30; padding: 10px 12px; background: linear-gradient(to top, rgba(5,8,13,0.92), rgba(5,8,13,0)); color: #fff; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; pointer-events: none; }
.player-hud .hud-title { font-family: var(--font-display); text-transform: uppercase; font-size: 14px; letter-spacing: 0.06em; line-height: 1.1; }
.player-hud .hud-sub { font-size: var(--fs-xs); color: var(--text-2); margin-top: 2px; }
.player-hud .hud-timer { font-family: var(--font-mono); font-size: 22px; font-weight: 600; line-height: 1; }
.player-hud .hud-timer.warn { color: var(--warning); }
.player-hud .hud-timer.danger { color: var(--danger); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.inject-banner { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 40; background: rgba(229,36,63,0.96); color: #fff; padding: 7px 14px; border-radius: var(--r); font-weight: 600; font-size: var(--fs); max-width: 80%; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,0.5); animation: inject-in 0.3s ease; border: 1px solid rgba(255,255,255,0.5); }
@keyframes inject-in { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.stage-progress { display: flex; gap: 3px; margin-bottom: 6px; flex-shrink: 0; }
.stage-progress span { flex: 1; height: 4px; border-radius: 2px; background: var(--border-2); }
.stage-progress span.done { background: var(--red); }
.stage-progress span.current { background: var(--text); }
.inject-log { font-size: var(--fs-xs); color: var(--muted); max-height: 48px; overflow: auto; flex: 1; }
.steps { display: flex; gap: 0; border-bottom: 1px solid var(--border); background: var(--panel-2); flex-shrink: 0; }
.steps .stp { flex: 1; display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2); border-right: 1px solid var(--border); }
.steps .stp:last-child { border-right: none; }
.steps .stp i { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--border-2); font-style: normal; font-size: 9px; }
.steps .stp.active { color: var(--text); background: var(--panel-3); }
.steps .stp.active i { background: var(--red); border-color: var(--red); color: #fff; }
.steps .stp.done { color: var(--success); }
.steps .stp.done i { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.narrative { font-size: var(--fs); line-height: 1.6; color: var(--text); }
.narrative p { margin-bottom: 6px; }
.narrative p:last-child { margin-bottom: 0; }
.radio-msg { display: flex; gap: 8px; background: #0a0e14; color: #cfe8d6; padding: 8px 10px; border-radius: var(--r); font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.5; margin: 8px 0; align-items: flex-start; border: 1px solid var(--border); border-left: 3px solid var(--success); }
.radio-msg svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; color: var(--success); }
.prompt-box { background: var(--red-soft); border: 1px solid var(--red-border); border-left: 3px solid var(--red); border-radius: var(--r); padding: 8px 10px; font-weight: 600; font-size: var(--fs); color: var(--prompt-fg); margin-top: 8px; }
.rec-area { display: grid; gap: 7px; }
.rec-button { width: 100%; height: 44px; border-radius: var(--r); border: 1px solid var(--red-dark); background: var(--red); color: #fff; font-weight: 700; font-size: var(--fs); display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-transform: uppercase; letter-spacing: 0.08em; }
.rec-button:hover { background: #f03a53; }
.rec-button svg { width: 16px; height: 16px; }
.rec-button.recording { background: var(--panel-3); color: #ff8091; border-color: var(--red); animation: rec-pulse 1.3s ease-in-out infinite; }
@keyframes rec-pulse { 0% { box-shadow: 0 0 0 0 rgba(229,36,63,0.5); } 70% { box-shadow: 0 0 0 10px rgba(229,36,63,0); } 100% { box-shadow: 0 0 0 0 rgba(229,36,63,0); } }
.rec-button:disabled { opacity: 0.55; cursor: not-allowed; }
.level-meter { height: 4px; border-radius: 2px; background: var(--border-2); overflow: hidden; }
.level-meter > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--success), var(--warning), var(--danger)); transition: width 0.08s; }
.transcript-box { border: 1px solid var(--border-2); border-radius: var(--r); padding: 8px; background: var(--input-bg); font-size: var(--fs); line-height: 1.55; min-height: 56px; color: var(--text); }
.spinner { width: 13px; height: 13px; border: 2px solid var(--border-2); border-top-color: var(--red); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.feedback-card { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.feedback-card .fc-head { padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; background: var(--panel-2); border-bottom: 1px solid var(--border); }
.feedback-card .fc-body { padding: 8px 10px; font-size: var(--fs-sm); }
.feedback-card ul { padding-left: 16px; margin: 2px 0 6px; }
.feedback-card li { margin-bottom: 2px; }
.feedback-card h5 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 8px 0 3px; }
.score-ring { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-mono); font-weight: 700; font-size: 13px; background: conic-gradient(var(--ring, #94a3b8) calc(var(--pct, 0) * 1%), var(--border-2) 0); position: relative; flex-shrink: 0; }
.score-ring::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--panel); }
.score-ring span { position: relative; color: var(--text); }
.skill-bars { display: grid; gap: 4px; }
.skill-bar { display: grid; grid-template-columns: 130px 1fr 28px; gap: 7px; align-items: center; font-size: var(--fs-sm); font-weight: 500; }
.skill-bar .bar { height: 6px; background: var(--border-2); border-radius: 3px; overflow: hidden; }
.skill-bar .bar > div { height: 100%; background: var(--red); border-radius: 3px; }
.skill-bar .val { font-family: var(--font-mono); text-align: right; color: var(--muted); font-size: var(--fs-xs); }
.debrief-hero { background: linear-gradient(135deg, #1a2029, #0f141b); color: #fff; border-radius: var(--r-lg); padding: 16px 20px; display: flex; gap: 20px; align-items: center; flex-wrap: wrap; border: 1px solid var(--border-2); border-left: 4px solid var(--red); }
.debrief-hero .big { font-family: var(--font-mono); font-size: 40px; font-weight: 700; line-height: 1; }
.debrief-hero h2 { font-family: var(--font-display); text-transform: uppercase; font-size: 18px; letter-spacing: 0.05em; }
.debrief-hero p { color: var(--text-2); font-size: var(--fs-sm); }
.log-entry { border-left: 3px solid var(--border-2); padding: 6px 10px; margin-bottom: 8px; background: var(--panel-2); border-radius: 0 var(--r) var(--r) 0; }
.log-entry.green { border-left-color: var(--success); }
.log-entry.amber { border-left-color: var(--warning); }
.log-entry.red { border-left-color: var(--danger); }
.log-entry blockquote { font-style: italic; color: var(--text-2); margin: 4px 0; padding-left: 8px; border-left: 2px solid var(--border-2); font-size: var(--fs-sm); }
.log-entry summary { color: #8fb6ff; }
.start-card { max-width: 720px; margin: 0 auto; }
.brief-list { display: grid; gap: 0; font-size: var(--fs); }
.brief-list div { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.brief-list div:last-child { border-bottom: none; }
.brief-list div b { color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.07em; padding-top: 2px; font-weight: 700; }
.section-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 8px 0 3px; font-weight: 700; }

/* ============================================================
   EXAM MODE (trainee player): comfortable reading scale.
   Applied by player.js on <html>. Instructor tools keep the
   dense workbench scale.
   ============================================================ */
html.exam-mode {
  --fs: 15px; --fs-sm: 13.5px; --fs-xs: 12px;
  --ctl: 36px; --ctl-sm: 30px;
  --r: 8px; --r-lg: 12px;
  --header-h: 50px;
}
html.exam-mode body { line-height: 1.5; }
html.exam-mode .brand h1 { font-size: 15px; }
html.exam-mode .brand p { font-size: 11.5px; }
html.exam-mode .brand-icon { width: 28px; height: 28px; }
html.exam-mode .nav a, html.exam-mode .nav button { height: 32px; padding: 0 14px; font-size: 13px; }
html.exam-mode .status-pill { height: 28px; font-size: 11.5px; }
html.exam-mode .page { padding: 22px 24px 60px; }
html.exam-mode .app-shell { padding: 12px 14px 14px; }
html.exam-mode .panel-header { height: auto; min-height: 44px; padding: 10px 16px; }
html.exam-mode .panel-header h3 { font-size: 12.5px; letter-spacing: 0.08em; }
html.exam-mode .panel-header p, html.exam-mode .panel-header:has(p) p { font-size: 13px; margin-top: 3px; }
html.exam-mode .panel-body { padding: 16px; }
html.exam-mode .btn { padding: 0 16px; font-size: 14px; }
html.exam-mode .btn svg { width: 16px; height: 16px; }
html.exam-mode .btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
html.exam-mode .btn.xs { height: 28px; padding: 0 10px; font-size: 12.5px; }
html.exam-mode .btn.lg { height: 46px; padding: 0 26px; font-size: 15px; }
html.exam-mode .field { gap: 5px; margin-bottom: 14px; }
html.exam-mode .field label, html.exam-mode .field .label { font-size: 13.5px; }
html.exam-mode .field small { font-size: 12.5px; }
html.exam-mode .input, html.exam-mode .select, html.exam-mode .textarea { font-size: 15px; padding: 0 12px; }
html.exam-mode .textarea { padding: 10px 12px; min-height: 120px; line-height: 1.55; }
html.exam-mode .toggle { width: 42px; height: 24px; }
html.exam-mode .toggle .track::before { width: 18px; height: 18px; left: 3px; bottom: 3px; }
html.exam-mode .toggle input:checked + .track::before { transform: translateX(18px); }
html.exam-mode .toggle-row { font-size: 14.5px; padding: 8px 0; }
html.exam-mode .badge { height: 24px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
html.exam-mode .notice { padding: 12px 14px; font-size: 14px; }
html.exam-mode .help { font-size: 12.5px; }
html.exam-mode .modal { max-width: 640px; }
html.exam-mode .modal-body { padding: 20px; }
html.exam-mode .toast { font-size: 14px; padding: 11px 14px; }

/* Start screen */
html.exam-mode .start-card { max-width: 860px; }
html.exam-mode .brief-list { font-size: 14.5px; }
html.exam-mode .brief-list div { grid-template-columns: 140px 1fr; padding: 8px 0; }
html.exam-mode .brief-list div b { font-size: 12px; padding-top: 3px; }
html.exam-mode .section-label { font-size: 12px; margin: 14px 0 6px; }
html.exam-mode #loList ul { font-size: 14.5px; line-height: 1.6; }
html.exam-mode .level-meter { height: 8px; }

/* Stage screen */
html.exam-mode .player-shell { grid-template-columns: minmax(0, 1fr) 470px; gap: 14px; }
@media (max-width: 1250px) { html.exam-mode .player-shell { grid-template-columns: minmax(0, 1fr) 420px; } }
html.exam-mode .player-right { gap: 12px; }
html.exam-mode .stage-progress { gap: 5px; margin-bottom: 10px; }
html.exam-mode .stage-progress span { height: 7px; }
html.exam-mode .steps .stp { height: 42px; font-size: 12.5px; padding: 0 14px; gap: 8px; }
html.exam-mode .steps .stp i { width: 22px; height: 22px; font-size: 11px; }
html.exam-mode .player-hud { padding: 14px 18px; }
html.exam-mode .player-hud .hud-title { font-size: 20px; }
html.exam-mode .player-hud .hud-sub { font-size: 13px; }
html.exam-mode .player-hud .hud-timer { font-size: 32px; }
html.exam-mode .inject-banner { font-size: 16px; padding: 12px 22px; }
html.exam-mode .inject-log { font-size: 12.5px; max-height: 60px; }
html.exam-mode .narrative { font-size: 16px; line-height: 1.65; }
html.exam-mode .narrative p { margin-bottom: 10px; }
html.exam-mode .radio-msg { font-size: 14px; padding: 12px 14px; gap: 10px; margin: 12px 0; line-height: 1.6; }
html.exam-mode .radio-msg svg { width: 18px; height: 18px; }
html.exam-mode .prompt-box { font-size: 16px; padding: 14px 16px; line-height: 1.5; margin-top: 12px; }
html.exam-mode .rec-area { gap: 12px; }
html.exam-mode .rec-button { height: 60px; font-size: 16px; letter-spacing: 0.08em; gap: 12px; }
html.exam-mode .rec-button svg { width: 22px; height: 22px; }
html.exam-mode .transcript-box { font-size: 15px; padding: 14px; min-height: 90px; line-height: 1.6; }
html.exam-mode .feedback-card .fc-head { padding: 12px 16px; }
html.exam-mode .feedback-card .fc-body { padding: 14px 16px; font-size: 14.5px; line-height: 1.55; }
html.exam-mode .feedback-card h5 { font-size: 12px; margin: 12px 0 5px; }
html.exam-mode .feedback-card li { margin-bottom: 4px; }
html.exam-mode .score-ring { width: 64px; height: 64px; font-size: 18px; }
html.exam-mode .score-ring::before { inset: 7px; }
html.exam-mode .rag { font-size: 14px; }
html.exam-mode .rag::before { width: 11px; height: 11px; }
html.exam-mode .skill-bar { grid-template-columns: 170px 1fr 36px; font-size: 13.5px; }
html.exam-mode .skill-bar .bar { height: 8px; }
html.exam-mode .skill-bar .val { font-size: 12.5px; }
html.exam-mode .spinner { width: 16px; height: 16px; }

/* Debrief */
html.exam-mode .debrief-hero { padding: 24px 28px; gap: 28px; }
html.exam-mode .debrief-hero .big { font-size: 56px; }
html.exam-mode .debrief-hero h2 { font-size: 24px; }
html.exam-mode .debrief-hero p { font-size: 14px; }
html.exam-mode .log-entry { padding: 12px 16px; margin-bottom: 12px; }
html.exam-mode .log-entry blockquote { font-size: 14.5px; padding-left: 12px; margin: 8px 0; }
html.exam-mode .log-entry summary { font-size: 13.5px; }
html.exam-mode #debriefSummary, html.exam-mode #debriefSkills, html.exam-mode #debriefStages { font-size: 14.5px; line-height: 1.6; }
html.exam-mode #debriefSummary ul { padding-left: 20px; }

/* Login gate: same comfortable scale */
html.exam-mode .auth-card { width: 400px; padding: 28px; }
html.exam-mode .auth-card p { font-size: 14px; }
html.exam-mode .auth-card input[type=password] { height: 40px; font-size: 15px; }
html.exam-mode .auth-btn { height: 42px; font-size: 14px; }

/* ---------- Print ---------- */
@media print {
  :root { color-scheme: light; }
  .app-header, .no-print { display: none !important; }
  body, body.app-body { background: #fff; color: #111; height: auto; overflow: visible; display: block; }
  .page { padding: 0; max-width: none; }
  .panel, .log-entry, .debrief-hero { background: #fff; color: #111; border-color: #ccc; break-inside: avoid; }
  .debrief-hero p, .log-entry blockquote, .narrative, .help { color: #333; }
}
