:root {
  --kbm-bg: var(--sv-color-canvas);
  --kbm-surface: var(--sv-color-surface);
  --kbm-surface-2: var(--sv-color-surface-strong);
  --kbm-line: var(--sv-color-border);
  --kbm-line-strong: var(--sv-color-border-strong);
  --kbm-text: var(--sv-color-text);
  --kbm-muted: var(--sv-color-text-muted);
  --kbm-faint: var(--sv-color-text-faint);
  --kbm-cyan: var(--sv-color-brand);
  --kbm-lime: var(--sv-color-brand-active);
  --kbm-amber: #ad7134;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body.knowledge-butler-body {
  background: var(--kbm-bg);
  color: var(--kbm-text);
  font-family: var(--sv-font-sans);
}

button, a { font: inherit; }
.kbm-shell { width: min(1440px, 100%); margin: 0 auto; padding: 36px clamp(24px, 4vw, 64px) 76px; }
.kbm-topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; }
.kbm-kicker, .kbm-section-code { margin: 0; color: var(--kbm-cyan); letter-spacing: .18em; font: 780 10px/1.2 var(--sv-font-mono); }
.kbm-topbar h1 { margin: 9px 0 7px; font-family: var(--sv-font-sans); font-size: clamp(38px, 5.2vw, 72px); font-weight: 500; line-height: .94; letter-spacing: -.065em; }
.kbm-lede { max-width: 820px; margin: 0; color: var(--kbm-muted); font-size: 13px; line-height: 1.75; }
.kbm-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.kbm-button { min-height: 40px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--kbm-cyan); border-radius: 4px; background: var(--kbm-cyan); color: var(--sv-color-on-brand); font-weight: 760; text-decoration: none; cursor: pointer; transition: transform 160ms ease, border-color 160ms ease; }
.kbm-button:hover { transform: translateY(-1px); }
.kbm-button--quiet { border-color: var(--kbm-line-strong); background: var(--sv-color-surface); color: var(--kbm-text); }

.kbm-observation { min-height: 370px; margin-top: 34px; display: grid; grid-template-columns: minmax(0, .96fr) minmax(450px, 1.04fr); overflow: hidden; border: 1px solid var(--kbm-line-strong); border-radius: 8px; background: var(--kbm-surface); box-shadow: 0 28px 80px rgba(0,0,0,.09); }
.kbm-observation-copy { padding: clamp(30px, 4vw, 58px); display: flex; flex-direction: column; justify-content: center; }
.kbm-section-code { display: flex; align-items: center; gap: 12px; color: var(--kbm-faint); }
.kbm-section-code span, .kbm-section-head span, .kbm-panel header span { color: var(--kbm-cyan); }
.kbm-observation h2 { max-width: 650px; margin: 24px 0 16px; font-size: clamp(31px, 3.3vw, 51px); font-weight: 520; line-height: 1.04; letter-spacing: -.052em; }
.kbm-observation h2 b { color: var(--kbm-cyan); font-weight: inherit; }
.kbm-observation-copy > p { max-width: 610px; margin: 0; color: var(--kbm-muted); font-size: 13px; line-height: 1.8; }
.kbm-window-switch { display: flex; gap: 4px; margin-top: 30px; }
.kbm-window-switch button { padding: 8px 14px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--kbm-muted); cursor: pointer; }
.kbm-window-switch button.is-active { border-color: rgba(var(--sv-brand-rgb),.34); background: rgba(var(--sv-brand-rgb),.08); color: var(--kbm-cyan); }

