/* ============================================================
   主题精修层 · 暖橙品牌统一版
   加载于 styles.css 之后，只做视觉覆盖，不改变任何布局结构与功能。
   目标：统一配色（清除硬编码蓝灰）、现代字体、统一圆角/阴影/控件语言。
   ============================================================ */

:root {
  /* 暖纸底色体系 */
  --bg: #f7f2ec;
  --workspace-bg: #f3ece4;
  --panel: #ffffff;
  --panel-soft: #faf6f1;
  --panel-strong: #f2e9df;
  --panel-translucent: rgba(255, 253, 250, 0.92);
  --ink: #2d231b;
  --ink-soft: #584739;
  --muted: #8d7a6b;
  --line: #e7dccf;
  --line-strong: #cbb9a7;

  /* 品牌暖橙 */
  --ui-accent: #d95f1e;
  --ui-accent-strong: #b04a12;
  --ui-accent-soft: #fdeede;
  --active-bg: #d95f1e;
  --active-ink: #ffffff;
  --focus-ring: rgba(217, 95, 30, 0.22);

  /* 旧变量重映射：原 --blue 是冷蓝，统一并入品牌橙 */
  --blue: #d95f1e;
  --yellow: #d99b2b;
  --accent: #d94f79;
  --violet: #7c5ac5;

  /* 图形语义色微调（更通透） */
  --cell: #2e3d4d;
  --plane: #ef6c00;
  --direction: #5b6cd9;

  --topbar-bg: rgba(255, 253, 250, 0.88);
  --grid-line: rgba(148, 108, 72, 0.09);
  --viewer-bg: #faf6f1;
  --input-bg: #fffdfb;
  --shadow: 0 12px 32px rgba(96, 63, 37, 0.1);

  /* 圆角体系 */
  --r-lg: 14px;
  --r-md: 11px;
  --r-sm: 8px;

  font-family: "Times New Roman", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "微软雅黑", serif;
}

html[data-theme="dark"] {
  --bg: #16110d;
  --workspace-bg: #1b1510;
  --panel: #231b15;
  --panel-soft: #2a211a;
  --panel-strong: #33271e;
  --panel-translucent: rgba(35, 27, 21, 0.92);
  --ink: #f3e9df;
  --ink-soft: #dccabd;
  --muted: #b3a08f;
  --line: #453428;
  --line-strong: #6b513f;

  --ui-accent: #ff8647;
  --ui-accent-strong: #ffab74;
  --ui-accent-soft: rgba(255, 134, 71, 0.15);
  --active-bg: #ff8647;
  --active-ink: #2b1507;
  --focus-ring: rgba(255, 134, 71, 0.26);

  --blue: #ff8647;
  --cell: #d5e0e9;
  --plane: #f08a61;
  --direction: #8b95e8;

  --topbar-bg: rgba(22, 17, 13, 0.88);
  --grid-line: rgba(216, 152, 102, 0.08);
  --viewer-bg: #1e1712;
  --input-bg: #1f1712;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.36);
}

/* ---------- 全局字体与数字 ---------- */
body,
button,
input,
select,
textarea,
.dislocation-range-label output,
.dislocation-choice span,
.dislocation-stack-sequence {
  font-family: "Times New Roman", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "微软雅黑", serif;
}

