:root {
  --realm-color: #FFC64B;
  --realm-glow: #FFC64B33;
  --realm-glow-44: rgba(255, 198, 75, 0.27);
  --realm-glow-55: rgba(255, 198, 75, 0.33);
  --realm-glow-66: rgba(255, 198, 75, 0.40);
  --realm-glow-25: rgba(255, 198, 75, 0.25);
  --realm-faint: rgba(255, 198, 75, 0.06);
  --realm-tint: rgba(255, 198, 75, 0.08);
  --realm-soft-10: rgba(255, 198, 75, 0.10);
  --realm-soft: rgba(255, 198, 75, 0.12);
  --realm-line: rgba(255, 198, 75, 0.15);
  --realm-glow-20: rgba(255, 198, 75, 0.20);
  --realm-glow-50: rgba(255, 198, 75, 0.50);
}
/* focus-breath 呼吸光晕（下一场景按钮引导） */
.focus-breath {
  box-shadow: 0 0 0 0 var(--realm-glow-66);
  animation: ch17Breath 2s ease-in-out infinite;
}

@keyframes ch17Breath {
  0%, 100% { box-shadow: 0 0 0 0 var(--realm-glow-66); }
  50% { box-shadow: 0 0 16px 4px var(--realm-glow-44); }
}

/* 工纹（S10 本命石新痕 · 微缩尺+金刚钻交叉成"工"字形） */
.s10-scar-gong {
  display: inline-block;
  width: 56px;
  height: 36px;
  position: relative;
  vertical-align: middle;
  margin: 0 0.4rem;
}
/* 一横：微缩尺（刻度从米到原子逐级缩小） */
.s10-scar-gong::before {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  background: linear-gradient(90deg,
    var(--realm-color) 0%, var(--realm-color) 18%,
    #F2BE45 18%, #F2BE45 36%,
    #C9A038 36%, #C9A038 54%,
    #8D6E63 54%, #8D6E63 72%,
    #5D4037 72%, #5D4037 90%,
    #2A1B12 90%, #2A1B12 100%);
  border-radius: 2px;
  box-shadow: 0 0 6px var(--realm-glow-66);
}
/* 一竖：金刚钻（贯穿尺心） */
.s10-scar-gong::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 2px;
  bottom: 2px;
  width: 3px;
  margin-left: -1.5px;
  background: linear-gradient(180deg, #FFD700 0%, var(--realm-color) 50%, #8D6E63 100%);
  border-radius: 2px;
  box-shadow: 0 0 8px #FFD70088;
}

/* S9 Boss 战触发按钮的雌黄描边（火焰色边） */
#s9-start {
  border-color: var(--realm-color);
  color: var(--realm-color);
  background: rgba(255, 107, 53, 0.08);
}
#s9-start:hover {
  background: var(--realm-color);
  color: #1a1a1a;
  box-shadow: 0 0 18px 4px #FF6B3555;
}

/* S10 碎片节点（10枚 K-164~K-173） */
.frag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
  margin: 1rem 0;
}
.frag-node {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass-bg);
  color: var(--text-3);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  transition: all 0.3s var(--ease-out);
  opacity: 0.5;
}
.frag-node:hover {
  border-color: var(--realm-color);
  transform: translateY(-2px);
}
.frag-node.lit {
  border-color: var(--realm-color);
  background: var(--realm-soft);
  color: var(--realm-color);
  opacity: 1;
  box-shadow: 0 0 10px var(--realm-glow-44);
}

/* tex-eq：剧本里的数学公式块（KaTeX 渲染容器） */
.tex-eq {
  margin: 0.6rem 0;
  padding: 0.6rem 0.9rem;
  border-left: 3px solid var(--realm-color);
  background: var(--realm-faint);
  border-radius: 0 6px 6px 0;
  font-size: 1rem;
  overflow-x: auto;
}

/* 境界突破 inscription */
.inscription {
  margin: 1rem 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--realm-color);
  border-radius: 8px;
  background: var(--realm-soft-10);
  color: var(--realm-color);
  text-align: center;
  font-family: var(--font-serif);
  letter-spacing: 0.1em;
  animation: ch17Inscribe 1.4s ease-out;
}
@keyframes ch17Inscribe {
  0% { opacity: 0; transform: scale(0.9); }
  60% { opacity: 1; transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}

/* btn-row */
.btn-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* 炼砂成芯的火账按钮（侧栏物品栏） */
#inv-fog .inv-icon {
  filter: hue-rotate(-15deg) saturate(1.4);
}

/* ============================================================
   通用交互组件样式 · 结丹期金色主题
   ============================================================ */

/* 组件头 */
.cmp-head {
  margin-bottom: 0.6rem;
}
/* 控件区 */
.cmp-ctrl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--realm-line);
  border-radius: 8px;
  background: rgba(30, 25, 35, 0.4);
}
.cmp-val {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--realm-color);
  min-width: 4rem;
  text-align: right;
}
.cmp-slider {
  flex: 1;
  min-width: 120px;
  max-width: 220px;
  accent-color: var(--realm-color);
  cursor: pointer;
}

