:root {
  --bg: #0b0e14;
  --panel: rgba(18, 23, 34, 0.88);
  --panel-border: rgba(255,255,255,0.08);
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #4ea1ff;
  --accent2: #34d399;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif; background: var(--bg); color: var(--text); }
#app { position: relative; width: 100%; height: 100%; }
#viewer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 60px; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: linear-gradient(180deg, rgba(8,11,18,0.92), rgba(8,11,18,0.55) 70%, transparent);
  pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 26px; color: var(--accent); }
.brand h1 { font-size: 17px; font-weight: 600; letter-spacing: 0.5px; }
.brand p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stats { display: flex; gap: 22px; }
.stat { text-align: center; }
.stat .num { font-size: 17px; font-weight: 600; color: #fff; display: block; }
.stat .lbl { font-size: 11px; color: var(--muted); }

#sidebar {
  position: absolute; top: 72px; left: 14px; bottom: 84px; width: 250px; z-index: 9;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px;
  backdrop-filter: blur(10px); padding: 14px; overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.45);
  transition: transform .25s ease;
}
#sidebar::-webkit-scrollbar { width: 6px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

/* 移动端：图层面板折叠按钮（默认隐藏，≤768px 显示） */
.side-toggle {
  display: none; position: absolute; top: 78px; left: 8px; z-index: 12;
  align-items: center; gap: 6px; height: 42px; padding: 0 14px;
  border-radius: 11px; border: 1px solid var(--panel-border);
  background: rgba(18,23,34,0.92); color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45); backdrop-filter: blur(8px);
  transition: transform .25s ease;
}
.side-toggle .st-icon { font-size: 16px; line-height: 1; }
.side-toggle:hover { background: rgba(78,161,255,0.2); border-color: var(--accent); }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; color: #cdd6e4; margin-bottom: 10px; letter-spacing: 0.3px;
}
.panel-actions { display: flex; gap: 6px; }
.panel-actions button {
  background: rgba(255,255,255,0.07); color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 6px; padding: 2px 9px; font-size: 11px; cursor: pointer;
}
.panel-actions button:hover { background: rgba(78,161,255,0.25); border-color: var(--accent); }
.category-list { display: flex; flex-direction: column; gap: 4px; }
.cat-item {
  display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 8px;
  cursor: pointer; transition: background 0.15s;
}
.cat-item:hover { background: rgba(255,255,255,0.06); }
.cat-item.off { opacity: 0.45; }
.cat-check {
  width: 15px; height: 15px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.35);
  display: flex; align-items: center; justify-content: center; font-size: 10px; flex-shrink: 0;
  background: rgba(255,255,255,0.06);
}
.cat-item.on .cat-check { background: var(--accent); border-color: var(--accent); }
.cat-item.on .cat-check::after { content: "✓"; color: #fff; }
.cat-name { font-size: 12.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { font-size: 11px; color: var(--muted); }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.view-opts { display: flex; flex-direction: column; gap: 8px; }
.opt { font-size: 12.5px; color: #c3cddc; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.opt input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }


#animBar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 9;
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 999px;
  padding: 8px 16px; backdrop-filter: blur(10px); box-shadow: 0 8px 30px rgba(0,0,0,0.45);
}
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.08); color: var(--text); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.icon-btn:hover { background: rgba(78,161,255,0.25); }
.icon-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.speed-wrap { display: flex; align-items: center; gap: 8px; }
.speed-lbl { font-size: 11px; color: var(--muted); }
#speed { width: 90px; accent-color: var(--accent); cursor: pointer; }
.hint { font-size: 11.5px; color: var(--muted); padding-left: 6px; border-left: 1px solid var(--panel-border); }
.hint-touch { display: none; }

#infoPanel {
  position: absolute; right: 16px; top: 84px; width: 260px; z-index: 9;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px;
  padding: 14px; backdrop-filter: blur(10px); box-shadow: 0 8px 30px rgba(0,0,0,0.45);
}
#infoPanel.hidden { display: none; }
.info-close { position: absolute; top: 8px; right: 12px; cursor: pointer; color: var(--muted); font-size: 16px; }
.info-close:hover { color: #fff; }
.info-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.info-rows { display: flex; flex-direction: column; gap: 7px; }
.info-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.info-row span:first-child { color: var(--muted); flex-shrink: 0; }
.info-row span:last-child { text-align: right; word-break: break-all; }
#infoSwatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

#loader {
  position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #101623 0%, var(--bg) 75%);
}
#loader.fade { opacity: 0; pointer-events: none; transition: opacity 0.6s; }
.loader-card { text-align: center; width: 320px; }
.loader-spinner {
  width: 46px; height: 46px; margin: 0 auto 18px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.12); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.loader-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.1); overflow: hidden; }
#loaderFill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width 0.2s; }
.loader-sub { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* 悬停名称提示 */
#tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: rgba(18,23,34,0.92); border: 1px solid rgba(255,255,255,0.16);
  color: #e8ecf4; padding: 5px 11px; border-radius: 6px; font-size: 12.5px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.45); white-space: nowrap;
  transform: translate(14px, 12px); max-width: 320px; overflow: hidden; text-overflow: ellipsis;
}
#tooltip.hidden { display: none; }

