:root {
  color-scheme: light;
  --surface-0: #f4f3ef;
  --surface-1: #fcfcfb;
  --border: #dcdad3;
  --grid: #e8e6e0;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --accent: #2a78d6;
  --series-owner: #2a78d6;   /* slot 1 blue: ordinary registrant */
  --series-trust: #eb6834;   /* slot 2 orange: trustee registrant */
  --series-seed: #1baf7a;    /* slot 3 aqua: focus entity / known owner */
  --highlight-bg: #fff4d6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --border: #383835;
    --grid: #2a2a28;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --accent: #3987e5;
    --series-owner: #3987e5;
    --series-trust: #d95926;
    --series-seed: #199e70;
    --highlight-bg: #3a3320;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --border: #383835;
  --grid: #2a2a28;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8e86;
  --accent: #3987e5;
  --series-owner: #3987e5;
  --series-trust: #d95926;
  --series-seed: #199e70;
  --highlight-bg: #3a3320;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--surface-0); color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
header {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface-1); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; color: var(--text-primary); }
#searchform { flex: 1; min-width: 200px; }
#q {
  width: 100%; max-width: 520px; padding: 7px 10px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface-0); color: var(--text-primary);
}
nav { display: flex; gap: 14px; }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 4px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
.sub { color: var(--text-secondary); margin-bottom: 12px; }
.muted { color: var(--text-muted); }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { color: var(--text-secondary); font-weight: 600; position: sticky; top: 0; background: var(--surface-1); }
tr.current td { background: var(--highlight-bg); }
.tablewrap { overflow-x: auto; max-height: 560px; overflow-y: auto; }
.pill {
  display: inline-block; padding: 0 6px; border-radius: 9px; font-size: 11px; line-height: 17px;
  border: 1px solid var(--border); color: var(--text-secondary); white-space: nowrap;
}
.pill.trust::before, .pill.owner::before, .pill.known::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px;
}
.pill.trust::before { background: var(--series-trust); }
.pill.owner::before { background: var(--series-owner); }
.pill.known::before { background: var(--series-seed); }
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat { background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; min-width: 150px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--text-secondary); font-size: 12px; }
#cy { width: 100%; height: min(78vh, 820px); min-height: 420px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); margin: 6px 0; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.timeline svg { display: block; width: 100%; }
.timeline .axis text { fill: var(--text-muted); font-size: 11px; }
.timeline .axis line { stroke: var(--grid); }
.timeline .lbl { fill: var(--text-primary); font-size: 12px; }
.timeline .lbl2 { fill: var(--text-muted); font-size: 11px; }
#tooltip {
  position: fixed; pointer-events: none; z-index: 20; display: none; max-width: 360px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px;
  font-size: 12px; box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.finding { border-left: 3px solid var(--series-seed); }
.finding h3 { margin: 0 0 6px; font-size: 15px; }
.chain { font-size: 13px; }
.chain li { margin: 2px 0; }
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.controls input, .controls select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1); color: var(--text-primary); }
.small { font-size: 12px; }
.graph-toolbar { display: flex; gap: 8px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.graph-toolbar button, .controls button {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1);
  color: var(--text-primary); font: inherit; font-size: 13px; cursor: pointer;
}
.graph-toolbar button:disabled { opacity: 0.45; cursor: default; }
.graph-toolbar button:not(:disabled):hover { border-color: var(--accent); }
