:root {
  color-scheme: dark;
  --bg: #061019;
  --line: rgba(184, 214, 230, 0.15);
  --text: #eff8fb;
  --muted: #8ea5b3;
  --red: #ff3d4f;
  --blue: #3ca8ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }

#app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 640px;
  isolation: isolate;
  background:
    radial-gradient(circle at 35% 42%, rgba(32, 92, 124, 0.14), transparent 38%),
    radial-gradient(circle at 62% 35%, rgba(167, 32, 52, 0.08), transparent 28%),
    #061019;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.backdrop-grid {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(132, 186, 213, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(132, 186, 213, 0.05) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at 38% 46%, #000 0 38%, transparent 72%);
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  box-shadow: inset 0 0 180px 40px rgba(0, 0, 0, 0.38);
  background: linear-gradient(180deg, rgba(2, 8, 13, 0.36), transparent 22%, transparent 72%, rgba(2, 8, 13, 0.44));
}

.glass-panel {
  position: absolute;
  z-index: 8;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(13, 27, 39, 0.85), rgba(7, 16, 25, 0.68));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28), inset 0 1px rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(18px) saturate(120%);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
}

.eyebrow {
  margin: 0 0 8px;
  color: #7da0b2;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

.hero-copy {
  position: absolute;
  top: 38px;
  left: 42px;
  z-index: 9;
  width: min(470px, 38vw);
  pointer-events: none;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(40px, 4.1vw, 70px);
  line-height: 0.94;
  letter-spacing: -0.055em;
  font-weight: 720;
}

.hero-copy h1 span {
  color: transparent;
  -webkit-text-stroke: 1px rgba(231, 245, 250, 0.7);
  font-weight: 530;
}

.lede {
  width: 440px;
  max-width: 100%;
  margin: 16px 0 14px;
  color: #a8bdc8;
  font-size: 13px;
  line-height: 1.72;
}

.hero-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.hero-tags span {
  padding: 5px 9px;
  border: 1px solid rgba(154, 203, 226, 0.16);
  border-radius: 999px;
  color: #9eb7c4;
  background: rgba(11, 22, 31, 0.34);
  font-size: 10px;
}

.mode-switch {
  top: 38px;
  left: 50%;
  transform: translateX(-50%);
  width: 292px;
  padding: 11px 12px 12px;
  border-radius: 14px;
}

.mode-switch .eyebrow { margin: 0 0 6px 3px; }
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.24);
}
.segmented button {
  border: 0;
  border-radius: 8px;
  padding: 8px 9px;
  background: transparent;
  color: #7f98a5;
  font-size: 11px;
  cursor: pointer;
  transition: 180ms ease;
}
.segmented button.is-active {
  color: #f4fbff;
  background: rgba(80, 132, 158, 0.25);
  box-shadow: inset 0 0 0 1px rgba(154, 213, 239, 0.13);
}

.spectrum-panel {
  top: 38px;
  right: 36px;
  width: min(470px, 34vw);
  padding: 18px 18px 14px;
  border-radius: 20px;
}

