/* ============================================================
   科技感增强层（Tech Layer）· 保留橙色主色调（--ui-accent）
   叠加在 theme-refresh.css 之后，仅做视觉覆盖，
   不改动任何布局结构与功能逻辑。
   设计要点：蓝图网格底纹、HUD 边角括号、等宽数字、
   激活态辉光、视图扫描线。所有主色仍取自 --ui-accent。
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=Share+Tech+Mono&family=Noto+Sans+SC:wght@400;500;700&display=swap');

:root {
  --font-display: "Times New Roman", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "微软雅黑", serif;
  --font-mono: "Times New Roman", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "微软雅黑", serif;

  --tech-edge: color-mix(in srgb, var(--ui-accent) 22%, var(--line));
  --tech-grid: rgba(217, 95, 30, 0.045);
  --tech-glow: rgba(217, 95, 30, 0.30);
  --tech-bracket: rgba(217, 95, 30, 0.45);
  --tech-scan: rgba(217, 95, 30, 0.035);
}

html[data-theme="dark"] {
  --tech-edge: color-mix(in srgb, var(--ui-accent) 34%, var(--line-strong));
  --tech-grid: rgba(255, 134, 71, 0.06);
  --tech-glow: rgba(255, 134, 71, 0.42);
  --tech-bracket: rgba(255, 134, 71, 0.55);
  --tech-scan: rgba(255, 134, 71, 0.05);
}

/* ---------- 全局字体：中文走系统，拉丁/数字走科技字体 ---------- */
body,
button,
input,
select,
textarea,
h1, h2, h3, h4, h5, h6,
.brand-name,
.module-tab,
.control-label,
.fe-kicker,
.segment,
.chip,
.legend,
.cs-legend,
.ternary-legend,
.component-label,
.viewer-icon-button,
.theme-toggle span {
  font-family: var(--font-display);
}

.component-input,
.index-input,
.small-input,
.ternary-field input,
.ternary-point-grid input,
.fe-carbon-field input,
.metric-list dd,
.cs-meta dd,
.dislocation-meta dd,
.ternary-meta dd,
.fe-detail-list dd,
.fe-composition-strip strong,
.readout-panel,
.dislocation-range-label output,
.stereo-status-card strong,
.visit-metric strong,
.fe-bar-label {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ---------- 蓝图网格背景 + 顶部辉光 ---------- */
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(860px 400px at 50% -8%, rgba(217, 95, 30, 0.13), transparent 72%),
    linear-gradient(var(--tech-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--tech-grid) 1px, transparent 1px);
  background-size: auto, 30px 30px, 30px 30px;
  background-attachment: fixed, fixed, fixed;
  background-repeat: no-repeat, repeat, repeat;
}

html[data-theme="dark"] body {
  background-image:
    radial-gradient(860px 420px at 50% -10%, rgba(255, 134, 71, 0.16), transparent 72%),
    linear-gradient(var(--tech-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--tech-grid) 1px, transparent 1px);
}

/* ---------- 顶栏：分隔线与辉光强化 ---------- */
.topbar {
  border-bottom: 1px solid var(--tech-edge);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 10px 30px var(--tech-glow);
}

.brand h1 {
  text-shadow: 0 0 18px var(--tech-glow);
}

.brand-logo {
  filter: drop-shadow(0 3px 10px var(--tech-glow));
}

