:root {
  color-scheme: dark;
  --bg: #071411;
  --panel: #0b1c18;
  --panel-soft: rgba(12, 30, 26, .88);
  --line: rgba(199, 226, 216, .15);
  --text: #eef7f3;
  --muted: #91aaa1;
  --mint: #64dbb3;
  --coral: #ff7969;
  --gold: #f0c45e;
  --blue: #63bfe8;
  --violet: #b79ce8;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); }
button, input { font: inherit; }
button { color: inherit; }

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 210px minmax(230px, 1fr) minmax(280px, 460px) auto auto;
  align-items: center;
  gap: 24px;
  height: 78px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 18, 15, .94);
  backdrop-filter: blur(18px);
}
.brand img { display: block; width: 186px; height: 44px; object-fit: contain; object-position: left center; }
.title-lockup span, .panel-heading span, .source-note > span, .detail-empty > span, .detail-label {
  color: var(--mint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
}
.title-lockup h1 { margin: 3px 0 0; font-size: 19px; font-weight: 650; letter-spacing: 0; }
.search-box { position: relative; display: grid; grid-template-columns: 24px 1fr auto; align-items: center; min-height: 42px; padding: 0 10px 0 13px; border: 1px solid var(--line); background: rgba(255,255,255,.035); }
.search-box:focus-within { border-color: rgba(100,219,179,.65); box-shadow: 0 0 0 3px rgba(100,219,179,.08); }
.search-box > span { color: var(--mint); font-size: 21px; transform: rotate(-20deg); }
.search-box input { min-width: 0; color: var(--text); border: 0; outline: 0; background: transparent; }
.search-box input::placeholder { color: #6f8980; }
.search-box kbd { padding: 3px 6px; color: var(--muted); font-size: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.04); }
.search-results { position: absolute; top: calc(100% + 8px); right: 0; left: 0; max-height: 360px; overflow: auto; border: 1px solid var(--line); background: #0d211c; box-shadow: 0 22px 52px rgba(0,0,0,.38); }
.search-result { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 11px 13px; text-align: left; border: 0; border-bottom: 1px solid rgba(199,226,216,.08); background: transparent; }
.search-result:hover, .search-result:focus-visible { background: rgba(100,219,179,.08); outline: 0; }
.search-result i { width: 7px; height: 7px; border-radius: 50%; background: var(--node-color); box-shadow: 0 0 12px var(--node-color); }
.search-result b { display: block; font-size: 13px; }
.search-result small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.search-result em { color: var(--muted); font-size: 10px; font-style: normal; }
.view-switch { display: grid; grid-template-columns: repeat(2, 44px); border: 1px solid var(--line); }
.view-switch button { height: 36px; border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 800; }
.view-switch button.active { color: #06201a; background: var(--mint); }
.language-toggle { min-height: 36px; width: 42px; padding: 0; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; background: transparent; color: var(--muted); font: 800 11px/1 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: 0; }
.language-toggle:hover { color: var(--mint); border-color: rgba(100,219,179,.65); }

.workspace { display: grid; grid-template-columns: 228px minmax(0, 1fr) 342px; height: calc(100% - 78px); }
.filter-panel, .detail-panel { position: relative; z-index: 10; min-width: 0; background: var(--panel-soft); backdrop-filter: blur(18px); }
.filter-panel { display: flex; flex-direction: column; padding: 25px 18px 18px; border-right: 1px solid var(--line); }
.panel-heading b { display: block; margin-top: 5px; font-size: 20px; }
.category-filters { display: grid; gap: 2px; margin-top: 23px; }
.category-filter { display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 10px; min-height: 38px; padding: 0 8px; cursor: pointer; color: var(--muted); }
.category-filter:hover { color: var(--text); background: rgba(255,255,255,.025); }
.category-filter input { position: absolute; opacity: 0; pointer-events: none; }
.category-filter i { width: 9px; height: 9px; border: 1px solid var(--node-color); border-radius: 50%; }
.category-filter:has(input:checked) i { background: var(--node-color); box-shadow: 0 0 12px color-mix(in srgb, var(--node-color) 65%, transparent); }
.category-filter span { font-size: 12px; font-weight: 650; }
.category-filter b { color: #69847a; font-size: 10px; font-weight: 700; }
.source-note { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); }
.source-note p { margin: 8px 0 5px; color: #c9d9d3; font-size: 11px; line-height: 1.6; }
.source-note small { display: block; color: #718c82; font-size: 9px; line-height: 1.6; }

.graph-stage { position: relative; min-width: 0; overflow: hidden; background: #071411; }
#graph-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }
.graph-wash { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(7,20,17,.05), transparent 30%, rgba(7,20,17,.18)); }
.stage-heading { position: absolute; top: 26px; left: 28px; max-width: 520px; pointer-events: none; }
.stage-heading span { color: var(--coral); font-size: 10px; font-weight: 800; }
.stage-heading strong { display: block; margin-top: 5px; color: rgba(238,247,243,.82); font-size: 16px; font-weight: 550; }
.stage-controls { position: absolute; top: 25px; right: 24px; display: grid; grid-template-columns: repeat(2, 36px); gap: 7px; }
.stage-controls button { width: 36px; height: 36px; border: 1px solid var(--line); background: rgba(7,20,17,.66); font-size: 16px; }
.stage-controls button:hover { border-color: var(--mint); color: var(--mint); }
.graph-stats { position: absolute; bottom: 23px; left: 27px; display: flex; gap: 20px; color: var(--muted); font-size: 10px; }
.graph-stats b { color: var(--text); font-size: 13px; }
.depth-indicator { position: absolute; right: 24px; bottom: 23px; display: grid; grid-template-columns: auto 70px auto; align-items: center; gap: 8px; color: #607c72; font-size: 8px; font-weight: 800; }
.depth-indicator i { height: 1px; background: linear-gradient(90deg, var(--mint), var(--coral)); }
.graph-tooltip { position: absolute; z-index: 12; max-width: 220px; padding: 8px 10px; pointer-events: none; color: var(--text); font-size: 11px; border-left: 2px solid var(--tooltip-color, var(--mint)); background: rgba(6,20,16,.9); box-shadow: 0 10px 24px rgba(0,0,0,.3); }
.graph-tooltip b { display: block; }
.graph-tooltip span { color: var(--muted); font-size: 9px; }

.detail-panel { padding: 27px 24px; overflow: auto; border-left: 1px solid var(--line); }
.close-detail { display: none; }
.detail-empty h2, .detail-panel article h2 { margin: 12px 0 6px; font-size: 29px; line-height: 1.15; }
.detail-empty > p { color: var(--muted); font-size: 12px; line-height: 1.75; }
.detail-metrics { display: grid; grid-template-columns: repeat(2, 1fr); margin-top: 26px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-metrics div { padding: 16px 0; }
.detail-metrics div + div { padding-left: 16px; border-left: 1px solid var(--line); }
.detail-metrics b { display: block; color: var(--gold); font-size: 24px; }
.detail-metrics span { color: var(--muted); font-size: 9px; }
.detail-categories { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-category { display: inline-flex; align-items: center; gap: 6px; color: var(--category-color); font-size: 10px; font-weight: 800; }
.detail-category::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.detail-en { margin: 0; color: var(--mint); font-family: Georgia, serif; font-size: 17px; font-style: italic; }
.detail-source { margin: 25px 0; border-top: 1px solid var(--line); }
.detail-source div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail-source dt { color: var(--muted); font-size: 10px; }
.detail-source dd { margin: 0; font-size: 10px; }
.detail-panel article section { margin-top: 25px; }
.detail-excerpt { color: #bdcec7; font-size: 12px; line-height: 1.8; }
.detail-neighbors { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.detail-neighbor { padding: 6px 8px; color: #b9cec6; font-size: 10px; border: 1px solid var(--line); background: transparent; }
.detail-neighbor:hover { color: var(--mint); border-color: var(--mint); }

.load-state { position: fixed; z-index: 50; inset: 0; display: grid; place-content: center; justify-items: center; gap: 17px; background: #071411; transition: opacity .5s ease, visibility .5s ease; }
.load-state.done { opacity: 0; visibility: hidden; }
.load-state i { width: 42px; height: 42px; border: 1px solid rgba(100,219,179,.18); border-top-color: var(--mint); border-radius: 50%; animation: spin 1s linear infinite; }
.load-state span { color: var(--muted); font-size: 11px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .topbar { grid-template-columns: 180px 1fr minmax(250px, 380px) auto auto; gap: 14px; }
  .title-lockup span { display: none; }
  .workspace { grid-template-columns: 190px minmax(0, 1fr) 300px; }
}
@media (max-width: 820px) {
  html, body { overflow: hidden; }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; height: 68px; padding-inline: 14px; }
  .brand img { width: 172px; }
  .title-lockup, .view-switch { display: none; }
  .search-box { min-width: 0; }
  .search-box kbd { display: none; }
  .workspace { grid-template-columns: 1fr; height: calc(100% - 68px); }
  .filter-panel { position: absolute; z-index: 15; top: 68px; right: 0; left: 0; display: block; height: 49px; padding: 7px 12px; overflow-x: auto; overflow-y: hidden; border: 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
  .panel-heading, .source-note { display: none; }
  .category-filters { display: flex; gap: 3px; margin: 0; }
  .category-filter { display: inline-grid; grid-template-columns: 11px auto; min-height: 34px; padding: 0 9px; border: 1px solid rgba(199,226,216,.08); }
  .category-filter b { display: none; }
  .graph-stage { padding-top: 49px; }
  .stage-heading { top: 66px; left: 17px; max-width: calc(100% - 100px); }
  .stage-heading strong { font-size: 13px; }
  .stage-controls { top: 64px; right: 13px; grid-template-columns: 34px; }
  #toggle-motion { display: none; }
  .depth-indicator { display: none; }
  .graph-stats { bottom: 15px; left: 16px; gap: 12px; }
  .detail-panel { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; height: min(50vh, 440px); padding: 22px 20px; border: 0; border-top: 1px solid var(--line); transform: translateY(102%); transition: transform .32s ease; }
  body.detail-open .detail-panel { transform: translateY(0); }
  .close-detail { position: absolute; top: 13px; right: 16px; display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid var(--line); background: transparent; font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
