:root {
  --night: #081015;
  --night-2: #101a20;
  --panel: #121f26;
  --canvas: #e8eee9;
  --canvas-grid: rgba(27, 54, 59, .13);
  --canvas-ink: #1c3439;
  --paper: #f2f1ea;
  --ink: #162027;
  --muted: #7d898f;
  --line: rgba(255, 255, 255, .18);
  --lime: #c7f33a;
  --blue: #55a9ff;
  --orange: #ff9f43;
  --red: #ff6577;
  --cyan: #54d6c5;
  --yellow: #f4d35e;
  --display: "Agency FB", "Bahnschrift Condensed", "Microsoft YaHei UI", sans-serif;
  --body: "Microsoft YaHei UI", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: #fff; background: var(--night); font-family: var(--body); letter-spacing: 0; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.graph-noise { position: fixed; inset: 0; z-index: 50; pointer-events: none; opacity: .035; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.88' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E"); }

.graph-topbar { position: sticky; top: 0; z-index: 40; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; min-height: 76px; padding: 12px max(28px, calc((100vw - 1480px) / 2)); background: rgba(8, 16, 21, .96); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); }
.graph-brand { display: inline-flex; align-items: center; gap: 12px; width: max-content; }
.graph-brand-mark { display: grid; place-items: center; width: 44px; height: 44px; color: var(--lime); border: 1px solid rgba(199, 243, 58, .55); font-family: var(--display); font-size: 18px; font-weight: 800; transform: rotate(-5deg); }
.graph-brand strong, .graph-brand small { display: block; }
.graph-brand strong { font-family: var(--display); font-size: 15px; letter-spacing: 2px; }
.graph-brand small { margin-top: 3px; color: rgba(255,255,255,.5); font-size: 10px; }
.back-link { justify-self: end; color: rgba(255,255,255,.65); font-size: 12px; }
.back-link span { color: var(--lime); }

