: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 {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 650; letter-spacing: -0.01em; text-decoration: none; color: var(--text);
}
.brand-mark { display: block; flex: none; border-radius: 5px; }
body.public .brand { gap: 8px; }
body.public .brand span {
  font-weight: 500; color: var(--muted); font-size: 13.5px; font-family: var(--mono);
}
body.public .brand:hover span { 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;
}
/* Cards size to their content instead of being stretched to the tallest in
   the row, which was leaving large blank areas under the short ones. */
.grid { display: grid; gap: 16px; align-items: start; }
.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: 13px 16px 15px; }
.stat .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 620; letter-spacing: -0.025em; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat .note { font-size: 12px; color: var(--muted); }

/* Two-column key/value tables read better without per-cell rules. */
.kv th, .kv td { border-bottom: none; padding: 5px 10px 5px 0; }
.kv th { width: 40%; font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 13.5px; }
.kv tr + tr th, .kv tr + tr td { border-top: 1px solid var(--border); }

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 {
  display: flex; align-items: flex-start; gap: 9px;
  border-radius: var(--radius); padding: 11px 14px; margin-bottom: 16px; border: 1px solid;
}
.flash .action-icon { flex: none; margin-top: 1px; }
.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: 190px; display: block; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.chart-area { fill: var(--accent); opacity: 0.12; stroke: none; }
.chart-dot { fill: var(--accent); }
.chart-labels {
  display: flex; justify-content: space-between; font-size: 12px;
  color: var(--muted); border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px;
}
.chart-labels span:only-child { margin: 0 auto; }

/* Filter form: fields in a grid, actions on their own line. */
.filter-actions {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border);
}
.filter-spacer { flex: 1 1 auto; }

.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.
   -------------------------------------------------------------------------- */
/* Masthead, content and footer share one column, so the page reads as a
   single measure rather than three unrelated bands. */
body.public .wrap,
body.public .topbar-inner { max-width: 820px; padding-left: 24px; padding-right: 24px; }
body.public .wrap { padding-bottom: 72px; padding-top: 0; }
body.public .topbar { background: transparent; border-bottom-color: var(--border); }
body.paper { background: var(--surface); }

.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.2;
  letter-spacing: -0.024em;
  font-weight: 680;
  /* The reading column already bounds the line; a tighter cap would push a
     long paper title into five short lines. Balancing avoids a runt last line. */
  max-width: 30ch;
  text-wrap: balance;
}

.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); }
/* A quiet mark that the link leaves this site. */
.action-out { display: inline-flex; color: var(--muted); margin-left: 2px; }
.action-out .action-icon { color: inherit; width: 13px; height: 13px; }
.action:hover .action-out { color: var(--accent); }

.paper-section { margin-bottom: 40px; }
.paper-section:last-child { margin-bottom: 8px; }
.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(110px, max-content) 1fr;
  gap: 10px 28px;
  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);
  text-wrap: pretty;
}

/* Code blocks scroll inside themselves; the page never scrolls sideways. */
.code-block { position: relative; }
.code-block pre {
  margin: 0;
  /* Room for the copy button. No hanging indent: text-indent only moves the
     first line of the block, which would misrepresent the real indentation of
     a BibTeX entry that people read and copy. */
  padding: 16px 92px 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;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  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. */
.index-page { padding-top: 48px; }
.index-page h1 { font-size: 26px; letter-spacing: -0.02em; margin-bottom: 6px; }
.index-page .lead { max-width: 60ch; margin-bottom: 26px; }
.index-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.index-item {
  display: flex; gap: 20px; align-items: baseline; justify-content: space-between;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  padding: 16px 18px; text-decoration: none; color: var(--text);
  transition: border-color .12s ease;
}
.index-item:hover { border-color: var(--accent); }
.index-main { display: block; }
.index-title {
  display: block; font-weight: 600; font-size: 15.5px; line-height: 1.45;
  letter-spacing: -0.008em; margin-bottom: 4px;
}
.index-venue { display: block; font-size: 13px; color: var(--muted); }
.index-slug { flex: none; font-size: 13px; color: var(--muted); }
@media (max-width: 620px) {
  .index-item { flex-direction: column; gap: 8px; }
}

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); }

/* Keyboard users get the same affordances as pointer users. */
.action:focus-visible,
.copy-btn:focus-visible,
.index-item:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
::selection { background: var(--accent-soft); color: var(--text); }

/* A research page gets printed and saved as PDF. Chrome, footer and controls
   are noise on paper; the destinations behind the links are not. */
@media print {
  :root { --text: #000; --muted: #333; --border: #bbb; --accent: #000; }
  body, body.paper { background: #fff; }
  header.topbar, footer.site, .copy-btn, .action-out { display: none; }
  .brand-mark { display: none; }
  body.public .wrap { max-width: none; padding: 0; }
  .paper-page { padding-top: 0; }
  .paper-title { font-size: 22pt; }
  .abstract, .byline { font-size: 11pt; }
  .paper-section { break-inside: avoid; margin-bottom: 18pt; }
  .code-block pre { border: 1px solid #bbb; background: #fff; font-size: 8.5pt; }
  .actions-row { gap: 6pt; }
  .action { border: 1px solid #bbb; padding: 3pt 6pt; font-size: 9pt; }
  /* No URL expansion after links. The Record section already prints the
     persistent URL and the DOI as text, and the /go/ addresses are tracked
     redirects whose real destination is not knowable from the markup, so
     printing them would duplicate one and mislead about the other. */
}

/* Long documents such as the privacy notice. */
.doc-page { padding-top: 48px; max-width: 68ch; }
.doc-page h1 {
  font-size: 27px; letter-spacing: -0.02em; margin: 0 0 8px; line-height: 1.25;
}
.doc-page .lead { font-size: 16px; line-height: 1.7; margin-bottom: 30px; }
.doc-page h2 {
  margin: 30px 0 12px; 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);
}
.doc-page ul { margin: 0; padding-left: 20px; }
.doc-page li { margin-bottom: 7px; line-height: 1.65; }
.doc-page .note { margin-top: 26px; }

/* Sign-in: a three-field form does not need a 760px card. */
.signin { max-width: 380px; margin: 0 auto; padding-top: 76px; }
.signin .card { padding: 26px 26px 24px; }
.signin-mark { display: block; width: 38px; height: 38px; margin-bottom: 16px; }
.signin h1 { font-size: 21px; letter-spacing: -0.015em; margin-bottom: 2px; }
.signin .lead { font-size: 13.5px; margin-bottom: 20px; }
.signin button[type=submit] { width: 100%; margin-top: 4px; }
.signin .hint { margin-top: 16px; }

/* A quiet way back that does not read as body copy. */
.backlink {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; color: var(--muted); text-decoration: none;
}
.backlink:hover { color: var(--accent); }
.backlink::before { content: "\2190"; }

/* Long URLs in a two-column table break at punctuation before mid-word. */
.kv td .url, .link-facts td { overflow-wrap: break-word; word-break: normal; }
