:root {
  color-scheme: dark;
  --bg: #0c1210;
  --panel: #141d19;
  --panel-raised: #19231e;
  --line: #2a3830;
  --line-soft: #223028;
  --text: #e7eee8;
  --muted: #9aaba0;
  --soft: #708178;
  --accent: #b9e5a7;
  --accent-dim: rgba(185, 229, 167, .14);
  --wood: #a8794c;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  background: radial-gradient(ellipse at 18% -10%, rgba(64, 94, 70, .16), transparent 38%), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
}
button, input { font: inherit; }
button { color: inherit; }
.topbar {
  height: 72px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(119, 146, 127, .16);
  background: rgba(11, 17, 14, .84);
}
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 30px; height: 30px; border: 1px solid #607a65; border-radius: 50%; position: relative; display: flex; align-items: center; justify-content: center; gap: 2px; transform: rotate(-18deg); }
.brand-mark span { width: 3px; height: 14px; border-radius: 5px; background: var(--accent); transform: rotate(22deg); opacity: .9; }
.brand-mark span:nth-child(2) { height: 19px; opacity: .65; }
.brand-kicker, .section-kicker, .control-label, .readout-label, .top-meta, .stage-corner, .page-footer, .micro-tag { letter-spacing: .13em; text-transform: uppercase; font-size: 9px; font-weight: 700; }
.brand-kicker { color: var(--accent); font-size: 8px; }
.brand-name { font-size: 13px; font-weight: 650; letter-spacing: .01em; margin-top: 2px; }
.top-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 9px; }
.live-dot, .state-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; box-shadow: 0 0 10px rgba(185,229,167,.45); }
.top-divider { height: 14px; width: 1px; background: var(--line); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; padding: 18px 24px 14px; max-width: 1600px; margin: 0 auto; align-items: stretch; }
.panel { background: linear-gradient(145deg, rgba(24, 34, 29, .97), rgba(17, 25, 21, .98)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 14px 38px rgba(0,0,0,.16); }
.hero-panel { padding: 16px; min-width: 0; }
.stage-heading { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 2px 12px; }
.section-kicker { color: var(--muted); font-size: 9px; }
h1, h2, h3, p { margin-top: 0; }
.stage-heading h1 { font-size: 22px; line-height: 1.1; letter-spacing: -.035em; margin: 5px 0 0; font-weight: 650; }
.state-chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 30px; color: var(--accent); font-size: 9px; font-weight: 750; letter-spacing: .12em; white-space: nowrap; }
.state-dot { width: 5px; height: 5px; }
.stage { height: 510px; min-height: 360px; position: relative; overflow: hidden; border-radius: 12px; border: 1px solid rgba(130, 157, 137, .15); background: #101915; }
#scene { width: 100%; height: 100%; display: block; }
.stage-corner { position: absolute; bottom: 10px; color: rgba(213, 228, 215, .48); font-size: 8px; pointer-events: none; }
.stage-corner-left { left: 12px; }
.stage-corner-right { right: 12px; }
.caption-row { display: flex; gap: 10px; align-items: flex-start; padding: 13px 3px 0; min-height: 48px; }
.caption-mark { width: 17px; height: 17px; border-radius: 50%; border: 1px solid #536a59; color: var(--accent); font-family: Georgia, serif; font-style: italic; font-size: 11px; text-align: center; line-height: 15px; flex: 0 0 auto; }
.caption-row p { color: #b8c6bc; margin: 0; font-size: 12px; line-height: 1.5; }
.control-panel { padding: 16px; min-width: 0; display: flex; flex-direction: column; gap: 14px; max-height: 584px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3a4a40 transparent; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-title-row h2, .experiment-panel h2, .checks-panel h2 { font-size: 17px; letter-spacing: -.025em; line-height: 1.2; margin: 4px 0 0; font-weight: 640; }
.quality-button { border: 1px solid #526b58; color: var(--accent); background: rgba(185,229,167,.08); padding: 6px 9px; border-radius: 7px; font-size: 9px; letter-spacing: .12em; font-weight: 800; cursor: pointer; }
.preset-block { display: flex; flex-direction: column; gap: 8px; }
.control-label-row, .slider-heading, .range-ends, .experiment-action-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.control-label { color: #c0cec4; font-size: 9px; }
.micro-tag { color: #8fa396; font-size: 8px; border: 1px solid #34453a; padding: 3px 6px; border-radius: 4px; white-space: nowrap; }
.preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
.preset { min-width: 0; text-align: left; border: 1px solid var(--line); background: rgba(10, 17, 13, .28); border-radius: 8px; padding: 8px 9px; cursor: pointer; transition: border-color .16s, background .16s, transform .16s; }
.preset:hover { border-color: #617d67; transform: translateY(-1px); }
.preset.active { border-color: #71916e; background: var(--accent-dim); box-shadow: inset 0 0 0 1px rgba(185,229,167,.05); }
.preset-name { display: block; font-size: 11px; font-weight: 650; }
.preset-sub { display: block; font-size: 9px; color: var(--muted); margin-top: 2px; }
.preset-alert .preset-name { color: #d6c19f; }
.sliders { display: grid; gap: 10px; }
.slider-row { display: grid; gap: 4px; }
.slider-heading label { color: #d3ddd5; font-size: 11px; font-weight: 550; }
.slider-heading output { color: var(--accent); font-size: 11px; font-variant-numeric: tabular-nums; font-weight: 650; }
input[type="range"] { appearance: none; -webkit-appearance: none; width: 100%; height: 14px; background: transparent; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 4px; background: linear-gradient(90deg, #77966f, #45594b); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 4px; background: linear-gradient(90deg, #77966f, #45594b); }
input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; margin-top: -5px; background: var(--accent); border: 2px solid #152019; box-shadow: 0 0 0 1px #8caf7d; }
input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); border: 2px solid #152019; box-shadow: 0 0 0 1px #8caf7d; }
input[type="range"]:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.range-ends { color: #718178; font-size: 8px; font-variant-numeric: tabular-nums; }
.readout-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
.readout { padding: 8px 9px 7px; border-radius: 8px; background: rgba(7, 13, 10, .34); border: 1px solid #26352c; min-width: 0; }
.readout-label { display: block; font-size: 7px; color: #8ea094; letter-spacing: .12em; white-space: nowrap; }
.readout strong { display: block; font-size: 19px; letter-spacing: -.04em; line-height: 1.25; margin-top: 4px; font-variant-numeric: tabular-nums; }
.readout-unit { display: block; color: #78897e; font-size: 8px; margin-top: 1px; }
.transport-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.transport-buttons { display: flex; gap: 6px; }
.transport-button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 31px; border: 1px solid #35453b; border-radius: 7px; padding: 5px 9px; background: #1b2820; color: #d4dfd6; font-size: 10px; cursor: pointer; }
.transport-button:hover { border-color: #6a896c; }
.transport-button.primary { background: var(--accent-dim); color: var(--accent); border-color: #5c795e; font-weight: 700; }
.speed-control { display: flex; align-items: center; gap: 3px; color: #819186; font-size: 8px; letter-spacing: .12em; }
.speed-control button { border: 1px solid transparent; background: transparent; border-radius: 5px; padding: 4px 5px; color: #9eaea2; font-size: 9px; cursor: pointer; }
.speed-control button.selected { color: var(--accent); border-color: #4b654f; background: rgba(185,229,167,.08); }
.parameter-note { color: #738279; font-size: 9px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.lab-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; max-width: 1600px; padding: 0 24px 16px; margin: 0 auto; }
.experiment-panel, .checks-panel { padding: 18px; min-width: 0; }
.experiment-panel h2, .checks-panel h2 { font-size: 18px; margin-top: 5px; }
.panel-copy { color: #a5b4a9; font-size: 12px; line-height: 1.6; max-width: 620px; margin: 9px 0 14px; }
.experiment-action-row { justify-content: flex-start; }
.action-button { border: 1px solid #6c8b69; border-radius: 8px; background: var(--accent-dim); color: var(--accent); padding: 9px 12px; font-size: 11px; font-weight: 700; cursor: pointer; }
.action-button span { margin-left: 10px; }
.action-button:hover { background: rgba(185,229,167,.2); }
.experiment-result { margin-top: 13px; min-height: 62px; border-top: 1px solid var(--line-soft); padding-top: 11px; }
.experiment-placeholder { color: #77877c; font-size: 11px; }
.experiment-metrics { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.experiment-metric { min-width: 0; }
.experiment-metric span { display: block; color: #819187; font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.experiment-metric strong { display: block; color: var(--text); font-size: 17px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.experiment-foot { color: #9eafa2; font-size: 10px; margin-top: 8px; }
.checks-list { display: grid; gap: 0; margin-top: 12px; }
.check-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.check-row:last-child { border-bottom: 0; }
.check-row strong { display: block; font-size: 11px; font-weight: 650; }
.check-row span { display: block; color: #829287; font-size: 9px; margin-top: 2px; }
.check-row b { color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.checks-foot { color: #718178; font-size: 9px; line-height: 1.5; border-top: 1px solid var(--line-soft); padding-top: 9px; margin-top: 2px; }
.science-panel { max-width: 1552px; margin: 0 auto 16px; padding: 0 18px; }
.science-panel summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; padding: 16px 0; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-panel summary strong { display: block; font-size: 15px; margin-top: 3px; }
.summary-mark { color: var(--accent); font-size: 20px; transition: transform .2s; }
.science-panel[open] .summary-mark { transform: rotate(45deg); }
.science-content { border-top: 1px solid var(--line-soft); padding: 17px 0 16px; }
.science-columns { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 24px; }
.science-columns h3 { font-size: 12px; margin: 0 0 7px; }
.science-columns p { color: #a6b5aa; font-size: 11px; line-height: 1.65; margin-bottom: 8px; }
.equation { background: rgba(5, 10, 7, .35); border: 1px solid #29372e; border-radius: 7px; padding: 8px 10px; color: #d6e6d8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; margin: 7px 0; overflow-wrap: anywhere; }
.science-foot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.page-footer { display: flex; justify-content: space-between; gap: 12px; color: #66766b; font-size: 8px; padding: 0 26px 18px; max-width: 1600px; margin: 0 auto; }
button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
.embed-mode .topbar, .embed-mode .lab-grid, .embed-mode .science-panel, .embed-mode .page-footer { display: none; }
.embed-mode .workspace { height: 100%; min-height: 0; padding: 12px; gap: 12px; grid-template-columns: minmax(0,1fr) 352px; }
.embed-mode .hero-panel, .embed-mode .control-panel { height: 100%; min-height: 0; max-height: none; }
.embed-mode .hero-panel { display: flex; flex-direction: column; }
.embed-mode .stage { flex: 1; min-height: 0; height: auto; }
.embed-mode .control-panel { overflow-y: auto; }
.embed-mode .caption-row { min-height: 42px; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0,1fr) 330px; padding-left: 14px; padding-right: 14px; }
  .hero-panel { padding: 12px; }
  .control-panel { padding: 13px; }
  .stage { height: 470px; }
  .lab-grid { padding-left: 14px; padding-right: 14px; }
}
@media (max-width: 700px) {
  .topbar { height: 60px; padding: 0 14px; }
  .top-meta { font-size: 8px; gap: 7px; }
  .top-meta span:last-child, .top-divider { display: none; }
  .workspace { display: flex; flex-direction: column; gap: 10px; padding: 10px; }
  .hero-panel { padding: 10px; }
  .stage-heading { min-height: 46px; padding-bottom: 8px; }
  .stage-heading h1 { font-size: 19px; }
  .stage { height: 330px; min-height: 270px; }
  .control-panel { max-height: none; overflow: visible; padding: 13px; gap: 12px; }
  .lab-grid { grid-template-columns: 1fr; padding: 0 10px 12px; gap: 10px; }
  .science-panel { margin: 0 10px 12px; }
  .science-columns { grid-template-columns: 1fr; gap: 13px; }
  .page-footer { padding: 0 12px 16px; flex-direction: column; gap: 4px; }
  .embed-mode .workspace { display: grid; height: 100%; padding: 8px; gap: 8px; grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(240px, 40%) minmax(0,1fr); }
  .embed-mode .hero-panel { padding: 8px; min-height: 0; }
  .embed-mode .stage-heading { min-height: 34px; padding-bottom: 5px; }
  .embed-mode .stage-heading h1 { font-size: 16px; }
  .embed-mode .stage-heading .section-kicker { font-size: 7px; }
  .embed-mode .state-chip { padding: 5px 7px; font-size: 7px; }
  .embed-mode .stage { min-height: 0; height: auto; }
  .embed-mode .caption-row { min-height: 34px; padding-top: 7px; }
  .embed-mode .caption-row p { font-size: 10px; }
  .embed-mode .stage-corner-right, .embed-mode .stage-corner-left { display: none; }
  .embed-mode .control-panel { padding: 11px; gap: 10px; overflow-y: auto; }
}
@media (max-width: 390px) {
  .top-meta { display: none; }
  .readout strong { font-size: 17px; }
  .preset { padding: 7px; }
  .preset-name { font-size: 10px; }
  .preset-sub { font-size: 8px; }
  .transport-row { align-items: flex-start; }
  .speed-control { margin-left: auto; }
  .experiment-metrics { gap: 5px; }
  .experiment-metric strong { font-size: 15px; }
}
