:root {
  color-scheme: light;
  --ink-deep: #1a2a3a;
  --ink-deeper: #142433;
  --ink-soft: #1c3348;
  --canvas: #e8eef4;
  --surface: #ffffff;
  --surface-soft: #f0f4f8;
  --ink: #1a2a3a;
  --muted: #5a6f84;
  --subtle: #6a7f94;
  --line: #c8d4e2;
  --violet: #1e4566;
  --violet-bright: #2f5f8a;
  --amber: #5a6f84;
  --amber-soft: #dce5ee;
  --teal: #1e4566;
  --teal-soft: #d5dee8;
  --rose: #1e4566;
  --rose-soft: #d5dee8;
  --shadow: 0 12px 38px rgba(26, 42, 58, 0.1);
  --radius: 16px;
  --display: "IBM Plex Sans", "Source Sans 3", ui-sans-serif, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: "Source Sans 3", "IBM Plex Sans", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
h1, h2, h3 { font-family: var(--display); }

html { min-width: 320px; background: var(--canvas); scroll-behavior: smooth; }

body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: var(--canvas); }

button, input, select, textarea { font: inherit; }

button:focus-visible, a:focus-visible { outline: 3px solid var(--violet-bright); outline-offset: 3px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; }

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 32px;
  border-bottom: 1px solid #c8d4e2;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--ink-deep);
  box-shadow: 0 7px 18px rgba(26, 42, 58, 0.22);
}

.brand-mark i { position: relative; width: 20px; height: 20px; display: block; border: 2px solid #fff; border-radius: 50%; }
.brand-mark i::before { content: ""; position: absolute; inset: -6px 2px; border: 2px solid rgba(255,255,255,0.75); border-radius: 50%; }

.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 16px; letter-spacing: -0.02em; }
.brand-copy small { color: var(--muted); font-size: 12px; }

.environment-labels { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }

.notice {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: #5a6f84;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 700;
}

