:root {
  --ink: #181e21;        /* 主文字 */
  --quiet: #555f64;      /* 次要文字 */
  --line: #d8ddd9;       /* 边框 */
  --soft: #f2f5f3;       /* 页面背景 */
  --card: #ffffff;       /* 卡片背景 */
  --card-tint: #fafcfb;  /* 卡片浅底 */
  --teal: #006c65;       /* 主色 */
  --teal-dark: #14564b;  /* 主色深 */
  --rust: #a25130;       /* 点缀赭红 */
  --mono: "SFMono-Regular", Consolas, ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--soft);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
}

/* ---------- 顶栏 ---------- */
.topbar {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--ink);
}
.brand .subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--quiet);
}
.tabs {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 550;
  color: #253830;
  background: #fff;
  border: 1px solid #c3cec7;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab:hover { border-color: #38776b; }
.tab.active {
  color: #fff;
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  font-weight: 600;
}
.present-toggle {
  margin-left: auto;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--teal);
  background: transparent;
  border: 1px solid var(--teal);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.present-toggle:hover { background: #e8f2ef; }

/* ---------- 主体 ---------- */
main { padding: 18px 22px; max-width: 1240px; margin: 0 auto; }

.scene { display: none; }
.scene.active { display: block; }

.layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }
.layout-3col { grid-template-columns: 220px 1fr 330px; }
.layout-2col { grid-template-columns: 1fr 1fr; margin-top: 16px; }
.layout-scene3 { grid-template-columns: 1fr 340px; }

/* ---------- 3D 视口（深色舞台）---------- */
.viewport {
  position: relative;
  height: 520px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: radial-gradient(120% 120% at 50% 20%, #16202a 0%, #0a1016 75%);
  overflow: hidden;
}
.viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 140px rgba(0, 0, 0, 0.5);
}
.viewport-small { height: 380px; }
.viewport canvas { display: block; }
.viewport-hint {
  position: absolute;
  bottom: 10px;
  left: 12px;
  font-size: 11px;
  color: #8fa3b0;
  pointer-events: none;
  opacity: 0.85;
  z-index: 1;
}

/* ---------- 控制面板 ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.panel-section { display: flex; flex-direction: column; gap: 8px; }
.field-label {
  font-size: 12px;
  color: var(--quiet);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
select {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #aab7af;
  border-radius: 8px;
}

.controls { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 550;
  color: #253830;
  background: #fff;
  border: 1px solid #c3cec7;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn:hover { border-color: #38776b; }
.btn-primary {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  color: #fff;
  font-weight: 600;
  min-width: 84px;
}
.btn-primary:hover { background: var(--teal); }

.speed-wrap { display: flex; align-items: center; gap: 6px; flex: 1; }
.speed-wrap .field-label { white-space: nowrap; }
#speedRange { flex: 1; }
#speedValue { font-size: 12px; color: var(--quiet); white-space: nowrap; }

.slider-head { display: flex; justify-content: space-between; align-items: baseline; }
.readout { font-size: 13px; color: var(--teal); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--teal); }
.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--quiet);
}

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--teal); }

/* ---------- 图例 ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 8px; }
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  font-size: 12px;
  background: var(--card-tint);
  border: 1px solid var(--line);
  border-radius: 20px;
}
.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.2);
}

/* ---------- 说明文字 ---------- */
.caption {
  margin: 14px 2px 0;
  font-size: 13px;
  color: var(--quiet);
  max-width: 860px;
}
.muted { color: var(--quiet); }

/* ---------- 占位场景 ---------- */
.placeholder {
  padding: 80px 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--ink);
}
.placeholder h2 { margin: 0 0 12px; font-size: 18px; }
.placeholder p { margin: 4px 0; font-size: 14px; }

/* ---------- 页脚 ---------- */
.footer {
  padding: 14px 22px 22px;
  font-size: 12px;
  color: var(--quiet);
  text-align: center;
  border-top: 1px solid var(--line);
}

/* ---------- 错误提示 ---------- */
.error-banner {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  max-width: 560px;
  padding: 12px 18px;
  background: #fdecea;
  border: 1px solid #e2b8b4;
  color: #8c2f24;
  border-radius: 10px;
  font-size: 13px;
  z-index: 10;
}
.hidden { display: none; }

