/* TrialPulse — stylesheet. Light and dark themes via tokens. */

:root {
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --text: #1c2326;
  --muted: #5a656b;
  --border: #d9d6cd;
  --border-strong: #b9b4a7;
  --accent: #0f5f66;
  --accent-strong: #0a474c;
  --accent-soft: #dcecec;
  --on-accent: #ffffff;
  --link: #0f5f66;
  --focus: #c8580a;

  --tier-high: #a8231a;
  --tier-high-bg: #fbe6e3;
  --tier-high-border: #e8a39b;
  --tier-elevated: #8a4b00;
  --tier-elevated-bg: #fdf0da;
  --tier-elevated-border: #ecc27c;
  --tier-typical: #2d5571;
  --tier-typical-bg: #e3edf4;
  --tier-typical-border: #a9c1d4;

  --raises: #a8231a;
  --lowers: #1f6b45;
  --lowers-bg: #e2f2e9;

  --shadow: 0 1px 2px rgba(20, 30, 35, 0.06), 0 4px 16px rgba(20, 30, 35, 0.05);
  --radius: 10px;
  --radius-sm: 6px;
  --wrap: 1180px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15191b;
    --surface: #1e2427;
    --surface-2: #262d31;
    --text: #e8e6e0;
    --muted: #a3adb2;
    --border: #343d42;
    --border-strong: #4b575d;
    --accent: #6cc4c9;
    --accent-strong: #8fd6da;
    --accent-soft: #1f3b3f;
    --on-accent: #0d1c1e;
    --link: #7fd0d4;
    --focus: #ffb169;

    --tier-high: #ffa49b;
    --tier-high-bg: #43201d;
    --tier-high-border: #7a3a34;
    --tier-elevated: #f5c470;
    --tier-elevated-bg: #3f2e12;
    --tier-elevated-border: #7a5b23;
    --tier-typical: #a8c8e0;
    --tier-typical-bg: #22323f;
    --tier-typical-border: #3f586c;

    --raises: #ffa49b;
    --lowers: #8fd3ad;
    --lowers-bg: #1f3a2c;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15191b;
  --surface: #1e2427;
  --surface-2: #262d31;
  --text: #e8e6e0;
  --muted: #a3adb2;
  --border: #343d42;
  --border-strong: #4b575d;
  --accent: #6cc4c9;
  --accent-strong: #8fd6da;
  --accent-soft: #1f3b3f;
  --on-accent: #0d1c1e;
  --link: #7fd0d4;
  --focus: #ffb169;

  --tier-high: #ffa49b;
  --tier-high-bg: #43201d;
  --tier-high-border: #7a3a34;
  --tier-elevated: #f5c470;
  --tier-elevated-bg: #3f2e12;
  --tier-elevated-border: #7a5b23;
  --tier-typical: #a8c8e0;
  --tier-typical-bg: #22323f;
  --tier-typical-border: #3f586c;

  --raises: #ffa49b;
  --lowers: #8fd3ad;
  --lowers-bg: #1f3a2c;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
main { flex: 1 0 auto; width: 100%; padding-top: 28px; padding-bottom: 56px; }
main:focus { outline: none; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding-left: 16px; padding-right: 16px; }
@media (min-width: 700px) { .wrap { padding-left: 28px; padding-right: 28px; } }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.005em; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.9rem, 1.3rem + 2.2vw, 2.9rem); font-weight: 700; }
h2 { font-size: clamp(1.45rem, 1.15rem + 1vw, 1.9rem); font-weight: 700; }
h3 { font-size: 1.2rem; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
h1[tabindex="-1"]:focus { outline: none; }
button, input, select { font: inherit; color: inherit; }
img { max-width: 100%; height: auto; display: block; }
code, pre { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.small { font-size: 0.92rem; }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.loading { color: var(--muted); padding: 40px 0; }

.skip-link { position: absolute; left: 8px; top: -60px; background: var(--accent); color: var(--on-accent); padding: 10px 14px; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { top: 8px; }

/* ---------- Header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand-mark { width: 30px; height: 30px; color: var(--accent); }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; }
.brand-tag { color: var(--muted); font-size: 0.85rem; border-left: 1px solid var(--border-strong); padding-left: 10px; }
.site-nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.site-nav a { color: var(--text); text-decoration: none; padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 500; }
.site-nav a:hover { background: var(--surface-2); }
.site-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: 999px; width: 40px; height: 40px; margin-left: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
}
@media (max-width: 560px) {
  .brand-tag { display: none; }
  .header-row { position: relative; padding-right: 52px; }
  .site-nav { width: 100%; gap: 0; }
  .site-nav a { padding: 8px 7px; font-size: 0.9rem; white-space: nowrap; }
  .theme-toggle { position: absolute; top: 10px; right: 0; margin: 0; width: 36px; height: 36px; }
}

/* ---------- Footer ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 32px 0; color: var(--muted); font-size: 0.92rem; }
.footer-grid { display: grid; gap: 24px; grid-template-columns: 1fr; }
@media (min-width: 800px) { .footer-grid { grid-template-columns: 1.3fr 1fr 1fr; } }
.footer-title { font-weight: 600; color: var(--text); margin-bottom: 6px; }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card h2, .card h3 { margin-top: 0; }
.source { color: var(--muted); font-size: 0.85rem; margin: 10px 0 0; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px; border-radius: 999px; border: 1px solid transparent; background: var(--accent); color: var(--on-accent); font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2; }
.btn:hover { background: var(--accent-strong); color: var(--on-accent); }
.btn-secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-secondary:hover { background: var(--accent-soft); color: var(--accent-strong); }
.btn-small { padding: 8px 14px; font-size: 0.92rem; }
.btn svg { width: 18px; height: 18px; }

.tier { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.86rem; font-weight: 600; border: 1px solid; white-space: nowrap; line-height: 1.4; }
.tier::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tier-high { color: var(--tier-high); background: var(--tier-high-bg); border-color: var(--tier-high-border); }
.tier-elevated { color: var(--tier-elevated); background: var(--tier-elevated-bg); border-color: var(--tier-elevated-border); }
.tier-typical { color: var(--tier-typical); background: var(--tier-typical-bg); border-color: var(--tier-typical-border); }

.risk-bar { display: block; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 6px; max-width: 120px; }
.risk-bar > span { display: block; height: 100%; border-radius: 3px; }
.risk-bar.tier-high > span { background: var(--tier-high); }
.risk-bar.tier-elevated > span { background: var(--tier-elevated); }
.risk-bar.tier-typical > span { background: var(--tier-typical); }

.pill { display: inline-block; padding: 2px 9px; border: 1px solid var(--border); border-radius: 999px; font-size: 0.85rem; background: var(--surface-2); color: var(--text); margin: 2px 4px 2px 0; }

.notice { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 0 0 1em; }
.notice p:last-child { margin-bottom: 0; }

.grid-2 { display: grid; gap: 20px; grid-template-columns: 1fr; }
.grid-3 { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.error { border: 1px solid var(--tier-high-border); background: var(--tier-high-bg); color: var(--tier-high); padding: 16px; border-radius: var(--radius-sm); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.data th, table.data td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { font-weight: 600; color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface); position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tr.lead td { font-weight: 600; background: var(--accent-soft); }

/* ---------- Home ---------- */
.hero { padding: 24px 0 36px; max-width: 860px; }
.hero .eyebrow { color: var(--accent); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.82rem; margin-bottom: 10px; }
.hero h1 { margin-bottom: 18px; }
.hero .lede { font-size: 1.2rem; color: var(--text); max-width: 760px; }
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.stats { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; margin: 8px 0 28px; }
@media (min-width: 860px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat .value { font-family: var(--font-display); font-size: 2.1rem; font-weight: 700; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; }
.stat .label { color: var(--muted); font-size: 0.92rem; margin-top: 6px; line-height: 1.35; }
.stat .detail { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }
.section { margin: 36px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.lede-small { max-width: 760px; color: var(--muted); margin-bottom: 14px; }
dl.terms { max-width: 860px; } dl.terms dt { font-weight: 600; color: var(--text); font-size: 1rem; } dl.terms dd { margin-bottom: 6px; }
.tier-legend { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .tier-legend { grid-template-columns: repeat(3, 1fr); } }
.tier-legend .card { padding: 16px 18px; }
.tier-legend .card p { margin: 8px 0 0; font-size: 0.95rem; color: var(--muted); }
ul.checks { list-style: none; padding: 0; margin: 0; }
ul.checks li { padding: 6px 0 6px 30px; position: relative; }
ul.checks li::before { content: ""; position: absolute; left: 6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
ul.checks li.no::before { background: var(--tier-high); }
.preview-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.preview-item { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: start; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.preview-item .rank { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; color: var(--muted); line-height: 1; padding-top: 2px; }
.preview-item .preview-text { min-width: 0; }
.preview-item .title { font-weight: 600; font-size: 1.08rem; overflow-wrap: anywhere; }
.preview-item .reg-title { color: var(--muted); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.preview-item .reg-title a { color: inherit; text-decoration: none; }
.preview-item .reg-title a:hover, .preview-item .reg-title a:focus-visible { text-decoration: underline; color: var(--text); }
.preview-item .title a { color: var(--text); }
.preview-item .meta { font-size: 0.9rem; color: var(--muted); margin-top: 4px; }
.preview-item .risk { text-align: right; white-space: nowrap; }
.preview-item .risk .pct { font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .preview-item { grid-template-columns: 36px 1fr; } .preview-item .risk { grid-column: 2; text-align: left; margin-top: 6px; } }

/* ---------- Trials list ---------- */
.page-head { margin-bottom: 18px; }
.page-head h1 { margin-bottom: 8px; }
.page-head p { color: var(--muted); max-width: 820px; }
.filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; margin-bottom: 12px; }
.filters-toggle { min-height: 44px; }
.filters-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .filters-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); } }
@media (min-width: 1100px) { .filters-grid { grid-template-columns: repeat(6, 1fr); } }
@media (min-width: 640px) { .filters-toggle { display: none; } .search-row { grid-template-columns: 1fr; } }
@media (max-width: 639px) {
  .filters-grid { display: none; }
  .filters.open .filters-grid { display: grid; }
  .filters { padding: 12px; }
  .filters-bar { margin-top: 10px; }
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); min-height: 44px; }
.field input::placeholder { color: var(--muted); }
.filters-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.result-count { font-weight: 600; }
.link-btn { background: none; border: none; color: var(--link); text-decoration: underline; cursor: pointer; padding: 6px 4px; }
.link-btn:hover { color: var(--accent-strong); }

.trials-table .title-cell { overflow-wrap: anywhere; }
.trials-table .title-cell a { color: var(--text); font-weight: 600; text-decoration: none; }
.trials-table .title-cell a:hover { text-decoration: underline; color: var(--accent-strong); }
.trials-table .title-cell .sub { color: var(--muted); font-size: 0.85rem; margin-top: 3px; }
.trials-table .risk-cell { min-width: 120px; }
.trials-table .risk-cell .times, .trials-table .risk-cell .pct { display: block; white-space: nowrap; }
.trials-table .risk-cell .times { font-weight: 700; font-variant-numeric: tabular-nums; }
.trials-table .risk-cell .pct { color: var(--muted); font-size: 0.88rem; }
.trials-table td.rank { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.trials-table .sites-cell { font-size: 0.9rem; min-width: 130px; }
.trials-table .title-cell { min-width: 200px; }
.show-more { text-align: center; padding: 18px 0; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  table.data.trials-table, .trials-table thead, .trials-table tbody, .trials-table tr, .trials-table td { display: block; }
  .trials-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .trials-table tr { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 12px; padding: 12px 14px; }
  .trials-table tbody tr:hover { background: var(--surface); }
  .trials-table td { border: none; padding: 4px 0; }
  .trials-table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 0.82rem; }
  .trials-table td.rank { font-size: 0.85rem; }
  .trials-table td.rank::before { content: "Rank "; color: var(--muted); }
  .trials-table td.title-cell { padding: 4px 0 8px; font-size: 1.02rem; }
  .trials-table .risk-cell { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
  .risk-bar { display: none; }
}

/* ---------- Trial detail ---------- */
.detail-head { margin-bottom: 20px; }
.detail-head .crumbs { font-size: 0.92rem; margin-bottom: 12px; }
.detail-head h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.3rem); max-width: 960px; }
.detail-head .h1-sub { font-family: var(--font-ui); font-weight: 500; font-size: 0.55em; color: var(--muted); white-space: nowrap; }
.detail-head .reg-title-full { max-width: 960px; margin: -4px 0 12px; font-size: 1.02rem; line-height: 1.45; overflow-wrap: anywhere; }
.detail-head .ids { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; color: var(--muted); }
.detail-head .ids code { background: var(--surface-2); padding: 2px 8px; border-radius: 4px; font-size: 0.95rem; color: var(--text); }
.detail-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .detail-grid { grid-template-columns: 1.2fr 1fr; } }
.risk-card .headline { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 4px; }
.risk-card .big { font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.risk-card .big small { font-size: 1rem; font-family: var(--font-ui); font-weight: 500; color: var(--muted); margin-left: 6px; }
.risk-card .facts { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 0.95rem; margin: 10px 0 0; }
.risk-card .facts strong { color: var(--text); }
.reasons { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; }
.reason { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.reason .dir { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 3px 8px; border-radius: 4px; white-space: nowrap; margin-top: 2px; }
.reason .dir.raises { color: var(--raises); background: var(--tier-high-bg); }
.reason .dir.lowers { color: var(--lowers); background: var(--lowers-bg); }
.reason .what { font-weight: 600; }
.reason .val { color: var(--muted); font-size: 0.92rem; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 0.9rem; }
dl.facts dd { margin: 0; }
@media (max-width: 480px) { dl.facts { grid-template-columns: 1fr; gap: 2px; } dl.facts dd { margin-bottom: 10px; } }
.map { height: 320px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); margin-top: 12px; z-index: 0; }
.site-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.site-list li { padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 0.95rem; }
.site-list .city { color: var(--muted); }
.eligibility { margin-top: 20px; }
.eligibility .elig-body { overflow-wrap: anywhere; font-size: 0.97rem; line-height: 1.55; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 18px; margin: 0; max-height: 520px; overflow: hidden; position: relative; }
.eligibility .elig-body p { white-space: pre-wrap; margin: 0 0 0.8em; }
.eligibility .elig-body p.elig-head { font-weight: 700; margin-top: 0.4em; }
.eligibility .elig-body ul { margin: 0 0 0.9em; padding-left: 1.4em; }
.eligibility .elig-body li { margin: 0.25em 0 0.25em calc(var(--lvl, 0) * 1.3em); }
.eligibility .elig-body > :last-child { margin-bottom: 0; }
.eligibility .elig-body.expanded { max-height: none; }
.eligibility .elig-body.clamped::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 80px; background: linear-gradient(to bottom, transparent, var(--surface-2)); pointer-events: none; }
.eligibility .toggle { margin-top: 10px; }
.required-lines { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.required-lines span { background: var(--surface-2); border: 1px solid var(--border); padding: 6px 12px; border-radius: 999px; font-size: 0.9rem; font-weight: 500; }
.ctgov-link { margin-top: 16px; }

/* Leaflet overrides for dark mode readability */
.leaflet-container { font: inherit; }
.leaflet-popup-content { font-size: 0.92rem; line-height: 1.4; }
[data-theme="dark"] .leaflet-tile { filter: brightness(0.8) contrast(1.05) saturate(0.8); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile { filter: brightness(0.8) contrast(1.05) saturate(0.8); } }
[data-theme="dark"] .leaflet-popup-content-wrapper, [data-theme="dark"] .leaflet-popup-tip { background: var(--surface); color: var(--text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-popup-content-wrapper, :root:not([data-theme="light"]) .leaflet-popup-tip { background: var(--surface); color: var(--text); } }

/* ---------- About ---------- */
.about .section { margin: 32px 0; }
.about .prose { max-width: 820px; }
.about ul.limits { padding-left: 0; list-style: none; display: grid; gap: 10px; }
.about ul.limits li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; }
.about ul.limits li strong { display: block; margin-bottom: 2px; }
.figures { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .figures { grid-template-columns: 1fr 1fr; } }
.figure { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.figure img { border-radius: 4px; width: 100%; background: #fff; }
.figure figcaption { padding: 10px 6px 4px; font-size: 0.92rem; color: var(--muted); }
.figure figcaption strong { color: var(--text); }
.bar-chart { width: 100%; height: auto; font-family: var(--font-ui); }
.bar-chart .bar { fill: var(--accent); }
.bar-chart .bar.flagged { fill: var(--border-strong); }
.bar-chart text { fill: var(--text); font-size: 13px; }
.bar-chart .val { fill: var(--muted); font-size: 12px; }
.bar-chart .axis { stroke: var(--border); }
.metrics-note { font-size: 0.9rem; color: var(--muted); }
.kv { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .kv { grid-template-columns: repeat(4, 1fr); } }
.kv .stat .value { font-size: 1.7rem; }
details.more { margin-top: 12px; }
details.more summary { cursor: pointer; color: var(--link); font-weight: 500; }

/* Inline icons inside links and buttons */
svg.ext { width: 1em; height: 1em; vertical-align: -0.15em; flex: none; }

/* ---------- Ethics ---------- */
.ethics .section { margin: 32px 0; }
.ethics .prose { max-width: 820px; }
.ethics h3 { margin-top: 0; }
.ethics ul.limits { padding-left: 0; list-style: none; display: grid; gap: 8px; max-width: 860px; }
.ethics ul.limits li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
.promise { background: var(--accent-soft); border: 1px solid var(--accent); border-left-width: 6px; border-radius: var(--radius); padding: 20px 24px; max-width: 860px; }
.promise h2 { margin-bottom: 10px; }
.promise ul { margin: 0; padding-left: 1.2em; font-size: 1.08rem; font-weight: 500; }
.promise li { margin: 4px 0; }
.fair-chart .bar-all { fill: var(--tier-typical); }
.fair-chart .bar-high { fill: var(--tier-high); }
.chart-key { margin: 6px 0 14px; display: flex; gap: 14px; flex-wrap: wrap; }
.chart-key .key::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-key .key-all::before { background: var(--tier-typical); }
.chart-key .key-high::before { background: var(--tier-high); }
.fair-table th[scope="row"] { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 0.95rem; position: static; }
@media (max-width: 640px) { .fair-chart { display: none; } }

/* ---------- Map page ---------- */
.map-card { padding: 16px; }
.map-controls { border: none; padding: 0; margin: 0 0 12px; display: flex; gap: 16px; flex-wrap: wrap; }
.map-controls label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.map-controls input { width: 18px; height: 18px; accent-color: var(--accent); }
.map-large { height: 520px; margin-top: 0; }
@media (max-width: 640px) { .map-large { height: 380px; } }
.map-legend { list-style: none; padding: 0; margin: 12px 0 0; display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.92rem; }
.map-legend li { display: inline-flex; align-items: center; gap: 6px; }
.map-legend .swatch { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border-strong); display: inline-block; }
.map-table th[scope="row"] { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 0.95rem; position: static; }
.leaflet-tooltip { font: inherit; font-size: 0.9rem; }

/* ---------- FAQ ---------- */
.faq-page .section { margin: 28px 0; max-width: 860px; }
details.faq { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; }
details.faq summary { cursor: pointer; padding: 14px 16px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 10px; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::before { content: "+"; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; flex: none; }
details.faq[open] summary::before { content: "−"; }
details.faq summary:hover { background: var(--surface-2); }
details.faq .faq-a { padding: 0 16px 14px 48px; }
details.faq .faq-a p { margin: 0 0 0.6em; }
details.faq .faq-a .source { margin-top: 4px; }

/* ---------- Info buttons and cards ---------- */
.info-wrap { white-space: nowrap; }
.info-btn { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--accent); background: transparent; color: var(--accent); font: 700 11px/1 var(--font-ui); font-style: italic; cursor: help; vertical-align: 1px; margin-left: 2px; padding: 0; }
.info-btn:hover, .info-btn[aria-expanded="true"] { background: var(--accent); color: var(--on-accent); }
.field .label-row { display: flex; align-items: center; gap: 6px; }
.info-card { position: fixed; z-index: 200; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: 0 8px 28px rgba(0,0,0,0.22); padding: 12px 14px; font-size: 0.9rem; line-height: 1.45; }
.info-card p { margin: 0 0 6px; }
.info-card p:last-child { margin-bottom: 0; }
.info-card .info-tag { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.info-card .info-title { font-weight: 700; font-size: 0.98rem; }
.info-card .info-people { font-weight: 600; }
.info-card .info-note { color: var(--muted); font-size: 0.82rem; border-top: 1px solid var(--border); padding-top: 6px; margin-top: 8px; }
.info-card .info-list { margin: 0 0 6px; padding-left: 1.1em; }
.info-card .info-list li { margin: 2px 0; }

/* ---------- About us ---------- */
.team-page .section { margin: 28px 0; }
.team-page .prose { max-width: 820px; }
.team-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); max-width: 900px; }
.team-card { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.team-card .avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.team-card .name { font-weight: 600; font-size: 1.05rem; }

/* ---------- Trials toolbar, sorting ---------- */
.bar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bar-actions .sort-label { font-size: 0.82rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.bar-actions select { padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); min-height: 38px; }
table.data th .sort-link { color: inherit; text-decoration: none; }
table.data th .sort-link:hover { text-decoration: underline; color: var(--text); }
table.data th[aria-sort="ascending"] .sort-link, table.data th[aria-sort="descending"] .sort-link { color: var(--text); }

/* ---------- Map v2 ---------- */
.map-filters { margin-bottom: 16px; }
.map-filters .filters-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
@media (max-width: 639px) { .map-toggle-row { margin-bottom: 10px; } }
@media (min-width: 640px) { .map-toggle-row { display: none; } }
.year-chart { width: 100%; height: auto; }
.year-chart rect { fill: var(--accent); cursor: pointer; }
.year-chart .dim rect { fill: var(--border-strong); }
.year-chart .yc-bar:hover rect, .year-chart .yc-bar:focus rect { fill: var(--accent-strong); }
.year-chart .yc-bar:focus { outline: none; }
.year-chart .yc-bar:focus-visible rect { stroke: var(--focus); stroke-width: 2; }
.year-chart text { fill: var(--text); font-size: 11px; font-family: var(--font-ui); }
.year-chart .val { fill: var(--muted); }

/* ---------- Live registry status ---------- */
.live-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.live-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-weight: 600; font-size: 0.9rem; border: 1px solid; }
.live-badge.ok { color: var(--lowers); background: var(--lowers-bg); border-color: var(--lowers); }
.live-badge.changed { color: var(--tier-elevated); background: var(--tier-elevated-bg); border-color: var(--tier-elevated-border); }
dl.small-facts { font-size: 0.92rem; }

/* ---------- Map legend v2 ---------- */
.legend-block { margin-top: 12px; }
.legend-title { display: block; font-size: 0.82rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.legend-compare { margin: 6px 0 0; }
.size-legend { margin-top: 10px; color: var(--muted); }
.size-legend svg { display: block; max-width: 100%; height: auto; }
.size-legend text { fill: var(--text); font-family: var(--font-ui); }

/* ---------- Active filter chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent-strong); border: 1px solid var(--accent); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 0.9rem; font-weight: 500; }
.chip-x { border: none; background: transparent; color: inherit; font-size: 1.1rem; line-height: 1; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; padding: 0; }
.chip-x:hover { background: var(--accent); color: var(--on-accent); }

/* ---------- Coordinator journey ---------- */
.journey { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .journey { grid-template-columns: repeat(5, 1fr); } }
.journey li { counter-increment: step; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 14px 48px; position: relative; display: flex; flex-direction: column; gap: 4px; }
.journey li::before { content: counter(step); position: absolute; left: 14px; top: 14px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 0.85rem; display: inline-flex; align-items: center; justify-content: center; }
.journey li a { color: var(--text); text-decoration: none; }
.journey li a:hover strong { text-decoration: underline; color: var(--accent-strong); }
.journey li span { font-size: 0.9rem; color: var(--muted); }

/* ---------- Trial next steps and live conflict ---------- */
.next-card h3 { font-size: 1rem; margin: 12px 0 6px; }
.conflict { background: var(--tier-elevated-bg); border: 1px solid var(--tier-elevated-border); color: var(--text); padding: 8px 10px; border-radius: var(--radius-sm); }
.risk-card .big small { display: block; margin-left: 0; margin-top: 2px; }

/* ---------- Metrics extras ---------- */
.ci { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.shift-table th[scope="row"] { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 0.95rem; position: static; }
.callout-warn { border-left: 4px solid var(--tier-elevated); background: var(--tier-elevated-bg); padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 0 0 1em; }
.callout-warn p:last-child { margin-bottom: 0; }

.notice-limit { border-left-color: var(--tier-elevated); }
.notice-limit .notice-title { font-weight: 700; margin-bottom: 4px; }
