:root {
  color-scheme: light dark;
  /* "Glass" panel tokens — cards sit as translucent panels over the fixed
     starfield/photo background (see body::before/::after below), so these
     are alpha colors rather than solid ones. Light/dark toggle changes how
     opaque/tinted the glass is, not the backdrop itself. */
  --bg: transparent;
  --bg-elev: #ffffff;
  --bg-elev-2: #f6f1e6;
  --text: #14161f;
  --text-dim: #4c5170;
  --border: rgba(20, 22, 31, 0.12);
  --accent: #c9670c;
  --accent-text: #ffffff;
  --accent-soft: #fbe6cf;
  --link: #1d6fbf;
  --planet: #1d6fbf;
  --bdplanet: #8a5a2b;
  --ffp: #5b3fa0;
  --row-hover: rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(20, 22, 31, 0.1), 0 8px 24px rgba(20, 22, 31, 0.08);
  --glass-blur: blur(14px);
  /* Opaque (no blur) - a sticky element repainting backdrop-filter on every
     scroll tick is a well-known source of scroll jank, so the table's sticky
     header uses this instead of --bg-elev-2 + blur. */
  --sticky-header-bg: var(--bg-elev-2);
  --radius: 10px;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

:root:not([data-theme="light"]) {
  @media (prefers-color-scheme: dark) {
    --bg-elev: rgba(18, 20, 30, 0.68);
    --bg-elev-2: rgba(255, 255, 255, 0.06);
    --text: #eef1fb;
    --text-dim: #aab0d0;
    --border: rgba(255, 255, 255, 0.14);
    --accent: #e08a2c;
    --accent-text: #191008;
    --accent-soft: #3a2a14;
    --link: #6fb3f2;
    --planet: #6fb3f2;
    --bdplanet: #e0b070;
    --ffp: #b79cf0;
    --row-hover: rgba(255, 255, 255, 0.06);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.35);
    --sticky-header-bg: rgba(18, 20, 30, 0.92);
  }
}

:root[data-theme="dark"] {
  --bg-elev: rgba(18, 20, 30, 0.68);
  --bg-elev-2: rgba(255, 255, 255, 0.06);
  --text: #eef1fb;
  --text-dim: #aab0d0;
  --border: rgba(255, 255, 255, 0.14);
  --accent: #e08a2c;
  --accent-text: #191008;
  --accent-soft: #3a2a14;
  --link: #6fb3f2;
  --planet: #6fb3f2;
  --bdplanet: #e0b070;
  --ffp: #b79cf0;
  --row-hover: rgba(255, 255, 255, 0.06);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.35);
  --sticky-header-bg: rgba(18, 20, 30, 0.92);
}

* { box-sizing: border-box; }