.kbm-domain-map { position: relative; min-height: 370px; overflow: hidden; border-left: 1px solid var(--kbm-line); background: radial-gradient(circle at 50% 50%, var(--sv-color-surface) 0, var(--sv-color-surface) 66%); }
.kbm-map-grid { position: absolute; inset: 0; opacity: .55; background-image: linear-gradient(rgba(var(--sv-brand-rgb),.08) 1px, transparent 1px), linear-gradient(90deg, rgba(var(--sv-brand-rgb),.08) 1px, transparent 1px); background-size: 38px 38px; mask-image: radial-gradient(circle, #000 20%, transparent 76%); }
.kbm-domain-map::before, .kbm-domain-map::after { content: ""; position: absolute; left: 50%; top: 50%; border: 1px solid rgba(var(--sv-brand-rgb),.16); border-radius: 50%; transform: translate(-50%,-50%); }
.kbm-domain-map::before { width: 330px; height: 330px; }
.kbm-domain-map::after { width: 210px; height: 210px; }
.kbm-map-label { position: absolute; left: 22px; top: 22px; color: var(--kbm-cyan); letter-spacing: .15em; font: 750 9px/1 var(--sv-font-mono); }
.kbm-map-core { position: absolute; left: 50%; top: 50%; width: 86px; height: 86px; display: grid; place-content: center; justify-items: center; border: 1px solid rgba(var(--sv-brand-rgb),.42); border-radius: 50%; background: var(--sv-color-surface); box-shadow: 0 0 44px rgba(var(--sv-brand-rgb),.12); transform: translate(-50%,-50%); }
.kbm-map-core span { color: var(--kbm-cyan); font: 500 29px/1 var(--sv-font-mono); }
.kbm-map-core small { margin-top: 6px; color: var(--kbm-faint); letter-spacing: .13em; font: 700 8px/1 var(--sv-font-mono); }
.kbm-domain-node { position: absolute; z-index: 2; min-width: 86px; padding: 9px 10px 8px 26px; border: 1px solid var(--kbm-line); border-radius: 5px; background: var(--sv-color-surface); color: inherit; text-decoration: none; transition: 180ms ease; }
.kbm-domain-node:hover { border-color: var(--kbm-cyan); transform: translateY(-2px); }
.kbm-domain-node i { position: absolute; left: 10px; top: 13px; width: 7px; height: 7px; border-radius: 50%; background: var(--kbm-cyan); box-shadow: 0 0 0 5px rgba(var(--sv-brand-rgb),.1); }
.kbm-domain-node b, .kbm-domain-node small { display: block; }
.kbm-domain-node b { font-size: 11px; }
.kbm-domain-node small { margin-top: 4px; color: var(--kbm-faint); font: 700 8px/1 var(--sv-font-mono); }
.kbm-domain-node--knowledge { left: 8%; top: 27%; }
.kbm-domain-node--skills { right: 8%; top: 22%; }
.kbm-domain-node--files { right: 6%; bottom: 21%; }
.kbm-domain-node--resources { left: 8%; bottom: 19%; }
.kbm-domain-node--hot { left: 50%; bottom: 5%; transform: translateX(-50%); }
.kbm-domain-node--hot:hover { transform: translateX(-50%) translateY(-2px); }

.kbm-metrics { display: grid; grid-template-columns: repeat(4,1fr); border: 1px solid var(--kbm-line); border-top: 0; background: var(--kbm-surface); }
.kbm-metrics article { min-height: 128px; padding: 23px 25px; display: grid; align-content: center; border-right: 1px solid var(--kbm-line); }
.kbm-metrics article:last-child { border-right: 0; }
.kbm-metrics span { color: var(--kbm-muted); font-size: 11px; }
.kbm-metrics strong { margin: 8px 0 5px; font: 520 34px/1 var(--sv-font-mono); letter-spacing: -.04em; }
.kbm-metrics small { color: var(--kbm-faint); font-size: 10px; }
.kbm-metric--cyan strong { color: var(--kbm-cyan); }

.kbm-memory { margin: 18px 0; padding: 22px 24px; display: grid; grid-template-columns: minmax(220px,.8fr) minmax(330px,1.35fr) auto; gap: 24px; align-items: center; border: 1px solid rgba(var(--sv-brand-rgb),.24); border-radius: 8px; background: linear-gradient(110deg, rgba(var(--sv-brand-rgb),.06), var(--kbm-surface) 44%, rgba(173,113,52,.04)); }
.kbm-memory-identity > span, .kbm-memory-copy > span { color: var(--kbm-cyan); letter-spacing: .14em; font: 700 9px/1 var(--sv-font-mono); }
.kbm-memory h2 { margin: 8px 0 6px; font-size: 18px; letter-spacing: -.025em; }
.kbm-memory p, .kbm-memory-copy small { margin: 0; color: var(--kbm-faint); font-size: 10px; line-height: 1.6; }
.kbm-memory-copy { display: grid; gap: 7px; padding-left: 23px; border-left: 1px solid var(--kbm-line); }
.kbm-memory-copy strong { font-size: 12px; font-weight: 560; line-height: 1.55; }
.kbm-button--memory { min-width: 138px; background: transparent; color: var(--kbm-cyan); }

.kbm-domain-section { margin-bottom: 14px; padding: 24px; border: 1px solid var(--kbm-line); border-radius: 8px; background: var(--kbm-surface); }
.kbm-section-head, .kbm-panel header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.kbm-section-head > div, .kbm-panel header > div { display: flex; align-items: baseline; gap: 12px; }
.kbm-section-head span, .kbm-panel header span { font: 700 10px/1 var(--sv-font-mono); }
.kbm-section-head h2, .kbm-panel h2 { margin: 0; font-size: 18px; letter-spacing: -.025em; }
.kbm-section-head small, .kbm-panel header small { color: var(--kbm-faint); letter-spacing: .11em; font: 700 9px/1 var(--sv-font-mono); }
.kbm-module-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 9px; margin-top: 22px; }
.kbm-module-card { position: relative; min-height: 148px; padding: 16px; overflow: hidden; border: 1px solid var(--kbm-line); border-radius: 6px; background: var(--sv-color-surface); color: inherit; text-decoration: none; transition: 180ms ease; }
.kbm-module-card::after { content: ""; position: absolute; right: -28px; bottom: -34px; width: 90px; height: 90px; border: 1px solid rgba(var(--sv-brand-rgb),.12); border-radius: 50%; }
.kbm-module-card:hover { border-color: rgba(var(--sv-brand-rgb),.46); transform: translateY(-2px); background: var(--sv-color-surface); }
.kbm-module-card > span { color: var(--kbm-cyan); letter-spacing: .13em; font: 700 8px/1 var(--sv-font-mono); }
.kbm-module-card strong, .kbm-module-card b, .kbm-module-card small { display: block; }
.kbm-module-card strong { margin-top: 11px; font-size: 13px; }
.kbm-module-card b { margin-top: 22px; font: 500 27px/1 var(--sv-font-mono); }
.kbm-module-card small { margin-top: 7px; overflow: hidden; color: var(--kbm-faint); text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }

.kbm-grid { display: grid; grid-template-columns: minmax(0,1.16fr) minmax(360px,.84fr); gap: 14px; }
.kbm-panel { min-height: 340px; padding: 24px; border: 1px solid var(--kbm-line); border-radius: 8px; background: var(--kbm-surface); }
.kbm-panel--unread { border-color: rgba(var(--sv-brand-rgb),.2); }
.kbm-panel--boundary { grid-column: 1/-1; min-height: 0; border-color: rgba(232,174,87,.2); }
.kbm-panel-note { margin: 12px 0 18px; color: var(--kbm-muted); font-size: 11px; line-height: 1.65; }
.kbm-activity-list, .kbm-doc-list { display: grid; margin-top: 20px; }
.kbm-activity, .kbm-doc { min-width: 0; display: grid; grid-template-columns: 76px minmax(0,1fr) auto; gap: 12px; align-items: center; min-height: 62px; padding: 10px 0; border-top: 1px solid var(--kbm-line); color: inherit; text-decoration: none; }
.kbm-activity > span { color: var(--module-color, var(--kbm-cyan)); letter-spacing: .1em; font: 700 8px/1 var(--sv-font-mono); }
.kbm-activity strong, .kbm-activity small, .kbm-doc strong, .kbm-doc small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kbm-activity strong, .kbm-doc strong { font-size: 11px; }
.kbm-activity small, .kbm-doc small { margin-top: 5px; color: var(--kbm-faint); font-size: 9px; }
.kbm-activity time, .kbm-doc time { color: var(--kbm-faint); font: 700 8px/1 var(--sv-font-mono); }
.kbm-doc { grid-template-columns: 34px minmax(0,1fr) auto; }
.kbm-doc-index { width: 29px; height: 29px; display: grid; place-items: center; border: 1px solid var(--kbm-line-strong); border-radius: 50%; color: var(--kbm-cyan); font: 700 8px/1 var(--sv-font-mono); }
.kbm-empty { margin: 28px 0 0; color: var(--kbm-faint); font-size: 12px; line-height: 1.8; }
.kbm-boundary-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 24px; }
.kbm-boundary-grid > div { padding: 16px; border: 1px solid var(--kbm-line); border-radius: 6px; background: var(--sv-color-surface); }
.kbm-boundary-grid b { font-size: 12px; }
.kbm-boundary-grid p { margin: 8px 0 0; color: var(--kbm-muted); font-size: 11px; line-height: 1.65; }
.kbm-toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; padding: 11px 14px; border: 1px solid var(--kbm-line-strong); border-radius: 5px; background: var(--kbm-text); color: white; opacity: 0; transform: translateY(8px); pointer-events: none; transition: 180ms ease; }
.kbm-toast.is-visible { opacity: 1; transform: none; }

