:root {
  color-scheme: dark;
  --bg: #071319;
  --panel: rgba(12, 28, 34, 0.88);
  --panel-strong: rgba(16, 42, 50, 0.96);
  --line: rgba(157, 216, 210, 0.22);
  --text: #ecf7f4;
  --muted: #9fb8b2;
  --aqua: #4dd7c4;
  --gold: #f2bd57;
  --blue: #6aa8ff;
  --red: #f0746e;
  --green: #83d17b;
  --clay: #c8845a;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 22% 18%, rgba(77, 215, 196, 0.18), transparent 30%),
    linear-gradient(135deg, #061015 0%, #10282b 48%, #1b2c2b 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar,
.workspace,
.stage-panel,
.catalog-panel,
.control-panel,
.data-panel,
.data-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 18px;
  align-items: center;
  border-radius: 8px;
  padding: 16px 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--aqua);
  font-size: 12px;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.lab-tabs,
.chip-row,
.view-strip,
.segmented,
.speed-row,
.module-ribbon,
.draw-tools,
.fan-cycle-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.lab-tab,
.chip,
.ghost-button,
.view-strip button,
.segmented button,
.speed-row button,
.module-ribbon button,
.draw-tools button,
.fan-cycle-buttons button,
.button-grid button,
.compare-switch button {
  min-height: 34px;
  border: 1px solid rgba(157, 216, 210, 0.24);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.lab-tab {
  flex: 1 1 132px;
  padding: 8px 10px;
}

button.is-active,
.lab-tab.is-active,
.chip.is-active,
.experiment-card.is-active {
  border-color: var(--aqua);
  background: rgba(77, 215, 196, 0.16);
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(560px, 1fr) 320px;
  gap: 14px;
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(6, 20, 26, 0.68);
}

.catalog-panel,
.stage-panel,
.control-panel {
  min-height: calc(100vh - 130px);
  border-radius: 8px;
  overflow: hidden;
}

.catalog-panel,
.control-panel {
  padding: 14px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.section-title strong {
  color: var(--gold);
}

.catalog-grid {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 260px);
  overflow: auto;
  padding-right: 4px;
}

.experiment-card {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 88px;
  padding: 11px;
  border: 1px solid rgba(157, 216, 210, 0.16);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  text-align: left;
}

.experiment-card span,
.experiment-card small,
.panel-note,
.control-caption,
.metric-grid span,
.data-card span {
  color: var(--muted);
  font-size: 12px;
}

.stage-panel {
  display: grid;
  grid-template-rows: auto auto minmax(360px, 1fr) auto;
  padding: 14px;
  background: rgba(8, 23, 29, 0.82);
  overflow: auto;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.lab-stage {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid rgba(157, 216, 210, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,0)),
    #07161d;
}

.lab-visual {
  position: relative;
  min-height: 360px;
  padding: 14px;
}

.protocol-panel {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(77, 215, 196, 0.24);
  border-radius: 8px;
  background: rgba(77, 215, 196, 0.07);
}

.protocol-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.protocol-header h3 {
  margin: 0;
  font-size: 17px;
}

.protocol-header span {
  max-width: 360px;
  color: var(--gold);
  font-size: 13px;
  text-align: right;
}

.protocol-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.protocol-grid article {
  padding: 10px;
  border: 1px solid rgba(157, 216, 210, 0.14);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
}

.protocol-grid strong {
  display: block;
  margin-bottom: 5px;
  color: var(--aqua);
}

.protocol-grid p,
.protocol-grid li {
  margin: 0 0 7px;
  color: #d7e5e1;
  font-size: 13px;
  line-height: 1.5;
}

.protocol-grid ul {
  margin: 0;
  padding-left: 18px;
}

.record-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.record-grid span {
  padding: 5px 8px;
  border: 1px solid rgba(242, 189, 87, 0.3);
  border-radius: 999px;
  color: #ffe0a6;
  font-size: 12px;
  background: rgba(242, 189, 87, 0.08);
}

.view-strip {
  position: relative;
  z-index: 4;
  margin-bottom: 10px;
}

.solar-scenes,
.cyclone-board,
.earth-system,
.glacier-board,
.fan-board {
  position: relative;
  min-height: 310px;
}

.solar-dome,
.cosmic-scene,
.fan-plan,
.fan-profile {
  display: none;
}

.solar-dome.is-active,
.cosmic-scene.is-active,
.fan-board.plan .fan-plan,
.fan-board.profile .fan-profile {
  display: block;
}

.solar-dome,
.orbit-overlay,
.cyclone-overlay,
.jet-overlay,
.glacier-svg,
.fan-plan,
.fan-profile {
  width: 100%;
  height: 310px;
}

.sun-dot {
  filter: drop-shadow(0 0 18px rgba(255, 215, 107, 0.75));
}

.lab-visual svg text {
  fill: var(--text);
  paint-order: stroke;
  stroke: rgba(5, 16, 20, 0.72);
  stroke-width: 3px;
  stroke-linejoin: round;
  font-weight: 700;
}

.cosmic-scene {
  height: 350px;
}

.solar-cosmic-svg {
  width: 100%;
  height: 310px;
}

.earth-orbit {
  position: relative;
  height: 100%;
  perspective: 900px;
}

.sun-orb {
  position: absolute;
  left: 38px;
  top: 120px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffe38b, #e98a3a);
  box-shadow: 0 0 54px rgba(242, 189, 87, 0.56);
}

.earth-3d {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 210px;
  height: 210px;
  transform-style: preserve-3d;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 28%, rgba(255,255,255,.36), transparent 18%),
    linear-gradient(120deg, #1a7695, #315f45 42%, #163c67 70%);
  box-shadow: inset -24px -20px 44px rgba(0,0,0,.38), 0 24px 60px rgba(0,0,0,.38);
}

.observer-pin,
.terminator {
  position: absolute;
  border-radius: 999px;
}

.observer-pin {
  left: 96px;
  width: 14px;
  height: 14px;
  background: var(--gold);
}

.terminator {
  inset: 0 0 0 50%;
  background: rgba(0,0,0,.28);
}

#lab-canvas,
#drawing-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#drawing-canvas {
  z-index: 3;
  touch-action: none;
}

.cyclone-model {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 250px;
  height: 250px;
  transform: translate(-50%, -50%) rotateX(62deg);
  transform-style: preserve-3d;
}

.cloud-ring {
  position: absolute;
  inset: 20px;
  border: 22px solid rgba(235,247,255,.42);
  border-top-color: rgba(242,189,87,.74);
  border-radius: 50%;
  animation: spin 10s linear infinite;
  animation-direction: reverse;
}

.ring-two {
  inset: 58px;
  border-width: 16px;
  animation-duration: 6s;
}

.pressure-core,
.vertical-column {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

.pressure-core {
  top: 95px;
  width: 120px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(6, 19, 24, .78);
}

.vertical-column {
  top: -16px;
  width: 210px;
  color: var(--gold);
}

.cyclone-overlay,
.jet-overlay,
.glacier-svg,
.fan-plan,
.fan-profile {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.subhigh-path {
  fill: none;
  stroke: var(--gold);
  stroke-width: 5;
  stroke-dasharray: 12 8;
}

.subhigh-path.east {
  d: path("M120 300 C230 180 370 150 610 120");
}

.subhigh-path.split {
  d: path("M80 260 C190 150 290 192 390 122 C470 66 560 110 626 72");
}

.drag-hint {
  color: var(--muted);
  margin-bottom: 8px;
}

.earth-system {
  perspective: 900px;
}

.circulation-earth {
  transform: translate(-50%, -50%) rotateX(var(--rx)) rotateY(var(--ry));
}

.belt,
.cell-loop {
  position: absolute;
  left: 10%;
  right: 10%;
  min-height: 26px;
  border: 2px solid rgba(255,255,255,.24);
  border-radius: 50%;
  text-align: center;
  font-size: 12px;
}

.equatorial { top: calc(48% + var(--shift)); color: var(--red); }
.north-high { top: calc(31% + var(--shift)); color: var(--gold); }
.south-high { top: calc(65% + var(--shift)); color: var(--gold); }
.cell-loop.hadley { top: 39%; border-color: var(--aqua); }
.cell-loop.ferrel { top: 25%; border-color: var(--gold); }
.cell-loop.polar { top: 12%; border-color: var(--blue); }

.jet-overlay path {
  fill: none;
  stroke: var(--blue);
  stroke-width: 4;
  opacity: .92;
}

.module-ribbon {
  margin-bottom: 10px;
}

.glacier-board {
  background: linear-gradient(#163b47, #26343a);
  border-radius: 8px;
}

.fan-board {
  background: linear-gradient(180deg, #273b35, #1e2828);
  border-radius: 8px;
}

.fan-experiment-panels {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.fan-zone-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.fan-zone-card,
.fan-cycle {
  display: grid;
  gap: 5px;
  padding: 9px;
  border: 1px solid rgba(157, 216, 210, 0.18);
  border-radius: 8px;
  background: rgba(4, 14, 18, 0.68);
}

.fan-zone-card strong,
.fan-cycle strong {
  color: var(--aqua);
}

.fan-zone-card span,
.fan-cycle span {
  color: #d7e5e1;
  font-size: 12px;
  line-height: 1.35;
}

.fan-cycle-buttons {
  gap: 6px;
}

.fan-cycle-buttons button {
  min-height: 30px;
  padding: 5px 7px;
  font-size: 12px;
}

.fan-cycle.is-progradation {
  border-color: rgba(240, 154, 68, 0.42);
}

.fan-cycle.is-retrogradation {
  border-color: rgba(74, 163, 255, 0.46);
}

.spring-pulse {
  fill: #62b7ff;
  animation: pulse 1.6s ease-in-out infinite;
}

.control-panel {
  overflow: auto;
}

.control-group {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.control-group label,
.speed-row span,
.draw-tools span {
  color: var(--muted);
  font-size: 13px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--aqua);
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.button-grid .control-caption {
  grid-column: 1 / -1;
}

.check-list {
  display: grid;
  gap: 9px;
  margin-bottom: 14px;
}

.compare-switch {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.data-panel {
  display: grid;
  grid-template-columns: minmax(360px, 1.6fr) 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
}

.data-card {
  padding: 12px;
  border-radius: 8px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
}

.metric-grid div {
  display: grid;
  gap: 4px;
  padding: 9px;
  border: 1px solid rgba(157, 216, 210, 0.14);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
}

.metric-grid.compact {
  grid-template-columns: repeat(2, minmax(90px, 1fr));
}

.fan-data-columns {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.fan-data-columns h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.trend-panel {
  margin-top: 10px;
  color: var(--gold);
}

@keyframes spin {
  to { transform: rotate(calc(var(--spin, 1) * 360deg)); }
}

@keyframes pulse {
  0%, 100% { r: 7; opacity: .55; }
  50% { r: 15; opacity: 1; }
}
