:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #08110d;
  color: #eef8f2;
  --bg: #08110d;
  --panel: #0d1813;
  --panel-2: #122119;
  --line: #24362c;
  --muted: #91a69a;
  --text: #eef8f2;
  --accent: #78e4a1;
  --act: #5fe08f;
  --wait: #e9bd63;
  --block: #ff7d7d;
}

* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; margin: 0; overflow-x: clip; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
code { overflow-wrap: anywhere; }

.topbar,
main,
footer {
  width: min(1180px, 100%);
  margin-inline: auto;
  padding-inline: clamp(14px, 3vw, 28px);
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding-top: max(18px, env(safe-area-inset-top));
  padding-bottom: 18px;
}

.brand, .status-strip, .panel, .subpanel, .stage-card, .hypothesis, .question-box,
.stage-grid > *, .two-grid > *, .three-grid > *, .four-grid > *, .facts-grid > * {
  min-width: 0;
  max-width: 100%;
}

.eyebrow, .section-kicker {
  display: inline-block;
  color: var(--accent);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(1.55rem, 5vw, 2.4rem); }
h2 { margin-bottom: 0; font-size: clamp(1.15rem, 4vw, 1.55rem); }
h3 { margin-bottom: 14px; font-size: 1rem; }
h4 { margin: 18px 0 8px; font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.brand p, .muted { color: var(--muted); }
.brand p { margin-bottom: 0; }

.status-strip { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.badge, .signal-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge.act { color: var(--act); border-color: color-mix(in srgb, var(--act) 45%, var(--line)); background: color-mix(in srgb, var(--act) 10%, transparent); }
.badge.wait { color: var(--wait); border-color: color-mix(in srgb, var(--wait) 45%, var(--line)); background: color-mix(in srgb, var(--wait) 9%, transparent); }
.badge.block { color: var(--block); border-color: color-mix(in srgb, var(--block) 45%, var(--line)); background: color-mix(in srgb, var(--block) 9%, transparent); }
.signal-pill { color: var(--muted); background: #0a1510; }

button {
  border: 1px solid #345444;
  background: #183426;
  color: var(--text);
  border-radius: 10px;
  min-height: 38px;
  padding: 8px 13px;
  font-weight: 750;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .55; cursor: progress; }

main { display: grid; gap: 14px; padding-bottom: 28px; }
.panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #0e1a15 0%, #0b1511 100%);
  border-radius: 18px;
  padding: clamp(14px, 3vw, 22px);
  overflow: hidden;
}
.subpanel, .hypothesis, .question-box {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 14px;
  padding: 14px;
}

.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.cycle-meta { display: grid; justify-items: end; gap: 4px; color: var(--muted); font-size: .8rem; text-align: right; }
.cycle-meta strong { color: var(--text); overflow-wrap: anywhere; }

.auth-panel { display: grid; grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr); gap: 18px; align-items: end; }
.auth-form { min-width: 0; }
.auth-form label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.auth-row { display: flex; gap: 8px; min-width: 0; }
.auth-row input {
  min-width: 0;
  flex: 1 1 240px;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #355047;
  border-radius: 10px;
  background: #08130f;
  color: var(--text);
}
.auth-form .muted { margin: 8px 0 0; min-height: 1.2em; }

.stage-grid, .two-grid, .three-grid, .four-grid { display: grid; gap: 10px; }
.stage-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.four-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stage-card { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: #0a1510; }
.stage-card span { color: var(--muted); font-size: .8rem; }

.facts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; margin: 0; }
.facts-grid div { border-bottom: 1px solid #213128; padding-bottom: 7px; }
dt { color: var(--muted); font-size: .72rem; margin-bottom: 3px; }
dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; word-break: break-word; }

.hypothesis span, .question-box span, .metric-grid span { display: block; color: var(--muted); font-size: .76rem; margin-bottom: 6px; }
.hypothesis strong, .question-box strong { display: block; line-height: 1.45; overflow-wrap: anywhere; }
.hypothesis.dominant { border-left: 3px solid var(--accent); }
.hypothesis.counter { border-left: 3px solid var(--wait); }
.metric-grid { margin: 10px 0; }
.metric-grid > div { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #0a1510; }
.metric-grid strong { display: block; overflow-wrap: anywhere; font-size: .86rem; }
.question-box { margin-bottom: 10px; }

.compact-list { margin: 0; padding-left: 18px; display: grid; gap: 7px; }
.compact-list li { overflow-wrap: anywhere; word-break: break-word; line-height: 1.4; color: #dce9e1; }

.evidence-panel details { min-width: 0; }
.evidence-panel summary { cursor: pointer; font-weight: 750; }
pre {
  width: 100%;
  max-width: 100%;
  margin: 12px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #06100c;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow-x: auto;
  font-size: .73rem;
  line-height: 1.45;
}

footer { display: grid; gap: 5px; padding-top: 6px; padding-bottom: max(24px, env(safe-area-inset-bottom)); color: var(--muted); font-size: .76rem; }
footer strong { color: var(--accent); }

@media (max-width: 900px) {
  .stage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .three-grid { grid-template-columns: 1fr; }
  .four-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .status-strip { justify-content: flex-start; width: 100%; }
  .auth-panel { grid-template-columns: 1fr; }
  .auth-row { flex-wrap: wrap; }
  .auth-row input { flex-basis: 100%; }
  .auth-row button { flex: 1 1 140px; }
  .two-grid, .four-grid { grid-template-columns: 1fr; }
  .section-heading { flex-direction: column; }
  .cycle-meta { justify-items: start; text-align: left; }
  .facts-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 430px) {
  .topbar, main, footer { padding-inline: 12px; }
  .panel { border-radius: 14px; padding: 13px; }
  .stage-grid, .facts-grid { grid-template-columns: 1fr; }
  .stage-card { min-height: 48px; }
  .status-strip button { flex: 1 1 100%; }
}
