:root {
  --bg: #121316;
  --bg2: #17191d;
  --grid: rgba(255,255,255,.035);
  --line: #2a2d33;
  --text: #e9e7e2;
  --muted: #8d8f95;
  --root: #f4efe6;
  --feature: #7aa2ff;
  --policy: #4fd1a5;
  --platform: #f2b84b;
  --case: #c9c6bf;
  --hit: #ff7a59;
  --panel-w: 420px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
button { font: inherit; color: inherit; }

/* top bar */
.bar {
  position: fixed; inset: 0 0 auto 0; height: 60px; z-index: 5;
  display: flex; align-items: center; gap: 18px; padding: 0 18px;
  background: linear-gradient(to bottom, rgba(18,19,22,.97), rgba(18,19,22,.85));
  border-bottom: 1px solid var(--line); backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--root);
  background: radial-gradient(circle at 70% 30%, var(--feature) 0 25%, transparent 26%),
              radial-gradient(circle at 30% 70%, var(--policy) 0 25%, transparent 26%); }
.brand-title { font-weight: 650; letter-spacing: .2px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.search { flex: 1; max-width: 560px; display: flex; align-items: center; gap: 6px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 0 6px 0 10px; height: 38px; color: var(--muted); }
.search:focus-within { border-color: #4a4f58; }
.search input { flex: 1; background: none; border: 0; outline: 0; color: var(--text); font-size: 14px; height: 100%; }
.qcount { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.btn, .ibtn { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; height: 32px; cursor: pointer; }
.btn { padding: 0 12px; font-size: 13px; }
.ibtn { width: 32px; font-size: 18px; line-height: 1; padding: 0; }
.btn:hover, .ibtn:hover { border-color: #50555f; background: #1d2025; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.zoom { font-size: 12px; color: var(--muted); width: 42px; text-align: center; font-variant-numeric: tabular-nums; }

/* stage */
.stage { position: fixed; inset: 60px 0 0 0; cursor: grab; touch-action: none;
  background-color: var(--bg);
  background-image: radial-gradient(var(--grid) 1px, transparent 1px);
  background-size: 22px 22px; transition: right .3s ease; }
.stage.panning { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.edges path { fill: none; stroke-width: 2; stroke-linecap: round; opacity: .55; transition: opacity .2s, stroke-width .2s; }
.edges path.on { opacity: 1; stroke-width: 2.6; }
.edges.dim path:not(.on) { opacity: .18; }
.hint { position: absolute; left: 16px; bottom: 14px; font-size: 12px; color: #5d6067; pointer-events: none; }

/* nodes */
.node {
  position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 10px;
  padding: 9px 12px 9px 14px; border-radius: 12px; cursor: pointer; user-select: none;
  background: #1a1c21; border: 1px solid #2c3037; color: var(--text);
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 6px 18px rgba(0,0,0,.25);
  transition: border-color .15s, background .15s, box-shadow .2s, opacity .2s;
  white-space: nowrap; font-size: 14px;
}
.node::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); }
.node:hover { border-color: color-mix(in srgb, var(--c) 55%, #2c3037); background: #1e2126; }
.node .t { overflow: hidden; text-overflow: ellipsis; }
.node .cnt { font-size: 11px; font-weight: 600; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
  border-radius: 999px; padding: 2px 7px; font-variant-numeric: tabular-nums; }
.node .chev { width: 18px; height: 18px; border-radius: 50%; border: 1px solid #3a3e46; display: grid; place-items: center;
  font-size: 11px; color: var(--muted); margin-left: 2px; transition: transform .25s; flex: none; }
.node.open .chev { transform: rotate(180deg); }
.node.k-root { --c: var(--root); font-size: 17px; font-weight: 700; padding: 13px 16px 13px 18px; border-radius: 14px;
  background: #f4efe6; color: #15161a; border-color: #f4efe6; }
.node.k-root::before { box-shadow: none; background: #15161a; }
.node.k-root .cnt { color: #15161a; background: rgba(0,0,0,.08); }
.node.k-root .chev { border-color: rgba(0,0,0,.2); color: #15161a; }
.node.k-feature { --c: var(--feature); font-weight: 600; }
.node.k-policy { --c: var(--policy); font-weight: 600; }
.node.k-platform { --c: var(--platform); font-weight: 600; }
.node .os { font-size: 13px; opacity: .85; }
.node.k-case { --c: var(--case); white-space: normal; width: 320px; align-items: flex-start; font-size: 13px; line-height: 1.35;
  background: #17191d; border-radius: 10px; padding: 9px 12px; }
.node.k-case::before { margin-top: 5px; width: 7px; height: 7px; background: transparent; border: 1.5px solid var(--c); box-shadow: none; }
.node.k-case .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; flex: 1; }
.node.k-case .pri { font-size: 10px; font-weight: 700; color: var(--muted); border: 1px solid #343840; border-radius: 5px; padding: 1px 5px; flex: none; margin-top: 1px; }
.node.k-case .pri.P1 { color: #ff9b85; border-color: #5a3a33; }
.node.sel { border-color: var(--c) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent), 0 8px 24px rgba(0,0,0,.4); }
.node.k-case.sel { --c: #ffffff; background: #22252b; }
.node.path { border-color: color-mix(in srgb, var(--c) 70%, #2c3037); }
.node.hit { border-color: var(--hit) !important; }
.node.hit .t mark { background: color-mix(in srgb, var(--hit) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.node.cur { box-shadow: 0 0 0 3px color-mix(in srgb, var(--hit) 35%, transparent), 0 8px 24px rgba(0,0,0,.4); }
.searching .node:not(.hit):not(.path):not(.k-root) { opacity: .45; }

/* side panel */
.panel { position: fixed; top: 60px; right: 0; bottom: 0; width: var(--panel-w); z-index: 4;
  background: #16181c; border-left: 1px solid var(--line); padding: 22px 24px 28px; overflow-y: auto;
  transform: translateX(100%); transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.panel.open { transform: none; }
body.panel-open .stage { right: var(--panel-w); }
.panel .close { position: absolute; right: 14px; top: 14px; }
.crumbs { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 6px; padding-right: 40px; }
.crumbs span:not(:last-child)::after { content: "›"; margin-left: 6px; color: #50545b; }
.panel h2 { font-size: 19px; line-height: 1.3; margin: 12px 0 14px; font-weight: 650; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.chip { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 3px 9px; background: #22252b; color: var(--muted); border: 1px solid #30343b; }
.chip.P1 { color: #ff9b85; border-color: #5a3a33; }
.chip.plat { color: var(--platform); border-color: #4d3f22; }
.chip.status { color: #b5b9c2; }
.panel h3 { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 34px; font-size: 14px; line-height: 1.45; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: -1px; width: 22px; height: 22px; border-radius: 50%;
  background: #23262c; border: 1px solid #353941; font-size: 11px; display: grid; place-items: center; color: #c9ccd2; }
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 11px; top: 24px; bottom: 2px; width: 1px; background: #30343b; }
.expected { background: color-mix(in srgb, var(--policy) 9%, #16181c); border: 1px solid color-mix(in srgb, var(--policy) 30%, #2a2d33);
  border-radius: 10px; padding: 12px 14px; font-size: 14px; line-height: 1.5; }
.panel .id { margin-top: 26px; font-size: 11px; color: #5d6067; font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
.panel .list { display: grid; gap: 6px; }
.panel .list button { text-align: left; background: #1b1d22; border: 1px solid #2c3037; border-radius: 8px; padding: 8px 10px; font-size: 13px; cursor: pointer; }
.panel .list button:hover { border-color: #4a4f58; }
