/* ══════════════════════════════════════════════════════════
   组件：按钮 / 滑杆 / 开关 / 面板 / 图层 / 说明卡 / 导览
   ══════════════════════════════════════════════════════════ */

/* ── 按钮 ──────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  transition: color 150ms var(--ease), background 150ms var(--ease),
    border-color 150ms var(--ease);
}
.btn:hover { color: var(--text); background: var(--panel-3); }
.btn:active { transform: translateY(0.5px); }
.btn[aria-pressed='true'] {
  color: var(--rf);
  background: var(--rf-dim);
  border-color: rgba(34, 211, 238, 0.28);
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-icon { width: 30px; padding: 0; }
.btn-primary {
  color: #04212b;
  background: var(--rf);
  border-color: var(--rf);
  font-weight: 500;
}
.btn-primary:hover { background: #5ee7f7; color: #04212b; }
.btn-ghost { border-color: var(--border-2); }
.btn-ghost:hover { border-color: var(--border-3); }

.btn-mini {
  height: 22px;
  padding: 0 7px;
  font-size: 11px;
  border-radius: 4px;
  color: var(--text-3);
  border: 1px solid var(--border);
}
.btn-mini:hover { color: var(--text); border-color: var(--border-3); background: var(--panel-2); }
.btn-play {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--energy); border-color: rgba(245,158,11,.38);
  background: var(--energy-dim); padding: 0 9px;
}
.btn-play:hover { color: #fcd34d; background: rgba(245,158,11,.2); border-color: rgba(245,158,11,.55); }
.btn-play[aria-pressed='true'] { color: var(--energy); background: rgba(245,158,11,.22); border-color: rgba(245,158,11,.6); }
.btn-mini[aria-pressed='true'] { color: var(--rf); border-color: rgba(34, 211, 238, 0.3); background: var(--rf-dim); }

/* ── 面板分区 ──────────────────────────────────────────────── */

.section { border-bottom: 1px solid var(--border); }
.section:last-child { border-bottom: none; }

.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px 8px;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-align: left;
  transition: color 150ms;
}
.section-head:hover { color: var(--text); }
.section-head .caret {
  width: 10px;
  height: 10px;
  margin-left: auto;
  opacity: 0.5;
  transition: transform 200ms var(--ease);
}
.section[data-collapsed='1'] .caret { transform: rotate(-90deg); }
.section[data-collapsed='1'] .section-body { display: none; }

.section-head .dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--rf); opacity: 0.85;
}
.section-head .hint {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-4);
  font-family: var(--font-mono);
  letter-spacing: 0;
}

.section-body { padding: 2px 12px 12px; }

/* ── 参数行 ────────────────────────────────────────────────── */

.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}
.row-label { font-size: 11.5px; color: var(--text-2); }
.row-value {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.row-value .unit { color: var(--text-4); font-size: 10px; margin-left: 2px; }
.row-value.accent { color: var(--rf); }
.row-value.warn { color: var(--energy); }
.row-value.bad { color: var(--danger); }

.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 2px; }

/* ── 滑杆 ──────────────────────────────────────────────────── */

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 16px;
  background: transparent;
  cursor: pointer;
  display: block;
  --p: 0%;
  --track: var(--rf);
}
input[type='range']::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    var(--track) 0%,
    var(--track) var(--p),
    var(--border-2) var(--p),
    var(--border-2) 100%
  );
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px var(--border-3);
  transition: transform 120ms var(--ease), box-shadow 120ms var(--ease);
}
input[type='range']:hover::-webkit-slider-thumb { transform: scale(1.15); }
input[type='range']:active::-webkit-slider-thumb { transform: scale(1.28); box-shadow: 0 0 0 1px var(--rf); }
input[type='range']::-moz-range-track { height: 3px; border-radius: 3px; background: var(--border-2); }
input[type='range']::-moz-range-progress { height: 3px; border-radius: 3px; background: var(--track); }
input[type='range']::-moz-range-thumb {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text); border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px var(--border-3);
}

