:root {
  color-scheme: dark;
  --bg: #07111c;
  --panel: #0d1a27;
  --panel-2: #101f2d;
  --line: rgba(139, 184, 190, 0.14);
  --line-strong: rgba(139, 184, 190, 0.25);
  --text: #e5eff0;
  --muted: #91a8ad;
  --subtle: #637d85;
  --teal: #63d4cb;
  --teal-soft: #2d8d91;
  --amber: #e4b06b;
  --coral: #ee8a70;
  --good: #78d5b0;
  --warning: #e7b26e;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  min-width: 320px;
  background:
    radial-gradient(ellipse at 50% -15%, rgba(33, 89, 102, 0.2), transparent 43%),
    linear-gradient(180deg, #08131e 0%, #07111c 58%, #060e17 100%);
}
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 28, 0.88);
  backdrop-filter: blur(18px);
  z-index: 10;
}
.brand-lockup { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border: 1px solid rgba(99, 212, 203, 0.52); border-radius: 11px;
  display: grid; place-items: center; position: relative; flex: 0 0 auto;
  background: linear-gradient(145deg, rgba(57, 151, 153, 0.22), rgba(15, 34, 46, 0.35));
  box-shadow: inset 0 0 18px rgba(69, 199, 191, 0.08), 0 0 24px rgba(49, 171, 169, 0.08);
}
.brand-mark span { position: absolute; width: 19px; height: 19px; border: 1.5px solid var(--teal); border-radius: 50%; opacity: 0.82; }
.brand-mark span:nth-child(2) { width: 12px; height: 12px; border-color: var(--amber); }
.brand-mark span:nth-child(3) { width: 4px; height: 4px; background: var(--coral); border: 0; }
.eyebrow, .section-kicker, .control-section-title, .readout-label, .hud-label, .timeline-meta, .status-model, .footer-note, .textbook-tag {
  font-size: 9px; letter-spacing: 0.14em; font-weight: 750;
}
.eyebrow { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.eyebrow-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 8px var(--teal); }
.brand-title { margin-top: 3px; font-size: 16px; font-weight: 680; letter-spacing: -0.025em; white-space: nowrap; }
.brand-subtitle { color: var(--muted); font-size: 12px; font-weight: 450; letter-spacing: 0; }
.topbar-meta { display: flex; align-items: center; gap: 8px; }
.field-chip, .seed-chip, .units-chip {
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 7px 10px;
  color: #a7c0c3; font-size: 9px; font-weight: 750; letter-spacing: 0.11em; white-space: nowrap;
  background: rgba(22, 43, 55, 0.54);
}
.field-chip { color: var(--teal); border-color: rgba(99, 212, 203, 0.25); background: rgba(39, 121, 121, 0.12); }
.icon-button { width: 29px; height: 29px; border: 1px solid var(--line-strong); border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }
.icon-button:hover, .tool-button:hover, .secondary-control:hover { border-color: rgba(99, 212, 203, 0.55); color: var(--text); }