.metric-list dd,
.fe-composition-strip strong,
.interstitial-meta dd,
.dislocation-range-label output,
.stereo-status-card strong,
.visit-metric strong {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* ---------- 顶栏 ---------- */
.topbar {
  row-gap: 14px;
  padding: 16px 26px 18px;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 10px 30px rgba(96, 63, 37, 0.06);
  backdrop-filter: blur(16px) saturate(1.15);
}

h1 {
  font-size: 23px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.brand .brand-name {
  color: var(--ui-accent);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.brand .visit-ordinal {
  border: 0;
  border-radius: 999px;
  padding: 0 11px;
  min-height: 24px;
  color: var(--ui-accent-strong);
  background: var(--ui-accent-soft);
  font-size: 12.5px;
  font-weight: 800;
}

.brand-logo {
  height: 62px;
  filter: drop-shadow(0 3px 8px rgba(96, 63, 37, 0.14));
}

/* ---------- 模块导航：铺满顶端 + 大字号加粗 ---------- */
.module-nav {
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-strong);
  width: 100%;
  max-width: 100%;
}

.module-tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.04em;
  transition: color 0.18s ease, background-color 0.18s ease,
    box-shadow 0.18s ease;
}

.module-tab:hover {
  color: var(--ink);
  background: var(--panel-soft);
}

.module-tab.is-active {
  color: #fff;
  background: linear-gradient(135deg, #e2702c, var(--ui-accent));
  box-shadow: 0 6px 16px rgba(217, 95, 30, 0.32);
}

html[data-theme="dark"] .module-tab.is-active {
  color: var(--active-ink);
  background: linear-gradient(135deg, #ff9a5c, var(--ui-accent));
  box-shadow: 0 6px 16px rgba(255, 134, 71, 0.28);
}

.module-tab:disabled {
  color: var(--muted);
  background: transparent;
  opacity: 0.55;
}

/* 桌面宽屏顶栏：导航从通栏分隔条改为居中胶囊组 */
@media (min-width: 1080px) {
  .topbar {
    min-height: 84px;
    padding: 10px 24px;
    grid-template-columns: minmax(280px, 330px) minmax(0, 1fr) 44px;
  }

  .module-nav {
    align-self: center;
    justify-self: stretch;
    width: 100%;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel-strong);
  }

  .module-tab,
  .module-tab + .module-tab {
    flex: 1 1 0;
    min-width: 0;
    min-height: 48px;
    padding: 0 16px;
    border: 0;
    border-radius: 12px;
    color: var(--muted);
    background: transparent;
    font-size: 19px;
    font-weight: 900;
  }

  .module-tab:hover {
    color: var(--ink);
    background: var(--panel-soft);
    border-color: transparent;
  }

  .module-tab.is-active {
    color: #fff;
    background: linear-gradient(135deg, #e2702c, var(--ui-accent));
    box-shadow: 0 6px 16px rgba(217, 95, 30, 0.3);
    border-color: transparent;
  }

  html[data-theme="dark"] .module-tab.is-active {
    color: var(--active-ink);
    background: linear-gradient(135deg, #ff9a5c, var(--ui-accent));
  }

  .brand-logo {
    height: 56px;
  }
}

/* ---------- 主题切换按钮 ---------- */
.theme-toggle {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink-soft);
  background: var(--panel);
  box-shadow: 0 4px 12px rgba(96, 63, 37, 0.1);
  transition: transform 0.16s ease, border-color 0.16s ease,
    color 0.16s ease;
}

.theme-toggle:hover {
  border-color: var(--ui-accent);
  color: var(--ui-accent);
  transform: translateY(-1px);
}

/* ---------- 面板与卡片：统一圆角与阴影 ---------- */
.control-panel,
.dislocation-control-panel,
.crystal-structure-control-panel,
.dislocation-view-panel,
.cs-view-panel,
.fe-chart-panel,
.fe-card,
.structure-card,
.structure-view-panel,
.interstitial-card,
.interstitial-view-panel,
.ternary-card,
.ternary-view-panel,
.visit-head,
.visit-metric,
.visit-detail-panel,
.stereo-card,
.stereo-view-panel {
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

@media (min-width: 821px) {
  .control-panel,
  .stereo-control-panel,
  .structure-control-panel,
  .interstitial-control-panel,
  .ternary-control-panel,
  .fe-info-panel,
  .dislocation-control-panel,
  .crystal-structure-control-panel,
  .fe-chart-panel,
  .viewer-panel,
  .stereo-view-panel,
  .structure-view-panel,
  .interstitial-view-panel,
  .ternary-view-panel,
  .dislocation-view-panel,
  .cs-view-panel {
    border-radius: var(--r-lg);
    border-top-width: 3px;
    box-shadow: 0 16px 40px rgba(96, 63, 37, 0.09);
  }

  html[data-theme="dark"] .control-panel,
  html[data-theme="dark"] .stereo-control-panel,
  html[data-theme="dark"] .structure-control-panel,
  html[data-theme="dark"] .interstitial-control-panel,
  html[data-theme="dark"] .ternary-control-panel,
  html[data-theme="dark"] .fe-info-panel,
  html[data-theme="dark"] .dislocation-control-panel,
  html[data-theme="dark"] .crystal-structure-control-panel,
  html[data-theme="dark"] .fe-chart-panel,
  html[data-theme="dark"] .viewer-panel,
  html[data-theme="dark"] .stereo-view-panel,
  html[data-theme="dark"] .structure-view-panel,
  html[data-theme="dark"] .interstitial-view-panel,
  html[data-theme="dark"] .ternary-view-panel,
  html[data-theme="dark"] .dislocation-view-panel,
  html[data-theme="dark"] .cs-view-panel {
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.4);
  }
}

/* ---------- 分区标签 ---------- */
.control-label {
  color: var(--ink-soft);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

/* ---------- 分段控件 ---------- */
.segmented {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel-strong);
  gap: 4px;
}

.segment {
  min-height: 38px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-weight: 800;
  transition: background-color 0.16s ease, color 0.16s ease,
    box-shadow 0.16s ease;
}

.segment:hover {
  color: var(--ink);
}

/* 选中态基础按钮统一加透明描边，避免切换时尺寸抖动 */
.segment {
  border: 1px solid transparent;
}

.segment.is-active {
  color: #ffffff;
  border-color: var(--ui-accent);
  background: linear-gradient(135deg, #e2702c, var(--ui-accent));
  box-shadow: 0 6px 14px rgba(217, 95, 30, 0.26);
}

html[data-theme="dark"] .segment.is-active {
  color: var(--active-ink);
  border-color: var(--ui-accent);
  background: linear-gradient(135deg, #ff9a5c, var(--ui-accent));
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
}

.mode-segmented .segment.is-active {
  box-shadow: inset 0 -3px 0 var(--plane), 0 3px 10px rgba(96, 63, 37, 0.14);
}

.mode-segmented [data-mode="direction"].is-active {
  box-shadow: inset 0 -3px 0 var(--direction), 0 3px 10px rgba(96, 63, 37, 0.14);
}

.mode-segmented [data-mode="overlay"].is-active {
  box-shadow: inset 0 -3px 0 var(--ui-accent), 0 3px 10px rgba(96, 63, 37, 0.14);
}

/* ---------- 输入框 ---------- */
.index-input,
.small-input,
.cs-select,
.dislocation-select,
.structure-select,
.ternary-select,
.fe-carbon-field input,
.ternary-field input,
.ternary-point-grid input {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--input-bg);
  color: var(--ink);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.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 {
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 3.5px var(--focus-ring);
  outline: none;
}

/* ---------- 按钮 ---------- */
.primary-button,
.ghost-button,
.chip {
  border-radius: var(--r-md);
  font-weight: 800;
  letter-spacing: 0.02em;
  transition: transform 0.14s ease, box-shadow 0.14s ease,
    background-color 0.16s ease, color 0.16s ease,
    border-color 0.16s ease, filter 0.14s ease;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, #e2702c, var(--ui-accent));
  box-shadow: 0 8px 18px rgba(217, 95, 30, 0.28);
}

.primary-button:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(217, 95, 30, 0.34);
}

.primary-button:active {
  transform: translateY(0);
}

html[data-theme="dark"] .primary-button {
  color: var(--active-ink);
  background: linear-gradient(135deg, #ff9a5c, var(--ui-accent));
  box-shadow: 0 8px 18px rgba(255, 134, 71, 0.26);
}

.ghost-button {
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  background: var(--panel);
}

.ghost-button:hover {
  color: var(--ui-accent-strong);
  border-color: var(--ui-accent);
  background: var(--ui-accent-soft);
  filter: none;
}

.ghost-button:disabled {
  color: var(--muted);
  border-color: var(--line);
  background: var(--panel-strong);
  cursor: default;
}

.chip {
  border-radius: 999px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  background: var(--panel-soft);
  font-size: 14px;
}

.chip:hover {
  color: var(--ui-accent-strong);
  border-color: var(--ui-accent);
  background: var(--ui-accent-soft);
  filter: none;
}

/* 列表型选择项（位错/FCC/相区等）激活态统一为品牌橙 */
.dislocation-choice,
.cs-mode-button,
.structure-list-item,
.ternary-region-item,
.stereo-check {
  border-radius: var(--r-md);
  transition: border-color 0.16s ease, background-color 0.16s ease,
    color 0.16s ease, box-shadow 0.16s ease;
}

.dislocation-choice:hover,
.cs-mode-button:hover,
.structure-list-item:hover,
.ternary-region-item:hover {
  border-color: var(--line-strong);
}

.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 {
  color: #fff;
  border-color: var(--ui-accent);
  background: linear-gradient(135deg, #e2702c, var(--ui-accent));
  box-shadow: 0 6px 14px rgba(217, 95, 30, 0.26);
}

html[data-theme="dark"] .dislocation-choice.is-active,
html[data-theme="dark"] .cs-mode-button.is-active,
html[data-theme="dark"] .structure-list-item.is-active,
html[data-theme="dark"] .ternary-region-item.is-active,
html[data-theme="dark"] .structure-tools .ghost-button.is-active,
html[data-theme="dark"] .ternary-tools .ghost-button.is-active {
  color: var(--active-ink);
  border-color: var(--ui-accent);
  background: linear-gradient(135deg, #ff9a5c, var(--ui-accent));
}

.structure-list-item.is-active small,
.ternary-region-item.is-active small {
  color: rgba(255, 255, 255, 0.78);
}

html[data-theme="dark"] .structure-list-item.is-active small,
html[data-theme="dark"] .ternary-region-item.is-active small {
  color: color-mix(in srgb, var(--active-ink) 74%, transparent);
}

/* ---------- 数据展示块 ---------- */
.readout-panel,
.cs-meta div,
.dislocation-meta div,
.fe-detail-list div,
.structure-meta div,
.interstitial-meta div,
.ternary-meta div,
.visit-detail-list div,
.metric-list div,
.fe-composition-strip {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel-soft);
}

.readout-panel {
  gap: 12px;
}

.status-dot {
  box-shadow: 0 0 0 4px var(--lattice-soft);
}

/* ---------- 滑杆 ---------- */
input[type="range"] {
  accent-color: var(--ui-accent);
}

.dislocation-range,
.fe-carbon-range,
.interstitial-range,
.structure-slider input {
  accent-color: var(--ui-accent);
}

/* ---------- 视图区徽标与图例 ---------- */
.legend,
.cs-legend,
.dislocation-legend,
.interstitial-legend,
.structure-legend,
.ternary-legend,
.stereo-legend {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-translucent);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 22px rgba(96, 63, 37, 0.1);
}

.dislocation-view-badge,
.cs-view-badge,
.interstitial-view-badge,
.structure-view-badge,
.stereo-view-badge,
.dislocation-stacking-compare {
  border-left: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-translucent);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 22px rgba(96, 63, 37, 0.1);
  position: absolute;
}

/* 徽标左侧彩色条改为圆角小竖条 */
.dislocation-view-badge::before,
.cs-view-badge::before,
.interstitial-view-badge::before,
.structure-view-badge::before,
.stereo-view-badge::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--ui-accent);
}

.structure-view-badge::before {
  background: var(--plane);
}

.stereo-view-badge::before {
  background: var(--direction);
}

.interstitial-view-badge::before {
  background: var(--lattice-accent);
}

.cs-legend-item {
  border-radius: 999px;
}

.cs-legend-item:hover,
.cs-legend-item.is-active {
  border-color: var(--ui-accent);
  color: var(--ui-accent-strong);
  background: var(--ui-accent-soft);
}

/* ---------- 铁碳相图细节 ---------- */
.fe-panel-head h2,
.fe-card-title h3 {
  letter-spacing: 0.01em;
}

.fe-kicker {
  color: var(--ui-accent-strong);
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

html[data-theme="dark"] .fe-kicker {
  color: var(--ui-accent);
}

.fe-room-section-title::before {
  border-radius: 3px;
}

.fe-bar-fill {
  height: 10px;
}

.fe-chart-shell {
  border-radius: var(--r-md);
}

/* ---------- 复选开关行 ---------- */
.cs-toggle-row,
.stereo-check {
  border-radius: var(--r-md);
}

.cs-toggle-row:hover,
.stereo-check:hover {
  border-color: var(--line-strong);
}

.cs-toggle-row input,
.stereo-check input {
  accent-color: var(--ui-accent);
}

/* ---------- 图标按钮 ---------- */
.viewer-icon-button {
  border-radius: 12px;
  transition: color 0.16s ease, border-color 0.16s ease,
    transform 0.14s ease;
}

.viewer-icon-button:hover {
  border-color: var(--ui-accent);
  color: var(--ui-accent);
  transform: translateY(-1px);
}

/* ---------- 焦点可见性 ---------- */
.module-tab:focus-visible,
.segment:focus-visible,
.primary-button:focus-visible,
.ghost-button:focus-visible,
.chip:focus-visible,
.dislocation-choice:focus-visible,
.cs-mode-button:focus-visible,
.structure-list-item:focus-visible,
.ternary-region-item:focus-visible,
.cs-legend-item:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ---------- 移动端细节收束 ---------- */
@media (max-width: 820px) {
  .topbar {
    row-gap: 10px;
    padding: 10px 12px;
  }

  .module-nav {
    gap: 6px;
    padding: 4px;
    border-radius: 14px;
  }

  .module-tab {
    flex: 1 0 auto;
    min-height: 38px;
    padding: 0 14px;
    font-size: 16px;
    font-weight: 900;
  }

  .brand .visit-ordinal {
    font-size: 12px;
  }
}

/* ============================================================
   排版精修层（v3）
   1) 工作区限宽居中，超宽屏不再松散
   2) 顶栏标题区重排：主标题 / 副标题 / 访问徽标同行
   3) 控制面板分区节奏：统一内边距 + 细分隔线
   4) 文本行高与字距微调
   ============================================================ */

/* ---------- 1) 工作区限宽居中 ---------- */
@media (min-width: 821px) {
  .workspace,
  .crystal-structure-workspace,
  .dislocation-workspace,
  .fe-workspace,
  .ternary-workspace,
  .stereo-workspace,
  .structure-workspace,
  .interstitial-workspace {
    width: 100%;
    max-width: 1560px;
    margin-inline: auto;
  }

  .crystal-module,
  .crystal-structure-module,
  .dislocation-module,
  .iron-carbon-module,
  .ternary-module,
  .stereo-module,
  .structure-module,
  .interstitial-module {
    padding-inline: 26px;
  }
}

@media (min-width: 1700px) {
  .workspace,
  .crystal-structure-workspace,
  .dislocation-workspace,
  .fe-workspace,
  .ternary-workspace,
  .stereo-workspace,
  .structure-workspace,
  .interstitial-workspace {
    max-width: 1640px;
  }
}

/* ---------- 2) 顶栏标题区重排 ---------- */
.brand > div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 12px;
  row-gap: 4px;
  min-width: 0;
}

.brand h1 {
  font-size: 24px;
  letter-spacing: 0.03em;
}

.brand p {
  margin: 0;
}

.brand .brand-name {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--ui-accent);
}

.brand .visit-ordinal {
  align-self: center;
  margin-top: 0;
}

@media (min-width: 1080px) {
  .brand h1 {
    font-size: 21px;
  }
}

/* ---------- 3) 控制面板分区节奏（桌面端） ---------- */
@media (min-width: 821px) {
  /* 桌面端 crystal control-panel 保持默认块级布局，不套用手机端紧凑 grid */

  /* 晶面截距读出行 */
  .crystal-module .intercept-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
  }
  .crystal-module .intercept-label {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--ui-accent);
  }
  .crystal-module .intercept-values {
    font-family: "Times New Roman", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "微软雅黑", serif;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--ink);
  }

  /* 其余模块面板：卡片内边距与分隔线统一 */
  .dislocation-section,
  .cs-card,
  .ternary-card,
  .stereo-card,
  .structure-card,
  .interstitial-card {
    padding: 15px 16px;
  }

  .fe-info-panel .fe-card {
    padding: 15px 16px;
  }
}