/* 管道入口流入开关 */
.inflow-switch {
  position: fixed; z-index: 30; pointer-events: auto;
  background: rgba(20,26,38,0.92); border: 1px solid #4ea1ff;
  color: #e8ecf4; padding: 4px 12px; border-radius: 999px;
  font-size: 12px; cursor: pointer; transform: translate(-50%, -140%);
  box-shadow: 0 4px 14px rgba(0,0,0,0.45); white-space: nowrap;
}
.inflow-switch:hover { background: rgba(78,161,255,0.28); }
.inflow-switch.off { border-color: #5a6270; color: #9aa6b8; opacity: 0.85; }

/* 风量/风速悬浮标签 */
.supply-label {
  position: fixed; z-index: 29; pointer-events: none;
  background: rgba(18,23,34,0.9); border: 1px solid rgba(78,161,255,0.65);
  color: #fff; padding: 3px 10px; border-radius: 6px; font-size: 12px;
  transform: translate(-50%, -130%); white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* 3D 内风量/根数控制 */
.flow-control {
  position: fixed; z-index: 31; display: flex; align-items: center; gap: 6px;
  background: rgba(18,23,34,0.92); border: 1px solid rgba(78,161,255,0.7);
  color: #fff; padding: 4px 8px; border-radius: 999px; font-size: 12px;
  transform: translate(-50%, -160%); white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,0.45);
}
.flow-control button {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.1); color: #fff; font-size: 13px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.flow-control button:hover { background: rgba(78,161,255,0.4); }

/* 矩形风管根数控件：更贴近风管 */
.flow-control.flow-duct { transform: translate(-50%, -112%); }

/* ============ 顶部导航栏（首页 / 焓湿图） ============ */
.topbar-nav {
  display: flex; align-items: center; gap: 8px;
  pointer-events: auto; margin: 0 10px;
}
.nav-link {
  padding: 6px 16px; border-radius: 999px; font-size: 12.5px;
  color: var(--muted); text-decoration: none;
  border: 1px solid var(--panel-border); background: rgba(255,255,255,0.05);
  transition: all .15s; white-space: nowrap;
}
.nav-link:hover { color: #fff; background: rgba(78,161,255,0.2); border-color: var(--accent); }
.nav-link.active { color: #fff; background: var(--accent); border-color: var(--accent); }
@media (max-width: 860px) {
  #topbar { padding: 0 12px; }
  #topbar .stats { gap: 12px; }
  #topbar .stats .num { font-size: 14px; }
  #topbar .stats .lbl { font-size: 10px; }
}

/* 顶部白色 LOGO 图片 */
.logo-img {
  height: 34px; width: auto; display: block; flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
}

/* ============ 响应式：汉堡导航（全站） ============ */
.nav-toggle {
  display: none; pointer-events: auto; cursor: pointer;
  width: 40px; height: 40px; border-radius: 9px; border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.07); flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  flex-shrink: 0;
}
.nav-toggle span { display: block; width: 20px; height: 2px; border-radius: 2px; background: #cdd6e4; transition: all .2s; }
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* 平板 / 手机：3D 图层面板默认收起（避免遮挡模型展示），点“图层”按钮展开 */
@media (max-width: 1366px) {
  #sidebar { transform: translateX(calc(-100% - 24px)); }
  #sidebar.open { transform: translateX(0); }
  .side-toggle { display: flex; }
  #sidebar.open + .side-toggle { transform: translateX(236px); width: 42px; padding: 0; justify-content: center; }
  #sidebar.open + .side-toggle .st-label { display: none; }
}

@media (max-width: 768px) {
  #topbar .nav-toggle { display: flex; }
  #topbar .topbar-nav {
    position: absolute; top: 60px; right: 10px; flex-direction: column; gap: 4px;
    background: rgba(13,18,28,0.98); border: 1px solid var(--panel-border); border-radius: 12px;
    padding: 8px; box-shadow: 0 12px 30px rgba(0,0,0,0.5); display: none; margin: 0; z-index: 40;
  }
  #topbar .topbar-nav.open { display: flex; }
  #topbar .brand { min-width: 0; flex: 1 1 auto; }
  #topbar .brand > div { min-width: 0; }
  #topbar .brand h1 { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #topbar .brand p { display: none; }
  #topbar .logo-img { height: 26px; }
  #topbar .stats { gap: 10px; flex-shrink: 0; }
  #topbar .stats .num { font-size: 13px; }

  /* 触摸设备提示 */
  .hint-mouse { display: none; }
  .hint-touch { display: block; }
}

/* 超窄屏：统计信息保持可见，进一步紧凑排列 */
@media (max-width: 560px) {
  #topbar { padding: 0 8px; }
  #topbar .brand h1 { font-size: 13px; }
  #topbar .stats { gap: 7px; }
  #topbar .stats .num { font-size: 12px; }
  #topbar .stats .lbl { font-size: 9.5px; }
}
