:root {
  color-scheme: dark;
  font-family: Figtree, system-ui, sans-serif;
  background: #0b1020;
  color: #f1f3ff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --muted: #a2abc9;
  --soft: #7783a7;
  --line: #29314b;
  --mint: #35f0d2;
  --violet: #9f8cff;
  --blue: #51caff;
  --red: #ff7894;
  --panel: #11182b;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 136px; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.wrap { width: min(1160px, calc(100% - 40px)); margin-inline: auto; }

.topbar { position: sticky; top: 0; z-index: 30; border-bottom: 1px solid var(--line); background: rgb(11 16 32 / 92%); backdrop-filter: blur(12px); }
.topbar-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 9px; min-width: 0; text-decoration: none; font-weight: 700; letter-spacing: -.03em; }
.brand-logo { display: block; width: 150px; height: auto; flex: 0 0 auto; }
.brand-divider { margin-inline: 5px; color: #53607f; }
.brand-module { color: var(--muted); font-weight: 500; }
.header-actions { display: flex; align-items: center; gap: 18px; }
.collection-link, .footer a { color: var(--muted); font-size: 13px; text-decoration: none; }
.collection-link:hover, .footer a:hover { color: var(--mint); }
.lang-toggle, .icon-button, .reset-button, .preset-button, .phase-tab { border: 1px solid var(--line); background: transparent; cursor: pointer; }
.lang-toggle { border-radius: 999px; padding: 8px 13px; color: var(--muted); font: 600 12px "JetBrains Mono", monospace; }
.lang-toggle:hover, .lang-toggle:focus-visible { border-color: var(--mint); color: var(--mint); }
.subnav { border-top: 1px solid rgb(41 49 75 / 65%); }
.subnav-inner { min-height: 48px; display: flex; align-items: center; gap: 16px; }
.module-nav { display: flex; min-width: 0; align-items: center; gap: 4px; margin-right: auto; }
.module-nav a { flex: 0 0 auto; border-radius: 999px; padding: 7px 11px; color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: none; }
.module-nav a:hover, .module-nav a:focus-visible { background: #35f0d20d; color: var(--mint); }
.subnav .lang-toggle { flex: 0 0 auto; }

.hero { padding-block: clamp(64px, 9vw, 112px) 44px; }
.eyebrow, .kicker, .live-label, .preset-label, .equation-label, .valve-label { display: flex; align-items: center; gap: 9px; color: var(--mint); font: 600 10px "JetBrains Mono", monospace; letter-spacing: .12em; text-transform: uppercase; }
.pulse, .live-dot { width: 7px; aspect-ratio: 1; border-radius: 50%; background: var(--mint); box-shadow: 0 0 15px var(--mint); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 22px 0; font: 500 clamp(40px, 7.4vw, 78px)/1.08 Unbounded, sans-serif; letter-spacing: -.065em; }
.title-accent { color: var(--mint); }
.hero-copy { max-width: 670px; margin-bottom: 0; color: var(--muted); font-size: clamp(16px, 2vw, 19px); line-height: 1.7; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 20px; }
.section-heading .kicker { margin-bottom: 10px; color: var(--soft); }
.section-heading h2 { margin-bottom: 0; font: 500 clamp(22px, 3.3vw, 31px)/1.25 Unbounded, sans-serif; letter-spacing: -.045em; }
.phase-counter { color: var(--muted); font: 12px "JetBrains Mono", monospace; }
.cycle-layout, .lab-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .8fr); gap: 16px; }
.panel { border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, #141c32, var(--panel) 72%); }
.heart-panel { padding: 18px 22px 16px; overflow: hidden; }
.heart-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.live-label { color: var(--soft); font-size: 9px; }
.live-dot { width: 6px; background: var(--mint); box-shadow: 0 0 12px var(--mint); }
#heartbeat-pulse { animation: heartbeat var(--beat-period, .8s) ease-in-out infinite; }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.55); } 24% { transform: scale(1); } 36% { transform: scale(1.4); } 52% { transform: scale(1); } }
.icon-button { display: inline-flex; align-items: center; gap: 7px; border-radius: 9px; padding: 8px 11px; color: var(--mint); font-size: 12px; }
.icon-button:hover, .icon-button:focus-visible { border-color: var(--mint); background: #35f0d20d; }
.heart-visual { width: 100%; margin: 14px auto 0; }
#heart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.vessel { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; opacity: .46; transition: opacity .25s, stroke-width .25s; }
.blue-path { stroke: url(#venous); }
.red-path { stroke: url(#arterial); }
.chamber rect { fill: #15213a; stroke-width: 2; transition: fill .3s, stroke-width .3s, filter .3s; }
.chamber-ra rect, .chamber-rv rect { stroke: #51caff80; }
.chamber-la rect, .chamber-lv rect { stroke: #ff789480; }
.chamber-short { fill: #f1f3ff; font: 700 16px "JetBrains Mono", monospace; text-anchor: middle; }
.chamber-name { fill: #a2abc9; font: 600 8px "JetBrains Mono", monospace; text-anchor: middle; letter-spacing: .03em; }
.organ-label, .small-label { fill: #8e9bbc; font: 600 9px "JetBrains Mono", monospace; letter-spacing: .04em; }
.center-note { fill: #8793bd; font: 600 9px "JetBrains Mono", monospace; letter-spacing: .08em; }
.flow-legend { font: 600 9px "JetBrains Mono", monospace; }
.heart-panel[data-phase="fill"] .chamber-ra rect,
.heart-panel[data-phase="fill"] .chamber-la rect,
.heart-panel[data-phase="atrial"] .chamber-ra rect,
.heart-panel[data-phase="atrial"] .chamber-la rect,
.heart-panel[data-phase="ventricular"] .chamber-rv rect,
.heart-panel[data-phase="ventricular"] .chamber-lv rect { fill: #263454; stroke-width: 3; filter: drop-shadow(0 0 7px #51caff55); }
.heart-panel[data-phase="ventricular"] .chamber-lv rect { filter: drop-shadow(0 0 8px #ff789455); }
.heart-panel[data-phase="fill"] .vessel,
.heart-panel[data-phase="atrial"] .vessel,
.heart-panel[data-phase="relax"] .vessel { opacity: .84; }
.heart-panel[data-phase="ventricular"] .path-lung-out,
.heart-panel[data-phase="ventricular"] .path-body-out { opacity: .95; stroke-width: 5; }
.heart-panel[data-playing="true"][data-phase="ventricular"] .path-lung-out,
.heart-panel[data-playing="true"][data-phase="ventricular"] .path-body-out { stroke-dasharray: 9 7; animation: blood-flow .65s linear infinite; }
.heart-panel[data-playing="true"][data-phase="fill"] .path-body-in,
.heart-panel[data-playing="true"][data-phase="fill"] .path-lung-in,
.heart-panel[data-playing="true"][data-phase="relax"] .path-body-in,
.heart-panel[data-playing="true"][data-phase="relax"] .path-lung-in { stroke-dasharray: 7 7; animation: blood-flow 1.2s linear infinite; }
@keyframes blood-flow { to { stroke-dashoffset: -32; } }
.flow-key { display: flex; justify-content: center; flex-wrap: wrap; gap: 17px; padding-top: 4px; color: var(--muted); font-size: 11px; }
.flow-key > span { display: inline-flex; align-items: center; gap: 7px; }
.key-dot { width: 8px; height: 8px; border-radius: 50%; }
.venous-dot { background: var(--blue); box-shadow: 0 0 8px #51caff88; }
.arterial-dot { background: var(--red); box-shadow: 0 0 8px #ff789488; }
.phase-panel { padding: 24px; display: flex; flex-direction: column; min-height: 100%; }
.phase-panel > .kicker { color: var(--soft); margin-bottom: 12px; }
.phase-number { color: var(--mint); font: 500 42px/1 Unbounded, sans-serif; letter-spacing: -.07em; }
.phase-panel h3 { margin: 10px 0 8px; font-size: 22px; letter-spacing: -.03em; }
.phase-description { min-height: 72px; margin-bottom: 18px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.valve-state { margin-top: auto; display: grid; gap: 7px; border-top: 1px solid var(--line); padding: 14px 0; }
.valve-label { color: var(--soft); font-size: 9px; }
#valve-text { color: #d9deef; font-size: 12px; line-height: 1.45; }
.phase-tabs { display: grid; gap: 6px; }
.phase-tab { width: 100%; min-height: 38px; display: grid; grid-template-columns: 28px 1fr; align-items: center; text-align: left; gap: 9px; padding: 7px 9px; border-radius: 8px; color: var(--muted); font-size: 12px; }
.phase-tab > span:first-child { color: var(--soft); font: 10px "JetBrains Mono", monospace; }
.phase-tab:hover { border-color: #596586; color: #fff; }
.phase-tab.active { border-color: #35f0d24f; background: #35f0d20e; color: var(--mint); }
.phase-tab.active > span:first-child { color: var(--mint); }
.animation-note { margin: 12px 0 0; color: var(--soft); font-size: 10px; line-height: 1.5; }
.lab-section, .learn-section { padding-top: 92px; }
.reset-button { border-radius: 8px; padding: 8px 11px; color: var(--muted); font-size: 11px; }
.reset-button:hover { border-color: var(--mint); color: var(--mint); }
.section-intro { margin: -6px 0 18px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.controls-panel { padding: 22px; display: flex; flex-direction: column; gap: 26px; }
.control-block + .control-block { border-top: 1px solid var(--line); padding-top: 22px; }
.control-heading { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.control-heading label { padding-top: 4px; color: #e7eaf8; font-size: 14px; font-weight: 600; }
.control-reading { display: flex; flex-direction: column; align-items: end; color: var(--mint); font: 500 24px/1 Unbounded, sans-serif; }
.control-reading small { margin-top: 6px; color: var(--soft); font: 10px "JetBrains Mono", monospace; }
input[type="range"] { --range-progress: 35%; width: 100%; height: 4px; display: block; margin: 19px 0 9px; border-radius: 999px; appearance: none; background: linear-gradient(to right, var(--mint) 0 var(--range-progress), #333c58 var(--range-progress) 100%); cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { width: 16px; height: 16px; border: 3px solid #0b1020; border-radius: 50%; appearance: none; background: var(--mint); box-shadow: 0 0 0 1px var(--mint), 0 0 12px #35f0d244; }
input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border: 3px solid #0b1020; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 1px var(--mint), 0 0 12px #35f0d244; }
input[type="range"]:focus-visible { outline: 2px solid var(--mint); outline-offset: 7px; }
.range-ends { display: flex; justify-content: space-between; color: var(--soft); font: 10px "JetBrains Mono", monospace; }
.control-hint { margin: 11px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.presets { border-top: 1px solid var(--line); padding-top: 17px; }
.preset-label { color: var(--soft); font-size: 9px; }
.preset-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.preset-button { border-radius: 999px; padding: 8px 11px; color: var(--muted); font-size: 11px; }
.preset-button:hover { border-color: #687493; color: #fff; }
.preset-button.active { border-color: #9f8cff80; background: #9f8cff12; color: #d5ccff; }
.results-panel { padding: 22px; }
.results-panel > .kicker { margin-bottom: 17px; color: var(--soft); }
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.result-card { min-height: 124px; display: flex; flex-direction: column; justify-content: space-between; gap: 11px; padding: 13px 11px; border: 1px solid var(--line); border-radius: 11px; background: #0e1527; }
.result-label { min-height: 27px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.result-card strong { display: flex; align-items: baseline; gap: 5px; white-space: nowrap; color: #f1f3ff; font: 500 clamp(17px, 2.2vw, 24px)/1 Unbounded, sans-serif; letter-spacing: -.06em; }
.result-card strong small { color: var(--soft); font: 10px "JetBrains Mono", monospace; letter-spacing: 0; }
.result-caption { color: var(--soft); font: 9px "JetBrains Mono", monospace; line-height: 1.4; }
.accent-blue { border-color: #51caff45; }
.accent-blue strong { color: var(--blue); }
.accent-pink { border-color: #ff789445; }
.accent-pink strong { color: #ff9bb0; }
.equation-box { display: grid; gap: 11px; margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #0d1425; }
.equation-label { margin-bottom: 2px; color: var(--soft); font-size: 9px; }
.equation-box > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.equation-box code { color: var(--mint); font: 600 13px "JetBrains Mono", monospace; }
.equation-box > div > span { color: var(--muted); font-size: 11px; }
.interpretation { margin: 14px 0 0; color: #d9deef; font-size: 12px; line-height: 1.6; }
.model-caveat { display: flex; align-items: start; gap: 12px; margin-top: 14px; padding: 16px; border: 1px solid #9f8cff35; border-radius: 12px; background: #9f8cff0b; }
.caveat-icon { width: 20px; height: 20px; flex: 0 0 20px; display: grid; place-items: center; border: 1px solid #9f8cff80; border-radius: 50%; color: #cabfff; font: 600 11px "JetBrains Mono", monospace; }
.model-caveat p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.model-caveat strong { color: #e4deff; }
.learn-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.learn-card { position: relative; min-height: 176px; padding: 21px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.learn-index { display: inline-block; margin-bottom: 22px; color: var(--violet); font: 600 11px "JetBrains Mono", monospace; }
.learn-card h3 { margin-bottom: 9px; font-size: 15px; }
.learn-card p { margin-bottom: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.sources-section { padding-top: 64px; }
.sources-panel { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.sources-panel summary { padding: 16px 18px; cursor: pointer; color: #d9deef; font-size: 13px; font-weight: 600; }
.sources-panel summary::marker { color: var(--mint); }
.sources-content { padding: 0 18px 18px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.sources-content a { color: var(--mint); text-underline-offset: 3px; }
.sources-content li + li { margin-top: 5px; }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px 24px; margin-top: 52px; padding: 20px 0 30px; border-top: 1px solid var(--line); color: var(--soft); font-size: 11px; }

@media (max-width: 860px) {
  .cycle-layout, .lab-layout { grid-template-columns: 1fr; }
  .phase-description { min-height: 0; }
  .phase-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .learn-grid { grid-template-columns: 1fr; }
  .learn-card { min-height: 0; }
  .learn-index { margin-bottom: 12px; }
}
@media (max-width: 520px) {
  .wrap { width: min(100% - 28px, 1160px); }
  html { scroll-padding-top: 144px; }
  .topbar-inner { min-height: 62px; }
  .brand { gap: 7px; font-size: 12px; }
  .brand-logo { width: 124px; }
  .header-actions { gap: 10px; }
  .collection-link { font-size: 11px; }
  .subnav-inner { min-height: 0; flex-direction: column; align-items: stretch; gap: 5px; padding-block: 6px; }
  .module-nav { width: 100%; overflow-x: auto; scrollbar-width: thin; }
  .module-nav a { padding: 6px 10px; font-size: 12px; }
  .subnav .lang-toggle { align-self: flex-end; padding: 6px 10px; }
  .hero { padding-top: 58px; }
  .section-heading { align-items: start; }
  .heart-panel { padding: 15px 10px 13px; }
  .heart-visual { margin-top: 18px; }
  .phase-panel, .controls-panel, .results-panel { padding: 18px; }
  .result-grid { gap: 6px; }
  .result-card { padding: 10px 8px; min-height: 118px; }
  .result-card strong { font-size: 17px; }
  .result-card strong small { font-size: 9px; }
  .result-label { font-size: 9px; }
  .chamber-name, .organ-label, .small-label, .center-note, .flow-legend { display: none; }
  .chamber-short { font-size: 21px; }
  .phase-tabs { grid-template-columns: 1fr; }
  .lab-section, .learn-section { padding-top: 70px; }
  .footer { flex-direction: column; }
  .center-note { font-size: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
