:root {
  color-scheme: dark;
  /* 面向 LED 拼接屏：相邻色块保持明显的明度差，暗部不低于屏幕能分辨的范围 */
  --bg: #060e1a;
  --surface: #142841;
  --surface-2: #20395a;
  --leaf: #365a80;
  --leaf-hover: #4a7099;
  --leaf-lit: #4f7ba8;
  --band: #16497c;
  --line: #34506f;
  --line-strong: #6b8bad;
  --text: #f6f9fc;
  --text-2: #f2f6fa;
  --muted: #a9bcd0;
  /* 金色只表示“当前”，冰蓝只表示“相关” */
  --accent: #ffc04d;
  --accent-rgb: 255, 192, 77;
  --accent-ink: #1f1500;
  /* 选中的框：底色和普通框一样亮，靠暖色和金色描边区分，不刺眼 */
  --accent-fill: #6b5224;
  --accent-on-fill: #fff4dc;
  --accent-soft: rgba(255, 192, 77, .18);
  --accent-glow: rgba(255, 192, 77, .45);
  --rel-1: #86dcff;
  --rel-2: #63bce6;
  --rel-3: #4a9ac4;
  --rel-fill: #1b6f9f;
  --danger: #ff8a75;
  --ease: cubic-bezier(.22, .8, .2, 1);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 密码验证：登录页和登录失效时的弹窗共用 */
.auth { display: grid; place-items: center; min-height: 100%; padding: 24px 16px; }
.auth__card { width: min(360px, 100%); padding: 28px 24px 24px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--text); }
.auth__card::backdrop { background: rgba(6, 14, 26, .72); }
.auth__card h1, .auth__card h2 { margin: 0 0 8px; font-size: 20px; font-weight: 600; }
.auth__card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.auth__card input { width: 100%; margin-top: 20px; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg); font-size: 16px; }
.auth__card .auth__error { min-height: 22px; margin-top: 8px; color: var(--danger); font-size: 13px; }
.auth__card button { width: 100%; margin-top: 4px; padding: 11px; border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-size: 15px; font-weight: 600; }
.auth__card button:disabled { opacity: .6; cursor: default; }

/* 架构图：主屏、控制台缩略图和工作台共用。
   画布大小、排列和尺寸都来自 architecture.json，这里只定义每种类型的默认样式 */
.map {
  position: relative;
  display: flex;
  user-select: none;
}

