:root {
  color-scheme: dark;
  --ink: #eaf2f2;
  --muted: #93a9aa;
  --faint: #607778;
  --bg: #071415;
  --surface: #0d2021;
  --surface-2: #122829;
  --surface-3: #173233;
  --line: #244243;
  --teal: #47b5bd;
  --teal-soft: rgba(71, 181, 189, .13);
  --green: #89b36f;
  --amber: #d5ad5b;
  --red: #cf7e62;
  --shadow: 0 20px 60px rgba(0, 0, 0, .34);
  font-family: Inter, Aptos, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { overflow: hidden; }
button, a { font: inherit; }
button { cursor: pointer; }

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(71,181,189,.13), transparent 34%),
    radial-gradient(circle at 80% 75%, rgba(137,179,111,.09), transparent 32%),
    var(--bg);
}
.auth-card {
  width: min(470px, 100%);
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-card p { color: var(--muted); line-height: 1.6; margin: 24px 0 18px; }
.auth-card small { display: block; color: var(--faint); margin-top: 18px; line-height: 1.5; }
.auth-message { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.brand-lockup { display: flex; align-items: center; gap: 12px; line-height: 1.2; font-weight: 600; }
.brand-lockup.compact { font-size: 12px; }
.brand-gei { color: #ef3940; font-size: 30px; font-weight: 700; letter-spacing: -.05em; }
.compact .brand-gei { font-size: 23px; }
.brand-divider { width: 1px; align-self: stretch; background: var(--line); }

.primary-button, .quiet-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid var(--line);
}
.primary-button { background: var(--teal); border-color: var(--teal); color: #071415; font-weight: 700; }
.quiet-button { background: var(--surface-2); color: var(--muted); }
.quiet-button:hover { color: var(--ink); border-color: var(--teal); }

.app-shell { height: 100vh; min-height: 680px; display: grid; grid-template-rows: 60px minmax(0, 1fr); }
.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  z-index: 20;
}
.project-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.project-meta span:first-child { color: var(--ink); font-weight: 600; }
.meta-divider { width: 1px; height: 18px; background: var(--line); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

.review-layout { min-height: 0; display: grid; grid-template-columns: 210px minmax(520px, 1fr) 350px; }
.story-rail { min-height: 0; display: flex; flex-direction: column; padding: 16px 12px; border-right: 1px solid var(--line); background: var(--surface); }
.rail-heading { padding: 4px 9px 10px; color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
#scene-list { display: grid; gap: 5px; }
.scene-button {
  width: 100%;
  border: 0;
  border-radius: 9px;
  padding: 10px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  display: grid;
  grid-template-columns: 25px 1fr;
  gap: 8px;
  align-items: start;
}
.scene-button:hover { background: var(--surface-2); color: var(--ink); }
.scene-button[aria-current="page"] { background: var(--teal-soft); color: var(--ink); }
.scene-number { width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 50%; display: grid; place-items: center; font-size: 10px; }
.scene-button[aria-current="page"] .scene-number { background: var(--teal); border-color: var(--teal); color: var(--bg); }
.scene-label { font-size: 12px; font-weight: 600; }
.scene-label small { display: block; color: var(--faint); font-size: 10px; font-weight: 400; margin-top: 3px; }
.rail-note { margin-top: auto; padding: 14px 9px 3px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11px; line-height: 1.5; }
.rail-note strong, .rail-note span { display: block; }
.rail-note strong { color: var(--muted); margin-bottom: 4px; }

.model-stage { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); background: #0b1718; }
.stage-header { min-height: 84px; display: flex; gap: 18px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.stage-header > div:first-child { flex: 1; min-width: 0; }
.scene-status { color: var(--teal); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.stage-header h1 { margin: 5px 0 0; font-size: 18px; line-height: 1.25; font-weight: 600; }
.depth-control { display: flex; padding: 3px; gap: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; }
.depth-control button { min-height: 34px; padding: 6px 9px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 11px; }
.depth-control button[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); }

.viewer-frame { min-height: 0; position: relative; overflow: hidden; }
#viewer { position: absolute; inset: 0; }
.viewer-status { position: absolute; left: 18px; top: 16px; max-width: 430px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: rgba(13,32,33,.93); color: var(--muted); font-size: 11px; z-index: 8; }
.viewer-status:empty { display: none; }
.viewer-toolbar { position: absolute; top: 16px; right: 16px; display: flex; gap: 5px; z-index: 8; }
.viewer-toolbar button { min-height: 34px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: rgba(13,32,33,.93); color: var(--muted); font-size: 10px; }
.viewer-toolbar button:hover { color: var(--ink); border-color: var(--teal); }
.model-layers { position: absolute; left: 16px; bottom: 16px; width: min(290px, calc(100% - 32px)); padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(13,32,33,.94); z-index: 8; box-shadow: var(--shadow); }
.layer-heading { color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; margin: 0 0 7px; }
.layer-button { width: 100%; display: flex; align-items: center; gap: 8px; min-height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); text-align: left; padding: 5px 7px; font-size: 11px; }
.layer-button:hover { background: var(--surface-3); color: var(--ink); }
.layer-button[aria-pressed="true"] { color: var(--ink); }
.layer-swatch { width: 9px; height: 9px; border-radius: 50%; background: var(--layer-color); opacity: .35; }
.layer-button[aria-pressed="true"] .layer-swatch { opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--layer-color) 20%, transparent); }
.layer-meta { margin-left: auto; color: var(--faint); font-size: 9px; }

.decision-panel { min-height: 0; overflow: auto; padding: 18px; border-left: 1px solid var(--line); background: var(--surface); }
.panel-kicker { color: var(--teal); font-size: 10px; text-transform: uppercase; letter-spacing: .11em; font-weight: 700; }
.panel-view h2 { margin: 8px 0 10px; font-size: 19px; line-height: 1.3; font-weight: 600; }
.panel-view > p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.decision-block { margin-top: 17px; padding-top: 14px; border-top: 1px solid var(--line); }
.decision-block span, .source-list > span { display: block; color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.decision-block p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.decision-block.recommendation { padding: 12px; border: 0; border-left: 3px solid var(--teal); background: var(--teal-soft); border-radius: 0 8px 8px 0; }
.panel-action { width: 100%; margin-top: 17px; border: 0; }

.option-list { display: grid; gap: 8px; margin-top: 16px; }
.option-button { width: 100%; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); color: var(--ink); text-align: left; }
.option-button[aria-pressed="true"] { border-color: var(--teal); background: var(--teal-soft); }
.option-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 600; }
.option-status { color: var(--amber); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.option-story, .option-tradeoff { display: block; color: var(--muted); font-size: 11px; line-height: 1.45; margin-top: 5px; }
.option-tradeoff { padding-top: 5px; border-top: 1px solid var(--line); }

.evidence-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.evidence-card { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.evidence-kind { display: block; color: var(--faint); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.evidence-value { display: block; color: var(--ink); font-size: 16px; font-weight: 600; margin-top: 5px; }
.evidence-label { display: block; color: var(--muted); font-size: 10px; line-height: 1.35; margin-top: 3px; }
.question-list { margin-top: 16px; }
.question-list h3 { font-size: 11px; margin: 0 0 8px; color: var(--amber); }
.question-list ul, .source-list ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.source-list { margin-top: 15px; padding-top: 14px; border-top: 1px solid var(--line); }
.empty-state { margin-top: 16px; padding: 14px; border: 1px dashed var(--line); border-radius: 9px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.empty-state strong { display: block; color: var(--ink); margin-bottom: 5px; }
.empty-state p { margin: 0; }
.model-register { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.model-register summary { color: var(--ink); cursor: pointer; }
.register-row { margin-top: 9px; padding: 8px; background: var(--surface-2); border-radius: 7px; }
.register-row strong, .register-row span { display: block; }
.register-row span { color: var(--faint); margin-top: 2px; }
.register-row a { display: inline-block; color: var(--teal); margin-top: 5px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(16px); opacity: 0; padding: 9px 13px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 11px; pointer-events: none; transition: .2s ease; z-index: 50; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

@media (max-width: 1100px) {
  .review-layout { grid-template-columns: 190px minmax(470px, 1fr) 310px; }
  .project-meta { display: none; }
}
@media (max-width: 880px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; }
  .review-layout { grid-template-columns: 1fr; }
  .story-rail { display: none; }
  .model-stage { min-height: 650px; }
  .decision-panel { border-left: 0; border-top: 1px solid var(--line); }
}
