:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --hover: #f0efe9;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6b6963;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, .10);
  --border-strong: rgba(11, 11, 11, .20);
  --border-focus: rgba(11, 11, 11, .45);   /* a selected text box: just a lighter border, no glow */
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: rgba(42, 120, 214, .10);
  --track: #e4edf9;
  --critical: #d03b3b;
  --shadow: 0 12px 32px rgba(0, 0, 0, .14);
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --hover: #262624;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #9a988f;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, .10);
    --border-strong: rgba(255, 255, 255, .20);
    --border-focus: rgba(255, 255, 255, .45);
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-wash: rgba(57, 135, 229, .16);
    --track: #1d2836;
    --critical: #e66767;
    --shadow: 0 12px 32px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --hover: #262624;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #9a988f;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, .10);
  --border-strong: rgba(255, 255, 255, .20);
  --border-focus: rgba(255, 255, 255, .45);
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --accent-wash: rgba(57, 135, 229, .16);
  --track: #1d2836;
  --critical: #e66767;
  --shadow: 0 12px 32px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
.home-link:hover, a.btn:hover { text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.sub { color: var(--ink-2); font-size: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar ---------- */
/* ---------- header (floating card: title + credit, menu in the blue bar) ---------- */
:root { --brand-font: Montserrat, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --hdr-bg: rgba(245, 245, 244, .8); --bar: #3563e9; --wm-yr: #3563e9; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --hdr-bg: rgba(30, 30, 29, .8); --bar: #2d52c9; --wm-yr: #86a5ff; } }
:root[data-theme="dark"] { --hdr-bg: rgba(30, 30, 29, .8); --bar: #2d52c9; --wm-yr: #86a5ff; }
.topbar { position: relative; z-index: 20; width: calc(100% - 32px); max-width: 1288px; margin: 10px auto 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--hdr-bg); -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px); box-shadow: 0 2px 10px rgba(0, 0, 0, .06); font-family: var(--brand-font); }
.hdr-main { display: flex; align-items: center; gap: 8px 18px; padding: 10px 12px 10px 18px; min-height: 62px; }
.brand { margin: 0; flex: none; font-size: inherit; font-weight: inherit; }
.home-link { color: var(--ink); text-decoration: none; white-space: nowrap; font-weight: 400; letter-spacing: .005em; }
.home-link:hover .wm { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
/* title line: "top-cited scientists | 2025 · 2024 · 2023"; fixed order, the year on show is coloured */
.brand-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 12px; min-width: 0; font-size: 22px; }
.brand-row .sep { color: var(--border-strong); font-weight: 300; }
.years { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.years a { font-weight: 700; color: var(--muted); text-decoration: none; }
.years a:hover { color: var(--ink-2); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.years a[aria-current] { color: var(--wm-yr); }
.years a[aria-current]:hover { color: var(--wm-yr); text-decoration: none; }
.years a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.years .dot { color: var(--muted); font-weight: 700; }
/* share icons, top right of the title row: small and muted, brighter on hover */
.share-row { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }
.s-ic { display: inline-flex; padding: 5px; border-radius: 6px; color: var(--muted); }
.s-ic:hover { color: var(--ink); }
.s-ic:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.tabs { display: flex; justify-content: flex-start; gap: 4px; background: var(--bar); padding: 6px 12px 6px 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
/* buttons in the app, links on the generated pages */
.tabs button, .tabs a { border: 0; background: none; padding: 6px 14px; border-radius: 7px; cursor: pointer; color: rgba(255, 255, 255, .88); white-space: nowrap; font: 500 15px var(--brand-font); text-decoration: none; }
.tabs button:hover, .tabs a:hover { color: #fff; background: rgba(255, 255, 255, .12); text-decoration: none; }
.tabs button[aria-selected="true"], .tabs a[aria-current] { color: #fff; font-weight: 700; background: rgba(255, 255, 255, .2); }
.tabs button:focus-visible, .tabs a:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; height: 32px; min-width: 32px; padding: 0 8px; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--hover); color: var(--ink); }

main { max-width: 1320px; margin: 0 auto; padding: 16px 16px 24px; }

/* ---------- buy me a coffee (floating, official button image) ---------- */
.bmc { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: block; line-height: 0; border-radius: 8px; transition: transform .15s ease; }
.bmc img { display: block; width: 178px; height: 50px; filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .25)); }
.bmc:hover { transform: translateY(-2px); }
.bmc:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.view[hidden] { display: none; }

/* ---------- search & filters ---------- */
/* finder: one panel on a soft grey gradient, a faint dot grid fading in from the top-right corner;
   the filters fill the row in equal columns so their edges line up with the search box */
:root { --finder-a: #fdfdfc; --finder-b: #ecebe7; --finder-sheen: rgba(255, 255, 255, .9); --finder-dot: rgba(11, 11, 11, .07); --finder-foot: rgba(11, 11, 11, .025); --field: #fff; --field-inset: inset 0 1px 2px rgba(0, 0, 0, .05); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --finder-a: #242423; --finder-b: #141413; --finder-sheen: rgba(255, 255, 255, .05); --finder-dot: rgba(255, 255, 255, .06); --finder-foot: rgba(0, 0, 0, .22); --field: #0f0f0f; --field-inset: inset 0 1px 3px rgba(0, 0, 0, .45); } }
:root[data-theme="dark"] { --finder-a: #242423; --finder-b: #141413; --finder-sheen: rgba(255, 255, 255, .05); --finder-dot: rgba(255, 255, 255, .06); --finder-foot: rgba(0, 0, 0, .22); --field: #0f0f0f; --field-inset: inset 0 1px 3px rgba(0, 0, 0, .45); }
.finder, .sheet-head { position: relative; z-index: 5; isolation: isolate; background: radial-gradient(90% 120% at 50% -20%, var(--finder-sheen), transparent 70%), linear-gradient(180deg, var(--finder-a), var(--finder-b)); box-shadow: inset 0 1px 0 var(--finder-sheen); }
.finder::before, .sheet-head::before, .about::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none; background: radial-gradient(circle, var(--finder-dot) 1px, transparent 1.5px) 0 0 / 16px 16px; -webkit-mask-image: radial-gradient(55% 140% at 100% 0%, #000, transparent 75%); mask-image: radial-gradient(55% 140% at 100% 0%, #000, transparent 75%); }
.finder { margin-bottom: 14px; padding: 18px 18px 0; border: 1px solid var(--border); border-radius: 12px; box-shadow: inset 0 1px 0 var(--finder-sheen), 0 2px 10px rgba(0, 0, 0, .06); }
.search { position: relative; }
.search input { width: 100%; height: 52px; padding: 0 48px 0 46px; font-size: 16.5px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--field); box-shadow: var(--field-inset); outline: none; transition: border-color .15s, box-shadow .15s; }
.search input:focus { border-color: var(--border-focus); }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search:focus-within svg { color: var(--ink-2); }
.search kbd { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font: 12px ui-monospace, monospace; color: var(--muted); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 1px 7px; background: var(--surface-2); }
.filters { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.filters select, .filters input[type="text"], .sheet-tools select, .sheet-tools input[type="text"] { height: 36px; width: 100%; max-width: 100%; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--field); box-shadow: var(--field-inset); }
.filters select:focus, .filters input[type="text"]:focus, .sheet-tools select:focus, .sheet-tools input[type="text"]:focus { outline: none; border-color: var(--border-focus); }
.filters select, .sheet-tools select { min-width: 0; appearance: none; -webkit-appearance: none; padding-right: 26px; cursor: pointer; }
.filters .combo::after, .filters .pick::after, .sheet-tools .combo::after { top: 13px; }
.filters .combo-list, .sheet-tools .combo-list { top: 40px; }
.pick { position: relative; min-width: 0; }
.pick::after { content: ""; position: absolute; right: 12px; top: 12px; width: 6px; height: 6px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); pointer-events: none; }
/* type-to-search dropdown (Country, Field, Subfield): a text box that filters a hidden <select> */
.combo { position: relative; }
.combo input[type="text"] { width: 100%; padding-right: 26px; cursor: pointer; }
.combo input[type="text"]:focus { cursor: text; }
.combo input::placeholder { color: var(--ink); opacity: 1; }
.combo input:focus::placeholder { color: var(--muted); }
.combo::after { content: ""; position: absolute; right: 12px; top: 12px; width: 6px; height: 6px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); pointer-events: none; }
.combo-list { position: absolute; top: 38px; left: 0; z-index: 30; min-width: 100%; width: max-content; max-width: min(380px, calc(100vw - 32px)); max-height: min(360px, 60vh); overflow-y: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; }
.combo-list[hidden] { display: none; }
.combo-list.flip { left: auto; right: 0; }
.combo-list .grp { padding: 8px 10px 3px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.combo-list [role="option"] { padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.combo-list [role="option"].active { background: var(--hover); }
.combo-list [role="option"][aria-selected="true"] { color: var(--accent-ink); font-weight: 600; }
.combo-list .none { padding: 8px 10px; color: var(--ink-2); font-size: 12px; }
.info-line { display: flex; gap: 8px; align-items: baseline; font-size: 13px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; margin-bottom: 10px; }
.info-line[hidden] { display: none; }
.info-line .i { color: var(--accent-ink); font-weight: 700; }
.tile.wide { grid-column: 1 / -1; }
.check { display: inline-flex; gap: 6px; align-items: center; padding: 0 4px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.link-btn { border: 0; background: none; color: var(--accent-ink); cursor: pointer; padding: 4px; }
.link-btn:hover { text-decoration: underline; }
.btn { height: 34px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); padding: 0 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.finder .info-line { margin: 12px 0 0; background: var(--accent-wash); border-color: transparent; }
/* panel footer: result count on the left, Reset on the right */
.summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; align-items: center; margin: 14px -18px 0; padding: 9px 18px; border-top: 1px solid var(--border); border-radius: 0 0 11px 11px; background: var(--finder-foot); color: var(--ink-2); font-size: 13px; }
.summary strong { color: var(--ink); font-size: 14px; }
.summary .link-btn { padding: 2px 4px; margin: 0 -4px 0 auto; }
/* shown while the data file loads; the pre-filled first page stays visible meanwhile */
.load-note { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.load-note[hidden] { display: none; }
.spin-sm { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--track); border-top-color: var(--accent); animation: spin .9s linear infinite; flex: none; }

/* ---------- tables ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 600; font-size: 12px; color: var(--ink-2); padding: 0; border-bottom: 1px solid var(--grid); white-space: nowrap; background: var(--surface); }
.tbl th > span, .tbl th > button { display: block; padding: 10px 10px; }
.tbl th > button { border: 0; background: none; width: 100%; text-align: inherit; cursor: pointer; font-weight: 600; color: inherit; font-size: 12px; }
.tbl th > button:hover { color: var(--ink); }
.tbl th.num { text-align: right; }
.tbl th[aria-sort="ascending"] > button::after { content: " ↑"; color: var(--accent-ink); }
.tbl th[aria-sort="descending"] > button::after { content: " ↓"; color: var(--accent-ink); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover, .tbl tbody tr.clickable:focus-visible { background: var(--hover); outline: none; }
.tbl tbody tr.selected { background: var(--accent-wash); }
.tbl .nm { font-weight: 600; }
.tbl .rank { color: var(--ink); font-weight: 600; }
.tbl td.who { min-width: 220px; }
.tbl td.sf { min-width: 180px; max-width: 260px; }
.flag { font-size: 15px; line-height: 1; }
.empty { padding: 48px 16px; text-align: center; color: var(--ink-2); }
/* pager: page buttons centred under the table */
.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px 16px; margin-top: 12px; color: var(--ink-2); }
.pager-nav { grid-column: 2; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
/* space between the Authors table and its pager (the footer is 48px below the pager) */
.view > .pager { margin-top: 35px; }
.pager-nav span { padding: 0 4px; }
.pager button { height: 32px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; padding: 0 12px; cursor: pointer; }
.pager button:disabled { opacity: .45; cursor: default; }
.inline-bar { display: flex; align-items: center; gap: 8px; min-width: 160px; }
.inline-bar .bar { height: 8px; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
.inline-bar .v { min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }
tr.group td { background: var(--surface-2); font-weight: 600; color: var(--ink); }
/* sheet: Countries, Institutions and Fields as one card; the finder's gradient head (title, count, filter, search) runs into the table */
.sheet { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 2px 10px rgba(0, 0, 0, .06); }
.sheet-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px 16px; padding: 16px 18px 18px; border-bottom: 1px solid var(--border); border-radius: 11px 11px 0 0; }
.sheet-title { flex: 1 1 320px; min-width: 0; }
.sheet-title h1, .sheet-title h2 { margin: 0; font: 600 18px var(--brand-font); letter-spacing: -.005em; }
.sheet-title h1 { font-size: 22px; letter-spacing: -.01em; }
.sheet-title .sub { margin-top: 3px; font-size: 13px; }
.sheet-tools { display: flex; gap: 8px; }
.sheet-head .search { flex-basis: 100%; }
.sheet-head .search input { height: 46px; font-size: 15.5px; padding-right: 16px; }
.sheet > .table-wrap:last-child { border-radius: 0 0 11px 11px; }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px 18px; border-top: 1px solid var(--grid); border-radius: 0 0 11px 11px; background: var(--finder-foot); }
.sheet-foot p { margin: 0; flex: 1 1 320px; }
.sheet-tools .pick { width: 240px; }

/* ---------- detail drawer ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 70; opacity: 0; pointer-events: none; transition: opacity .18s; }
.backdrop.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(600px, 100vw); background: var(--surface); z-index: 80; box-shadow: var(--shadow); transform: translateX(105%); transition: transform .22s ease, width .32s ease; display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.drawer.wide { width: 100vw; }
.pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.pane[hidden] { display: none; }
.pane-compare .modal-body { flex: 1; min-height: 0; }
.drawer.open { transform: none; }
.drawer-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; }
.drawer-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.drawer-head .grow { flex: 1; min-width: 0; }
.drawer-body { overflow-y: auto; padding: 16px; flex: 1; }
.drawer-body section { margin-bottom: 22px; }
.drawer-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); margin: 0 0 10px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2); }
button.chip { cursor: pointer; }
button.chip:hover { color: var(--ink); border-color: var(--border-strong); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--page); }
.tile .label { font-size: 12px; color: var(--ink-2); }
.tile .value { font-size: 24px; font-weight: 650; margin-top: 2px; letter-spacing: -.01em; }
.tile .note { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.cscore { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.cscore .big { font-size: 30px; font-weight: 650; letter-spacing: -.02em; }
.bars { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; }
.bars .lbl { font-size: 13px; }
.bars .lbl .sub { display: block; }
.bars .track { height: 10px; background: var(--track); border-radius: 0 4px 4px 0; }
.bars .fill { height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.bars .val { font-variant-numeric: tabular-nums; text-align: right; font-size: 13px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini th, .mini td { padding: 6px 8px; border-bottom: 1px solid var(--grid); text-align: left; }
.mini th { color: var(--ink-2); font-weight: 600; font-size: 12px; }
.mini td.num, .mini th.num { text-align: right; }
.mini tr:last-child td { border-bottom: 0; }
.mini .hl { background: var(--accent-wash); font-weight: 600; }
.note-box { font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-top: 8px; }
.fix-tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; font-size: 10.5px; font-weight: 600; line-height: 16px; vertical-align: 1px; color: var(--accent-ink); background: var(--accent-wash); cursor: help; }
.note-box.fix { margin: 10px 0 0; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.status.critical { color: var(--critical); }
.links { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- site footer (every page): name and blurb left, link columns right, as on datascienceplus.com ---------- */
/* the body is a column so the footer sits at the bottom of short pages */
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; width: 100%; }
.site-foot { margin-top: 24px; border-top: 1px solid var(--border); background: linear-gradient(180deg, var(--finder-b), var(--page)); }
.foot-inner { width: calc(100% - 32px); max-width: 1288px; margin: 0 auto; padding: 36px 2px calc(28px + env(safe-area-inset-bottom)); font-size: 13px; color: var(--muted); }
.foot-inner a { color: var(--muted); }
.foot-inner a:hover { color: var(--ink); text-decoration: none; }
.foot-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 30px 60px; padding-bottom: 28px; }
.foot-about { max-width: 380px; }
.foot-inner .foot-brand { color: var(--ink); font: 400 17px var(--brand-font); letter-spacing: .005em; }
.foot-about p { margin: 12px 0 0; line-height: 1.65; }
.foot-cols { display: flex; flex-wrap: wrap; gap: 30px 56px; }
.foot-col { display: flex; flex-direction: column; gap: 9px; min-width: 120px; }
.foot-col h2 { margin: 0 0 3px; color: var(--ink); font: 600 13px var(--brand-font); }
.foot-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12.5px; }
.foot-bottom span:last-child { text-align: right; }   /* the disclaimer, right of the © line (under it, left-aligned, on a phone) */

/* ---------- generated pages: country, institution, field, subfield, author ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 2px 10px; font-size: 12.5px; color: var(--muted); }
.crumbs a { color: var(--ink-2); }
.sheet-body { padding: 16px 18px 18px; border-bottom: 1px solid var(--border); }
.lede { margin: 0 0 14px; max-width: 880px; color: var(--ink-2); font-size: 14px; }
.lede strong { color: var(--ink); }
.tiles.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile .value a { color: inherit; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px 28px; margin-top: 18px; }
.facts h2 { margin: 0 0 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.facts ol, .facts ul { margin: 0; padding-left: 22px; }
.facts li { margin: 3px 0; }
.facts li .sub { margin-left: 4px; }
.sheet-body:last-child { border-bottom: 0; }
.sheet-body + .sheet-foot { border-top: 0; color: var(--ink-2); }
.sheet-foot strong { color: var(--ink); }
.sheet-foot > a { font-weight: 600; }
.lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px; margin-top: 8px; }
.rank-list { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px 12px; background: var(--page); }
.rank-list h2 { margin: 0 0 6px; font-size: 12px; font-weight: 400; color: var(--ink-2); }
.rank-list ol { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; margin: 0; padding: 0; list-style: none; }
.rank-list .row { display: flex; align-items: baseline; gap: 10px; }
.rank-list .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .t a { color: var(--ink); text-underline-offset: 2px; }
.rank-list .t a:hover { color: var(--accent-ink); }
.rank-list .n { font-weight: 600; font-variant-numeric: tabular-nums; }
.rank-list .p { width: 3.2em; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.rank-list .bar { height: 4px; margin-top: 4px; border-radius: 2px; background: var(--track); }
.rank-list .bar i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.tbl a.go { color: inherit; }
.tbl td.nm { overflow-wrap: anywhere; }   /* Institutions: a long one-word name must not widen the table on a phone */
.tbl a.go:hover { color: var(--accent-ink); }
/* a count with a bar (Countries, Institutions); --w is the share of the largest */
.ib { white-space: nowrap; }
.ib span { display: inline-block; min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; vertical-align: middle; }
.ib i { display: inline-block; vertical-align: middle; width: calc(var(--w) * 200px); min-width: 2px; height: 8px; margin-left: 8px; background: var(--accent); border-radius: 0 4px 4px 0; }
.tbl .nm a { color: var(--ink); }
.tbl .nm a:hover { color: var(--accent-ink); }
.tbl td a { text-underline-offset: 2px; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.sheet-head .btn.primary { height: 36px; }
.author-sec { margin-top: 22px; }
.author-sec h2 { margin: 0 0 10px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }

/* ---------- loading / about ---------- */
.loader { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--page); }
.loader[hidden] { display: none; }
.loader .box { width: min(440px, calc(100vw - 32px)); text-align: center; }
.loader .spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--track); border-top-color: var(--accent); animation: spin 0.9s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader .err { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.loader code, .about code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
/* About and Data tabs: same rounded box as the tables, text kept to a readable line length inside it */
/* the finder's gradient across the top of the box, settling to its end colour for the long text below */
.about { position: relative; isolation: isolate; border: 1px solid var(--border); border-radius: 12px; padding: 24px 28px 28px; background: radial-gradient(90% 120% at 50% -20%, var(--finder-sheen), transparent 70%) 0 0 / 100% 240px no-repeat, linear-gradient(180deg, var(--finder-a), var(--finder-b) 320px); box-shadow: inset 0 1px 0 var(--finder-sheen), 0 2px 10px rgba(0, 0, 0, .06); }
.about::before { bottom: auto; height: 260px; }
.about > * { max-width: 900px; }
.about code { overflow-wrap: anywhere; }
.about h2 { font-size: 18px; margin: 24px 0 8px; }
.about h2:first-child { margin-top: 0; }
.about p, .about li { color: var(--ink-2); }
.about dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.about dt { font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.about dd { margin: 0; color: var(--ink-2); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--page); padding: 8px 14px; border-radius: 8px; z-index: 120; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

/* ---------- compare ---------- */
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn[aria-pressed="true"] { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-ink); }
.modal-head { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0 auto 0 0; font-size: 18px; }
.modal-body { overflow: auto; }
.modal-foot { padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--ink-2); }
.cmp-add { position: relative; }
.cmp-add input { height: 34px; width: 280px; max-width: 100%; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); padding: 0 10px; }
.cmp-add input:focus { outline: none; border-color: var(--border-focus); }
.suggest { position: absolute; top: 40px; left: 0; width: 400px; max-width: calc(100vw - 48px); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); z-index: 5; padding: 4px; }
.suggest[hidden] { display: none; }
.suggest button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.suggest button:hover, .suggest button:focus-visible { background: var(--hover); outline: none; }
.suggest button:disabled { opacity: .5; cursor: default; }
.suggest .sub { display: block; }
table.cmp { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.cmp th, .cmp td { padding: 8px 12px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; min-width: 170px; }
.cmp th:first-child, .cmp td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 150px; width: 190px; color: var(--ink-2); }
.cmp thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); vertical-align: top; border-bottom: 1px solid var(--axis); }
.cmp thead th:first-child { z-index: 3; }
.cmp tr.sec td { background: var(--surface-2); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); padding-top: 6px; padding-bottom: 6px; }
.cmp .v { font-variant-numeric: tabular-nums; color: var(--ink); }
.cmp td.best { background: var(--accent-wash); }
.cmp td.best .v { font-weight: 700; }
.cmp .best-tag { font-size: 11px; font-weight: 600; color: var(--accent-ink); margin-left: 6px; }
.cmp .mbar { height: 6px; background: var(--track); border-radius: 0 3px 3px 0; margin-top: 5px; max-width: 220px; }
.cmp .mbar > span { display: block; height: 100%; background: var(--accent); border-radius: 0 3px 3px 0; min-width: 2px; }
.cmp .who-h .nm { font-size: 14.5px; font-weight: 650; color: var(--accent-ink); text-align: left; padding: 0; }
.cmp-empty { padding: 48px 16px; text-align: center; color: var(--ink-2); }
.drawer-head .btn { height: 28px; padding: 0 10px; font-size: 12.5px; flex: none; margin-top: 2px; }