/* ---------- 模块导航激活态：辉光 + 微动效 ---------- */
.module-tab.is-active {
  background: linear-gradient(135deg, #e2702c, var(--ui-accent));
  box-shadow: 0 0 0 1px var(--ui-accent), 0 8px 22px var(--tech-glow);
  background-size: 200% 100%;
  animation: tech-shimmer 4.5s linear infinite;
}

@keyframes tech-shimmer {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

html[data-theme="dark"] .module-tab.is-active {
  background: linear-gradient(135deg, #ff9a5c, var(--ui-accent));
  box-shadow: 0 0 0 1px var(--ui-accent), 0 8px 24px var(--tech-glow);
}

/* ---------- 通用卡片：科技边 + 悬停辉光 + HUD 边角 ---------- */
.tech-frame,
.control-panel,
.dislocation-control-panel,
.crystal-structure-control-panel,
.fe-card,
.structure-card,
.interstitial-card,
.stereo-card,
.ternary-card,
.readout-panel,
.viewer-panel,
.ternary-view-panel,
.structure-view-panel,
.interstitial-view-panel,
.dislocation-view-panel,
.cs-view-panel,
.stereo-view-panel,
.legend,
.cs-legend,
.dislocation-legend,
.interstitial-legend,
.structure-legend,
.ternary-legend,
.stereo-legend,
.visit-metric,
.visit-head {
  position: relative;
  border: 1px solid var(--tech-edge);
  box-shadow: var(--shadow), 0 0 0 1px rgba(217, 95, 30, 0.04) inset;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.control-panel:hover,
.ternary-card:hover,
.fe-card:hover,
.structure-card:hover,
.interstitial-card:hover,
.stereo-card:hover,
.viewer-panel:hover,
.ternary-view-panel:hover,
.structure-view-panel:hover,
.interstitial-view-panel:hover,
.dislocation-view-panel:hover,
.cs-view-panel:hover,
.stereo-view-panel:hover,
.legend:hover {
  border-color: color-mix(in srgb, var(--ui-accent) 46%, var(--line));
  box-shadow: var(--shadow), 0 0 20px var(--tech-glow);
}

/* HUD 边角括号（单伪元素绘制四角） */
.control-panel::before,
.dislocation-control-panel::before,
.crystal-structure-control-panel::before,
.fe-card::before,
.structure-card::before,
.interstitial-card::before,
.stereo-card::before,
.ternary-card::before,
.readout-panel::before,
.viewer-panel::before,
.ternary-view-panel::before,
.structure-view-panel::before,
.interstitial-view-panel::before,
.dislocation-view-panel::before,
.cs-view-panel::before,
.stereo-view-panel::before,
.legend::before,
.cs-legend::before,
.dislocation-legend::before,
.interstitial-legend::before,
.structure-legend::before,
.ternary-legend::before,
.stereo-legend::before,
.visit-metric::before {
  content: "";
  position: absolute;
  inset: 5px;
  pointer-events: none;
  border-radius: inherit;
  z-index: 2;
  opacity: 0.6;
  background:
    linear-gradient(var(--tech-bracket), var(--tech-bracket)) top left / 13px 2px no-repeat,
    linear-gradient(var(--tech-bracket), var(--tech-bracket)) top left / 2px 13px no-repeat,
    linear-gradient(var(--tech-bracket), var(--tech-bracket)) top right / 13px 2px no-repeat,
    linear-gradient(var(--tech-bracket), var(--tech-bracket)) top right / 2px 13px no-repeat,
    linear-gradient(var(--tech-bracket), var(--tech-bracket)) bottom left / 13px 2px no-repeat,
    linear-gradient(var(--tech-bracket), var(--tech-bracket)) bottom left / 2px 13px no-repeat,
    linear-gradient(var(--tech-bracket), var(--tech-bracket)) bottom right / 13px 2px no-repeat,
    linear-gradient(var(--tech-bracket), var(--tech-bracket)) bottom right / 2px 13px no-repeat;
  transition: opacity 0.2s ease;
}

/* ---------- 视图面板：扫描线 + 屏幕晕影 ---------- */
.viewer-panel::after,
.ternary-view-panel::after,
.structure-view-panel::after,
.interstitial-view-panel::after,
.dislocation-view-panel::after,
.cs-view-panel::after,
.stereo-view-panel::after,
.fe-chart-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  z-index: 1;
  background:
    repeating-linear-gradient(0deg, var(--tech-scan) 0 1px, transparent 1px 3px),
    radial-gradient(130% 120% at 50% 0%, transparent 62%, rgba(0, 0, 0, 0.05));
  opacity: 0.55;
}

html[data-theme="dark"] .viewer-panel::after,
html[data-theme="dark"] .ternary-view-panel::after,
html[data-theme="dark"] .structure-view-panel::after,
html[data-theme="dark"] .interstitial-view-panel::after,
html[data-theme="dark"] .dislocation-view-panel::after,
html[data-theme="dark"] .cs-view-panel::after,
html[data-theme="dark"] .stereo-view-panel::after,
html[data-theme="dark"] .fe-chart-shell::after {
  background:
    repeating-linear-gradient(0deg, var(--tech-scan) 0 1px, transparent 1px 3px),
    radial-gradient(130% 120% at 50% 0%, rgba(255, 134, 71, 0.1), transparent 60%);
  opacity: 0.7;
}

/* ---------- 分段/选择激活态辉光 ---------- */
.segment.is-active,
.dislocation-choice.is-active,
.cs-mode-button.is-active,
.structure-list-item.is-active,
.ternary-region-item.is-active,
.structure-tools .ghost-button.is-active,
.ternary-tools .ghost-button.is-active {
  box-shadow: 0 0 0 1px var(--ui-accent), 0 6px 16px var(--tech-glow);
}

/* ---------- 按钮辉光 ---------- */
.primary-button {
  box-shadow: 0 8px 18px var(--tech-glow);
}
.primary-button:hover {
  box-shadow: 0 10px 24px var(--tech-glow);
}
.ghost-button:hover {
  box-shadow: 0 0 14px var(--tech-glow);
}
.viewer-export-button:hover,
.viewer-reset-button:hover {
  box-shadow: 0 0 16px var(--tech-glow);
}

/* ---------- 聚焦辉光 ---------- */
.index-input:focus,
.small-input:focus,
.cs-select:focus,
.dislocation-select:focus,
.structure-select:focus,
.ternary-select:focus,
.fe-carbon-field input:focus,
.ternary-field input:focus,
.ternary-point-grid input:focus,
.component-input:focus {
  box-shadow: 0 0 0 3.5px var(--focus-ring), 0 0 14px var(--tech-glow);
}

/* ---------- 铁碳滑杆：保留红色轨道，增加辉光 ---------- */
.fe-carbon-range:focus {
  filter: drop-shadow(0 0 6px rgba(237, 28, 36, 0.5));
}

/* ============================================================
   科技感布局层（Tech Layout）
   在视觉层之上强化结构科技感：整页仪器控制台外框 /
   顶栏系统状态簇与导航指示 / 3D 视图 HUD 视窗栏 / 铁碳图区 HUD 顶栏
   不改动任何功能逻辑，仅覆盖样式与极少量装饰元素。
   ============================================================ */

/* ---------- 整页：仪器控制台外框 ---------- */
body {
  padding: 16px;
}

.app-shell {
  max-width: 1760px;
  margin: 0 auto;
  border-radius: 18px;
  border: 1px solid var(--tech-edge);
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(217, 95, 30, 0.06),
    0 30px 90px rgba(20, 30, 40, 0.22),
    inset 0 3px 0 var(--tech-glow);
}

/* ---------- 顶栏：导航指示 + 系统状态簇 ---------- */
.module-nav {
  gap: 6px;
}

.module-tab {
  position: relative;
  letter-spacing: 0.05em;
  transition: color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.module-tab:not(.is-active):hover {
  box-shadow: 0 0 14px var(--tech-glow);
  border-color: color-mix(in srgb, var(--ui-accent) 50%, var(--line));
}

.module-tab.is-active::after {
  content: "";
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 5px;
  height: 2px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.9);
  opacity: 0.92;
}

.sys-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--tech-edge);
  border-radius: 999px;
  background: rgba(217, 95, 30, 0.08);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--muted);
  box-shadow: 0 0 12px var(--tech-glow);
}

