:root {
  color-scheme: dark;
  --bg: #0b1118;
  --panel: #111a24;
  --panel-2: #15212d;
  --line: rgba(172, 194, 211, .13);
  --line-strong: rgba(172, 194, 211, .22);
  --text: #edf2f5;
  --muted: #9aaab7;
  --dim: #667988;
  --accent: #d8ad69;
  --accent-bright: #f0c47b;
  --blue: #72b8c5;
  --red: #d58c72;
  --green: #82c6a7;
  --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; width: 100%; height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
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-shell { height: 100vh; height: 100dvh; min-height: 0; display: grid; grid-template-rows: 76px minmax(0, 1fr) auto auto 26px; gap: 10px; padding: 12px 14px 8px; max-width: 1920px; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 14px; min-width: 0; padding: 0 6px; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid rgba(216,173,105,.34); border-radius: 13px; color: var(--accent); background: linear-gradient(145deg, rgba(216,173,105,.10), rgba(216,173,105,.02)); flex: 0 0 auto; }
.brand-mark svg { width: 33px; height: 33px; }
.brand-copy { min-width: 0; }
.eyebrow { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .17em; line-height: 1.2; }
.eyebrow span { color: var(--dim); padding: 0 4px; }
h1 { font-size: clamp(18px, 2.0vw, 25px); letter-spacing: -.035em; line-height: 1.05; margin: 4px 0 3px; font-weight: 690; }
.brand-copy p { margin: 0; font-size: 11px; color: var(--muted); letter-spacing: .01em; }
.top-status { margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .13em; white-space: nowrap; }
.status-dot, .live-pulse { width: 7px; height: 7px; background: var(--green); border-radius: 50%; box-shadow: 0 0 12px rgba(130,198,167,.45); }
.top-status.paused .status-dot { background: var(--accent); box-shadow: 0 0 12px rgba(216,173,105,.3); }
.top-status.stalled .status-dot { background: var(--red); box-shadow: 0 0 12px rgba(213,140,114,.35); }
.main-grid { display: grid; grid-template-columns: minmax(0, 1fr) 354px; gap: 10px; min-height: 0; }
.stage-card, .control-card { min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(155deg, rgba(20,31,43,.98), rgba(13,21,30,.98)); box-shadow: 0 14px 42px rgba(0,0,0,.14); overflow: hidden; }
.stage-card { display: grid; grid-template-rows: 52px minmax(0,1fr) auto 30px; }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.stage-kicker { display: flex; align-items: center; gap: 8px; color: #b5c2cc; font-size: 9px; letter-spacing: .14em; font-weight: 800; white-space: nowrap; }
.live-pulse { width: 6px; height: 6px; }
.model-tag, .mini-tag, .data-label { color: var(--dim); font-size: 8px; font-weight: 800; letter-spacing: .11em; }
.model-tag { padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; }
.stage-actions { display: flex; align-items: center; gap: 8px; }
.view-switch, .quality-switch { display: flex; align-items: center; padding: 3px; background: rgba(5,10,15,.42); border: 1px solid var(--line); border-radius: 8px; gap: 2px; }
.view-btn, .quality-btn { border: 0; background: transparent; color: var(--muted); font-size: 9px; font-weight: 700; padding: 6px 10px; border-radius: 6px; cursor: pointer; transition: background .2s ease, color .2s ease; }
.view-btn.active, .quality-btn.active { color: var(--text); background: rgba(216,173,105,.16); box-shadow: inset 0 0 0 1px rgba(216,173,105,.16); }
.icon-button { width: 31px; height: 31px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: rgba(5,10,15,.35); color: var(--muted); cursor: pointer; }
.icon-button:hover { color: var(--accent-bright); border-color: rgba(216,173,105,.4); }
.icon-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.canvas-wrap { min-height: 0; position: relative; overflow: hidden; background: radial-gradient(ellipse at 52% 44%, rgba(33,55,68,.33), rgba(10,17,25,.02) 62%), linear-gradient(180deg, rgba(9,15,22,.18), rgba(9,15,22,.5)); }
#machineCanvas { width: 100%; height: 100%; display: block; touch-action: pan-y; }
.canvas-hud { position: absolute; top: 12px; display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.hud-left { left: 14px; }
.hud-right { right: 14px; text-align: right; }
.hud-label { font-size: 8px; letter-spacing: .15em; color: var(--dim); font-weight: 800; }
.hud-value { font-size: 8px; letter-spacing: .08em; color: #c4d0d8; font-weight: 700; }
.stage-caption { display: flex; gap: 11px; align-items: center; min-height: 58px; padding: 9px 15px; border-top: 1px solid var(--line); background: rgba(6,11,17,.22); }
.caption-icon { width: 26px; height: 26px; border-radius: 8px; border: 1px solid rgba(216,173,105,.3); background: rgba(216,173,105,.08); display: grid; place-items: center; flex: 0 0 auto; }
.caption-icon span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(216,173,105,.4); }
.caption-label { font-size: 8px; color: var(--accent); letter-spacing: .15em; font-weight: 800; margin-bottom: 3px; }
.stage-caption p { margin: 0; color: #c0cbd3; font-size: 10px; line-height: 1.45; }
.stage-foot { display: flex; align-items: center; gap: 14px; padding: 0 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 8px; }
.stage-foot span { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-source { background: var(--blue); }
.dot-remontoire { background: var(--accent); }
.stage-foot .foot-note { margin-left: auto; color: var(--dim); }
.control-card { display: flex; flex-direction: column; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #344653 transparent; }
.control-header { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px 10px; border-bottom: 1px solid var(--line); }
.control-header h2 { font-size: 15px; letter-spacing: -.025em; margin: 4px 0 0; font-weight: 650; }
.quality-btn { font-size: 8px; padding: 5px 8px; }
.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.preset-btn { min-width: 0; display: flex; align-items: center; gap: 8px; padding: 9px 8px; text-align: left; border: 1px solid var(--line); border-radius: 9px; background: rgba(5,10,15,.22); cursor: pointer; transition: border-color .2s ease, background .2s ease, transform .2s ease; }
.preset-btn:hover { border-color: rgba(216,173,105,.35); transform: translateY(-1px); }
.preset-btn.selected { border-color: rgba(216,173,105,.48); background: rgba(216,173,105,.08); }
.preset-mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; background: rgba(216,173,105,.12); color: var(--accent); font-size: 12px; flex: 0 0 auto; }
.preset-btn b { display: block; color: #e0e8ed; font-size: 9px; line-height: 1.2; }
.preset-btn small { display: block; color: var(--dim); font-size: 7px; margin-top: 3px; white-space: nowrap; }
.control-section { padding: 10px 14px 8px; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 8px; letter-spacing: .16em; font-weight: 800; margin-bottom: 9px; }
.section-line { height: 1px; background: var(--line); flex: 1; }
.control-item { margin-bottom: 10px; }
.control-item:last-child { margin-bottom: 0; }
.control-label { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 5px; }
.control-label label { color: #d7e0e6; font-size: 10px; font-weight: 570; }
.control-label output { color: var(--accent-bright); font-variant-numeric: tabular-nums; font-size: 10px; font-weight: 700; white-space: nowrap; }
input[type="range"] { appearance: none; width: 100%; height: 14px; margin: 0; background: transparent; cursor: pointer; touch-action: pan-y; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 99px; background: linear-gradient(90deg, rgba(216,173,105,.9), rgba(216,173,105,.22)); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 99px; background: linear-gradient(90deg, rgba(216,173,105,.9), rgba(216,173,105,.22)); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border: 2px solid #f4d49b; border-radius: 50%; background: #9e7442; box-shadow: 0 0 0 3px rgba(216,173,105,.12); }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border: 2px solid #f4d49b; border-radius: 50%; background: #9e7442; box-shadow: 0 0 0 3px rgba(216,173,105,.12); }
.range-ends { display: flex; align-items: center; justify-content: space-between; color: #607281; font-size: 7px; letter-spacing: .08em; margin-top: 2px; }
.range-ends .data-label { margin-left: auto; padding-left: 8px; }
.last-controls { border-bottom: 0; }
.transport-controls { display: grid; grid-template-columns: 1.25fr .8fr .8fr; gap: 7px; padding: 10px 13px 5px; margin-top: auto; }
.primary-control, .secondary-control { display: flex; justify-content: center; align-items: center; gap: 7px; min-height: 34px; border-radius: 8px; font-size: 9px; font-weight: 750; cursor: pointer; transition: filter .18s ease, border-color .18s ease, background .18s ease; }
.primary-control { border: 1px solid rgba(216,173,105,.55); color: #21180e; background: linear-gradient(135deg, #edc47e, #c18d4f); box-shadow: 0 5px 16px rgba(181,126,62,.12); }
.primary-control:hover { filter: brightness(1.08); }
.secondary-control { border: 1px solid var(--line-strong); background: rgba(7,12,18,.28); color: #c6d1d9; }
.secondary-control:hover { border-color: rgba(216,173,105,.4); color: var(--accent-bright); }
.play-icon { font-size: 11px; line-height: 1; }
.keyboard-hint { padding: 0 13px 10px; color: #617383; font-size: 8px; text-align: center; letter-spacing: .03em; }
.keyboard-hint span { color: #3e5361; padding: 0 4px; }
.readout-strip { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 8px; }
.readout-card { min-width: 0; padding: 10px 12px 9px; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(145deg, rgba(18,29,40,.9), rgba(13,21,30,.9)); }
.readout-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; color: var(--muted); font-size: 8px; letter-spacing: .12em; font-weight: 800; white-space: nowrap; }
.mini-tag { font-size: 7px; letter-spacing: .08em; }
.readout-value { display: flex; align-items: baseline; gap: 5px; margin-top: 4px; }
.readout-value strong { font-size: clamp(17px, 1.7vw, 22px); font-weight: 650; letter-spacing: -.04em; font-variant-numeric: tabular-nums; color: #f0f3f5; }
.readout-value small { color: var(--accent); font-size: 9px; font-weight: 650; }
.readout-note { color: var(--dim); font-size: 8px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.science-panel { border: 1px solid var(--line); border-radius: 10px; background: rgba(15,24,34,.86); overflow: hidden; }
.science-panel summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 10px 13px; }
.science-panel summary::-webkit-details-marker { display: none; }
.science-icon { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid rgba(114,184,197,.3); border-radius: 8px; color: var(--blue); background: rgba(114,184,197,.08); font-size: 15px; }
.science-panel summary b { display: block; font-size: 10px; font-weight: 700; }
.science-panel summary small { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; }
.summary-chevron { margin-left: auto; color: var(--muted); transition: transform .2s ease; }
.science-panel[open] .summary-chevron { transform: rotate(180deg); }
.science-panel[open] { max-height: min(22vh, 170px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #344653 transparent; }
.science-panel[open] summary { position: sticky; top: 0; z-index: 2; background: #101923; }
.science-content { padding: 0 13px 13px; border-top: 1px solid var(--line); }
.equation-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; padding-top: 10px; }
.equation-card { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(4,9,14,.18); min-width: 0; }
.equation-name { display: block; color: var(--accent); font-size: 8px; letter-spacing: .09em; font-weight: 800; text-transform: uppercase; }
.equation { color: #e5edf1; font-family: Georgia, "Times New Roman", serif; font-size: 14px; margin: 9px 0 7px; white-space: nowrap; }
.equation-card p { color: var(--muted); font-size: 8px; line-height: 1.45; margin: 0; }
.audit-row { display: grid; grid-template-columns: minmax(0,1.7fr) repeat(3,minmax(0,.55fr)); gap: 10px; align-items: center; margin-top: 9px; padding: 10px; border: 1px solid rgba(114,184,197,.2); border-radius: 8px; background: rgba(114,184,197,.045); }
.audit-kicker { display: block; color: var(--blue); font-size: 8px; font-weight: 800; letter-spacing: .12em; margin-bottom: 4px; }
.audit-kicker b { color: var(--dim); font-size: 7px; }
.audit-row strong { display: block; font-size: 10px; font-weight: 650; }
.audit-row p { margin: 4px 0 0; color: var(--muted); font-size: 8px; line-height: 1.4; }
.audit-result { border-left: 1px solid var(--line); padding-left: 10px; min-width: 0; }
.audit-result span { display: block; color: #e5edf1; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.audit-result small { color: var(--dim); font-size: 7px; letter-spacing: .1em; }
.simplification-note { margin-top: 9px; padding: 10px; border-radius: 8px; background: rgba(5,10,15,.24); }
.simplification-note b { color: #d7e0e6; font-size: 9px; }
.simplification-note p { margin: 5px 0 0; color: var(--muted); font-size: 8px; line-height: 1.55; }
.simplification-note p:last-child { color: var(--dim); font-style: italic; }
.simplification-note .source-line { color: #8fa0ac; font-size: 7px; margin-top: 3px; margin-bottom: 9px; }
.footer { display: flex; align-items: center; justify-content: space-between; padding: 0 5px; color: #586b79; font-size: 7px; letter-spacing: .14em; font-weight: 750; }
.footer b { color: var(--accent); padding: 0 3px; }

@media (max-width: 1050px) and (min-width: 761px) {
  .main-grid { grid-template-columns: minmax(0,1fr) 322px; }
  .app-shell { padding: 10px; gap: 8px; }
  .stage-foot { gap: 8px; }
  .stage-foot .foot-note { display: none; }
  .readout-card { padding: 9px 9px 8px; }
  .readout-top { font-size: 7px; }
}
@media (max-width: 760px) {
  body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
  body { overflow: hidden; }
  .app-shell { height: 100vh; height: 100dvh; grid-template-rows: 58px minmax(0,1fr) auto auto 20px; gap: 7px; padding: 7px 7px 5px; }
  .topbar { gap: 9px; padding: 0 3px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 10px; }
  .brand-mark svg { width: 27px; height: 27px; }
  .eyebrow { font-size: 7px; letter-spacing: .13em; }
  h1 { font-size: 17px; margin: 3px 0 2px; }
  .brand-copy p { font-size: 8px; }
  .top-status { padding: 6px 8px; font-size: 7px; gap: 6px; }
  .main-grid { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(250px, 38dvh) minmax(0,1fr); gap: 7px; }
  .stage-card { grid-template-rows: 39px minmax(0,1fr) auto 23px; }
  .stage-head { padding: 0 8px; }
  .stage-kicker { font-size: 7px; gap: 5px; letter-spacing: .10em; }
  .model-tag { font-size: 6px; padding: 3px 4px; }
  .stage-actions { gap: 5px; }
  .view-btn { font-size: 7px; padding: 5px 7px; }
  .icon-button { width: 27px; height: 27px; }
  .hud-left { left: 8px; top: 8px; }
  .hud-right { right: 8px; top: 8px; }
  .hud-label { font-size: 6px; }
  .hud-value { font-size: 6px; }
  .stage-caption { min-height: 45px; padding: 6px 8px; gap: 8px; }
  .caption-icon { width: 22px; height: 22px; }
  .caption-label { font-size: 6px; margin-bottom: 2px; }
  .stage-caption p { font-size: 8px; line-height: 1.3; }
  .stage-foot { min-height: 23px; padding: 0 8px; gap: 9px; font-size: 6px; }
  .stage-foot .foot-note { display: none; }
  .control-card { border-radius: 11px; }
  .control-header { padding: 9px 10px 7px; }
  .control-header h2 { font-size: 13px; }
  .control-header .eyebrow { font-size: 7px; }
  .quality-switch { padding: 2px; }
  .quality-btn { padding: 4px 7px; font-size: 7px; }
  .preset-row { padding: 7px 9px; gap: 6px; }
  .preset-btn { padding: 7px 6px; gap: 6px; }
  .preset-mark { width: 18px; height: 18px; font-size: 10px; }
  .preset-btn b { font-size: 8px; }
  .preset-btn small { font-size: 6px; }
  .control-section { padding: 7px 10px 5px; }
  .section-heading { font-size: 7px; margin-bottom: 6px; }
  .control-item { margin-bottom: 7px; }
  .control-label { margin-bottom: 3px; }
  .control-label label, .control-label output { font-size: 9px; }
  input[type="range"] { height: 12px; }
  .range-ends { font-size: 6px; }
  .range-ends .data-label { font-size: 6px; }
  .transport-controls { padding: 7px 9px 3px; gap: 6px; }
  .primary-control, .secondary-control { min-height: 31px; font-size: 8px; }
  .keyboard-hint { font-size: 7px; padding-bottom: 7px; }
  .readout-strip { grid-template-columns: repeat(5,minmax(0,1fr)); gap: 4px; }
  .readout-card { padding: 6px 5px 5px; border-radius: 7px; }
  .readout-top { font-size: 5.5px; letter-spacing: .05em; }
  .mini-tag { display: none; }
  .readout-value { gap: 2px; margin-top: 3px; }
  .readout-value strong { font-size: 14px; }
  .readout-value small { font-size: 7px; }
  .readout-note { display: none; }
  .science-panel[open] { max-height: 14dvh; }
  .science-panel summary { padding: 7px 9px; gap: 7px; }
  .science-icon { width: 21px; height: 21px; font-size: 12px; }
  .science-panel summary b { font-size: 8px; }
  .science-panel summary small { font-size: 6px; }
  .footer { font-size: 6px; }
  .equation-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .audit-row { grid-template-columns: minmax(0,1fr) repeat(3,minmax(0,.5fr)); gap: 5px; padding: 7px; }
  .audit-row strong { font-size: 8px; }
  .audit-row p { font-size: 7px; }
  .audit-result { padding-left: 5px; }
  .audit-result span { font-size: 9px; }
  .audit-result small { font-size: 6px; }
}
@media (max-width: 390px) {
  .app-shell { padding-left: 5px; padding-right: 5px; }
  .brand-copy p { font-size: 7px; }
  .stage-kicker { font-size: 6px; }
  .stage-foot { gap: 6px; }
  .readout-top { font-size: 5px; }
  .readout-value strong { font-size: 12px; }
  .readout-value small { font-size: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
