:root {
  color-scheme: dark;
  --bg: #07131c;
  --panel: #0b1b25;
  --panel-2: #0e222d;
  --line: rgba(153, 198, 214, 0.13);
  --line-strong: rgba(153, 198, 214, 0.22);
  --text: #e5f1f4;
  --muted: #8ca6b0;
  --faint: #5e7883;
  --cyan: #76d9f2;
  --ice: #a9ecfb;
  --amber: #f2b66d;
  --green: #85d9b0;
  --radius: 13px;
  --space: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-width: 320px; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.app-shell { min-height: 100vh; max-width: 1920px; margin: 0 auto; padding: 0 22px 18px; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid rgba(118,217,242,.34); border-radius: 10px; color: var(--cyan); font-size: 23px; background: linear-gradient(145deg, rgba(118,217,242,.12), rgba(118,217,242,.02)); }
.eyebrow { color: #7fa2af; font-size: 9px; line-height: 1.35; letter-spacing: .16em; font-weight: 750; }
.brand-title { margin-top: 2px; font-size: 16px; letter-spacing: -.025em; font-weight: 720; }
.topbar-meta { display: flex; align-items: center; gap: 10px; color: #78929d; font-size: 9px; letter-spacing: .13em; font-weight: 700; }
.live-dot, .status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(133,217,176,.7); }
.meta-divider { width: 1px; height: 13px; background: var(--line-strong); }
.workspace { display: grid; grid-template-columns: minmax(238px, 270px) minmax(440px, 1fr) minmax(242px, 270px); gap: 14px; padding-top: 14px; align-items: stretch; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(180deg, rgba(13,31,42,.98), rgba(9,24,33,.98)); box-shadow: 0 12px 40px rgba(0,0,0,.12); }
.controls-panel, .data-panel { padding: 17px 15px 14px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.panel-heading h1, .panel-heading h2 { margin: 5px 0 0; font-size: 17px; letter-spacing: -.035em; font-weight: 680; }
.panel-icon { font-size: 24px; line-height: 1; color: #5f9eae; }
.section-label { color: #7795a0; font-size: 9px; font-weight: 760; letter-spacing: .15em; margin-bottom: 10px; }
.preset-block { padding: 15px 0 14px; border-bottom: 1px solid var(--line); }
.preset-grid { display: grid; gap: 6px; }
.preset-button { display: flex; align-items: center; gap: 9px; text-align: left; width: 100%; border: 1px solid transparent; background: rgba(255,255,255,.025); border-radius: 8px; padding: 8px 9px; cursor: pointer; transition: background .18s ease, border-color .18s ease; }
.preset-button:hover { background: rgba(118,217,242,.07); border-color: rgba(118,217,242,.18); }
.preset-button.active { border-color: rgba(118,217,242,.34); background: rgba(68,153,180,.12); }
.preset-button strong { display: block; font-size: 10px; font-weight: 680; line-height: 1.4; }
.preset-button small { display: block; margin-top: 2px; font-size: 9px; color: var(--muted); }
.preset-swatch { flex: 0 0 22px; width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(255,255,255,.1); }
.preset-swatch.silt { background: linear-gradient(145deg, #8a6548, #5b4334 55%, #9be4f4 56%, #347f98 66%, #624735 67%); }
.preset-swatch.sand { background: linear-gradient(145deg, #b99465, #7d6041 60%, #8b8c72); }
.preset-swatch.saline { background: linear-gradient(145deg, #5d8992, #395a66 60%, #b0eaf6 61%, #446775); }
.control-list { padding-top: 15px; }
.control-row { padding: 0 0 13px; }
.control-label { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; margin-bottom: 7px; }
.control-label label { color: #c9d9de; font-size: 10px; font-weight: 600; }
.control-label output { color: var(--cyan); font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
input[type="range"] { appearance: none; width: 100%; height: 4px; border-radius: 99px; background: linear-gradient(90deg, #327f98, #203c49); display: block; cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 13px; height: 13px; border-radius: 50%; border: 2px solid #c9f4ff; background: #5fc7e5; box-shadow: 0 0 0 3px rgba(95,199,229,.13); }
input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; border: 2px solid #c9f4ff; background: #5fc7e5; box-shadow: 0 0 0 3px rgba(95,199,229,.13); }
.control-hint { display: block; margin-top: 7px; color: #68838e; font-size: 9px; line-height: 1.4; }
.panel-note { display: flex; gap: 8px; padding: 10px 9px; margin-top: 2px; border-radius: 8px; background: rgba(118,217,242,.055); color: #8ba7b0; font-size: 9px; line-height: 1.5; }
.note-symbol { flex: 0 0 15px; width: 15px; height: 15px; display: grid; place-items: center; border: 1px solid rgba(118,217,242,.42); border-radius: 50%; color: var(--cyan); font-size: 9px; font-weight: 700; }
.stage-column { min-width: 0; display: flex; flex-direction: column; gap: 0; }
.stage-toolbar { height: 43px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; background: #0b1b25; }
.stage-title { display: flex; align-items: center; gap: 8px; color: #b6cbd1; font-size: 9px; letter-spacing: .14em; font-weight: 750; }
.stage-index { color: var(--cyan); font-variant-numeric: tabular-nums; }
.scale-pill { color: #7897a2; font-size: 8px; padding: 4px 6px; border: 1px solid var(--line-strong); border-radius: 4px; letter-spacing: .08em; }
.stage-tools { display: flex; gap: 6px; }
.icon-button { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 6px; background: rgba(255,255,255,.025); color: #a7c4cd; font-size: 13px; cursor: pointer; transition: background .18s ease, border-color .18s ease; }
.icon-button:hover { border-color: rgba(118,217,242,.45); background: rgba(118,217,242,.09); color: #d9f8ff; }
#qualityToggle { font-size: 8px; font-weight: 800; letter-spacing: .04em; }
.stage { position: relative; isolation: isolate; min-height: 570px; height: min(68vh, 760px); overflow: hidden; border: 1px solid var(--line); background: radial-gradient(ellipse at 52% 42%, #17313b 0%, #0a1a24 62%, #07131c 100%); }
.scene-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.stage-vignette { position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(180deg, rgba(4,12,18,.28), transparent 19%, transparent 76%, rgba(4,12,18,.6)); }
.stage-corner { position: absolute; z-index: 2; pointer-events: none; color: rgba(176,209,219,.68); font-size: 8px; letter-spacing: .12em; font-weight: 720; }
.stage-corner.top-left { top: 14px; left: 15px; display: flex; align-items: center; gap: 7px; }
.stage-corner.bottom-left { bottom: 69px; left: 15px; color: rgba(155,187,198,.58); }
.stage-corner.bottom-right { bottom: 69px; right: 15px; color: rgba(155,187,198,.58); }
.corner-dot { width: 5px; height: 5px; background: var(--cyan); border-radius: 50%; box-shadow: 0 0 9px var(--cyan); }
.corner-sep { color: #42626d; }
.stage-hud { position: absolute; z-index: 2; top: 13px; right: 15px; display: grid; gap: 3px; text-align: right; pointer-events: none; }
.hud-label { color: #7d9ca7; font-size: 8px; letter-spacing: .14em; font-weight: 750; }
.stage-hud strong { color: #e3f8fd; font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stage-bottom-controls { position: absolute; z-index: 3; left: 12px; right: 12px; bottom: 12px; min-height: 42px; display: flex; align-items: center; gap: 8px; padding: 6px; border: 1px solid rgba(164,213,227,.18); border-radius: 9px; background: rgba(6,18,26,.82); backdrop-filter: blur(16px); box-shadow: 0 8px 30px rgba(0,0,0,.22); }
.play-button { display: flex; align-items: center; gap: 7px; min-width: 87px; height: 30px; padding: 0 10px; border: 1px solid rgba(118,217,242,.36); border-radius: 6px; background: rgba(75,168,196,.16); color: #c9f4ff; font-size: 10px; font-weight: 700; cursor: pointer; }
.play-button:hover { background: rgba(75,168,196,.26); }
.play-glyph { font-size: 11px; width: 11px; }
.transport-button { height: 30px; display: flex; align-items: center; gap: 5px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: rgba(255,255,255,.025); color: #a9c2ca; font-size: 9px; font-weight: 750; letter-spacing: .04em; cursor: pointer; }
.transport-button:hover { color: #e4f9ff; border-color: rgba(118,217,242,.4); }
.transport-button span { color: var(--cyan); font-size: 14px; }
.transport-divider { width: 1px; height: 20px; background: var(--line-strong); margin: 0 2px; }
.speed-control { display: flex; gap: 2px; padding: 2px; border: 1px solid rgba(255,255,255,.07); border-radius: 6px; background: rgba(255,255,255,.025); }
.speed-control button { border: 0; border-radius: 4px; padding: 5px 7px; background: transparent; color: #7f9ba5; font-size: 9px; font-weight: 700; cursor: pointer; }
.speed-control button.selected { background: rgba(118,217,242,.16); color: #c8f4ff; }
.transport-spacer { flex: 1; }
.transport-status { display: flex; align-items: center; gap: 6px; color: #85a2ac; font-size: 8px; letter-spacing: .1em; font-weight: 750; white-space: nowrap; }
.transport-status.paused .status-dot { background: #9aaeb5; box-shadow: none; }
.mechanism-strip { display: flex; align-items: center; justify-content: space-between; gap: 7px; padding: 12px 9px 2px; }
.mechanism-step { display: flex; align-items: center; gap: 7px; min-width: 0; }
.mechanism-number { flex: 0 0 22px; width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid rgba(118,217,242,.3); border-radius: 50%; color: var(--cyan); font-size: 9px; font-weight: 750; }
.mechanism-step strong { display: block; color: #a9c2ca; font-size: 8px; letter-spacing: .12em; }
.mechanism-step small { display: block; margin-top: 3px; color: #6e8994; font-size: 9px; white-space: nowrap; }
.mechanism-arrow { color: #456975; font-size: 15px; }
.annotation-layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.scene-label { position: absolute; display: none; transform: translate(-50%, -50%); padding: 4px 6px; border-radius: 4px; border: 1px solid rgba(130,220,240,.3); background: rgba(5,19,27,.78); color: #b8f0fc; font-size: 8px; font-weight: 780; letter-spacing: .1em; white-space: nowrap; text-shadow: 0 1px 4px #000; }
.scene-label::before { content: ""; display: inline-block; width: 4px; height: 4px; margin: 0 5px 1px 0; border-radius: 50%; background: currentColor; }
.label-blue { color: #82d9f2; border-color: rgba(70,174,214,.35); }
.label-ice { color: #d4f9ff; border-color: rgba(178,242,255,.45); }
.label-amber { color: #f2c17f; border-color: rgba(242,193,127,.35); }
.scene-error { position: absolute; z-index: 6; inset: 50% auto auto 50%; transform: translate(-50%,-50%); width: min(84%, 390px); padding: 24px; border: 1px solid rgba(118,217,242,.26); border-radius: 12px; background: rgba(5,19,27,.94); text-align: center; box-shadow: 0 18px 60px rgba(0,0,0,.4); }
.scene-error[hidden] { display: none; }
.error-icon { color: var(--cyan); font-size: 26px; margin-bottom: 8px; }
.scene-error strong { font-size: 14px; }
.scene-error p { color: var(--muted); font-size: 11px; line-height: 1.6; }
.data-heading { align-items: center; }
.data-heading h2 { font-size: 17px; }
.live-chip { display: flex; align-items: center; gap: 5px; padding: 4px 7px; border: 1px solid rgba(133,217,176,.22); border-radius: 20px; color: #8bdab6; font-size: 8px; letter-spacing: .1em; font-weight: 800; }
.live-chip i { width: 5px; height: 5px; border-radius: 50%; background: #7cd8a7; box-shadow: 0 0 7px rgba(124,216,167,.65); }
.readout-list { display: grid; gap: 7px; padding: 13px 0; }
.readout-card { padding: 10px 10px 9px; border: 1px solid rgba(153,198,214,.11); border-radius: 8px; background: rgba(255,255,255,.022); }
.primary-readout { border-color: rgba(118,217,242,.23); background: linear-gradient(135deg, rgba(61,143,168,.12), rgba(255,255,255,.02)); }
.readout-top { display: flex; align-items: center; justify-content: space-between; color: #8ca9b3; font-size: 8px; letter-spacing: .12em; font-weight: 760; }
.readout-tag { color: #64818b; font-size: 7px; letter-spacing: .08em; }
.readout-value { display: flex; align-items: baseline; gap: 5px; margin: 4px 0 2px; }
.readout-value strong { color: #e3f5f8; font-size: 23px; line-height: 1.15; font-weight: 630; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.primary-readout .readout-value strong { color: #a8ebfb; }
.readout-value span { color: #8daab4; font-size: 10px; }
.readout-card small { display: block; color: #69838e; font-size: 8px; line-height: 1.4; }
.readout-card small b { color: #aac4cd; font-weight: 650; }
.readout-track { height: 3px; margin: 7px 0 6px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.readout-track i { display: block; width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #3b91ae, #9ceaff); transition: width .25s ease; }
.validation-card { padding: 12px 10px 10px; border: 1px solid rgba(242,182,109,.2); border-radius: 8px; background: linear-gradient(135deg, rgba(158,105,49,.1), rgba(255,255,255,.018)); }
.validation-title { display: flex; align-items: center; gap: 6px; color: #c9a777; font-size: 8px; letter-spacing: .11em; font-weight: 800; }
.validation-check { display: grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; color: #07131c; background: #9bd7b1; font-size: 9px; font-weight: 900; }
.validation-name { display: block; margin-top: 8px; color: #e2e9e8; font-size: 10px; }
.validation-equation { margin: 5px 0 9px; color: #d6b27d; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.validation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.validation-grid div { padding: 7px; border-radius: 5px; background: rgba(0,0,0,.16); }
.validation-grid small { display: block; color: #8f9d9c; font-size: 7px; letter-spacing: .1em; }
.validation-grid b { display: block; margin-top: 3px; color: #dce9e8; font-size: 11px; font-variant-numeric: tabular-nums; }
.validation-diff { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 7px; border-top: 1px solid rgba(242,182,109,.14); color: #9eaaa7; font-size: 8px; }
.validation-diff b { color: #b5e0c4; font-size: 9px; }
.science-section { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #0a1a24; }
.science-details summary { display: flex; align-items: center; gap: 11px; padding: 13px 15px; cursor: pointer; list-style: none; }
.science-details summary::-webkit-details-marker { display: none; }
.science-summary-icon { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid rgba(118,217,242,.26); border-radius: 7px; color: var(--cyan); font-size: 15px; }
.science-details summary strong { display: block; font-size: 11px; }
.science-details summary small { display: block; margin-top: 3px; color: #7d99a3; font-size: 9px; }
.summary-chevron { margin-left: auto; color: #7d9ba5; font-size: 17px; transition: transform .2s ease; }
.science-details[open] .summary-chevron { transform: rotate(180deg); }
.science-content { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 9px; padding: 0 14px 14px; }
.equation-card { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.02); }
.equation { margin: 12px 0 8px; color: #b8edfa; font-family: Georgia, "Times New Roman", serif; font-size: 16px; white-space: nowrap; }
.equation sub { font-size: 10px; }
.equation-card p { margin: 0; color: #829ca6; font-size: 9px; line-height: 1.55; }
.science-footnote { grid-column: 1 / -1; padding: 10px 12px; border-left: 2px solid rgba(242,182,109,.55); background: rgba(242,182,109,.045); }
.science-footnote b { color: #d9b783; font-size: 9px; }
.science-footnote p { margin: 5px 0 0; color: #8ba2aa; font-size: 9px; line-height: 1.6; }
.footer-note { display: flex; justify-content: space-between; gap: 10px; padding: 12px 2px 0; color: #5e7984; font-size: 8px; letter-spacing: .04em; }
.footer-note span:last-child { font-weight: 750; letter-spacing: .12em; }
.footer-note i { color: #88b9c6; font-style: normal; padding: 0 3px; }

.embed .app-shell { padding: 0 10px 10px; }
.embed .topbar { display: none; }
.embed .workspace { padding-top: 8px; }
.embed .science-section, .embed .footer-note { display: none; }
.embed .stage { height: min(74vh, 720px); }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(220px, 245px) minmax(390px, 1fr); }
  .data-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 210px 1fr; gap: 12px; align-items: start; }
  .data-heading { grid-column: 1 / -1; padding-bottom: 10px; }
  .readout-list { grid-template-columns: repeat(5, minmax(0,1fr)); gap: 6px; padding: 0; }
  .readout-card { padding: 9px 8px; }
  .readout-value strong { font-size: 20px; }
  .validation-card { align-self: stretch; }
}

@media (max-width: 820px) {
  .app-shell { padding: 0 12px 14px; }
  .workspace { grid-template-columns: 1fr; gap: 10px; }
  .stage-column { order: -1; }
  .stage { min-height: 420px; height: 56vh; }
  .controls-panel { order: 0; }
  .data-panel { grid-column: auto; display: block; }
  .readout-list { grid-template-columns: repeat(2, minmax(0,1fr)); padding: 12px 0; }
  .readout-card:last-child { grid-column: 1 / -1; }
  .science-content { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .mechanism-strip { flex-wrap: wrap; }
  .mechanism-step { flex: 1 1 26%; }
  .mechanism-arrow { display: none; }
}

@media (max-width: 520px) {
  .app-shell { padding: 0 8px 12px; }
  .topbar { height: 60px; }
  .topbar-meta { font-size: 7px; gap: 6px; }
  .brand-title { font-size: 14px; }
  .brand-mark { width: 30px; height: 30px; }
  .workspace { padding-top: 8px; }
  .stage-toolbar { height: 38px; padding: 0 8px; }
  .stage-title { font-size: 8px; gap: 6px; }
  .scale-pill { font-size: 7px; padding: 3px 5px; }
  .stage { min-height: 410px; height: 51vh; }
  .stage-bottom-controls { left: 7px; right: 7px; bottom: 7px; gap: 5px; padding: 5px; }
  .play-button { min-width: 73px; padding: 0 7px; font-size: 9px; }
  .transport-button { padding: 0 6px; font-size: 8px; }
  .transport-divider { margin: 0; }
  .speed-control button { padding: 5px 5px; font-size: 8px; }
  .transport-status { font-size: 7px; gap: 4px; }
  .stage-corner { font-size: 7px; }
  .stage-corner.bottom-right { display: none; }
  .stage-corner.bottom-left { bottom: 58px; }
  .stage-hud { top: 11px; right: 10px; }
  .hud-label { font-size: 7px; }
  .stage-hud strong { font-size: 14px; }
  .scene-label { font-size: 7px; padding: 3px 4px; }
  .mechanism-strip { padding: 9px 3px 1px; gap: 6px; }
  .mechanism-step { gap: 5px; }
  .mechanism-number { width: 19px; height: 19px; flex-basis: 19px; font-size: 8px; }
  .mechanism-step strong { font-size: 7px; }
  .mechanism-step small { font-size: 8px; white-space: normal; }
  .controls-panel, .data-panel { padding: 13px 11px; }
  .panel-heading h1, .panel-heading h2 { font-size: 16px; }
  .science-content { grid-template-columns: 1fr; }
  .equation { font-size: 15px; }
  .footer-note { flex-direction: column; font-size: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