html { background: #05060f; }

body {
  margin: 0;
  /* Explicitly transparent (not just omitted) so a host page that stamps its
     own default body background (e.g. an embedding preview) can't paint in
     front of the fixed body::before/::after backdrop layers below - they're
     negative z-index descendants of a non-stacking-context body, so any
     opaque body fill hides them entirely. html's background is the
     fallback behind everything. */
  background: transparent;
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: 0 max(16px, env(safe-area-inset-left)) 48px max(16px, env(safe-area-inset-right));
  min-height: 100vh;
}

/* ---------- Fixed deep-space backdrop ---------- */
/* Behind the whole page (not just the hero), so every panel reads as a
   glass card floating over the sky. The last background-image layer is a
   real KMTNet night-sky photo (Milky Way over a KMTNet dome, cropped to
   sky only); the color glows and dark veil above it stay translucent so
   the photo shows through while keeping text legible. */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  z-index: -2;
  background-image:
    radial-gradient(ellipse 55% 45% at 12% 10%, rgba(130, 110, 255, 0.32), transparent 60%),
    radial-gradient(ellipse 45% 35% at 90% 5%, rgba(224, 138, 44, 0.22), transparent 60%),
    radial-gradient(ellipse 60% 50% at 65% 100%, rgba(60, 150, 220, 0.2), transparent 60%),
    linear-gradient(180deg, rgba(5, 6, 15, 0.55) 0%, rgba(10, 13, 30, 0.68) 45%, rgba(18, 22, 44, 0.85) 100%),
    url("../images/milkyway-bg.jpg");
  /* The photo stretches to fill the page width and reaches down to just
     above the stat-card row (measured ~444px on a typical 900px-tall
     desktop viewport) — a mild vertical enlargement from its native
     400px. Below it, the gradient/star layers show through as the
     original synthetic backdrop. */
  background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 440px;
  background-position: 0 0, 0 0, 0 0, 0 0, center top;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

body::after {
  z-index: -1;
  opacity: 0.8;
  background-image:
    radial-gradient(1px 1px at 6% 12%, #fff, transparent 60%),
    radial-gradient(1px 1px at 14% 38%, #fff, transparent 60%),
    radial-gradient(1px 1px at 22% 74%, #cfe0ff, transparent 60%),
    radial-gradient(1px 1px at 31% 22%, #fff, transparent 60%),
    radial-gradient(1px 1px at 39% 58%, #fff, transparent 60%),
    radial-gradient(1px 1px at 47% 88%, #cfe0ff, transparent 60%),
    radial-gradient(1px 1px at 55% 15%, #fff, transparent 60%),
    radial-gradient(1px 1px at 63% 46%, #fff, transparent 60%),
    radial-gradient(1px 1px at 71% 80%, #fff, transparent 60%),
    radial-gradient(1px 1px at 79% 28%, #cfe0ff, transparent 60%),
    radial-gradient(1px 1px at 87% 64%, #fff, transparent 60%),
    radial-gradient(1px 1px at 95% 10%, #fff, transparent 60%),
    radial-gradient(1px 1px at 4% 92%, #fff, transparent 60%),
    radial-gradient(1.6px 1.6px at 18% 55%, #fff, transparent 65%),
    radial-gradient(1.6px 1.6px at 36% 95%, #fff, transparent 65%),
    radial-gradient(1.6px 1.6px at 58% 33%, #fff, transparent 65%),
    radial-gradient(1.6px 1.6px at 76% 68%, #fff, transparent 65%),
    radial-gradient(1.6px 1.6px at 92% 40%, #fff, transparent 65%),
    radial-gradient(1.6px 1.6px at 9% 66%, #fff, transparent 65%);
  background-size: 100% 100%;
  background-attachment: fixed;
}

a { color: var(--link); }

.wrap {
  max-width: 1320px;
  margin: 0 auto;
}

/* Frosted-glass panel: shared look for every card floating over the sky. */
.glass {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 4px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 0.2px;
  color: #ffffff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

.brand-title a {
  color: inherit;
  text-decoration: none;
}

.brand-icons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.brand-emblem {
  height: 54px;
  width: auto;
  display: block;
  flex: none;
}

.topbar nav {
  display: flex;
  gap: 6px;
  align-items: center;
}

.topbar nav a {
  color: #b9bfdd;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13.5px;
}

.topbar nav a:hover { background: var(--bg-elev-2); color: #ffffff; }

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
}

/* ---------- Hero ---------- */
/* No background of its own any more — the fixed starfield behind the whole
   page (body::before/::after) shows straight through, so the hero is just
   text, always light-colored since the backdrop is reliably dark. */
.hero {
  padding: 28px 4px 24px;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.hero-copy { flex: 1 1 auto; min-width: 0; }

.hero-mascot-wrap {
  position: relative;
  flex: none;
  /* .hero has 4px of side padding that the table/chart cards below don't,
     so nudge the mascot+bubble group right by that same 4px - lines their
     right edges up with the table's right edge instead of sitting 4px short. */
  transform: translateX(4px);
}

.hero-mascot {
  height: 140px;
  width: auto;
  display: block;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.35));
}

.hero-mascot-link {
  display: block;
  transition: transform 0.15s ease;
}

.hero-mascot-link:hover,
.hero-mascot-link:focus-visible {
  transform: translateY(-3px);
}

.mascot-bubble {
  /* Anchored from the right (the mascot sits near the page's right edge), so
     a longer message grows leftward into free space instead of overflowing
     past the viewport edge. Anchored from the bottom too - near the top of
     Kensy's head - so a message that wraps to two lines grows further up
     instead of down into the character. */
  position: absolute;
  bottom: 96px;
  right: 0;
  max-width: min(280px, 60vw);
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  white-space: normal;
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.mascot-bubble::after {
  content: "";
  position: absolute;
  bottom: -7px;
  right: 24px;
  width: 14px;
  height: 14px;
  background: inherit;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
  border-bottom-right-radius: 3px;
}

@media (max-width: 720px) {
  .hero-top { flex-direction: column; align-items: flex-start; }
  .hero-mascot-wrap { align-self: center; transform: none; }
  .hero-mascot { height: 100px; }
  .mascot-bubble { left: 50%; right: auto; bottom: 68px; transform: translateX(-50%); }
  .mascot-bubble::after { left: 50%; right: auto; margin-left: -7px; }
}

/* A little hop whenever the theme switches - Kensy reacting to the light change. */
@keyframes mascotHop {
  0% { transform: translateY(0) rotate(0deg) scale(1); }
  30% { transform: translateY(-10px) rotate(-8deg) scale(1.05); }
  55% { transform: translateY(2px) rotate(6deg) scale(0.97); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}

.mascot-hop { animation: mascotHop 0.5s ease; }

@media (prefers-reduced-motion: reduce) {
  .mascot-hop { animation: none; }
}

/* ---------- Floating mascot (back-to-top) ---------- */
.mascot-fab {
  position: fixed;
  /* left/top are set from JS, near the cursor's last known position, so it
     appears where the mouse already is instead of a fixed page corner. */
  left: 0;
  top: 0;
  width: 56px;
  height: 56px;
  padding: 6px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  cursor: pointer;
  z-index: 60;
  opacity: 0;
  transform: translateY(14px) scale(0.85);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.mascot-fab.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.mascot-fab:hover { transform: translateY(-2px) scale(1.05); }

.mascot-fab img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.hero h1 {
  font-size: clamp(24px, 4vw, 34px);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  color: #ffffff;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
}

.hero p {
  color: #cdd2ec;
  max-width: 780px;
  margin: 0 0 24px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}

.hero p a { color: #8ec8ff; }
.hero p a:hover { color: #b7ddff; }

.stat-grid {
  display: grid;
  /* Fixed at 5 columns (the original card count) rather than auto-fit, so a
     row showing fewer cards keeps the same per-card width as a full row —
     the extra columns just stay empty instead of the cards stretching wider. */
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.stat-grid-secondary {
  margin-top: 10px;
}

#papersCard {
  /* Discovery papers has an extra title line, so it's naturally taller than
     the rest. A negative top margin removes that extra height from the
     grid row's own auto-sizing (so the row and its other four cards stay
     exactly as before) while visually pushing the card upward, overlapping
     into the row above, instead of growing the row itself. */
  margin-top: -22px;
  position: relative;
}

.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.stat-card .num {
  font-size: 21px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stat-card .num-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 1px;
}

.stat-card .label {
  color: var(--text-dim);
  font-size: 11.5px;
  margin-top: 2px;
}

/* ---------- Chart ---------- */
.chart-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 8px;
  margin: 20px 0;
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.chart-card h2 {
  font-size: 14px;
  margin: 0 0 4px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chart-note {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 0 10px;
}

.mass-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.mass-grid-compact {
  margin: 0 0 16px;
}

.mass-grid .stat-card { box-shadow: none; }

@media (max-width: 720px) {
  .mass-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
}

.data-chart { width: 100%; height: auto; display: block; }
.data-chart .bar { fill: var(--planet); }
.data-chart text { fill: var(--text-dim); font-size: 9.5px; font-family: var(--font-mono); }
.data-chart .bar-label { fill: var(--text); font-size: 9.5px; font-weight: 600; pointer-events: none; }
.data-chart .axis-line { stroke: var(--border); stroke-width: 1; }
.data-chart .bar-hit { fill: transparent; }
.data-chart .year-group:hover .bar-hit,
.data-chart .hist-group:hover .bar-hit { fill: color-mix(in srgb, var(--text) 8%, transparent); }

.data-chart .grid-line { stroke: var(--border); stroke-width: 1; opacity: 0.6; }
.data-chart .axis-title { fill: var(--text-dim); font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em; }
.data-chart .point { fill: var(--planet); fill-opacity: 0.8; stroke: var(--bg-elev); stroke-width: 0.5; r: 4; transition: r 120ms ease, fill-opacity 120ms ease; }
.data-chart .scatter-group { cursor: pointer; }
.data-chart .scatter-group:hover .point { r: 6; fill-opacity: 1; }

.data-chart .line { stroke-width: 2; fill: none; }
.data-chart .cum-line { stroke: var(--planet); }
.data-chart .pct-line { stroke: var(--accent); stroke-dasharray: 4 2; }
.data-chart .line-point { stroke: var(--bg-elev); stroke-width: 1; transition: r 120ms ease; }
.data-chart .cum-point { fill: var(--planet); }
.data-chart .pct-point { fill: var(--accent); }
.data-chart .line-point-group:hover .line-point { r: 5; }
.data-chart .pct-label { fill: var(--accent); }

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 2px 12px;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend .csv-link { margin-left: auto; text-decoration: none; }
.legend .csv-link:hover { text-decoration: underline; }

/* ---------- Controls ---------- */
.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 22px 0 10px;
}

.controls input[type="search"],
.controls select {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13.5px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.controls input[type="search"] { flex: 1 1 220px; min-width: 160px; }
.controls input[type="search"]::placeholder { color: var(--text-dim); }

.controls .count {
  margin-left: auto;
  color: #d3d7ef;
  font-size: 13px;
  white-space: nowrap;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.btn {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.btn:hover { background: var(--bg-elev-2); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

/* ---------- Table ---------- */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

table.data {
  border-collapse: collapse;
  width: 100%;
  min-width: 980px;
  font-size: 13px;
}

table.data thead th {
  position: sticky;
  top: 0;
  /* Opaque, no backdrop-filter: a blurred sticky element has to repaint the
     blur every scroll frame, which is what made scrolling the year-bar
     popup's table feel sluggish. */
  background: var(--sticky-header-bg);
  text-align: center;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  color: var(--text-dim);
}

table.data thead th.col-name { text-align: left; }

table.data thead th:hover { color: var(--text); }

table.data thead th .arrow { opacity: 0.5; margin-left: 3px; font-size: 10px; }
table.data thead th.sorted .arrow { opacity: 1; color: var(--accent); }

table.data thead th .col-label { display: block; }
table.data thead th .col-unit {
  display: block;
  font-weight: 400;
  font-size: 10.5px;
  opacity: 0.7;
  margin-top: 1px;
}


.disk-bulge { cursor: help; }

table.data tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

table.data tbody td.col-name { text-align: left; }

table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: var(--row-hover); }
table.data tbody tr:last-child td { border-bottom: none; }

table.data tbody tr:has(.empty-state) { cursor: default; }
table.data tbody tr:has(.empty-state):hover { background: none; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 36px 16px;
  white-space: normal;
}

.empty-state img { height: 72px; width: auto; }

.empty-state p {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
}

.name-cell strong { font-family: var(--font-mono); font-weight: 600; }
.name-cell .host { display: block; font-size: 11px; color: var(--text-dim); }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}
.pill.planet { color: var(--planet); background: color-mix(in srgb, var(--planet) 14%, transparent); border-color: color-mix(in srgb, var(--planet) 35%, transparent); }
.pill.bdplanet { color: var(--bdplanet); background: color-mix(in srgb, var(--bdplanet) 16%, transparent); border-color: color-mix(in srgb, var(--bdplanet) 35%, transparent); }
.pill.ffp { color: var(--ffp); background: color-mix(in srgb, var(--ffp) 16%, transparent); border-color: color-mix(in srgb, var(--ffp) 35%, transparent); }

.na { color: var(--text-dim); opacity: 0.6; }

/* .val wraps just the headline number so centering in the table cell is based
   on that number alone — .err-stack is pulled out of flow (absolutely
   positioned off its right edge) so it never skews where the number sits. */
.val { position: relative; display: inline-block; }

.err-stack {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  font-size: 0.62em;
  line-height: 1.05;
  color: var(--text-dim);
  margin-left: 3px;
  white-space: nowrap;
  cursor: help;
}

/* Columns that can carry an .err-stack (see above) need a reserved minimum
   width: the stack is positioned out of flow, so a table's own auto-sizing
   never accounts for it, and a small subset of rows (e.g. one year's worth
   in the year-bar popup) can size the column too tight to fit it, spilling
   into the next column. */
table.data th.col-err,
table.data td.col-err {
  min-width: 108px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
  color: #d3d7ef;
  font-size: 13px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

/* ---------- Detail drawer ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.6);
  display: none;
  z-index: 40;
}
.overlay.open { display: block; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(440px, 100%);
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 41;
  overflow-y: auto;
  padding: 20px;
  color: var(--text);
}
.drawer.open { transform: translateX(0); }

.drawer h2 {
  font-family: var(--font-mono);
  font-size: 19px;
  margin: 0 0 4px;
  padding-right: 30px;
}

.drawer-kensy {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 600;
}

.drawer-kensy img { height: 32px; width: auto; flex: none; }

.drawer .close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.drawer dl {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 10px;
  margin: 18px 0;
  font-size: 13.5px;
}
.drawer dt { color: var(--text-dim); }
.drawer dd { margin: 0; }

.drawer .abstract-link {
  display: inline-block;
  margin-top: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.drawer .title-text {
  color: var(--text-dim);
  font-size: 13px;
  margin: 6px 0 0;
}

.stat-card-clickable { cursor: pointer; }
.stat-card-clickable:hover { border-color: var(--accent); }

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.97);
  width: min(480px, calc(100vw - 32px));
  max-height: 82vh;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  padding: 22px;
  color: var(--text);
  z-index: 41;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }

.modal.modal-wide {
  width: min(1120px, calc(100vw - 32px));
  /* User-resizable (drag the bottom-right corner) so a year with many wide
     columns can be widened enough to see without the inner table scrolling. */
  resize: both;
  overflow: auto;
  min-width: 420px;
  min-height: 260px;
  max-width: 96vw;
  max-height: 92vh;
}

.modal h2 {
  font-family: var(--font-mono);
  font-size: 18px;
  margin: 0 0 2px;
  padding-right: 30px;
}

.modal-subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 16px;
}

.modal .close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.modal .table-scroll { box-shadow: none; }


.scope-note {
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0 0 12px;
}
.scope-note[hidden] { display: none; }

/* ---------- About / footer ---------- */
.about {
  margin-top: 40px;
  padding: 12px 24px;
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.65;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.about p { margin: 0 0 10px; }
.about p:last-child { margin-bottom: 0; }
.about h3 { color: var(--text); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; margin: 14px 0 6px; }
.about h3:first-of-type { margin-top: 0; }
.about code { font-family: var(--font-mono); background: var(--bg-elev-2); padding: 1px 5px; border-radius: 4px; }

footer {
  margin-top: 24px;
  color: #aab0d0;
  font-size: 12px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px 16px;
}
footer span:first-child { grid-column: 2; text-align: center; }
footer span:last-child { grid-column: 3; justify-self: end; text-align: right; }

@media (max-width: 640px) {
  /* The fixed 5-column stat grid (kept for desktop so a partial row's cards
     stay the same width as a full row) is too wide to fit a phone screen —
     fall back to letting cards wrap to fit instead. */
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  /* On the wrapped mobile layout, Discovery papers sits directly under
     another card instead of an empty column, so the desktop overlap trick
     would just clip into it — drop the negative margin here. */
  #papersCard { margin-top: 0; }
  .drawer { width: 100%; }
  .controls .count { margin-left: 0; width: 100%; order: 5; }
  footer { display: flex; flex-direction: column; align-items: center; text-align: center; }
  footer span:first-child, footer span:last-child { grid-column: auto; justify-self: auto; }
}
