/* --- 侧边栏底部版权与联系方式 --- */
.sidebar-footer {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.footer-copy {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  user-select: none;
}

.footer-contact {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 3px 8px;
  border-radius: var(--radius-xs);
}

.footer-contact:hover {
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
}

:root {
  --bg-primary: #07090e;
  --bg-surface: #0e111a;
  --bg-card: #131724;
  --bg-card-hover: #191f30;
  --bg-input: #0a0d15;
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-focus: #3b82f6;
  --border-hover: rgba(255, 255, 255, 0.14);
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

/* 全站默认采用极其工整的现代无衬线字体 */
body, input, select, button {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* --- 侧边栏 --- */
.sidebar {
  width: 380px;
  min-width: 380px;
  max-width: 380px;
  flex: 0 0 380px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 20;
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.6);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-sidebar-bar { display: none; }
.mobile-menu-btn { display: none; }
.sidebar-backdrop { display: none; }

.sidebar-content {
  padding: 22px 18px 22px 18px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-content::-webkit-scrollbar {
  width: 5px;
}
.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* --- 卡片式分组区 --- */
.section-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: 0 4px 20px -2px rgba(0,0,0,0.4);
  transition: border-color 0.25s, box-shadow 0.25s;
}

.section-box:hover {
  border-color: var(--border-hover);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.section-tag {
  font-size: 10px;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-weight: 700;
  background: rgba(59, 130, 246, 0.14);
  color: var(--accent-blue);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  letter-spacing: 0.05em;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sub-param-box {
  background: rgba(10, 13, 21, 0.7);
  border: 1px dashed rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* =========================================================
   核心优化：高精度一体化数值框与无衬线清晰单位微标
   ========================================================= */
.input-unit-box {
  position: relative;
  display: flex;
  align-items: center;
  height: 36px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.input-unit-box input {
  background: transparent;
  border: none;
  height: 100%;
  padding: 0 42px 0 10px;
  color: var(--text-main);
  font-size: 13px;
  /* 仅数值使用等宽无衬线，不使用丑陋的 Courier New */
  font-family: "JetBrains Mono", "SF Mono", "Roboto Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  outline: none;
  width: 100%;
}

/* 单位字体彻底剔除 monospace，改为极简现代无衬线 */
.input-unit-box .unit-tag {
  position: absolute;
  right: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: #94a3b8;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 5px;
  border-radius: 3px;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.input-unit-box:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue), 0 0 16px -2px rgba(59, 130, 246, 0.35);
}

.input-unit-box.disabled {
  opacity: 0.65;
  background: rgba(10, 13, 21, 0.4);
}

/* 下拉菜单 */
.select-wrapper {
  position: relative;
}

.select-wrapper select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  height: 36px;
  padding: 0 30px 0 10px;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 500;
  outline: none;
  transition: all 0.2s;
  width: 100%;
  cursor: pointer;
}

.select-wrapper select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue);
}

.select-wrapper::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-dim);
  pointer-events: none;
}

/* 渐变色温滑块 */
.cct-badge {
  font-size: 11px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-weight: 600;
  color: var(--accent-cyan);
}

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(to right, #ff9e2c 0%, #ffd09b 30%, #ffffff 55%, #d5e5ff 80%, #a2c6ff 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
  margin-top: 6px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #0a0d15;
  box-shadow: 0 2px 8px rgba(0,0,0,0.7);
  cursor: pointer;
  transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* 布灯模式 Tab */
.mode-tab-bar {
  display: flex;
  background: #0a0d15;
  padding: 3px;
  border-radius: var(--radius-sm);
  gap: 4px;
  margin-bottom: 12px;
  border: 1px solid var(--border-subtle);
}

.mode-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 7px 0;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-tab.active {
  background: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4);
}

.manual-guide-card {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
}

.guide-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-cyan);
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 4px;
}

.guide-desc {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.5;
}

.manual-toolbar {
  display: flex;
  gap: 6px;
}

