/* =========================================================
   名侦探柯南 · 人物关系图
   ========================================================= */

:root {
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Songti SC", "SimSun", Georgia, serif;

  --accent: #c8322b;
  --accent-2: #b08a4a;

  --r-s: 8px;
  --r-m: 14px;
  --r-l: 20px;

  --ease: cubic-bezier(.22, 1, .36, 1);
  --fast: .18s var(--ease);
  --mid: .32s var(--ease);
}

html[data-theme="light"] {
  --bg: #f4f1eb;
  --bg-2: #ece7de;
  --panel: #fffefb;
  --panel-2: #f7f3ec;
  --text: #191a1c;
  --text-2: #4c4a46;
  --muted: #827d75;
  --line: rgba(26, 20, 12, .10);
  --line-2: rgba(26, 20, 12, .055);
  --dot: rgba(26, 20, 12, .10);
  --edge: rgba(38, 30, 22, .26);
  --halo: #f4f1eb;
  --shadow: 0 12px 34px rgba(40, 30, 18, .10);
  --shadow-lg: 0 26px 70px rgba(40, 30, 18, .18);
  --glass: rgba(255, 254, 251, .82);
  --node-fill: .82;
}

html[data-theme="dark"] {
  --bg: #0b0c0f;
  --bg-2: #101216;
  --panel: #12141a;
  --panel-2: #191c23;
  --text: #eceef1;
  --text-2: #b9bec6;
  --muted: #868c96;
  --line: rgba(255, 255, 255, .10);
  --line-2: rgba(255, 255, 255, .055);
  --dot: rgba(255, 255, 255, .07);
  --edge: rgba(226, 232, 240, .22);
  --halo: #0b0c0f;
  --shadow: 0 12px 34px rgba(0, 0, 0, .45);
  --shadow-lg: 0 26px 70px rgba(0, 0, 0, .60);
  --glass: rgba(18, 20, 26, .82);
  --node-fill: .80;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

body.theming *,
body.theming *::before,
body.theming *::after {
  transition: background-color .38s var(--ease), border-color .38s var(--ease),
              color .38s var(--ease), fill .38s var(--ease), stroke .38s var(--ease) !important;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
ul { margin: 0; padding: 0; list-style: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg.i, .btn svg, .modal-x svg, .zoomer svg { width: 18px; height: 18px; display: block; }

/* ---------------- 顶部 ---------------- */
.top {
  position: relative;
  z-index: 30;
  flex: 0 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 0 0 auto; }

.mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(150deg, #d94a3f, #a91f1c);
  box-shadow: 0 5px 16px rgba(200, 50, 43, .32), inset 0 1px 0 rgba(255, 255, 255, .28);
  flex: 0 0 auto;
}
.mark svg { width: 20px; height: 20px; }

.brand-txt { min-width: 0; }
.brand h1 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: .10em;
  white-space: nowrap;
}
.brand p {
  margin: 1px 0 0;
  font-size: 9.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.search {
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(330px, 34vw);
  height: 36px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  transition: border-color var(--fast), background-color var(--fast), box-shadow var(--fast);
}
.search:focus-within {
  border-color: rgba(200, 50, 43, .55);
  box-shadow: 0 0 0 3px rgba(200, 50, 43, .10);
}
.search svg { color: var(--muted); flex: 0 0 auto; }
.search input {
  flex: 1; min-width: 0;
  border: 0; background: none; outline: none;
  font-size: 13px;
  letter-spacing: .01em;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search kbd {
  font: 10px/1 var(--sans);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 3px 5px;
  flex: 0 0 auto;
}

.tools { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 12px;
  border-radius: 9px;
  font-size: 12.5px;
  letter-spacing: .03em;
  color: var(--text-2);
  transition: background-color var(--fast), color var(--fast), transform var(--fast);
}
.btn:hover { background: var(--panel-2); color: var(--text); }
.btn:active { transform: scale(.97); }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
#btn-list { display: none; }

#btn-theme { position: relative; }
#btn-theme svg {
  position: absolute;
  transition: opacity .3s var(--ease), transform .5s var(--ease);
}
html[data-theme="dark"] .ic-sun { opacity: 0; transform: rotate(-70deg) scale(.6); }
html[data-theme="dark"] .ic-moon { opacity: 1; transform: none; }
html[data-theme="light"] .ic-sun { opacity: 1; transform: none; }
html[data-theme="light"] .ic-moon { opacity: 0; transform: rotate(70deg) scale(.6); }

/* ---------------- 布局 ---------------- */
.app { display: flex; flex-direction: column; height: 100dvh; width: 100%; max-width: 100vw; overflow: hidden; }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}

/* ---------------- 左侧列表 ---------------- */
.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  z-index: 20;
}

.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 10px;
}
.side-actions { display: inline-flex; align-items: center; gap: 2px; }
.side-close { display: none; }
.side-title { font-size: 11px; letter-spacing: .16em; color: var(--muted); text-transform: uppercase; }
.side-title b { color: var(--text); font-weight: 600; margin-left: 4px; letter-spacing: 0; }
.link {
  font-size: 11.5px; color: var(--muted);
  padding: 4px 7px; border-radius: 6px;
  transition: color var(--fast), background-color var(--fast);
}
.link:hover { color: var(--accent); background: var(--panel-2); }

.filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 12px; }

.chip {
  --c: var(--muted);
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  height: 27px; padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text-2);
  white-space: nowrap;
  transition: all var(--fast);
}
.chip i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 22%, transparent);
}
.chip:hover { border-color: color-mix(in srgb, var(--c) 45%, var(--line)); }
.chip.on {
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border-color: color-mix(in srgb, var(--c) 55%, transparent);
  color: var(--text);
  font-weight: 550;
}

.list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; overscroll-behavior: contain; }
.list::-webkit-scrollbar { width: 8px; }
.list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; border: 2px solid var(--panel); }

.li {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 7px 9px;
  border-radius: 9px;
  text-align: left;
  transition: background-color var(--fast);
}
.li:hover { background: var(--panel-2); }
.li.on { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.li.on .li-name { color: var(--accent); font-weight: 600; }

.avatar {
  width: 28px; height: 28px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 34%, transparent);
}
.li-txt { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.li-name { font-size: 13px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub {
  font-size: 10px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: .02em;
}
.li-deg {
  margin-left: auto; flex: 0 0 auto;
  font: 10.5px/1 var(--sans);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.li-empty { padding: 26px 14px; font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.8; }

.side-foot {
  flex: 0 0 auto;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--line-2);
  font-size: 10.5px;
  letter-spacing: .05em;
  color: var(--muted);
}
.side-foot b { color: var(--text-2); font-weight: 600; }

/* ---------------- 画布 ---------------- */
.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, var(--bg-2) 0%, var(--bg) 62%);
  touch-action: none;
}

#graph { display: block; width: 100%; height: 100%; cursor: grab; }
#graph.dragging { cursor: grabbing; }
.bg-grid { pointer-events: none; }
.dot { fill: var(--dot); }

#edges { pointer-events: none; }

.edge {
  fill: none;
  stroke: var(--edge);
  stroke-width: 1;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  transition: stroke .28s var(--ease), opacity .28s var(--ease), stroke-width .2s var(--ease);
}
.edge.dim { opacity: .10; }
.edge.hot {
  stroke: var(--c, var(--accent));
  stroke-width: 1.8;
  opacity: 1;
}
.edge.faint { opacity: .34; }

.node { cursor: pointer; }
.node .disc {
  fill: currentColor;
  fill-opacity: var(--node-fill);
  stroke: currentColor;
  stroke-opacity: .55;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform .26s var(--ease), fill-opacity .26s var(--ease), stroke-width .2s var(--ease);
}
.node .halo {
  fill: currentColor;
  opacity: 0;
  transition: opacity .4s var(--ease);
}
.node .ring {
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  opacity: 0;
  stroke-dasharray: 3 5;
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity .3s var(--ease);
}
.node .label {
  font-family: var(--sans);
  font-size: calc(11px * var(--invk, 1));
  font-weight: 500;
  letter-spacing: .02em;
  fill: var(--text);
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--halo);
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
  transition: opacity .28s var(--ease), fill .28s var(--ease);
}
.node.hub .label { font-weight: 600; }

.node:hover .disc { transform: scale(1.16); fill-opacity: 1; }
.node:hover .label { fill: var(--text); }

.node.sel .disc { fill-opacity: 1; stroke-width: 2; stroke-opacity: 1; }
.node.sel .halo { opacity: .16; }
.node.sel .ring { opacity: .55; animation: spin 14s linear infinite; }
.node.sel .label { font-weight: 650; }

.node.dim { opacity: .13; }
.node.dim .label { opacity: 0; }
.node.dim:hover { opacity: .9; }

@keyframes spin { to { transform: rotate(360deg); } }

