html, body { overflow: hidden; }

.stage { position: fixed; inset: 0; z-index: 1; }

.map-wrap {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0;
  transition: transform .75s var(--ease);
}
.no-anim .map-wrap, .no-anim .panel, .no-anim .rail { transition: none !important; }

/* 左侧信息栏：大屏横屏时显示，打开素材后让出空间 */
.rail {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 2;
  display: flex; flex-direction: column;
  width: var(--rail, 340px);
  padding: 36px 28px 24px 32px;
  transition: opacity .4s ease, transform .6s var(--ease);
}
.rail.is-hidden { opacity: 0; transform: translateX(-20px); pointer-events: none; }

.rail__brand h1 { margin: 0; font-size: 42px; font-weight: 500; letter-spacing: .02em; line-height: 1.1; }
.rail__brand p { margin: 8px 0 0; color: var(--muted); font-size: 15px; letter-spacing: .08em; }

.rail__legend { flex: 0 1 auto; min-height: 0; margin-top: 34px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.rail__legend h2 { margin: 20px 0 6px; color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .18em; }
.legend-item {
  display: flex; align-items: baseline; gap: 12px;
  width: 100%; padding: 6px 0;
  border: 0; border-bottom: 1px solid var(--line);
  background: none;
  color: var(--text);
  font-size: 16px; font-weight: 500; text-align: left;
  transition: color .3s ease, padding-left .4s var(--ease);
}
.legend-item small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.legend-item:hover { color: var(--accent); }
.legend-item.is-active { padding-left: 8px; color: var(--accent); }
.legend-item.is-active small { color: var(--accent); }

.narration { flex: none; margin-top: auto; padding-top: 24px; opacity: 0; transition: opacity .4s ease; }
.narration.is-on { opacity: 1; }
/* 没有脚本在播放时不占位，矮屏幕上把空间留给目录和快捷按钮 */
.narration:not(.is-on) { display: none; }
.narration__program { color: var(--accent); font-size: 13px; letter-spacing: .06em; }
.narration__caption { min-height: 2.6em; margin-top: 8px; font-size: 23px; font-weight: 500; line-height: 1.3; text-wrap: balance; }
.narration__meta { margin-top: 8px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.meter { height: 4px; margin-top: 10px; background: var(--line); overflow: hidden; }
.meter i { display: block; width: 100%; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }

/* 快捷按钮：展示模块并自动播放它的素材 */
.shortcuts { flex: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: auto; padding-top: 20px; }
.narration.is-on + .shortcuts { margin-top: 0; }
.shortcuts:empty { display: none; }
.shortcut {
  display: flex; align-items: center; gap: 8px;
  min-height: 52px; padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 500; line-height: 1.3; text-align: left;
  transition: color .2s ease, background-color .2s ease, border-color .2s ease;
}
.shortcut:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.shortcut small { flex: none; color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; }
.shortcut span { text-wrap: balance; }
.is-offline { color: var(--danger); }

/* 依赖详情：选中模块时替换目录 */
.rail__legend[hidden], .inspector[hidden] { display: none; }
.inspector { display: flex; flex-direction: column; flex: 0 1 auto; min-height: 0; margin-top: 28px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.inspector__crumb { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.inspector h2 { margin: 6px 0 0; color: var(--accent); font-size: 23px; font-weight: 500; line-height: 1.3; }
.inspector__actions { display: flex; gap: 8px; margin-top: 14px; }
.inspector__actions button {
  flex: 1 1 auto; min-height: 36px; padding: 6px 10px;
  border: 1px solid var(--line-strong); border-radius: 5px;
  background: none; color: var(--text);
  font-size: 13.5px; white-space: nowrap;
}
.inspector__actions button:hover { border-color: var(--accent); color: var(--text); }
.inspector__actions .is-primary { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.inspector__key { display: flex; gap: 16px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.inspector__key span { display: inline-flex; align-items: center; gap: 6px; }
.inspector__key svg { flex: none; }
.inspector__key path { fill: none; stroke: var(--rel-1); stroke-width: 2.6; }
.inspector h3 { margin: 18px 0 4px; color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: .12em; }
.inspector__hint { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.dep-link {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 8px; align-items: baseline;
  width: 100%; padding: 6px 0;
  border: 0; border-bottom: 1px solid var(--line);
  background: none; color: var(--text);
  text-align: left;
  transition: color .2s ease;
}
.dep-link:hover { color: var(--rel-1); }
.dep-link b { font-size: 14.5px; font-weight: 500; line-height: 1.35; }
.dep-link em { color: var(--rel-1); font-size: 12px; font-style: normal; }
.dep-link small { grid-column: 1 / -1; color: var(--muted); font-size: 11.5px; }

/* 信息栏隐藏时的单行字幕，占用架构图之外预留的区域 */
.caption-strip {
  position: absolute; z-index: 3;
  display: flex; align-items: center; gap: 12px;
  min-height: 36px;
  color: var(--text);
  font-size: 16px; font-weight: 500;
  opacity: 0;
  transition: opacity .35s ease;
  overflow: hidden;
  white-space: nowrap;
}
.caption-strip b { color: var(--accent); font-weight: 400; font-size: 13px; flex: none; }
.caption-strip span { overflow: hidden; text-overflow: ellipsis; }
.caption-strip.is-on { opacity: 1; }
.caption-strip button { flex: none; min-height: 30px; margin-left: auto; padding: 2px 10px; border: 1px solid var(--accent); border-radius: 5px; background: none; color: var(--accent); font-size: 13px; }
.caption-strip:not(.is-on) { pointer-events: none; }

/* 引线 */
.leader { position: absolute; inset: 0; z-index: 30; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: opacity .3s ease; }
.leader.is-on { opacity: 1; }
.leader path { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-dasharray: 1; stroke-dashoffset: 1; }
.leader.is-on path { stroke-dashoffset: 0; transition: stroke-dashoffset .7s var(--ease) .15s; }
.leader circle { fill: var(--accent); }

/* 素材面板：停靠在架构图腾出的空白区域，不压在图上 */
.panel {
  position: absolute; z-index: 25;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 2px solid var(--line-strong);
  border-radius: 6px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
  opacity: 0;
  transform: translateX(var(--enter, 28px));
  transition: opacity .4s ease, transform .6s var(--ease), left .75s var(--ease), top .75s var(--ease), width .75s var(--ease), height .75s var(--ease);
}
.panel[hidden] { display: none; }
.panel.is-on { opacity: 1; transform: none; }

.panel__head { display: flex; align-items: flex-start; gap: 16px; padding: 20px 20px 12px 24px; }
.panel__titles { flex: 1; min-width: 0; }
.panel__crumb { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.panel__head h2 { margin: 5px 0 0; color: var(--text); font-size: 25px; font-weight: 400; line-height: 1.25; }
.panel__close {
  flex: none; display: grid; place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--line-strong); border-radius: 50%;
  background: none; color: var(--text-2);
  transition: color .2s ease, border-color .2s ease;
}
.panel__close:hover { border-color: var(--accent); color: var(--accent); }
.panel__auto {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 16px 0 12px;
  border: 1px solid var(--accent); border-radius: 19px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 14px; white-space: nowrap;
  transition: background-color .2s ease, color .2s ease;
}
.panel__auto[hidden] { display: none; }
.panel__auto:hover, .panel__auto.is-on { background: var(--accent); color: var(--accent-ink); }

.panel__tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 24px 14px; }
.panel__tabs:empty { display: none; }
.panel-tab {
  padding: 6px 12px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: none; color: var(--text-2);
  font-size: 13px;
  transition: color .2s ease, background-color .2s ease, border-color .2s ease;
}
.panel-tab small { margin-right: 6px; color: var(--muted); font-size: 11px; }
.panel-tab:hover { color: var(--text); }
.panel-tab[aria-selected="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.panel-tab[aria-selected="true"] small { color: inherit; }

.panel__body { position: relative; flex: 1; min-height: 0; margin: 0 24px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.panel__body video, .panel__body iframe, .panel__body img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg); object-fit: contain; }
.panel__notice { margin: 10px 24px 0; color: var(--accent); font-size: 13px; }
.panel__meter { margin: 16px 24px 18px; }

/* 分区：每个素材一块，点击后放大到页面中央，播完缩回 */
.panel__body--split { display: grid; grid-auto-rows: minmax(140px, 1fr); gap: 10px; overflow: hidden auto; background: none; }
.region { position: relative; min-width: 0; min-height: 0; }
/* z-index 让每块自成一层，缩小的分区和它的标签都在遮罩下面 */
.region__stage { position: absolute; inset: 0; z-index: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--bg); }
.region__media { position: absolute; inset: 0; }
.region__hit { position: absolute; inset: 0; z-index: 2; width: 100%; padding: 0; border: 0; border-radius: inherit; background: none; transition: background-color .2s ease, box-shadow .2s ease; }
.region__hit:hover { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.region__label {
  position: absolute; top: 8px; left: 8px; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 16px); padding: 3px 9px;
  border-radius: 4px;
  background: rgba(6, 14, 26, .82);
  font-size: 13px;
  pointer-events: none;
}
.region__label small { flex: none; color: var(--accent); font-size: 11.5px; }
.region__label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.region__step { flex: none; color: var(--muted); font-size: 12px; font-style: normal; }
.region__step:empty { display: none; }
.region__close {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  display: none; place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--line-strong); border-radius: 50%;
  background: rgba(6, 14, 26, .82); color: var(--text-2);
}
.region__close:hover { border-color: var(--accent); color: var(--accent); }
.region__meter { position: absolute; right: 0; bottom: 0; left: 0; z-index: 3; height: 3px; margin: 0; background: none; opacity: 0; }

.panel.is-enlarged { z-index: 40; }
.panel__backdrop { position: fixed; inset: 0; z-index: 1; background: rgba(3, 8, 15, .78); opacity: 0; pointer-events: none; transition: opacity .35s ease; }
.panel__backdrop.is-on { opacity: 1; pointer-events: auto; }
.region.is-big .region__stage { position: fixed; inset: auto; z-index: 2; overflow: visible; border-color: var(--accent); box-shadow: 0 30px 120px rgba(0, 0, 0, .7); }
.region.is-big .region__media { overflow: hidden; border-radius: 3px; }
.region.is-big .region__hit { display: none; }
/* 放大后标题、关闭按钮和进度条都放在内容框外，不遮挡素材 */
.region.is-big .region__label { top: -36px; left: 0; background: none; padding-left: 0; font-size: 15px; }
.region.is-big .region__close { top: -46px; right: 0; display: grid; }
.region.is-big .region__meter { bottom: -9px; opacity: 1; }
.panel.is-enlarged .panel__notice { position: fixed; bottom: 3vh; left: 50%; z-index: 3; margin: 0; padding: 6px 14px; border-radius: 4px; background: var(--surface-2); cursor: pointer; transform: translateX(-50%); }

.slide { position: absolute; inset: 0; opacity: 0; transition: opacity .7s ease; pointer-events: none; }
.slide.is-on { opacity: 1; pointer-events: auto; }
.slide-dots { position: absolute; left: 50%; bottom: 12px; z-index: 2; display: flex; gap: 2px; transform: translateX(-50%); }
.slide-dots button { width: 26px; height: 22px; padding: 0; border: 0; background: none; }
.slide-dots button::before { content: ""; display: block; height: 3px; margin: 10px 3px; background: rgba(255, 255, 255, .5); transition: background-color .2s ease; }
.slide-dots button.is-on::before { background: var(--accent); }

.empty { display: flex; flex-direction: column; justify-content: center; height: 100%; padding: 32px; background: var(--surface-2); }
.empty h3 { margin: 0; font-size: 20px; font-weight: 400; }
.empty p { margin: 10px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.empty code { display: block; margin-top: 16px; padding: 12px 14px; background: var(--bg); border-radius: 3px; color: var(--text-2); font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }

.fatal { position: fixed; inset: 0; z-index: 99; display: grid; place-items: center; padding: 24px; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.7; text-align: center; white-space: pre-line; }
.fatal[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .map-wrap, .panel, .rail, .leader path { transition-duration: .01ms !important; }
}