/* ── 分段选择器 ────────────────────────────────────────────── */

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 2px;
  background: var(--panel-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.seg button {
  height: 24px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--text-3);
  transition: color 140ms, background 140ms;
  white-space: nowrap;
}
.seg button:hover { color: var(--text-2); }
.seg button[aria-pressed='true'] {
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.seg button[aria-pressed='true'][data-tone='rf'] { color: var(--rf); }

/* ── 开关 ──────────────────────────────────────────────────── */

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
}
.switch-label { font-size: 11.5px; color: var(--text-2); display: flex; flex-direction: column; gap: 1px; }
.switch-label small { font-size: 10px; color: var(--text-4); }

.switch {
  position: relative;
  width: 34px;
  height: 19px;
  border-radius: 10px;
  background: var(--panel-3);
  border: 1px solid var(--border-2);
  flex-shrink: 0;
  transition: background 180ms var(--ease), border-color 180ms var(--ease);
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text-3);
  transition: transform 200ms var(--ease), background 180ms var(--ease);
}
.switch[aria-checked='true'] { background: var(--rf-dim); border-color: rgba(34, 211, 238, 0.4); }
.switch[aria-checked='true']::after { transform: translateX(15px); background: var(--rf); }

/* ── 图层列表 ──────────────────────────────────────────────── */

.layer-group { margin-bottom: 10px; }
.layer-group:last-child { margin-bottom: 0; }

.layer-group-title {
  font-size: 9.5px;
  letter-spacing: 0.11em;
  color: var(--text-4);
  margin: 0 0 5px 2px;
  font-family: var(--font-mono);
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 7px;
  border-radius: 5px;
  border: 1px solid transparent;
  color: var(--text-2);
  font-size: 11.5px;
  text-align: left;
  transition: background 130ms, color 130ms, border-color 130ms;
  min-height: 26px;
}
.layer-row:hover { background: var(--panel-2); color: var(--text); }
.layer-row[data-state='half'] { color: var(--text-3); }
.layer-row[data-state='off'] { color: var(--text-4); }
.layer-row[data-active='1'] { border-color: rgba(34, 211, 238, 0.35); background: var(--rf-dim); color: var(--text); }

.layer-eye {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.85;
  display: flex;
  align-items: center;
  justify-content: center;
}
.layer-swatch {
  width: 3px;
  height: 13px;
  border-radius: 2px;
  flex-shrink: 0;
  opacity: 0.9;
}
.layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-4);
  padding: 0 3px;
  border: 1px solid var(--border);
  border-radius: 3px;
  line-height: 14px;
}

/* ── 视口工具条 ────────────────────────────────────────────── */

.vp-toolbar {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 4px;
  padding: 3px;
  background: rgba(12, 18, 24, 0.82);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}
[data-theme='light'] .vp-toolbar { background: rgba(255, 255, 255, 0.85); }

.vp-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 9px;
  background: rgba(12, 18, 24, 0.82);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
  letter-spacing: 0.04em;
}
[data-theme='light'] .vp-badge { background: rgba(255, 255, 255, 0.85); }
.vp-badge .fps { color: var(--ok); }

/* 悬停部件提示 */
.hover-tip {
  position: absolute;
  pointer-events: none;
  padding: 3px 8px;
  background: rgba(6, 9, 13, 0.92);
  border: 1px solid var(--border-3);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  z-index: 20;
  opacity: 0;
  transform: translate(-50%, -140%);
  transition: opacity 120ms;
}
.hover-tip[data-show='1'] { opacity: 1; }

/* ── 图例 ──────────────────────────────────────────────────── */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 8px 12px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: var(--text-3);
}
.legend-swatch { width: 8px; height: 8px; border-radius: 2px; }

/* ── 警告条 ────────────────────────────────────────────────── */

.warn-banner {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  margin: 0 12px 10px;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  background: var(--energy-dim);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fcd34d;
  font-size: 11px;
  line-height: 1.45;
}
.warn-banner[data-tone='bad'] {
  background: var(--danger-dim);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fda4af;
}
.warn-banner svg { width: 13px; height: 13px; flex-shrink: 0; margin-top: 1px; }

/* ── 部件说明卡 ────────────────────────────────────────────── */