/* ---------- 场景①：信息读数 ---------- */
.info-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--quiet); }
.info-row b { color: var(--teal-dark); font-variant-numeric: tabular-nums; }

/* ---------- 场景②：摘要条 ---------- */
.summary-strip {
  display: flex; gap: 26px; align-items: center; flex-wrap: wrap;
  padding: 14px 18px; margin-bottom: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-size: 22px; font-weight: 700; color: var(--teal-dark); }
.stat-warn .stat-num { color: var(--rust); }
.stat-label { font-size: 12px; color: var(--quiet); }
.stat-note { font-size: 12px; color: var(--quiet); max-width: 230px; }

/* ---------- 场景②：候选列表 ---------- */
.candidate-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 520px; }
.cand-card {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 12px; text-align: left;
  background: #fff; border: 1px solid #cbd5cf;
  border-radius: 10px; color: var(--ink); cursor: pointer;
  transition: all 0.15s ease;
}
.cand-card:hover { border-color: #38776b; }
.cand-card.selected { border-color: var(--teal); border-left: 3px solid var(--teal); background: #f4faf7; }
.cand-formula { font-size: 15px; font-weight: 650; }
.cand-badge { align-self: flex-start; padding: 1px 8px; font-size: 11px; border-radius: 20px; }
.cand-meta { font-size: 11px; color: var(--quiet); }

/* ---------- 场景②：详情面板 ---------- */
.kv { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }
.kv b { color: var(--ink); font-variant-numeric: tabular-nums; }
.status-line { margin: 2px 0 6px; }
.tag { padding: 1px 8px; font-size: 11px; border-radius: 20px; }
.tag-ok { background: #e6f4e6; color: #2e7d32; }
.tag-bad { background: #fdecea; color: #c0392b; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini-table th, .mini-table td { padding: 5px 6px; text-align: right; border-bottom: 1px solid var(--line); }
.mini-table th:first-child, .mini-table td:first-child { text-align: left; }
.mini-table th { color: var(--quiet); font-weight: 550; }
.mini-table td { font-variant-numeric: tabular-nums; }

/* ---------- 图表 ---------- */
.chart-row { margin-top: 16px; }
.chart-box {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px;
}
.chart-box canvas { width: 100%; height: 220px; display: block; }
.chart-box-wide canvas { height: 400px; }
.legend-inline { display: flex; gap: 14px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- 提示 ---------- */
.notice-warn {
  padding: 12px 14px; font-size: 13px;
  background: #fdf3e7; border: 1px solid #e6c99a;
  color: #7a4a12; border-radius: 10px; margin: 8px 0;
}

/* ---------- 场景⑤：条件控制 ---------- */
.gammas { display: flex; gap: 6px; flex-wrap: wrap; }
.gamma-btn {
  padding: 6px 12px; font-size: 13px; font-weight: 550; color: #253830;
  background: #fff; border: 1px solid #c3cec7;
  border-radius: 8px; cursor: pointer; transition: all 0.15s ease;
}
.gamma-btn:hover { border-color: #38776b; }
.gamma-btn.active { color: #fff; background: var(--teal-dark); border-color: var(--teal-dark); font-weight: 600; }
.summary-strip select { width: auto; min-width: 90px; }
.summary-strip .field-label { margin: 0; }

/* ---------- 场景⑥：采样器对比 ---------- */
.sampler-col { display: flex; flex-direction: column; gap: 8px; }
.sampler-label { font-size: 14px; font-weight: 650; color: var(--ink); }
.sampler-col .info-row { gap: 10px; }

/* ---------- 演示模式 ---------- */
body.present { font-size: 16px; }
body.present .topbar h1 { font-size: 27px; }
body.present .brand .subtitle { font-size: 15px; }
body.present .tab { font-size: 15px; padding: 10px 18px; }
body.present .btn { font-size: 15px; padding: 10px 16px; }
body.present .field-label { font-size: 14px; }
body.present .stat-num { font-size: 28px; }
body.present .caption { font-size: 15px; }
body.present .mini-table { font-size: 13px; }
body.present .viewport-hint,
body.present .footer,
body.present .error-banner { display: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  .layout, .layout-3col, .layout-scene3, .layout-2col { grid-template-columns: 1fr; }
  .viewport, .viewport-small { height: 380px; }
  .candidate-list { max-height: 260px; }
  .chart-box-wide canvas { height: 300px; }
}
