/* ReproTrail. Style: achromatic ledger (taste-skill app sheet, seed 329486979).
   Face: blue-grey ledger ground; ink chrome; colour only on evidence.
   Grid: canvas max 1240px, 32px gutters. Rows use one 16px gap.
   two-one: (1240 - 16) = 1224 -> 816 + 408. map-row: 1224 -> 904 + 320. Ledger: one card, 5 equal cells. */

:root {
  --ground: #f2f4f7;
  --surface: #ffffff;
  --raised: #eef0f3;
  --active: #e6e9ee;
  --border: #e3e6ea;
  --rule: #eef0f2;
  --control: #cfd4da;
  --text: #0a0a0a;
  --muted: #5f646b;
  --faint: #6b6f75;
  --primary: #141414;
  --hue: #1d5fbf;            /* the paper itself: the one data hue */
  --positive: #2e7d32;
  --negative: #c4242a;
  --amber: #c27c0e;          /* mark colour for mixed / corrections */
  --warning: #92400e;        /* amber as text */
  --pill-positive-bg: #dcfae5; --pill-positive-ink: #04250e;
  --pill-negative-bg: #ffedea; --pill-negative-ink: #831c1e;
  --pill-warning-bg: #fff4dc;  --pill-warning-ink: #7a3a06;
  --pill-neutral-bg: #eceef1;  --pill-neutral-ink: #3d3d3d;
  --grid: #e8eaee;
  --radius-card: 8px; --radius-control: 6px; --radius-chip: 4px;
  --gap: 16px; --card-pad: 20px; --pad: 32px;
  --control-height: 36px;
  --font: "Geist", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --fs-title: 24px; --fs-section: 16px; --fs-kpi: 30px; --fs-body: 14px; --fs-small: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--text);
  font: 400 var(--fs-body)/1.45 var(--font);
  font-feature-settings: "ss01" 0;
}
a { color: inherit; text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--hue); }
:focus-visible { outline: 2px solid var(--hue); outline-offset: 2px; border-radius: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: 0; }
p { margin: 0; }
button { font: inherit; color: inherit; }

/* Bar */
.bar {
  display: grid; grid-template-columns: auto minmax(0, 560px) auto; justify-content: space-between; align-items: center; gap: 24px;
  height: 56px; padding: 0 var(--pad); max-width: 1304px; margin: 0 auto;
}
body[data-view="home"] .bar { grid-template-columns: auto auto; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 600; font-size: 16px; }
.brand:hover { color: var(--text); }
.mark { width: 24px; height: 24px; color: var(--text); }
.bar-links a { color: var(--muted); text-decoration: none; }
.bar-links a:hover { color: var(--text); }

/* Search */
.search { position: relative; display: flex; gap: 8px; }
.search input {
  flex: 1; min-width: 0; height: var(--control-height); padding: 0 12px;
  border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface);
  font: inherit; color: var(--text);
}
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.search-home input { height: 48px; font-size: 16px; padding: 0 16px; }
.btn-primary {
  height: 48px; padding: 0 22px; border: 0; border-radius: var(--radius-control);
  background: var(--primary); color: #fff; font-weight: 500; cursor: pointer;
}
.btn-primary:hover { background: #2b2b2b; }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost {
  height: 32px; padding: 0 12px; border: 1px solid var(--control); border-radius: var(--radius-control);
  background: var(--surface); cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center;
}
.btn-ghost:hover { border-color: var(--text); color: var(--text); }
.btn-ghost:disabled { color: var(--faint); cursor: default; border-color: var(--border); }
.btn-small { height: 28px; padding: 0 10px; font-size: 13px; }
.results {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  box-shadow: 0 10px 28px rgba(15, 20, 30, .12); padding: 6px; max-height: 420px; overflow: auto;
}
.results button {
  display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 6px; cursor: pointer;
}
.results button:hover, .results button[aria-selected="true"] { background: var(--active); }
.results .r-title { display: block; font-weight: 500; }
.results .r-meta { display: block; color: var(--muted); font-size: 13px; }
.results .r-empty { padding: 10px; color: var(--muted); }