.sys-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2ecc71;
  box-shadow: 0 0 8px #2ecc71;
  animation: tech-pulse 1.8s ease-in-out infinite;
}

.sys-status .sys-text {
  color: var(--ui-accent);
  font-weight: 800;
}

/* ---------- 3D 视图 HUD 视窗栏（浮层） ---------- */
.panel-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--ui-accent) 18%, transparent),
    color-mix(in srgb, var(--ui-accent) 5%, transparent)
  );
  border-bottom: 1px solid var(--tech-edge);
  backdrop-filter: blur(6px);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  color: var(--muted);
  pointer-events: none;
}

.panel-hud-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ui-accent);
  box-shadow: 0 0 8px var(--ui-accent);
  animation: tech-pulse 1.8s ease-in-out infinite;
}

.panel-hud-title {
  color: var(--ui-accent);
  font-weight: 800;
}

.panel-hud-sub {
  opacity: 0.72;
}

.panel-hud-status {
  margin-left: auto;
  opacity: 0.85;
  color: var(--muted);
}

/* 让 3D 画布从 HUD 下方开始，避免 HUD 遮住视图顶部细节（HUD 作为窗口标题栏而非画布浮层） */
.viewer-panel > .scene-host,
.cs-view-panel > .cs-viewer-host,
.dislocation-view-panel > .dislocation-viewer-host,
.ternary-view-panel > .ternary-viewer-host {
  top: 38px;
}

