/* Layout: full-bleed 3D map under a solid top bar; floating cards for legend, camera, minimap; side drawers for detail. */
:root {
  --ground: #f6f6f3;
  --map: #fbfbf9;
  --surface: #ffffff;
  --surface-2: #f1f1ec;
  --line: #e3e3de;
  --line-2: #cfcfc8;
  --ink: #16181d;
  --ink-2: #3f444c;
  --muted: #5b616b;
  --link: #1d4ed8;
  --sel: #facc15;
  --sel-ink: #78350f;
  --warn: #b45309;
  --err: #b91c1c;
  --person: #2563eb;
  --org: #5b21b6;
  --agent: #d9580d;
  --radius: 12px;
  --display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, sans-serif;
  font-family: var(--body);
  color: var(--ink);
  background: var(--ground);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ground); color: var(--ink); }
button, input, select { font: inherit; color: inherit; }
a { color: var(--link); }
a:hover { color: #1e3a8a; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
h2 { font-family: var(--display); font-weight: 600; margin: 0; font-size: 16px; }

#app { display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.brand .title { font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand .sub { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; }
.sample { background: #fef3c7; color: var(--sel-ink); border: 1px solid #f59e0b; border-radius: 6px; padding: 1px 6px; font-weight: 600; font-size: 11px; }
.search { position: relative; flex: 1 1 300px; max-width: 580px; }
.search .icon { position: absolute; left: 13px; top: 13px; color: var(--muted); }
.search input { width: 100%; height: 44px; padding: 0 40px 0 42px; border-radius: 10px; border: 1.5px solid var(--line-2); background: var(--surface); font-size: 15px; }
.search input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, .22); }
.search kbd { position: absolute; right: 10px; top: 11px; font-size: 12px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 7px; background: var(--ground); }
.results { position: absolute; left: 0; right: 0; top: 52px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 12px 32px rgba(22, 24, 29, .14); padding: 6px; max-height: 62vh; overflow: auto; }
.results .group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px 4px; font-weight: 600; }
.result { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 8px 10px; min-height: 48px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 14px; }
.result[aria-selected="true"], .result:hover { background: var(--surface-2); }
.result .meta { display: block; font-size: 12px; color: var(--muted); }
.result mark { background: #fde68a; color: inherit; border-radius: 2px; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.btn { height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 14px; color: var(--ink); }
.btn:hover { background: var(--surface-2); }
.btn[aria-expanded="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.ghost { border-style: dashed; }
.btn.file input { display: none; }
.badge { display: inline-flex; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--sel); color: #1c1600; font-size: 11px; font-weight: 700; align-items: center; justify-content: center; }
.badge.warn { background: #fde68a; color: var(--sel-ink); }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; color: var(--ink); }
.icon-btn:hover { background: var(--surface-2); }
.link { background: none; border: 0; color: var(--link); cursor: pointer; padding: 6px; font-weight: 600; font-size: 13px; }

#stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--map); }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#map:focus-visible { outline: 3px solid var(--link); outline-offset: -3px; }
.labels { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; text-align: left; background: rgba(255, 255, 255, .94); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px 2px 7px; color: var(--ink); font-size: 13px; font-weight: 500; line-height: 1.4; max-width: 230px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 1px 2px rgba(22, 24, 29, .08); border-left: 3px solid var(--person); }
.lbl.t-organization { border-left-color: var(--org); }
.lbl.t-agent { border-left-color: var(--agent); }
.lbl .n { display: block; overflow: hidden; text-overflow: ellipsis; }
.lbl .h { display: block; font-size: 11.5px; color: var(--muted); }
.lbl.sel { background: var(--ink); color: #fff; font-weight: 700; font-size: 14px; border-color: var(--ink); }
.lbl.sel .h { color: #d4d7dc; }
.lbl.focus { font-weight: 600; }
.lbl.match { box-shadow: 0 0 0 2px var(--sel); }
.tooltip { position: absolute; left: 0; top: 0; pointer-events: none; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; font-size: 13px; max-width: 260px; z-index: 5; box-shadow: 0 6px 18px rgba(22, 24, 29, .12); }
.tooltip b { display: block; }
.tooltip span { color: var(--muted); font-size: 12px; }

.card { background: rgba(255, 255, 255, .96); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(22, 24, 29, .06); }
.legend { position: absolute; left: 14px; bottom: 14px; width: 290px; padding: 12px 14px; z-index: 6; }
.legend-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.legend ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.legend-nodes { flex-direction: row !important; flex-wrap: wrap; gap: 6px 14px !important; padding-bottom: 8px !important; border-bottom: 1px solid var(--line) !important; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend-edges { padding-top: 8px !important; font-size: 12.5px !important; color: var(--ink-2); }
.legend .note { margin: 8px 0 0; line-height: 1.4; }
.legend.collapsed .legend-edges, .legend.collapsed .note { display: none; }
.legend.collapsed .legend-nodes { border-bottom: 0 !important; padding-bottom: 0 !important; }

.nav { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px; z-index: 6; }
.nav input[type="range"] { writing-mode: vertical-lr; direction: rtl; width: 28px; height: 170px; accent-color: var(--ink); cursor: pointer; }
.depth-read { font-size: 11px; color: var(--muted); width: 58px; text-align: center; font-weight: 600; }
.minimap { position: absolute; right: 14px; bottom: 14px; margin: 0; padding: 8px; z-index: 6; }
.minimap canvas { display: block; border-radius: 8px; background: var(--surface-2); cursor: crosshair; }
.minimap figcaption { margin-top: 4px; text-align: center; }

.hint { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); background: rgba(255, 255, 255, .94); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 12px; color: var(--ink-2); white-space: nowrap; z-index: 4; max-width: calc(100% - 680px); overflow: hidden; text-overflow: ellipsis; }
.filter-bar { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px; padding: 4px 6px 4px 14px; font-size: 13px; z-index: 7; box-shadow: 0 4px 16px rgba(22, 24, 29, .08); }
.toast { position: absolute; left: 50%; top: 60px; transform: translateX(-50%); background: var(--ink); color: #fff; font-weight: 600; padding: 8px 14px; border-radius: 10px; font-size: 13px; z-index: 20; }

.drawer { position: absolute; top: 0; bottom: 0; width: 360px; max-width: 100%; background: var(--surface); border: 0 solid var(--line); overflow: auto; z-index: 10; padding: 16px; box-shadow: 0 0 24px rgba(22, 24, 29, .08); }
.drawer.left { left: 0; border-right-width: 1px; }
.drawer.right { right: 0; border-left-width: 1px; width: 420px; padding: 0; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
fieldset { border: 0; padding: 0; margin: 14px 0 0; }
legend { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; padding: 0; }
.row { display: flex; align-items: center; gap: 10px; min-height: 36px; font-size: 14px; cursor: pointer; }
.row input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.row .count { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.list-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.list-tools select { background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; height: 34px; padding: 0 8px; }
.list-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.list-items button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; min-height: 52px; padding: 8px 10px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 14px; }
.list-items button:hover { background: var(--surface-2); }
.list-items button[aria-current="true"] { border: 2px solid var(--ink); }
.list-items .dim { opacity: .7; }
.list-items .sub { display: block; font-size: 12px; color: var(--muted); }
.list-items .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 4px; font-weight: 600; list-style: none; }

.shape { display: inline-block; flex: 0 0 auto; width: 12px; height: 12px; }
.shape.person { border-radius: 50%; background: var(--person); }
.shape.organization { border-radius: 2px; background: var(--org); }
.shape.agent { width: 10px; height: 10px; margin: 0 1px; background: var(--agent); transform: rotate(45deg); }
.edge-swatch { display: inline-block; width: 30px; flex: 0 0 auto; }

.d-head { padding: 16px 18px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.d-top { display: flex; justify-content: space-between; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 12px; font-weight: 600; }
.d-name { font-family: var(--display); font-size: 27px; font-weight: 700; margin: 0; line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance; }
.handle-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.handle { font-size: 15px; font-weight: 600; color: var(--ink); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); text-decoration: none; height: 36px; font-size: 13px; }
.btn.primary:hover { background: #2b2e35; color: #fff; }
.btn.sm { height: 34px; font-size: 13px; text-decoration: none; }
.d-body { padding: 14px 18px 24px; display: flex; flex-direction: column; gap: 18px; }
.d-sec h3 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.d-sec p { margin: 0; font-size: 15px; line-height: 1.55; }
.notes { background: var(--surface-2); border: 1px dashed var(--line-2); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-height: 32px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-size: 12.5px; }
.chips button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.src-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.src-list .m { display: block; color: var(--muted); font-size: 12px; }
.src-list .missing { color: var(--warn); }
.conf { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.conf .bars { display: inline-flex; gap: 2px; align-items: flex-end; }
.conf .bars i { display: block; width: 3px; background: var(--line-2); }
.conf .bars i.on { background: var(--ink-2); }
.conn-group { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.conn-group .gh { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.conn { display: flex; align-items: center; gap: 8px; }
.conn .main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; min-height: 48px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.conn .main:hover { background: var(--surface-2); }
.conn .main .t { flex: 1; min-width: 0; }
.conn .main b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn .main .s { display: block; font-size: 12px; color: var(--muted); }
.callout { border-radius: 10px; padding: 12px 14px; font-size: 14px; line-height: 1.5; border: 1px solid var(--line-2); background: var(--surface-2); }
.callout.engage { border-color: #67b7c9; background: #ecf8fb; }
.offmap { background: #fef3c7; border: 1px solid #f59e0b; color: var(--sel-ink); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.pair-ends { display: flex; flex-direction: column; gap: 6px; }

dialog { background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); border-radius: 14px; width: min(760px, 94vw); max-height: 86vh; padding: 0; }
dialog::backdrop { background: rgba(22, 24, 29, .35); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
#reportBody, #loadBody { padding: 14px 18px 20px; font-size: 14px; line-height: 1.5; }
#reportBody h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 6px; }
#reportBody ul { margin: 0; padding-left: 18px; }
#reportBody .lvl-error { color: var(--err); font-weight: 600; }
#reportBody .lvl-warning { color: var(--warn); font-weight: 600; }
#reportBody .lvl-info { color: var(--link); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stats div { background: var(--surface-2); border-radius: 8px; padding: 10px; }
.stats b { display: block; font-size: 24px; font-family: var(--display); font-variant-numeric: tabular-nums; }
.choice { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 18px 18px; }

@media (max-width: 1150px) {
  .hint { display: none; }
  .tools .ghost { display: none; }
}
@media (max-width: 760px) {
  .topbar { padding-block: 8px; gap: 8px; }
  .brand { min-width: 0; }
  .brand .sub { display: none; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .search kbd { display: none; }
  .tools { margin-left: auto; }
  .minimap { display: none; }
  .legend { left: 8px; right: 8px; bottom: 8px; width: auto; }
  .nav { right: 8px; top: 12px; transform: none; }
  .nav input[type="range"] { height: 110px; }
  .drawer, .drawer.right { width: 100%; }
  .drawer.right { top: auto; height: 62%; border-top: 1px solid var(--line-2); border-left: 0; border-radius: 16px 16px 0 0; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Keep camera controls, minimap and legend clear of open drawers. */
@media (min-width: 761px) {
  /* The map shrinks beside the details panel so the selection stays centred and visible. */
  #stage:has(#details:not([hidden])) #map,
  #stage:has(#details:not([hidden])) .labels { width: calc(100% - 420px); right: auto; }
  #stage:has(#details:not([hidden])) .nav,
  #stage:has(#details:not([hidden])) .minimap { right: 434px; }
  #stage:has(#details:not([hidden])) .hint { left: calc(50% - 210px); }
  #stage:has(#filters:not([hidden])) .legend,
  #stage:has(#list:not([hidden])) .legend { left: 374px; }
  #stage:has(#details:not([hidden])) .filter-bar { left: calc(50% - 210px); }
}

/* Power view: just the map. */
body.power .topbar,
body.power .legend,
body.power .nav,
body.power .minimap,
body.power .hint,
body.power .filter-bar,
body.power #filters,
body.power #list { display: none !important; }
.power-exit { position: absolute; top: max(12px, env(safe-area-inset-top, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); z-index: 12; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, .94); color: var(--ink); font: 600 13px var(--body); cursor: pointer; box-shadow: 0 4px 16px rgba(22, 24, 29, .1); opacity: .75; }
.power-exit:hover, .power-exit:focus-visible { opacity: 1; }
body.power #stage:has(#details:not([hidden])) .power-exit { right: 434px; }

/* ===================== Linear pass =====================
   Restraint: neutral surfaces, one indigo accent, Inter, hairlines, minimal chrome. */
:root {
  --ground: #fbfbfb;
  --map: #fcfcfd;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --line: #e8e8eb;
  --line-2: #dcdce0;
  --ink: #1b1c1f;
  --ink-2: #3c3f44;
  --muted: #6b6f76;
  --link: #5e6ad2;
  --accent: #5e6ad2;
  --accent-soft: #eef0fc;
  --sel: #5e6ad2;
  --person: #3b82f6;
  --org: #8b5cf6;
  --agent: #f97316;
  --radius: 10px;
  --display: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h2 { letter-spacing: -0.01em; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--surface); color: var(--muted); font: 500 11px var(--body); }

/* Top bar */
.topbar { padding-block: 8px; gap: 12px; border-bottom-color: var(--line); }
.brand { min-width: 0; gap: 9px; }
.brand svg { width: 22px; height: 22px; }
.brand .title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.brand .sub { font-size: 12px; }
.search-trigger { flex: 1 1 280px; max-width: 460px; height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font: 400 13px var(--body); cursor: pointer; text-align: left; }
.search-trigger:hover { border-color: var(--line-2); background: #efeff1; }
.search-trigger span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn { height: 32px; padding: 0 10px; border-radius: 7px; font-size: 13px; font-weight: 500; border-color: var(--line); }
.btn:hover { background: var(--surface-2); }
.btn[aria-expanded="true"], .btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: #d5d9f6; }
.btn.ghost { border-style: solid; color: var(--muted); }
.badge { background: var(--accent); color: #fff; }
.badge.warn { background: #fdecc8; color: #8a5300; }
.sample { background: #fef7e0; color: #8a5300; border-color: #f3dfa3; font-weight: 500; }
.icon-btn { width: 32px; height: 32px; border-radius: 7px; border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.xs { width: 22px; height: 22px; border-radius: 5px; }

/* Map labels: plain text with a halo, no boxes */
.lbl { background: none; border: 0; box-shadow: none; padding: 0 2px; font: 500 12px/1.3 var(--body); color: var(--ink); letter-spacing: -0.005em; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff, 0 0 1px #fff; }
.lbl .h { font-size: 11px; color: var(--muted); }
.lbl.sel { background: none; color: var(--accent); font-weight: 600; font-size: 12.5px; }
.lbl.sel .h { color: var(--muted); }
.lbl.focus { font-weight: 500; }
.lbl.match { box-shadow: none; color: var(--accent); }
.tooltip { border-radius: 8px; border-color: var(--line); font-size: 12px; padding: 6px 9px; box-shadow: 0 4px 14px rgba(0, 0, 0, .08); }

/* Cards, legend popover, controls */
.card { background: rgba(255, 255, 255, .96); border-color: var(--line); box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px rgba(0, 0, 0, .05); }
.legend-btn { position: absolute; left: 14px; bottom: 14px; z-index: 6; display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px 0 11px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, .96); color: var(--ink-2); font: 500 12px var(--body); cursor: pointer; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.legend-btn:hover, .legend-btn[aria-expanded="true"] { color: var(--ink); border-color: var(--line-2); }
.legend { bottom: 52px; width: 300px; padding: 12px 14px; }
.legend-head h2 { font-size: 13px; }
.legend ul { font-size: 12.5px; }
.legend-edges { font-size: 12px !important; }
.nav-pill { position: absolute; right: 14px; bottom: 14px; z-index: 6; display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px; }
.pill-btn { width: 30px; height: 30px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.pill-btn:hover { background: var(--surface-2); color: var(--ink); }
.pill-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.pill-sep { width: 1px; height: 16px; background: var(--line); margin: 0 3px; }
.minimap { bottom: 58px; padding: 6px; }
.minimap canvas { background: var(--surface-2); }
.hint { bottom: 18px; font-size: 11.5px; color: var(--muted); border-color: var(--line); padding: 5px 12px; }
.hint kbd { margin: 0 1px; }
.filter-bar { border-color: var(--line); font-size: 12.5px; }
.toast { background: var(--ink); font-weight: 500; font-size: 12.5px; border-radius: 8px; }
@media (min-width: 761px) {
  #stage:has(#details:not([hidden])) .nav-pill,
  #stage:has(#details:not([hidden])) .minimap { right: 434px; }
  #stage:has(#filters:not([hidden])) .legend-btn,
  #stage:has(#list:not([hidden])) .legend-btn { left: 374px; }
}
body.power .legend-btn, body.power .nav-pill { display: none !important; }

/* Command menu */
.palette-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(15, 16, 20, .18); display: flex; justify-content: center; align-items: flex-start; padding: 12vh max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); }
.palette { width: min(640px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 24px 64px rgba(15, 16, 20, .18), 0 2px 6px rgba(15, 16, 20, .06); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 52px; border-bottom: 1px solid var(--line); color: var(--muted); }
.palette-input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; font: 400 15px var(--body); color: var(--ink); }
.palette-list { overflow: auto; padding: 6px; }
.p-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 500; color: var(--muted); }
.p-item { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px; border-radius: 7px; cursor: pointer; font-size: 13.5px; color: var(--ink); }
.p-item[aria-selected="true"] { background: var(--surface-2); }
.p-label { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-meta { flex: 1; min-width: 0; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-meta mark { background: var(--accent-soft); color: var(--accent); border-radius: 2px; }
.p-type { color: var(--muted); font-size: 12px; margin-left: auto; }
.p-cmd-icon { width: 12px; color: var(--muted); text-align: center; }
.p-item kbd { margin-left: auto; }
.p-empty { padding: 18px 12px; color: var(--muted); font-size: 13px; }
.palette-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; }
.palette-foot span { display: inline-flex; align-items: center; gap: 4px; }

/* Details panel: issue-sidebar style */
.drawer.right { width: 400px; }
.d-head { padding: 14px 18px 12px; gap: 8px; border-bottom-color: var(--line); }
.d-top { min-height: 28px; }
.crumb { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; color: var(--muted); }
.crumb .sep { color: var(--line-2); }
.d-actions { display: inline-flex; gap: 2px; }
.d-name { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
.d-name.sm { font-size: 16px; }
.d-name .verb { color: var(--muted); font-weight: 500; }
.d-summary { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }
.d-body { padding: 12px 18px 28px; gap: 20px; }
.props { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 2px 12px; margin: 0; font-size: 13px; }
.props dt { color: var(--muted); padding: 6px 0; }
.props dd { margin: 0; padding: 4px 0; min-height: 28px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--ink); min-width: 0; }
.props dd a { display: inline-flex; align-items: center; gap: 4px; color: var(--ink); text-decoration: none; font-weight: 500; }
.props dd a:hover { color: var(--accent); }
.props .sep { color: var(--line-2); }
.props .handle { font-size: 13px; font-weight: 500; }
.p-note { color: var(--muted); font-size: 12px; flex-basis: 100%; }
.warn-text { color: #8a5300; }
.d-sec h3 { font-size: 11.5px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); margin-bottom: 8px; }
.notes { border-style: solid; border-color: var(--line); background: var(--surface-2); font-size: 13px; }
.chips button { min-height: 24px; padding: 0 8px; border-radius: 6px; border-color: var(--line); font-size: 12px; }
.chips button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: #d5d9f6; }
.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.plain a { display: inline-flex; gap: 4px; align-items: center; color: var(--ink); font-weight: 500; text-decoration: none; }
.plain .m { display: block; color: var(--muted); font-size: 12px; }
.conn-group { margin-top: 4px; gap: 2px; }
.conn-group .gh { font-size: 12px; font-weight: 500; color: var(--ink-2); padding: 6px 0 2px; }
.conn-group .gh .count { color: var(--muted); font-weight: 400; }
.conn.dim { opacity: .5; }
.conn .main { min-height: 40px; border-color: transparent; padding: 4px 8px; border-radius: 7px; }
.conn .main:hover, .conn .main:focus-visible { background: var(--surface-2); }
.conn .main b { font-size: 13px; font-weight: 500; }
.conn .main .s { font-size: 12px; }
.conf { font-size: 12px; color: var(--muted); }
.kbd-tip { margin: 8px 0 0; font-size: 11.5px; color: var(--muted); display: flex; gap: 4px; align-items: center; }
.callout { border-radius: 8px; border-color: var(--line); background: var(--surface-2); font-size: 13px; padding: 10px 12px; }
.callout.engage { border-color: #d5d9f6; background: var(--accent-soft); }
.link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; color: var(--ink); font: 500 13px var(--body); cursor: pointer; }
.crumb .link-btn { color: var(--muted); font-size: 12px; }
.link-btn:hover { color: var(--accent); }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 14px 18px; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.timeline li::before { content: ""; position: absolute; left: 3px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--line-2); }
.timeline li::after { content: ""; position: absolute; left: 6.5px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline a { color: var(--ink); text-decoration: none; font-weight: 500; }
.timeline a:hover { color: var(--accent); }
.t-date { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.t-meta { font-size: 12px; color: var(--muted); }
.timeline .missing { color: #8a5300; }

/* Drawers & lists */
.drawer { box-shadow: 0 0 0 1px var(--line), 0 8px 30px rgba(0, 0, 0, .06); }
.row { font-size: 13px; min-height: 32px; }
.row input { accent-color: var(--accent); }
.list-items button { min-height: 44px; font-size: 13px; border-radius: 7px; }
.list-items button[aria-current="true"] { border: 1px solid #d5d9f6; background: var(--accent-soft); }
.shape.person { background: var(--person); }
.shape.organization { background: var(--org); }
.shape.agent { background: var(--agent); }
@media (max-width: 760px) {
  .search-trigger { order: 3; flex-basis: 100%; max-width: none; }
  .legend { left: 8px; right: 8px; bottom: 48px; width: auto; }
  .legend-btn { left: 8px; bottom: 8px; }
  .nav-pill { right: 8px; bottom: 8px; top: auto; transform: none; }
  .palette-backdrop { padding-top: 8vh; }
}
