:root {
  color-scheme: dark;
  --bg: #0a1017;
  --panel: #111a24;
  --panel-2: #0e1720;
  --panel-3: #172330;
  --line: rgba(167, 190, 207, .14);
  --line-strong: rgba(167, 190, 207, .24);
  --text: #edf2f5;
  --muted: #93a4b1;
  --quiet: #647582;
  --accent: #e9ad58;
  --accent-soft: rgba(233, 173, 88, .14);
  --accent-line: rgba(233, 173, 88, .42);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow-x: hidden; }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-rows: 72px minmax(0, 1fr) auto; background: radial-gradient(ellipse at 38% 0%, rgba(36, 65, 79, .16), transparent 42%), var(--bg); }
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
body.embed-mode .app-shell { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(10, 16, 23, .94); min-width: 0; }
.brand-mark { width: 30px; height: 30px; border: 1px solid var(--accent-line); border-radius: 50%; display: flex; align-items: center; justify-content: center; gap: 2px; flex: 0 0 auto; transform: rotate(-25deg); }
.brand-mark span { width: 3px; height: 13px; border-radius: 4px; background: var(--accent); opacity: .9; }
.brand-mark span:nth-child(2) { height: 19px; opacity: .65; }
.brand-mark span:nth-child(3) { height: 9px; opacity: .45; }
.brand-copy { min-width: 0; }
.eyebrow, .section-kicker, .footer-line, .readout-label, .canvas-corner-note, .caption-kicker, .progress-meta, .check-topline { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .11em; }
.eyebrow { color: var(--muted); font-size: 9px; margin-bottom: 4px; }
.eyebrow span { color: var(--accent); padding: 0 4px; }
h1 { font-size: clamp(15px, 1.55vw, 20px); line-height: 1.1; font-weight: 560; letter-spacing: -.035em; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
h1 em { color: var(--accent); font-style: normal; padding: 0 2px; }
.top-meta { margin-left: auto; display: flex; align-items: center; gap: 8px; font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .09em; color: var(--muted); white-space: nowrap; }
.live-dot, .caption-pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(233,173,88,.1); }
.seed-label { margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--line-strong); color: var(--quiet); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 374px; gap: 16px; padding: 16px 20px 12px; min-height: 0; overflow: hidden; }
.stage-panel, .lab-panel { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(150deg, rgba(20,31,43,.96), rgba(13,21,30,.98)); min-width: 0; min-height: 0; }
.stage-panel { display: flex; flex-direction: column; padding: 16px; overflow: hidden; }
.stage-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stage-heading { flex: 0 0 auto; padding: 0 2px 12px; }
.section-kicker { color: var(--accent); font-size: 9px; line-height: 1.2; }
h2 { font-size: 17px; line-height: 1.2; font-weight: 570; letter-spacing: -.025em; margin: 5px 0 0; }
.stage-tools { display: flex; align-items: center; gap: 8px; }
.view-switch, .quality-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; padding: 3px; background: rgba(4,10,16,.36); }
.view-button, .quality-button { border: 0; border-radius: 6px; background: transparent; color: var(--muted); padding: 6px 9px; font-size: 10px; cursor: pointer; transition: color .2s ease, background .2s ease; }
.view-button.active, .quality-button.active { color: var(--text); background: var(--panel-3); box-shadow: inset 0 0 0 1px rgba(255,255,255,.04); }
.quality-button { padding: 6px 7px; }
.stage-visual { position: relative; flex: 1 1 auto; min-height: 280px; overflow: hidden; border: 1px solid rgba(142,170,188,.12); border-radius: 12px; background: radial-gradient(ellipse at 50% 48%, rgba(29,55,68,.22), transparent 57%), #0b131c; animation: stageReveal .9s cubic-bezier(.2,.75,.25,1) both; }
#simulationCanvas { display: block; width: 100%; height: 100%; outline: none; }
.canvas-label { position: absolute; z-index: 2; color: rgba(216,229,235,.62); font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; pointer-events: none; }
.canvas-label span { color: var(--accent); }
.canvas-label-top { top: 14px; left: 16px; }
.canvas-label-bottom { bottom: 14px; left: 16px; }
.canvas-corner-note { position: absolute; top: 14px; right: 16px; color: rgba(216,229,235,.58); font-size: 8px; pointer-events: none; }
.canvas-corner-note span { color: var(--accent); }
.canvas-legend { position: absolute; right: 16px; bottom: 14px; display: flex; align-items: center; gap: 6px; color: rgba(216,229,235,.62); font-size: 9px; pointer-events: none; }
.legend-swatch { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-left: 7px; }
.gel-swatch { background: #28515b; }
.precip-swatch { background: var(--accent); }
.stage-bottom { flex: 0 0 auto; padding-top: 12px; }
.progress-meta { display: flex; justify-content: space-between; align-items: center; font-size: 8px; color: var(--muted); margin-bottom: 6px; }
.progress-meta b { color: var(--quiet); font-weight: 500; }
.progress-track { height: 3px; background: rgba(163,184,198,.12); border-radius: 8px; overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); box-shadow: 0 0 10px rgba(233,173,88,.5); transition: none; }
.mechanism-strip { display: grid; grid-template-columns: 1fr 16px 1fr 16px 1fr; align-items: center; gap: 7px; margin-top: 12px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(5,11,17,.25); }
.mechanism-step { display: flex; align-items: center; gap: 8px; min-width: 0; }
.step-index { width: 22px; height: 22px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--accent-line); border-radius: 7px; color: var(--accent); font: 10px ui-monospace, monospace; }
.mechanism-step b { display: block; font-size: 10px; font-weight: 600; margin-bottom: 2px; }
.mechanism-step small { display: block; color: var(--muted); font-size: 9px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mechanism-arrow { color: var(--quiet); text-align: center; font-size: 13px; }
.lab-panel { overflow-y: auto; overscroll-behavior: contain; padding: 15px; scrollbar-width: thin; scrollbar-color: rgba(150,170,185,.25) transparent; }
.lab-panel::-webkit-scrollbar, .workspace::-webkit-scrollbar { width: 6px; }
.lab-panel::-webkit-scrollbar-thumb, .workspace::-webkit-scrollbar-thumb { background: rgba(150,170,185,.25); border-radius: 8px; }
.section-heading { margin-bottom: 11px; }
.section-heading h2 { font-size: 15px; margin-top: 4px; }
.status-pill, .illustrative-tag, .textbook-tag { border: 1px solid var(--line-strong); border-radius: 20px; padding: 5px 8px; color: var(--muted); font: 8px ui-monospace, monospace; letter-spacing: .08em; white-space: nowrap; }
.status-pill { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.readout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.readout-card { border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px 8px; background: rgba(6,13,20,.28); min-width: 0; }
.readout-label { display: flex; justify-content: space-between; gap: 5px; font-size: 7px; color: var(--muted); letter-spacing: .08em; white-space: nowrap; }
.readout-label span { color: var(--quiet); font-size: 6px; }
.readout-value { font-size: 23px; line-height: 1.2; letter-spacing: -.05em; font-weight: 560; margin-top: 6px; font-variant-numeric: tabular-nums; }
.readout-value small { font-size: 11px; color: var(--muted); font-weight: 450; letter-spacing: 0; }
.caption-box { margin-top: 8px; padding: 10px 11px; border-left: 2px solid var(--accent); background: linear-gradient(90deg, rgba(233,173,88,.08), rgba(233,173,88,.015)); border-radius: 0 8px 8px 0; }
.caption-kicker { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 8px; }
.caption-pulse { width: 5px; height: 5px; box-shadow: none; }
.caption-box p { color: #c4d0d7; font-size: 10px; line-height: 1.45; margin: 6px 0 0; }
.controls-section { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 13px; }
.section-heading.compact { margin-bottom: 9px; }
.illustrative-tag { color: var(--quiet); border-color: var(--line); font-size: 7px; }
.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 12px; }
.preset-button { border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 9px; background: rgba(5,11,17,.28); color: var(--muted); font-size: 10px; text-align: left; cursor: pointer; transition: border-color .2s ease, background .2s ease, color .2s ease; }
.preset-button.active { color: var(--text); border-color: var(--accent-line); background: var(--accent-soft); }
.preset-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--quiet); margin-right: 6px; vertical-align: 1px; }
.preset-button.active .preset-dot { background: var(--accent); box-shadow: 0 0 8px rgba(233,173,88,.5); }
.control-list { display: grid; gap: 10px; }
.control-row { min-width: 0; }
.control-label-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.control-label-line label { color: #dce5e9; font-size: 10px; font-weight: 530; }
.control-value { color: var(--accent); font: 10px ui-monospace, monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }
input[type="range"] { width: 100%; display: block; height: 14px; margin: 0; background: transparent; accent-color: var(--accent); cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 6px; background: linear-gradient(90deg, rgba(233,173,88,.72), rgba(233,173,88,.22)); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 6px; background: linear-gradient(90deg, rgba(233,173,88,.72), rgba(233,173,88,.22)); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #1a232b; box-shadow: 0 0 0 1px var(--accent-line); margin-top: -4.5px; }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid #1a232b; box-shadow: 0 0 0 1px var(--accent-line); }
.range-ends { display: flex; justify-content: space-between; color: var(--quiet); font: 8px ui-monospace, monospace; margin-top: 1px; }
.range-ends .control-unit { color: #667681; font-size: 7px; letter-spacing: .08em; }
.reset-note { color: var(--quiet); font-size: 8px; line-height: 1.35; margin: 9px 0 -5px; }
.action-row { display: grid; grid-template-columns: minmax(0,1fr) auto 34px; gap: 7px; margin-top: 14px; }
.primary-button, .secondary-button, .icon-button { min-height: 36px; border-radius: 8px; cursor: pointer; transition: transform .18s ease, border-color .18s ease, background .18s ease, opacity .18s ease; }
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: #17140f; font-size: 11px; font-weight: 680; box-shadow: 0 5px 16px rgba(233,173,88,.12); }
.primary-button:hover { background: #f3bf73; transform: translateY(-1px); }
.button-symbol { margin-right: 7px; font-size: 10px; }
.secondary-button, .icon-button { border: 1px solid var(--line-strong); background: rgba(6,13,20,.3); color: var(--text); font-size: 10px; padding: 0 10px; }
.secondary-button:hover, .icon-button:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.icon-button { font-size: 20px; padding: 0; color: var(--muted); }
.utility-row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.text-button { border: 0; padding: 3px 0; background: transparent; color: var(--muted); font-size: 9px; cursor: pointer; }
.text-button:hover { color: var(--accent); }
.text-button span { color: var(--accent); margin-right: 4px; }
.keyboard-hint { color: var(--quiet); font: 7px ui-monospace, monospace; letter-spacing: .04em; }
.check-section { border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; margin-top: 14px; background: rgba(6,13,20,.26); }
.check-topline { display: flex; align-items: center; justify-content: space-between; }
.textbook-tag { font-size: 7px; color: var(--accent); border-color: var(--accent-line); }
.check-title { margin-top: 7px; font-size: 11px; font-weight: 600; }
.check-equation { color: var(--accent); font: 14px Georgia, serif; margin: 5px 0 8px; }
.check-result-row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.check-result-row b { color: var(--text); font: 10px ui-monospace, monospace; text-align: right; }
.check-note { color: var(--quiet); font-size: 8px; line-height: 1.4; margin: 6px 0 0; }
.bottom-dock { border-top: 1px solid var(--line); background: rgba(8,14,20,.96); }
.science-panel summary { list-style: none; display: flex; align-items: center; gap: 9px; min-height: 38px; padding: 0 22px; cursor: pointer; color: #dce5e9; font: 9px ui-monospace, monospace; letter-spacing: .1em; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-icon { color: var(--accent); font: 17px Georgia, serif; }
.science-summary { color: var(--quiet); letter-spacing: .02em; font: 9px system-ui, sans-serif; }
.summary-chevron { margin-left: auto; color: var(--accent); font-size: 15px; transition: transform .2s ease; }
.science-panel[open] .summary-chevron { transform: rotate(180deg); }
.science-content { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 24px; padding: 15px 22px 20px; border-top: 1px solid var(--line); max-height: 38vh; overflow-y: auto; }
.science-column h3 { color: var(--accent); font-size: 10px; font-weight: 600; margin: 0 0 7px; }
.science-column p { color: var(--muted); font-size: 9px; line-height: 1.5; margin: 6px 0; }
.science-column code { color: #e7d2ad; font-family: ui-monospace, monospace; font-size: 9px; }
.equation-block { display: grid; gap: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: rgba(4,10,15,.4); }
.equation-block code { font-size: 10px; }
.source-note { color: #8496a2 !important; }
.disclaimer { color: #c8d2d8 !important; border-left: 2px solid var(--accent); padding-left: 8px; }
.footer-line { display: flex; justify-content: space-between; padding: 0 22px 7px; color: #586874; font-size: 7px; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@keyframes stageReveal { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: scale(1); } }
@media (max-width: 1080px) and (min-width: 761px) {
  .workspace { grid-template-columns: minmax(0,1fr) 340px; padding: 12px; gap: 12px; }
  .topbar { padding: 0 16px; }
  .stage-panel { padding: 12px; }
  .lab-panel { padding: 12px; }
  .mechanism-strip { gap: 4px; padding: 8px; }
  .mechanism-step small { font-size: 8px; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-rows: 58px minmax(0,1fr) auto; }
  .topbar { padding: 0 12px; gap: 9px; }
  .brand-mark { width: 25px; height: 25px; }
  .eyebrow { font-size: 7px; }
  h1 { font-size: 14px; max-width: 54vw; }
  .top-meta { font-size: 7px; gap: 5px; }
  .top-meta .seed-label { display: none; }
  .workspace { display: flex; flex-direction: column; gap: 10px; padding: 10px; overflow-y: auto; overflow-x: hidden; min-height: 0; }
  .stage-panel { flex: 0 0 auto; padding: 10px; }
  .stage-heading { padding: 0 1px 9px; align-items: flex-end; }
  .stage-heading h2 { font-size: 14px; }
  .stage-tools { gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
  .view-button, .quality-button { padding: 6px 7px; font-size: 9px; }
  .stage-visual { height: min(82vw, 370px); min-height: 280px; flex: 0 0 auto; }
  .stage-bottom { padding-top: 9px; }
  .mechanism-strip { grid-template-columns: 1fr; gap: 7px; padding: 9px; }
  .mechanism-arrow { display: none; }
  .mechanism-step small { white-space: normal; }
  .lab-panel { flex: 0 0 auto; overflow: visible; padding: 12px; }
  .science-panel summary { padding: 0 12px; min-height: 42px; gap: 7px; font-size: 8px; }
  .science-summary { display: none; }
  .science-content { grid-template-columns: 1fr; gap: 12px; padding: 12px; max-height: 45vh; }
  .footer-line { padding: 0 12px 7px; font-size: 6px; }
  .caption-box p { font-size: 10px; }
  .readout-value { font-size: 21px; }
  .control-list { gap: 11px; }
  .action-row { grid-template-columns: minmax(0,1fr) auto 34px; }
}
@media (max-width: 390px) {
  .top-meta { display: none; }
  h1 { max-width: calc(100vw - 60px); }
  .stage-heading { align-items: flex-start; flex-direction: column; }
  .stage-tools { width: 100%; justify-content: space-between; }
  .canvas-label, .canvas-corner-note { font-size: 7px; }
  .canvas-legend { font-size: 8px; }
  .footer-line span:last-child { text-align: right; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
