:root {
  --bg: #f7f7f4;
  --card: #ffffff;
  --ink: #1d2327;
  --muted: #5f6b73;
  --line: #e2e3dd;
  --accent: #2f5d8a;
  --exposure: #1b8a6b;
  --outcome: #c4462f;
  --adjusted: #2f5d8a;
  --unadjusted: #9aa7b1;
  --mediator: #7b4fa0;
  --ai: #d08a00;
  --radius: 10px;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* let the hidden attribute win over display rules */
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .4rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: .95rem; margin: 0 0 .6rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }

header {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem;
  padding: .8rem 1.5rem; background: var(--ink); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.logo { color: #7fd4b8; margin-right: .3rem; }
nav a { color: #cfd6db; text-decoration: none; margin-left: 1.2rem; }
nav a.active, nav a:hover { color: #fff; }
.disclaimer { background: #fff4d6; color: #6b4c00; text-align: center; font-size: .85rem; padding: .35rem 1rem; }

main { max-width: 1280px; margin: 0 auto; padding: 1.5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { background: #fde8e4; color: #8a2a17; padding: .7rem 1rem; border-radius: var(--radius); margin-top: 1rem; }

.hero { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; }
.hero p { max-width: 760px; color: var(--muted); }
.submit { display: flex; gap: .6rem; margin-top: 1.2rem; flex-wrap: wrap; }
.submit input { flex: 1; min-width: 0; }
input, select {
  font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
button, .button {
  font: inherit; padding: .55rem 1rem; border: 0; border-radius: 8px; background: var(--accent); color: #fff;
  cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap;
}
button:disabled { opacity: .45; cursor: default; }
button.secondary, .button.secondary { background: #eef1f3; color: var(--ink); }
button.danger { color: #a23218; }
button.approve { background: var(--exposure); }
button.mini { padding: .2rem .6rem; font-size: .8rem; }

.progress { list-style: none; padding: 0; margin: 1.2rem 0 0; }
.progress li { padding: .35rem .5rem .35rem 1.8rem; position: relative; color: var(--muted); border-radius: 6px; }
.progress li::before { content: "○"; position: absolute; left: .2rem; }
.progress li.active { color: var(--ink); font-weight: 600; }
.progress li.active::before { content: "◐"; color: var(--accent); animation: spin 1s linear infinite; display: inline-block; }
.progress li.done::before { content: "●"; color: var(--exposure); }
@keyframes spin { to { transform: rotate(360deg); } }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-decoration: none; color: inherit; }
.card:hover { border-color: var(--accent); }
.card .eo { font-weight: 600; }
.card .eo .arrow { color: var(--muted); margin: 0 .3rem; }

.record-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.badge { padding: .25rem .7rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #eef1f3; }
.badge.approved { background: #dff3ea; color: #145c47; }
.badge.draft { background: #fff4d6; color: #6b4c00; }

.record-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.2rem; margin-bottom: 1rem; }
.graph-col #editor { margin-bottom: 0; }
/* The review column takes the graph column's height and scrolls inside it. */
.side-col { position: relative; min-height: 420px; }
.side-scroll { position: absolute; inset: 0; overflow-y: auto; padding-right: .3rem; }
.side-scroll > .panel:last-child { margin-bottom: 0; }
.record-lower { column-count: 2; column-gap: 1.2rem; }
.record-lower > .panel { break-inside: avoid; display: inline-block; width: 100%; }
@media (max-width: 900px) {
  .record-grid { grid-template-columns: 1fr; }
  .side-col { min-height: 0; }
  .side-scroll { position: static; overflow: visible; padding-right: 0; }
  .record-lower { column-count: 1; }
}
#cy { height: 520px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.legend { display: grid; gap: .45rem; font-size: .82rem; color: var(--ink); margin: .6rem 0 1rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem; }
.legend-group { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1rem; }
.legend-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); min-width: 4.8rem; }
/* swatches mirror the graph: rounded boxes, square box for adjusted */
.sw { display: inline-block; width: 18px; height: 12px; border-radius: 4px; margin-right: .4rem; vertical-align: -1px; box-sizing: border-box; }
.sw.exposure { background: var(--exposure); }
.sw.outcome { background: var(--outcome); }
.sw.adjusted { background: var(--adjusted); border: 2px solid #1b3a59; border-radius: 0; }
.sw.unadjusted { background: #fff; border: 2px solid var(--unadjusted); }
.sw.mediator { background: #efe6f6; border: 2px solid var(--mediator); }
.sw.ai { background: #fffaf0; border: 2px dashed var(--ai); }
.ln { display: inline-block; width: 24px; height: 0; border-top: 2px solid #a6b0b7; margin-right: .4rem; vertical-align: 3px; position: relative; }
.ln::after { content: ""; position: absolute; right: -2px; top: -5px; border: 4px solid transparent; border-left: 6px solid #a6b0b7; }
.ln.main { border-top-width: 3px; border-top-color: #5d6970; }
.ln.main::after { border-left-color: #5d6970; top: -5.5px; }
.ln.ai { border-top-style: dashed; border-top-color: #e0b04a; }
.ln.ai::after { border-left-color: #e0b04a; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.panel.ai { border-left: 4px solid var(--ai); }
.panel.highlight { border-color: var(--accent); }
.tag { font-size: .7rem; background: #fff1cc; color: #7a5200; padding: .1rem .45rem; border-radius: 4px; text-transform: none; letter-spacing: 0; margin-left: .3rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .6rem; }
.row select, .row input { min-width: 0; }
.row.actions { margin-top: 1rem; }
.check { display: inline-flex; gap: .3rem; align-items: center; font-size: .9rem; }
pre#dagitty { background: #f3f4f1; padding: .8rem; border-radius: 8px; overflow-x: auto; max-height: 260px; }

dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: .35rem .9rem; font-size: .9rem; }
dt { color: var(--muted); }
dd { margin: 0; }

.sugg { border-top: 1px solid var(--line); padding: .7rem .4rem; margin: 0 -.4rem; border-radius: 6px; }
.sugg:first-of-type { border-top: 0; }
.sugg .head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.sugg .label { font-weight: 600; }
.sugg ul { margin: .3rem 0 0; padding-left: 1.1rem; font-size: .82rem; }
.sugg.accepted .label::after { content: " ✓ accepted"; color: var(--exposure); font-weight: 400; font-size: .8rem; }
.sugg.rejected { opacity: .55; }
.sugg.rejected .label { text-decoration: line-through; }
.sev { font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 4px; text-transform: uppercase; }
.sev.high { background: #fde0d9; color: #8a2a17; }
.sev.medium { background: #fff1cc; color: #7a5200; }
.sev.low { background: #e5f1ec; color: #145c47; }
.bias { margin-bottom: .7rem; }
.bias b { margin-right: .4rem; }

.filters > input { flex: 1; min-width: 200px; }  /* the search box only, not the checkbox */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f3f4f1; font-weight: 600; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7f9fb; }

.prose { max-width: 760px; }

/* ---------- key figures ---------- */
.headline { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: .3rem 0 .5rem; }
.headline .arrow { color: var(--muted); font-weight: 700; }
.pill { display: inline-block; padding: .2rem .7rem; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.pill.exposure { background: #e1f3ec; color: #12634c; }
.pill.outcome { background: #fbe5df; color: #8f2f1d; }
.pill.design { background: #eef1f3; color: var(--ink); text-transform: capitalize; font-weight: 500; margin-left: .3rem; }

.keyfacts { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: 1rem; margin-bottom: 1.2rem; }
@media (max-width: 760px) { .keyfacts { grid-template-columns: 1fr; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.tile.ai { border-top: 3px solid var(--ai); }
.tile.warn { border-top: 3px solid var(--outcome); }
.t-label { font-size: .8rem; color: var(--muted); }
.t-value { font-size: 1.6rem; font-weight: 600; line-height: 1.2; margin-top: .15rem; }
.t-sub { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.tile.hero { border-top: 3px solid var(--ink); }
.t-hero { font-size: 3rem; font-weight: 600; line-height: 1.05; margin-top: .2rem; letter-spacing: -.01em; }
.t-hero .measure { font-size: 1.4rem; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.forest { width: 100%; max-width: 260px; height: auto; margin-top: .5rem; display: block; }
.forest .null { stroke: #9aa7b1; stroke-width: 1; stroke-dasharray: 3 3; }
.forest .ci { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.forest .est { fill: var(--ink); }
.forest .axis { font-size: 10px; fill: var(--muted); }
.sig { color: #12634c; font-weight: 600; }

mark { padding: 0 .15em; border-radius: 3px; color: inherit; }
mark.num { background: #e8eef6; font-weight: 600; }
mark.term { background: transparent; font-weight: 600; border-bottom: 2px solid #c9d6e4; border-radius: 0; padding: 0; }
mark.term.warn { background: #fff1cc; border: 0; border-radius: 3px; padding: 0 .3em; margin-right: .2rem; font-weight: 500; }

/* ---------- dataset charts ---------- */
.insights { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 960px) { .insights { grid-template-columns: 1fr; } }
.chart-scroll { overflow-x: auto; }
svg.chart { width: 100%; min-width: 460px; height: auto; display: block; font-family: inherit; }
svg.chart .grid { stroke: #eceee9; stroke-width: 1; }
svg.chart .null { stroke: #8c979f; stroke-width: 1; stroke-dasharray: 4 3; }
svg.chart .axis, svg.chart .sub { font-size: 10px; fill: var(--muted); }
svg.chart .lbl { font-size: 12px; fill: var(--ink); }
svg.chart .val { font-size: 11px; fill: var(--muted); }
svg.chart .hit { fill: transparent; }
svg.chart g[data-tip]:hover .hit, svg.chart .frow:hover .hit { fill: #f3f6f9; }
svg.chart .frow { cursor: pointer; }
svg.chart .ci { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
svg.chart .est { fill: var(--ink); }
svg.chart .ns .ci { stroke: #a6b0b7; }
svg.chart .ns .est { fill: #a6b0b7; }
svg.chart .bar { fill: #c27f00; }
.tooltip { position: fixed; z-index: 10; max-width: 340px; background: var(--ink); color: #fff; font-size: .8rem;
  line-height: 1.4; padding: .55rem .7rem; border-radius: 8px; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.tooltip .muted { color: #c4ccd2; }

.back { display: inline-block; margin-bottom: .6rem; font-size: .9rem; text-decoration: none; }
.back:hover { text-decoration: underline; }
.intro { max-width: 720px; margin: .2rem 0 0; }

/* ---------- network ---------- */
.net-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; }
@media (max-width: 900px) { .net-grid { grid-template-columns: 1fr; } }
.net-wrap { position: relative; min-width: 0; }
.net-grid > * { min-width: 0; }
/* the library sizes its canvas in pixels; keep it inside the column so the side panel isn't pushed off-screen */
#net3d canvas { display: block; max-width: 100%; }
#net3d { width: 100%; height: min(72vh, 720px); min-height: 380px; border-radius: var(--radius); overflow: hidden; background: #0f1720; }
.net-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #c4ccd2; text-align: center; padding: 1rem; }
.net-side { max-height: min(72vh, 720px); overflow-y: auto; margin: 0; }
.net-legend { margin-bottom: .9rem; font-size: .82rem; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: .35rem; vertical-align: -1px; }
.dot.exposure { background: #2bb38a; } .dot.outcome { background: #e2654b; } .dot.confounder { background: #5b8fd0; }
.dot.ai { background: #e0a320; } .dot.other { background: #8a96a0; }
.net-top { padding-left: 1.2rem; margin: 0; }
.net-top li { margin: .25rem 0; }
.net-papers { padding-left: 1rem; margin: .3rem 0 .8rem; font-size: .85rem; }
.net-papers li { margin-bottom: .45rem; }
.net-role { display: inline-block; font-size: .72rem; background: #eef1f3; border-radius: 4px; padding: 0 .35rem; margin-left: .25rem; }
.net-role.exposure { background: #e1f3ec; } .net-role.outcome { background: #fbe5df; } .net-role.ai { background: #fff1cc; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-align: left; }
.linklike:hover { text-decoration: underline; }
.net-tip { font: 12px/1.4 ui-sans-serif, -apple-system, sans-serif; background: rgba(15,23,32,.92); color: #fff; padding: .35rem .55rem; border-radius: 6px; }

.net-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: var(--radius); }
.net-label { position: absolute; left: 0; top: 0; white-space: nowrap; color: #e8eef4; font-weight: 600; font-size: 12px;
  text-shadow: 0 1px 3px #0f1720, 0 0 6px #0f1720; opacity: 0; transform-origin: 50% 0; will-change: transform, opacity; }
.net-label.exposure { color: #7fe0bf; } .net-label.outcome { color: #ffab97; } .net-label.ai { color: #ffd277; }
.net-label.selected { background: rgba(15,23,32,.85); padding: .1rem .45rem; border-radius: 5px; outline: 1px solid #e8eef4; }
.alias { display: inline-block; font-size: .78rem; background: #eef1f3; border-radius: 4px; padding: 0 .35rem; margin: .15rem .1rem 0 0; }

/* ---------- ask the dataset ---------- */
.ask-panel { border-top: 3px solid var(--accent); }
.tag.nv { background: #e3f1d6; color: #3c6b12; }
.ask-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.ask-row input { flex: 1; min-width: 0; }
.ask-examples { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.chip { background: #eef1f3; color: var(--ink); border-radius: 999px; padding: .3rem .75rem; font-size: .82rem; }
.chip:hover { background: #e2e8ed; }
.ask-out { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.ask-answer p { margin: 0 0 .5rem; max-width: 820px; }
.ask-answer ul { margin: .2rem 0 .6rem; padding-left: 1.2rem; }
.cite { display: inline-block; min-width: 1.2rem; text-align: center; font-size: .72rem; font-weight: 700; line-height: 1.2rem;
  background: #e8eef6; color: var(--accent); border-radius: 4px; margin-left: .2rem; text-decoration: none; vertical-align: 1px; }
.cite:hover { background: var(--accent); color: #fff; }
.ask-sources { font-size: .85rem; padding-left: 1.4rem; margin: .4rem 0 .6rem; }
.ask-sources li { margin-bottom: .2rem; }
.ask-method { margin: .4rem 0 0; }

.badge.ai-rev { background: #fff1cc; color: #6b4c00; }
.review-note { margin-top: .3rem; padding: .3rem .5rem; background: #f7f4ea; border-radius: 6px; }
.ai-review-note { background: #fff4d6; color: #6b4c00; padding: .5rem .7rem; border-radius: 8px; margin: 0 0 .7rem; }

/* forest plot: about 13 rows visible, the rest scroll; axis stays pinned below */
.forest-rows { max-height: 400px; overflow-y: auto; overscroll-behavior: contain; border-bottom: 1px solid var(--line); scrollbar-gutter: stable; }
.forest-axis-wrap { overflow-y: hidden; scrollbar-gutter: stable; }  /* same gutter as the rows, so the axis lines up */
#forest-chart { overflow-x: auto; }
#forest-chart svg.chart { min-width: 520px; }
svg.chart.forest-axis { margin-top: 2px; }

/* dataset table */
.badge { white-space: nowrap; }
#table td:last-child { white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pager { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; margin: .7rem 0 1.5rem; }
.pages { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.pages button[aria-current] { cursor: default; }
