:root {
  color-scheme: light;
  --surface: #ffffff; --surface-2: #f6f6f4; --surface-3: #ecece8; --line: #dcdcd6;
  --text: #191919; --text-2: #666666; --text-3: #8f8f8f;
  --prop: #257de0; --def: #f47230; --type: #00b894; --inst: #8d8d8d;
  --dep: #257de0; --dep-far: #b6d5f8; --user: #ec4647; --user-far: #f9c6c6; --sel: #f2a600;
  --dim: #e4e4e0; --link: #1757ac; --code-bg: #fafaf8; --body-bg: #f1f1ee;
  --kw: #6a4ce2; --com: #7a7a70; --str: #008a17; --num: #b3540e;
  --mono: "JuliaMono", "DejaVu Sans Mono", "Menlo", "Consolas", "Noto Sans Mono", "Noto Sans Math", "STIX Two Math", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface: #191919; --surface-2: #212121; --surface-3: #2b2b2b; --line: #3a3a3a;
    --text: #efefef; --text-2: #9c9c9c; --text-3: #707070;
    --prop: #338ced; --def: #e76624; --type: #00a888; --inst: #7d7d7d;
    --dep: #338ced; --dep-far: #0f3a6e; --user: #eb6263; --user-far: #6b2222; --sel: #f2a600;
    --dim: #2e2e2e; --link: #84b9f3; --code-bg: #1e1e1e; --body-bg: #262626;
    --kw: #9887ef; --com: #8a8a80; --str: #0aac23; --num: #e7a15f;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #191919; --surface-2: #212121; --surface-3: #2b2b2b; --line: #3a3a3a;
  --text: #efefef; --text-2: #9c9c9c; --text-3: #707070;
  --prop: #338ced; --def: #e76624; --type: #00a888; --inst: #7d7d7d;
  --dep: #338ced; --dep-far: #0f3a6e; --user: #eb6263; --user-far: #6b2222; --sel: #f2a600;
  --dim: #2e2e2e; --link: #84b9f3; --code-bg: #1e1e1e; --body-bg: #262626;
  --kw: #9887ef; --com: #8a8a80; --str: #0aac23; --num: #e7a15f;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--sans); color: var(--text); background: var(--surface); display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px; cursor: pointer; }
button:hover { background: var(--surface-3); }
#bar { display: flex; align-items: center; gap: 12px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex: none; }
#brand { white-space: nowrap; font-size: 15px; }
#edition { color: var(--text-2); font-size: 12px; margin-left: 6px; }
#edSel { font: 12px var(--sans); color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px; margin-left: 4px; }
#searchwrap { position: relative; flex: 1; max-width: 560px; }
#search { width: 100%; font: 13px var(--sans); padding: 5px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); }
#results { position: absolute; z-index: 30; top: calc(100% + 3px); left: 0; right: 0; max-height: 60vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.25); }
#results .r { padding: 4px 9px; cursor: pointer; display: flex; gap: 7px; align-items: baseline; }
#results .r.act, #results .r:hover { background: var(--surface-3); }
#results .r .nm { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
#results .r .wh { color: var(--text-2); font-size: 11px; margin-left: auto; white-space: nowrap; }
#tools { margin-left: auto; display: flex; gap: 6px; }
#main { flex: 1; display: flex; min-height: 0; }
#mapwrap { position: relative; flex: 1; min-width: 0; background: var(--surface); }
#map { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#map.drag { cursor: grabbing; }
#split { width: 5px; cursor: col-resize; background: var(--line); flex: none; }
#side { scrollbar-width: thin; scrollbar-color: var(--line) transparent; width: 40%; min-width: 280px; max-width: 75%; overflow: auto; background: var(--surface); flex: none; }
#insp { padding: 12px 14px 60px; }
#crumbs { position: absolute; left: 8px; top: 8px; font-size: 12px; background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; max-width: calc(100% - 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#crumbs a { color: var(--text); text-decoration: none; cursor: pointer; }
#crumbs a:hover { text-decoration: underline; }
#crumbs .s { color: var(--text-3); margin: 0 4px; }
#mapctl { position: absolute; right: 8px; top: 8px; display: flex; gap: 8px; align-items: center; font-size: 12px; background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; }
#mapctl label { display: flex; gap: 3px; align-items: center; cursor: pointer; color: var(--text-2); }
#mapctl button { padding: 0 8px; font-size: 15px; line-height: 20px; }
#mapctl .sep { width: 1px; height: 16px; background: var(--line); }
#legend { position: absolute; left: 8px; bottom: 8px; font-size: 11.5px; color: var(--text-2); background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; display: flex; gap: 10px; flex-wrap: wrap; max-width: calc(100% - 16px); }
#legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
#tip { position: absolute; z-index: 20; pointer-events: none; font-size: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; box-shadow: 0 4px 16px rgba(0,0,0,.2); max-width: 420px; }
#tip .nm { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
#tip .wh { color: var(--text-2); font-size: 11px; }
#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-2); background: var(--surface); }
#loading.err { color: var(--user); white-space: pre-wrap; padding: 20px; font-family: var(--mono); font-size: 12px; }

/* inspector */
.path { font-size: 12px; color: var(--text-2); margin-bottom: 6px; overflow-wrap: anywhere; }
.path a { color: var(--text-2); text-decoration: none; cursor: pointer; }
.path a:hover { color: var(--text); text-decoration: underline; }
.path .s { color: var(--text-3); margin: 0 3px; }
h1 { font: 600 15px/1.35 var(--mono); margin: 0 0 4px; overflow-wrap: anywhere; }
h1.t { font-family: var(--sans); font-size: 18px; }
h2 { font: 600 12px var(--sans); text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin: 18px 0 6px; display: flex; align-items: baseline; gap: 8px; }
h2 .n { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-3); }
h2 .act { margin-left: auto; font-weight: 400; text-transform: none; letter-spacing: 0; }
h2 .act a { color: var(--link); cursor: pointer; }
.badge { display: inline-block; font: 600 11px var(--sans); padding: 1px 7px; border-radius: 10px; color: #fff; vertical-align: 1px; margin-right: 6px; }
.k-prop { background: var(--prop); } .k-def { background: var(--def); } .k-type { background: var(--type); } .k-inst { background: var(--inst); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; flex: none; }
.meta { font-size: 12px; color: var(--text-2); margin: 2px 0 8px; }
.meta a { color: var(--link); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; margin: 8px 0; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; }
.stat b { display: block; font-size: 16px; font-weight: 600; }
.stat span { font-size: 11px; color: var(--text-2); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
pre.code { scrollbar-width: thin; scrollbar-color: var(--line) transparent; font: 12px/1.5 var(--mono); background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 0; margin: 6px 0; overflow-x: auto; white-space: pre; tab-size: 2; }
pre.code .ln { display: block; padding: 0 10px 0 0; min-height: 1.5em; }
pre.code .ln::before { content: attr(data-n); display: inline-block; width: 4.2ch; margin-right: 10px; text-align: right; color: var(--text-3); user-select: none; }
pre.code .ln.body { background: var(--body-bg); }
pre.code .ln.out { opacity: .55; }
pre.code .ln.hl { box-shadow: inset 3px 0 0 var(--sel); }
pre.code.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
pre.code.wrap .ln { padding-left: calc(4.2ch + 10px); text-indent: calc(-4.2ch - 10px); }
.c-kw { color: var(--kw); font-weight: 600; } .c-com { color: var(--com); font-style: italic; } .c-str { color: var(--str); } .c-num { color: var(--num); }
.c-name { font-weight: 700; }
pre.code a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--text-3); cursor: pointer; }
pre.code a.p { border-bottom: 1px solid var(--link); color: var(--link); }
pre.code a:hover { background: color-mix(in srgb, var(--sel) 30%, transparent); }
.list { margin: 0; padding: 0; list-style: none; }
.row { display: flex; align-items: baseline; gap: 6px; padding: 2px 4px; border-radius: 5px; cursor: pointer; font-size: 12.5px; }
.row:hover { background: var(--surface-3); }
.row .tw { width: 12px; flex: none; color: var(--text-3); font-size: 10px; text-align: center; user-select: none; }
.row .nm { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.row .wh { color: var(--text-3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.row .tag { font-size: 10px; color: var(--text-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; white-space: nowrap; }
.row .num { margin-left: auto; color: var(--text-2); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .bar { width: 46px; height: 5px; background: var(--surface-3); border-radius: 3px; flex: none; align-self: center; overflow: hidden; }
.row .bar i { display: block; height: 100%; background: var(--text-3); }
.kids { margin-left: 14px; border-left: 1px solid var(--line); padding-left: 2px; }
.more { color: var(--link); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.hint { color: var(--text-2); font-size: 12.5px; }
.hint kbd { font: 11px var(--mono); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; background: var(--surface-2); }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; margin: 6px 0; cursor: pointer; background: var(--surface-2); }
.card:hover { border-color: var(--text-3); }
.card .nm { font: 600 12.5px var(--mono); overflow-wrap: anywhere; }
.card pre { font: 11.5px/1.45 var(--mono); margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); }
details > summary { cursor: pointer; color: var(--text-2); font-size: 12px; margin: 6px 0; }
.note { font-size: 12px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin: 8px 0; }

@media (max-width: 820px) {
  #main { flex-direction: column; }
  #mapwrap { flex: none; height: 46vh; }
  #split { width: auto; height: 5px; cursor: row-resize; }
  #side { width: auto !important; max-width: none; flex: 1; }
  #brand { font-size: 13px; } #btnHome { display: none; } #edition { display: none; } #bar { gap: 6px 8px; flex-wrap: wrap; }
  #searchwrap { order: 5; flex: 1 0 100%; max-width: none; } #tools { margin-left: 0; } #views { margin-left: auto; }
  #legend span:last-child { display: none; }
  #brand .long { display: none; }
  #legend { font-size: 10.5px; gap: 6px; padding: 2px 6px; }
  #mapctl label { display: none; } #mapctl .sep { display: none; }
}

#peek { position: fixed; z-index: 40; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; box-shadow: 0 10px 34px rgba(0,0,0,.3); }
#peek .nm { font: 600 13px var(--mono); overflow-wrap: anywhere; }
#peek .wh { color: var(--text-2); font-size: 11.5px; margin: 2px 0 4px; }
#peek pre.code { margin: 4px 0 0; }

#views { display: flex; }
#views button { border-radius: 0; margin-left: -1px; padding: 3px 12px; }
#views button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
#views button:last-child { border-radius: 0 6px 6px 0; }
#views button.on { background: var(--text); color: var(--surface); border-color: var(--text); }
#views button:disabled { opacity: .4; cursor: default; }
body[data-view="graph"] #optEdgesL { display: none; }
#legend span { white-space: normal; }

#draft { font: 600 10.5px var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); border: 1px solid var(--text-3); border-radius: 4px; padding: 0 5px; vertical-align: 1px; }