/* Canvas */
.canvas { max-width: 1304px; margin: 0 auto; padding: 16px var(--pad) 48px; display: grid; gap: var(--gap); }
.row { display: grid; gap: var(--gap); align-items: start; }
.two-one { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.map-row { grid-template-columns: minmax(0, 1fr) 320px; align-items: stretch; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--card-pad); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 12px; min-height: 28px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-size: var(--fs-section); font-weight: 600; margin-right: auto; }
.card-note { color: var(--muted); font-size: var(--fs-small); }

/* Skeletons: flat bars at the real size, no shimmer */
.sk { display: inline-block; height: 14px; max-width: 100%; background: var(--raised); border-radius: 3px; vertical-align: middle; }
.sk-title { width: min(720px, 100%); height: 26px; }
.sk-block { background: var(--raised); border-radius: 6px; }
[data-k="rail-body"] .sk, [data-k="reps"] .sk, [data-k="scan"] .sk, [data-k="record"] .sk, [data-k="links"] .sk { display: block; margin: 0 0 10px; }

/* Title row */
.title-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; padding: 20px 0 8px; align-items: start; }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.title-row h1 { font-size: var(--fs-title); line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; max-width: 920px; text-wrap: balance; }
.byline { margin-top: 8px; color: var(--muted); max-width: 920px; }
.finding { margin-top: 12px; font-size: 16px; line-height: 1.45; max-width: 860px; }
.finding .f-neg { color: var(--negative); font-weight: 500; }
.finding .f-warn { color: var(--warning); font-weight: 500; }
.finding .f-pos { color: var(--positive); font-weight: 500; }
.title-side { text-align: right; padding-top: 22px; }
.doi-line { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.doi { font-family: var(--mono); font-size: 13px; color: var(--text); word-break: break-all; }
.fresh { margin-top: 8px; color: var(--muted); font-size: var(--fs-small); }
.fresh button { border: 0; background: none; padding: 0; text-decoration: underline; color: var(--muted); cursor: pointer; font-size: inherit; }
.notice-banner {
  margin-top: 12px; padding: 10px 12px; border-radius: 6px; background: var(--pill-warning-bg); color: var(--pill-warning-ink);
  border: 1px solid #f3d9a4; max-width: 860px;
}

/* Ledger: one card split by dividers */
.ledger { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }
.ledger .cell { padding: 16px 20px 18px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.ledger .cell + .cell { border-left: 1px solid var(--border); }
.ledger .lbl { color: var(--muted); font-size: 13px; }
.ledger .val { font-size: var(--fs-kpi); line-height: 1.15; font-weight: 500; letter-spacing: -0.01em; }
.ledger .val.word { font-size: 24px; }
.ledger .val.v-neg { color: var(--negative); }
.ledger .val.v-warn { color: var(--warning); }
.ledger .val.v-zero { color: var(--muted); }
.ledger .sub { color: var(--muted); font-size: 13px; line-height: 1.4; }
.ledger .sub b { font-weight: 500; }
.c-success { color: var(--positive); } .c-failure { color: var(--negative); } .c-mixed { color: var(--warning); }

/* Legends */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: var(--fs-small); align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend svg { width: 12px; height: 12px; flex: none; overflow: visible; }
.legend-map { margin-top: 12px; }

/* Trail */
.trail { position: relative; }
.trail svg, .map svg { display: block; width: 100%; height: auto; overflow: visible; }
.trail text, .map text { font-family: var(--font); fill: var(--muted); font-size: 12px; }
.trail .lane-label { fill: var(--text); font-size: 13px; }
.trail .ev-label { fill: var(--text); font-size: 12px; }
.trail .ev { cursor: pointer; }
.tip {
  position: absolute; z-index: 10; pointer-events: none; max-width: 340px; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 18px rgba(15, 20, 30, .12);
  font-size: 13px; line-height: 1.35;
}
.tip b { display: block; font-weight: 500; }
.tip span { color: var(--muted); }

/* Map */
.seg { display: inline-flex; background: var(--raised); border-radius: var(--radius-control); padding: 3px; gap: 2px; }
.seg button { height: 26px; padding: 0 10px; border: 0; border-radius: 4px; background: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.seg button:hover { color: var(--text); }
.map-note { color: var(--muted); font-size: 13px; margin: -6px 0 10px; }
.map { position: relative; }
.map .node { cursor: pointer; }
.map .edge { stroke: #0a0a0a; stroke-opacity: .06; stroke-width: 1; }
.map .edge.hot { stroke: #0a0a0a; stroke-opacity: .55; }
.map .dim { opacity: .18; }
.map .sel-ring { fill: none; stroke: var(--text); stroke-width: 1.5; }
.map-card { display: flex; flex-direction: column; }

/* Rail */
.rail { display: flex; flex-direction: column; }
.rail-body { display: flex; flex-direction: column; gap: 12px; }
.rail-body > * { flex: none; }
.rail .r-title { font-size: 15px; font-weight: 500; line-height: 1.35; }
.rail .r-meta { color: var(--muted); font-size: 13px; }
.rail .abstract { color: var(--text); font-size: 13px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 9; -webkit-box-orient: vertical; overflow: hidden; }
.rail .abstract.open { -webkit-line-clamp: unset; }
.rail .r-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rail .quote { border-left: 2px solid var(--control); padding-left: 10px; color: var(--text); font-size: 13px; }
.rail h3 { font-size: 13px; font-weight: 600; margin-top: 6px; }
.fu-list { list-style: none; margin: 0; padding: 0; display: grid; }
.fu-list li { border-top: 1px solid var(--rule); }
.fu-list button { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: start; width: 100%; text-align: left; background: none; border: 0; padding: 8px 0; cursor: pointer; }
.fu-list button:hover .fu-t { text-decoration: underline; }
.fu-list svg { width: 12px; height: 12px; margin-top: 3px; }
.fu-t { font-size: 13px; line-height: 1.35; }
.fu-y { color: var(--muted); font-size: 12px; }
.text-btn { border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 13px; justify-self: start; align-self: flex-start; }

/* Pills */
.pill { flex: none; display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.p-success { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.p-failure { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.p-mixed { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.p-other { background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }

/* Tables */
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-weight: 400; color: var(--muted); font-size: var(--fs-small); padding: 0 12px 8px 0; }
td { padding: 10px 12px 10px 0; border-top: 1px solid var(--rule); vertical-align: top; }
td:last-child, th:last-child { padding-right: 0; }
th.num, td.num { text-align: right; }
.t-title { font-weight: 500; }
.t-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.t-quote { color: var(--muted); font-size: 13px; margin-top: 4px; }
.date { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text); text-align: right; }
.more { margin-top: 10px; }

/* Effects */
.effects { margin-top: 20px; }
.effects h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.eff-plot svg { width: 100%; height: 36px; display: block; }
.eff-plot text { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.empty { border: 1px dashed var(--control); border-radius: 8px; padding: 12px 14px; color: var(--muted); }
.empty + .empty { margin-top: 8px; }
.empty a { color: var(--text); }

/* Planner */
.planner .fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.planner label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; }
.planner input, .planner select {
  height: 36px; width: 100%; padding: 0 10px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); font: inherit; font-variant-numeric: tabular-nums;
}
.planner .prefill { color: var(--muted); font-size: 12px; margin-top: 8px; }
.planner table { margin-top: 14px; }
.planner td { padding: 8px 0; }
.planner td.num { font-weight: 500; }

/* Lists */
.dep-list, .link-list { list-style: none; margin: 0; padding: 0; }
.dep-list li, .link-list li { padding: 9px 0; border-top: 1px solid var(--rule); }
.dep-list li:first-child, .link-list li:first-child { border-top: 0; padding-top: 0; }
.links-group + .links-group { margin-top: 18px; }
.links-group h3 { font-size: 13px; font-weight: 600; margin-bottom: 8px; }

/* Home */
.home-top { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--gap); align-items: stretch; padding-top: 24px; }
.home-ask { padding: 36px 0 24px; display: grid; gap: 14px; align-content: start; }
.home-ask h1 { font-size: 32px; line-height: 1.15; letter-spacing: -0.02em; max-width: 640px; }
.lede { font-size: 16px; color: var(--muted); max-width: 600px; }
.search-home { max-width: 680px; margin-top: 10px; }
.examples { color: var(--muted); }
.examples a { color: var(--text); }
.coverage h2 { font-size: var(--fs-section); }
.cov-figure { display: grid; margin-top: 12px; gap: 2px; }
.kpi { font-size: 36px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; }
.cov-sub { color: var(--muted); font-size: 13px; }
.cov-bar { display: flex; gap: 2px; height: 10px; margin: 16px 0 6px; border-radius: 3px; overflow: hidden; }
.cov-bar i { display: block; height: 100%; }
.cov-table td { padding: 7px 0; font-size: 13px; }
.cov-table td:first-child { display: flex; gap: 8px; align-items: center; }
.cov-table svg { width: 10px; height: 10px; }
.source-line { color: var(--muted); font-size: 12px; margin-top: 10px; }
.top-list { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.top-list li { display: grid; grid-template-columns: minmax(0, 1fr) 150px 56px; gap: 16px; align-items: center; padding: 10px 0; border-top: 1px solid var(--rule); }
.top-list li:first-child { border-top: 0; padding-top: 0; }
.top-list a { text-decoration: none; }
.top-list a:hover .t-title { text-decoration: underline; }
.units { display: flex; flex-wrap: wrap; gap: 3px; }
.units i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.u-success { background: var(--positive); } .u-failure { background: var(--negative); } .u-mixed { background: var(--amber); } .u-other { background: #a9adb3; }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li { padding: 9px 0; border-top: 1px solid var(--rule); }
.recent-list li:first-child { border-top: 0; padding-top: 0; }
.recent-list a { text-decoration: none; }
.recent-list a:hover .t-title { text-decoration: underline; }

/* About */
.prose { max-width: 760px; display: grid; gap: 14px; font-size: 15px; line-height: 1.6; }
.prose h1 { font-size: var(--fs-title); margin-top: 20px; }
.prose h2 { font-size: 17px; margin-top: 14px; }
.prose ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

/* Footer */
.foot { max-width: 1304px; margin: 0 auto; padding: 8px var(--pad) 40px; color: var(--muted); font-size: 13px; display: grid; gap: 4px; }
.foot strong { color: var(--text); font-weight: 600; }

/* Desktop: the rail takes the map's height and scrolls inside it */
@media (min-width: 1101px) {
  .map-row .rail { position: relative; min-height: 0; }
  .map-row .rail-body { position: absolute; inset: 62px var(--card-pad) var(--card-pad); overflow: auto; padding-right: 4px; }
}
.stack { display: grid; gap: var(--gap); align-content: start; min-width: 0; }

/* Tablet */
@media (max-width: 1100px) {
  .map-row { grid-template-columns: 1fr; }
  .ledger { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ledger .cell:nth-child(4) { border-left: 0; }
  .ledger .cell:nth-child(n+4) { border-top: 1px solid var(--border); }
}
@media (max-width: 860px) {
  .two-one, .home-top { grid-template-columns: 1fr; }
  .title-row { grid-template-columns: 1fr; }
  .title-side { text-align: left; padding-top: 0; }
  .doi-line { justify-content: flex-start; }
}
/* Phone */
@media (max-width: 640px) {
  :root { --pad: 16px; --card-pad: 16px; }
  .bar { grid-template-columns: auto auto; height: auto; padding-top: 10px; padding-bottom: 10px; row-gap: 10px; }
  .bar .search-bar { grid-column: 1 / -1; grid-row: 2; }
  .home-ask { padding-top: 8px; }
  .home-ask h1 { font-size: 26px; }
  .search-home { flex-direction: column; }
  .btn-primary { width: 100%; }
  .ledger { grid-template-columns: 1fr 1fr; }
  .ledger .cell { border-left: 0 !important; border-top: 1px solid var(--border); padding: 12px 14px; }
  .ledger .cell:nth-child(-n+2) { border-top: 0; }
  .ledger .cell:nth-child(even) { border-left: 1px solid var(--border) !important; }
  .ledger .cell:last-child { grid-column: 1 / -1; border-left: 0 !important; }
  .ledger .val { font-size: 24px; }
  .ledger .val.word { font-size: 20px; }
  .title-row h1 { font-size: 20px; }
  .top-list li { grid-template-columns: minmax(0, 1fr) 40px; }
  .top-list .units { grid-column: 1 / -1; grid-row: 2; }
  .planner .fields { grid-template-columns: 1fr 1fr; }
  .planner .fields label:first-child { grid-column: 1 / -1; }
  .eff-plot { display: none; }
  .rec-table thead { display: none; }
  .rec-table tr { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; border-top: 1px solid var(--rule); padding: 10px 0; }
  .rec-table td { border: 0; padding: 0; }
  .rec-table td.rec-detail, .rec-table td.rec-src { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