/* 远景时只保留核心人物的名字 */
#vp { --invk: 1; transform-box: view-box; transform-origin: 0 0; }
#vp.zoom-far .node:not(.hub):not(.mid) .label { opacity: 0; }
#vp.zoom-far .node:hover .label,
#vp.zoom-far .node.sel .label { opacity: 1; }

/* 节点入场 */
.node.enter { animation: node-in .62s var(--ease) both; animation-delay: var(--d, 0ms); }
@keyframes node-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.node.enter .disc { animation: disc-in .62s var(--ease) both; animation-delay: var(--d, 0ms); }
@keyframes disc-in {
  from { transform: scale(.1); fill-opacity: .9; }
  to { transform: scale(1); }
}

/* ---------------- HUD ---------------- */
.crumbs {
  position: absolute; top: 14px; left: 16px; right: 90px;
  display: flex; align-items: center; gap: 4px;
  overflow-x: auto; overflow-y: hidden;
  padding: 3px;
  scrollbar-width: none;
  mask-image: linear-gradient(90deg, #000 88%, transparent);
  -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
  pointer-events: none;
}
.crumbs::-webkit-scrollbar { display: none; }
.crumb {
  pointer-events: auto;
  flex: 0 0 auto;
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color var(--fast), border-color var(--fast);
  animation: crumb-in .3s var(--ease) both;
}
.crumb:hover { color: var(--accent); border-color: rgba(200, 50, 43, .4); }
.crumb.now { color: var(--text); font-weight: 600; }
.crumb-sep { flex: 0 0 auto; color: var(--muted); opacity: .5; font-size: 10px; }
@keyframes crumb-in { from { opacity: 0; transform: translateX(-4px); } }

.zoomer {
  position: absolute; right: 16px; bottom: 18px;
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.zoomer button {
  width: 34px; height: 32px;
  display: grid; place-items: center;
  color: var(--text-2);
  transition: background-color var(--fast), color var(--fast);
}
.zoomer button + button { border-top: 1px solid var(--line-2); }
.zoomer button:hover { background: var(--panel-2); color: var(--text); }
.zoomer svg { width: 15px; height: 15px; }

.legend {
  position: absolute; left: 16px; bottom: 18px;
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.legend-toggle {
  display: block;
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--muted);
  width: 100%;
  text-align: left;
}
.legend-toggle:hover { color: var(--text); }
.legend-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 10px;
  padding: 0 12px 10px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height .4s var(--ease), opacity .3s var(--ease), padding .3s var(--ease);
}
.legend.open .legend-body { max-height: 200px; opacity: 1; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text-2); white-space: nowrap; }
.legend-item i { width: 14px; height: 2px; border-radius: 2px; background: var(--c); flex: 0 0 auto; }

.stage-intro {
  position: absolute;
  top: 16px; right: 16px;
  width: 244px;
  padding: 15px 17px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: var(--shadow);
  transition: opacity .4s var(--ease), transform .5s var(--ease);
  pointer-events: none;
}
body.has-sel .stage-intro { opacity: 0; transform: translateY(-8px); }
.stage-intro .eyebrow {
  font-size: 9px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 7px;
}
.stage-intro h2 {
  margin: 0 0 8px;
  font-size: 12.5px; font-weight: 600; letter-spacing: .06em;
}
.stage-intro p { margin: 0; font-size: 11px; line-height: 1.85; color: var(--muted); }
.stage-intro .stats {
  display: flex; gap: 16px;
  margin-top: 12px; padding-top: 11px;
  border-top: 1px solid var(--line-2);
}
.stage-intro .stats b {
  display: block;
  font: 600 16px/1.2 var(--serif);
  letter-spacing: .02em;
  color: var(--text);
}
.stage-intro .stats span { font-size: 9px; letter-spacing: .13em; color: var(--muted); }

.stage-hint {
  position: absolute; left: 50%; bottom: 20px;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .06em;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--line-2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  opacity: 1;
  transition: opacity .6s var(--ease), transform .6s var(--ease);
  white-space: nowrap;
}
.stage-hint.hide { opacity: 0; transform: translateX(-50%) translateY(6px); }

.tip {
  position: absolute;
  z-index: 15;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -6px);
  transition: opacity .16s;
  max-width: 240px;
  white-space: nowrap;
}
.tip.on { opacity: 1; }
.tip b { font-weight: 600; }
.tip span { color: var(--muted); }