@media (max-width: 1100px) {
  .kbm-observation { grid-template-columns: 1fr; }
  .kbm-domain-map { min-height: 350px; border-top: 1px solid var(--kbm-line); border-left: 0; }
  .kbm-module-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .kbm-memory { grid-template-columns: 1fr auto; }
  .kbm-memory-copy { grid-column: 1/-1; grid-row: 2; padding: 16px 0 0; border-top: 1px solid var(--kbm-line); border-left: 0; }
}

@media (max-width: 720px) {
  .kbm-shell { padding: 25px 17px 52px; }
  .kbm-topbar { align-items: flex-start; flex-direction: column; }
  .kbm-actions { width: 100%; }
  .kbm-actions > * { flex: 1; }
  .kbm-observation h2 { font-size: 34px; }
  .kbm-metrics { grid-template-columns: repeat(2,1fr); }
  .kbm-metrics article:nth-child(2) { border-right: 0; }
  .kbm-metrics article:nth-child(-n+2) { border-bottom: 1px solid var(--kbm-line); }
  .kbm-domain-node { min-width: 76px; }
  .kbm-module-grid, .kbm-grid, .kbm-boundary-grid { grid-template-columns: 1fr; }
  .kbm-panel--boundary { grid-column: auto; }
  .kbm-memory { grid-template-columns: 1fr; }
  .kbm-memory-copy { grid-column: auto; grid-row: auto; }
  .kbm-button--memory { justify-self: start; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
