/* SeePhysics: same shell as Momentum / Daystack. Sticky sidebar, frosted top bar, card workspace */
:root {
  --bg: #f4f6f7; --surface: #ffffff; --sunk: #eef1f3; --sunk-2: #e3e8eb;
  --line: rgba(15,20,24,.1); --line-2: rgba(15,20,24,.18);
  --fg: #0f1418; --fg-2: rgba(15,20,24,.72); --muted: rgba(15,20,24,.5);
  --accent: #1e40af; --accent-2: #3730a3; --on-accent: #fff; --accent-soft: rgba(30,64,175,.1);
  --grad: linear-gradient(135deg, #1e40af, #3730a3);
  --side-glow: rgba(30,64,175,.07);
  --ok: #047857; --ok-soft: #d1fae5; --bad: #b91c1c; --bad-soft: #fee2e2;
  --shadow: 0 1px 0 rgba(0,0,0,.04), 0 18px 40px -30px rgba(0,0,0,.55);
  --c: #1e40af; /* read by the simulations */
  --ease: cubic-bezier(.16,1,.3,1);
  --f-display: "Instrument Serif", Georgia, serif;
  --f-body: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
.i { display: inline-block; vertical-align: -0.2em; flex-shrink: 0; }
.app { display: grid; grid-template-columns: 256px 1fr; height: 100%; }

/* Sidebar */
aside {
  background: radial-gradient(120% 50% at 0% 0%, var(--side-glow), transparent 60%), var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; padding: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; cursor: pointer; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--grad); color: var(--on-accent); display: grid; place-items: center; font: 400 20px var(--f-display); }
.brand b { font-size: 18px; font-weight: 700; letter-spacing: -.025em; }
.navgrp { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 16px 12px 6px; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav button {
  all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px;
  border-radius: 8px; cursor: pointer; color: var(--fg-2); font-weight: 500; font-size: 14px;
  transition: background .3s var(--ease), color .2s, transform .35s var(--ease);
}
nav button:hover { background: var(--sunk); color: var(--fg); transform: translateX(3px); }
nav button.on { background: var(--grad); color: var(--on-accent); box-shadow: 0 8px 22px -12px rgba(30,64,175,.75); transform: none; }
nav button .cnt { margin-left: auto; font: 500 11px var(--f-mono); opacity: .75; }
.me { margin-top: auto; border: 1px solid var(--line); background: var(--sunk); border-radius: 10px; padding: 12px; display: grid; gap: 6px; }
.me-row { display: flex; justify-content: space-between; font-size: 13px; }
.me-k { color: var(--muted); }
.me b { font-variant-numeric: tabular-nums; }

/* Top bar */
.shell { display: flex; flex-direction: column; min-width: 0; height: 100%; }
header.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
}
header.bar .spacer { flex: 1; }
.icon-btn { all: unset; cursor: pointer; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--fg-2); }
.icon-btn:hover { background: var(--sunk); }
.icon-btn svg { width: 20px; height: 20px; }
.menu { display: none; }
main { overflow-y: auto; flex: 1; padding: 24px 16px 48px; }
.wrap { max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }

