:root {
  color-scheme: dark;
  --bg: #091117;
  --panel: #101a22;
  --panel-2: #121f28;
  --panel-3: #0c151c;
  --line: rgba(171, 198, 207, .13);
  --line-strong: rgba(171, 198, 207, .22);
  --text: #e7f0ef;
  --muted: #91a4a9;
  --dim: #63767d;
  --accent: #77dfc0;
  --accent-soft: rgba(119, 223, 192, .13);
  --brass: #c6a36d;
  --blue: #7d9aa8;
  --direct: #a4b2b7;
  --danger: #d99a7c;
  --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; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow-x: hidden; }
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.app { min-height: 100vh; max-width: 1800px; margin: 0 auto; padding: 20px 24px 12px; display: flex; flex-direction: column; gap: 14px; }
body.embed-mode .app { height: 100vh; height: 100dvh; min-height: 0; padding: 14px 18px 8px; gap: 10px; }
.topbar { min-height: 68px; display: flex; align-items: center; gap: 16px; }
.brand-mark { width: 42px; height: 42px; border: 1px solid rgba(119,223,192,.4); border-radius: 50%; position: relative; flex: 0 0 auto; background: radial-gradient(circle, rgba(119,223,192,.1), transparent 65%); }
.mark-ring { position: absolute; inset: 7px; border: 1px solid var(--accent); border-radius: 50%; opacity: .8; }
.mark-hand { position: absolute; width: 1px; height: 12px; left: 20px; top: 8px; background: var(--accent); transform-origin: 50% 13px; transform: rotate(36deg); box-shadow: 0 0 8px rgba(119,223,192,.5); }
.heading { min-width: 0; }
.eyebrow, .section-label, .metric-label, .chart-heading, .stage-kicker, .stage-state, .time-label, .margin-strip > div:first-child span, .footer, .model-tag { letter-spacing: .13em; font-size: 9px; font-weight: 750; }
.eyebrow { color: var(--accent); margin-bottom: 4px; }
.eyebrow-dot { color: var(--dim); padding: 0 4px; }
h1 { margin: 0; font-size: clamp(21px, 2vw, 28px); font-weight: 640; letter-spacing: -.045em; line-height: 1.1; }
.subtitle { margin: 4px 0 0; font-size: 12px; color: var(--muted); letter-spacing: .01em; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.history-chip { border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 8px 12px; font-size: 9px; letter-spacing: .08em; white-space: nowrap; }
.chip-dot, .live-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 7px; box-shadow: 0 0 8px rgba(119,223,192,.65); vertical-align: 1px; }
.icon-button, .transport-btn, .tab, .quality-btn, .drive-btn, .preset-btn { border: 1px solid var(--line); background: rgba(17,29,37,.75); border-radius: 9px; cursor: pointer; transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease; }
.icon-button { display: inline-flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 11px; color: var(--text); }
.icon-button svg, .transport-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:hover, .transport-btn:hover, .tab:hover, .quality-btn:hover, .drive-btn:hover, .preset-btn:hover { border-color: rgba(119,223,192,.55); background: rgba(119,223,192,.08); }
.toolbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 12px; }
.view-tabs { display: flex; gap: 5px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: rgba(12,21,28,.85); }
.tab { padding: 7px 13px; border-color: transparent; background: transparent; color: var(--muted); font-size: 11px; }
.tab.active { background: var(--accent-soft); color: var(--accent); border-color: rgba(119,223,192,.24); }
.toolbar-right { display: flex; align-items: center; gap: 12px; }
.quality-toggle { display: flex; border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.quality-btn { border: 0; background: transparent; padding: 5px 9px; color: var(--dim); font-size: 10px; }
.quality-btn.active { background: rgba(119,223,192,.13); color: var(--accent); }
.transport { display: flex; gap: 5px; }
.transport-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 10px; color: var(--muted); font-size: 11px; min-height: 34px; }
.transport-btn.primary { color: var(--accent); border-color: rgba(119,223,192,.3); background: rgba(119,223,192,.1); }
.transport-btn.square { width: 35px; padding: 0; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; flex: 1; min-height: 0; }
.stage-column { display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 8px; }
.stage-shell { position: relative; flex: 1; min-height: 390px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: radial-gradient(ellipse at 48% 43%, rgba(35,61,68,.42), rgba(12,22,29,.85) 58%, #0a1218 100%); box-shadow: 0 18px 60px rgba(0,0,0,.22), inset 0 1px rgba(255,255,255,.025); }
#machineCanvas { display: block; width: 100%; height: 100%; min-height: 390px; }
.stage-topline, .stage-bottomline { position: absolute; left: 18px; right: 18px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.stage-topline { top: 16px; }
.stage-bottomline { bottom: 14px; gap: 14px; align-items: flex-end; }
.stage-kicker { color: var(--muted); }
.stage-state { color: var(--accent); font-size: 9px; }
.stage-state.paused { color: var(--brass); }
.stage-state.paused .live-dot { background: var(--brass); box-shadow: none; }
#stageCaption { max-width: 68%; color: #a9b9bb; font-size: 11px; line-height: 1.45; text-shadow: 0 1px 4px #071017; }
.time-readout { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; color: var(--text); font-variant-numeric: tabular-nums; }
.time-label { color: var(--dim); font-size: 8px; }
.time-readout strong { font-size: 12px; font-weight: 650; }
.time-readout em { font-size: 9px; color: var(--dim); font-style: normal; }
.machine-key { display: flex; gap: 18px; padding: 0 6px; color: var(--muted); font-size: 10px; flex-wrap: wrap; }
.machine-key span { display: inline-flex; align-items: center; gap: 6px; }
.key-swatch { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
.key-swatch.mainspring { background: #c6a36d; }.key-swatch.train { background: #8b9da3; }.key-swatch.remontoire { background: var(--accent); }.key-swatch.escapement { background: #d5d9d3; }
.control-panel { min-height: 0; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; background: linear-gradient(160deg, rgba(17,29,37,.98), rgba(12,21,28,.98)); scrollbar-width: thin; scrollbar-color: #30454d transparent; }
.panel-heading, .design-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.section-label { color: var(--accent); font-size: 8px; margin-bottom: 4px; }
h2 { margin: 0; font-size: 16px; font-weight: 620; letter-spacing: -.025em; }
.model-tag { border: 1px solid rgba(119,223,192,.22); border-radius: 5px; color: var(--accent); padding: 4px 6px; font-size: 7px; white-space: nowrap; }
.drive-switch { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; gap: 3px; margin: 12px 0 10px; border-radius: 9px; background: #0a1319; border: 1px solid var(--line); }
.drive-btn { border: 0; background: transparent; padding: 7px 5px; font-size: 10px; color: var(--muted); }
.drive-btn.active { background: rgba(119,223,192,.13); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(119,223,192,.16); }
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.metric-card { min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: rgba(7,15,20,.46); padding: 9px 10px 8px; }
.metric-label { color: var(--dim); font-size: 7px; display: block; margin-bottom: 6px; }
.metric-card strong { display: block; font-size: 21px; font-weight: 590; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1.1; white-space: nowrap; }
.metric-card strong small { color: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: 0; }
.metric-note { display: block; color: var(--dim); font-size: 8px; margin-top: 4px; }
.chart-block { margin-top: 12px; border: 1px solid var(--line); border-radius: 9px; padding: 9px 9px 7px; background: rgba(7,15,20,.34); }
.chart-heading { color: var(--muted); font-size: 7px; display: flex; justify-content: space-between; gap: 8px; }
.chart-unit { color: var(--dim); font-size: 7px; }
#torqueChart { display: block; width: 100%; height: 100px; margin-top: 5px; }
.chart-legend { display: flex; gap: 14px; color: var(--dim); font-size: 8px; }
.chart-legend span { display: flex; align-items: center; gap: 5px; }
.legend-line { display: inline-block; width: 14px; height: 2px; border-radius: 2px; }.direct-line { background: var(--direct); }.rem-line { background: var(--accent); }
.design-heading { margin-top: 16px; align-items: center; }
.presets { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 5px; margin: 9px 0 12px; }
.preset-btn { min-width: 0; padding: 7px 4px; font-size: 8px; color: var(--muted); }
.preset-btn.active { border-color: rgba(119,223,192,.35); color: var(--accent); background: rgba(119,223,192,.08); }
.sliders { display: flex; flex-direction: column; gap: 11px; }
.slider-row { display: block; }
.slider-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: 10px; color: #cbd7d7; }
.slider-top em { color: var(--dim); font-style: normal; cursor: help; }
.slider-top output { color: var(--accent); font-variant-numeric: tabular-nums; font-size: 9px; white-space: nowrap; }
input[type="range"] { display: block; width: 100%; height: 13px; margin: 5px 0 1px; accent-color: var(--accent); cursor: pointer; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: #2a3a42; border-radius: 5px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 11px; height: 11px; margin-top: -4px; border-radius: 50%; background: var(--accent); border: 2px solid #0e1b20; box-shadow: 0 0 0 1px rgba(119,223,192,.4); }
input[type="range"]::-moz-range-track { height: 3px; background: #2a3a42; border-radius: 5px; }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid #0e1b20; }
.slider-range { display: flex; justify-content: space-between; color: var(--dim); font-size: 8px; font-variant-numeric: tabular-nums; }
.margin-strip { border-top: 1px solid var(--line); margin-top: 13px; padding-top: 10px; }
.margin-strip > div:first-child { display: flex; justify-content: space-between; align-items: baseline; }
.margin-strip > div:first-child span { color: var(--dim); font-size: 7px; }
.margin-strip strong { color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; }
.margin-track { height: 4px; border-radius: 6px; background: #26363e; margin-top: 6px; overflow: hidden; }
.margin-track span { display: block; width: 100%; height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s ease, background .2s ease; }
.margin-strip p { margin: 5px 0 0; color: var(--dim); font-size: 8px; line-height: 1.4; }
.science-panel { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 9px; }
.science-panel summary { list-style: none; display: flex; align-items: center; justify-content: space-between; color: var(--text); font-size: 11px; font-weight: 600; cursor: pointer; }
.science-panel summary::-webkit-details-marker { display: none; }
.summary-plus { color: var(--accent); font-size: 17px; font-weight: 400; transition: transform .18s ease; }
.science-panel[open] .summary-plus { transform: rotate(45deg); }
.science-content { padding-top: 8px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.science-intro { margin: 0 0 8px; }
.equation { padding: 7px 8px; margin: 5px 0; border-radius: 6px; border: 1px solid var(--line); background: rgba(4,11,15,.35); display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
.equation span { color: #c4d1d1; font-size: 9px; }
.equation code { color: var(--accent); font-size: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.equation small { color: var(--dim); font-size: 7px; }
.simplification { margin: 9px 0; }
.simplification b { color: #d5e1df; }
.historical-note { border-left: 2px solid var(--brass); padding-left: 8px; margin: 8px 0; color: #aeb8b3; }
.checkline { padding: 8px; border: 1px solid rgba(119,223,192,.2); border-radius: 7px; background: rgba(119,223,192,.05); display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
.checkline span { color: var(--accent); font-size: 7px; letter-spacing: .1em; font-weight: 750; }
.checkline strong { color: var(--text); font-size: 10px; font-variant-numeric: tabular-nums; }
.checkline small { grid-column: 1 / -1; color: var(--dim); font-size: 8px; }
.disclaimer { margin: 10px 0 4px; color: #d1dcda; font-size: 8px; }
.references { color: var(--dim); font-size: 7px; margin: 0; }
.footer { display: flex; justify-content: space-between; gap: 12px; color: var(--dim); font-size: 7px; min-height: 14px; align-items: center; }
.footer span:first-child { color: #71868c; }
@media (min-width: 1500px) { .workspace { grid-template-columns: minmax(0, 1fr) 390px; } .app { padding-left: 32px; padding-right: 32px; } }
@media (max-width: 1100px) { .workspace { grid-template-columns: minmax(0, 1fr) 330px; } .history-chip { display: none; } }
@media (max-width: 820px) {
  .app, body.embed-mode .app { padding: 10px 10px 6px; gap: 8px; }
  .topbar { min-height: 54px; gap: 10px; }
  .brand-mark { width: 34px; height: 34px; }.mark-ring { inset: 6px; }.mark-hand { left: 16px; top: 6px; height: 10px; transform-origin: 50% 11px; }
  .eyebrow { font-size: 7px; } h1 { font-size: 20px; }.subtitle { font-size: 10px; }
  .header-actions { gap: 0; }.icon-button { padding: 8px; }.icon-button span { display: none; }
  .toolbar { min-height: 38px; gap: 6px; }.tab { padding: 6px 8px; font-size: 9px; }.toolbar-right { gap: 6px; }.quality-toggle { display: none; }
  .transport-btn { min-height: 31px; padding: 6px 8px; font-size: 9px; }.transport-btn.square { width: 31px; }
  .workspace { display: flex; flex-direction: column; gap: 8px; flex: 1; }
  .stage-column { flex: 0 0 auto; min-height: 0; }
  .stage-shell { height: clamp(260px, 39vh, 360px); min-height: 250px; flex: none; }
  #machineCanvas { min-height: 250px; }
  .stage-topline { top: 10px; left: 12px; right: 12px; }.stage-bottomline { left: 12px; right: 12px; bottom: 10px; }
  #stageCaption { font-size: 9px; max-width: 68%; }.time-readout em { display: none; }.time-readout strong { font-size: 10px; }
  .machine-key { display: none; }
  .control-panel { flex: 1 1 auto; min-height: 0; padding: 11px; }
  .panel-heading h2, .design-heading h2 { font-size: 14px; }
  .metrics-grid { gap: 5px; }.metric-card { padding: 7px 8px; }.metric-card strong { font-size: 18px; }
  .chart-block { margin-top: 8px; }.chart-heading { font-size: 6px; } #torqueChart { height: 78px; }
  .design-heading { margin-top: 12px; }.presets { margin: 7px 0 10px; }.preset-btn { font-size: 7px; padding: 6px 3px; }
  .sliders { gap: 8px; }.slider-top { font-size: 9px; }.slider-range { font-size: 7px; }
  .footer { display: none; }
}
@media (max-width: 430px) {
  .app, body.embed-mode .app { padding: 8px 8px 5px; gap: 6px; }
  .topbar { min-height: 48px; }.brand-mark { display: none; }.heading { padding-left: 2px; }.eyebrow { font-size: 6px; margin-bottom: 3px; } h1 { font-size: 18px; }.subtitle { font-size: 9px; }
  .toolbar { min-height: 34px; }.view-tabs { padding: 2px; gap: 1px; }.tab { padding: 6px 7px; font-size: 8px; }.transport { gap: 3px; }.transport-btn { padding: 5px 6px; gap: 4px; }.transport-btn svg { width: 14px; height: 14px; }.transport-btn.square { width: 28px; }
  .stage-shell { height: clamp(250px, 34vh, 300px); min-height: 250px; border-radius: 10px; } #machineCanvas { min-height: 250px; }
  .stage-bottomline { align-items: flex-end; }.time-readout { gap: 4px; }.time-label { font-size: 6px; }.time-readout strong { font-size: 9px; }
  .control-panel { border-radius: 10px; padding: 9px; }
  .model-tag { font-size: 6px; }.metric-label { font-size: 6px; }.metric-card strong { font-size: 17px; }.metric-note { font-size: 7px; }
  .chart-block { padding: 7px; } #torqueChart { height: 68px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
