/* Anotomy 3D —— 深色医学影像风格 */
:root {
  --bg: #0b1017;
  --panel: rgba(16, 22, 32, 0.92);
  --panel-border: rgba(94, 234, 212, 0.12);
  --text: #d7e2ee;
  --text-dim: #7d8fa5;
  --accent: #2dd4bf;
  --accent-dim: rgba(45, 212, 191, 0.15);
  --accent2: #38bdf8;
  --danger: #fb7185;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  font-size: 14px;
  user-select: none;
}

#viewport { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }

.ic { width: 18px; height: 18px; flex: none; }

/* ---------- 通用 UI ---------- */
.ui { transition: opacity 0.25s ease, transform 0.25s ease; }
body.ui-hidden .ui { opacity: 0; pointer-events: none; }
body.ui-hidden #labels { display: none; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.mini-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.mini-btn:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--accent); }
.mini-btn.accent { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.mini-btn.accent:hover { background: rgba(45, 212, 191, 0.3); }
.mini-btn.active { background: var(--accent); border-color: var(--accent); color: #04211d; font-weight: 600; }

/* ---------- 加载遮罩 ---------- */
#loading {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(ellipse at center, #101a26 0%, #070b11 100%);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.6s;
}
#loading.done { opacity: 0; pointer-events: none; }
.loading-box { text-align: center; width: 320px; }
.loading-logo { font-size: 44px; font-weight: 800; letter-spacing: 2px; color: var(--text); }
.loading-logo span { color: var(--accent); }
.loading-title { color: var(--text-dim); margin: 8px 0 14px; letter-spacing: 6px; }
.loading-wordmark {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: 0 0 28px;
  color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: 5px;
}
.loading-wordmark::before, .loading-wordmark::after {
  content: ""; width: 34px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent));
  opacity: 0.55;
}
.loading-wordmark::after { transform: scaleX(-1); }
.progress-track { height: 4px; background: rgba(255, 255, 255, 0.08); border-radius: 2px; overflow: hidden; }
#progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 2px; transition: width 0.2s; }
#progress-text { margin-top: 12px; font-size: 12px; color: var(--text-dim); }

/* ---------- 顶栏 ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: 60px;
  display: flex; align-items: center; gap: 20px;
  padding: 0 16px;
  background: linear-gradient(180deg, rgba(8, 12, 18, 0.95), rgba(8, 12, 18, 0.75));
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #0e7490);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #04211d;
}
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 10px; color: var(--text-dim); letter-spacing: 1px; }
.brand-wordmark {
  margin-left: 2px; padding-left: 12px;
  border-left: 1px solid var(--panel-border);
  color: var(--accent); font-size: 12px; font-weight: 700;
  letter-spacing: 2px; white-space: nowrap;
}

.search-wrap { position: relative; flex: 1; max-width: 460px; display: flex; align-items: center; }
.search-wrap > .ic { position: absolute; left: 12px; color: var(--text-dim); width: 16px; height: 16px; }
#search-input {
  width: 100%; height: 36px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 0 16px 0 36px;
  color: var(--text); font-size: 13px; outline: none;
  transition: border-color 0.15s, background 0.15s;
}
#search-input:focus { border-color: var(--accent); background: rgba(255, 255, 255, 0.08); }
#search-input::placeholder { color: var(--text-dim); }

#search-results {
  position: absolute; top: 42px; left: 0; right: 0;
  max-height: 320px; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: none;
}
#search-results.open { display: block; }
.sr-item { padding: 8px 14px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sr-item:hover, .sr-item.hover { background: var(--accent-dim); }
.sr-cn { font-size: 13px; }
.sr-en { font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-sys { font-size: 10px; color: var(--accent); flex: none; }
.sr-empty { padding: 12px; color: var(--text-dim); font-size: 12px; text-align: center; }

.top-actions { display: flex; gap: 8px; flex: none; margin-left: auto; }
.tbtn {
  display: flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px;
  background: transparent; border: 1px solid transparent; border-radius: 10px;
  color: var(--text-dim); font-size: 12px; cursor: pointer;
  transition: all 0.15s;
}
.tbtn:hover { color: var(--accent); background: var(--accent-dim); border-color: var(--panel-border); }

/* ---------- 左侧面板 ---------- */
#left-panel {
  position: fixed; top: 72px; left: 12px; bottom: 48px; z-index: 15;
  width: 268px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.panel-tabs { display: flex; border-bottom: 1px solid rgba(255, 255, 255, 0.06); flex: none; }
