:root {
  --bg-deep: #050810;
  --bg-panel: rgba(8, 18, 32, 0.82);
  --border: rgba(0, 212, 255, 0.22);
  --accent: #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.45);
  --accent-warm: #ff6b35;
  --accent-hot: #ff8c42;
  --accent-cold: #6eb5ff;
  --text: #e8f4fc;
  --text-muted: #7a9bb8;
  --glow: 0 0 24px rgba(0, 212, 255, 0.15);
  --font-display: "Orbitron", sans-serif;
  --font-body: "Noto Sans SC", sans-serif;
  --panel-width: 280px;
  --radius: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 70% 20%, rgba(0, 100, 180, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 20% 80%, rgba(0, 212, 255, 0.06), transparent),
    radial-gradient(1px 1px at 10% 20%, rgba(255, 255, 255, 0.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 80% 40%, rgba(255, 255, 255, 0.25) 50%, transparent 51%),
    radial-gradient(1px 1px at 45% 75%, rgba(255, 255, 255, 0.2) 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 88%, rgba(255, 255, 255, 0.3) 50%, transparent 51%);
  pointer-events: none;
  z-index: 0;
}

.app {
  display: grid;
  grid-template-columns: var(--panel-width) 1fr;
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}

.app.panel-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

/* —— 左侧控制面板（固定宽度；防止长选项撑宽） —— */
.panel-column {
  position: relative;
  width: var(--panel-width);
  max-width: var(--panel-width);
  flex-shrink: 0;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  transition: width 0.22s ease, max-width 0.22s ease;
}

.app.panel-collapsed .panel-column {
  width: 0;
  max-width: 0;
  min-width: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  padding: 0;
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  box-shadow: var(--glow);
  border-right: 1px solid var(--border);
  overflow: hidden;
  transition: opacity 0.18s ease, border-color 0.22s ease;
}

.app.panel-collapsed .panel {
  border-right-color: transparent;
  opacity: 0;
  pointer-events: none;
}

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) transparent;
}

.app.panel-collapsed .panel-body {
  display: none;
}

.panel-header {
  flex-shrink: 0;
  padding: 18px 14px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(
    165deg,
    rgba(0, 212, 255, 0.14) 0%,
    rgba(0, 100, 160, 0.06) 45%,
    transparent 100%
  );
  box-shadow: inset 0 -1px 0 rgba(0, 212, 255, 0.1);
}

.panel-title {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.4;
  min-width: 0;
  color: #f2fbff;
  text-shadow:
    0 0 14px rgba(0, 212, 255, 0.65),
    0 0 32px rgba(0, 212, 255, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.45);
}

.panel-title-mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.22em;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 0 0.1em;
  vertical-align: -0.02em;
  text-shadow:
    0 0 18px rgba(0, 212, 255, 0.95),
    0 0 36px rgba(0, 212, 255, 0.45);
}

.section-label {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin: 0 0 8px;
  opacity: 0.9;
}

.panel-body > .control-group {
  margin: 0 10px;
  padding: 10px 10px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 20, 40, 0.5);
  min-width: 0;
  overflow: hidden;
}

.panel-body > .control-group.is-hidden {
  display: none;
}

#surfaceTempControls .temp-label-b {
  margin-top: 10px;
}

.panel-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 6px 32px 6px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(0, 40, 70, 0.5);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.82rem;
  line-height: 1.25;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2300d4ff' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.panel-select:hover,
.panel-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.15);
}

.panel-select option {
  background: #0a1828;
  color: var(--text);
}

.panel-range-full {
  width: 100%;
}

.control-group-layers .layer-checkboxes > label {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-muted);
  font-family: var(--font-body);
  cursor: pointer;
}

.control-group input[type="checkbox"] {
  width: auto;
  margin-right: 0;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--accent);
}

.control-group-layers .layer-checkboxes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px 10px;
  margin-top: 0;
}

input[type="range"] {
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0, 212, 255, 0.2);
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  cursor: pointer;
  border: none;
}

.panel-toggle-btn {
  position: absolute;
  left: 100%;
  top: 50%;
  z-index: 20;
  transform: translateY(-50%);
  box-sizing: border-box;
  width: 28px;
  height: 52px;
  padding: 0;
  margin: 0;
  font-size: 13px;
  line-height: 1;
  border-radius: 0 8px 8px 0;
  border: 1px solid var(--border);
  border-left: none;
  background: rgba(8, 18, 32, 0.95);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  box-shadow: 4px 0 16px rgba(0, 0, 0, 0.35);
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.panel-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 212, 255, 0.12);
  box-shadow: 4px 0 20px rgba(0, 212, 255, 0.2);
}

.panel-toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.copyright-entry {
  flex-shrink: 0;
  margin-top: auto;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(0, 212, 255, 0.35);
  background: linear-gradient(
    180deg,
    rgba(0, 212, 255, 0.06) 0%,
    rgba(0, 50, 90, 0.28) 100%
  );
  box-shadow: inset 0 1px 0 rgba(0, 212, 255, 0.12);
}

.app.panel-collapsed .copyright-entry {
  display: none;
}

.copyright-text-btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 0.82rem;
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.1em;
  color: #e8fcff;
  background: linear-gradient(
    135deg,
    rgba(0, 212, 255, 0.22) 0%,
    rgba(0, 100, 170, 0.32) 55%,
    rgba(0, 60, 110, 0.38) 100%
  );
  border: 1px solid rgba(0, 212, 255, 0.5);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  text-shadow: 0 0 14px rgba(0, 212, 255, 0.45);
  box-shadow:
    0 0 18px rgba(0, 212, 255, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s,
    box-shadow 0.2s,
    transform 0.15s;
}

