:root {
  --bg:        #f7f8fa;
  --surface:   #ffffff;
  --text:      #0f172a;
  --text-soft: #475569;
  --muted:     #94a3b8;
  --border:    #e2e8f0;
  --border-strong: #cbd5e1;
  --accent:    #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --code-bg:   #f1f5f9;
  --warn-bg:   #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #92400e;
  --radius:    10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px 0 rgba(15,23,42,.04);
  --shadow:    0 1px 3px 0 rgba(15,23,42,.06), 0 1px 2px -1px rgba(15,23,42,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.015em; margin: 0 0 12px; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 600; margin-top: 32px; }
h3 { font-size: 16px; font-weight: 600; margin-top: 20px; }
p  { margin: 12px 0; color: var(--text-soft); }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: "SF Mono", Menlo, Monaco, Consolas, monospace; font-size: 13px; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 3px; color: var(--text); }
pre  { background: var(--code-bg); border-radius: var(--radius-sm); padding: 14px 16px; overflow-x: auto; line-height: 1.5; }
pre code { background: transparent; padding: 0; }

/* ---- Site chrome ---- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 24px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
  line-height: 1;
}
.brand:hover { text-decoration: none; }
.brand-dot {
  display: inline-block;
  width: 18px; height: 18px; border-radius: 4px; flex-shrink: 0;
  background: linear-gradient(135deg,#dc2626,#ea580c,#ca8a04,#16a34a,#0891b2,#2563eb,#9333ea);
}
.nav {
  display: flex; align-items: center; gap: 20px;
}
.nav a {
  color: var(--text-soft); font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center;
  line-height: 1;
}
.nav a:hover { color: var(--accent); text-decoration: none; }
.nav a.active { color: var(--text); }
.nav a.cta {
  padding: 8px 14px; border-radius: 6px;
  background: var(--text); color: white;
  line-height: 1;
}
.nav a.cta:hover { background: var(--accent); color: white; }

main { max-width: 1200px; margin: 0 auto; padding: 32px 24px 80px; }

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 60px;
  padding: 28px 24px;
  color: var(--muted); font-size: 13px;
}
.site-footer .inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
}

/* ---- Hero ---- */
.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 32px 28px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 12px;
}
.hero .eyebrow::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.hero h1 { font-size: 34px; margin-bottom: 10px; max-width: 760px; }
.hero p.lede {
  font-size: 16px; color: var(--text-soft); max-width: 720px; margin: 0 0 20px;
}
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.btn-primary { background: var(--text); color: white; }
.btn-primary:hover { background: var(--accent); color: white; text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.hero-stats {
  display: flex; gap: 28px; margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--border); flex-wrap: wrap;
}
.hero-stat .num {
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--text); font-variant-numeric: tabular-nums;
}
.hero-stat .lbl {
  font-size: 12px; color: var(--muted); margin-top: 2px;
  letter-spacing: 0.04em; text-transform: uppercase;
}

/* ---- Toolbar ---- */
.toolbar {
  position: sticky; top: 56px; z-index: 30;
  background: rgba(247,248,250,0.9);
  backdrop-filter: blur(8px);
  padding: 14px 0; margin-bottom: 16px;
}
.toolbar-row {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.search-wrap {
  flex: 1 1 240px; min-width: 200px;
  position: relative;
}
.search-wrap input {
  width: 100%; border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px 9px 34px;
  font-size: 14px; font-family: inherit;
  background: var(--surface); color: var(--text);
  transition: border-color .12s ease;
}
.search-wrap input:focus { outline: none; border-color: var(--accent); }
.search-wrap::before {
  content: ""; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'><circle cx='11' cy='11' r='7'/><path d='m21 21-4.3-4.3'/></svg>") no-repeat center / contain;
  pointer-events: none;
}
.sort-wrap select {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 28px 9px 12px; font-size: 13px; font-family: inherit;
  background: var(--surface); color: var(--text); cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 14px;
}
.count-pill {
  margin-left: auto; font-size: 13px; color: var(--text-soft);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 12px; font-variant-numeric: tabular-nums;
}

.chip-row {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-soft); font-size: 12px; font-weight: 500;
  cursor: pointer; user-select: none;
  transition: border-color .1s ease, background .1s ease, color .1s ease;
}
.chip:hover { border-color: var(--border-strong); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .6; }
.chip .n { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chip.active { background: var(--text); color: white; border-color: var(--text); }
.chip.active .n { color: rgba(255,255,255,0.7); }

/* ---- Card grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.card.hidden { display: none; }
.card.matches-search { border-color: var(--accent); }

.card-top {
  display: flex; align-items: center; justify-content: space-between;
}
.card-type {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  padding: 3px 9px; border-radius: 999px;
}
.card-type .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.card-year {
  font-size: 12px; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums;
}

.card-title {
  font-size: 16px; font-weight: 600; line-height: 1.3;
  margin: 0; color: var(--text);
}
.card-title a { color: inherit; }
.card-title a:hover { color: var(--accent); text-decoration: none; }

.card-desc {
  margin: 0; font-size: 13.5px; color: var(--text-soft);
  line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 41px;
}

.card-meta {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border); padding-top: 10px;
  margin-top: auto;  /* push meta + actions to the bottom of the card */
}
.card-meta .sep { color: var(--border-strong); }
.card-meta .v { color: var(--text-soft); font-weight: 500; }