/* ---------- 铁碳图区顶栏 HUD 化 ---------- */
.fe-chart-panel {
  position: relative;
}

.fe-panel-head {
  position: relative;
  padding: 12px 16px;
  border-left: 3px solid var(--ui-accent);
  box-shadow: -1px 0 0 var(--tech-glow);
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--ui-accent) 9%, transparent),
    transparent 60%
  );
}

.fe-panel-head h2 {
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

.fe-panel-head p {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* ---------- 窄屏：收起仪器外框与冗余装饰 ---------- */
@media (max-width: 720px) {
  body {
    padding: 0;
  }
  .app-shell {
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: 0 0 0 1px rgba(217, 95, 30, 0.06);
  }
  .sys-status {
    display: none;
  }
  .panel-hud {
    height: 30px;
  }
}

@keyframes tech-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.78); }
}

/* ============================================================
   科技感 · 个性增强层（Persona Layer）
   在保留橙色主色调前提下强化"全息实验仪表"辨识度：
   大气层呼吸光 / 开机自检序列 / 视窗扫描光束 /
   整机流光描边 / 定制滚动条与选区 / 暗色玻璃质感 /
   激活态辉光脉动。所有新增装饰 pointer-events:none 不挡交互。
   ============================================================ */

/* ---------- 大气层：固定全屏的缓慢呼吸橙光 + 大格漂移 ---------- */
.tech-atmos {
  position: fixed;
  inset: -30%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(46% 38% at 50% 8%, var(--tech-glow), transparent 70%),
    linear-gradient(var(--tech-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--tech-grid) 1px, transparent 1px);
  background-size: auto, 64px 64px, 64px 64px;
  opacity: 0.5;
  animation: tech-aurora 10s ease-in-out infinite;
}
@keyframes tech-aurora {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); opacity: 0.4; }
  50% { transform: translate3d(0, 22px, 0) scale(1.06); opacity: 0.6; }
}

/* ---------- 整机流光描边：沿顶边移动的签名高光 ---------- */
.app-shell::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--ui-accent), #fff, var(--ui-accent), transparent);
  background-size: 45% 100%;
  background-repeat: no-repeat;
  animation: tech-sweep-x 6s linear infinite;
  opacity: 0.9;
  pointer-events: none;
  z-index: 7;
}
@keyframes tech-sweep-x {
  0% { background-position: -45% 0; }
  100% { background-position: 145% 0; }
}

