:root {
  --bg-deep: #101319;
  --bg-panel: #171b24;
  --bg-card: #1f2531;
  --bg-card-hover: #272f3e;
  --border-subtle: rgba(232, 220, 200, 0.14);
  --border-strong: rgba(219, 163, 77, 0.42);
  --text-main: #f3ede2;
  --text-muted: #b5ae9f;
  --text-dim: #8a8478;
  --accent-gold: #dba34d;
  --accent-terracotta: #d26e47;
  --accent-lapis: #4d90d9;
  --tag-text-bg: rgba(219, 163, 77, 0.16);
  --tag-text-fg: #f6c76b;
  --tag-arch-bg: rgba(16, 185, 129, 0.16);
  --tag-arch-fg: #6ee7b7;
  --tag-recon-bg: rgba(56, 189, 248, 0.16);
  --tag-recon-fg: #7dd3fc;
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.55);
  --radius-md: 10px;
  --radius-sm: 6px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  line-height: 1.55;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent-lapis);
}

code,
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-main);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

/* 顶部声明横幅 */
.top-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 18px;
  background: linear-gradient(90deg, #161a24 0%, #1c2230 60%, #171c26 100%);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 30;
  flex-shrink: 0;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-titles {
  min-width: 0;
}

.brand-titles h1 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-main);
}

.en-sub {
  font-weight: 400;
  font-size: 0.86em;
  color: var(--text-muted);
}

.en-inline {
  font-size: 0.9em;
  color: var(--text-muted);
}

.honesty-banner {
  margin: 3px 0 0;
  font-size: 0.82rem;
  color: #e4d8c3;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* 证据标签 */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.tag-text {
  background: var(--tag-text-bg);
  color: var(--tag-text-fg);
  border-color: rgba(219, 163, 77, 0.35);
}

.tag-arch {
  background: var(--tag-arch-bg);
  color: var(--tag-arch-fg);
  border-color: rgba(16, 185, 129, 0.35);
}

.tag-recon {
  background: var(--tag-recon-bg);
  color: var(--tag-recon-fg);
  border-color: rgba(56, 189, 248, 0.35);
}

/* 通用按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  min-height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  font-size: 0.84rem;
  font-weight: 500;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(232, 220, 200, 0.32);
}

.btn:active {
  transform: translateY(1px);
}

.btn.active,
.btn[aria-pressed="true"] {
  background: rgba(219, 163, 77, 0.22);
  border-color: var(--accent-gold);
  color: #ffe2ad;
}

.btn-accent {
  background: rgba(210, 110, 71, 0.22);
  border-color: rgba(210, 110, 71, 0.55);
  color: #ffd3bf;
}

.btn-accent:hover {
  background: rgba(210, 110, 71, 0.35);
  border-color: var(--accent-terracotta);
}

.btn-accent[aria-pressed="true"] {
  background: rgba(77, 144, 217, 0.28);
  border-color: var(--accent-lapis);
  color: #d6ebff;
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 0.78rem;
}

.mobile-only {
  display: none;
}

/* 主工作区布局 */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 400px 1fr;
  position: relative;
}

/* 左侧学术面板 */
.side-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  z-index: 20;
}

.panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.18);
}

.evidence-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.12);
}

.tab-btn {
  padding: 10px 8px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
  background: rgba(219, 163, 77, 0.08);
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 24px;
}

.tab-panel h2 {
  margin: 0;
  font-size: 0.98rem;
  color: var(--text-main);
}

.section-heading {
  margin: 18px 0 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(219, 163, 77, 0.18);
  padding-bottom: 4px;
}

.callout,
.info-block,
.compare-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 13px;
  margin-bottom: 10px;
}

.callout-warn {
  border-left: 3px solid var(--accent-terracotta);
}

