/* Design tokens: the WikiViews / openreview visual language (flat, tight, tabular). */
:root {
  --bg: #eff1ed;      /* light grey, as at the start (Ivan 2026-10-10; light blue #e8f0fc and darker #d0d4cd before) */
  --surface: #fff;
  --surface-soft: #f7f8f5;
  --ink: #1a1a1a;
  --ink-muted: #575757;
  --line: #d7dad4;
  --line-strong: #b8bdb5;
  --blue: #48a7ff;
  --blue-soft: #eaf4ff;
  --green: #89e289;
  --purple: #af9de3;
  --orange: #ff703d;
  --yellow: #ffd45d;
  --grey: #878787;
  --accent: #1668c4;
  --page-width: 1180px;
  --gap: 18px;
  --radius: 3px;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: clip; scrollbar-gutter: stable; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 13.5px/1.45 var(--sans); font-feature-settings: "tnum" 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4em; font-weight: 600; letter-spacing: -.012em; line-height: 1.22; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 13.5px; }
p { margin: 0 0 .6em; }
input, select, button { font: inherit; color: inherit; min-height: 29px; padding: 4px 8px;
  border: 1px solid var(--line-strong); border-radius: 2px; background: var(--surface); }
button { cursor: pointer; background: var(--surface-soft); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

/* header */
.site-header { position: sticky; top: 0; z-index: 1000; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.97); }
.site-header-inner { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; width: min(var(--page-width), calc(100% - 32px)); min-height: 52px; margin: 0 auto; padding: 8px 0 0; }
.brand { display: inline-flex; align-items: baseline; gap: 8px; color: var(--ink); font-weight: 650; white-space: nowrap; }
.brand small { color: var(--ink-muted); font-weight: 500; }
.brand:hover { text-decoration: none; }
.scope-version { color: var(--ink-muted); font-size: 12px; white-space: nowrap; }
.header-search { flex: 1 1 250px; max-width: 460px; display: flex; margin-left: auto; }
.header-search input { width: 100%; border-left: 0; }
.header-search select { border-radius: 2px 0 0 2px; background: var(--surface-soft); }
.nav { display: flex; gap: 18px; flex-basis: 100%; overflow-x: auto; }
.nav a { padding: 6px 0 8px; color: var(--ink-muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.nav a:hover, .nav a.active { color: var(--ink); border-bottom-color: var(--blue); text-decoration: none; }

/* page */
.page { width: min(var(--page-width), calc(100% - 32px)); margin: 0 auto; padding: 0 0 48px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 22px 0 10px; flex-wrap: wrap; }
.meta { color: var(--ink-muted); font-size: 12.5px; }
.filters { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12.5px; }
.filters label { color: var(--ink-muted); }

/* KPI strip: contiguous cells */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border: 1px solid var(--line);
  background: var(--surface); border-radius: var(--radius); margin: 0 0 var(--gap); }
.kpi { padding: 10px 14px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi .v { font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.kpi .l { color: var(--ink-muted); font-size: 12px; }

/* cards */
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(12, minmax(0, 1fr)); margin-bottom: var(--gap); }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; }
@media (max-width: 900px) { .grid > * { grid-column: span 12 !important; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.note { color: var(--ink-muted); font-size: 12px; }
.chart { width: 100%; height: 320px; }
.chart.tall { height: 460px; }
.chart.xtall { height: 680px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--ink-muted); font-size: 12px; white-space: nowrap; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr:hover td { background: var(--surface-soft); }
.bar { display: inline-block; height: 8px; background: var(--blue); border-radius: 1px; vertical-align: middle; }
.pos { color: #2f855a; } .neg { color: #b83b00; }

/* chips, toggles, results */
.chip { display: inline-block; padding: 1px 6px; border: 1px solid var(--line); border-radius: 2px; background: var(--surface-soft); font-size: 11.5px; color: var(--ink-muted); white-space: nowrap; }
.chip.blue { background: var(--blue-soft); border-color: #cfe5ff; color: var(--accent); }
.toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 2px; overflow: hidden; }
.toggle a { padding: 4px 10px; color: var(--ink-muted); border-right: 1px solid var(--line); }
.toggle a:last-child { border-right: 0; }
.toggle a.on { background: var(--accent); color: #fff; text-decoration: none; }
.results { list-style: none; margin: 0; padding: 0; }
.results li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.results .t { font-weight: 600; }
.results .m { color: var(--ink-muted); font-size: 12.5px; }
.abstract { max-width: 80ch; }
.map { height: 640px; border: 1px solid var(--line); border-radius: var(--radius); }
.leaflet-container { background: #f2f3f0; font: 12.5px var(--sans); }
.map-tiles { filter: grayscale(1) contrast(.92) brightness(1.04); }
.empty { color: var(--ink-muted); padding: 24px 0; }
.scope-switch { max-width: 260px; }

/* search */
.searchbar { display: flex; gap: 6px; align-items: flex-start; margin: 0 0 14px; }
textarea.query { flex: 1; min-height: 38px; max-height: 260px; resize: vertical; padding: 8px 10px; font: inherit; font-size: 14px;
  line-height: 1.4; border: 1px solid var(--line-strong); border-radius: 2px; background: var(--surface); overflow-y: auto; }
textarea.query:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.searchbar select, .searchbar button { min-height: 38px; }
.page-head.sub { margin-top: 4px; align-items: center; }
.page-head.sub h2 { font-size: 16px; margin-bottom: 2px; }
.page-head.sub .meta a.on { color: var(--ink); font-weight: 600; }
.results li.scored { display: flex; gap: 12px; align-items: flex-start; }
.results li .body { min-width: 0; flex: 1; }
.score { flex: none; display: inline-block; min-width: 46px; padding: 3px 0; text-align: center; border-radius: 3px;
  font: 650 15px/1.2 var(--sans); letter-spacing: -.01em; font-feature-settings: "tnum" 1;
  color: color-mix(in srgb, var(--accent) calc(55% + var(--s) * 45%), #333);
  background: color-mix(in srgb, var(--blue) calc(8% + var(--s) * 30%), #fff); border: 1px solid color-mix(in srgb, var(--blue) calc(20% + var(--s) * 40%), #fff); }
.sim-small { display: inline-block; min-width: 32px; margin-right: 6px; color: var(--accent); font-weight: 600; font-size: 12px; }
.results .best { margin-top: 2px; }
a.similar { margin-left: 10px; font-size: 12px; white-space: nowrap; }
a.similar::before { content: "≈ "; }
.kws { margin: 4px 0 2px; line-height: 1.9; }
.kws .chip { margin-right: 2px; }
.kws.big .chip { font-size: 12.5px; }
a.chip.kw { color: var(--ink); }
a.chip.kw:hover { border-color: var(--blue); text-decoration: none; }
.chip.green { background: #eaf8ea; border-color: #bfe6bf; color: #2f855a; }
.chip.warn { background: #fff4e0; border-color: #ffd9a8; color: #a14a00; }
.toggle.small a { padding: 1px 7px; font-size: 11.5px; }
.stack { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.pager { margin: 12px 0 0; color: var(--ink-muted); }
.nowrap { white-space: nowrap; }
.place-form { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.place-form input, .place-form button { min-height: 25px; padding: 2px 6px; font-size: 12px; }
.table-filter { width: 320px; margin-bottom: 8px; }
.hidden-by-filter, .hidden-by-flag { display: none; }
th.sort { cursor: pointer; user-select: none; }
th.sort:hover { color: var(--ink); }
th[data-dir="desc"]::after { content: " ▾"; } th[data-dir="asc"]::after { content: " ▴"; }
.map-legend { background: #fff; padding: 6px 8px; border: 1px solid var(--line); font-size: 11.5px; max-height: 300px; overflow-y: auto; }
.map-legend span { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }

/* shortlist star */
.star { border: 0; background: none; padding: 0 5px 0 0; min-height: 0; font-size: 15px; line-height: 1; color: var(--grey); cursor: pointer; }
.star.on { color: #e0a100; }
.star:hover { color: #e0a100; }
h1 .star { font-size: 20px; }
.nav-right { margin-left: auto; }
a.button { display: inline-block; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 2px; background: var(--surface-soft); color: var(--ink); }
a.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
a.button:hover { text-decoration: none; }

/* search summary and facets */
.facets { position: sticky; top: 100px; }
.facets h2 { margin-bottom: 2px; }
.facets h3 { margin: 14px 0 4px; font-size: 12.5px; color: var(--ink-muted); }
.facets table td { padding: 3px 6px; }
.facets .chosen { margin-top: 8px; }
.yearbars { display: flex; align-items: flex-end; gap: 3px; height: 70px; }
.yearbars a { display: flex; flex-direction: column; align-items: center; flex: 1; text-decoration: none; }
.yearbars span { display: block; width: 100%; background: var(--blue); border-radius: 1px; }
.yearbars a:hover span { background: var(--accent); }
.yearbars small { color: var(--ink-muted); font-size: 10.5px; }
.yearbars a.partial span { opacity: .4; }

/* landscape */
.landscape { width: 100%; height: 720px; }
.scroll-list { max-height: 760px; overflow-y: auto; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
table.gaps td { vertical-align: top; }

/* D3 networks (net.js) */
.net-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.net-find { width: 240px; }
.net-legend { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-bottom: 6px; }
.net-legend button { min-height: 0; padding: 2px 8px; font-size: 11.5px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; color: var(--ink); }
.net-legend button span { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.net-legend button small { color: var(--ink-muted); }
.net-legend button.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.net-stage { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: #fcfcfb; overflow: hidden; }
.net-stage svg { display: block; cursor: grab; }
.net-stage svg:active { cursor: grabbing; }
.net .links line { stroke: #7d837a; stroke-opacity: .5; transition: stroke-opacity .15s, stroke .15s; }
.net .links line.near { stroke: #1a1a1a; stroke-opacity: .7; }
.net .links line.dim { stroke-opacity: .04; }
.net .node circle { stroke: #fff; stroke-width: 1; transition: opacity .15s; }
.net .node circle.clickable { cursor: pointer; }
.net .labels .label { font: 600 10.5px var(--sans); fill: #1a1a1a; text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: rgba(255,255,255,.9); stroke-width: 3px; opacity: 0; transition: opacity .15s; }
.net .labels .label.always, .net .labels .label.near { opacity: 1; }
.net .labels .label.center { font-weight: 700; }
.net .node.dim circle { opacity: .12; }
.net .labels .label.dim { opacity: 0; }
.net .node.near circle { stroke: #1a1a1a; stroke-width: 1.2; }
.net-tip { position: absolute; display: none; pointer-events: none; background: #fff; border: 1px solid var(--line-strong);
  border-radius: 3px; padding: 5px 8px; font-size: 12px; max-width: 240px; box-shadow: 0 2px 6px rgba(0,0,0,.08); }

/* topic bars coloured by mean year (author page) */
.tbars { display: grid; grid-template-columns: minmax(0, 1fr) 150px 34px; gap: 4px 8px; align-items: center; font-size: 12.5px; }
.tbars .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbars .track { height: 12px; background: var(--surface-soft); border-radius: 2px; }
.tbars .fill { height: 100%; border-radius: 2px; }
.tbars .n { text-align: right; color: var(--ink-muted); }
.yearscale { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 11.5px; color: var(--ink-muted); }
.yearscale .grad { width: 160px; height: 8px; border-radius: 2px; }

/* search controls under a query box */
.searchbar { flex-wrap: wrap; }
.search-ctl { flex-basis: 100%; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-muted); }
.search-ctl input[type=number] { width: 64px; min-height: 25px; padding: 2px 6px; }
.search-ctl select { min-height: 25px; padding: 2px 4px; }
.search-ctl input[type=checkbox] { min-height: 0; vertical-align: -2px; }

/* map popup: the edit link is small and grey; anchors land below the sticky header */
.leaflet-popup a.pop-edit { color: #8a8f87; font-size: 11px; }
#location, #locations, #papers-map { scroll-margin-top: calc(var(--header, 120px) + 14px); }

/* a card whose chart fills the height left by its neighbour in the grid row */
.card.fill { display: flex; flex-direction: column; }
.card.fill .chart.grow { flex: 1 1 auto; height: auto; min-height: 300px; }
.html-legend { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 8px; }
.html-legend button { min-height: 0; padding: 2px 8px; font-size: 11.5px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; color: var(--ink); }
.html-legend button span { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.html-legend button.off { opacity: .4; text-decoration: line-through; }

/* a text filter inside a filter row sits on the row's line (no extra bottom margin) */
.filters .table-filter { margin-bottom: 0; }

/* the shared search panel (Papers, Experts, landscape) */
.search-panel { margin: 0 0 var(--gap); display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; }
.sp-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sp-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sp-row .sp-words { flex: 1 1 300px; min-height: 31px; padding: 4px 8px; background: var(--surface-soft); }
.sp-row select { min-height: 31px; }
.sp-row textarea.query { flex: 1 1 380px; min-height: 31px; margin: 0; padding: 5px 8px; }
.sp-sim { font-size: 12.5px; color: var(--ink-muted); white-space: nowrap; }
.sp-sim input[type=number] { width: 62px; min-height: 31px; }
/* row 1: words, field, years, documents · row 2: and/or, query, min similarity · row 3: selections, switches, button */
.sp-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sp-filters .ms { flex: 1 1 140px; max-width: 250px; }
.sp-ctl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex: 0 1 auto; margin-left: auto; font-size: 12.5px; }
.sp-when { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; }
.sp-when select { min-height: 31px; padding: 2px 4px; }
.sp-ctl select { min-height: 29px; padding: 2px 4px; }
.sp-ctl label { display: inline-flex; align-items: center; gap: 4px; margin: 0; color: var(--ink-muted); white-space: nowrap; }
.sp-ctl input[type=checkbox] { margin: 0; }
.sp-row textarea.query:placeholder-shown { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-ctl button.primary { min-height: 29px; padding: 3px 14px; }
.andor { display: inline-flex; align-items: baseline; gap: 6px; min-width: 52px; font-size: 13px; }
.andor label { cursor: pointer; color: var(--ink-muted); }
.andor label.on { color: var(--ink); font-weight: 700; }
.andor input { position: absolute; opacity: 0; width: 0; height: 0; }
.andor label:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 1px; }
.andor .sep { color: var(--line-strong); }
.ms { position: relative; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 29px; padding: 1px 4px;
  border: 1px solid var(--line-strong); border-radius: 2px; background: var(--surface); }
.ms .ms-q { flex: 1 1 100px; border: 0; min-height: 25px; padding: 2px 4px; background: transparent; }
.ms .ms-q:focus { outline: 0; }
.ms:focus-within { outline: 2px solid var(--blue); outline-offset: 1px; }
.ms-list { position: absolute; z-index: 50; left: -1px; right: -1px; top: 100%; max-height: 300px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.ms-list button { display: flex; justify-content: space-between; gap: 8px; width: 100%; min-height: 0; padding: 5px 8px;
  border: 0; border-radius: 0; background: none; text-align: left; }
.ms-list button:hover { background: var(--blue-soft); }
.ms-list .note { padding: 6px 8px; }
.chip .ms-x { min-height: 0; padding: 0 0 0 5px; border: 0; background: none; color: inherit; font-weight: 700; cursor: pointer; }
.sp-fixed { display: flex; flex-wrap: wrap; gap: 4px; }

/* priority scores (METHODOLOGY §10): one bar per priority, 0–1 */
.prio { width: 100%; border-collapse: collapse; }
.prio td { padding: 2px 4px; vertical-align: middle; }
.prio .pname { width: 48%; font-size: 12.5px; }
.prio .pbar { position: relative; height: 12px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 2px; }
.prio .pbar span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--blue); border-radius: 1px; }
.prio .pval { width: 1%; white-space: nowrap; text-align: right; font-size: 12px; color: var(--ink-muted); }
.heat td.h { text-align: center; font-size: 11.5px; padding: 3px 2px; min-width: 38px; }
.heat th.v { writing-mode: vertical-rl; transform: rotate(180deg); font-weight: 500; font-size: 11.5px; padding: 4px 2px; max-height: 170px; }

/* logins (app/auth.py): who is logged in, in the header; the login and set-password cards */
.whoami { order: 2; margin-left: auto; display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--ink-muted); }
.nav { order: 3; }
button.linkish { min-height: 0; padding: 0; border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; }
button.linkish:hover { text-decoration: underline; }
.auth-card { max-width: 420px; margin: 48px auto; }
.auth-card form { display: grid; gap: 12px; margin: 14px 0; }
.auth-card label { display: grid; gap: 4px; font-weight: 600; }
.auth-card input { width: 100%; font-weight: normal; }
.auth-card .auth-error { color: #b3261e; }