.copyright-text-btn:hover {
  color: #fff;
  border-color: var(--accent);
  background: linear-gradient(
    135deg,
    rgba(0, 212, 255, 0.35) 0%,
    rgba(0, 120, 190, 0.42) 100%
  );
  box-shadow:
    0 0 28px rgba(0, 212, 255, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.copyright-text-btn:active {
  transform: scale(0.98);
}

.copyright-text-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* —— 模态框 —— */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-dialog {
  width: 100%;
  max-width: 380px;
  padding: 18px 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, #0a1428 0%, #050a14 100%);
  border: 1px solid rgba(0, 212, 255, 0.35);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  color: var(--text);
}

.copyright-modal {
  max-width: 440px;
}

.modal-title {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 600;
  color: #b8d4ff;
  text-align: center;
}

.copyright-qr-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 14px 16px;
  margin-bottom: 14px;
}

.copyright-qr-item {
  margin: 0;
  flex: 1 1 150px;
  max-width: 200px;
  min-width: 0;
  text-align: center;
}

.copyright-qr-caption {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-muted);
}

.copyright-qr-image {
  display: block;
  width: 100%;
  max-width: 200px;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid rgba(0, 212, 255, 0.35);
}

.copyright-note {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: #c8d6ff;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: center;
}

.modal-btn {
  padding: 8px 18px;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid rgba(0, 212, 255, 0.45);
  background: rgba(0, 40, 70, 0.5);
  color: var(--text);
  font-family: inherit;
}

.modal-btn:hover {
  background: rgba(0, 212, 255, 0.12);
  border-color: var(--accent);
}

.modal-btn-primary {
  border-color: var(--accent);
  background: rgba(0, 100, 170, 0.45);
}

/* —— 动画区域 —— */
.stage-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  background: #0d1520;
}

.stage-inner {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

.diagram-stack {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.85rem 0.4rem;
  gap: 0.45rem;
}

#diagram-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#diagram-wrap svg {
  max-width: 92%;
  max-height: 90%;
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.35));
}

.sea-land-controls {
  flex-shrink: 0;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.sea-land-controls.is-hidden {
  display: none;
}

.sea-land-btn {
  padding: 5px 12px;
  font-size: 0.75rem;
  font-family: var(--font-body);
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 30, 50, 0.5);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.sea-land-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.sea-land-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(0, 212, 255, 0.1);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.12);
}

.knowledge-box,
.stage-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(5, 15, 28, 0.88);
  backdrop-filter: blur(8px);
  box-shadow: var(--glow);
}

.stage-text-stack {
  position: absolute;
  left: 16px;
  top: 14px;
  max-width: min(calc(100% - 140px), 860px);
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
}

.collapsible-box {
  max-width: 100%;
  padding: 10px 12px;
}

.stage-knowledge.collapsed .collapsible-content {
  display: none;
}

.collapsible-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.collapsible-head-title {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-weight: 600;
}

.collapse-btn,
.collapsible-head-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.72rem;
  font-family: var(--font-body);
  white-space: nowrap;
  padding: 2px 4px;
  transition: color 0.2s;
}

.collapse-btn:hover,
.collapsible-head-btn:hover {
  color: var(--text);
}

.stage-card-body {
  padding: 8px 0 0;
  font-size: 0.78rem;
  line-height: 1.65;
  color: var(--text-muted);
  max-height: min(280px, 38vh);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) transparent;
}

.stage-card-body strong {
  color: var(--text);
}

.stage-card-body p {
  margin: 0 0 0.55rem;
}

.stage-card-body p:last-child {
  margin-bottom: 0;
}

.stage-tool-btn {
  position: absolute;
  top: 14px;
  z-index: 20;
  font-family: var(--font-body);
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: rgba(5, 15, 28, 0.88);
  border: 1px solid var(--border);
  border-radius: 6px;
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.stage-tool-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 212, 255, 0.12);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.15);
}

.stage-tool-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stage-reset-btn {
  right: 126px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.stage-fullscreen-btn {
  right: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  padding: 6px 12px;
  font-size: 0.72rem;
}

.stage-data {
  display: none;
  position: absolute;
  bottom: 12px;
  right: 16px;
  width: 210px;
  z-index: 3;
  padding: 10px 12px;
}

.stage-data .stage-card-header {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 6px;
}

.stage-data .stage-card-body {
  max-height: none;
  padding: 0;
  font-size: 0.75rem;
}

.stage-data ul {
  list-style: none;
  padding: 0;
}

.stage-data li {
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(0, 212, 255, 0.12);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.stage-data li:last-child {
  border-bottom: none;
}

.val {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.point-label {
  font-size: 11px;
  font-weight: 600;
  fill: #ff6b6b;
}

.hidden-layer {
  opacity: 0;
  pointer-events: none;
}

.hidden-layer.show-when-on {
  opacity: 1;
  pointer-events: auto;
}

body.is-fullscreen .app {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

body.is-fullscreen .panel-column {
  display: none;
}

@media (max-width: 980px) {
  .app,
  .app.panel-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .panel-column {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .app.panel-collapsed .panel-column {
    width: 100%;
    max-width: none;
    max-height: 0;
    overflow: visible;
  }

  .panel {
    max-height: 42vh;
  }

  .app.panel-collapsed .panel {
    max-height: 0;
    opacity: 0;
  }

  .panel-toggle-btn {
    left: auto;
    right: 12px;
    top: auto;
    bottom: 12px;
    transform: none;
    border-radius: 8px;
    border-left: 1px solid var(--border);
    width: 36px;
    height: 36px;
  }

  .stage-text-stack {
    left: 10px;
    right: 10px;
    max-width: none;
  }

  .stage-reset-btn {
    right: 110px;
  }

  .stage-fullscreen-btn {
    right: 10px;
  }
}