.notice-synthetic { border-color: #8ab4d4; color: #1e4566; background: #d5dee8; }
.notice i { width: 7px; height: 7px; border-radius: 50%; background: var(--violet-bright); box-shadow: 0 0 0 3px rgba(47, 95, 138, 0.16); }

.workspace { max-width: 1500px; min-height: calc(100vh - 78px); display: grid; grid-template-columns: 330px minmax(0, 1fr); margin: 0 auto; }

.control-rail {
  min-width: 0;
  padding: 38px 28px 28px;
  color: #fff;
  background:
    radial-gradient(circle at -10% 22%, rgba(47, 95, 138, 0.28), transparent 34%),
    linear-gradient(168deg, var(--ink-deep) 0%, var(--ink-deeper) 100%);
}

.rail-heading { display: flex; gap: 13px; align-items: flex-start; }
.rail-step { width: 44px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 8px; color: #8ab4d4; background: rgba(255, 255, 255, 0.09); font: 800 10px/1 var(--mono); }
.eyebrow { margin: 0 0 6px; color: var(--violet); font: 800 11px/1.2 var(--mono); letter-spacing: 0.12em; }
.control-rail .eyebrow { color: #8ab4d4; }
.rail-heading h1 { margin: 0; font-size: 20px; line-height: 1.25; letter-spacing: -0.025em; }
.rail-intro { margin: 20px 0 26px; color: #b8c4d0; font-size: 14px; line-height: 1.6; }

.stage-tabs { display: grid; gap: 9px; }

.stage-tab {
  width: 100%;
  min-height: 62px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 12px;
  color: #e8eef4;
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.stage-tab:hover { border-color: rgba(255, 255, 255, 0.26); background: rgba(255, 255, 255, 0.07); transform: translateY(-1px); }
.stage-tab.is-active { border-color: rgba(47, 95, 138, 0.55); color: #fff; background: rgba(47, 95, 138, 0.22); box-shadow: inset 3px 0 0 #2f5f8a; }
.stage-tab.is-complete .stage-number { color: #2f5f8a; }
.stage-tab > span:nth-child(2) { min-width: 0; display: grid; gap: 3px; }
.stage-tab strong { font-size: 14px; }
.stage-tab small { color: #b8c4d0; font-size: 12px; }
.stage-tab.is-active small { color: #b8c4d0; }
.stage-number { color: #8fa0b0; font: 800 11px/1 var(--mono); }
.stage-tab.is-active .stage-number { color: #4a7ba8; }
.tab-check { opacity: 0; color: #2f5f8a; font-style: normal; font-weight: 900; }
.stage-tab.is-complete .tab-check { opacity: 1; }

.policy-note { margin-top: 24px; padding: 17px; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px; background: rgba(11, 21, 32, 0.55); }
.policy-heading-row { display: flex; align-items: center; gap: 9px; }
.policy-heading-row svg { width: 18px; height: 18px; fill: #2f5f8a; }
.policy-note h2 { margin: 0; font-size: 13px; }
.policy-note p { margin: 10px 0 0; color: #b8c4d0; font-size: 12px; line-height: 1.55; }
.keyboard-hint { margin: 18px 0 0; color: #8fa0b0; font-size: 12px; text-align: center; }
kbd { min-width: 21px; display: inline-grid; place-items: center; padding: 3px 5px; border: 1px solid rgba(255,255,255,.14); border-radius: 5px; color: #e8eef4; background: rgba(255,255,255,.06); font: inherit; }

.main-stage { min-width: 0; padding: 35px clamp(24px, 4vw, 58px) 50px; }

.stage-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.stage-heading h2 { margin: 0; font-size: clamp(24px, 3vw, 33px); line-height: 1.15; letter-spacing: -0.04em; }
.progress-anchor { flex: 0 0 auto; display: grid; gap: 6px; min-width: 150px; }
.progress-anchor span { color: var(--muted); font-size: 12px; }
.progress-anchor strong { font: 800 13px/1.2 var(--mono); }
.progress-track { height: 6px; border-radius: 2px; background: #d5dee8; overflow: hidden; }
.progress-fill { height: 100%; width: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--violet), var(--violet-bright)); transform: scaleX(0); transform-origin: left; transition: transform 220ms ease; }

.stage-panel { padding: 26px clamp(20px, 3vw, 30px); border: 1px solid #c8d4e2; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.stage-lede { margin: 0 0 20px; color: var(--muted); font-size: 15px; line-height: 1.6; }
.card-label { margin: 0 0 10px; color: var(--violet); font: 800 11px/1.2 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }

/* Stage 1: literature */
.paper-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.paper-item { padding: 15px 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.paper-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.paper-tag { padding: 2px 8px; border-radius: 2px; color: var(--violet); background: #d5dee8; font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.paper-title { margin: 0 0 5px; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.paper-relevance { margin: 0; color: #43514b; font-size: 14px; line-height: 1.55; }

/* Stage 2: derivation */
.hypothesis-card { padding: 16px 18px; margin-bottom: 20px; border: 1px solid #8ab4d4; border-radius: 12px; background: #d5dee8; }
.hypothesis-card p:not(.card-label) { margin: 0; color: var(--ink); font-size: 15px; line-height: 1.6; }
.derivation-steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.derivation-step { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.derivation-step-index { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: var(--violet); background: #d5dee8; font: 800 12px/1 var(--mono); }
.derivation-step-body strong { display: block; margin-bottom: 5px; font-size: 14px; }
.derivation-step-body .equation { display: block; margin: 6px 0; padding: 8px 12px; overflow-x: auto; color: #e8eef4; background: var(--ink-deeper); font: 14px/1.5 "Cambria Math", ui-serif, Georgia, serif; border-radius: 8px; }
.derivation-step-body p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

/* Stage 3: model comparison */
.model-picker { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 18px; }
.model-pill { display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 2px; color: var(--muted); background: var(--surface-soft); cursor: pointer; font-size: 13px; font-weight: 700; transition: border-color 140ms ease, color 140ms ease, background 140ms ease; }
.model-pill input { accent-color: var(--violet); }
.model-pill.is-checked { color: var(--violet); border-color: #8ab4d4; background: #d5dee8; }
.model-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.model-card { padding: 16px 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.model-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.model-card-heading strong { font-size: 15px; }
.model-confidence { padding: 2px 8px; border-radius: 2px; font-size: 11px; font-weight: 800; }
.model-confidence.is-high { color: #1e4566; background: #d5dee8; }
.model-confidence.is-medium { color: #3d5166; background: var(--amber-soft); }
.model-style { margin: 0 0 8px; color: var(--subtle); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.model-answer { margin: 0; color: #43514b; font-size: 14px; line-height: 1.6; }
.consensus-note { margin: 18px 0 0; padding: 12px 15px; border: 1px solid #8ab4d4; border-radius: 10px; color: #1e4566; background: var(--teal-soft); font-size: 14px; line-height: 1.5; }

/* Stage 4: simulation */
.simulation-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr); gap: 22px; }
.chart-card, .sim-summary { padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
#energy-chart { width: 100%; height: auto; }
.sim-stats { display: grid; gap: 12px; margin: 0; }
.sim-stats div { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.sim-stats div:last-child { border-bottom: 0; padding-bottom: 0; }
.sim-stats dt { margin: 0 0 4px; color: var(--muted); font-size: 12px; }
.sim-stats dd { margin: 0; font: 800 15px/1.3 var(--mono); }
.sim-stats dd.is-good { color: var(--teal); }

/* Stage 5: peer review */
.critique-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.critique-item { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 13px; padding: 14px 16px; border: 1px solid #8ab4d4; border-radius: 12px; background: var(--amber-soft); }
.critique-item.is-minor { border-color: var(--line); background: var(--surface-soft); }
.critique-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; color: var(--amber); background: #dce5ee; font-weight: 900; }
.critique-item.is-minor .critique-icon { color: var(--subtle); background: #d5dee8; }
.critique-body strong { display: block; margin-bottom: 4px; font-size: 14px; }
.critique-body p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

/* Stage 6: write-up */
.writeup-card { padding: 18px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.writeup-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.copy-button { padding: 7px 14px; border: 1px solid #8ab4d4; border-radius: 2px; color: var(--violet); background: #d5dee8; font-size: 12px; font-weight: 800; cursor: pointer; }
.copy-button:hover { background: #d5dee8; }
#writeup-status { min-height: 1.2em; margin: 0 0 8px; color: var(--teal); font-size: 12px; font-weight: 700; }
.writeup-text { color: var(--ink); font-size: 14px; line-height: 1.7; }
.writeup-text p { margin: 0 0 12px; }
.reference-list { margin: 16px 0 0; padding: 14px 0 0 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.7; }

.stage-nav { display: flex; justify-content: space-between; gap: 14px; margin-top: 20px; }
.stage-nav-button { padding: 11px 18px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); font-size: 14px; font-weight: 700; cursor: pointer; transition: border-color 140ms ease, background 140ms ease; }
.stage-nav-button:hover:not(:disabled) { border-color: #8ab4d4; background: #d5dee8; }
.stage-nav-button:disabled { opacity: 0.4; cursor: not-allowed; }
.stage-nav-button.primary { color: #fff; border-color: var(--violet); background: var(--violet); }
.stage-nav-button.primary:hover:not(:disabled) { background: var(--violet-bright); }

.disclaimer-footer { display: flex; align-items: center; gap: 11px; margin-top: 20px; padding: 13px 18px; border: 1px solid #8ab4d4; border-radius: 12px; background: #d5dee8; }
.disclaimer-footer svg { width: 22px; height: 22px; flex: 0 0 auto; fill: var(--violet); }
.disclaimer-footer p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.disclaimer-footer strong { color: var(--ink); }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 285px minmax(0, 1fr); }
  .control-rail { padding: 30px 22px; }
  .main-stage { padding: 30px 25px 42px; }
  .simulation-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .topbar { align-items: flex-start; padding: 13px 18px; }
  .workspace { display: block; }
  .control-rail { padding: 24px 20px; }
  .rail-intro { margin: 14px 0 18px; }
  .keyboard-hint { display: none; }
  .stage-heading { align-items: flex-start; }
  .progress-anchor { display: none; }
}

@media (max-width: 620px) {
  .topbar { display: grid; gap: 12px; }
  .environment-labels { justify-content: flex-start; }
  .notice { min-height: 27px; font-size: 11px; }
  .control-rail { padding: 22px 16px; }
  .main-stage { padding: 25px 14px 36px; }
  .stage-panel { padding: 18px; }
  .model-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}



html[data-theme="dark"] {
  color-scheme: dark;
  --ink-deep: #101c2a;
  --ink-deeper: #0b1520;
  --ink-soft: #15263a;
  --canvas: #0b1520;
  --surface: #122033;
  --surface-soft: #15263a;
  --ink: #e8eef4;
  --muted: #8fa0b0;
  --subtle: #6a7f94;
  --line: #243548;
  --violet: #8ab4d4;
  --violet-bright: #9ec5e0;
  --amber: #8ab4d4;
  --amber-soft: #1c3348;
  --teal: #6a9cc4;
  --teal-soft: #1c3348;
  --rose: #6a9cc4;
  --rose-soft: #1c3348;
  --shadow: 0 12px 38px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .topbar {
  border-bottom-color: var(--line);
  background: rgba(16, 28, 42, 0.94);
}

html[data-theme="dark"] .notice {
  background: #15263a;
  color: #b8c4d0;
}

html[data-theme="dark"] .notice-synthetic {
  border-color: #3d5166;
  color: #9ec5e0;
  background: #1c3348;
}

html[data-theme="dark"] .control-rail .eyebrow,
html[data-theme="dark"] .rail-step {
  color: #9ec5e0;
}

html[data-theme="dark"] .stage-tab.is-active small {
  color: #b8c4d0;
}

html[data-theme="dark"] .progress-track {
  background: #243548;
}

html[data-theme="dark"] .stage-panel {
  border-color: var(--line);
  background: var(--surface);
}

html[data-theme="dark"] .paper-tag,
html[data-theme="dark"] .derivation-step-index,
html[data-theme="dark"] .model-pill.is-checked,
html[data-theme="dark"] .copy-button {
  color: var(--violet-bright);
  background: #1c3348;
  border-color: #3d5166;
}

html[data-theme="dark"] .hypothesis-card,
html[data-theme="dark"] .disclaimer-footer,
html[data-theme="dark"] .consensus-note,
html[data-theme="dark"] .critique-item {
  border-color: #3d5166;
  background: #1c3348;
  color: #e8eef4;
}

html[data-theme="dark"] .stage-nav-button:hover:not(:disabled) {
  border-color: #8ab4d4;
  background: #1c3348;
}

html[data-theme="dark"] .stage-tab.is-active {
  border-color: rgba(158, 197, 224, 0.45);
  background: rgba(106, 156, 196, 0.16);
  box-shadow: inset 3px 0 0 #9ec5e0;
}

html[data-theme="dark"] .stage-tab.is-complete .stage-number,
html[data-theme="dark"] .tab-check {
  color: #9ec5e0;
}

html[data-theme="dark"] .policy-heading-row svg { fill: #9ec5e0; }

html[data-theme="dark"] .critique-icon { background: #243548; }
html[data-theme="dark"] .critique-item.is-minor .critique-icon { background: #1c3348; }

