:root {
  color-scheme: dark;
  --bg: #0b1117;
  --panel: #101820;
  --panel-2: #131e27;
  --panel-3: #17232d;
  --line: rgba(166, 190, 204, 0.14);
  --line-strong: rgba(166, 190, 204, 0.24);
  --text: #e8f0f3;
  --muted: #8b9da7;
  --muted-2: #637782;
  --accent: #72d4ca;
  --accent-dim: rgba(114, 212, 202, 0.13);
  --brass: #c8a978;
  --steel: #8ea4b1;
  --danger: #e3a47e;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.app-shell { height: 100%; min-height: 0; display: flex; flex-direction: column; background: radial-gradient(ellipse at 22% 12%, rgba(34, 68, 75, .18), transparent 42%), var(--bg); }
.topbar { height: 72px; min-height: 72px; padding: 0 26px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(10, 16, 22, .94); }
.brand-lockup { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-emblem { width: 42px; height: 42px; display: grid; place-items: center; color: var(--accent); border: 1px solid rgba(114, 212, 202, .28); border-radius: 12px; background: rgba(114, 212, 202, .055); }
.brand-emblem svg { width: 32px; height: 32px; }
.brand-copy { min-width: 0; }
.eyebrow { display: block; color: var(--muted); font-size: 9px; line-height: 1.3; font-weight: 750; letter-spacing: .16em; }
.eyebrow span { color: var(--accent); padding: 0 3px; }
h1 { margin: 3px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 22px; line-height: 1; font-weight: 500; letter-spacing: -.025em; }
.topbar-status { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .12em; }
.status-dot, .motion-indicator { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px rgba(114, 212, 202, .55); }
.phase-badge { color: var(--accent); }
.model-tag { margin-left: 10px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; color: #9eb0b8; font-size: 8px; letter-spacing: .13em; }

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.57fr) minmax(370px, .83fr); gap: 14px; padding: 14px; }
.visual-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(21, 33, 42, .96), rgba(11, 18, 25, .98)); box-shadow: 0 18px 50px rgba(0,0,0,.18); }
.visual-toolbar { min-height: 58px; padding: 10px 16px 10px 19px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); background: rgba(17, 27, 35, .72); }
.view-heading { display: flex; flex-direction: column; gap: 3px; }
.view-heading strong { font-family: Georgia, "Times New Roman", serif; font-size: 17px; font-weight: 500; }
.view-switch { display: flex; align-items: center; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: rgba(5, 10, 14, .4); }
.view-button { padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 650; cursor: pointer; transition: color .2s ease, background .2s ease; }
.view-button:hover { color: var(--text); }
.view-button.active { color: var(--accent); background: rgba(114, 212, 202, .12); box-shadow: inset 0 0 0 1px rgba(114, 212, 202, .12); }
.stage-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 46%, rgba(37, 64, 70, .28), transparent 57%), #0d151c; }
#machineCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-corner { position: absolute; top: 16px; display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.stage-corner-left { left: 17px; }
.stage-corner-right { right: 17px; text-align: right; }
.corner-label { color: #71848e; font-size: 8px; font-weight: 750; letter-spacing: .15em; }
.corner-value { color: #b5c6cb; font-size: 9px; font-weight: 750; letter-spacing: .12em; }
.stage-caption { position: absolute; left: 16px; right: 16px; bottom: 14px; display: flex; align-items: flex-start; gap: 11px; max-width: 650px; padding: 12px 15px; border: 1px solid rgba(160, 190, 195, .12); border-radius: 10px; background: linear-gradient(100deg, rgba(10, 18, 23, .92), rgba(10, 18, 23, .72)); backdrop-filter: blur(8px); pointer-events: none; }
.caption-mark { flex: 0 0 auto; width: 3px; min-height: 35px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 14px rgba(114, 212, 202, .35); }
.caption-kicker { display: block; margin-bottom: 4px; color: var(--accent); font-size: 8px; font-weight: 800; letter-spacing: .15em; }
.stage-caption p { margin: 0; color: #c2d0d4; font-size: 11px; line-height: 1.45; max-width: 610px; }
.transport-bar { min-height: 56px; padding: 9px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); background: rgba(13, 21, 28, .92); }
.transport-controls { display: flex; align-items: center; gap: 6px; }
.transport-button, .screenshot-button, .quality-button { height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 7px; background: #15212a; color: #b5c5cb; font-size: 10px; font-weight: 700; cursor: pointer; transition: border-color .18s ease, background .18s ease, color .18s ease; }
.transport-button:hover, .screenshot-button:hover, .quality-button:hover { border-color: rgba(114,212,202,.45); color: var(--text); }
.quality-button { border-color: rgba(114,212,202,.25); color: #a7c7c6; background: rgba(114,212,202,.06); font-size: 9px; white-space: nowrap; }
.transport-button.primary { border-color: rgba(114,212,202,.4); background: rgba(114,212,202,.12); color: var(--accent); }
.transport-button svg, .screenshot-button svg { width: 16px; height: 16px; }
.transport-meta { display: flex; align-items: center; gap: 8px; color: var(--muted-2); font-size: 8px; font-weight: 750; letter-spacing: .12em; white-space: nowrap; }
.motion-indicator { width: 6px; height: 6px; }
.transport-meta.paused .motion-indicator { background: #84949c; box-shadow: none; }
.screenshot-button { border-color: transparent; background: transparent; }

.control-panel { min-height: 0; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 11px; padding: 1px 2px 12px 0; scrollbar-width: thin; scrollbar-color: #30424c transparent; }
.control-panel::-webkit-scrollbar { width: 6px; }
.control-panel::-webkit-scrollbar-thumb { background: #30424c; border-radius: 8px; }
.readout-section, .plot-card, .controls-card, .science-card { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(18, 29, 38, .96), rgba(13, 21, 28, .96)); box-shadow: 0 10px 26px rgba(0,0,0,.12); }
.readout-section { padding: 15px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-heading h2, .plot-heading h2 { margin: 4px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 18px; line-height: 1.1; font-weight: 500; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid rgba(114,212,202,.22); border-radius: 20px; color: var(--accent); font-size: 8px; font-weight: 800; letter-spacing: .13em; }
.live-pill i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.readout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.readout-card { min-width: 0; padding: 10px 11px 8px; border: 1px solid rgba(156, 181, 192, .11); border-radius: 9px; background: rgba(5, 12, 17, .32); }
.readout-card.readout-primary { border-color: rgba(114,212,202,.22); background: linear-gradient(135deg, rgba(114,212,202,.09), rgba(5,12,17,.28)); }
.readout-label { display: block; overflow: hidden; color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .11em; white-space: nowrap; text-overflow: ellipsis; }
.readout-value { display: flex; align-items: baseline; gap: 5px; margin-top: 5px; white-space: nowrap; }
.readout-value strong { color: #eaf3f4; font-size: 22px; font-weight: 550; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.readout-primary .readout-value strong { color: var(--accent); }
.readout-value span { color: #9aacb4; font-size: 9px; }
.readout-origin { display: block; margin-top: 3px; color: #647781; font-size: 7px; font-weight: 650; letter-spacing: .08em; }
.secondary-readouts { display: flex; justify-content: space-between; gap: 12px; padding: 10px 2px 0; }
.secondary-readouts div { display: flex; flex-direction: column; gap: 3px; }
.secondary-readouts span { color: var(--muted); font-size: 9px; }
.secondary-readouts strong { color: #c7d4d8; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.secondary-origin { color: #647781; font-size: 7px; font-weight: 650; letter-spacing: .06em; }

.plot-card { padding: 14px 14px 11px; }
.plot-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.plot-heading h2 { font-size: 16px; }
.origin-chip { margin-top: 1px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; color: #82959e; font-size: 7px; font-weight: 750; letter-spacing: .1em; white-space: nowrap; }
#plotCanvas { display: block; width: 100%; height: 114px; margin-top: 6px; }
.plot-legend { display: flex; align-items: center; gap: 17px; color: #9aabb2; font-size: 8px; }
.plot-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { width: 17px; height: 2px; display: inline-block; border-radius: 2px; }
.legend-line.direct { background: #8597a1; }
.legend-line.buffered { background: var(--accent); box-shadow: 0 0 7px rgba(114,212,202,.35); }

.controls-card { padding: 15px; }
.controls-heading { margin-bottom: 10px; }
.control-note { color: var(--muted-2); font-size: 8px; white-space: nowrap; }
.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 13px; }
.preset-button { min-height: 32px; border: 1px solid var(--line); border-radius: 7px; background: rgba(4, 11, 16, .35); color: #9aabb2; font-size: 9px; font-weight: 700; cursor: pointer; transition: all .18s ease; }
.preset-button:hover { border-color: var(--line-strong); color: var(--text); }
.preset-button.selected { border-color: rgba(114,212,202,.38); background: rgba(114,212,202,.1); color: var(--accent); }
.control-list { display: flex; flex-direction: column; gap: 13px; }
.control-item { min-width: 0; }
.control-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.control-label-row label { color: #d4dfe2; font-size: 10px; font-weight: 650; }
.control-label-row output { color: var(--accent); font-size: 10px; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
input[type="range"] { width: 100%; height: 14px; margin: 5px 0 0; display: block; appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, rgba(114,212,202,.7), rgba(114,212,202,.18)); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, rgba(114,212,202,.7), rgba(114,212,202,.18)); }
input[type="range"]::-webkit-slider-thumb { width: 12px; height: 12px; margin-top: -4.5px; appearance: none; -webkit-appearance: none; border: 2px solid #0d171d; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px rgba(114,212,202,.55), 0 0 9px rgba(114,212,202,.28); }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border: 2px solid #0d171d; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px rgba(114,212,202,.55); }
.control-foot { display: flex; justify-content: space-between; align-items: center; color: #637781; font-size: 7px; }
.origin-label { color: #72858d; font-size: 7px; font-weight: 700; letter-spacing: .06em; }

.science-card { overflow: hidden; }
.science-card summary { min-height: 58px; padding: 11px 15px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }
.science-card summary::-webkit-details-marker { display: none; }
.science-card summary > span:first-child { display: flex; flex-direction: column; gap: 3px; }
.science-card summary strong { font-family: Georgia, "Times New Roman", serif; font-size: 17px; font-weight: 500; }
.details-chevron { color: var(--accent); font-size: 20px; transition: transform .2s ease; }
.science-card[open] .details-chevron { transform: rotate(180deg); }
.science-content { padding: 0 15px 15px; border-top: 1px solid var(--line); }
.science-intro { margin: 12px 0; color: #aebdc2; font-size: 10px; line-height: 1.55; }
.equation-list { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.equation-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 9px; border-bottom: 1px solid var(--line); background: rgba(5,12,17,.28); }
.equation-row:last-child { border-bottom: 0; }
.equation-row span { color: #8fa1a9; font-size: 8px; }
.equation-row code { color: #c9e5e1; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; white-space: nowrap; }
.check-panel { margin-top: 11px; padding: 10px; border: 1px solid rgba(114,212,202,.18); border-radius: 8px; background: rgba(114,212,202,.045); }
.check-heading { display: flex; justify-content: space-between; align-items: center; color: #9db0b6; font-size: 8px; font-weight: 800; letter-spacing: .1em; }
.check-pass { color: var(--accent); }
.check-panel p { margin: 7px 0; color: #8fa1a9; font-size: 9px; line-height: 1.45; }
.check-values { display: grid; grid-template-columns: auto 1fr auto auto; align-items: baseline; gap: 7px; }
.check-values strong, .check-values b { color: #dce8e9; font-size: 11px; font-weight: 750; font-variant-numeric: tabular-nums; }
.check-values span { color: #72858e; font-size: 8px; }
.check-difference { margin-top: 7px; color: #8799a1; font-size: 8px; }
.check-difference strong { color: var(--accent); font-size: 9px; }
.simplification-note { margin-top: 12px; }
.simplification-note strong { color: #c7d4d8; font-size: 9px; }
.simplification-note p { margin: 5px 0 0; color: #8799a1; font-size: 9px; line-height: 1.55; }
.disclaimer { margin: 12px 0 0; padding-top: 9px; border-top: 1px solid var(--line); color: #788b94; font-size: 8px; line-height: 1.45; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: minmax(0, 1.35fr) minmax(340px, .9fr); }
  .topbar { padding: 0 18px; }
  .view-button { padding: 7px 8px; }
}

@media (max-width: 760px) {
  body { overflow: hidden; }
  .topbar { height: 59px; min-height: 59px; padding: 0 12px; }
  .brand-emblem { width: 35px; height: 35px; border-radius: 10px; }
  .brand-emblem svg { width: 27px; height: 27px; }
  .brand-lockup { gap: 9px; }
  .eyebrow { font-size: 7px; letter-spacing: .12em; }
  h1 { font-size: 18px; }
  .topbar-status { gap: 6px; font-size: 7px; }
  .model-tag { display: none; }
  .workspace { padding: 8px; gap: 8px; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(270px, 44dvh) minmax(0, 1fr); }
  .visual-panel { border-radius: 11px; }
  .visual-toolbar { min-height: 46px; padding: 6px 8px 6px 11px; gap: 6px; }
  .view-heading { gap: 1px; }
  .view-heading .eyebrow { font-size: 7px; }
  .view-heading strong { font-size: 14px; }
  .view-switch { gap: 1px; padding: 2px; }
  .view-button { padding: 6px 7px; font-size: 8px; }
  .stage-caption { left: 8px; right: 8px; bottom: 7px; padding: 8px 9px; gap: 8px; border-radius: 8px; }
  .caption-mark { min-height: 31px; }
  .caption-kicker { font-size: 7px; margin-bottom: 2px; }
  .stage-caption p { font-size: 9px; line-height: 1.35; }
  .stage-corner { top: 8px; }
  .stage-corner-left { left: 9px; }
  .stage-corner-right { right: 9px; }
  .corner-label { font-size: 6px; }
  .corner-value { font-size: 7px; }
  .transport-bar { min-height: 43px; padding: 5px 7px; gap: 5px; }
  .transport-button, .screenshot-button, .quality-button { height: 30px; padding: 0 7px; gap: 4px; font-size: 8px; }
  .transport-button svg, .screenshot-button svg { width: 14px; height: 14px; }
  .transport-controls { gap: 4px; }
  .transport-meta { gap: 5px; font-size: 6px; letter-spacing: .08em; }
  .screenshot-button { padding: 0 5px; }
  .quality-button { padding: 0 6px; font-size: 7px; }
  .control-panel { padding: 0 0 10px; gap: 8px; }
  .readout-section, .plot-card, .controls-card { padding: 11px; border-radius: 10px; }
  .section-heading { margin-bottom: 9px; }
  .section-heading h2, .plot-heading h2 { font-size: 16px; }
  .readout-grid { gap: 6px; }
  .readout-card { padding: 8px 9px 7px; }
  .readout-value strong { font-size: 19px; }
  .readout-label { font-size: 7px; }
  .secondary-readouts { padding-top: 8px; }
  .plot-card { padding-bottom: 9px; }
  #plotCanvas { height: 95px; }
  .controls-card { padding: 12px; }
  .control-list { gap: 11px; }
  .science-card summary { min-height: 51px; padding: 9px 12px; }
  .science-content { padding: 0 12px 12px; }
}

@media (max-width: 390px) {
  .workspace { grid-template-rows: minmax(260px, 42dvh) minmax(0, 1fr); }
  .view-button { padding: 6px 5px; font-size: 7px; }
  .transport-button, .screenshot-button, .quality-button { padding: 0 6px; font-size: 7px; }
  .transport-meta { font-size: 5px; }
}

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