/* ---------------- 详情 ---------------- */
.detail {
  position: fixed;
  top: 64px; right: 0; bottom: 0;
  width: 380px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
  z-index: 28;
  box-shadow: -18px 0 50px rgba(0, 0, 0, .16);
  transform: translateX(101%);
  transition: transform .46s var(--ease);
}
body.has-sel .detail { transform: none; }
.detail-scroll {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px 26px 48px;
}
.detail-scroll::-webkit-scrollbar { width: 8px; }
.detail-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; border: 2px solid var(--panel); }

.grip { display: none; }
.sheet-x {
  position: absolute; top: 10px; right: 10px;
  display: none;
  width: 30px; height: 30px;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  z-index: 3;
}
.sheet-x svg { width: 14px; height: 14px; }

.empty { padding: 12vh 6px 0; text-align: center; }
.empty-art { width: 100%; max-width: 250px; margin: 0 auto 28px; opacity: .9; }
.empty-art circle, .empty-art path { vector-effect: non-scaling-stroke; }
.empty h2 { margin: 0 0 10px; font-size: 16px; font-weight: 600; letter-spacing: .06em; }
.empty p { margin: 0 auto; max-width: 250px; font-size: 12.5px; line-height: 1.9; color: var(--muted); }
.empty-stats {
  margin-top: 26px; padding-top: 18px;
  border-top: 1px solid var(--line-2);
  font: 11px/1.8 var(--sans);
  letter-spacing: .12em;
  color: var(--muted);
}
.empty-stats b { color: var(--text-2); font-weight: 600; }

.dc { animation: dc-in .45s var(--ease) both; }
@keyframes dc-in { from { opacity: 0; transform: translateY(10px); } }

.dc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px;
  border-radius: 999px;
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.tag.dead { color: var(--muted); background: var(--panel-2); border-color: var(--line); }
.tag.dead i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.dc h2 {
  margin: 0;
  font-size: 29px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: .02em;
}
.dc .romaji {
  margin: 7px 0 0;
  font: 400 11px/1.6 var(--serif);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.dc .jp {
  margin: 5px 0 0;
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--text-2);
}

.alias-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.alias {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--text-2);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
}

.quote {
  margin: 20px 0 0;
  padding: 2px 0 2px 14px;
  border-left: 2px solid var(--accent);
  font: 400 13px/1.9 var(--serif);
  color: var(--text-2);
  letter-spacing: .04em;
}

.meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 22px 0 0;
  background: var(--line-2);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  overflow: hidden;
}
.meta > div { background: var(--panel); padding: 10px 12px; }
.meta dt {
  font-size: 9.5px;
  letter-spacing: .14em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.meta dd {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}
.meta > div.wide { grid-column: span 2; }

.bio {
  margin: 22px 0 0;
  font-size: 13px;
  line-height: 2.0;
  color: var(--text-2);
  letter-spacing: .02em;
}

.dc-sub {
  display: flex; align-items: baseline; gap: 8px;
  margin: 30px 0 2px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
.dc-sub h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: .16em;
  font-weight: 600;
  text-transform: uppercase;
}
.dc-sub span { font: 10.5px/1 var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; }
.dc-sub .mini {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; color: var(--muted); letter-spacing: .04em;
  padding: 3px 6px; border-radius: 5px;
}
.dc-sub .mini:hover { color: var(--accent); background: var(--panel-2); }
.dc-sub .mini svg { width: 11px; height: 11px; }

.rel-group { margin-top: 16px; }
.rel-head {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 6px;
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--muted);
  text-transform: uppercase;
}
.rel-head i { width: 12px; height: 2px; border-radius: 2px; background: var(--c); }

.rel-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 7px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  text-align: left;
  transition: background-color var(--fast), transform var(--fast);
}
.rel-item:hover { background: var(--panel-2); }
.rel-item:hover .rel-go { opacity: 1; transform: translateX(0); }
.rel-item:active { transform: scale(.99); }