/* ---------- 4) 文本节奏微调 ---------- */
.fe-note,
#csNote,
#dislocationNote,
#ternaryNote {
  line-height: 1.68;
}

.fe-panel-head h2,
.structure-head-card h2,
.ternary-head-card h2,
.interstitial-head-card h2,
.stereo-head-card h2,
.visit-head h2 {
  letter-spacing: 0.02em;
}

.metric-list dd,
.cs-meta dd,
.dislocation-meta dd,
.ternary-meta dd,
.fe-detail-list dd {
  letter-spacing: 0.01em;
}

.input-hint {
  line-height: 1.5;
}

/* 视图区徽标排版 */
.dislocation-view-badge,
.cs-view-badge,
.interstitial-view-badge,
.structure-view-badge,
.stereo-view-badge {
  padding: 10px 14px 10px 16px;
  gap: 4px;
}

.dislocation-view-badge strong,
.cs-view-badge strong {
  letter-spacing: 0.02em;
}

/* 图例与工具条行内节奏 */
.legend,
.cs-legend,
.dislocation-legend,
.interstitial-legend,
.structure-legend,
.ternary-legend,
.stereo-legend {
  gap: 12px;
  padding: 10px 14px;
}

/* cs 模块图例单独收紧（用户反馈 2026-08-10） */
.cs-legend {
  gap: 5px;
  padding: 6px 7px;
  font-size: 13px;
}