.n {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-radius: 3px;
  transition: opacity .45s ease, transform .6s var(--ease), box-shadow .4s ease, background-color .4s ease, border-color .4s ease;
}
.n__head { color: var(--text); transition: color .4s ease; }
.n__head--plain { background: none; }
.n__kids { display: flex; gap: 4px; min-width: 0; min-height: 0; flex: 1; }
.n__kids--row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.n__kids--col { flex-direction: column; }
.n__kids--col > .n { flex: 1 1 auto; }
.n__kids--grid { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.n__kids--free { display: block; position: relative; }
.n.n--free { position: absolute; }
.n--vertical { writing-mode: vertical-rl; }

.n--leaf {
  display: flex; align-items: center; justify-content: center;
  padding: var(--leaf-pad, 3px 6px);
  background: var(--leaf);
  color: var(--text-2);
  font-size: var(--leaf-font, 14px); font-weight: 500; line-height: 1.22;
  text-align: center; text-wrap: balance;
  cursor: pointer;
}
.n--leaf:hover { background: var(--leaf-hover); color: var(--text); }

.n--layer, .n--pillar:not(.n--slim) {
  display: flex; gap: 8px;
  padding: 7px 8px 7px 0;
  background: var(--surface);
}
.n--layer > .n__head {
  flex: 0 0 var(--head-size, 34px);
  display: flex; align-items: center; justify-content: center;
  margin: -7px 0;
  background: var(--band);
  border-radius: 3px 0 0 3px;
  writing-mode: vertical-rl;
  font-size: 16px; font-weight: 600; letter-spacing: .22em;
  cursor: pointer;
}
.n--layer > .n__kids { gap: 6px; }

.n--group { display: flex; flex-direction: column; gap: 4px; padding: 5px 6px 6px; background: var(--surface-2); }
.n--group > .n__head { font-size: 15.5px; font-weight: 600; line-height: 1.25; text-align: center; text-wrap: balance; cursor: pointer; }
.n--group.n--side { flex-direction: row; align-items: stretch; gap: 8px; }
.n--group.n--side > .n__head { flex: 0 0 var(--head-size, 84px); display: flex; align-items: center; font-size: 14px; text-align: left; }

.n--col { display: flex; flex-direction: column; gap: 4px; }
.n--col > .n__head {
  display: flex; align-items: center; justify-content: center;
  min-height: var(--head-size, 34px);
  color: var(--text);
  font-size: 14.5px; font-weight: 600; line-height: 1.2;
  text-align: center; text-wrap: balance;
  cursor: pointer;
}
.n--layer > .n__kids > .n--col { padding: 4px 5px 5px; background: var(--surface-2); }
.n--col.n--side { flex-direction: row; align-items: stretch; gap: 8px; }
.n--col.n--side > .n__head { flex: 0 0 var(--head-size, 76px); min-height: 0; text-align: left; justify-content: flex-start; }

.n--wrap { display: flex; flex-direction: column; min-height: 0; }

.n--cluster { display: flex; flex-direction: column; gap: 3px; padding: 4px 5px 5px; border: 1.5px solid var(--line-strong); border-radius: 4px; }
.n--cluster > .n__head { color: var(--text); font-size: 13px; font-weight: 600; line-height: 1.2; text-align: center; cursor: pointer; }
.n--cluster.n--side { flex-direction: row; align-items: stretch; gap: 8px; }
.n--cluster.n--side > .n__head { flex: 0 0 var(--head-size, 76px); display: flex; align-items: center; }
.n--cluster.n--dashed { border-style: dashed; border-radius: 12px; }

/* 透明的大容器：标题条和纵列一样是完整的一根，点缝隙不会选中整块 */
.n--layer.n--plain > .n__head { border-radius: 3px; }
.n--layer.n--plain, .n--layer.n--plain > .n__kids { pointer-events: none; }
.n--layer.n--plain > .n__head, .n--layer.n--plain > .n__kids > .n { pointer-events: auto; }

/* 通栏分区：标题两侧有分隔线，下面排列若干层 */
.n--span { display: flex; flex-direction: column; gap: 5px; }
.n--span > .n__head {
  flex: 0 0 var(--head-size, 22px);
  display: flex; align-items: center; justify-content: center; gap: 14px;
  color: var(--text);
  font-size: 15px; font-weight: 600; letter-spacing: .14em;
  cursor: pointer;
}
.n--span > .n__head::before, .n--span > .n__head::after { content: ""; flex: 1; height: 2px; background: var(--line-strong); }
.n--span > .n__kids { gap: 6px; }

/* 纵列：没有下级时是一根竖条 */
.n--pillar { display: flex; }
.n--pillar:not(.n--slim) { flex-direction: column; padding: 8px; gap: 7px; }
.n--pillar:not(.n--slim) > .n__head { font-size: 16px; font-weight: 600; letter-spacing: .08em; text-align: center; cursor: pointer; margin: -8px -8px 0; padding: 7px 0; background: var(--band); border-radius: 3px 3px 0 0; }
.n--slim {
  align-items: center; justify-content: center;
  background: var(--band);
  cursor: pointer;
}
.n--slim:hover { background: #1c5a97; }
.n--slim > .n__head { writing-mode: vertical-rl; font-size: 16px; font-weight: 600; letter-spacing: .34em; }
.n--tag { --leaf-font: 13px; --leaf-pad: 2px 3px; }
.n--tag > .n__head { color: var(--text); font-size: 17px; letter-spacing: 0; }
.n--tag .n--cluster { border: 0; padding: 0; }
.n--tag .n--cluster > .n__head { font-size: 13.5px; }

/* 在数据里设置的“无底色”，优先级要高于各类型的底色，低于选中状态 */
.n > .n__head.n__head--plain { background: none; }
.n.n.n--plain { background: none; }

/* 素材标记 */
.n__dot { position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); pointer-events: none; }

/* 聚焦状态：其余部分只是退后，不隐藏 */
.n.is-dim { opacity: .58; }
.n.is-path { z-index: 5; }
.n.is-path > .n__head { color: var(--text); }
.n.is-within.n--leaf { color: #fff; background: var(--leaf-lit); }
.n.is-within > .n__head { color: var(--text); }
.n.is-focus {
  z-index: 8;
  box-shadow: 0 0 0 3px var(--accent), 0 0 34px var(--accent-glow);
  animation: focus-breathe 2.6s ease-in-out infinite;
}
.n.is-focus > .n__head { color: var(--accent); }
.n.is-focus.n--leaf { background: var(--accent-fill); color: var(--accent-on-fill); font-weight: 600; }
.n.is-focus.n--layer > .n__head { background: var(--accent-fill); color: var(--accent-on-fill); }
.n.is-zoom {
  z-index: 20;
  transform: translate(var(--zx, 0), var(--zy, 0)) scale(var(--zs, 1));
  box-shadow: 0 0 0 2px var(--accent), 0 18px 60px rgba(0, 0, 0, .7), 0 0 40px var(--accent-glow);
  animation: none;
}
.n.is-zoom.n--col, .n.is-zoom.n--group, .n.is-zoom.n--cluster, .n.is-zoom.n--layer, .n.is-zoom.n--wrap { background: var(--surface-2); }
.n.is-zoom.n--slim, .n.is-zoom.n--pillar { background: var(--surface-2); }

@keyframes focus-breathe {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent), 0 0 20px rgba(var(--accent-rgb), .3); }
  50% { box-shadow: 0 0 0 3px var(--accent), 0 0 44px rgba(var(--accent-rgb), .6); }
}