@media (max-width: 980px) {
  .hide-md { display: none; }
  /* filters on two rows: three on top, two below, still edge to edge */
  .filters { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  #f-country-box, #f-field-box, #f-sf-box { grid-column: span 2; }
  #f-stage-box, #f-inst { grid-column: span 3; }
}
@media (max-width: 720px) {
  .hide-sm { display: none; }
  .search kbd { display: none; }
  .finder { padding: 12px 12px 0; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #f-country-box, #f-field-box, #f-sf-box, #f-stage-box { grid-column: auto; }
  #f-inst { grid-column: 1 / -1; }
  .summary { margin: 12px -12px 0; padding: 8px 12px; }
  .sheet-head { padding: 12px 12px 14px; }
  .sheet-tools { flex-basis: 100%; }
  .sheet-tools .pick { width: 100%; }
  .foot-bottom span:last-child { text-align: left; }
  .ib i { width: calc(var(--w) * 80px); }
  .sheet-foot { padding: 10px 12px; }
  .pager { grid-template-columns: 1fr; justify-items: center; }
  .pager-nav { grid-column: 1; justify-self: center; }
  .tbl td.who { min-width: 160px; }
  .bars { grid-template-columns: minmax(0, 1fr) 30% auto; }
  .about dl { grid-template-columns: 1fr; }
  .about { padding: 18px 16px 20px; }
}
@media (max-width: 720px) {
  .cmp-add, .cmp-add input { width: 100%; }
  .cmp th, .cmp td { min-width: 140px; }
  .cmp th:first-child, .cmp td:first-child { min-width: 110px; width: 110px; }
  .modal-foot { display: none; }
}
@media (max-width: 720px) {
  .topbar { margin-top: 8px; }
  .hdr-main { padding: 8px 10px 8px 14px; gap: 2px 12px; }
  .brand-row { font-size: 19px; }
  .tabs { justify-content: flex-start; padding: 5px 8px; }
  .tabs button, .tabs a { padding: 5px 10px; font-size: 14.5px; }
}
@media (max-width: 520px) {
  .hide-xs { display: none; }
  .ib span { min-width: 0; }
  .ib i { width: calc(var(--w) * 36px); margin-left: 6px; }
  /* profile header: buttons on their own row so the name and affiliation get the full width */
  .drawer-head { flex-wrap: wrap; row-gap: 8px; }
  .drawer-head .grow { order: 1; flex-basis: 100%; }
  .drawer-head #d-compare { margin-left: auto; }
  .tiles.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .foot-cols { gap: 26px 36px; }
  .foot-col { min-width: 130px; }
  .bmc { right: 12px; bottom: 12px; }
  .bmc img { width: 143px; height: 40px; }
  .brand-row { font-size: 17px; }
  .brand-row .sep { display: none; }   /* the years wrap onto their own line here */
  .years { flex-basis: 100%; }
  /* six tabs on one line: the text shrinks with the screen (13.5px at 414+, 12px at 360) */
  .tabs { gap: 0; padding: 5px 2px; justify-content: space-between; }
  .tabs button, .tabs a { padding: 5px 3px; font-size: clamp(10.5px, calc(4.2vw - 3.4px), 13.5px); }
}
@media (max-width: 380px) {
  .brand-row { font-size: 16px; }
}
@media print { .bmc { display: none; } }
@media (prefers-reduced-motion: reduce) { .drawer, .backdrop, .toast, .bmc { transition: none; } .loader .spin { animation-duration: 3s; } }