/* ============================================================
   定向调整（v4）
   1) 品牌区移到右上角
   2) 晶系板块字体调大
   3) 对象板块字体调小
   ============================================================ */

/* ---------- 1) 品牌区移到右上角 ---------- */
@media (min-width: 1080px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "nav brand actions";
  }

  .brand {
    justify-self: end;
    flex-direction: row-reverse;
  }

  .brand > div {
    justify-content: flex-end;
    text-align: right;
  }
}

@media (max-width: 1079px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "actions brand"
      "nav nav";
  }

  .topbar-actions {
    justify-self: start;
  }

  .brand {
    justify-self: end;
    flex-direction: row-reverse;
  }

  .brand > div {
    justify-content: flex-end;
    text-align: right;
  }
}

/* 晶系 / 对象 改为竖向排列（按钮上下堆叠，单列） */
.crystal-module .segmented,
.crystal-module .mode-segmented {
  grid-template-columns: minmax(0, 1fr);
}

/* ---------- 2) 晶系板块字体调大 ---------- */
.crystal-module .system-section .segment {
  min-height: 48px;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

/* ---------- 3) 对象板块字体调小 ---------- */
.crystal-module .mode-segmented .segment {
  min-height: 40px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

@media (max-width: 820px) {
  .crystal-module .system-section .segment {
    min-height: 38px;
    font-size: 16px;
    letter-spacing: 0.05em;
  }

  .crystal-module .mode-segmented .segment {
    min-height: 34px;
    font-size: 13px;
    letter-spacing: 0.01em;
  }
}

/* ============================================================
   定向调整（v5）
   1) 品牌区移回导航栏上方（覆盖 v4 的右上角方案）
   2) 访问统计元素已从 HTML 删除
   ============================================================ */

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "brand actions"
    "nav nav";
  row-gap: 12px;
}

.brand {
  justify-self: start;
  flex-direction: row;
}

.brand > div {
  justify-content: flex-start;
  text-align: left;
}

.topbar-actions {
  justify-self: end;
}

@media (min-width: 1080px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "nav nav";
    min-height: 118px;
  }
}

