:root {
  color-scheme: dark;
  --bg: #0b1117;
  --panel: #101a22;
  --panel-2: #14212a;
  --line: #293944;
  --line-soft: rgba(124, 151, 162, .18);
  --text: #e7eceb;
  --muted: #91a2a7;
  --quiet: #657980;
  --accent: #e8ad62;
  --accent-soft: rgba(232, 173, 98, .13);
  --radius: 12px;
  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; overflow-x: hidden; }
button, input { font: inherit; }
button { color: inherit; }
.masthead {
  height: 88px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line-soft); background: #0d151c;
}
.brand-lockup { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark { width: 30px; height: 30px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; transform: rotate(-8deg); flex: 0 0 auto; }
.brand-mark span { border: 1px solid #84969a; border-radius: 2px; background: linear-gradient(135deg, #536a72, #18262d); }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(3) { border-color: var(--accent); }
.eyebrow, .section-kicker, .header-meta, .tiny-stamp, .stage-footer-note, .canvas-corner, .experiment-kicker, .rail-bottom-note {
  font-size: 9px; font-weight: 750; letter-spacing: .15em; line-height: 1.3;
}
.eyebrow { color: var(--muted); margin-bottom: 5px; }
.eyebrow-dot { display: inline-block; width: 4px; height: 4px; margin: 0 6px 2px; border-radius: 50%; background: var(--accent); }
h1 { font-size: clamp(17px, 1.7vw, 21px); font-weight: 620; letter-spacing: -.035em; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-meta { color: var(--muted); display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px rgba(232,173,98,.5); }
.header-divider { width: 1px; height: 14px; background: var(--line); margin: 0 3px; }
.app-shell { width: 100%; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 376px; gap: 14px; padding: 14px; height: calc(100dvh - 88px); min-height: 580px; }
.stage-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #0d171e; }
.stage-topline { height: 42px; flex: 0 0 42px; padding: 0 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line-soft); background: #111c24; }
.stage-topline > div { display: flex; align-items: center; gap: 9px; min-width: 0; }
.section-kicker { color: #b2c0c2; }
.stage-separator { color: var(--quiet); }
.stage-subtitle { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-top-right { color: var(--muted); font-size: 9px; letter-spacing: .12em; white-space: nowrap; }
.quality-indicator { color: var(--accent); font-weight: 750; }
.model-tag { color: var(--quiet); }
.canvas-wrap { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: #0a1218; }
#scene { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.canvas-corner { position: absolute; color: #7e9298; font-size: 8px; pointer-events: none; }
.canvas-corner span { color: var(--accent); font-size: 12px; margin-left: 4px; }
.canvas-corner-tl { top: 16px; left: 17px; }
.canvas-corner-tr { top: 16px; right: 17px; }
.canvas-corner-bl { bottom: 48px; left: 17px; }
.canvas-corner-br { bottom: 48px; right: 17px; color: var(--accent); }
.canvas-caption { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); padding: 7px 12px; max-width: calc(100% - 32px); width: max-content; border: 1px solid rgba(143,166,171,.18); border-radius: 20px; background: rgba(9,17,22,.76); color: #c1cccb; font-size: 10px; line-height: 1.3; text-align: center; pointer-events: none; backdrop-filter: blur(8px); }
.stage-footer { height: 36px; flex: 0 0 36px; display: flex; align-items: center; gap: 18px; padding: 0 16px; border-top: 1px solid var(--line-soft); background: #111c24; }
.legend-item { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.legend-swatch { display: inline-block; width: 14px; height: 4px; border-radius: 4px; }
.warp-swatch { background: #c7c0b0; }
.weft-swatch { background: #78929a; }
.contact-swatch { background: var(--accent); }
.stage-footer-note { color: var(--quiet); margin-left: auto; font-size: 8px; white-space: nowrap; }
.instrument-rail { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 14px; background: #101920; scrollbar-width: thin; scrollbar-color: #344852 transparent; }
.rail-section { padding: 14px 14px 13px; border-bottom: 1px solid var(--line-soft); }
.rail-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 11px; }
.tiny-stamp { color: var(--quiet); font-size: 8px; letter-spacing: .1em; white-space: nowrap; }
.readout-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.readout-card { min-width: 0; padding: 10px 10px 9px; border: 1px solid var(--line-soft); border-radius: 8px; background: linear-gradient(145deg, rgba(24,38,47,.9), rgba(16,27,34,.85)); }
.readout-label { font-size: 8px; color: var(--muted); letter-spacing: .1em; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout-value { margin-top: 5px; font-size: 23px; font-weight: 620; letter-spacing: -.05em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.readout-value span { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.readout-foot { margin-top: 2px; color: var(--quiet); font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.state-strip { display: flex; align-items: center; gap: 7px; margin-top: 8px; min-height: 28px; padding: 0 9px; border-radius: 6px; background: rgba(232,173,98,.08); color: var(--accent); font-size: 8px; font-weight: 750; letter-spacing: .1em; }
.state-indicator { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px rgba(232,173,98,.45); flex: 0 0 auto; }
.state-detail { margin-left: auto; color: #9eaaa8; font-size: 8px; font-weight: 500; letter-spacing: 0; white-space: nowrap; }
.preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.preset-button { min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #121f27; text-align: left; cursor: pointer; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.preset-button:hover { border-color: #647a80; background: #172731; }
.preset-button.active { border-color: rgba(232,173,98,.75); background: var(--accent-soft); }
.preset-button:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.preset-button b { display: block; font-size: 10px; font-weight: 650; }
.preset-button small { display: block; margin-top: 2px; font-size: 8px; color: var(--muted); white-space: nowrap; }
.preset-icon { width: 24px; height: 24px; flex: 0 0 auto; border: 1px solid #536b72; border-radius: 5px; background-color: #1b2a32; background-image: repeating-linear-gradient(0deg, transparent 0 4px, #8ba0a3 4px 5px), repeating-linear-gradient(90deg, transparent 0 4px, #718b91 4px 5px); opacity: .9; }
.open-icon { background-size: 8px 8px; }
.balanced-icon { background-size: 5px 5px; }
.dense-icon { background-size: 3px 3px; }
.failure-icon { background-size: 4px 4px; background-image: repeating-linear-gradient(0deg, transparent 0 4px, #8ba0a3 4px 5px), linear-gradient(135deg, transparent 43%, var(--accent) 44% 48%, transparent 49%); }
.controls-section { padding-bottom: 12px; }
.control-list { display: grid; gap: 11px; }
.control-row { display: block; min-width: 0; cursor: pointer; }
.control-copy { display: flex; align-items: center; gap: 5px; min-width: 0; margin-bottom: 5px; }
.control-name { color: #c7d0d0; font-size: 10px; font-weight: 550; }
.control-tip { color: #72858b; font-size: 10px; cursor: help; }
.control-value { margin-left: auto; color: var(--accent); font-size: 10px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
input[type="range"] { display: block; width: 100%; height: 14px; margin: 0; appearance: none; background: transparent; cursor: ew-resize; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) var(--pct, 0%), #52666d var(--pct, 0%)); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 4px; background: #52666d; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border: 2px solid #f4d4a6; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(232,173,98,.13); }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border: 2px solid #f4d4a6; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(232,173,98,.13); }
.range-ends { display: flex; justify-content: space-between; margin-top: 1px; color: #62767d; font-size: 8px; font-variant-numeric: tabular-nums; }
.motion-section { padding-bottom: 12px; }
.transport-controls { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr; gap: 6px; }
.transport-button { min-width: 0; height: 33px; display: flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); border-radius: 7px; background: #15232b; color: #c6d0d0; font-size: 9px; cursor: pointer; transition: background .18s ease, border-color .18s ease; }
.transport-button:hover { background: #1b2c35; border-color: #5b7077; }
.transport-button.primary { border-color: rgba(232,173,98,.65); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.transport-button .play-symbol { font-size: 9px; }
.transport-button span:first-child:not(.play-symbol) { font-size: 13px; }
.experiment-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; padding: 10px; border: 1px solid var(--line-soft); border-radius: 8px; background: #121f27; }
.experiment-row strong { display: block; margin-top: 3px; font-size: 10px; font-weight: 650; }
.experiment-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.experiment-kicker { color: var(--accent); font-size: 8px; }
.experiment-button { flex: 0 0 auto; padding: 8px 10px; border: 1px solid rgba(232,173,98,.55); border-radius: 6px; background: rgba(232,173,98,.1); color: var(--accent); font-size: 9px; font-weight: 700; cursor: pointer; }
.experiment-button:hover { background: rgba(232,173,98,.18); }
.experiment-button span { margin-left: 5px; }
.experiment-result { margin-top: 8px; padding: 9px; border-left: 2px solid var(--accent); background: rgba(232,173,98,.07); color: #d4ddda; font-size: 9px; line-height: 1.5; }
.checks-section { padding-top: 12px; padding-bottom: 12px; }
.check-list { display: grid; gap: 8px; }
.check-row { display: flex; align-items: center; gap: 7px; min-width: 0; }
.check-mark { color: var(--accent); font-size: 11px; }
.check-name { min-width: 0; color: #aab8b9; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.check-row strong { margin-left: auto; color: #d9e0dd; font-size: 9px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.science-panel { border-bottom: 1px solid var(--line-soft); }
.science-panel summary { display: flex; align-items: center; gap: 8px; padding: 14px; cursor: pointer; list-style: none; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-summary { color: var(--muted); font-size: 9px; }
.details-chevron { margin-left: auto; color: var(--accent); font-size: 16px; transition: transform .2s ease; }
.science-panel[open] .details-chevron { transform: rotate(45deg); }
.science-content { padding: 0 14px 15px; color: #b5c1c0; font-size: 10px; line-height: 1.55; }
.science-content h2 { margin: 12px 0 5px; color: #e1e7e4; font-size: 11px; font-weight: 650; }
.science-content p { margin: 5px 0 8px; }
.science-content ul { margin: 6px 0 10px; padding-left: 17px; }
.science-content li { margin: 4px 0; }
.equation { margin: 8px 0; padding: 9px; border: 1px solid var(--line-soft); border-radius: 6px; background: #0d171e; color: #f1c58f; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; overflow-wrap: anywhere; }
.science-note { padding: 8px; border-left: 2px solid var(--accent); background: rgba(232,173,98,.07); color: #c3ceca; }
.rail-bottom-note { padding: 12px 14px; color: #62747a; text-align: center; font-size: 8px; }
.rail-bottom-note span { color: var(--accent); margin: 0 5px; }
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
body.embed-mode .masthead { display: none; }
body.embed-mode .workspace { height: 100vh; height: 100dvh; min-height: 0; padding: 8px; gap: 8px; }
body.embed-mode .stage-panel, body.embed-mode .instrument-rail { border-radius: 10px; }
@media (max-width: 1050px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 340px; gap: 10px; padding: 10px; }
  .stage-footer { gap: 11px; }
  .stage-footer-note { display: none; }
}
@media (max-width: 760px) {
  .masthead { height: 72px; padding: 0 15px; }
  .brand-mark { width: 25px; height: 25px; }
  .header-meta { display: none; }
  h1 { font-size: 16px; }
  .eyebrow { font-size: 8px; }
  .workspace { display: flex; flex-direction: column; height: auto; min-height: 0; padding: 8px; gap: 8px; }
  .stage-panel { height: 58vh; min-height: 320px; max-height: 560px; flex: 0 0 auto; }
  .stage-topline { padding: 0 10px; height: 36px; flex-basis: 36px; }
  .stage-topline > div { gap: 6px; }
  .stage-subtitle { font-size: 9px; }
  .stage-top-right { font-size: 8px; }
  .canvas-corner { font-size: 7px; }
  .canvas-caption { bottom: 9px; font-size: 9px; }
  .canvas-corner-bl, .canvas-corner-br { bottom: 39px; }
  .stage-footer { height: 31px; flex-basis: 31px; padding: 0 9px; gap: 12px; }
  .legend-item { font-size: 8px; }
  .legend-swatch { width: 11px; }
  .instrument-rail { overflow: visible; }
  .rail-section { padding: 13px; }
  .readout-value { font-size: 21px; }
  body.embed-mode .workspace { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(260px, 40dvh) minmax(0,1fr); height: 100dvh; overflow: hidden; }
  body.embed-mode .stage-panel { height: auto; min-height: 0; max-height: none; }
  body.embed-mode .instrument-rail { overflow-y: auto; min-height: 0; }
}
@media (max-width: 420px) {
  .masthead { padding: 0 12px; }
  .brand-lockup { gap: 10px; }
  h1 { font-size: 14px; }
  .stage-topline { padding: 0 8px; }
  .section-kicker { font-size: 8px; }
  .stage-subtitle { max-width: 145px; }
  .stage-top-right .model-tag { display: none; }
  .stage-footer { gap: 8px; }
  .legend-item { gap: 4px; font-size: 7px; }
  .legend-swatch { width: 9px; }
  .readout-card { padding: 8px; }
  .readout-label { font-size: 7px; }
  .readout-value { font-size: 19px; }
  .readout-foot { font-size: 7px; }
  .control-name { font-size: 9px; }
  .control-value { font-size: 9px; }
  .range-ends { font-size: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

.check-fail { color: var(--accent) !important; }
.state-strip.failed { background: rgba(232,173,98,.16); }