.panel-heading,
.control-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading h2,
.control-title h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 620;
  letter-spacing: -0.03em;
}
.panel-heading h2 span { color: #92adbb; font-weight: 450; }

.icon-button {
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(15, 32, 45, 0.75);
  cursor: pointer;
}
.pause-glyph {
  width: 11px;
  height: 12px;
  display: block;
  border-left: 3px solid #c9dbe3;
  border-right: 3px solid #c9dbe3;
}
.icon-button:not(.is-playing) .pause-glyph {
  width: 0;
  height: 0;
  border: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid #c9dbe3;
  margin-left: 2px;
}

.chart-wrap { position: relative; height: 230px; margin: 12px -4px 4px; }
#spectrumChart { width: 100%; height: 100%; display: block; }
.chart-legend {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 10px;
  color: #8099a6;
  font-size: 9px;
}
.chart-legend span { display: flex; align-items: center; gap: 5px; }
.chart-legend i { width: 14px; height: 2px; display: inline-block; }
.legend-total { background: var(--red); box-shadow: 0 0 8px rgba(255, 61, 79, 0.55); }
.legend-component { background: #a4b1b8; opacity: 0.7; }

.spectrum-readout {
  display: grid;
  grid-template-columns: 1.05fr repeat(3, 0.8fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--line);
}
.spectrum-readout > div { min-width: 0; padding: 9px 10px 8px; background: rgba(5, 13, 20, 0.62); }
.spectrum-readout small { display: block; color: #6f8b9a; font-size: 9px; letter-spacing: 0.08em; }
.spectrum-readout strong { display: block; margin-top: 4px; color: #eef8fb; font-size: 15px; font-variant-numeric: tabular-nums; }
.spectrum-readout em { color: #7290a0; font-size: 9px; font-style: normal; }

.oscillator-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-top: 9px; }
.oscillator-item {
  min-width: 0;
  padding: 6px 7px;
  border-radius: 8px;
  background: rgba(5, 13, 20, 0.45);
  border: 1px solid rgba(159, 199, 220, 0.09);
}
.oscillator-item small { display: block; color: #65808f; font-size: 8px; }
.oscillator-item strong { display: block; margin-top: 2px; color: #b5c7d0; font-size: 10px; font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oscillator-item.is-dominant { border-color: rgba(255, 61, 79, 0.26); background: rgba(129, 28, 40, 0.13); }
.oscillator-item.is-dominant strong { color: #ff8892; }

.control-panel {
  left: 38px;
  bottom: 44px;
  width: 350px;
  padding: 16px 16px 15px;
  border-radius: 18px;
}
.text-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(14, 31, 43, 0.54);
  color: #9db3bf;
  font-size: 10px;
  cursor: pointer;
}

.range-control { display: block; margin-top: 13px; }
.range-control > span { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #99afba; font-size: 10px; }
.range-control strong { color: #c3d4dc; font-weight: 570; }
.range-control output { color: #f2f9fc; font-variant-numeric: tabular-nums; }
.range-control input {
  width: 100%;
  height: 4px;
  margin: 10px 0 0;
  border-radius: 999px;
  appearance: none;
  background: linear-gradient(90deg, #547689, #db384a);
  outline: none;
}
.range-control input::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  appearance: none;
  border: 2px solid #0c1720;
  background: #f3fbff;
  box-shadow: 0 0 0 1px rgba(163, 208, 230, 0.5), 0 0 13px rgba(123, 207, 244, 0.2);
  cursor: ew-resize;
}
.range-control input::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid #0c1720;
  background: #f3fbff;
  cursor: ew-resize;
}
.range-scale { display: flex; justify-content: space-between; margin-top: 3px; color: #536e7d; font-size: 8px; font-style: normal; }
.range-scale b { font-weight: 500; }

.physics-metric {
  display: grid;
  grid-template-columns: 5px 1fr;
  gap: 11px;
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.heat-gauge { position: relative; width: 5px; height: 68px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, 0.07); }
.heat-gauge i {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 35%;
  border-radius: inherit;
  background: linear-gradient(0deg, #ff3146, #ff9f77);
  box-shadow: 0 0 15px rgba(255, 65, 80, 0.45);
  transition: height 120ms linear;
}
.physics-metric small { display: block; color: #6f8794; font-size: 8px; letter-spacing: 0.09em; }
.physics-metric strong { display: block; margin: 3px 0 2px; color: #ff8e98; font-size: 22px; font-weight: 590; font-variant-numeric: tabular-nums; }
.physics-metric p { margin: 0; color: #68818e; font-size: 9px; line-height: 1.55; }

.formula-panel {
  right: 38px;
  bottom: 44px;
  width: min(560px, 40vw);
  padding: 13px 15px 12px;
  border-radius: 16px;
}
.formula-panel .eyebrow { margin-bottom: 6px; }
.formula {
  color: #aec2cc;
  font-family: "Merriweather", serif;
  font-size: 13px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.formula span { color: #eef8fb; }
.parameter-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 8px; }
.parameter-row > span { padding-top: 7px; border-top: 1px solid rgba(163, 203, 223, 0.1); }
.parameter-row small { display: block; color: #67808d; font-size: 8px; }
.parameter-row strong { display: block; margin-top: 3px; color: #aebfc8; font-size: 10px; font-weight: 550; }

.scene-label {
  position: absolute;
  z-index: 7;
  min-width: 112px;
  padding: 7px 9px 7px 11px;
  border-left: 1px solid rgba(149, 204, 230, 0.38);
  color: #a7bbc5;
  background: linear-gradient(90deg, rgba(6, 16, 25, 0.77), rgba(6, 16, 25, 0));
  pointer-events: none;
  transform: translate(10px, -50%);
  opacity: 0;
  transition: opacity 180ms ease;
}
.scene-label.is-visible { opacity: 1; }
.scene-label i {
  position: absolute;
  left: -4px;
  top: 50%;
  width: 7px;
  height: 7px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: #85dfff;
  box-shadow: 0 0 11px rgba(75, 197, 255, 0.7);
}
.scene-label strong { display: block; color: #d3e2e8; font-size: 10px; font-weight: 600; }
.scene-label small { display: block; margin-top: 2px; color: #69818e; font-size: 8px; }
.label-dsp i { background: #ff6876; box-shadow: 0 0 11px rgba(255, 64, 80, 0.65); }
.label-spsp i { background: #b7c5cc; box-shadow: 0 0 11px rgba(210, 230, 239, 0.45); }

.interaction-hint {
  position: absolute;
  left: 50%;
  bottom: 17px;
  z-index: 8;
  transform: translateX(-50%);
  margin: 0;
  color: #536f7e;
  font-size: 9px;
  white-space: nowrap;
  pointer-events: none;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 15px;
  background: #061019;
  transition: opacity 450ms ease, visibility 450ms ease;
}
.loading-overlay.is-hidden { opacity: 0; visibility: hidden; }
.loading-overlay p { margin: 0; color: #718d9c; font-size: 11px; letter-spacing: 0.04em; }
.loader-orbit { position: relative; width: 64px; height: 64px; animation: spin 2.4s linear infinite; }
.loader-orbit::before,
.loader-orbit::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(104, 204, 245, 0.28);
  border-radius: 50%;
  transform: rotateX(62deg);
}
.loader-orbit::after { transform: rotateY(62deg); border-color: rgba(255, 76, 92, 0.25); }
.loader-orbit i { position: absolute; top: 50%; left: 50%; width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: #dceaf0; box-shadow: 0 0 14px rgba(156, 221, 247, 0.65); }
.loader-orbit i:nth-child(2) { transform: translateX(25px); background: #52bfff; }
.loader-orbit i:nth-child(3) { transform: translateX(-25px); background: #ff4859; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-panel {
  position: absolute;
  inset: auto 50% 50% auto;
  z-index: 50;
  width: min(520px, 86vw);
  transform: translate(50%, 50%);
  padding: 24px;
  border: 1px solid rgba(255, 89, 103, 0.25);
  border-radius: 16px;
  background: rgba(30, 8, 13, 0.94);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.error-panel h2 { margin: 0 0 8px; font-size: 18px; }
.error-panel p { margin: 0; color: #d19aa2; font-size: 12px; line-height: 1.6; }

@media (max-width: 1180px) {
  .hero-copy { width: 36vw; }
  .hero-copy .lede { font-size: 12px; }
  .spectrum-panel { width: 38vw; }
  .formula-panel { width: 43vw; }
  .mode-switch { top: 18px; }
}

@media (max-width: 900px) {
  html, body { overflow: auto; }
  #app { height: 1120px; min-height: 1120px; }
  .hero-copy { top: 26px; left: 24px; width: calc(100% - 48px); }
  .hero-copy h1 { font-size: 45px; }
  .hero-copy .lede { width: 520px; }
  .mode-switch { top: 196px; left: 24px; transform: none; width: 270px; }
  .spectrum-panel { top: 620px; right: 24px; left: 24px; width: auto; }
  .control-panel { left: 24px; bottom: 230px; width: 340px; }
  .formula-panel { right: 24px; bottom: 88px; width: calc(100% - 48px); }
  .interaction-hint { bottom: 28px; }
  .chart-wrap { height: 210px; }
}

@media (max-width: 600px) {
  #app { height: 1260px; min-height: 1260px; }
  .hero-copy h1 { font-size: 38px; }
  .hero-copy .lede { font-size: 11px; }
  .mode-switch { top: 218px; width: calc(100% - 48px); }
  .control-panel { left: 20px; right: 20px; bottom: 355px; width: auto; }
  .spectrum-panel { top: 690px; right: 20px; left: 20px; padding: 14px; }
  .formula-panel { right: 20px; bottom: 98px; width: calc(100% - 40px); }
  .parameter-row { grid-template-columns: 1fr; }
  .spectrum-readout { grid-template-columns: repeat(2, 1fr); }
  .oscillator-strip { grid-template-columns: repeat(3, 1fr); }
  .chart-legend { display: none; }
}