/* ---------- 视窗扫描光束（4 个 3D 视图内） ---------- */
.scan-beam {
  position: absolute;
  left: 0;
  right: 0;
  top: 38px;
  height: 110px;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent,
    color-mix(in srgb, var(--ui-accent) 26%, transparent),
    transparent
  );
  mix-blend-mode: screen;
  opacity: 0;
  animation: tech-beam 7s ease-in-out infinite;
}
@keyframes tech-beam {
  0% { transform: translateY(0); opacity: 0; }
  9% { opacity: 0.9; }
  48% { opacity: 0.9; }
  58% { transform: translateY(540px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}

/* ---------- 顶栏系统状态簇：闪烁指示文字 ---------- */
.sys-text::after {
  content: "_";
  animation: tech-blink 1.1s step-end infinite;
}
@keyframes tech-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ---------- 激活态 tab：叠加辉光脉动（保留原有 shimmer） ---------- */
.module-tab.is-active {
  animation: tech-shimmer 4.5s linear infinite, tech-tab-glow 2.8s ease-in-out infinite;
}
@keyframes tech-tab-glow {
  0%, 100% {
    box-shadow: 0 0 0 1px var(--ui-accent), 0 8px 22px var(--tech-glow);
  }
  50% {
    box-shadow: 0 0 0 1px var(--ui-accent), 0 8px 30px var(--tech-glow), 0 0 18px var(--tech-glow);
  }
}

/* ---------- 暗色：玻璃质感面板（通透、有层次） ---------- */
html[data-theme="dark"] .control-panel,
html[data-theme="dark"] .ternary-card,
html[data-theme="dark"] .fe-card,
html[data-theme="dark"] .structure-card,
html[data-theme="dark"] .interstitial-card,
html[data-theme="dark"] .stereo-card,
html[data-theme="dark"] .readout-panel,
html[data-theme="dark"] .viewer-panel,
html[data-theme="dark"] .ternary-view-panel,
html[data-theme="dark"] .structure-view-panel,
html[data-theme="dark"] .interstitial-view-panel,
html[data-theme="dark"] .dislocation-view-panel,
html[data-theme="dark"] .cs-view-panel,
html[data-theme="dark"] .stereo-view-panel,
html[data-theme="dark"] .legend,
html[data-theme="dark"] .cs-legend,
html[data-theme="dark"] .dislocation-legend,
html[data-theme="dark"] .interstitial-legend,
html[data-theme="dark"] .structure-legend,
html[data-theme="dark"] .ternary-legend,
html[data-theme="dark"] .stereo-legend,
html[data-theme="dark"] .visit-metric {
  background-color: color-mix(in srgb, var(--bg) 74%, transparent);
  backdrop-filter: blur(9px) saturate(1.15);
  -webkit-backdrop-filter: blur(9px) saturate(1.15);
}

/* ---------- 定制滚动条 + 选区（橙系） ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--ui-accent) transparent;
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--ui-accent), color-mix(in srgb, var(--ui-accent) 55%, #000));
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ui-accent);
  background-clip: padding-box;
}
::selection {
  background: var(--ui-accent);
  color: #fff;
}

/* ---------- 开机自检序列（仅首屏，会话内只播一次） ---------- */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 120% at 50% 42%, rgba(28, 18, 12, 0.96), rgba(8, 6, 4, 0.99));
  animation: boot-out 0.55s ease 1.5s forwards;
  pointer-events: none;
}
.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  font-family: var(--font-mono);
  color: var(--ui-accent);
  letter-spacing: 0.24em;
}
.boot-logo {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 800;
  text-shadow: 0 0 22px var(--tech-glow);
  letter-spacing: 0.12em;
}
.boot-bar {
  width: 230px;
  height: 3px;
  border-radius: 2px;
  background: rgba(217, 95, 30, 0.22);
  overflow: hidden;
  position: relative;
}
.boot-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--ui-accent), #fff);
  transform: translateX(-100%);
  animation: boot-load 1.4s ease forwards;
}
.boot-status {
  font-size: 12px;
  opacity: 0.85;
  min-height: 1em;
}
.boot-status::after {
  content: "";
  animation: boot-typing 1.4s steps(1) forwards;
}
@keyframes boot-load {
  to { transform: translateX(0); }
}
@keyframes boot-out {
  to { opacity: 0; visibility: hidden; }
}
.boot-skip .boot-screen {
  display: none;
}

/* ============================================================
   科技感 · 布局大改（指挥中枢 Deck Layout）
   左导航栏 + 顶部状态条 + 舞台；并重分区所有视图悬浮层，
   彻底消除遮挡：顶栏 HUD / 左上徽标 / 左下角图例 / 右下按钮 四区互不重叠。
   不改动任何功能逻辑，仅覆盖样式与极少量装饰元素。
   ============================================================ */

/* ---------- 外壳：左右分栏（导航栏 + 主列） ---------- */
.app-shell {
  display: flex;
  min-height: calc(100vh - 32px);
  grid-template-rows: none;
}

/* ---------- 左导航栏 ---------- */
.nav-rail {
  flex: 0 0 112px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 14px 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--ui-accent) 12%, var(--panel)), var(--panel));
  border-right: 1px solid var(--tech-edge);
  z-index: 4;
}

.nav-rail-brand {
  display: grid;
  place-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--tech-edge);
}
.nav-rail-logo {
  width: 68px;
  height: auto;
  filter: drop-shadow(0 3px 10px var(--tech-glow));
}

.nav-rail-foot {
  margin-top: auto;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--tech-edge);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-align: center;
}
.nav-rail-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ui-accent);
}

/* ---------- 主列 + 顶部状态条 + 舞台 ---------- */
.main-col {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.top-strip {
  flex: 0 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--tech-edge);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 8px 24px var(--tech-glow);
  z-index: 3;
}