/* 切换按钮 */
.cmp-toggle {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--line-strong, #475569);
  border-radius: 6px;
  background: rgba(30, 25, 35, 0.5);
  color: var(--text-3, #94A3B8);
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 200ms ease-out;
}
.cmp-toggle:hover { border-color: var(--realm-color); }
.cmp-toggle.active {
  border-color: var(--realm-color);
  background: var(--realm-line);
  color: var(--realm-color);
}
.cmp-pill {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--line-strong, #475569);
  border-radius: 999px;
  background: rgba(30, 25, 35, 0.5);
  color: var(--text-3, #94A3B8);
  cursor: pointer;
  font-size: 0.78rem;
  transition: all 200ms ease-out;
}
.cmp-pill:hover { border-color: var(--realm-color); }
.cmp-pill.active {
  border-color: var(--realm-color);
  background: var(--realm-line);
  color: var(--realm-color);
}

/* 画布容器 */
.cmp-canvas-box {
  margin: 0.6rem 0;
  border: 1px solid var(--realm-soft);
  border-radius: 8px;
  padding: 0.5rem;
  background: #1A1520;
  overflow: hidden;
}
/* 读数面板 */
.cmp-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--line-strong, #475569);
  border-radius: 8px;
  background: rgba(30, 25, 35, 0.3);
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}
.ro-item b {
  color: var(--realm-color);
  font-size: 0.95rem;
}

/* 通量说明 */
.cmp-flux {
  margin: 0.5rem 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--realm-soft);
  border-radius: 8px;
  background: rgba(30, 25, 35, 0.3);
  font-size: 0.82rem;
}
.flux-eq {
  text-align: center;
  margin-bottom: 0.4rem;
  color: var(--text-1, #F1F5F9);
}
.flux-eq b { color: var(--realm-color); }
.flux-row {
  margin: 0.2rem 0;
  color: var(--text-3, #94A3B8);
}
.flux-row b { color: var(--text-1, #F1F5F9); }
.flux-tag {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.72rem;
  margin-left: 0.3rem;
}
.flux-tag.linear {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
}
.flux-tag.parabolic {
  background: rgba(245, 158, 11, 0.15);
  color: #F59E0B;
}

/* 炉管剖面 */
.cmp-bottom {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}
.cmp-furnace {
  flex: 1;
  min-width: 200px;
}
.furnace-tube {
  position: relative;
  border: 2px solid var(--realm-glow-25);
  border-radius: 12px;
  padding: 0.5rem;
  background: linear-gradient(180deg, rgba(30, 25, 35, 0.6) 0%, rgba(60, 40, 20, 0.3) 100%);
  min-height: 100px;
  display: flex;
  flex-direction: column;
}
.gas-inlet {
  text-align: center;
  font-size: 0.78rem;
  font-weight: bold;
  padding: 0.2rem;
  border-bottom: 1px dashed var(--realm-glow-20);
  margin-bottom: 0.3rem;
}
.sio2-layer {
  min-height: 4px;
  border-radius: 4px;
  margin: 0.3rem 0;
  transition: all 300ms ease-out;
  font-size: 0.72rem;
  text-align: center;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.8);
}
.si-layer {
  flex: 1;
  min-height: 30px;
  border-radius: 4px;
  background: linear-gradient(135deg, #475569 0%, #334155 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.6);
  border: 1px solid #475569;
}

/* 干涉色 */
.cmp-interf {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  min-width: 100px;
  justify-content: center;
}
.interf-swatch {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition: background 300ms ease-out;
  box-shadow: 0 0 12px var(--realm-line);
}
.interf-label {
  font-size: 0.75rem;
  color: var(--text-3, #94A3B8);
  text-align: center;
}

/* 警告框 */
.cmp-warn {
  margin: 0.5rem 0;
  padding: 0.5rem 0.8rem;
  border-left: 3px solid #F59E0B;
  background: rgba(245, 158, 11, 0.08);
  color: #FCD34D;
  font-size: 0.82rem;
  border-radius: 0 6px 6px 0;
  line-height: 1.5;
}
.cmp-warn.danger {
  border-left-color: #EF4444;
  background: rgba(239, 68, 68, 0.1);
  color: #FCA5A5;
}

/* 可视化行 */
.cmp-vis-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}
.cmp-path-box, .cmp-img-box {
  flex: 1;
  min-width: 180px;
}
.path-label {
  font-size: 0.78rem;
  color: var(--text-3, #94A3B8);
  margin-bottom: 0.3rem;
}

/* 光路图 */
.path-stage {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.5rem;
  border: 1px solid var(--realm-soft);
  border-radius: 8px;
  background: rgba(30, 25, 35, 0.3);
  min-height: 100px;
}
.ps-source, .ps-mirror, .ps-lens, .ps-water, .ps-wafer {
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.78rem;
  text-align: center;
}
.ps-source {
  border: 1px solid currentColor;
  font-weight: bold;
}
.ps-mirror {
  background: rgba(157, 78, 221, 0.1);
  border: 1px solid #9D4EDD55;
  color: #C4B5FD;
}
.ps-lens {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid #3B82F655;
  color: #93C5FD;
}
.ps-water {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid #22C55E55;
  color: #86EFAC;
}
.ps-wafer {
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid #94A3B855;
  color: #CBD5E1;
}

/* 时间线 */
.cmp-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0;
  padding: 0.5rem;
  border: 1px solid var(--realm-soft-10);
  border-radius: 8px;
  background: rgba(30, 25, 35, 0.2);
}
.tl-node {
  flex: 1;
  min-width: 70px;
  text-align: center;
  padding: 0.3rem;
  border-radius: 6px;
  border: 1px solid var(--realm-soft-10);
  background: rgba(30, 25, 35, 0.3);
}
.tl-name {
  font-size: 0.78rem;
  font-weight: bold;
  color: var(--text-2, #CBD5E1);
}
.tl-lam {
  font-size: 0.72rem;
  color: var(--realm-color);
}
.tl-year {
  font-size: 0.68rem;
  color: var(--text-3, #94A3B8);
}

/* S10 碎片网格（覆盖已有定义以适配 ch17） */
.frag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 0.8rem 0;
}
.frag-node {
  min-height: 40px;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--line-strong, #475569);
  border-radius: 999px;
  background: transparent;
  color: var(--text-3, #94A3B8);
  cursor: pointer;
  font-family: var(--font-serif, serif);
  font-size: 0.82rem;
  transition: all 300ms ease-out;
}
.frag-node:hover { border-color: var(--realm-color); color: var(--realm-color); }
.frag-node.lit {
  color: var(--realm-color);
  border-color: var(--realm-color);
  background: var(--realm-soft-10);
  box-shadow: 0 0 10px var(--realm-glow-25);
}

/* ============================================================
   S0 七工台导览卡片
   ============================================================ */
.bench-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
  margin: 0.8rem 0;
}
.bench-card {
  position: relative;
  border: 1px solid var(--line-strong, #475569);
  border-radius: 10px;
  background: rgba(30, 25, 35, 0.25);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 260ms ease-out, box-shadow 260ms ease-out, transform 260ms ease-out;
}
.bench-card:hover {
  border-color: var(--realm-glow-50);
  transform: translateY(-2px);
}
.bench-card.open {
  border-color: var(--realm-color);
  box-shadow: 0 0 12px var(--realm-glow-20);
  cursor: default;
  transform: none;
}
.bench-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
}
.bench-num {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line-strong, #475569);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono, monospace);
  font-size: 0.75rem;
  color: var(--text-3, #94A3B8);
  transition: all 260ms ease-out;
}
.bench-card.open .bench-num {
  border-color: var(--realm-color);
  color: var(--realm-color);
  background: var(--realm-soft);
}
.bench-name {
  font-family: var(--font-serif, serif);
  font-size: 0.9rem;
  color: var(--text-1, #E2E8F0);
}
.bench-card.open .bench-name { color: var(--realm-color); }
.bench-hint {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-3, #94A3B8);
  font-family: var(--font-mono, monospace);
  transition: transform 260ms ease-out;
}
.bench-card.open .bench-hint { transform: rotate(90deg); }
.bench-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 360ms ease-out;
}
.bench-card.open .bench-body { max-height: 240px; }
.bench-body-inner {
  padding: 0 0.8rem 0.7rem;
  font-size: 0.8rem;
  line-height: 1.6;
}
.bench-law {
  color: var(--text-2, #94A3B8);
  margin-bottom: 0.35rem;
}
.bench-law b { color: var(--realm-color); }
.bench-trade {
  color: var(--text-3, #94A3B8);
  font-size: 0.75rem;
  border-top: 1px dashed var(--line, rgba(148,163,184,0.12));
  padding-top: 0.35rem;
}
.bench-trade b { color: var(--danger, #F27A63); }
.bench-progress {
  text-align: center;
  margin-top: 0.6rem;
  font-family: var(--font-mono, monospace);
  font-size: 0.78rem;
  color: var(--text-3, #94A3B8);
}
.bench-progress b { color: var(--realm-color); }
.bench-progress.done { color: var(--realm-color); }

/* 响应式适配 */
@media (max-width: 600px) {
  .cmp-ctrl { flex-direction: column; align-items: stretch; }
  .cmp-slider { max-width: 100%; }
  .cmp-vis-row { flex-direction: column; }
  .cmp-canvas { height: 200px; }
  .bench-grid { grid-template-columns: repeat(2, 1fr); }
}