.ptab {
  flex: 1; padding: 11px 0; background: none; border: none;
  color: var(--text-dim); font-size: 13px; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.ptab.active { color: var(--accent); border-bottom-color: var(--accent); }
.ptab-page { flex: 1; overflow-y: auto; min-height: 0; }
.catalog-tools { display: flex; gap: 8px; padding: 10px 12px 4px; }

.tree-sys { border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.tree-sys-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; cursor: pointer;
  transition: background 0.12s;
}
.tree-sys-head:hover { background: rgba(255, 255, 255, 0.04); }
.tree-arrow { width: 14px; height: 14px; color: var(--text-dim); transition: transform 0.18s; flex: none; }
.tree-sys.open .tree-arrow { transform: rotate(90deg); }
.tree-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tree-sys-name { flex: 1; font-size: 13px; }
.tree-sys-count { font-size: 11px; color: var(--text-dim); }
.eye-btn, .iso-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 2px; display: flex; }
.eye-btn:hover { color: var(--accent); }
.iso-btn { opacity: 0; transition: opacity 0.15s, color 0.15s; }
.tree-sys-head:hover .iso-btn, .tree-item:hover .iso-btn { opacity: 1; }
.iso-btn:hover { color: var(--accent2); }
.iso-btn.active { opacity: 1; color: var(--accent2); }
.eye-btn.off { color: rgba(255, 255, 255, 0.18); }
.eye-btn .ic, .iso-btn .ic { width: 15px; height: 15px; }

.tree-items { display: none; padding: 2px 0 6px; }
.tree-sys.open .tree-items { display: block; }
.tree-item {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px 5px 34px; cursor: pointer;
  font-size: 12px;
  transition: background 0.12s;
}
.tree-item:hover { background: rgba(255, 255, 255, 0.04); }
.tree-item.selected { background: var(--accent-dim); }
.tree-item.selected .ti-cn { color: var(--accent); }
.tree-item.hidden-part .ti-cn, .tree-item.hidden-part .ti-en { opacity: 0.35; }
.ti-names { flex: 1; min-width: 0; }
.ti-cn { display: block; }
.ti-en { display: block; font-size: 10px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 状态目录 */
.states-save { display: flex; gap: 8px; padding: 12px; }
#state-name {
  flex: 1; min-width: 0; height: 30px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px; padding: 0 10px;
  color: var(--text); font-size: 12px; outline: none;
}
#state-name:focus { border-color: var(--accent); }
.states-hint { padding: 0 12px 10px; font-size: 11px; color: var(--text-dim); }
.state-item {
  display: flex; align-items: center; gap: 8px;
  margin: 0 12px 8px; padding: 9px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
}
.state-item-name { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.state-item-time { font-size: 10px; color: var(--text-dim); flex: none; }
.state-item button { flex: none; }

/* ---------- 右侧模式工具条 ---------- */
#modebar {
  position: fixed; right: 12px; top: 50%; transform: translateY(-50%); z-index: 15;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 8px 6px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.mbtn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 52px; padding: 7px 0 5px;
  background: none; border: 1px solid transparent; border-radius: 10px;
  color: var(--text-dim); font-size: 10px; cursor: pointer;
  transition: all 0.15s;
}
.mbtn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.mbtn.active { color: var(--accent); background: var(--accent-dim); border-color: rgba(45, 212, 191, 0.35); }
.modebar-sep { height: 1px; background: rgba(255, 255, 255, 0.08); margin: 4px 6px; }