/* ============================================================
   定向调整（v6）：品牌区在导航上方整行居中
   品牌区横跨第一行并居中；主题切换按钮浮于右上角
   ============================================================ */

.brand {
  grid-column: 1 / -1;
  grid-row: 1;
  justify-self: center;
}

.brand > div {
  justify-content: center;
  text-align: center;
}

.topbar-actions {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  z-index: 1;
}

/* ============================================================
   定向调整（v7）：主题切换按钮改为中文文字按钮
   ============================================================ */

.theme-toggle {
  width: auto;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
}

.theme-toggle span {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1;
}

@media (min-width: 1080px) {
  .theme-toggle {
    width: auto;
    height: 40px;
  }
}

@media (max-width: 820px) {
  .theme-toggle {
    width: auto;
    height: 34px;
    padding: 0 12px;
  }

  .theme-toggle span {
    font-size: 13px;
  }
}

/* ============================================================
   定向调整（v8）：铁碳相图含量条改色
   铁素体 α / 组织条 → 浅蓝渐变；渗碳体 Fe3C → 紫色渐变
   ============================================================ */

.fe-bar-fill {
  background: linear-gradient(90deg, #5ea3f7, #9cc7fb);
}

.fe-bar-cementite {
  background: linear-gradient(90deg, #8b5cf6, #c0a6f7);
}

html[data-theme="dark"] .fe-bar-fill {
  background: linear-gradient(90deg, #3f8bf2, #7fb5f8);
}

html[data-theme="dark"] .fe-bar-cementite {
  background: linear-gradient(90deg, #9d74f8, #c8b3fa);
}

/* ============================================================
   定向调整（v10）：组织含量条统一为橙色
   只作用于 #structureBreakdown 内的条子，相含量条不受影响
   ============================================================ */

#structureBreakdown .fe-bar-fill {
  background: linear-gradient(90deg, #e2702c, #f2a86b);
}

html[data-theme="dark"] #structureBreakdown .fe-bar-fill {
  background: linear-gradient(90deg, #ff8647, #ffb87e);
}

/* ============================================================
   定向调整（v12）：铁碳相图选定成分控件改橘红色
   滑杆 + 相图虚线游标统一橘红；虚线变细（2px）变密（4/3）
   ============================================================ */

.fe-carbon-range {
  accent-color: #ed1c24;
}

.fe-carbon-cursor line {
  stroke: #ed1c24;
  stroke-width: 2;
  stroke-dasharray: 4 3;
}

.fe-carbon-cursor polygon {
  fill: #ed1c24;
}

html[data-theme="dark"] .fe-carbon-range {
  accent-color: #ff3b3b;
}

html[data-theme="dark"] .fe-carbon-cursor line {
  stroke: #ff3b3b;
}

html[data-theme="dark"] .fe-carbon-cursor polygon {
  fill: #ff3b3b;
}

/* ============================================================
   定向调整（v20）：铁碳相图拖动条轨道改为鲜红
   原 accent-color 下未填充轨道会渲染成 accent 色的淡橙残留，
   这里用 appearance:none + 自定义 track/thumb 显式控制为鲜红，
   已填充部分通过 JS 注入的 --fe-fill 变量驱动渐变
   ============================================================ */

.fe-carbon-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  accent-color: #ed1c24;
  cursor: pointer;
}

.fe-carbon-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    #ed1c24 0%,
    #ed1c24 var(--fe-fill, 0%),
    rgba(237, 28, 36, 0.2) var(--fe-fill, 0%),
    rgba(237, 28, 36, 0.2) 100%
  );
}

.fe-carbon-range::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(237, 28, 36, 0.2);
}

