.viz-root {
  color-scheme: light;
  --surface-0: #f6f5f1;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #dddcd6;
  --grid: #e6e5e0;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77756f;
  --accent: #2a78d6;
  --series-1: #2a78d6;  /* integrity 研究 */
  --series-2: #eb6834;  /* 総説・メタ解析 */
  --series-3: #1baf7a;  /* fragmentomics */
  --neutral-mark: #a9a7a0;
  --seed: #0b0b0b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #262624;
    --border: #3a3a37;
    --grid: #2e2e2b;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #9a998f;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --neutral-mark: #6b6a64;
    --seed: #ffffff;
  }
}
:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #262624;
  --border: #3a3a37;
  --grid: #2e2e2b;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #9a998f;
  --accent: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --neutral-mark: #6b6a64;
  --seed: #ffffff;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: #f6f5f1; }
@media (prefers-color-scheme: dark) { body { background: #121211; } }
.viz-root {
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;
  line-height: 1.7;
  min-height: 100vh;
}
a { color: var(--accent); }
.nowrap { white-space: nowrap; }

.hero, main { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.hero { padding-top: 40px; padding-bottom: 8px; }
.eyebrow { color: var(--text-secondary); font-size: 14px; margin: 0 0 4px; letter-spacing: .04em; }
h1 { font-size: clamp(24px, 4.2vw, 36px); line-height: 1.35; margin: 0 0 12px; }
.lead { color: var(--text-secondary); max-width: 760px; margin: 0 0 20px; }
h2 { font-size: 22px; margin: 0 0 8px; padding-top: 16px; }
section { padding: 24px 0 32px; border-top: 1px solid var(--border); }
.note { color: var(--text-secondary); font-size: 14px; margin: 0 0 12px; max-width: 820px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 20px; }
.stat { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.stat b { display: block; font-size: 28px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { color: var(--text-secondary); font-size: 13px; }
.toc { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; padding-bottom: 16px; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 20px; border-left: 2px solid var(--border); }
.timeline li { position: relative; margin: 0 0 18px; padding-left: 12px; }
.timeline li::before { content: ""; position: absolute; left: -28px; top: 7px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface-1); border: 2px solid var(--text-muted); }
.timeline li.seed::before { background: var(--seed); border-color: var(--seed); }
.timeline li.parallel::before { border-color: var(--seed); border-style: dashed; }
.timeline .yr { font-weight: 700; font-variant-numeric: tabular-nums; margin-right: 8px; }
.timeline h3 { display: inline; font-size: 16px; margin: 0; }
.timeline p { margin: 4px 0 0; color: var(--text-secondary); font-size: 14px; }
.timeline .refs { font-size: 13px; color: var(--text-muted); }

.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin: 0 0 10px; font-size: 14px; }
.controls label { display: inline-flex; gap: 6px; align-items: center; color: var(--text-secondary); }
select, input[type=search] { font: inherit; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; }
input[type=search] { min-width: 200px; }
.count { color: var(--text-muted); font-size: 13px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-secondary); margin: 0 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend svg { overflow: visible; }

.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
#mapSvg { width: 100%; height: auto; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; display: block; }
.detail { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; font-size: 14px; position: sticky; top: 12px; }
.detail h3 { font-size: 15px; margin: 0 0 6px; line-height: 1.45; }
.detail .meta { color: var(--text-muted); font-size: 13px; margin: 0 0 8px; }
.detail .tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.detail .tag { background: var(--surface-2); border-radius: 999px; padding: 1px 8px; font-size: 12px; color: var(--text-secondary); }
.detail-empty { color: var(--text-muted); margin: 0; }
@media (max-width: 860px) { .map-wrap { grid-template-columns: minmax(0, 1fr); } .detail { position: static; } }
.map-wrap > *, .grid > *, main > section { min-width: 0; }
.timeline .refs, .method, td { overflow-wrap: anywhere; }

.ring { fill: none; stroke: var(--grid); stroke-width: 1; }
.ring-label { fill: var(--text-muted); font-size: 11px; }
.sector-line { stroke: var(--grid); stroke-width: 1; }
.sector-label { fill: var(--text-secondary); font-size: 12px; font-weight: 600; }
.sector-count { fill: var(--text-muted); font-size: 11px; }
.node { stroke: var(--surface-1); stroke-width: 1.5; cursor: pointer; }
.node:focus { outline: none; stroke: var(--text-primary); stroke-width: 2; }
.node.dim { opacity: .12; pointer-events: none; }
.node.active { stroke: var(--text-primary); stroke-width: 2.5; }
.seed-node { fill: var(--seed); }
.seed-label { fill: var(--text-primary); font-size: 12px; font-weight: 700; }
.prior-node { fill: none; stroke: var(--text-muted); stroke-width: 2; }

.chart { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 8px; }
.axis text { fill: var(--text-muted); font-size: 11px; }
.axis path, .axis line { stroke: var(--grid); }
.gridline line { stroke: var(--grid); }
.gridline path { display: none; }
.line { fill: none; stroke-width: 2; }
.direct-label { font-size: 12px; fill: var(--text-secondary); }
.crosshair { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.bar-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.bar-card h3 { font-size: 15px; margin: 0 0 8px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 36px; gap: 8px; align-items: center; font-size: 13px; margin: 3px 0; }
.bar-row .lbl { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { height: 12px; }
.bar-row .fill { height: 12px; border-radius: 0 4px 4px 0; background: var(--series-1); }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }

.table-wrap { overflow-x: auto; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; max-height: 640px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
th { white-space: nowrap; position: sticky; top: 0; background: var(--surface-2); color: var(--text-secondary); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .sum { color: var(--text-secondary); display: block; margin-top: 2px; }
td .badge { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }

.method { color: var(--text-secondary); font-size: 14px; padding-left: 20px; }
.back { margin-top: 20px; }

.tooltip { position: fixed; z-index: 10; max-width: 340px; background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.5; box-shadow: 0 4px 16px rgba(0,0,0,.12); pointer-events: none; }
.tooltip .tt-meta { color: var(--text-muted); font-size: 12px; }
