:root {
  color-scheme: dark;
  --bg: #0b1117;
  --panel: #101820;
  --panel-2: #121d26;
  --panel-3: #17232d;
  --line: #263541;
  --line-soft: rgba(145, 166, 181, .13);
  --text: #e7eef2;
  --muted: #9aabb7;
  --quiet: #687b89;
  --accent: #5ed7d0;
  --accent-dim: rgba(94, 215, 208, .14);
  --accent-glow: rgba(94, 215, 208, .24);
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-rows: 64px minmax(0, 1fr); }
.topbar { height: 64px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: #0d141b; }
.brand-lockup { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark { width: 29px; height: 29px; border: 1px solid rgba(94,215,208,.5); border-radius: 9px; position: relative; display: flex; align-items: center; justify-content: center; gap: 3px; transform: rotate(-8deg); }
.brand-mark span { display: block; width: 3px; border-radius: 3px; background: var(--accent); }
.brand-mark span:nth-child(1) { height: 10px; opacity: .55; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 12px; opacity: .75; }
.eyebrow, .section-kicker, .readout-label, .quality-row, .panel-footer, .model-tag, .micro-kind { letter-spacing: .105em; font-size: 9px; font-weight: 750; color: var(--quiet); }
.eyebrow { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.eyebrow-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--accent); }
h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.025em; line-height: 1.1; }
.period-chip { display: flex; align-items: center; gap: 9px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; color: #aab9c3; font-size: 9px; font-weight: 750; letter-spacing: .1em; white-space: nowrap; }
.period-dot, .live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }
.period-sep { color: #536573; }
.period-kind { color: var(--quiet); font-size: 8px; }
.workspace { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 366px; gap: 16px; padding: 16px; }
.stage-panel, .control-panel { min-width: 0; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stage-panel { display: grid; grid-template-rows: auto minmax(280px, 1fr) auto; }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; padding: 12px 18px; border-bottom: 1px solid var(--line-soft); }
.section-kicker { color: var(--accent); margin-bottom: 5px; }
.stage-subtitle { color: var(--muted); font-size: 11px; }
.view-switch { display: flex; align-items: center; gap: 3px; padding: 3px; background: #0b1218; border: 1px solid var(--line); border-radius: 9px; }
.view-button { border: 0; background: transparent; color: #8294a1; padding: 8px 11px; border-radius: 6px; font-size: 10px; font-weight: 650; cursor: pointer; transition: color .18s ease, background .18s ease; }
.view-button:hover { color: var(--text); }
.view-button.active { color: #dff9f7; background: var(--accent-dim); box-shadow: inset 0 0 0 1px rgba(94,215,208,.22); }
.canvas-frame { position: relative; min-height: 0; overflow: hidden; background: #0c141b; }
#machineCanvas { width: 100%; height: 100%; display: block; touch-action: pan-y; }
.canvas-corner { position: absolute; top: 13px; display: flex; align-items: center; gap: 7px; pointer-events: none; color: #738795; font-size: 8px; font-weight: 750; letter-spacing: .12em; }
.canvas-corner-left { left: 16px; }
.canvas-corner-right { right: 16px; }
.stage-caption { display: flex; align-items: flex-start; gap: 10px; min-height: 58px; padding: 13px 18px 14px; border-top: 1px solid var(--line-soft); background: rgba(13,20,27,.75); }
.caption-symbol { width: 21px; height: 21px; display: grid; place-items: center; flex: 0 0 21px; border: 1px solid rgba(94,215,208,.25); color: var(--accent); border-radius: 6px; font-size: 12px; }
.stage-caption p { margin: 1px 0 0; color: #a9bac5; font-size: 11px; line-height: 1.5; }
.control-panel { overflow: auto; scrollbar-width: thin; scrollbar-color: #334754 transparent; display: flex; flex-direction: column; }
.control-panel::-webkit-scrollbar { width: 6px; }
.control-panel::-webkit-scrollbar-thumb { background: #334754; border-radius: 10px; }
.readout-section, .adjust-section, .transport-section { padding: 15px 16px; border-bottom: 1px solid var(--line-soft); }
.panel-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
h2 { margin: 0; color: #dce6eb; font-size: 12px; font-weight: 700; letter-spacing: -.01em; }
.model-tag { color: #7c909e; font-size: 8px; white-space: nowrap; }
.readout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.readout-card { min-width: 0; min-height: 82px; padding: 10px 10px 9px; border: 1px solid #253541; border-radius: 8px; background: #0d151c; }
.primary-readout { border-color: rgba(94,215,208,.26); background: linear-gradient(145deg, rgba(94,215,208,.075), rgba(13,21,28,.9) 72%); }
.readout-label { display: flex; flex-wrap: wrap; gap: 4px 6px; color: #8093a0; font-size: 8px; letter-spacing: .075em; line-height: 1.25; }
.readout-label span, .slider-label-row label span, .micro-kind { color: #5c7b83; font-size: 7px; letter-spacing: .08em; }
.readout-value { margin-top: 7px; color: #e9f2f5; font-size: 24px; font-weight: 650; letter-spacing: -.045em; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.primary-readout .readout-value { color: var(--accent); }
.readout-value small { margin-left: 4px; color: #7d929f; font-size: 9px; font-weight: 600; letter-spacing: 0; }
.readout-foot { margin-top: 6px; color: #6e828f; font-size: 8px; }
.meter-track { height: 3px; margin-top: 10px; border-radius: 5px; background: #263640; overflow: hidden; }
.meter-track span { display: block; width: 76%; height: 100%; border-radius: inherit; background: var(--accent); transition: width .25s ease; }
.check-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 9px; padding: 9px 10px; border: 1px solid var(--line-soft); border-radius: 8px; background: rgba(255,255,255,.015); }
.check-title { color: #b9c8d0; font-size: 9px; font-weight: 650; }
.check-kind { margin-left: 5px; color: #78939a; font-size: 7px; letter-spacing: .08em; }
.check-detail { margin-top: 5px; color: #8396a2; font-size: 9px; font-variant-numeric: tabular-nums; }
.check-vs { color: #536a77; padding: 0 3px; }
.check-difference { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.check-difference strong { color: var(--accent); font-size: 14px; font-variant-numeric: tabular-nums; }
.check-difference span { color: #6e838f; font-size: 8px; }
.drift-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 2px 0; color: #7f929e; font-size: 8px; font-weight: 750; letter-spacing: .09em; }
.drift-row strong { color: #c8d5db; font-size: 11px; font-weight: 650; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.drift-row strong small { color: #7e929e; font-size: 8px; font-weight: 500; }
.adjust-section { padding-top: 14px; }
.adjust-heading-row { margin-bottom: 10px; }
.preset-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin-bottom: 14px; }
.preset-button { min-height: 31px; padding: 5px 4px; border: 1px solid var(--line); border-radius: 7px; background: #0d151c; color: #81939f; font-size: 8px; font-weight: 650; line-height: 1.2; cursor: pointer; transition: border-color .18s ease, color .18s ease, background .18s ease; }
.preset-button:hover { color: #dce9ed; border-color: #4c6672; }
.preset-button.selected { color: #dff9f7; border-color: rgba(94,215,208,.35); background: var(--accent-dim); }
.slider-list { display: grid; gap: 13px; }
.slider-control { min-width: 0; }
.slider-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.slider-label-row label { color: #b5c3cb; font-size: 9px; font-weight: 600; }
.slider-label-row label span { margin-left: 3px; }
.slider-label-row output { color: #d8e5e9; font-size: 9px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
input[type="range"] { display: block; width: 100%; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; background: transparent; }
input[type="range"]:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 5px; background: #344652; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border: 2px solid #dff9f7; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(94,215,208,.12); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 5px; background: #344652; }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border: 2px solid #dff9f7; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(94,215,208,.12); }
.slider-range { display: flex; justify-content: space-between; margin-top: 2px; color: #617581; font-size: 7px; font-variant-numeric: tabular-nums; }
.compact-slider { margin-top: -1px; }
.transport-section { padding-top: 12px; padding-bottom: 12px; }
.transport-buttons { display: grid; grid-template-columns: 1.4fr .8fr .8fr 38px; gap: 6px; }
.transport-buttons button { min-height: 34px; border-radius: 7px; font-size: 9px; font-weight: 700; cursor: pointer; transition: background .18s ease, border-color .18s ease, opacity .18s ease; }
.transport-primary { display: flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid rgba(94,215,208,.42); background: var(--accent); color: #06211f; }
.transport-primary:hover { background: #79e5df; }
.play-icon { font-size: 12px; line-height: 1; }
.transport-secondary, .transport-icon { border: 1px solid var(--line); background: #111b23; color: #b5c4cc; }
.transport-secondary:hover, .transport-icon:hover { border-color: #506a76; color: #f0f7f8; }
.transport-secondary:disabled { opacity: .35; cursor: not-allowed; }
.transport-icon { font-size: 15px !important; }
.quality-row { display: flex; align-items: center; gap: 8px; margin-top: 11px; font-size: 8px; }
.quality-switch { display: flex; gap: 2px; padding: 2px; background: #0b1218; border: 1px solid var(--line); border-radius: 6px; }
.quality-switch button { border: 0; border-radius: 4px; padding: 4px 7px; background: transparent; color: #708490; font-size: 8px; cursor: pointer; }
.quality-switch button.active { background: #20323a; color: #dff9f7; }
.elapsed-label { margin-left: auto; color: #637783; white-space: nowrap; }
.elapsed-label strong { margin-left: 4px; color: #aab9c2; font-size: 9px; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.science-panel { margin: 12px 14px 8px; border: 1px solid var(--line); border-radius: 8px; background: #0d151c; }
.science-panel summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px; color: #c7d5dc; font-size: 10px; font-weight: 700; cursor: pointer; list-style: none; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-panel summary::after { content: "+"; color: var(--accent); font-size: 16px; font-weight: 400; }
.science-panel[open] summary::after { content: "−"; }
.summary-note { margin-left: auto; color: #667d89; font-size: 7px; letter-spacing: .1em; }
.science-content { padding: 0 12px 12px; color: #8da0ab; font-size: 9px; line-height: 1.55; }
.history-note { margin: 0 0 12px; color: #aebdc5; }
.science-content h3 { display: flex; align-items: center; justify-content: space-between; margin: 0 0 7px; color: #b9c8d0; font-size: 9px; }
.science-content h3 span { color: #6e8792; font-size: 7px; letter-spacing: .08em; }
.equation { padding: 7px 8px; margin: 5px 0; border-left: 2px solid rgba(94,215,208,.55); background: rgba(94,215,208,.045); color: #d6e6e9; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 9px; }
.equation small { color: #77919b; font-family: inherit; font-size: 8px; }
.model-note { margin: 10px 0 0; color: #8396a1; }
.required-disclaimer { margin: 11px 0 0; padding-top: 9px; border-top: 1px solid var(--line-soft); color: #a9bbc3; font-style: italic; }
.panel-footer { display: flex; justify-content: space-between; gap: 8px; margin: auto 14px 12px; padding-top: 7px; color: #5d707c; font-size: 7px; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 330px; gap: 10px; padding: 10px; }
  .stage-head { padding: 10px 12px; }
  .view-button { padding: 8px 8px; }
}
@media (max-width: 700px) {
  .app-shell { min-height: 100vh; grid-template-rows: 56px minmax(0, 1fr); }
  .topbar { height: 56px; padding: 0 12px; }
  .brand-mark { width: 25px; height: 25px; }
  .eyebrow { font-size: 8px; }
  h1 { font-size: 14px; }
  .period-chip { gap: 6px; padding: 7px 8px; font-size: 8px; }
  .period-kind { display: none; }
  .workspace { display: flex; flex-direction: column; gap: 8px; padding: 8px; overflow: hidden; }
  .stage-panel { flex: 0 0 43%; min-height: 235px; grid-template-rows: auto minmax(0,1fr) auto; }
  .stage-head { min-height: 55px; padding: 8px 9px; align-items: center; }
  .stage-subtitle { font-size: 9px; }
  .section-kicker { font-size: 8px; }
  .view-switch { gap: 1px; }
  .view-button { padding: 7px 6px; font-size: 8px; }
  .canvas-frame { min-height: 0; }
  .stage-caption { min-height: 48px; padding: 8px 10px; gap: 7px; }
  .caption-symbol { width: 19px; height: 19px; flex-basis: 19px; }
  .stage-caption p { font-size: 9px; line-height: 1.4; }
  .canvas-corner { top: 8px; font-size: 7px; }
  .canvas-corner-left { left: 9px; }
  .canvas-corner-right { right: 9px; }
  .control-panel { flex: 1 1 auto; min-height: 0; overflow: auto; }
  .readout-section, .adjust-section, .transport-section { padding-left: 11px; padding-right: 11px; }
  .readout-card { min-height: 75px; padding: 8px; }
  .readout-value { font-size: 21px; }
  .readout-label { font-size: 7px; }
  .preset-button { font-size: 8px; }
  .science-panel { margin-left: 9px; margin-right: 9px; }
  .panel-footer { margin-left: 10px; margin-right: 10px; }
}
@media (max-width: 380px) {
  .period-chip { font-size: 7px; padding: 6px; }
  .stage-title-group { max-width: 45%; }
  .stage-subtitle { max-width: 155px; }
  .view-button { padding: 7px 5px; font-size: 7px; }
  .readout-value { font-size: 19px; }
}
@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; }
body.embed-mode .workspace { min-height: 0; }
@media (max-width: 700px) {
  body.embed-mode .workspace { height: 100%; }
  body.embed-mode .stage-panel { flex-basis: 43%; }
}

body.embed-mode .app-shell{grid-template-rows:minmax(0,1fr)!important}