.fe-carbon-range::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: #ed1c24;
}

.fe-carbon-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -6px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 0;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2018%2018'%3E%3Cpolygon%20points='9,1%2017,17%201,17'%20fill='%23ed1c24'%20stroke='%23ffffff'%20stroke-width='2'%20stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 18px 18px;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
}

.fe-carbon-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 0;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2018%2018'%3E%3Cpolygon%20points='9,1%2017,17%201,17'%20fill='%23ed1c24'%20stroke='%23ffffff'%20stroke-width='2'%20stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 18px 18px;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
}

html[data-theme="dark"] .fe-carbon-range::-webkit-slider-runnable-track {
  background: linear-gradient(
    90deg,
    #ff3b3b 0%,
    #ff3b3b var(--fe-fill, 0%),
    rgba(255, 59, 59, 0.22) var(--fe-fill, 0%),
    rgba(255, 59, 59, 0.22) 100%
  );
}

html[data-theme="dark"] .fe-carbon-range::-moz-range-track {
  background: rgba(255, 59, 59, 0.22);
}

html[data-theme="dark"] .fe-carbon-range::-moz-range-progress {
  background: #ff3b3b;
}

html[data-theme="dark"] .fe-carbon-range::-webkit-slider-thumb {
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2018%2018'%3E%3Cpolygon%20points='9,1%2017,17%201,17'%20fill='%23ff3b3b'%20stroke='%232b1507'%20stroke-width='2'%20stroke-linejoin='round'/%3E%3C/svg%3E");
}