/* ---------- 切刀面板 ---------- */
#knife-panel {
  position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%); z-index: 16;
  width: min(560px, calc(100vw - 640px));
  min-width: 380px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  padding: 12px 16px;
  display: none;
}
#knife-panel.open { display: block; }
.knife-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.knife-title { font-size: 13px; font-weight: 600; color: var(--accent); }
.knife-tabs { display: flex; gap: 4px; flex: 1; }
.ktab {
  padding: 4px 12px; font-size: 11px; cursor: pointer;
  background: rgba(255, 255, 255, 0.05); color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 7px;
  transition: all 0.15s;
}
.ktab.active { color: var(--accent); background: var(--accent-dim); border-color: var(--accent); }
.knife-body { display: flex; align-items: center; gap: 12px; }
.knife-step {
  width: 28px; height: 28px; flex: none;
  background: rgba(255, 255, 255, 0.06); color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px;
  font-size: 16px; cursor: pointer;
}
.knife-step:hover { border-color: var(--accent); color: var(--accent); }
#knife-label { flex: none; width: 130px; text-align: right; font-size: 12px; color: var(--text-dim); }

input[type="range"] {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 0%), rgba(255, 255, 255, 0.12) var(--fill, 0%));
  outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent);
  border: 3px solid #0b1017;
  box-shadow: 0 0 0 1px var(--accent);
}

/* ---------- 信息面板 ---------- */
#info-panel {
  position: fixed; right: 76px; bottom: 48px; z-index: 15;
  width: 280px; padding: 14px 16px;
  display: none;
}
#info-panel.open { display: block; }
.info-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
#info-cn { font-size: 17px; font-weight: 700; }
#info-en { font-size: 11px; color: var(--text-dim); margin-top: 2px; word-break: break-all; }
.info-count {
  flex: none; font-size: 11px; color: var(--accent);
  background: var(--accent-dim); border-radius: 10px; padding: 2px 10px;
}
.info-sys { margin: 8px 0 10px; font-size: 11px; color: var(--accent2); }
.info-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.info-label { font-size: 12px; color: var(--text-dim); flex: none; }
#opacity-val { font-size: 11px; color: var(--text-dim); width: 38px; text-align: right; flex: none; }
.info-actions { display: flex; gap: 8px; }
.info-actions .mini-btn { flex: 1; }

/* ---------- 状态栏 ---------- */
#statusbar {
  position: fixed; left: 12px; bottom: 10px; z-index: 14;
  font-size: 11px; color: var(--text-dim);
  background: rgba(10, 14, 20, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px; padding: 5px 12px;
  backdrop-filter: blur(10px);
}
#statusbar b { color: var(--accent); font-weight: 600; }

/* ---------- 3D 标签 ---------- */
.label3d {
  position: absolute; transform: translate(-50%, -130%);
  background: rgba(10, 16, 24, 0.88);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 7px; padding: 3px 9px;
  font-size: 11px; white-space: nowrap;
  pointer-events: none;
}
.label3d::after {
  content: ""; position: absolute; left: 50%; bottom: -5px;
  width: 8px; height: 8px; transform: translateX(-50%) rotate(45deg);
  background: inherit; border-right: 1px solid var(--accent); border-bottom: 1px solid var(--accent);
}
.label3d .l-en { color: var(--text-dim); font-size: 9px; margin-left: 5px; }

/* ---------- 显示界面悬浮按钮 ---------- */
#btn-showui {
  position: fixed; right: 14px; top: 14px; z-index: 30;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--panel-border);
  color: var(--text-dim); cursor: pointer;
  display: none; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
#btn-showui:hover { color: var(--accent); }
body.ui-hidden #btn-showui { display: flex; }