/* Type */
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.025em; line-height: 1.2; margin: 0; }
h1 em { font: italic 400 30px var(--f-display); letter-spacing: 0; color: var(--accent); }
h1.hero { font-size: 34px; }
h1.hero em { font-size: 42px; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

/* Buttons */
.btn {
  all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px;
  border-radius: 9px; background: var(--grad); color: var(--on-accent); font-weight: 600; font-size: 14px;
  box-shadow: 0 10px 28px -14px rgba(30,64,175,.65); transition: transform .45s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn.ghost { background: var(--surface); color: var(--fg); border: 1px solid var(--line-2); box-shadow: none; }
.btn.ghost:hover { background: var(--sunk); transform: none; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .4; pointer-events: none; }

/* Panels, KPIs */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-width: 0; box-shadow: var(--shadow); }
.panel > h2 { font-size: 15px; font-weight: 600; margin: 0; padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.panel > h2 span { color: var(--muted); font-weight: 400; font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; box-shadow: var(--shadow); }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi b { display: block; font-size: 28px; font-weight: 700; letter-spacing: -.025em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi i { font-style: normal; font-size: 12px; color: var(--muted); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.p-ok { background: var(--ok-soft); color: var(--ok); }
.p-bad { background: var(--bad-soft); color: var(--bad); }
.p-info { background: var(--accent-soft); color: var(--accent); }
.p-mute { background: var(--sunk-2); color: var(--fg-2); }
.bar { height: 6px; border-radius: 99px; background: var(--sunk); overflow: hidden; }
.bar > div { height: 100%; background: var(--grad); border-radius: 99px; transition: width .5s var(--ease); }

/* Chapter list (home) */
.rows { display: flex; flex-direction: column; }
.crow { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: 40px 1fr 180px 48px 20px; gap: 16px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); transition: background .15s; }
.crow:first-child { border-top: 0; }
.crow:hover { background: var(--sunk); }
.crow .t { font-weight: 600; }
.crow .d { color: var(--muted); font-size: 13px; }
.crow .n { font: 500 12px var(--f-mono); color: var(--muted); text-align: right; }
.crow .go { color: var(--muted); }
.ibox { width: 40px; height: 40px; border-radius: 10px; background: var(--sunk); color: var(--accent); display: grid; place-items: center; }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tabs button { all: unset; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; white-space: nowrap; color: var(--fg-2); transition: background .3s var(--ease); }
.tabs button:hover { background: var(--sunk); }
.tabs button.on { background: var(--grad); color: var(--on-accent); }
.tabs .k { font: 500 11px var(--f-mono); opacity: .6; }
.tabs .done { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.tabs button.on .done { background: #fff; }
.pane { padding: 24px; animation: rise .35s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* Story */
.story-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.story-meta .n { font: 500 12px var(--f-mono); color: var(--muted); }
.segs { display: flex; gap: 4px; flex: 1; max-width: 240px; }
.segs i { flex: 1; height: 3px; border-radius: 3px; background: var(--sunk-2); }
.segs i.on { background: var(--accent); }
.story-text { font-size: 22px; line-height: 1.45; letter-spacing: -.015em; max-width: 720px; min-height: 130px; margin: 0; cursor: pointer; animation: rise .35s var(--ease); }
.story-nav { display: flex; gap: 8px; margin-top: 20px; }
.definition { border-left: 2px solid var(--accent); padding: 4px 0 4px 20px; max-width: 760px; }
.definition p { font: italic 400 24px/1.35 var(--f-display); margin: 8px 0 0; }

/* Simulation */
.sim canvas { width: 100%; height: auto; display: block; background: #fafbfc; border: 1px solid var(--line); border-radius: 10px; }
.controls { display: flex; flex-wrap: wrap; gap: 16px 24px; margin-top: 16px; align-items: flex-end; }
.controls label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; min-width: 180px; flex: 1; }
.controls label b { color: var(--fg); font-variant-numeric: tabular-nums; }
.controls input[type=range] { accent-color: var(--accent); width: 100%; }
.controls input[type=checkbox] { accent-color: var(--accent); }
.readout { margin-top: 16px; padding: 10px 14px; border-radius: 8px; background: var(--sunk); font: 500 13px var(--f-mono); color: var(--fg-2); }

.sim-block + .sim-block { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.sim-title { margin-bottom: 12px; }
.controls select { font: inherit; font-size: 14px; color: var(--fg); background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 12px; }
.controls select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Side-by-side sims (energy conservation) */
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.duo-col { min-width: 0; display: flex; flex-direction: column; }
.duo-col canvas { width: 100%; height: auto; display: block; background: #fafbfc; border: 1px solid var(--line); border-radius: 10px; }
.meters { display: grid; gap: 6px; margin-top: 12px; }
.meter { display: grid; grid-template-columns: 64px 1fr 72px; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); font-weight: 500; }
.meter .bar { height: 8px; }
.meter .bar > div { transition: none; }
.meter b { font: 600 12px var(--f-mono); color: var(--fg); text-align: right; font-variant-numeric: tabular-nums; }
.m-ke .bar > div { background: linear-gradient(135deg, #0f766e, #047857); }
.m-tot .bar > div { background: #0f1418; }
.eqs { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.eq { display: grid; grid-template-columns: 128px 1fr; gap: 10px; padding: 5px 0; border-top: 1px solid var(--line); font: 12.5px/1.5 var(--f-mono); color: var(--fg-2); font-variant-numeric: tabular-nums; }
.eq:first-of-type { border-top: 0; }
.eq .f { color: var(--fg); font-weight: 600; white-space: nowrap; }
.eq b { color: var(--fg); }
.eq .pill { font-family: var(--f-body); margin-left: 4px; }
.eq-state { margin-bottom: 6px; }
.playbar { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.playbar label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.playbar label b { color: var(--fg); font-variant-numeric: tabular-nums; }
.playbar .time { flex: 1; min-width: 200px; }
.playbar input[type=range] { accent-color: var(--accent); width: 100%; }
.playbar select { font: inherit; font-size: 14px; color: var(--fg); background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 7px 10px; }
@media (max-width: 900px) { .duo { grid-template-columns: 1fr; } }

/* Real-life cards */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.card { border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.card h3 { margin: 14px 0 4px; font-size: 15px; font-weight: 600; }
.card p { margin: 0; color: var(--fg-2); font-size: 14px; }

/* Myths */
.myths { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.myth { all: unset; box-sizing: border-box; cursor: pointer; border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 10px; transition: border-color .2s; }
.myth:hover { border-color: var(--line-2); }
.myth p { margin: 0; font-size: 15px; }
.myth .claim { font-weight: 500; }
.myth .reveal { color: var(--muted); font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.myth .fact { border-top: 1px solid var(--line); padding-top: 10px; color: var(--fg-2); animation: rise .35s var(--ease); }
.myth.open .claim { text-decoration: line-through; text-decoration-color: rgba(185,28,28,.5); color: var(--muted); }

/* Formula decoder */
.formula { border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 12px; }
.expr { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; margin-top: 8px; font: italic 400 38px/1.2 var(--f-display); }
.sym { all: unset; cursor: pointer; padding: 0 6px; border-radius: 6px; border-bottom: 1.5px dashed var(--line-2); transition: background .2s; }
.sym:hover { background: var(--sunk); }
.sym.on { background: var(--accent-soft); color: var(--accent); border-bottom-color: var(--accent); }
.op { color: var(--muted); font-style: normal; font-size: 30px; }
.meaning { margin-top: 10px; min-height: 22px; color: var(--muted); font-size: 14px; }
.meaning b { color: var(--fg); font-weight: 600; }
.meaning code { font: 500 12px var(--f-mono); background: var(--sunk); padding: 2px 6px; border-radius: 5px; color: var(--fg-2); }

/* Quiz */
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.quiz-head .n { font: 500 12px var(--f-mono); color: var(--muted); }
.quiz h3 { font-size: 20px; font-weight: 600; letter-spacing: -.015em; margin: 12px 0 18px; max-width: 720px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt { all: unset; box-sizing: border-box; cursor: pointer; display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 10px; font-size: 14px; transition: background .15s, border-color .15s; }
.opt:hover { background: var(--sunk); }
.opt .l { width: 24px; height: 24px; border-radius: 6px; background: var(--sunk); display: grid; place-items: center; font: 600 12px var(--f-mono); color: var(--muted); flex: none; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .l { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .l { background: var(--bad); color: #fff; }
.opt:disabled, .opt[disabled] { pointer-events: none; }
.explain { margin-top: 16px; padding: 12px 14px; border-radius: 10px; background: var(--sunk); font-size: 14px; color: var(--fg-2); display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; animation: rise .3s var(--ease); }
.explain b { color: var(--fg); }
.result { text-align: center; padding: 24px 0; }
.result .score { font: italic 400 72px/1 var(--f-display); color: var(--accent); }
.result .score span { font-size: 36px; color: var(--muted); }
.result p { color: var(--muted); margin: 8px 0 18px; }

/* Responsive */
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .cards, .myths, .opts { grid-template-columns: 1fr; }
  .crow { grid-template-columns: 40px 1fr 48px; }
  .crow .bar, .crow .go { display: none; }
}
@media (max-width: 1023px) {
  .app { grid-template-columns: 1fr; }
  aside { position: fixed; inset: 0 auto 0 0; width: 256px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  aside.open { transform: none; box-shadow: 0 0 0 100vmax rgba(5,8,10,.5); }
  .menu { display: grid; }
}
@media (max-width: 600px) {
  .story-text { font-size: 18px; }
  .pane { padding: 18px 16px; }
  h1.hero { font-size: 26px; } h1.hero em { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
