/* ============================================================
   AuraMind VLA-Scout — 기술 검증소 (Proof Lab) 스타일
   대시보드와 동일한 토큰 체계 재사용.
   ============================================================ */
:root {
  --font-ui: system-ui, -apple-system, "Segoe UI", "Noto Sans KR", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --bg: #e9edf2; --surface-1: #ffffff; --surface-2: #f4f7fa; --surface-3: #eef2f7;
  --inset: #f7f9fc; --border: rgba(11,18,32,0.10); --border-strong: rgba(11,18,32,0.18);
  --text-1: #0b1220; --text-2: #45566a; --text-muted: #7c8a9b;
  --accent: #0a8ec2; --accent-ink: #0a6f99; --accent-dim: rgba(10,142,194,0.12); --accent-glow: rgba(10,142,194,0.28);
  --series-1: #2a78d6; --grid: #e1e6ee; --axis: #c3cbd6;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-ink: #0a7a0a; --warning-ink: #9a6b00; --serious-ink: #b4562f; --critical-ink: #b02a2a;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(11,18,32,0.06), 0 8px 24px rgba(11,18,32,0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #080b11; --surface-1: #0f141d; --surface-2: #131a25; --surface-3: #1a2331;
    --inset: #0b1017; --border: rgba(255,255,255,0.08); --border-strong: rgba(255,255,255,0.16);
    --text-1: #eef2f8; --text-2: #9fb0c4; --text-muted: #64748b;
    --accent: #3cc7f0; --accent-ink: #7ad8f5; --accent-dim: rgba(60,199,240,0.14); --accent-glow: rgba(60,199,240,0.32);
    --series-1: #3987e5; --grid: #1e2836; --axis: #2b3849;
    --good-ink: #34d058; --warning-ink: #fac638; --serious-ink: #f39d78; --critical-ink: #ef5a5a;
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 12px 32px rgba(0,0,0,0.45);
  }
}
:root[data-theme="dark"] {
  --bg: #080b11; --surface-1: #0f141d; --surface-2: #131a25; --surface-3: #1a2331;
  --inset: #0b1017; --border: rgba(255,255,255,0.08); --border-strong: rgba(255,255,255,0.16);
  --text-1: #eef2f8; --text-2: #9fb0c4; --text-muted: #64748b;
  --accent: #3cc7f0; --accent-ink: #7ad8f5; --accent-dim: rgba(60,199,240,0.14); --accent-glow: rgba(60,199,240,0.32);
  --series-1: #3987e5; --grid: #1e2836; --axis: #2b3849;
  --good-ink: #34d058; --warning-ink: #fac638; --serious-ink: #f39d78; --critical-ink: #ef5a5a;
  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 12px 32px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font-ui); background: var(--bg); color: var(--text-1); -webkit-font-smoothing: antialiased; line-height: 1.5; min-height: 100vh; }
.mono { font-family: var(--font-mono); }
.tnum { font-variant-numeric: tabular-nums; }
h1,h2,h3,h4 { margin: 0; font-weight: 650; text-wrap: balance; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.eyebrow { font-family: var(--font-mono); font-size: 12.0px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); font-weight: 500; }