/* 控制台缩略图隐藏文字，只保留色块 */
.map--mini .n__head, .map--mini .n--leaf { color: transparent !important; }
.map--mini .n--leaf { background: var(--leaf); }
.map--mini .n__dot { display: none; }
.map--mini .n.is-focus, .map--mini .n.is-focus .n--leaf, .map--mini .n.is-focus > .n__head { background: var(--accent); box-shadow: none; animation: none; }
.map--mini .n.is-within.n--leaf { background: var(--accent); }
.map--mini * { transition: none; }

@media (prefers-reduced-motion: reduce) {
  .n, .n__head { transition-duration: .01ms; }
  .n.is-focus { animation: none; }
}

/* 一直显示的双向箭头 */
.links { position: absolute; inset: 0; z-index: 9; width: 100%; height: 100%; overflow: visible; pointer-events: none; transition: opacity .45s ease; }
.links path { fill: var(--leaf); stroke: var(--text); stroke-width: 1.3; stroke-linejoin: round; }
.map.has-focus .links { opacity: .55; }

/* 依赖链路 */
.map { isolation: isolate; }
.rel { position: absolute; inset: 0; z-index: 15; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.rel__group { --stroke: var(--rel-1); --width: 2.2; --flow-width: 4.4; }
.rel__group[data-level="2"] { --stroke: var(--rel-2); --width: 2; --flow-width: 4; }
.rel__group[data-level="3"] { --stroke: var(--rel-3); --width: 1.8; --flow-width: 3.6; }
.rel__line { fill: none; stroke: var(--stroke); stroke-opacity: .72; stroke-width: var(--width); stroke-linecap: round; }
.rel__flow { fill: none; stroke-width: var(--flow-width); }
.rel__flow--tail { stroke: var(--rel-1); stroke-opacity: .75; }
.rel__flow--head { stroke: #f2fbff; }
.map.is-flowing .n.is-focus { animation: none; }
.rel__line--support { stroke-dasharray: 1; stroke-dashoffset: 1; animation: rel-draw .75s var(--ease) var(--d) forwards; }
.rel__line--prereq { stroke-dasharray: 11 8; stroke-linecap: butt; opacity: 0; animation: rel-fade .5s ease var(--d) forwards; }
.rel__arrow { fill: var(--stroke); opacity: 0; animation: rel-fade .3s ease calc(var(--d) + .45s) forwards; }
.rel__line--new { stroke: var(--accent); stroke-opacity: 1; }
.rel__arrow--new { fill: var(--accent); }
.rel__line--removed { stroke: var(--danger); stroke-opacity: 1; stroke-dasharray: 6 5; stroke-linecap: butt; }
.rel__arrow--removed { fill: var(--danger); }
@keyframes rel-draw { to { stroke-dashoffset: 0; } }
@keyframes rel-fade { to { opacity: 1; } }

.map.is-relating .n.is-dim { opacity: .5; }
.n.is-dep {
  z-index: 7;
  box-shadow: 0 0 0 var(--dep-width, 2.5px) var(--dep-color, var(--rel-1));
  transition-delay: var(--dep-delay, 0s);
}
.n.is-dep[data-dep="2"] { --dep-color: var(--rel-2); --dep-width: 2px; }
.n.is-dep[data-dep="3"] { --dep-color: var(--rel-3); --dep-width: 2px; }
.n.is-dep > .n__head { color: var(--dep-color, var(--rel-1)); }
.n.is-dep.n--leaf { background: var(--rel-fill); color: #fff; }

/* 工作台的关系视图：静止显示，方便编辑 */
.map.is-static .rel__line, .map.is-static .rel__arrow { animation: none; opacity: 1; stroke-dashoffset: 0; }
.map.is-static .n.is-dep { transition-delay: 0s; }
.map.is-static .n.is-focus { animation: none; }

.map--mini .n.is-dep, .map--mini .n.is-dep .n--leaf { background: var(--rel-2); box-shadow: none; }
.map--mini .rel__line { stroke: var(--rel-1); stroke-opacity: 1; stroke-width: 7; }
.map--mini .rel__line, .map--mini .rel__arrow { animation: none; }
.map--mini .rel__line--support { stroke-dashoffset: 0; }
.map--mini .rel__line--prereq { stroke-dasharray: 24 18; opacity: 1; }
.map--mini .rel__arrow { display: none; }

@media (prefers-reduced-motion: reduce) {
  .rel__line, .rel__arrow { animation: none; opacity: 1; stroke-dashoffset: 0; }
  .n.is-dep { transition-delay: 0s; }
}