.rel-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c);
  flex: 0 0 auto;
}
.rel-txt { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.rel-name { font-size: 12.5px; letter-spacing: .02em; }
.rel-label {
  font-size: 10.5px; color: var(--muted);
  line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rel-go {
  margin-left: auto; flex: 0 0 auto;
  color: var(--muted);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--fast), transform var(--fast);
}
.rel-go svg { width: 13px; height: 13px; }

/* ---------------- 移动端抽屉 / 筛选条 ---------------- */
.chips { display: none; }
.backdrop {
  position: fixed; inset: 0;
  background: rgba(8, 8, 10, .48);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease);
  z-index: 45;
}

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; inset: 0;
  z-index: 90;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(8, 8, 10, .55);
  backdrop-filter: blur(6px);
  animation: fade .24s var(--ease) both;
}
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.modal-card {
  position: relative;
  width: min(560px, 100%);
  max-height: 82dvh;
  overflow: auto;
  padding: 32px 32px 30px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: pop .34s var(--ease) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.modal-x {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px; color: var(--muted);
}
.modal-x:hover { background: var(--panel-2); color: var(--text); }
.modal-body h2 { margin: 0 0 6px; font-size: 18px; letter-spacing: .04em; }
.modal-body .lead { margin: 0 0 22px; font-size: 12.5px; line-height: 1.9; color: var(--muted); }
.modal-body h3 {
  margin: 24px 0 10px; font-size: 11px; letter-spacing: .16em;
  color: var(--muted); text-transform: uppercase; font-weight: 600;
}
.modal-body p, .modal-body li { font-size: 12.5px; line-height: 1.95; color: var(--text-2); }
.modal-body ol, .modal-body ul { padding-left: 18px; margin: 0; }
.modal-body li { margin-bottom: 8px; }
.src { display: block; padding: 10px 0; border-bottom: 1px solid var(--line-2); text-decoration: none; }
.src:last-child { border: 0; }
.src b { display: block; font-size: 12.5px; color: var(--text); font-weight: 600; }
.src span { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.7; margin-top: 3px; }
.src:hover b { color: var(--accent); }
.kbd-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.kbd-row span {
  font-size: 11px; color: var(--text-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px;
}
.kbd-row b { color: var(--muted); font-weight: 500; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 232px minmax(0, 1fr); }
  .detail { width: 352px; }
  .search { width: min(280px, 30vw); }
}

@media (max-width: 900px) {
  .top {
    height: auto;
    padding: 10px 14px;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
  }
  .brand { flex: 1 1 auto; }
  .brand h1 { font-size: 14px; letter-spacing: .08em; }
  .brand p { display: none; }
  .mark { width: 30px; height: 30px; border-radius: 9px; }
  .mark svg { width: 17px; height: 17px; }

  .tools { gap: 2px; }
  #btn-list { display: inline-flex; }
  #btn-random { width: 34px; padding: 0; justify-content: center; }
  #btn-random span { display: none; }
  #btn-about { display: none; }

  .search {
    order: 3;
    width: 100%;
    height: 34px;
    margin: 2px 0 0;
  }
  .search kbd { display: none; }

  .chips {
    display: flex;
    min-width: 0;
    max-width: 100%;
    gap: 6px;
    padding: 9px 26px 10px 14px;
    overflow-x: auto;
    scrollbar-width: none;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--line-2);
    background: var(--panel);
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent 100%);
    mask-image: linear-gradient(90deg, #000 88%, transparent 100%);
  }
  .chips::-webkit-scrollbar { display: none; }
  .chips .chip { flex: 0 0 auto; }

  .layout { grid-template-columns: minmax(0, 1fr); }

  .side {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 84%;
    max-width: 320px;
    border-right: 1px solid var(--line);
    box-shadow: 24px 0 60px rgba(0, 0, 0, .3);
    transform: translateX(-102%);
    transition: transform .4s var(--ease);
    padding-top: calc(env(safe-area-inset-top) + 10px);
    z-index: 50;
  }
  body.side-open .side { transform: none; }
  .side-close { display: inline-flex; }
  body.side-open .backdrop { opacity: 1; pointer-events: auto; }
  .filters { display: none; }

  .detail {
    top: auto;
    left: 0; right: 0; bottom: 0;
    width: auto;
    height: 58dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -24px 60px rgba(0, 0, 0, .34);
    transform: translateY(101%);
    transition: transform .46s var(--ease);
  }
  body.has-sel .detail { transform: none; }
  .detail-scroll { padding: 18px 20px calc(30px + env(safe-area-inset-bottom)); }
  .grip {
    display: flex; align-items: center; justify-content: center;
    height: 20px; padding-top: 8px;
    cursor: grab;
  }
  .grip span { width: 34px; height: 4px; border-radius: 2px; background: var(--line); }
  .sheet-x { display: grid; }

  .dc h2 { font-size: 24px; }
  .legend, .stage-intro { display: none; }

.stage-hint { bottom: 14px; font-size: 10px; padding: 5px 11px; }
  .zoomer { right: 12px; bottom: 12px; }
  .crumbs { top: 10px; left: 12px; right: 70px; }
  .empty { padding-top: 8vh; }
}

@media (max-width: 380px) {
  .brand h1 { font-size: 13px; }
  .chips { padding-left: 10px; padding-right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
