:root {
  color-scheme: dark;
  --bg: #0b1118;
  --panel: #121b25;
  --panel-raised: #172330;
  --panel-soft: #101821;
  --line: #293745;
  --line-soft: #202c38;
  --text: #e7e5df;
  --muted: #8e9aa5;
  --dim: #667482;
  --accent: #d9a45b;
  --accent-bright: #efc17c;
  --accent-dark: #8c673a;
  --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; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 3px; }
#app { min-height: 100vh; display: flex; flex-direction: column; padding: 0 24px; }
.topbar { min-height: 90px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line-soft); flex: 0 0 auto; }
.identity { display: flex; align-items: center; gap: 14px; min-width: 0; }
.seal { width: 42px; height: 42px; color: var(--accent); flex: 0 0 auto; }
.seal svg { width: 100%; height: 100%; }
.eyebrow { color: var(--accent); font-size: 9px; font-weight: 750; letter-spacing: .17em; margin: 0 0 5px; }
.eyebrow span { color: var(--dim); padding: 0 4px; }
h1 { font-size: 23px; line-height: 1.1; margin: 0; letter-spacing: -.035em; font-weight: 650; }
.subtitle { color: var(--muted); font-size: 12px; margin: 4px 0 0; letter-spacing: .01em; }
.top-meta { text-align: right; display: flex; flex-direction: column; gap: 5px; flex: 0 0 auto; }
.era { color: var(--accent-bright); font-size: 9px; letter-spacing: .12em; font-weight: 700; }
.meta-note { color: var(--dim); font-size: 10px; }
.workspace { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; padding: 18px 0 14px; }
.stage-column { min-width: 0; min-height: 0; display: grid; grid-template-rows: 42px minmax(250px, 1fr) auto; gap: 10px; }
.stage-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.view-switch { display: inline-flex; align-items: center; gap: 3px; background: #111a23; border: 1px solid var(--line-soft); border-radius: 9px; padding: 3px; }
.view-tab { border: 0; background: transparent; color: var(--muted); font-size: 11px; padding: 7px 13px; border-radius: 6px; cursor: pointer; transition: color .18s ease, background .18s ease; }
.view-tab:hover { color: var(--text); }
.view-tab.active { color: #1b1711; background: var(--accent); font-weight: 750; }
.stage-actions { display: flex; align-items: center; gap: 8px; }
.run-state { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; letter-spacing: .12em; font-weight: 700; margin-right: 4px; white-space: nowrap; }
.run-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px #d9a45b66; }
.run-state.paused i { background: #697582; box-shadow: none; }
.quiet-button { border: 1px solid var(--line); background: #111a23; color: #aeb9c2; border-radius: 7px; padding: 7px 10px; font-size: 9px; letter-spacing: .09em; font-weight: 750; cursor: pointer; transition: border-color .18s ease, color .18s ease, background .18s ease; }
.quiet-button:hover { color: var(--accent-bright); border-color: var(--accent-dark); }
.screenshot-button { display: inline-flex; align-items: center; gap: 7px; letter-spacing: .02em; font-size: 10px; font-weight: 600; }
.screenshot-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.stage-wrap { position: relative; min-height: 0; overflow: hidden; border: 1px solid #2b3947; border-radius: var(--radius); background: #0d151e; box-shadow: 0 14px 40px #00000024; }
#machineCanvas { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.canvas-overlay-top { position: absolute; top: 13px; left: 15px; right: 15px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.plate-label { color: var(--accent-bright); font-size: 8px; letter-spacing: .16em; font-weight: 750; }
.subtle-plate { color: #71808e; }
.canvas-caption { position: absolute; left: 15px; top: 48px; bottom: auto; width: min(320px, 56%); padding: 10px 13px 11px; background: #101a24e8; border: 1px solid #344250; border-left: 2px solid var(--accent); border-radius: 0 8px 8px 0; backdrop-filter: blur(8px); pointer-events: none; }
.caption-kicker { color: var(--accent); font-size: 8px; letter-spacing: .16em; font-weight: 800; }
.canvas-caption p { color: #c4cbd0; font-size: 10px; line-height: 1.45; margin: 4px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stage-bottomline { position: absolute; bottom: 0; left: 0; right: 0; height: 25px; display: flex; justify-content: space-between; align-items: center; padding: 0 14px; border-top: 1px solid #25313c; background: #0d151ee8; color: #758391; font-size: 8px; font-weight: 700; letter-spacing: .12em; pointer-events: none; }
#mileCounter { color: var(--accent-bright); }
.readouts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.readout { min-width: 0; padding: 10px 11px 9px; background: #111a23; border: 1px solid var(--line-soft); border-radius: 9px; display: flex; flex-direction: column; gap: 4px; }
.readout-label { color: #84919d; font-size: 8px; font-weight: 750; letter-spacing: .11em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout strong { color: var(--text); font-size: clamp(14px, 1.45vw, 19px); line-height: 1.15; font-weight: 620; font-variant-numeric: tabular-nums; letter-spacing: -.025em; white-space: nowrap; }
.readout small { color: #687784; font-size: 8px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.error-readout strong { color: var(--accent-bright); }
.control-column { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 2px; scrollbar-width: thin; scrollbar-color: #334250 transparent; }
.control-card, .science-card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.control-card { padding: 14px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-heading .eyebrow { font-size: 8px; margin-bottom: 4px; }
h2 { font-size: 15px; margin: 0; font-weight: 650; letter-spacing: -.02em; }
.fixed-badge { color: var(--accent); border: 1px solid #6d5434; background: #3a2c1c55; border-radius: 5px; padding: 4px 6px; font-size: 7px; letter-spacing: .12em; font-weight: 800; white-space: nowrap; }
.transport-controls { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 7px; }
.transport-controls button { min-height: 34px; border-radius: 7px; font-size: 10px; font-weight: 700; cursor: pointer; display: inline-flex; justify-content: center; align-items: center; gap: 7px; }
.primary-button { color: #1b1711; background: var(--accent); border: 1px solid var(--accent); }
.primary-button:hover { background: var(--accent-bright); }
.primary-button svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.secondary-button { color: #bdc6cd; background: #18232e; border: 1px solid #33414e; }
.secondary-button:hover { border-color: var(--accent-dark); color: var(--accent-bright); }
.preset-heading { display: flex; justify-content: space-between; margin: 14px 0 7px; color: #788693; font-size: 7px; font-weight: 800; letter-spacing: .13em; }
.preset-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.preset-button { display: flex; align-items: flex-start; gap: 8px; text-align: left; border: 1px solid #2a3743; border-radius: 7px; background: #111a23; padding: 8px; cursor: pointer; min-width: 0; }
.preset-button:hover, .preset-button.active { border-color: #8b683e; background: #241f19; }
.preset-dot { flex: 0 0 auto; width: 7px; height: 7px; border: 1px solid var(--accent-dark); border-radius: 50%; margin-top: 4px; }
.preset-button.active .preset-dot { background: var(--accent); box-shadow: 0 0 8px #d9a45b66; }
.preset-button b { display: block; color: #dce0e2; font-size: 9px; font-weight: 700; }
.preset-button small { display: block; color: #7f8c98; font-size: 8px; line-height: 1.35; margin-top: 3px; }
.compact-heading { align-items: center; margin-bottom: 14px; }
.reset-note { color: #778592; font-size: 8px; text-align: right; max-width: 110px; line-height: 1.3; }
.slider-group { margin: 0 0 14px; }
.slider-group:last-child { margin-bottom: 0; }
.slider-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 7px; }
.slider-heading label { color: #d6dce0; font-size: 10px; font-weight: 600; }
.slider-heading output { color: var(--accent-bright); font-size: 9px; font-variant-numeric: tabular-nums; white-space: nowrap; }
input[type="range"] { display: block; width: 100%; height: 15px; margin: 0; appearance: none; background: transparent; cursor: pointer; accent-color: var(--accent); }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: #34414d; border-radius: 3px; }
input[type="range"]::-moz-range-track { height: 3px; background: #34414d; border-radius: 3px; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; border-radius: 50%; margin-top: -4.5px; background: var(--accent); border: 2px solid #f0c989; box-shadow: 0 0 0 3px #d9a45b22; }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid #f0c989; box-shadow: 0 0 0 3px #d9a45b22; }
.range-ends { display: flex; justify-content: space-between; color: #63717d; font-size: 8px; margin-top: 1px; }
.control-hint { color: #7b8995; font-size: 8px; line-height: 1.4; margin: 6px 0 0; }
.speed-time-group { padding-top: 11px; border-top: 1px solid #27333e; }
.science-card { overflow: hidden; }
.science-card summary { list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 13px 14px; cursor: pointer; }
.science-card summary::-webkit-details-marker { display: none; }
.science-card summary span:first-child { display: flex; flex-direction: column; gap: 3px; }
.science-card summary small { color: var(--accent); font-size: 7px; font-weight: 800; letter-spacing: .15em; }
.science-card summary b { color: #e3e6e7; font-size: 12px; font-weight: 650; }
.chevron { color: var(--accent); font-size: 17px; transition: transform .2s ease; }
.science-card[open] .chevron { transform: rotate(180deg); }
.science-content { padding: 0 14px 14px; border-top: 1px solid #27333e; }
.science-content h3 { color: #dce1e3; font-size: 10px; margin: 13px 0 6px; }
.science-content p, .science-content li { color: #9aa6af; font-size: 9px; line-height: 1.5; }
.science-content p { margin: 6px 0; }
.science-content b { color: #d8dfe2; font-weight: 650; }
.equation { color: var(--accent-bright); background: #0e1720; border: 1px solid #273541; border-radius: 6px; padding: 8px 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; text-align: center; margin: 8px 0; }
.audit-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid #26323d; color: #8f9ba5; font-size: 8px; }
.audit-row b { color: #dce2e5; font-variant-numeric: tabular-nums; font-weight: 650; }
.audit-result b { color: var(--accent-bright); }
.audit-note { color: #788793 !important; font-size: 8px !important; }
.science-content ul { padding-left: 15px; margin: 7px 0 10px; }
.science-content li { margin: 4px 0; }
.disclaimer { border-left: 2px solid var(--accent-dark); padding-left: 8px; color: #b0a18a !important; }
.footerline { min-height: 28px; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line-soft); color: #64717d; font-size: 8px; letter-spacing: .12em; font-weight: 700; }

body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
body.embed-mode #app { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
body.embed-mode .workspace { min-height: 0; }

@media (max-width: 1000px) {
  #app { padding: 0 16px; }
  .workspace { grid-template-columns: minmax(0, 1fr) 330px; gap: 12px; }
  .readouts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .readout:nth-child(4), .readout:nth-child(5) { display: none; }
}
@media (max-width: 760px) {
  #app { padding: 0 10px; }
  .topbar { min-height: 72px; gap: 8px; }
  .seal { width: 34px; height: 34px; }
  h1 { font-size: 18px; }
  .subtitle { font-size: 10px; }
  .eyebrow { font-size: 7px; }
  .top-meta { max-width: 115px; }
  .era { font-size: 7px; line-height: 1.4; }
  .meta-note { font-size: 8px; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(390px, 52dvh) minmax(0, 1fr); gap: 10px; padding: 10px 0 8px; }
  .stage-column { grid-template-rows: 36px minmax(0, 1fr) auto; gap: 7px; }
  .view-tab { font-size: 9px; padding: 6px 9px; }
  .stage-actions { gap: 5px; }
  .run-state { font-size: 7px; margin-right: 0; }
  .quiet-button { padding: 6px 7px; font-size: 8px; }
  .screenshot-button { font-size: 0; gap: 0; padding: 6px 8px; }
  .screenshot-button svg { width: 16px; height: 16px; }
  .canvas-overlay-top { top: 9px; left: 10px; right: 10px; }
  .plate-label { font-size: 7px; }
  .canvas-caption { left: 9px; top: 32px; bottom: auto; width: min(310px, 78%); padding: 7px 9px; }
  .canvas-caption p { font-size: 8px; }
  .stage-bottomline { height: 22px; padding: 0 9px; font-size: 7px; }
  .readouts { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .readout { padding: 7px 7px 6px; gap: 3px; }
  .readout:nth-child(4) { display: flex; }
  .readout:nth-child(5) { display: none; }
  .readout-label { font-size: 6px; letter-spacing: .07em; }
  .readout strong { font-size: 13px; }
  .readout small { font-size: 6px; }
  .control-column { min-height: 0; padding-right: 0; overscroll-behavior: contain; }
  .control-card { padding: 12px; }
  .footerline { display: none; }
  body.embed-mode .workspace { grid-template-rows: minmax(390px, 52dvh) minmax(0, 1fr); }
}
@media (max-width: 400px) {
  .top-meta { display: none; }
  .workspace { grid-template-rows: minmax(370px, 50dvh) minmax(0, 1fr); }
  body.embed-mode .workspace { grid-template-rows: minmax(370px, 50dvh) minmax(0, 1fr); }
  .readouts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .readout:nth-child(3) { display: none; }
  .readout:nth-child(4) { display: flex; }
  .view-tab { padding: 6px 8px; }
  .stage-actions { gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
