:root {
  color-scheme: dark;
  --bg: #0b1118;
  --panel: #111b25;
  --panel-2: #15212c;
  --line: rgba(180, 198, 210, .12);
  --line-strong: rgba(180, 198, 210, .2);
  --text: #edf1f3;
  --muted: #91a0aa;
  --soft: #647581;
  --accent: #e5b45d;
  --accent-bright: #ffd58a;
  --accent-dim: rgba(229, 180, 93, .14);
  --good: #e5b45d;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-width: 320px; background: radial-gradient(ellipse at 34% -16%, rgba(50, 71, 82, .22), transparent 52%), var(--bg); }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { min-height: 100vh; padding: 0 22px 18px; max-width: 1800px; margin: 0 auto; }
.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); gap: 18px; }
.brand-lockup { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark { width: 42px; height: 42px; border: 1px solid rgba(229,180,93,.28); background: linear-gradient(145deg, rgba(229,180,93,.13), rgba(229,180,93,.025)); color: var(--accent); border-radius: 12px; display: grid; place-items: center; flex: 0 0 auto; }
.brand-mark svg { width: 31px; height: 31px; }
.eyebrow, .section-kicker { font-size: 9px; font-weight: 750; letter-spacing: .17em; color: var(--accent); line-height: 1.3; }
h1 { margin: 3px 0 0; font-size: 18px; line-height: 1.1; letter-spacing: -.025em; font-weight: 650; }
.topbar-meta { display: flex; align-items: center; gap: 18px; }
.topic-chip, .scene-tag, .micro-tag { border: 1px solid var(--line-strong); border-radius: 99px; padding: 6px 9px; color: #b7c2c9; font-size: 9px; letter-spacing: .1em; font-weight: 700; white-space: nowrap; }
.live-indicator { display: inline-flex; align-items: center; gap: 8px; font-size: 9px; letter-spacing: .13em; font-weight: 750; color: #a7b4bc; white-space: nowrap; }
.live-indicator i { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px rgba(229,180,93,.09); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 354px; gap: 16px; height: calc(100vh - 94px); height: calc(100dvh - 94px); min-height: 600px; padding-top: 16px; }
.stage-panel, .control-panel { background: linear-gradient(160deg, rgba(21,33,44,.98), rgba(14,23,32,.98)); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.stage-panel { display: flex; flex-direction: column; padding: 15px; overflow: hidden; }
.stage-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; margin-bottom: 10px; }
.stage-title { font-size: 14px; font-weight: 620; margin-top: 4px; letter-spacing: -.015em; }
.stage-tools { display: flex; align-items: center; gap: 10px; }
.scene-tag { font-size: 8px; color: var(--muted); padding: 6px 8px; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.025); color: #c7d0d5; cursor: pointer; transition: background .18s ease, border-color .18s ease, color .18s ease; }
.icon-button svg { width: 18px; height: 18px; }
.icon-button:hover { color: var(--accent-bright); border-color: rgba(229,180,93,.45); background: var(--accent-dim); }
.canvas-wrap { position: relative; flex: 1 1 auto; min-height: 280px; overflow: hidden; border-radius: 11px; background: #121c24; border: 1px solid rgba(255,255,255,.055); }
#simCanvas { display: block; width: 100%; height: 100%; outline: none; }
.canvas-corner-label { position: absolute; top: 12px; left: 13px; display: flex; align-items: center; gap: 7px; color: rgba(237,241,243,.65); font-size: 8px; font-weight: 750; letter-spacing: .16em; pointer-events: none; }
.corner-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 9px rgba(229,180,93,.7); }
.canvas-scale { position: absolute; bottom: 12px; left: 13px; display: flex; align-items: center; gap: 6px; color: rgba(237,241,243,.72); font-size: 9px; pointer-events: none; }
.canvas-scale span { display: block; width: 40px; height: 5px; border: 1px solid rgba(237,241,243,.7); border-top: 0; }
.canvas-scale b { font-size: 9px; font-weight: 650; }
.canvas-scale small { color: rgba(237,241,243,.45); font-size: 8px; }
.process-rail { display: grid; grid-template-columns: 1fr 22px 1.25fr 22px 1fr; align-items: center; gap: 6px; padding: 12px 4px 10px; border-bottom: 1px solid var(--line); }
.process-step { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.process-index { color: var(--accent); font-size: 8px; letter-spacing: .14em; font-weight: 800; }
.process-step strong { font-size: 11px; font-weight: 650; white-space: nowrap; }
.process-step small { font-size: 9px; color: var(--muted); }
.process-arrow { color: #687782; font-size: 17px; text-align: center; }
.caption-strip { display: flex; gap: 11px; align-items: flex-start; padding: 11px 2px 10px; min-height: 62px; }
.caption-mark { width: 19px; height: 19px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; border: 1px solid rgba(229,180,93,.45); color: var(--accent); font-size: 11px; font-family: Georgia, serif; font-style: italic; }
.caption-label { color: #b3bec5; font-size: 8px; font-weight: 800; letter-spacing: .15em; margin-bottom: 4px; }
.caption-strip p { margin: 0; color: #d1d9dd; font-size: 10px; line-height: 1.45; max-width: 900px; }
.readout-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.readout-card { min-width: 0; background: rgba(5,12,18,.28); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px 9px; }
.readout-highlight { border-color: rgba(229,180,93,.28); background: linear-gradient(135deg, rgba(229,180,93,.09), rgba(5,12,18,.3)); }
.readout-label { display: flex; align-items: center; gap: 6px; color: #9eacb5; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info-dot { width: 13px; height: 13px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; border: 1px solid rgba(180,198,210,.35); color: #aab7be; font-size: 8px; font-family: Georgia, serif; font-style: italic; cursor: help; }
.readout-value { margin-top: 5px; font-size: clamp(17px, 1.6vw, 23px); font-weight: 650; letter-spacing: -.04em; color: #f3f1eb; white-space: nowrap; }
.readout-value small { color: #a8b4bb; font-size: 9px; font-weight: 550; letter-spacing: 0; }
.readout-foot { margin-top: 3px; color: var(--soft); font-size: 8px; letter-spacing: .05em; }
.control-panel { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #354652 transparent; padding: 17px 16px 13px; }
.panel-header h2 { margin: 5px 0 5px; font-size: 19px; letter-spacing: -.035em; font-weight: 650; }
.panel-header p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; max-width: 290px; }
.preset-block { margin-top: 18px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.control-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.control-label { color: #9eacb5; font-size: 8px; letter-spacing: .15em; font-weight: 800; }
.micro-tag { font-size: 7px; padding: 4px 7px; color: #83929c; }
.preset-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.preset-button { min-width: 0; display: flex; align-items: center; gap: 8px; text-align: left; padding: 9px 8px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.02); border-radius: 9px; cursor: pointer; transition: border-color .18s ease, background .18s ease; }
.preset-button:hover { border-color: rgba(229,180,93,.4); }
.preset-button.active { border-color: rgba(229,180,93,.58); background: rgba(229,180,93,.085); }
.preset-symbol { width: 24px; height: 24px; flex: 0 0 auto; border-radius: 7px; display: grid; place-items: center; background: rgba(255,255,255,.055); color: #a9b5bd; font-size: 15px; }
.source-symbol { color: var(--accent); background: rgba(229,180,93,.11); }
.preset-button b { display: block; font-size: 9px; font-weight: 680; line-height: 1.2; }
.preset-button small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; line-height: 1.2; }
.control-section { padding-top: 15px; }
.slider-control { margin: 0 0 14px; }
.slider-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.slider-heading label { font-size: 10px; color: #e2e8eb; font-weight: 560; }
.slider-heading output { color: var(--accent-bright); font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.slider-heading output em { color: #82919a; font-size: 7px; font-style: normal; margin-left: 3px; letter-spacing: .02em; }
input[type="range"] { display: block; width: 100%; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: linear-gradient(90deg, rgba(229,180,93,.7), rgba(229,180,93,.16)); border-radius: 5px; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; border-radius: 50%; margin-top: -4.5px; border: 2px solid #f5d79f; background: #9e7537; box-shadow: 0 0 0 3px rgba(229,180,93,.12); }
input[type="range"]::-moz-range-track { height: 3px; background: rgba(229,180,93,.25); border-radius: 5px; }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; border: 2px solid #f5d79f; background: #9e7537; box-shadow: 0 0 0 3px rgba(229,180,93,.12); }
.range-ends { display: flex; justify-content: space-between; color: #71818c; font-size: 7px; margin-top: -1px; }
.control-hint { margin: 4px 0 0; color: #81909a; font-size: 8px; line-height: 1.35; }
.control-bottom { border-top: 1px solid var(--line); margin-top: 3px; }
.transport-controls { display: grid; grid-template-columns: 1.25fr .8fr .8fr; gap: 7px; }
.primary-button, .secondary-button { height: 34px; border-radius: 8px; cursor: pointer; font-size: 10px; font-weight: 650; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 7px; background: var(--accent); color: #1c1a16; border: 1px solid var(--accent); }
.primary-button:hover { background: var(--accent-bright); }
.secondary-button { background: rgba(255,255,255,.035); border: 1px solid var(--line-strong); color: #c8d1d6; }
.secondary-button:hover { border-color: rgba(229,180,93,.4); background: var(--accent-dim); }
.play-icon { font-size: 11px; letter-spacing: -2px; }
.quality-row { display: flex; align-items: center; justify-content: space-between; margin-top: 13px; }
.segmented-control { display: flex; padding: 2px; border-radius: 8px; background: rgba(0,0,0,.22); border: 1px solid var(--line); }
.segmented-control button { min-width: 42px; height: 24px; border: 0; border-radius: 6px; color: #91a0aa; background: transparent; font-size: 8px; cursor: pointer; }
.segmented-control button.selected { color: #241e14; background: var(--accent); font-weight: 750; }
.keyboard-hint { margin-top: 10px; color: #74838d; font-size: 8px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
kbd { border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 2px 4px; color: #b9c3c9; font-size: 8px; background: rgba(255,255,255,.025); }
.check-card { margin-top: 15px; border: 1px solid rgba(229,180,93,.22); background: linear-gradient(140deg, rgba(229,180,93,.07), rgba(5,12,18,.25)); border-radius: 10px; padding: 11px; }
.check-heading { display: flex; align-items: center; gap: 9px; }
.check-icon { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 7px; background: rgba(229,180,93,.13); color: var(--good); font-size: 12px; }
.check-heading strong { display: block; margin-top: 3px; font-size: 10px; font-weight: 650; }
.check-values { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.check-values span, .check-delta span { display: block; color: #8c9ba4; font-size: 8px; }
.check-values b { display: block; margin-top: 4px; color: #e3ebe7; font-size: 12px; font-variant-numeric: tabular-nums; }
.check-delta { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; padding-top: 8px; border-top: 1px solid rgba(229,180,93,.13); }
.check-delta b { color: var(--good); font-size: 10px; font-variant-numeric: tabular-nums; }
.check-note { color: #8f7a57; font-size: 8px; line-height: 1.4; margin: 8px 0 0; }
.science-panel { margin-top: 13px; border: 1px solid var(--line); border-radius: 10px; background: rgba(0,0,0,.13); }
.science-panel summary { list-style: none; cursor: pointer; padding: 12px 11px; display: flex; align-items: center; justify-content: space-between; color: #dce3e6; font-size: 10px; font-weight: 650; }
.science-panel summary::-webkit-details-marker { display: none; }
.summary-plus { color: var(--accent); font-size: 16px; line-height: 10px; transition: transform .2s ease; }
.science-panel[open] .summary-plus { transform: rotate(45deg); }
.science-content { padding: 0 11px 12px; color: #aab6bd; font-size: 9px; line-height: 1.55; }
.science-content h3 { margin: 12px 0 5px; color: #e5e9e9; font-size: 9px; letter-spacing: .02em; }
.science-content p { margin: 5px 0 8px; }
.science-content ul { margin: 5px 0 10px; padding-left: 15px; }
.science-content li { margin: 4px 0; }
.equation { overflow-wrap: anywhere; border-left: 2px solid rgba(229,180,93,.55); background: rgba(229,180,93,.055); padding: 7px 8px; color: #f1d7a5; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; margin: 7px 0; }
.model-note { color: #c4d2ca; font-style: italic; padding-top: 5px; }
.references { border-top: 1px solid var(--line); margin-top: 9px; padding-top: 8px; color: #7f8e98; font-size: 8px; line-height: 1.5; }
.panel-footnote { color: #64747e; font-size: 7px; line-height: 1.4; padding: 10px 2px 0; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 3px; }
@media (max-width: 1050px) and (min-width: 761px) {
  .app-shell { padding-inline: 14px; }
  .workspace { grid-template-columns: minmax(0, 1fr) 326px; gap: 11px; }
  .stage-panel { padding: 12px; }
  .control-panel { padding-inline: 13px; }
  .readout-card { padding-inline: 8px; }
  .readout-label { font-size: 8px; }
}
@media (max-width: 760px) {
  .app-shell { padding: 0 10px 10px; }
  .topbar { height: 60px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .brand-mark svg { width: 26px; height: 26px; }
  .eyebrow { font-size: 7px; }
  h1 { font-size: 15px; }
  .topbar-meta { gap: 9px; }
  .topic-chip { font-size: 7px; padding: 5px 7px; }
  .live-indicator { font-size: 7px; gap: 6px; }
  .workspace { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(250px, 44dvh) minmax(0,1fr); gap: 9px; height: calc(100dvh - 68px); min-height: 0; padding-top: 8px; }
  .stage-panel { padding: 9px; border-radius: 11px; }
  .stage-heading { min-height: 29px; margin-bottom: 6px; }
  .section-kicker { font-size: 7px; }
  .stage-title { font-size: 11px; margin-top: 2px; }
  .scene-tag { font-size: 6px; padding: 5px 6px; }
  .icon-button { width: 29px; height: 29px; border-radius: 8px; }
  .icon-button svg { width: 15px; height: 15px; }
  .canvas-wrap { min-height: 130px; border-radius: 8px; }
  .canvas-corner-label { top: 8px; left: 9px; font-size: 6px; }
  .canvas-scale { bottom: 7px; left: 9px; gap: 4px; }
  .canvas-scale span { width: 27px; height: 4px; }
  .canvas-scale b, .canvas-scale small { font-size: 7px; }
  .process-rail { padding: 7px 1px 6px; grid-template-columns: 1fr 13px 1.2fr 13px 1fr; gap: 2px; }
  .process-index { font-size: 6px; }
  .process-step strong { font-size: 8px; }
  .process-step small { font-size: 7px; }
  .process-arrow { font-size: 12px; }
  .caption-strip { min-height: 39px; padding: 6px 0 5px; gap: 7px; }
  .caption-mark { width: 15px; height: 15px; font-size: 9px; }
  .caption-label { font-size: 6px; margin-bottom: 2px; }
  .caption-strip p { font-size: 8px; line-height: 1.3; }
  .readout-grid { gap: 4px; }
  .readout-card { padding: 5px 6px 4px; border-radius: 7px; }
  .readout-label { font-size: 6px; gap: 3px; }
  .info-dot { width: 10px; height: 10px; font-size: 6px; }
  .readout-value { font-size: 13px; margin-top: 3px; }
  .readout-value small { font-size: 6px; }
  .readout-foot { font-size: 6px; margin-top: 1px; }
  .control-panel { min-height: 0; padding: 13px 12px 12px; border-radius: 11px; }
  .panel-header h2 { font-size: 16px; margin: 3px 0; }
  .panel-header p { font-size: 9px; }
  .preset-block { margin-top: 12px; padding-bottom: 11px; }
  .control-section { padding-top: 11px; }
  .slider-control { margin-bottom: 12px; }
  .slider-heading label { font-size: 9px; }
  .slider-heading output { font-size: 9px; }
  .control-hint { font-size: 7px; }
  .range-ends { font-size: 6px; }
  .control-label { font-size: 7px; }
  .preset-button { padding: 8px 7px; }
  .preset-button b { font-size: 8px; }
  .preset-button small { font-size: 7px; }
  .transport-controls { grid-template-columns: 1.2fr .8fr .8fr; }
  .primary-button, .secondary-button { height: 32px; font-size: 9px; }
  .check-card { margin-top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
body.embed-mode .app-shell { height: 100%; min-height: 0; display: flex; flex-direction: column; }
body.embed-mode .workspace { flex: 1 1 auto; min-height: 0; }
@media (max-width: 760px) {
  body.embed-mode .workspace { grid-template-rows: minmax(230px, 44dvh) minmax(0,1fr); }
}