.top-strip-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.top-strip-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-shadow: 0 0 16px var(--tech-glow);
  white-space: nowrap;
}
.top-strip-sep {
  color: var(--muted);
}
.top-strip-module {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--ui-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  padding: 18px;
  overflow: auto;
}

/* ---------- 导航按钮：竖向图标 + 文字 ---------- */
.module-nav {
  flex-direction: column;
  align-items: stretch;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
}
.module-nav::-webkit-scrollbar {
  display: none;
}

.module-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 66px;
  padding: 10px 4px;
  border-radius: 12px;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  line-height: 1.15;
}
.module-tab .tab-glyph {
  font-size: 22px;
  line-height: 1;
}
.module-tab .tab-label {
  font-size: 15px;
  font-weight: 800;
}
/* 激活态：左侧指示条（替代原底部白条） */
.module-tab.is-active::after {
  left: 0;
  right: auto;
  top: 14px;
  bottom: 14px;
  width: 3px;
  height: auto;
  border-radius: 3px;
}

/* ---------- 视图悬浮层重新分区，彻底消除遮挡 ----------
   分区规则：
     顶栏 HUD  →  top:0，高 34px，整宽（最高层之一）
     徽标      →  左上 top:46px（HUD 之下）
     叠加卡    →  左上 top:104px（徽标之下，限高）
     图例      →  左下角 bottom:16px left:12px（与右下按钮分区）
     按钮      →  右下角 right:12px bottom:16/62px
   扫描光束 z=5，其余浮层 z>=24 均在其上，光带仅从下方掠过不遮挡文字。
*/
.cs-view-badge,
.dislocation-view-badge {
  top: 46px;
  left: 12px;
  max-width: calc(100% - 160px);
  z-index: 25;
}

.dislocation-stacking-compare {
  top: 46px; /* 与左上角 .dislocation-view-badge 同行 */
  right: 12px;
  left: auto;
  bottom: auto;
  min-height: 68px; /* 与 .dislocation-view-badge 视觉等高 */
  z-index: 25;
}

.cs-legend,
.dislocation-legend,
.ternary-legend {
  position: absolute;
  left: 12px;
  right: auto;
  bottom: 16px;
  top: auto;
  max-width: min(360px, calc(100% - 200px));
  z-index: 24;
}

.viewer-export-button {
  right: 12px;
  bottom: 14px;
  min-height: 34px;
  padding: 0 13px;
  font-size: 13px;
  z-index: 26;
}
.viewer-reset-button {
  right: 12px;
  bottom: 52px; /* 与导出图片按钮间距收紧（原 62px） */
  min-height: 34px;
  padding: 0 13px;
  font-size: 13px;
  z-index: 26;
}

/* ---------- 窄屏：导航栏转为顶部横条，避免挤压内容 ---------- */
@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }
  .nav-rail {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-right: none;
    border-bottom: 1px solid var(--tech-edge);
    overflow-x: auto;
  }
  .nav-rail-brand {
    border-bottom: none;
    border-right: 1px solid var(--tech-edge);
    padding: 0 6px 0 0;
  }
  .nav-rail-logo {
    width: 44px;
  }
  .nav-rail-foot {
    display: none;
  }
  .module-nav {
    flex: 1 0 auto;
    flex-direction: row;
    gap: 2px;
    height: auto;
  }
  .module-tab {
    flex: 1 0 58px;
    min-width: 58px;
    min-height: 0;
    padding: 8px 2px;
    border-radius: 10px;
  }
  .module-tab .tab-label {
    font-size: 14px;
  }
  .module-tab.is-active::after {
    left: 14px;
    right: 14px;
    top: auto;
    bottom: 4px;
    width: auto;
    height: 2px;
  }
  .top-strip {
    height: 48px;
    padding: 0 12px;
  }
  .top-strip-title {
    font-size: 15px;
  }
  .stage {
    padding: 12px;
  }
}

/* ---------- 尊重减少动态偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  .tech-atmos,
  .app-shell::after,
  .scan-beam,
  .sys-text::after,
  .module-tab.is-active,
  .boot-screen,
  .boot-bar::after {
    animation: none !important;
  }
  .boot-screen { display: none; }
}