.btn-tool {
  flex: 1;
  background: var(--bg-card-hover);
  border: 1px solid var(--border-subtle);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 500;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-tool:hover:not(:disabled) {
  border-color: var(--border-hover);
  color: #ffffff;
  background: #242c42;
}

.btn-tool:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-tool.danger:hover:not(:disabled) {
  background: rgba(244, 63, 94, 0.15);
  border-color: var(--accent-rose);
  color: #fda4af;
}

/* 核心计算按钮 */
.btn-calc {
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: white;
  border: none;
  padding: 13px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.btn-calc:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(37, 99, 235, 0.5);
}

/* 右侧视口看板 */
.main-view {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  background: radial-gradient(circle at 50% 50%, #121727 0%, #06080d 100%);
}

.top-stats {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  pointer-events: none;
}

.stat-card {
  background: rgba(14, 17, 26, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

.stat-title {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.stat-val-group {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 4px;
}

.stat-val {
  font-size: 20px;
  font-weight: 700;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.stat-val span {
  font-size: 11px;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
  color: var(--text-dim);
  margin-left: 3px;
}

.compliance-pill {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
}
.compliance-pill.pass {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.compliance-pill.warn {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.view-switch {
  position: absolute;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(14, 17, 26, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 4px;
  border-radius: 30px;
  border: 1px solid var(--border-subtle);
  display: flex;
  gap: 4px;
  z-index: 10;
  box-shadow: 0 10px 35px rgba(0,0,0,0.6);
  white-space: nowrap;
}

.view-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.view-btn.active {
  background: var(--accent-blue);
  color: white;
  box-shadow: 0 2px 14px rgba(59, 130, 246, 0.45);
}

.canvas-container {
  width: 100%;
  height: 100%;
  position: relative;
  touch-action: none;
}

#threeCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

#heatmapCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  background: #07090e;
  cursor: default;
}

.interactive-mode-badge {
  position: absolute;
  top: calc(74px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(14, 17, 26, 0.92);
  border: 1px solid rgba(59, 130, 246, 0.35);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 11px;
  color: #94a3b8;
  z-index: 8;
  pointer-events: none;
  white-space: nowrap;
}
.interactive-mode-badge span {
  color: var(--accent-cyan);
  font-weight: 700;
  margin-right: 6px;
}

.color-scale {
  position: absolute;
  right: 16px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  background: rgba(14, 17, 26, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: none;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

.scale-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.scale-bar {
  width: 12px;
  height: 160px;
  border-radius: 3px;
  background: linear-gradient(to top, 
    #000033 0%, 
    #0000ff 15%, 
    #00ffff 30%, 
    #00ff00 50%, 
    #ffff00 70%, 
    #ff0000 85%, 
    #ffffff 100%
  );
  border: 1px solid rgba(255,255,255,0.12);
}

.scale-labels {
  height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 10px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.scale-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}

.view-info {
  position: absolute;
  left: 16px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  color: var(--text-dim);
  font-size: 11px;
  background: rgba(14, 17, 26, 0.75);
  backdrop-filter: blur(10px);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
  pointer-events: none;
  z-index: 5;
}

.mobile-hint { display: none; }
.desktop-hint { display: inline; }

/* 移动端适配 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 88vw;
    max-width: 380px;
    flex: none;
    z-index: 100;
    transform: translateX(-100%);
    box-shadow: 15px 0 50px rgba(0, 0, 0, 0.8);
  }

  .sidebar.mobile-open { transform: translateX(0); }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .sidebar-backdrop.active { opacity: 1; pointer-events: auto; }

  .mobile-sidebar-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    background: #0a0d15;
  }

  .mobile-sidebar-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-main);
  }

  .mobile-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    padding: 4px 8px;
    cursor: pointer;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    position: absolute;
    top: calc(12px + env(safe-area-inset-top));
    left: 12px;
    z-index: 30;
    background: rgba(14, 17, 26, 0.9);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 7px 13px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    cursor: pointer;
  }

  .top-stats {
    top: calc(54px + env(safe-area-inset-top));
    left: 10px;
    right: 10px;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .top-stats .stat-card:nth-child(4) { grid-column: span 1; }
  .top-stats .stat-card:nth-child(5) { grid-column: span 2; }
  .stat-card { padding: 8px 10px; }
  .stat-title { font-size: 9px; }
  .stat-val { font-size: 15px; margin-top: 2px; }
  .stat-val span { font-size: 10px; }

  .desktop-hint { display: none; }
  .mobile-hint { display: inline; }
  .view-info {
    left: 10px;
    bottom: calc(70px + env(safe-area-inset-bottom));
    font-size: 10px;
    padding: 4px 10px;
  }

  .view-switch {
    bottom: calc(16px + env(safe-area-inset-bottom));
    padding: 3px;
  }
  .view-btn { padding: 6px 13px; font-size: 11px; }

  .interactive-mode-badge {
    top: calc(122px + env(safe-area-inset-top));
    font-size: 10px;
    padding: 4px 10px;
  }

  .color-scale {
    right: 8px;
    bottom: calc(70px + env(safe-area-inset-bottom));
    padding: 6px 8px;
  }
  .scale-bar { height: 120px; width: 8px; }
  .scale-labels { height: 120px; font-size: 8px; }
}