:root {
  --paper: #ffffff;
  --ink: #111111;
  --ink-2: #555555;
  --ink-3: #767676;
  --rule: #111111;
  --rule-soft: #e2e2e2;
  --wash: #f4f4f2;
  --blue: #1f3fd9;
  --hue: #c2410c;
  --sans: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --side: 380px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--blue); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; margin: 0; }
button { font: inherit; }

.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }

/* ---------- side column ---------- */
.side { border-right: 1px solid var(--rule-soft); }
.side-inner { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding: 24px 20px 40px; }
.title { font-size: 28px; line-height: 1.12; margin-bottom: 12px; }
.lede { margin: 0 0 18px; }
.hint { font-size: 12.5px; color: var(--ink-3); margin: 4px 0 0; min-height: 1em; }

.search { position: relative; margin-bottom: 14px; }
.search label, .ctl label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 4px; }
input[type=search], select {
  width: 100%; font: inherit; font-size: 15px; padding: 7px 9px; border: 1px solid var(--ink);
  border-radius: 0; background: var(--paper); color: var(--ink);
}
.results {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20; margin: 0; padding: 0; list-style: none;
  background: var(--paper); border: 1px solid var(--ink); border-top: 0; max-height: 360px; overflow-y: auto;
}
.results li { padding: 6px 9px; cursor: pointer; font-size: 14px; line-height: 1.3; }
.results li small { display: block; color: var(--ink-3); font-size: 12px; }
.results li[aria-selected="true"], .results li:hover { background: var(--wash); }

.toc { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; padding: 10px 0 12px; border-top: 2px solid var(--rule); border-bottom: 1px solid var(--rule-soft); margin-bottom: 14px; }