/* ---------- 系统页签 ---------- */
.sys-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px; }
.sys-panel-title { font-size: 13px; font-weight: 600; }
.reveal-row { display: flex; align-items: center; gap: 10px; padding: 0 12px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.reveal-row label { font-size: 12px; color: var(--text-dim); flex: none; }

.sys-row { padding: 7px 12px 9px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.sys-row-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.sys-row-top .tree-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sys-name { flex: 1; font-size: 13px; cursor: pointer; }
.sys-name:hover { color: var(--accent); }
.sys-name.off { opacity: 0.4; }
.sys-count { font-size: 11px; color: var(--text-dim); }
.vis-btn {
  width: 30px; height: 22px; flex: none;
  font-size: 11px; border-radius: 6px; cursor: pointer;
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid rgba(45, 212, 191, 0.35);
  transition: all 0.15s;
}
.vis-btn.off { background: rgba(255, 255, 255, 0.05); color: var(--text-dim); border-color: rgba(255, 255, 255, 0.1); }
.sys-opacity { width: 100%; }
.sys-row .iso-btn { opacity: 0; }
.sys-row:hover .iso-btn { opacity: 1; }
.sys-row .iso-btn.active { opacity: 1; }

/* ---------- 设置页签 ---------- */
.set-block { padding: 12px 14px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.set-block h4 { font-size: 12px; color: var(--text-dim); font-weight: 600; margin-bottom: 10px; letter-spacing: 1px; }
.set-slider { display: flex; align-items: center; gap: 10px; font-size: 12px; margin-bottom: 10px; }
.set-slider:last-child { margin-bottom: 0; }
.set-slider input { flex: 1; }
.set-slider span { width: 24px; text-align: right; font-size: 11px; color: var(--text-dim); flex: none; }
.set-slider > *:first-child { flex: none; width: 40px; }
.set-slider { justify-content: flex-start; }
.theme-row { display: flex; gap: 8px; }
.theme-chip {
  flex: 1; padding: 7px 0; font-size: 12px; cursor: pointer;
  background: rgba(255, 255, 255, 0.05); color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px;
  transition: all 0.15s;
}
.theme-chip.active { color: var(--accent); background: var(--accent-dim); border-color: var(--accent); }
.help-text { font-size: 12px; color: var(--text-dim); line-height: 1.8; }

/* ---------- 主题变体 ---------- */
body.theme-slate {
  --bg: #161b26;
  --panel: rgba(24, 30, 42, 0.92);
  --panel-border: rgba(148, 178, 255, 0.14);
  --text: #dbe4f2;
  --text-dim: #8494ad;
}
body.theme-cloud {
  --bg: #dfe7f0;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-border: rgba(15, 60, 80, 0.12);
  --text: #1e2a38;
  --text-dim: #64748b;
  --accent: #0d9488;
  --accent-dim: rgba(13, 148, 136, 0.12);
  --accent2: #0284c7;
  --shadow: 0 8px 28px rgba(30, 50, 80, 0.18);
}
body.theme-cloud #topbar { background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.8)); }
body.theme-cloud #search-input { background: rgba(0, 0, 0, 0.05); border-color: rgba(0, 0, 0, 0.12); }
body.theme-cloud #statusbar { background: rgba(255, 255, 255, 0.75); border-color: rgba(0, 0, 0, 0.08); }
body.theme-cloud .mini-btn { background: rgba(0, 0, 0, 0.05); border-color: rgba(0, 0, 0, 0.12); }
body.theme-cloud .mini-btn:hover { background: rgba(0, 0, 0, 0.1); }
body.theme-cloud .reveal-row, body.theme-cloud .sys-row, body.theme-cloud .set-block,
body.theme-cloud .tree-sys { border-color: rgba(0, 0, 0, 0.07); }
body.theme-cloud input[type="range"] {
  background: linear-gradient(90deg, var(--accent) var(--fill, 0%), rgba(0, 0, 0, 0.15) var(--fill, 0%));
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(45, 212, 191, 0.4); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  #left-panel { width: 220px; }
  .brand-text { display: none; }
  .brand-wordmark { margin-left: 0; padding-left: 8px; font-size: 11px; letter-spacing: 1px; }
  .tbtn span { display: none; }
  #info-panel { right: 72px; width: 240px; }
  #knife-panel { width: calc(100vw - 340px); min-width: 0; }
}