.main-grid {
  width: 100%; max-width: 1920px; margin: 0 auto; padding: 14px 16px 10px;
  display: grid; grid-template-columns: 258px minmax(460px, 1fr) 274px; gap: 14px;
  align-items: stretch; flex: 1; min-height: 0;
}
.panel {
  min-width: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(155deg, rgba(17, 33, 47, 0.97), rgba(10, 22, 33, 0.97));
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.15), inset 0 1px rgba(255, 255, 255, 0.018);
}
.control-panel, .insight-panel { padding: 16px 15px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #294550 transparent; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.section-kicker { color: var(--teal); font-size: 8px; }
.panel-heading h2, .stage-heading h2 { margin: 5px 0 0; font-size: 15px; font-weight: 680; letter-spacing: -0.025em; }
.live-indicator { display: inline-flex; align-items: center; gap: 6px; color: var(--good); font-size: 8px; letter-spacing: 0.13em; font-weight: 800; }
.live-indicator i, .status-led, .hud-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--good); box-shadow: 0 0 10px rgba(120, 213, 176, 0.7); }
.field-label { display: block; margin-bottom: 7px; color: #b2c4c7; font-size: 10px; font-weight: 650; }
.select-control {
  width: 100%; padding: 10px 34px 10px 11px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: #101f2c; color: var(--text); font-size: 11px; cursor: pointer;
}
.micro-copy { margin: 7px 0 0; color: var(--subtle); font-size: 9px; line-height: 1.5; }
.control-divider { height: 1px; background: var(--line); margin: 15px 0 13px; }
.control-section-title { color: #76939a; font-size: 8px; margin-bottom: 14px; }
.slider-control { margin: 0 0 15px; }
.slider-heading { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.slider-heading label { color: #c4d4d5; font-size: 10px; font-weight: 580; }
.slider-heading output { color: var(--teal); font-size: 10px; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
input[type="range"] { width: 100%; height: 4px; appearance: none; border-radius: 99px; background: linear-gradient(90deg, #317f83, #24424d); cursor: pointer; display: block; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 13px; height: 13px; border: 2px solid #c6f1e8; border-radius: 50%; background: #4bb9b1; box-shadow: 0 0 0 4px rgba(75, 185, 177, 0.12), 0 0 12px rgba(75, 185, 177, 0.4); }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border: 2px solid #c6f1e8; border-radius: 50%; background: #4bb9b1; box-shadow: 0 0 0 4px rgba(75, 185, 177, 0.12); }
.range-ends { display: flex; justify-content: space-between; margin-top: 6px; color: #607a82; font-size: 8px; }
.speed-control { margin-bottom: 13px; }
.control-footnote { display: flex; align-items: flex-start; gap: 8px; color: #6e8990; font-size: 9px; line-height: 1.5; padding-top: 10px; border-top: 1px solid var(--line); }
.info-mark { flex: 0 0 auto; width: 14px; height: 14px; border: 1px solid #52757c; border-radius: 50%; display: grid; place-items: center; font-size: 8px; color: #8ab5b8; }

.stage-panel { display: flex; flex-direction: column; min-height: 610px; overflow: hidden; }
.stage-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 15px 12px; border-bottom: 1px solid var(--line); }
.stage-heading h2 { font-size: 14px; }
.stage-actions { display: flex; align-items: center; gap: 6px; }
.tool-button, .quality-button {
  min-height: 30px; padding: 0 9px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: rgba(17, 37, 49, 0.82); color: #a9c1c4;
  font-size: 9px; font-weight: 700; cursor: pointer; transition: border-color .18s ease, background .18s ease, color .18s ease;
}
.tool-button > span:first-child { font-size: 14px; line-height: 1; }
.quality-button { min-width: 48px; color: var(--teal); border-color: rgba(99, 212, 203, 0.28); font-size: 8px; letter-spacing: 0.1em; }
.scene-wrap { position: relative; flex: 1; min-height: 400px; background: radial-gradient(ellipse at 50% 48%, #102d3a 0%, #091a28 48%, #07131f 100%); overflow: hidden; }
.scene-host { position: absolute; inset: 0; overflow: hidden; }
.scene-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.scene-label-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.scene-label { padding: 5px 8px; border-radius: 5px; border: 1px solid rgba(104, 184, 181, 0.3); background: rgba(5, 17, 25, 0.78); color: #a6d6d3; font-size: 8px; font-weight: 800; letter-spacing: 0.12em; white-space: nowrap; text-shadow: 0 1px 6px #07111c; }
.scene-label-amber { color: #f0c486; border-color: rgba(228, 176, 107, 0.34); }
.scene-label-coral { color: #f0a28c; border-color: rgba(238, 138, 112, 0.36); }
.scene-hud { position: absolute; z-index: 3; pointer-events: none; display: flex; flex-direction: column; gap: 4px; }
.hud-top-left { top: 15px; left: 15px; }
.hud-label { color: #a7c4c5; font-size: 8px; }
.hud-sub { color: #5e7e87; font-size: 8px; letter-spacing: 0.1em; }
.hud-top-right { top: 16px; right: 16px; flex-direction: row; align-items: center; gap: 7px; color: #8ec7b2; font-size: 8px; letter-spacing: .12em; font-weight: 800; }
.hud-dot { width: 5px; height: 5px; }
.scene-legend { position: absolute; left: 14px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 13px; z-index: 4; pointer-events: none; padding: 7px 9px; border: 1px solid rgba(123, 169, 174, 0.14); border-radius: 8px; background: rgba(6, 17, 26, 0.62); backdrop-filter: blur(8px); }
.scene-legend span { display: inline-flex; align-items: center; gap: 6px; color: #92aeb1; font-size: 8px; }
.legend-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.legend-source { background: var(--coral); box-shadow: 0 0 8px var(--coral); }
.legend-front { background: var(--teal); box-shadow: 0 0 8px var(--teal); }
.legend-band { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.context-overlay { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: rgba(5, 14, 22, .92); text-align: center; }
.context-overlay[hidden], .interaction-hint[hidden], .science-panel[hidden] { display: none; }
.context-icon { width: 32px; height: 32px; border: 1px solid rgba(231, 178, 110, .5); border-radius: 50%; display: grid; place-items: center; color: var(--warning); font-weight: 800; }
.context-overlay strong { font-size: 13px; }
.context-overlay span { color: var(--muted); font-size: 10px; }
.interaction-hint { position: absolute; z-index: 7; right: 14px; top: 48px; width: min(270px, calc(100% - 28px)); padding: 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: rgba(7, 20, 29, .94); box-shadow: 0 12px 30px rgba(0,0,0,.28); display: flex; flex-direction: column; gap: 6px; }
.interaction-hint strong { font-size: 11px; }
.interaction-hint span { color: var(--muted); font-size: 9px; line-height: 1.45; }
.stage-controls { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 15px; border-top: 1px solid var(--line); background: rgba(9, 21, 31, 0.9); }
.transport-controls { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.primary-control, .secondary-control {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 0 11px;
  border-radius: 8px; cursor: pointer; font-size: 10px; font-weight: 750; transition: .18s ease;
}
.primary-control { color: #062326; background: linear-gradient(135deg, #80e1d4, #4cb9b5); border: 1px solid rgba(140, 241, 225, 0.62); box-shadow: 0 4px 18px rgba(54, 181, 173, .16); }
.primary-control:hover { filter: brightness(1.08); transform: translateY(-1px); }
.secondary-control { color: #b1c4c5; border: 1px solid var(--line-strong); background: #142532; }
.secondary-control:hover { border-color: rgba(99, 212, 203, .55); }
.button-icon { font-size: 13px; line-height: 1; }
.timeline-block { flex: 1; min-width: 100px; }
.timeline-meta { display: flex; justify-content: space-between; gap: 10px; color: #68858b; font-size: 8px; letter-spacing: .12em; margin-bottom: 8px; }
.timeline-meta span:last-child { color: #a6c0c2; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
.timeline-track { height: 4px; border-radius: 99px; background: #1b3541; overflow: hidden; }
.timeline-fill { width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #398f91, #e4b06b); box-shadow: 0 0 10px rgba(99, 212, 203, .35); transition: width .16s linear; }
.status-line { min-height: 30px; display: flex; align-items: center; gap: 8px; padding: 0 15px; color: #77969a; font-size: 8px; letter-spacing: .1em; border-top: 1px solid rgba(139, 184, 190, .08); }
.status-led { width: 5px; height: 5px; background: var(--teal); box-shadow: 0 0 8px rgba(99, 212, 203, .6); }
#status-text { flex: 1; }
#status-text[data-tone="success"] { color: var(--good); }
#status-text[data-tone="warning"] { color: var(--warning); }
.status-model { color: #526e77; font-size: 7px; white-space: nowrap; }

.units-chip { font-size: 8px; color: #87a6ab; padding: 6px 8px; }
.readout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.readout-card { min-width: 0; min-height: 82px; padding: 10px 9px 9px; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(145deg, rgba(20, 42, 54, .72), rgba(13, 28, 40, .74)); }
.readout-featured { grid-column: span 2; min-height: 72px; background: linear-gradient(110deg, rgba(34, 102, 102, .2), rgba(18, 43, 54, .72)); border-color: rgba(99, 212, 203, .22); }
.readout-label { display: block; color: #78959b; font-size: 7px; letter-spacing: .13em; line-height: 1.3; }
.readout-card strong { display: block; margin-top: 7px; color: #e4eeee; font-size: 15px; font-weight: 720; letter-spacing: -.035em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.readout-featured strong { color: var(--teal); font-size: 22px; margin-top: 4px; }
.readout-note { display: block; margin-top: 4px; color: #607c83; font-size: 8px; line-height: 1.35; }
.validation-card { margin-top: 12px; padding: 12px 11px 11px; border: 1px solid rgba(99, 212, 203, .17); border-radius: 11px; background: rgba(8, 24, 33, .64); }
.validation-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.textbook-tag { padding: 4px 6px; border-radius: 4px; color: var(--amber); border: 1px solid rgba(228, 176, 107, .3); font-size: 7px; }
.validation-card h3 { margin: 8px 0 10px; font-size: 11px; font-weight: 700; }
.validation-row, .validation-result { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 6px 0; color: #829ca1; font-size: 8px; }
.validation-row strong { color: #b9d1d1; font-size: 9px; font-variant-numeric: tabular-nums; }
.validation-result { padding-top: 8px; border-top: 1px solid var(--line); color: #b2c7c8; }
.validation-result strong { color: var(--good); font-size: 14px; font-variant-numeric: tabular-nums; }
.validation-status { display: inline-flex; margin-top: 5px; padding: 5px 7px; border-radius: 5px; color: var(--warning); background: rgba(231, 178, 110, .1); font-size: 7px; font-weight: 800; letter-spacing: .1em; }
.validation-status.is-pass { color: var(--good); background: rgba(120, 213, 176, .09); }
.validation-card .micro-copy { margin-top: 8px; }
.science-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 12px 1px 3px; margin-top: 10px; border: 0; border-top: 1px solid var(--line); background: transparent; color: #bfd1d2; text-align: left; cursor: pointer; font-size: 10px; font-weight: 700; }
.science-toggle span { color: var(--teal); font-size: 16px; }
.science-panel { padding-top: 8px; }
.science-block { padding: 10px 0; border-bottom: 1px solid rgba(139, 184, 190, .09); }
.science-block h4 { margin: 0 0 7px; color: #d1e0df; font-size: 9px; }
.equation { padding: 8px; border-radius: 7px; background: rgba(26, 57, 66, .5); color: #9ee0d8; font-family: Georgia, serif; font-size: 12px; text-align: center; overflow-wrap: anywhere; }
.science-block p { margin: 7px 0 0; color: #81999e; font-size: 8px; line-height: 1.55; }
.science-block p b { color: #b7d1cf; }
.model-caveat { display: inline-block; margin-top: 9px; color: var(--amber); font-size: 7px; letter-spacing: .08em; line-height: 1.5; }
.footer-note { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 21px 10px; color: #526d76; font-size: 7px; letter-spacing: .08em; font-weight: 600; }
.footer-note span:last-child { white-space: nowrap; }
.footer-note i { display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: #4b8990; margin: 0 5px 1px; }

@media (min-width: 1500px) {
  .main-grid { grid-template-columns: 285px minmax(500px, 1fr) 300px; gap: 16px; padding: 18px 20px 12px; }
  .control-panel, .insight-panel { padding: 18px; }
  .stage-panel { min-height: 680px; }
  .scene-wrap { min-height: 480px; }
}

@media (max-width: 1120px) {
  .main-grid { grid-template-columns: 238px minmax(400px, 1fr); }
  .insight-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1.2fr; gap: 12px 18px; align-items: start; }
  .insight-panel > .panel-heading { grid-column: 1 / -1; margin-bottom: 0; }
  .readout-grid { grid-column: 1; }
  .validation-card { grid-column: 2; grid-row: 2; margin-top: 0; }
  .science-toggle, .science-panel { grid-column: 1 / -1; }
  .control-panel { max-height: 780px; }
}

@media (max-width: 760px) {
  .topbar { min-height: 60px; padding: 8px 12px; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-title { font-size: 14px; }
  .brand-subtitle { display: none; }
  .eyebrow { font-size: 7px; }
  .topbar-meta { gap: 5px; }
  .field-chip, .seed-chip { padding: 6px 7px; font-size: 7px; }
  .icon-button { width: 27px; height: 27px; }
  .main-grid { display: flex; flex-direction: column; gap: 10px; padding: 10px; }
  .stage-panel { order: 0; min-height: 0; }
  .control-panel { order: 1; max-height: none; overflow: visible; }
  .insight-panel { order: 2; display: block; }
  .stage-toolbar { padding: 11px 11px 10px; }
  .stage-heading h2 { font-size: 12px; }
  .stage-actions { gap: 4px; }
  .tool-button, .quality-button { min-height: 29px; padding: 0 7px; }
  .button-word { display: none; }
  .scene-wrap { min-height: 430px; height: 430px; }
  .scene-legend { left: 8px; bottom: 8px; gap: 8px; padding: 6px 7px; }
  .scene-legend span { font-size: 7px; }
  .stage-controls { align-items: stretch; flex-direction: column; gap: 11px; padding: 10px 11px; }
  .transport-controls { justify-content: space-between; }
  .transport-controls button { flex: 1; }
  .timeline-block { width: 100%; }
  .status-line { padding: 0 10px; }
  .status-model { display: none; }
  .control-panel, .insight-panel { padding: 14px; }
  .control-panel .slider-control { margin-bottom: 17px; }
  .insight-panel > .panel-heading { margin-bottom: 13px; }
  .readout-grid { grid-template-columns: 1fr 1fr; }
  .validation-card { margin-top: 12px; }
  .footer-note { padding: 2px 12px 10px; flex-direction: column; align-items: flex-start; font-size: 7px; }
}

@media (max-width: 390px) {
  .topbar-meta .seed-chip { display: none; }
  .brand-title { font-size: 13px; }
  .scene-wrap { height: 405px; min-height: 405px; }
  .scene-hud .hud-sub { font-size: 7px; }
  .readout-card strong { font-size: 13px; }
  .readout-featured strong { font-size: 20px; }
  .scene-legend { max-width: calc(100% - 16px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

.embed-mode .topbar, .embed-mode .footer-note, .embed-mode .insight-panel { display: none; }
.embed-mode .main-grid { grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; padding: 10px; }
.embed-mode .stage-panel { min-height: calc(100vh - 20px); }
.embed-mode .scene-wrap { min-height: 420px; }
@media (max-width: 760px) {
  .embed-mode .main-grid { display: flex; min-height: 100vh; }
  .embed-mode .stage-panel { min-height: 0; }
  .embed-mode .scene-wrap { min-height: 430px; }
}