.mode-tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); background: rgba(255,255,255,.035); }
.mode-tab { min-width: 112px; padding: 9px 14px; color: rgba(255,255,255,.55); border: 0; background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; }
.mode-tab:hover { color: #fff; }
.mode-tab.active { color: var(--night); background: var(--lime); }

main { min-height: calc(100vh - 76px); }
.graph-intro { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 48px; max-width: 1480px; margin: 0 auto; padding: 66px 28px 34px; background: radial-gradient(circle at 82% 28%, rgba(199,243,58,.08), transparent 28%); }
.intro-index { display: block; margin-bottom: 12px; color: var(--lime); font-family: var(--display); font-size: 12px; font-weight: 700; letter-spacing: 2px; }
.intro-copy h1 { margin: 0; font-family: var(--display); font-size: 58px; line-height: .92; text-transform: uppercase; }
.intro-copy p { max-width: 680px; margin: 18px 0 0; color: rgba(255,255,255,.72); font-size: 14px; line-height: 1.8; }
.graph-metrics { display: grid; grid-template-columns: repeat(3, 112px); border: 1px solid var(--line); }
.graph-metrics div { min-height: 104px; padding: 15px; border-right: 1px solid var(--line); }
.graph-metrics div:last-child { border-right: 0; }
.graph-metrics span, .graph-metrics small { display: block; }
.graph-metrics span { color: rgba(255,255,255,.38); font-family: var(--display); font-size: 10px; letter-spacing: 1.5px; }
.graph-metrics strong { display: block; margin: 5px 0 2px; color: var(--lime); font-family: var(--display); font-size: 32px; line-height: 1; }
.graph-metrics small { color: rgba(255,255,255,.55); font-size: 10px; }

.graph-console { max-width: 1480px; margin: 0 auto; padding: 0 28px 76px; }
.graph-toolbar { display: flex; align-items: center; gap: 12px; min-height: 62px; padding: 10px; border: 1px solid rgba(28,52,57,.22); border-bottom: 0; background: #cfdad4; }
.graph-search { display: flex; align-items: center; gap: 9px; width: min(390px, 32vw); height: 40px; padding: 0 11px; border: 1px solid rgba(28,52,57,.25); background: rgba(255,255,255,.7); }
.search-symbol { color: var(--lime); font-family: var(--display); font-size: 24px; line-height: 1; }
.graph-search input { min-width: 0; flex: 1; color: var(--canvas-ink); border: 0; outline: 0; background: transparent; font-size: 12px; }
.graph-search input::placeholder { color: rgba(28,52,57,.52); }
.graph-search kbd { padding: 2px 5px; color: rgba(28,52,57,.62); border: 1px solid rgba(28,52,57,.2); font-family: var(--display); font-size: 9px; }
.type-filters { display: flex; flex: 1; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.type-filters::-webkit-scrollbar { display: none; }
.type-filter { flex: 0 0 auto; min-height: 34px; padding: 6px 11px; color: rgba(28,52,57,.7); border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 11px; }
.type-filter:hover { color: var(--canvas-ink); border-color: rgba(28,52,57,.24); }
.type-filter.active { color: #254000; border-color: rgba(95,131,16,.55); background: rgba(199,243,58,.34); }
.related-switch { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; color: rgba(28,52,57,.76); font-size: 11px; cursor: pointer; }
.related-switch input { position: absolute; opacity: 0; pointer-events: none; }
.related-switch span { position: relative; width: 34px; height: 18px; border: 1px solid rgba(28,52,57,.34); background: rgba(255,255,255,.72); }
.related-switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 10px; height: 10px; background: rgba(28,52,57,.52); transition: transform .2s ease, background .2s ease; }
.related-switch input:checked + span { border-color: var(--lime); }
.related-switch input:checked + span::after { background: var(--lime); transform: translateX(16px); }
.view-controls { display: flex; flex: 0 0 auto; gap: 4px; }
.view-controls button { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; color: var(--canvas-ink); border: 1px solid rgba(28,52,57,.25); background: rgba(255,255,255,.56); cursor: pointer; font-family: var(--display); font-size: 19px; }
.view-controls button:hover { color: var(--night); background: var(--lime); border-color: var(--lime); }

.graph-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 720px; border: 1px solid var(--line); }
.canvas-panel { min-width: 0; border-right: 1px solid rgba(28,52,57,.2); background: var(--canvas); }
.canvas-status { display: flex; align-items: center; justify-content: space-between; min-height: 42px; padding: 0 15px; color: rgba(28,52,57,.62); border-bottom: 1px solid rgba(28,52,57,.18); font-family: var(--display); font-size: 10px; letter-spacing: 1.4px; }
.canvas-status span { display: inline-flex; align-items: center; gap: 7px; }
.canvas-status i { width: 6px; height: 6px; background: var(--lime); box-shadow: 0 0 12px rgba(199,243,58,.65); }
.canvas-status strong { color: rgba(28,52,57,.84); font-weight: 700; }
.canvas-shell { position: relative; height: 630px; overflow: hidden; cursor: grab; background-color: var(--canvas); background-image: linear-gradient(var(--canvas-grid) 1px, transparent 1px), linear-gradient(90deg, var(--canvas-grid) 1px, transparent 1px); background-size: 28px 28px; }
.canvas-shell.dragging { cursor: grabbing; }
#knowledgeCanvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; }
.graph-edge { fill: none; stroke: rgba(28,52,57,.43); stroke-width: 1.6; transition: opacity .2s ease, stroke .2s ease, stroke-width .2s ease; }
.graph-edge.highlighted { stroke: var(--lime); stroke-width: 2.2; }
.graph-edge.dimmed { opacity: .28; }
.graph-edge-arrow { fill: rgba(28,52,57,.54); transition: opacity .2s ease, fill .2s ease; }
.graph-edge-arrow.highlighted { fill: var(--lime); }
.graph-edge-arrow.dimmed { opacity: .28; }
.edge-label { fill: rgba(28,52,57,.62); font-family: var(--body); font-size: 10px; text-anchor: middle; pointer-events: none; }
.edge-label.highlighted { fill: var(--lime); }
.edge-label.dimmed { opacity: .3; }
.graph-node { cursor: pointer; outline: none; transition: opacity .2s ease; }
.graph-node.dimmed { opacity: .58; }
.graph-node .node-box { fill: rgba(255,255,255,.9); stroke: rgba(28,52,57,.32); stroke-width: 1.2; transition: fill .2s ease, stroke .2s ease, stroke-width .2s ease; }
.graph-node:hover .node-box, .graph-node:focus .node-box { fill: #fff; stroke: rgba(28,52,57,.72); }
.graph-node.selected .node-box { stroke: var(--node-color, var(--lime)); stroke-width: 2.4; }
.graph-node.highlighted:not(.selected) .node-box { stroke: color-mix(in srgb, var(--node-color, var(--lime)) 65%, white); }
.graph-node .node-accent { fill: var(--node-color, var(--lime)); }
.graph-node .node-type { fill: var(--node-color, var(--lime)); font-family: var(--display); font-size: 9px; font-weight: 700; letter-spacing: 1.2px; }
.graph-node .node-title { fill: var(--canvas-ink); font-family: var(--body); font-size: 13px; font-weight: 800; }
.graph-node .node-subtitle { fill: rgba(28,52,57,.68); font-family: var(--body); font-size: 9px; }
.graph-node[data-type="scene"], .graph-node[data-type="stage"], .graph-node[data-type="check"] { --node-color: var(--lime); }
.graph-node[data-type="page"], .graph-node[data-type="role"], .graph-node[data-type="evidence"] { --node-color: var(--blue); }
.graph-node[data-type="api"], .graph-node[data-type="document"], .graph-node[data-type="target"] { --node-color: var(--orange); }
.graph-node[data-type="controller"], .graph-node[data-type="status"], .graph-node[data-type="symptom"] { --node-color: var(--red); }
.graph-node[data-type="service"], .graph-node[data-type="action"] { --node-color: var(--cyan); }
.graph-node[data-type="mapper"] { --node-color: var(--yellow); }
.graph-node[data-type="table"] { --node-color: #8bd17c; }
.layer-label { fill: rgba(28,52,57,.52); font-family: var(--display); font-size: 11px; font-weight: 700; letter-spacing: 1.6px; }
.layer-line { stroke: rgba(28,52,57,.18); stroke-dasharray: 4 7; }
.canvas-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.canvas-empty[hidden] { display: none; }
.canvas-empty strong, .canvas-empty span { display: block; }
.canvas-empty strong { font-family: var(--display); font-size: 28px; }
.canvas-empty span { margin-top: 8px; color: rgba(255,255,255,.48); font-size: 12px; }
.canvas-hint { display: flex; gap: 18px; min-height: 46px; align-items: center; padding: 0 15px; color: rgba(28,52,57,.62); border-top: 1px solid rgba(28,52,57,.18); font-size: 10px; }
.canvas-hint span::before { content: "■"; margin-right: 7px; color: var(--lime); font-size: 5px; vertical-align: 2px; }

.node-inspector { min-width: 0; padding: 25px; color: var(--ink); background: var(--paper); }
.inspector-empty { display: grid; place-content: center; min-height: 100%; text-align: center; }
.inspector-empty strong { font-family: var(--display); font-size: 28px; }
.inspector-empty span { max-width: 230px; margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.inspector-type { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; color: var(--night); border: 1px solid rgba(22,32,39,.22); font-family: var(--display); font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.node-inspector h2 { margin: 18px 0 5px; font-family: var(--display); font-size: 34px; line-height: .95; overflow-wrap: anywhere; }
.inspector-subtitle { color: #526069; font-size: 11px; font-weight: 700; }
.inspector-summary { margin: 20px 0; color: #526069; font-size: 13px; line-height: 1.8; }
.inspector-path { display: block; max-width: 100%; padding: 11px; overflow-wrap: anywhere; color: #8dd923; background: var(--night); font-family: Consolas, monospace; font-size: 10px; line-height: 1.6; }
.inspector-block { margin-top: 24px; padding-top: 18px; border-top: 1px solid rgba(22,32,39,.16); }
.inspector-block h3 { margin: 0 0 11px; font-family: var(--display); font-size: 13px; letter-spacing: 1.4px; }
.inspector-block ul { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.inspector-block li { position: relative; padding-left: 14px; color: #526069; font-size: 11px; line-height: 1.65; }
.inspector-block li::before { content: ""; position: absolute; top: 8px; left: 0; width: 5px; height: 5px; background: #7bbd22; }
.relation-list { display: grid; gap: 7px; }
.relation-button { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; width: 100%; padding: 9px 0; color: var(--ink); border: 0; border-bottom: 1px solid rgba(22,32,39,.12); background: transparent; text-align: left; cursor: pointer; }
.relation-button:hover strong { color: #5c930d; }
.relation-button span { min-width: 42px; color: #7a878e; font-family: var(--display); font-size: 9px; }
.relation-button strong { overflow-wrap: anywhere; font-size: 11px; }

.graph-legend { display: grid; grid-template-columns: 180px 1fr auto; align-items: center; gap: 32px; max-width: 1424px; margin: 0 auto 74px; padding: 25px 0; color: var(--ink); border-top: 1px solid rgba(255,255,255,.18); border-bottom: 1px solid rgba(255,255,255,.18); }
.graph-legend > span { color: var(--lime); font-family: var(--display); font-size: 11px; font-weight: 700; letter-spacing: 1.5px; }
.graph-legend p { margin: 0; color: rgba(255,255,255,.72); font-size: 12px; line-height: 1.7; }
.graph-legend a { color: #fff; font-size: 12px; }
.graph-legend a span { color: var(--lime); }
.graph-footer { display: flex; justify-content: space-between; gap: 24px; padding: 26px max(28px, calc((100vw - 1424px) / 2)); color: rgba(255,255,255,.45); border-top: 1px solid var(--line); font-size: 11px; }
.graph-footer strong { color: #fff; font-family: var(--display); letter-spacing: 1.6px; }

@media (max-width: 1120px) {
  .graph-topbar { grid-template-columns: 1fr auto; }
  .mode-tabs { grid-column: 1 / -1; grid-row: 2; justify-content: center; }
  .graph-intro { padding-top: 48px; }
  .graph-toolbar { flex-wrap: wrap; }
  .graph-search { width: min(520px, 100%); flex: 1 1 360px; }
  .type-filters { order: 3; flex-basis: 100%; }
  .graph-workspace { grid-template-columns: 1fr; }
  .canvas-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .node-inspector { min-height: 420px; }
  .graph-legend { margin-inline: 28px; }
}

@media (max-width: 720px) {
  .graph-topbar { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 15px; }
  .graph-brand { flex: 1; }
  .graph-brand strong { font-size: 13px; }
  .back-link { font-size: 0; }
  .back-link span { font-size: 18px; }
  .mode-tabs { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; }
  .mode-tab { min-width: 104px; }
  .graph-intro { grid-template-columns: 1fr; gap: 28px; padding: 42px 15px 26px; }
  .intro-copy h1 { font-size: 44px; }
  .graph-metrics { grid-template-columns: repeat(3, 1fr); }
  .graph-metrics div { min-height: 88px; padding: 12px; }
  .graph-metrics strong { font-size: 27px; }
  .graph-console { padding: 0 15px 58px; }
  .graph-toolbar { align-items: stretch; }
  .graph-search { flex-basis: 100%; width: 100%; }
  .related-switch { margin-right: auto; }
  .canvas-shell { height: 540px; }
  .canvas-hint { gap: 10px; overflow-x: auto; white-space: nowrap; }
  .node-inspector { min-height: 0; padding: 22px; }
  .graph-legend { grid-template-columns: 1fr; gap: 12px; margin: 0 15px 54px; }
  .graph-footer { flex-direction: column; padding: 24px 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
