:root {
  color-scheme: dark;
  --bg: #0b1116;
  --panel: #111a21;
  --panel-2: #15222b;
  --line: rgba(177, 206, 214, .12);
  --line-strong: rgba(177, 206, 214, .22);
  --text: #e9f1f2;
  --muted: #8fa2aa;
  --soft: #b9c9cc;
  --accent: #71e0c4;
  --accent-dim: rgba(113, 224, 196, .12);
  --water: #59bfe7;
  --warning: #f0b66b;
  --danger: #ee8378;
  --wood: #c18b55;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { width: 100%; height: 100%; min-height: 0; display: flex; flex-direction: column; padding: 0 18px 10px; gap: 10px; background: radial-gradient(ellipse at 50% -35%, rgba(56, 106, 111, .18), transparent 56%), var(--bg); }
.topbar { flex: 0 0 66px; min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding: 0 4px; }
.brand-lockup { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; border: 1px solid rgba(113,224,196,.38); border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 3px; background: var(--accent-dim); transform: rotate(-7deg); }
.brand-mark span { display: block; width: 3px; border-radius: 3px; background: var(--accent); transform: skewY(-28deg); }
.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: 13px; opacity: .75; }
.eyebrow { color: var(--muted); font-size: 9px; letter-spacing: .17em; font-weight: 750; line-height: 1.4; }
h1 { margin: 2px 0 0; font-size: 17px; line-height: 1.15; letter-spacing: -.025em; font-weight: 670; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.era-tag { color: #9eb1b6; font-size: 9px; letter-spacing: .12em; border: 1px solid var(--line-strong); border-radius: 20px; padding: 7px 10px; white-space: nowrap; }
.live-indicator { display: flex; align-items: center; gap: 7px; color: var(--accent); font-size: 9px; font-weight: 750; letter-spacing: .12em; white-space: nowrap; }
.live-indicator i { width: 6px; height: 6px; display: block; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px rgba(113,224,196,.8); }
.workspace { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 282px minmax(350px, 1fr) 286px; gap: 12px; }
.panel { min-width: 0; min-height: 0; background: linear-gradient(160deg, rgba(21,34,43,.98), rgba(15,24,31,.98)); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #33464d transparent; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
.panel-heading h2 { margin: 3px 0 0; font-size: 14px; font-weight: 650; letter-spacing: -.015em; }
.source-chip, .model-chip { flex: 0 0 auto; font-size: 8px; letter-spacing: .1em; font-weight: 750; color: #a4b7bc; border: 1px solid var(--line-strong); padding: 5px 6px; border-radius: 5px; white-space: nowrap; }
.model-chip { color: var(--accent); border-color: rgba(113,224,196,.26); background: rgba(113,224,196,.06); }
.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border: 1px solid var(--line); background: rgba(6,13,18,.3); border-radius: 9px; margin-bottom: 14px; }
.preset-btn { border: 0; background: transparent; color: var(--muted); padding: 8px 5px; border-radius: 6px; font-size: 10px; font-weight: 650; cursor: pointer; transition: background .18s ease, color .18s ease; }
.preset-btn.active { background: rgba(113,224,196,.14); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(113,224,196,.18); }
.control-list { display: flex; flex-direction: column; gap: 13px; }
.control-item { min-width: 0; }
.control-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.control-top label { color: #dce7e8; font-size: 11px; font-weight: 630; }
.control-top output { color: var(--accent); font-size: 11px; font-variant-numeric: tabular-nums; font-weight: 680; }
input[type="range"] { width: 100%; height: 4px; margin: 0; display: block; accent-color: var(--accent); cursor: pointer; background: #304149; border-radius: 5px; }
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
.control-foot { display: flex; justify-content: space-between; margin-top: 5px; color: #647a83; font-size: 8px; font-variant-numeric: tabular-nums; }
.control-hint { margin: 4px 0 0; color: #7e929a; font-size: 9px; line-height: 1.35; }
.drive-controls { display: grid; grid-template-columns: 1.2fr .8fr .8fr; gap: 6px; margin-top: 16px; }
.primary-btn, .icon-btn, .shot-btn, .view-tab, .quality-toggle button { border: 1px solid var(--line-strong); border-radius: 8px; background: rgba(255,255,255,.025); cursor: pointer; transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.primary-btn:hover, .icon-btn:hover, .shot-btn:hover, .view-tab:hover, .quality-toggle button:hover { border-color: rgba(113,224,196,.48); }
button:active { transform: translateY(1px); }
button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.primary-btn { display: flex; align-items: center; justify-content: center; gap: 7px; background: var(--accent); color: #08211d; border-color: var(--accent); padding: 10px 8px; font-size: 10px; font-weight: 800; }
.play-icon { font-size: 9px; }
.icon-btn { padding: 9px 5px; font-size: 8px; letter-spacing: .06em; color: #b7c8ca; }
.drive-note { margin-top: 9px; border-left: 2px solid rgba(113,224,196,.55); padding: 2px 0 2px 9px; color: #8fa3a8; font-size: 9px; line-height: 1.45; min-height: 28px; }
.stage-column { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 9px; }
.stage-toolbar { flex: 0 0 42px; min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.view-tabs { display: flex; gap: 4px; background: rgba(17,26,33,.86); padding: 4px; border: 1px solid var(--line); border-radius: 9px; }
.view-tab { padding: 7px 12px; color: #8ea1a7; font-size: 9px; border: 0; border-radius: 6px; background: transparent; font-weight: 700; }
.view-tab.active { background: rgba(113,224,196,.14); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(113,224,196,.18); }
.stage-actions { display: flex; align-items: center; gap: 7px; }
.quality-toggle { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: rgba(17,26,33,.86); }
.quality-toggle button { border: 0; border-radius: 5px; background: transparent; color: #71868e; padding: 6px 7px; font-size: 8px; letter-spacing: .1em; font-weight: 750; }
.quality-toggle button.selected { color: var(--accent); background: rgba(113,224,196,.13); }
.shot-btn { padding: 8px 10px; color: #b8c9cb; font-size: 8px; letter-spacing: .08em; font-weight: 750; white-space: nowrap; }
.shot-btn span { color: var(--accent); margin-right: 4px; font-size: 11px; }
.stage-wrap { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; border-radius: var(--radius); border: 1px solid rgba(141,177,185,.16); background: #0c151b; box-shadow: 0 16px 36px rgba(0,0,0,.18); }
#machineCanvas { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.canvas-topline { position: absolute; left: 15px; right: 15px; top: 13px; display: flex; justify-content: space-between; gap: 10px; color: #9eb3b8; font-size: 8px; letter-spacing: .14em; font-weight: 800; pointer-events: none; text-shadow: 0 1px 4px rgba(0,0,0,.65); }
.canvas-topline b { color: var(--accent); padding: 0 4px; }
.canvas-legend { position: absolute; left: 15px; bottom: 13px; display: flex; flex-wrap: wrap; gap: 13px; color: #8ea4aa; font-size: 8px; letter-spacing: .1em; font-weight: 700; pointer-events: none; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.canvas-legend span { display: flex; align-items: center; gap: 5px; }
.canvas-legend i { display: block; width: 12px; height: 3px; border-radius: 3px; }
.legend-water { background: var(--water); }.legend-chain { background: var(--accent); }.legend-wood { background: var(--wood); }
.caption-bar { flex: 0 0 auto; min-height: 58px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); background: rgba(17,26,33,.75); border-radius: 10px; padding: 9px 13px; }
.caption-icon { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; border-radius: 8px; color: var(--accent); background: var(--accent-dim); font-size: 15px; }
.caption-label { color: var(--accent); font-size: 8px; letter-spacing: .14em; font-weight: 800; }
.caption-bar p { margin: 3px 0 0; color: #aabbbf; font-size: 10px; line-height: 1.35; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric-card { min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 11px 10px 9px; background: rgba(5,12,17,.22); }
.metric-primary { grid-column: span 2; padding: 13px 12px 11px; background: linear-gradient(110deg, rgba(113,224,196,.11), rgba(113,224,196,.025)); border-color: rgba(113,224,196,.23); }
.metric-label { color: #80959d; font-size: 8px; letter-spacing: .13em; font-weight: 800; }
.metric-value { margin-top: 5px; color: #eff8f7; font-size: 22px; line-height: 1; font-weight: 690; letter-spacing: -.04em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-primary .metric-value { color: var(--accent); font-size: 29px; }
.metric-value small { margin-left: 3px; font-size: 10px; font-weight: 600; letter-spacing: 0; color: #9eb3b8; }
.metric-sub { margin-top: 6px; color: #738992; font-size: 8px; line-height: 1.3; }
.stability-card, .check-card, .reference-card { margin-top: 9px; border: 1px solid var(--line); border-radius: 10px; padding: 11px; background: rgba(5,12,17,.22); }
.stability-top, .check-head { display: flex; align-items: center; justify-content: space-between; color: #81969d; font-size: 8px; letter-spacing: .12em; font-weight: 800; }
.state-pill, .check-badge { border-radius: 4px; padding: 4px 6px; color: var(--accent); background: rgba(113,224,196,.1); font-size: 7px; letter-spacing: .1em; }
.state-pill.warning { color: var(--warning); background: rgba(240,182,107,.12); }
.state-pill.danger { color: var(--danger); background: rgba(238,131,120,.12); }
.stability-track { height: 4px; margin: 11px 0 9px; border-radius: 4px; background: #2b3b42; overflow: hidden; }
.stability-track div { height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .18s ease; }
.stability-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; color: #81959c; font-size: 8px; }
.stability-foot strong { color: #d7e4e5; font-weight: 650; font-variant-numeric: tabular-nums; }
.check-badge { color: #9fb2b6; background: rgba(159,178,182,.1); }
.check-equation { margin-top: 10px; color: #b5c8ca; font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.check-result { display: flex; align-items: center; justify-content: space-between; gap: 7px; margin-top: 9px; }
.check-result div:not(.check-arrow) { display: flex; flex-direction: column; gap: 4px; }
.check-result span { color: #7f939a; font-size: 8px; }
.check-result strong { color: #e0ebeb; font-size: 13px; font-weight: 680; font-variant-numeric: tabular-nums; }
.check-arrow { color: var(--accent); font-size: 14px; }
.check-diff { margin-top: 8px; color: #8da2a8; font-size: 8px; line-height: 1.35; }
.reference-card { background: linear-gradient(135deg, rgba(240,182,107,.07), rgba(240,182,107,.015)); border-color: rgba(240,182,107,.18); }
.reference-kicker { color: var(--warning); font-size: 8px; letter-spacing: .13em; font-weight: 800; }
.reference-card p { margin: 7px 0 6px; color: #9eafb2; font-size: 9px; line-height: 1.5; }
.reference-card strong { color: #e4eceb; font-weight: 700; }
.reference-source { color: #71868c; font-size: 8px; }
.science-panel { margin-top: 9px; border: 1px solid var(--line); border-radius: 10px; background: rgba(5,12,17,.22); }
.science-panel summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 11px; color: #c3d1d2; font-size: 8px; letter-spacing: .13em; font-weight: 800; }
.science-panel summary::-webkit-details-marker { display: none; }
.summary-plus { color: var(--accent); font-size: 15px; transition: transform .2s ease; }
.science-panel[open] .summary-plus { transform: rotate(45deg); }
.science-content { padding: 0 11px 11px; color: #91a6ab; font-size: 9px; line-height: 1.5; }
.science-content h3 { margin: 9px 0 4px; color: #c6d6d7; font-size: 9px; letter-spacing: .04em; }
.science-content p { margin: 4px 0; }
.science-content code { color: var(--accent); font-size: 8px; white-space: normal; }
.science-caveat { margin-top: 9px !important; color: #c2d0d1; font-style: italic; }
.science-source { color: #70858c; font-size: 8px; }
.footerbar { flex: 0 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #60757c; font-size: 7px; letter-spacing: .13em; font-weight: 750; padding: 0 4px; }
 .mobile-readouts { display: none; }
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
@media (max-width: 1120px) and (min-width: 761px) {
  .workspace { grid-template-columns: 248px minmax(300px, 1fr) 250px; gap: 9px; }
  .panel { padding: 12px; }
  .app-shell { padding-left: 12px; padding-right: 12px; }
  .metric-value { font-size: 19px; }
  .metric-primary .metric-value { font-size: 26px; }
}
@media (max-width: 760px) {
  html, body { height: 100%; }
  .app-shell { padding: 0 8px 6px; gap: 6px; }
  .topbar { flex-basis: 54px; min-height: 54px; padding: 0 2px; }
  .brand-mark { width: 29px; height: 29px; }
  h1 { font-size: 13px; }
  .eyebrow { font-size: 7px; }
  .topbar-right { gap: 8px; }
  .era-tag { display: none; }
  .live-indicator { font-size: 7px; }
  .workspace { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(260px, 42dvh) minmax(0,1fr); gap: 7px; }
  .stage-column { grid-row: 1; gap: 5px; }
  .stage-toolbar { flex-basis: 32px; min-height: 32px; }
  .view-tabs { padding: 3px; gap: 2px; }
  .view-tab { padding: 6px 9px; font-size: 8px; }
  .quality-toggle { padding: 2px; }
  .quality-toggle button { padding: 5px 6px; font-size: 7px; }
  .shot-btn { padding: 6px 7px; font-size: 7px; }
  .shot-btn span { font-size: 9px; }
  .stage-wrap { border-radius: 10px; }
  .canvas-topline { top: 9px; left: 10px; right: 10px; font-size: 7px; }
  .canvas-legend { left: 10px; bottom: 8px; gap: 9px; font-size: 7px; }
  .canvas-legend i { width: 9px; }
  .caption-bar { min-height: 42px; padding: 6px 9px; gap: 8px; }
  .caption-icon { width: 23px; height: 23px; flex-basis: 23px; font-size: 12px; }
  .caption-label { font-size: 7px; }
  .caption-bar p { font-size: 8px; margin-top: 2px; }
  .controls-panel, .readout-panel { grid-row: 2; min-height: 0; overflow-y: auto; border-radius: 10px; padding: 11px; }
  .controls-panel { display: block; }
  .readout-panel { display: none; }
  .panel-heading { margin-bottom: 9px; }
  .panel-heading h2 { font-size: 12px; }
  .source-chip { font-size: 7px; }
  .preset-row { margin-bottom: 10px; }
  .mobile-readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 0 0 10px; }
  .mobile-metric { min-width: 0; padding: 7px 8px; border: 1px solid rgba(113,224,196,.16); border-radius: 7px; background: rgba(113,224,196,.055); }
  .mobile-metric span { display: block; color: #7f969d; font-size: 6px; letter-spacing: .11em; font-weight: 800; white-space: nowrap; }
  .mobile-metric strong { display: block; margin-top: 3px; color: var(--accent); font-size: 14px; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
  .mobile-check { grid-column: span 2; color: #8da3a8; font-size: 7px; padding: 2px 1px 0; }
  .control-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
  .control-top { margin-bottom: 5px; }
  .control-top label, .control-top output { font-size: 10px; }
  .control-hint { font-size: 8px; }
  .drive-controls { margin-top: 12px; }
  .drive-note { font-size: 8px; }
  .footerbar { flex-basis: 10px; font-size: 6px; }
  .footerbar span:last-child { display: none; }
}
@media (max-width: 390px) {
  .app-shell { padding-left: 6px; padding-right: 6px; }
  .workspace { grid-template-rows: minmax(245px, 40dvh) minmax(0,1fr); }
  .control-list { gap: 8px 9px; }
  .control-hint { font-size: 7px; }
  .view-tab { padding: 6px 7px; }
  .shot-btn { padding: 6px 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