.callout {
  margin: 10px 12px 0;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  overflow: hidden;
  animation: calloutIn 260ms var(--ease-out);
}
@keyframes calloutIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.callout-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
}
.callout-title { font-size: 12.5px; font-weight: 500; color: var(--text); }
.callout-tag {
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--rf-dim);
  color: var(--rf);
  border: 1px solid rgba(34, 211, 238, 0.22);
  letter-spacing: 0.04em;
}
.callout-close {
  margin-left: auto;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  color: var(--text-4);
}
.callout-close:hover { color: var(--text); background: var(--panel-3); }

.callout-body { padding: 10px 11px 12px; }
.callout-role { font-size: 11.5px; line-height: 1.65; color: var(--text-2); margin-bottom: 10px; }

.callout-specs { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }
.callout-specs li {
  font-size: 11px;
  color: var(--text-3);
  padding-left: 11px;
  position: relative;
  line-height: 1.5;
}
.callout-specs li::before {
  content: '';
  position: absolute;
  left: 2px; top: 7px;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--text-4);
}

.callout-formula {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--rf);
  background: var(--panel-3);
  border-left: 2px solid var(--rf);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 7px 9px;
  line-height: 1.55;
  margin-bottom: 9px;
  overflow-x: auto;
  white-space: pre-wrap;
}

.callout-note {
  font-size: 10.5px;
  color: var(--text-4);
  line-height: 1.55;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.callout-note::before {
  content: '模型说明 · ';
  color: var(--text-3);
}

/* ── 导览 ──────────────────────────────────────────────────── */

.tour-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-h) + 14px);
  transform: translateX(-50%) translateY(14px);
  width: min(660px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: rgba(12, 18, 24, 0.94);
  border: 1px solid var(--border-3);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms var(--ease), transform 260ms var(--ease);
}
[data-theme='light'] .tour-bar { background: rgba(255, 255, 255, 0.96); }
.tour-bar[data-open='1'] { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

.tour-step {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--rf);
  letter-spacing: 0.06em;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--rf-dim);
  flex-shrink: 0;
}
.tour-content { flex: 1; min-width: 0; }
.tour-title { font-size: 12.5px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.tour-desc { font-size: 11px; color: var(--text-2); line-height: 1.5; }
.tour-actions { display: flex; gap: 5px; flex-shrink: 0; }

/* ── 弹层（模型说明 / 快捷键） ──────────────────────────────── */

.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 9, 0.66);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease);
}
.sheet-mask[data-open='1'] { opacity: 1; pointer-events: auto; }

.sheet {
  width: min(680px, 100%);
  max-height: 82vh;
  background: var(--panel);
  border: 1px solid var(--border-3);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.97);
  transition: transform 240ms var(--ease-out);
}
.sheet-mask[data-open='1'] .sheet { transform: none; }

.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.sheet-head h2 { font-size: 14px; font-weight: 500; }
.sheet-body {
  padding: 16px 18px 20px;
  overflow-y: auto;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.7;
}
.sheet-body h3 {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin: 18px 0 7px;
  font-weight: 500;
}
.sheet-body h3:first-child { margin-top: 0; }
.sheet-body p { margin: 0 0 9px; }
.sheet-body strong { color: var(--text); font-weight: 500; }
.sheet-body code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--panel-3);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--rf);
}
.sheet-body table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.sheet-body th, .sheet-body td {
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
}
.sheet-body th { color: var(--text-4); font-weight: 500; font-size: 10.5px; letter-spacing: 0.05em; }
.sheet-body td:first-child { color: var(--text); font-family: var(--font-mono); white-space: nowrap; }

/* ── 隐藏辅助 ──────────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 加载遮罩 */
#boot {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  z-index: 200;
  transition: opacity 420ms var(--ease), visibility 420ms;
}
#boot[data-done='1'] { opacity: 0; visibility: hidden; }
#boot .boot-mark {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.28em;
  color: var(--rf);
}
#boot .boot-line {
  width: 160px;
  height: 1px;
  background: var(--border-2);
  overflow: hidden;
  position: relative;
}
#boot .boot-line::after {
  content: '';
  position: absolute;
  inset: 0;
  width: 40%;
  background: var(--rf);
  animation: bootSlide 1.1s var(--ease) infinite;
}
@keyframes bootSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
#boot .boot-msg { font-size: 11px; color: var(--text-4); }

/* 减少动效 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