.callout-debate {
  border-left: 3px solid var(--accent-lapis);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.callout p,
.info-block p,
.compare-card p {
  margin: 0;
  font-size: 0.84rem;
  color: #dcd4c6;
}

.source-list,
.compare-card ul {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 0.83rem;
  color: #dcd4c6;
}

.source-list li,
.compare-card li {
  margin-bottom: 8px;
}

.compare-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.compare-babylon {
  border-top: 3px solid var(--accent-gold);
}

.compare-nineveh {
  border-top: 3px solid var(--accent-lapis);
}

.sub-meta {
  font-size: 0.77rem !important;
  color: var(--text-muted) !important;
  margin-bottom: 8px !important;
}

/* 图录 */
.gallery-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.figure-card {
  margin: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.figure-card img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: cover;
  background: #0d1015;
}

.figure-card figcaption {
  padding: 9px 11px;
  font-size: 0.78rem;
  color: #d6cebf;
}

.figure-card figcaption .tag {
  margin-right: 4px;
}

.sources-footer {
  margin: 14px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* 剖面地层列表 */
.strata-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.strata-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.strata-item p {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.strata-swatch {
  width: 14px;
  height: 36px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.swatch-soil { background: #5b3e28; }
.swatch-lead { background: #8998a8; }
.swatch-brick { background: #b85c3b; }
.swatch-bitumen { background: #19191d; }
.swatch-stone { background: #cbb799; }

/* 侧栏热点索引 */
.hotspot-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hotspot-list-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.83rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.hotspot-list-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.hotspot-list-btn.active {
  border-color: var(--accent-gold);
  background: rgba(219, 163, 77, 0.14);
}

.hotspot-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(219, 163, 77, 0.22);
  color: var(--accent-gold);
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 7px;
  flex-shrink: 0;
}

/* 3D 视口区 */
.viewport-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #233044 0%, #11151d 100%);
}

.canvas-wrap {
  position: absolute;
  inset: 0;
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.scene-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 15;
  background: rgba(14, 17, 24, 0.82);
  backdrop-filter: blur(6px);
}

.status-card {
  max-width: 520px;
  padding: 22px 24px;
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.status-title {
  margin: 8px 0 6px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.status-desc {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.status-actions {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.spinner {
  width: 30px;
  height: 30px;
  margin: 0 auto 8px;
  border-radius: 50%;
  border: 3px solid rgba(219, 163, 77, 0.2);
  border-top-color: var(--accent-gold);
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 3D 热点标注层 */
.hotspot-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

.hotspot-pin {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 5px;
  border-radius: 999px;
  border: 1px solid rgba(255, 232, 186, 0.55);
  background: rgba(16, 20, 28, 0.82);
  backdrop-filter: blur(4px);
  color: var(--text-main);
  font-size: 0.76rem;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  transition: opacity 0.18s ease, background 0.15s ease, border-color 0.15s ease;
}

.hotspot-pin:hover,
.hotspot-pin.active {
  background: rgba(188, 125, 38, 0.92);
  border-color: #fff2cf;
  color: #111;
  z-index: 12;
}

.hotspot-pin-idx {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-gold);
  color: #16181f;
  font-size: 0.72rem;
  font-weight: 800;
}

.hotspot-pin.active .hotspot-pin-idx {
  background: #16181f;
  color: #ffdf9e;
}

.hotspot-pin.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* 视口 HUD */
.viewport-hud {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
  z-index: 11;
}

.hud-pill {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(16, 20, 28, 0.78);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(6px);
  font-size: 0.76rem;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hud-mode {
  border-color: rgba(56, 189, 248, 0.45);
  color: #bae6fd;
}

/* 热点详情浮层卡片 */
.info-card {
  position: absolute;
  right: 14px;
  bottom: 112px;
  width: min(360px, calc(100% - 28px));
  background: rgba(21, 25, 34, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-lg);
  z-index: 16;
}

.info-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.info-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 5px;
}

.info-card-head h2 {
  margin: 0;
  font-size: 1rem;
  color: var(--accent-gold);
}

.info-card-en {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.info-card-body {
  margin: 10px 0 8px;
  font-size: 0.85rem;
  color: #e6dfd2;
}

.info-card-source {
  margin: 0 0 12px;
  font-size: 0.76rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
}

.info-card-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* 底部控制栏 */
.toolbar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: rgba(16, 20, 28, 0.88);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-lg);
  z-index: 14;
}

.toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-subtle);
}

/* 帮助弹窗 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.76);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
}

.modal-dialog {
  width: min(680px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-lg);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.help-grid h3 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--accent-gold);
}

.help-grid ul {
  margin: 0;
  padding-left: 18px;
  font-size: 0.84rem;
  color: #dfd8cb;
}

.help-grid li {
  margin-bottom: 7px;
}

.help-note {
  margin: 14px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 响应式：平板与手机 */
@media (max-width: 960px) {
  .mobile-only {
    display: inline-flex;
  }

  .top-banner {
    flex-direction: column;
    align-items: stretch;
    padding: 8px 12px;
    gap: 6px;
  }

  .header-actions {
    justify-content: flex-end;
  }

  .honesty-banner {
    font-size: 0.76rem;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(90vw, 390px);
    transform: translateX(-105%);
    transition: transform 0.24s ease;
    box-shadow: var(--shadow-lg);
    z-index: 40;
  }

  .side-panel.open {
    transform: translateX(0);
  }

  .toolbar {
    left: 8px;
    right: 8px;
    bottom: 8px;
    padding: 7px;
    gap: 6px;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .toolbar-group {
    flex-wrap: nowrap;
  }

  .btn {
    min-height: 42px;
    padding: 8px 12px;
  }

  .info-card {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 74px;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
  .btn,
  .side-panel,
  .hotspot-pin {
    transition: none;
  }
}