/* profile */
.profile h2 { font-size: 20px; line-height: 1.2; margin: 4px 0 4px; }
.profile .path { font-size: 12.5px; color: var(--ink-2); margin: 0 0 6px; }
.profile .path button { all: unset; cursor: pointer; color: var(--blue); }
.profile .path button:hover { text-decoration: underline; }
.profile h3 { font-size: 13px; margin: 16px 0 6px; padding-top: 8px; border-top: 1px solid var(--rule); }
.profile p { margin: 0 0 8px; font-size: 13.5px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 8px 0; font-size: 13.5px; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.btn { border: 1px solid var(--ink); background: var(--paper); padding: 4px 10px; cursor: pointer; font-size: 13px; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.bars { width: 100%; display: block; }
.bars text { font: 11.5px var(--sans); fill: var(--ink-2); }
.bars .v { fill: var(--ink); font-variant-numeric: tabular-nums; }
.taglist { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 12.5px; }
.taglist li { border: 1px solid var(--rule-soft); padding: 1px 6px; }
.taglist li.hot { border-color: var(--hue); }
.taglist li.hot::before { content: "\25CF"; color: var(--hue); margin-right: 4px; font-size: 9px; vertical-align: 1px; }
.small { font-size: 12.5px; color: var(--ink-2); }
.kids { margin: 0; padding-left: 18px; font-size: 13px; }
.kids li { margin-bottom: 3px; }
.more { all: unset; cursor: pointer; color: var(--blue); font-size: 12.5px; }

/* ---------- main ---------- */
.main { min-width: 0; padding: 24px 28px 60px; }
.sec { margin-bottom: 56px; }
.sec-head { border-top: 2px solid var(--rule); padding-top: 10px; margin-bottom: 10px; }
.sec-head h2 { font-size: 22px; line-height: 1.2; }
.sec-head p { margin: 4px 0 0; color: var(--ink-2); max-width: 70ch; }
h3.sub { font-size: 16px; margin: 26px 0 6px; }
.note { font-size: 12.5px; color: var(--ink-2); margin: 6px 0 0; max-width: 80ch; }
.ctl { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 14px; margin: 8px 0 10px; }
.ctl label { margin: 0 0 4px; }
.ctl select { width: auto; max-width: 100%; }
.ctl input[type=search] { max-width: 360px; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--ink); }
.seg button { border: 0; border-right: 1px solid var(--ink); background: var(--paper); padding: 5px 10px; cursor: pointer; font-size: 13px; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.crumbs { font-size: 13px; flex: 1 1 100%; }
.crumbs button { all: unset; cursor: pointer; color: var(--blue); }
.crumbs button:hover { text-decoration: underline; }
.crumbs span.sep { color: var(--ink-3); margin: 0 5px; }
.crumbs b { font-weight: 700; }

.tree-wrap { position: relative; }
#tree { display: block; width: 100%; height: min(72vh, 640px); background: var(--wash); }
#tree text { font: 11.5px var(--sans); pointer-events: none; }
#tree .cell { cursor: pointer; }
#tree .cell rect { stroke: #fff; stroke-width: 1; }
#tree .grp > rect { fill: none; stroke: #fff; stroke-width: 3; pointer-events: none; }
#tree .cell:hover rect { stroke: var(--ink); stroke-width: 2; }
#tree .cell.sel rect { stroke: var(--blue); stroke-width: 3; }

.tip {
  position: absolute; z-index: 10; pointer-events: none; background: var(--paper); border: 1px solid var(--ink);
  padding: 6px 8px; font-size: 12.5px; line-height: 1.35; max-width: 280px;
}
.tip b { display: block; font-size: 13px; }

.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.legend svg { display: block; }
.legend .sw { display: inline-block; width: 12px; height: 12px; vertical-align: -2px; margin-right: 4px; border: 1px solid rgba(0,0,0,.15); }

.map-grid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; }
.map-wrap { position: relative; }
#map { display: block; width: 100%; height: auto; }
.state { stroke: #fff; stroke-width: 0.8; cursor: pointer; }
.state:hover { stroke: var(--ink); stroke-width: 1.6; }
.rank h3 { font-size: 13px; margin-bottom: 6px; }
.rank ol { margin: 0; padding: 0; list-style: none; font-size: 13px; counter-reset: r; }
.rank li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 6px; padding: 3px 0; border-bottom: 1px solid var(--rule-soft); counter-increment: r; }
.rank li::before { content: counter(r); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rank li span:last-child { font-variant-numeric: tabular-nums; text-align: right; }
.rank li.np { color: var(--ink-3); }

.multi { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 12px; }
.mm { cursor: pointer; }
.mm h4 { font-size: 12px; font-weight: 700; margin: 0 0 2px; line-height: 1.25; min-height: 2.5em; }
.mm svg, .mm canvas { display: block; width: 100%; height: auto; }
.mm:hover h4 { color: var(--blue); }
.mm.sel h4 { color: var(--blue); }
.profiles { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.pf { border-top: 1px solid var(--rule); padding-top: 6px; cursor: pointer; }
.pf h4 { font-size: 12.5px; margin: 0 0 4px; line-height: 1.25; min-height: 2.5em; }
.pf svg { display: block; width: 100%; height: auto; }
.pf svg text { font: 9.5px var(--sans); fill: var(--ink-2); }

.fp { overflow-x: auto; }
.fp table { border-collapse: collapse; font-size: 11.5px; }
.fp th { font-weight: 400; text-align: left; padding: 1px 8px 1px 0; white-space: nowrap; color: var(--ink-2); }
.fp thead th { vertical-align: bottom; font-weight: 700; color: var(--ink); white-space: normal; min-width: 64px; max-width: 120px; padding: 0 4px 6px 0; line-height: 1.2; }
.fp td { width: 64px; height: 15px; padding: 0; border: 1px solid #fff; text-align: center; font-variant-numeric: tabular-nums; }
.fp tr.grp th { font-weight: 700; color: var(--ink); padding-top: 10px; }
.fp .x { all: unset; cursor: pointer; color: var(--ink-3); margin-left: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0 12px; }
.chip { border: 1px solid var(--rule-soft); background: var(--paper); padding: 2px 8px; font-size: 12.5px; cursor: pointer; }
.chip.hot { border-color: var(--hue); }
.chip:hover { border-color: var(--ink); }
.tech-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.occlist { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.occlist li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--rule-soft); }
.occlist li button { all: unset; cursor: pointer; color: var(--blue); }
.occlist li span { font-variant-numeric: tabular-nums; color: var(--ink-2); }

.dwa { font-size: 13.5px; }
.dwa details { border-bottom: 1px solid var(--rule-soft); }
.dwa details details { margin-left: 16px; border-bottom: 0; }
.dwa summary { cursor: pointer; padding: 4px 0; list-style-position: outside; }
.dwa summary .n { color: var(--ink-3); font-size: 12px; margin-left: 6px; font-variant-numeric: tabular-nums; }
.dwa .leaf { margin: 0 0 0 32px; padding: 0; list-style: none; }
.dwa .leaf li { padding: 2px 0; }
.dwa .leaf button { all: unset; cursor: pointer; }
.dwa .leaf button:hover { color: var(--blue); }
.dwa .occs { margin: 2px 0 8px 12px; font-size: 12.5px; color: var(--ink-2); }
.dwa .occs button { all: unset; cursor: pointer; color: var(--blue); }

/* embedding map */
.load { border: 1px solid var(--ink); background: var(--paper); padding: 8px 14px; cursor: pointer; }
.emb-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; }
.emb-wrap { position: relative; background: var(--wash); touch-action: none; }
#emb { display: block; width: 100%; height: min(70vh, 620px); cursor: grab; }
#emb.drag { cursor: grabbing; }
.emb-zoom { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; }
.emb-zoom button { width: 30px; height: 30px; border: 1px solid var(--ink); background: var(--paper); cursor: pointer; font-size: 16px; line-height: 1; }
.emb-side { font-size: 13px; }
.emb-side h3 { font-size: 13px; margin: 12px 0 4px; }
.emb-side ol { margin: 0; padding-left: 18px; }
.emb-side li { margin-bottom: 2px; }
.emb-side li button { all: unset; cursor: pointer; }
.emb-side li button:hover { color: var(--blue); }
.kinds { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12.5px; }
.kinds label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.facets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.facet { cursor: pointer; }
.facet h4 { font-size: 11.5px; margin: 0 0 2px; line-height: 1.25; min-height: 2.5em; }
.facet canvas { display: block; width: 100%; height: auto; background: var(--wash); }
.agree svg { display: block; width: 100%; height: auto; }
.agree svg text { font: 11px var(--sans); fill: var(--ink-2); }

.sources h2 { font-size: 22px; border-top: 2px solid var(--rule); padding-top: 10px; margin-bottom: 8px; }
.sources h3 { font-size: 15px; margin: 18px 0 6px; }
.sources ol, .sources ul { padding-left: 20px; font-size: 13.5px; }
.sources li { margin-bottom: 6px; }
.sources p { font-size: 13.5px; max-width: 80ch; }

@media (max-width: 1100px) {
  .map-grid, .emb-grid, .tech-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; border-bottom: 1px solid var(--rule-soft); }
  .side-inner { position: static; max-height: none; overflow: visible; padding: 20px 16px 16px; }
  .main { padding: 20px 16px 48px; }
  #tree { height: 70vh; }
  .multi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rank ol { columns: 1; }
}
