:root {
  color-scheme: dark;
  --bg: #0b1116;
  --panel: #121b22;
  --panel-2: #17232b;
  --line: #2a3942;
  --text: #edf4f2;
  --muted: #9aabb0;
  --dim: #6f8288;
  --accent: #5de0d0;
  --accent-ink: #06211f;
  --radius: 13px;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); }
body { color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 13px; line-height: 1.42; }
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }
.app-shell { display: flex; flex-direction: column; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; }
.topbar { height: 54px; min-height: 54px; display: flex; align-items: center; gap: 20px; padding: 0 18px; border-bottom: 1px solid var(--line); background: #0d151b; }
.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--text); font-size: 12px; font-weight: 750; letter-spacing: .03em; }
.brand-mark { width: 21px; height: 21px; display: grid; place-items: center; border: 1px solid var(--accent); border-radius: 6px; color: var(--accent); font-size: 11px; }
.brand-divider { color: var(--dim); }
.brand-sub { color: var(--muted); font-size: 9px; letter-spacing: .14em; }
.top-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dce7e5; font-size: 13px; font-weight: 620; }
.top-title span { color: var(--dim); padding: 0 4px; }
.quality-button { border: 1px solid var(--line); border-radius: 7px; background: #152129; padding: 7px 10px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .1em; cursor: pointer; white-space: nowrap; }
.quality-button:hover, .action-button:hover, .preset:hover { border-color: var(--accent); }
body.embed-mode .brand { display: none; }
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(350px, 405px); gap: 12px; padding: 12px; overflow: hidden; }
.scene-column { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 10px; overflow: hidden; }
.canvas-wrap { position: relative; min-width: 0; min-height: 0; overflow: hidden; border: 1px solid #263640; border-radius: 16px; background: #101b22; box-shadow: inset 0 0 0 1px rgba(255,255,255,.015), 0 14px 35px rgba(0,0,0,.16); }
#scene { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#scene.dragging { cursor: grabbing; }
.scene-label { position: absolute; z-index: 2; color: #a9b9bb; font-size: 9px; font-weight: 750; letter-spacing: .14em; pointer-events: none; text-shadow: 0 1px 3px #0b1116; }
.scene-label-top { top: 14px; left: 16px; display: flex; align-items: center; gap: 8px; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(93,224,208,.7); }
.scene-label-bottom { bottom: 14px; left: 16px; color: #7d9298; }
.scene-label-bottom span { color: var(--accent); font-size: 13px; margin-left: 5px; }
.scene-scale { position: absolute; right: 15px; bottom: 14px; color: #64767c; font-size: 8px; font-weight: 700; letter-spacing: .12em; pointer-events: none; }
.caption-band { display: flex; gap: 16px; align-items: flex-start; padding: 12px 15px; border: 1px solid var(--line); border-radius: 11px; background: #111a20; min-height: 68px; }
.caption-kicker { flex: 0 0 auto; padding-top: 2px; color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .13em; }
.caption-band p { margin: 0; color: #c1cecf; font-size: 12px; line-height: 1.5; }
.panel { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 2px 18px 0; scrollbar-width: thin; scrollbar-color: #35464e transparent; }
.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-thumb { background: #35464e; border-radius: 8px; }
.panel section { margin-bottom: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 2px 1px 8px; color: #c4d0d0; font-size: 9px; font-weight: 850; letter-spacing: .13em; }
.source-chip { color: var(--dim); font-size: 8px; font-weight: 750; letter-spacing: .1em; white-space: nowrap; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 7px; }
.metric-card { min-width: 0; min-height: 76px; padding: 10px 9px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.metric-card-accent { border-color: rgba(93,224,208,.42); background: linear-gradient(145deg, rgba(93,224,208,.09), #121b22 68%); }
.metric-label { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .1em; line-height: 1.25; min-height: 20px; }
.metric-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: clamp(16px, 1.6vw, 22px); font-weight: 760; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.metric-card-accent .metric-value { color: var(--accent); }
.metric-unit { margin-top: 3px; color: var(--dim); font-size: 8px; }
.metric-note { margin: 6px 2px 0; color: var(--muted); font-size: 10px; }
.comparison-card { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #111a20; }
.comparison-heading { margin-bottom: 6px; color: var(--muted); font-size: 8px; font-weight: 850; letter-spacing: .13em; }
.comparison-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; border-top: 1px solid rgba(42,57,66,.6); color: #c2cece; font-size: 10px; }
.comparison-row:first-of-type { border-top: 0; }
.comparison-row span { min-width: 0; }
.comparison-row b { margin-left: 4px; color: var(--dim); font-size: 7px; letter-spacing: .08em; }
.comparison-row strong { color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.comparison-foot { padding-top: 5px; color: var(--accent); font-size: 9px; }
#historyChart { display: block; width: 100%; height: 126px; border: 1px solid var(--line); border-radius: 9px; background: #0e171d; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 7px 2px 3px; color: var(--muted); font-size: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: #a5b3b7; }
.legend-dot.mean { background: var(--accent); }
.legend-dot.yours { background: #f0d6a2; }
.chart-note { margin: 4px 2px 0; color: var(--dim); font-size: 9px; line-height: 1.4; }
.preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px; margin-bottom: 11px; }
.preset { min-height: 31px; border: 1px solid var(--line); border-radius: 7px; background: #131e25; color: #aebdc0; font-size: 9px; font-weight: 700; cursor: pointer; }
.preset.active { border-color: var(--accent); color: var(--accent); background: rgba(93,224,208,.07); }
.control-list { display: grid; gap: 10px; }
.control-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 3px 10px; }
.control-row label { color: #d5dfde; font-size: 10px; font-weight: 650; }
.control-row label span { color: var(--accent); font-size: 11px; cursor: help; }
.control-row output { color: var(--accent); font-size: 10px; font-weight: 750; font-variant-numeric: tabular-nums; }
.control-row input[type="range"] { grid-column: 1 / -1; width: 100%; height: 14px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
.control-row input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: #35464e; }
.control-row input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: #35464e; }
.control-row input[type="range"]::-webkit-slider-thumb { width: 13px; height: 13px; margin-top: -4.5px; appearance: none; border: 2px solid #0b1116; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.control-row input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border: 2px solid #0b1116; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.control-row input[type="range"]:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; border-radius: 5px; }
.action-grid { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 6px; margin-top: 13px; }
.primary-action, .action-button { min-height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #16232b; color: #dce7e5; font-size: 9px; font-weight: 850; letter-spacing: .08em; cursor: pointer; }
.primary-action { grid-column: 1 / -1; min-height: 39px; border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.primary-action:hover { filter: brightness(1.07); }
.action-button:disabled { opacity: .35; cursor: not-allowed; }
.run-status { margin-top: 7px; color: var(--muted); font-size: 9px; min-height: 14px; }
.repeat-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.repeat-summary > div { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: #111a20; }
.summary-label { display: block; margin-bottom: 4px; color: var(--dim); font-size: 8px; font-weight: 800; letter-spacing: .1em; }
.repeat-summary strong { color: var(--accent); font-size: 15px; font-variant-numeric: tabular-nums; }
.repeat-note { margin: 6px 2px 0; color: var(--muted); font-size: 9px; }
.checks-section { padding: 10px 11px 7px; border: 1px solid var(--line); border-radius: 10px; background: #111a20; }
.check-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid rgba(42,57,66,.6); color: #c2cece; font-size: 9px; }
.check-row b { margin-right: 5px; color: var(--dim); font-size: 8px; }
.check-row strong { color: var(--accent); font-size: 8px; font-weight: 850; white-space: nowrap; letter-spacing: .05em; }
.science-panel { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #111a20; }
.science-panel summary { padding: 11px 12px; color: #cbd7d6; font-size: 9px; font-weight: 850; letter-spacing: .11em; cursor: pointer; }
.science-content { padding: 0 12px 12px; color: #aebdc0; font-size: 10px; }
.science-content p { margin: 7px 0; }
.science-content strong { color: #e2ecea; }
.science-content .equation { padding: 7px 8px; border-left: 2px solid var(--accent); background: #0c151a; color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; }
.science-content .affiliation { margin-top: 12px; color: var(--dim); font-style: italic; }
@media (max-width: 760px) {
  .topbar { height: 48px; min-height: 48px; padding: 0 10px; gap: 9px; }
  .brand { font-size: 10px; gap: 5px; }
  .brand-sub, .brand-divider { display: none; }
  .brand-mark { width: 18px; height: 18px; }
  .top-title { font-size: 11px; }
  .quality-button { padding: 6px 7px; font-size: 8px; }
  .layout { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(220px, 31vh) minmax(0,1fr); gap: 8px; padding: 8px; }
  .scene-column { grid-template-rows: minmax(0,1fr); }
  .caption-band { display: none; }
  .panel { padding-right: 1px; }
  .metric-card { min-height: 70px; padding: 8px 7px; }
  .metric-value { font-size: clamp(15px, 4.2vw, 20px); }
  .metric-label { font-size: 7px; }
  .metric-unit { font-size: 7px; }
  #historyChart { height: 118px; }
}
@media (max-width: 390px) {
  .topbar { gap: 6px; }
  .brand { font-size: 9px; }
  .top-title { font-size: 10px; }
  .quality-button { font-size: 7px; padding: 6px 5px; }
  .layout { grid-template-rows: minmax(220px, 30vh) minmax(0,1fr); }
  .section-head { font-size: 8px; }
  .comparison-row { font-size: 9px; }
  .chart-legend { gap: 8px; }
}