.card-actions {
  display: flex; gap: 8px; margin-top: 2px;
}
.card-actions a {
  flex: 1; text-align: center;
  padding: 7px 10px; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-soft);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: border-color .1s ease, color .1s ease, background .1s ease;
}
.card-actions a:hover {
  border-color: var(--accent); color: var(--accent);
  text-decoration: none;
}
.card-actions a.primary {
  background: var(--text); color: white; border-color: var(--text);
}
.card-actions a.primary:hover {
  background: var(--accent); border-color: var(--accent); color: white;
}

.empty-state {
  text-align: center; padding: 48px 16px; color: var(--muted); font-size: 14px;
}
.empty-state.hidden { display: none; }

/* ---- Dataset detail page ---- */
.detail-header {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 28px; margin-bottom: 24px;
}
.detail-header .crumbs {
  font-size: 13px; color: var(--muted); margin-bottom: 8px;
}
.detail-header .crumbs a { color: var(--muted); }
.detail-header .crumbs a:hover { color: var(--accent); }
.detail-header h1 { font-size: 26px; margin: 4px 0 8px; }
.detail-header .lede { font-size: 15px; color: var(--text-soft); max-width: 760px; margin: 0; }
.detail-tags { margin-top: 14px; display: flex; gap: 6px; flex-wrap: wrap; }

.detail-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 28px;
  align-items: start;
}
.detail-grid > * { min-width: 0; }
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}

/* Detail content: ensure long text wraps inside the column */
.detail-grid p, .detail-grid li, .detail-grid h1,
.detail-grid h2, .detail-grid h3, .detail-grid .citation {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.aside-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.aside-card h4 {
  margin: 0 0 10px; font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.aside-stat {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; font-size: 13px;
}
.aside-stat + .aside-stat { border-top: 1px dashed var(--border); }
.aside-stat .k { color: var(--text-soft); }
.aside-stat .v { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }

.download-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; margin: 14px 0;
  flex-wrap: wrap;
}
.download-block .info { flex: 1; min-width: 140px; }
.download-block .name { font-weight: 500; font-size: 14px; }
.download-block .sub  { font-size: 12px; color: var(--muted); margin-top: 2px; }
.download-block .size {
  font-size: 12px; color: var(--muted);
  padding: 4px 10px; border-radius: 999px; background: var(--bg);
  font-variant-numeric: tabular-nums;
}

.notes-list { margin: 16px 0; padding: 0; list-style: none; }
.notes-list li {
  background: var(--warn-bg); border-left: 3px solid var(--warn-border);
  padding: 12px 14px; margin: 8px 0; border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text);
}
.citation {
  background: var(--code-bg); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 13px; margin: 8px 0;
  color: var(--text-soft);
}

.table-wrap {
  overflow-x: auto; margin: 14px 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface);
}
.table-wrap table { margin: 0; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 14px 0; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table-wrap th, .table-wrap td { white-space: nowrap; }
th {
  background: var(--surface); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