html[data-theme="dark"] .fe-carbon-range::-moz-range-thumb {
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2018%2018'%3E%3Cpolygon%20points='9,1%2017,17%201,17'%20fill='%23ff3b3b'%20stroke='%232b1507'%20stroke-width='2'%20stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ============================================================
   定向调整（v13）：相图相区标注斜体 + Fe3C 下标样式
   ============================================================ */

.fe-phase-label {
  font-style: italic;
}

.fe-chart-labels sub,
.fe-chart-labels .fe-phase-label sub {
  font-size: 72%;
}

/* 信息面板下标基线对齐 */
.fe-card sub,
.fe-composition-strip sub,
.fe-room-method sub,
.fe-bar-label sub {
  font-size: 75%;
  vertical-align: baseline;
  position: relative;
  top: 0.3em;
}

/* ============================================================
   定向调整（v14/v15）：铁碳相图导出按钮缩小并移到右上角
   避免遮挡底部坐标轴；半透明进一步降低遮挡感
   ============================================================ */

.fe-chart-shell .viewer-export-button {
  top: 8px;
  right: 8px;
  bottom: auto;
  min-height: 26px;
  padding: 0 9px;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  opacity: 0.88;
  box-shadow: 0 3px 10px rgba(96, 63, 37, 0.1);
}

.fe-chart-shell .viewer-export-button:hover {
  opacity: 1;
}

@media (max-width: 820px) {
  .fe-chart-shell .viewer-export-button {
    top: 6px;
    right: 6px;
    bottom: auto;
    min-height: 24px;
    padding: 0 7px;
    font-size: 10.5px;
  }
}

/* ============================================================
   定向调整（v16）：移动端导航五板块一屏显示
   标签等分压缩，不再横向滑动
   ============================================================ */

@media (max-width: 820px) {
  .module-nav {
    gap: 3px;
    padding: 3px;
    width: 100%;
    overflow: visible;
  }

  .module-tab {
    flex: 1 1 0;
    min-width: 0;
    min-height: 34px;
    padding: 0 2px;
    font-size: 12.5px;
    font-weight: 900;
    letter-spacing: 0;
    text-align: center;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  .module-tab {
    min-height: 32px;
    padding: 0 1px;
    font-size: 11.5px;
  }
}

/* ============================================================
   定向调整（v9/v11）：视图右下角悬浮按钮
   「导出图片」「默认视角」移入各视图面板内部，
   定位于右下角、图例上方，上下堆叠
   ============================================================ */

.viewer-export-button,
.viewer-reset-button {
  position: absolute;
  right: 16px;
  z-index: 6;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--panel-translucent);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 20px rgba(96, 63, 37, 0.14);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.viewer-export-button {
  bottom: 68px;
}

.viewer-reset-button {
  bottom: 114px;
}

.viewer-export-button:hover,
.viewer-reset-button:hover {
  color: var(--ui-accent-strong);
  border-color: var(--ui-accent);
  background: var(--ui-accent-soft);
}

/* 铁碳相图：图表容器内无图例，直接贴右下角 */
.fe-chart-shell {
  position: relative;
}

.fe-chart-shell .viewer-export-button {
  right: 12px;
  bottom: 12px;
}

@media (max-width: 820px) {
  .viewer-export-button,
  .viewer-reset-button {
    right: 10px;
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
  }

  .viewer-export-button {
    bottom: 54px;
  }

  .viewer-reset-button {
    bottom: 90px;
  }

  .fe-chart-shell .viewer-export-button {
    right: 8px;
    bottom: 8px;
  }
}

/* ============================================================
   定向调整（v17）：晶向模块图例已删除，按钮下移补位
   ============================================================ */

.crystal-module .viewer-export-button {
  bottom: 14px;
}

.crystal-module .viewer-reset-button {
  bottom: 52px;
}

@media (max-width: 820px) {
  .crystal-module .viewer-export-button {
    bottom: 10px;
  }

  .crystal-module .viewer-reset-button {
    bottom: 46px;
  }
}

/* ============================================================
   定向调整（v19）：「手动输入合金成分 wC%」标签贴向输入框
   原 styles.css 用 grid-template-columns: minmax(0, 1fr) 92px
   导致 span 把空白撑满，这里改为自适应宽度 + 整体靠右对齐
   ============================================================ */
.fe-carbon-manual-field {
  grid-template-columns: auto 92px;
  justify-content: end;
  gap: 10px;
  width: auto;
  justify-self: end;
}

.fe-carbon-manual-field span {
  white-space: nowrap;
  color: var(--ink-soft);
  font-size: 13px;
}

/* ---------- 指数分量单独输入 ---------- */
.component-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 6px 0 4px;
}
.component-row[data-system="cubic"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.component-row[data-system="cubic"] .component-cell-optional {
  display: none;
}
.component-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.component-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--ui-accent-strong);
  letter-spacing: 0.04em;
  font-style: italic;
}
.component-input {
  width: 100%;
  height: 36px;
  line-height: 34px;
  text-align: center;
  cursor: text;
  user-select: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  font-family: "Times New Roman", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "微软雅黑", serif;
  font-size: 17px;
  font-weight: 700;
  padding: 0 4px;
  border: 1px solid var(--control-border, rgba(0,0,0,0.15));
  background: var(--panel, #fff);
  color: var(--ink, #1f2933);
  border-radius: 0;
  outline: none;
}
.component-input:empty::before {
  content: attr(data-placeholder);
  color: var(--muted, #aab2bd);
}
.component-input:focus {
  border-color: var(--ui-accent-strong);
  box-shadow: 0 0 0 2px rgba(217, 95, 30, 0.18);
}

@media (max-width: 820px) {
  .fe-carbon-manual-field {
    grid-column: 1 / -1;
    grid-template-columns: auto 80px;
    justify-self: stretch;
    justify-content: space-between;
  }
}
}