/* ---------- top bar + shared nav ---------- */
.topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 11px 20px; background: var(--surface-1); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; flex: none; background: radial-gradient(120% 120% at 30% 20%, var(--accent), color-mix(in srgb, var(--accent) 40%, #05202b)); display: grid; place-items: center; box-shadow: 0 0 0 1px var(--border-strong), 0 0 18px var(--accent-glow); }
.brand-mark svg { width: 21px; height: 21px; }
.brand-name { font-size: 17.1px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.1; }
.brand-name b { color: var(--accent-ink); }
.brand-sub { font-size: 12.0px; color: var(--text-muted); }
.topnav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.topnav-tab { font-size: 14.2px; font-weight: 600; color: var(--text-2); text-decoration: none; padding: 7px 13px; border-radius: 8px; border: 1px solid transparent; transition: .15s; white-space: nowrap; }
.topnav-tab:hover { background: var(--surface-2); color: var(--text-1); }
.topnav-tab.is-active { background: var(--accent-dim); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.topbar-spacer { flex: 1; }

/* ---------- mode / badge system (🟦 시뮬레이션 · 🟩 LIVE · 🟨 설계·예정) ---------- */
.mode-pill, .badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12.0px; font-weight: 600; letter-spacing: .05em; padding: 5px 10px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.badge { font-size: 11.4px; padding: 3px 8px; }
.mode-pill .dot, .badge .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.badge .dot { width: 6px; height: 6px; }
.sim  { color: var(--series-1);    background: color-mix(in srgb, var(--series-1) 13%, transparent); border-color: color-mix(in srgb, var(--series-1) 32%, transparent); }
.live { color: var(--good-ink);    background: color-mix(in srgb, var(--good) 15%, transparent);     border-color: color-mix(in srgb, var(--good) 36%, transparent); }
.plan { color: var(--warning-ink); background: color-mix(in srgb, var(--warning) 15%, transparent);  border-color: color-mix(in srgb, var(--warning) 36%, transparent); }
.sim  .dot { background: var(--series-1); }
.live .dot { background: var(--good); animation: pulse 1.5s ease-in-out infinite; }
.plan .dot { background: var(--warning); }
/* 사전분석(실제 산출 완료) — 미구현(예정, 노랑)과 구분되는 중립/accent 배지 */
.precomp { color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 13%, transparent); border-color: color-mix(in srgb, var(--accent) 34%, transparent); }
.precomp .dot { background: var(--accent); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) {
  .live .dot, .beat-dot { animation: none !important; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

.icon-btn { width: 36px; height: 36px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); display: grid; place-items: center; transition: .15s; }
.icon-btn:hover { background: var(--surface-3); color: var(--text-1); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- page ---------- */
.wrap { max-width: 1220px; margin: 0 auto; padding: 24px 22px 64px; }
@media (max-width: 520px) { .wrap { padding: 18px 14px 48px; } }
.page-head { margin: 6px 0 18px; }
.page-head h1 { font-size: 26.2px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head p { color: var(--text-2); font-size: 15.4px; margin: 9px 0 0; max-width: 74ch; }

.callout { display: flex; gap: 13px; align-items: flex-start; background: color-mix(in srgb, var(--good) 8%, var(--surface-1)); border: 1px solid color-mix(in srgb, var(--good) 26%, var(--border)); border-radius: var(--radius); padding: 14px 16px; margin: 18px 0 22px; }
.callout .ic { flex: none; color: var(--good-ink); margin-top: 1px; }
.callout .ic svg { width: 20px; height: 20px; }
.callout b { color: var(--text-1); }
.callout p { margin: 0; font-size: 14.8px; color: var(--text-2); line-height: 1.6; }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card + .card { margin-top: 20px; }
.card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 15px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.card-head h2 { font-size: 17.7px; display: flex; align-items: center; gap: 9px; }
.card-head h2 svg { width: 18px; height: 18px; color: var(--accent-ink); }
.card-head .spacer { flex: 1; }
.card-body { padding: 20px 22px; }

.steps { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 6px 4px; align-items: center; }
.steps b { color: var(--accent-ink); font-weight: 600; }
.steps .arw { color: var(--text-muted); opacity: .6; }

/* ---------- live video analysis ---------- */
.vid-stage { position: relative; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #0b0f16; line-height: 0; }
.vid-stage video { display: block; width: 100%; height: auto; background: #0b0f16; }
.vid-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.vid-cam { position: absolute; right: 10px; top: 10px; z-index: 3; font-family: var(--font-mono); font-size: 12.0px; color: #cfe8f5; background: rgba(6,12,18,.55); border: 1px solid rgba(255,255,255,.18); padding: 4px 9px; border-radius: 6px; line-height: 1.35; text-align: right; }
.vid-ovl-badge { position: absolute; left: 10px; top: 10px; z-index: 3; }
.zones-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 16px; }
.zbar { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.zbar-track { width: 100%; height: 56px; background: var(--inset); border: 1px solid var(--border); border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden; }
.zbar-fill { width: 100%; height: 6%; background: var(--accent); transition: height .12s linear, background .2s; }
.zbar-v { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.zbar-label { font-size: 11.4px; color: var(--text-muted); letter-spacing: .02em; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 12.5px; color: var(--text-muted); align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.vid-note { font-size: 13.1px; color: var(--text-muted); line-height: 1.65; margin: 16px 0 0; padding: 11px 13px; background: var(--inset); border: 1px solid var(--border); border-left: 3px solid var(--warning); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.vid-note b { color: var(--text-2); }

/* ---------- VLM scene-understanding panel ---------- */
#vlmPanel { margin-top: 14px; }
.vlm-head { display: flex; gap: 11px; align-items: flex-start; margin-bottom: 12px; }
.vlm-headsev { flex: none; font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; padding: 4px 11px; border-radius: 999px; border: 1px solid; }
.vlm-summary { font-size: 15.4px; line-height: 1.55; color: var(--text-1); font-weight: 550; }
.vlm-items { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 720px){ .vlm-items { grid-template-columns: 1fr; } }
.vlm-item { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.vlm-sev { flex: none; font-family: var(--font-mono); font-size: 12.0px; font-weight: 700; padding: 3px 9px; border-radius: 999px; border: 1px solid; }
.vlm-b { min-width: 0; }
.vlm-l { font-size: 14.2px; font-weight: 650; color: var(--text-1); }
.vlm-n { font-size: 13.1px; color: var(--text-2); line-height: 1.5; margin-top: 3px; }
.vlm-beat { font-family: var(--font-mono); font-size: 12.0px; color: var(--text-muted); margin-top: 6px; display: inline-flex; align-items: center; gap: 6px; }
.beat-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); animation: pulse 1.5s ease-in-out infinite; flex: none; }
.vid-beat-hud { position: absolute; left: 10px; bottom: 10px; z-index: 3; font-family: var(--font-mono); font-size: 12.5px; color: #cfe8f5; background: rgba(6,12,18,.62); border: 1px solid rgba(255,255,255,.2); padding: 5px 11px; border-radius: 999px; display: inline-flex; align-items: center; gap: 7px; }
.vlm-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.zone-status { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); }
.live-ind { font-family: var(--font-mono); font-size: 12.0px; padding: 3px 9px; border-radius: 999px; border: 1px solid; }
.live-ind.on { color: var(--good-ink); background: color-mix(in srgb, var(--good) 13%, transparent); border-color: color-mix(in srgb, var(--good) 34%, transparent); }
.live-ind.off { color: var(--text-muted); background: var(--surface-2); border-color: var(--border); }

/* ---------- controls ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-2); font-size: 13.7px; font-weight: 600; padding: 6px 11px; border-radius: 7px; transition: .12s; white-space: nowrap; }
.seg button.on { background: var(--surface-1); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg button:hover:not(.on) { color: var(--text-1); }

.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-1); font-size: 14.2px; font-weight: 600; padding: 8px 14px; border-radius: 9px; transition: .14s; }
.btn:hover { background: var(--surface-3); }
.btn svg { width: 15px; height: 15px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- canvases ---------- */
.stage { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 860px) { .stage { grid-template-columns: 1fr; } }
.frame { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #0b0f16; }
.frame-label { font-family: var(--font-mono); font-size: 12.0px; letter-spacing: .05em; color: var(--text-2); padding: 7px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.frame-label .tag { color: var(--text-muted); font-size: 10.8px; }
.frame canvas { display: block; width: 100%; height: auto; background: #0b0f16; }

/* ---------- sliders ---------- */
.ctl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 22px; margin-top: 18px; }
.ctl label { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.7px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.ctl label .v { font-family: var(--font-mono); font-size: 13.7px; color: var(--accent-ink); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.switch-row { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.chk { display: inline-flex; align-items: center; gap: 8px; font-size: 14.2px; font-weight: 600; color: var(--text-2); }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- metrics ---------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: 12px; margin-top: 18px; }
.metric { background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px 14px; }
.metric .k { font-family: var(--font-mono); font-size: 11.4px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }
.metric .val { font-size: 25.1px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.metric .val small { font-size: 13.7px; font-weight: 600; color: var(--text-muted); margin-left: 2px; }

.detlist { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.det { display: flex; align-items: center; gap: 11px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.det .idx { font-family: var(--font-mono); font-weight: 700; font-size: 13.7px; color: #fff; background: var(--critical); width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; flex: none; }
.det .body { flex: 1; min-width: 0; }
.det .t { font-size: 14.2px; font-weight: 600; }
.det .m { font-family: var(--font-mono); font-size: 12.0px; color: var(--text-muted); }
.det.empty { color: var(--text-muted); font-size: 14.2px; justify-content: center; }

details.raw { margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--inset); }
details.raw summary { cursor: pointer; padding: 11px 14px; font-size: 13.7px; font-weight: 600; color: var(--text-2); user-select: none; }
details.raw summary:hover { color: var(--text-1); }
details.raw pre { margin: 0; padding: 0 14px 14px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55; color: var(--text-2); overflow-x: auto; }
.maps-when-live { color: var(--text-muted); font-size: 13.7px; margin-top: 4px; }

/* ---------- next-step cards ---------- */
.next-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .next-grid { grid-template-columns: 1fr; } }
.next-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 760px) { .next-grid-3 { grid-template-columns: 1fr; } }
.next { border: 1px dashed color-mix(in srgb, var(--warning) 40%, var(--border)); border-radius: var(--radius); padding: 16px 17px; background: color-mix(in srgb, var(--warning) 5%, var(--surface-1)); }
.next h3 { font-size: 16.0px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.next p { font-size: 14.2px; color: var(--text-2); line-height: 1.6; margin: 9px 0 0; }
.next .flow { font-family: var(--font-mono); font-size: 12.5px; color: var(--accent-ink); margin-top: 11px; background: var(--inset); border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; }

footer { max-width: 1180px; margin: 0 auto; padding: 22px 20px 40px; color: var(--text-muted); font-size: 13.1px; border-top: 1px solid var(--border); }
footer b { color: var(--text-2); }
.sep { margin: 0 8px; opacity: .5; }
