:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #f0f2f5;
  --border: #d9dee5;
  --text: #16202c;
  --muted: #5d6b7a;
  --accent: #1f5fa9;
  --accent-soft: #e6eef8;
  --ok: #1c7c4a;
  --warn: #9a6200;
  --danger: #b3261e;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1a1f27;
    --surface-alt: #222833;
    --border: #333c49;
    --text: #e8edf3;
    --muted: #9aa7b6;
    --accent: #6ea8f0;
    --accent-soft: #1d2a3b;
    --ok: #57c98a;
    --warn: #e0a75a;
    --danger: #f08a82;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
pre {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  overflow-x: auto;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 20px 64px; }
.narrow { max-width: 760px; }

header.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 600; letter-spacing: -0.005em; text-decoration: none;
  color: var(--muted); font-size: 13.5px; font-family: var(--mono);
}
.brand:hover { color: var(--text); }
nav.main { display: flex; gap: 14px; flex-wrap: wrap; }
nav.main a {
  text-decoration: none;
  color: var(--muted);
  padding: 4px 2px;
  border-bottom: 2px solid transparent;
}
nav.main a.active, nav.main a:hover { color: var(--text); border-bottom-color: var(--accent); }
.spacer { margin-left: auto; }

h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 26px 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
p.lead { color: var(--muted); margin-top: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.stat .note { font-size: 12px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--muted);
}
.badge.active { color: var(--ok); border-color: currentColor; }
.badge.draft { color: var(--muted); }
.badge.disabled { color: var(--warn); border-color: currentColor; }
.badge.archived { color: var(--danger); border-color: currentColor; }
.badge.lock { color: var(--accent); border-color: currentColor; }

form { margin: 0; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=email], input[type=url],
input[type=number], input[type=date], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button, .btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger, .btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.small, .btn.small { padding: 4px 9px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }

.flash { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { color: var(--ok); border-color: currentColor; background: var(--surface); }
.flash.error { color: var(--danger); border-color: currentColor; background: var(--surface); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.bar-row { display: grid; grid-template-columns: 150px 1fr 60px; gap: 10px; align-items: center; margin-bottom: 6px; font-size: 13px; }
/* Geometry lives in SVG attributes, not inline CSS, so the strict
   Content-Security-Policy (no inline styles) leaves the bars intact. */
.bar-track { display: block; width: 100%; height: 10px; background: var(--surface-alt); border-radius: 4px; }
.bar-fill { fill: var(--accent); }
.bar-count { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.chart { width: 100%; height: auto; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

.version-row.current { background: var(--accent-soft); }
.url { word-break: break-all; font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 14px; align-items: end; }

/* --------------------------------------------------------------------------
   Public research page. Measured for reading: the text column stays near 70
   characters, which is where long abstracts stop being tiring.
   -------------------------------------------------------------------------- */
body.paper { background: var(--surface); }
body.paper .wrap { max-width: 820px; padding: 0 24px 72px; }

.paper-page { padding-top: 56px; }

.paper-head { margin-bottom: 36px; }

.eyebrow {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.paper-title {
  margin: 0 0 20px;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.22;
  letter-spacing: -0.022em;
  font-weight: 680;
  /* The reading column already bounds the line; a tighter cap would push a
     long paper title into five short lines. */
  max-width: 30ch;
}

.byline {
  margin: 0 0 12px;
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--text);
}
.author-name { font-weight: 520; }
.author-sep { color: var(--muted); }
.affil-mark {
  font-size: 0.66em;
  font-weight: 600;
  color: var(--accent);
  margin-left: 1px;
  top: -0.5em;
  position: relative;
}

.affiliations {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--muted);
}
.affiliations li { display: flex; gap: 7px; }
.affil-index {
  flex: none;
  font-size: 0.78em;
  font-weight: 600;
  color: var(--accent);
  padding-top: 2px;
}

/* Action row: the three things a reader actually came for. */
.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 44px;
  padding-bottom: 4px;
}
.action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  font-weight: 520;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.action:hover { border-color: var(--accent); background: var(--accent-soft); }
.action-icon { flex: none; color: var(--accent); }

.paper-section { margin-bottom: 40px; }
.paper-section h2 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
}

.abstract {
  margin: 0;
  font-size: 16.5px;
  line-height: 1.72;
  max-width: 68ch;
  color: var(--text);
}

.record {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr;
  gap: 9px 22px;
  margin: 0 0 14px;
  font-size: 14.5px;
}
.record dt { color: var(--muted); }
.record dd { margin: 0; word-break: break-word; }
.record a { text-decoration: none; }
.record a:hover { text-decoration: underline; }

.note {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 64ch;
}

/* Code blocks scroll inside themselves; the page never scrolls sideways. */
.code-block { position: relative; }
.code-block pre {
  margin: 0;
  padding: 16px 64px 16px 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.65;
  overflow-x: auto;
}
/* Wrapped rather than clipped: a citation or BibTeX entry that runs off the
   right edge looks broken, and the copied text is identical either way. */
.code-block pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.code-block pre.wrap-text { word-break: break-word; }
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 11px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.copy-btn:hover { color: var(--text); border-color: var(--accent); }

/* Index of published projects. */
.resource-list { display: grid; gap: 10px; margin-top: 8px; }
.resource-item {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); padding: 14px 16px; text-decoration: none; color: var(--text);
}
.resource-item:hover { border-color: var(--accent); }
.resource-item .type { font-size: 12.5px; color: var(--muted); }

footer.site {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding: 18px 0 28px;
  font-size: 12.5px;
  color: var(--muted);
}
footer.site .wrap { display: flex; gap: 16px; justify-content: space-between; }
body.paper footer.site { background: var(--bg); }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; }

/* Spacing utilities. Inline style attributes are blocked by the CSP. */
.stack { margin-top: 16px; }
.stack-sm { margin-top: 10px; }
.stack-lg { margin-top: 26px; }
.page-offset { padding-top: 64px; }
.flush-bottom { padding-bottom: 0; }
.note-archived { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ORCID iD, drawn inline so no external image and no inline style is needed. */
.orcid-icon circle { fill: #a6ce39; }
.orcid-icon text { fill: #fff; font: 700 9px system-ui, sans-serif; }
a.orcid { text-decoration: none; vertical-align: middle; }
.authors { margin: 0 0 4px; }
.venue-line { color: var(--muted); margin: 0 0 18px; }
.doi-badge {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 12px; font-size: 13px; text-decoration: none;
  background: var(--surface); color: var(--text);
}
.doi-badge:hover { border-color: var(--accent); }
.doi-badge .label { color: var(--muted); }
