@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600;8..60,700&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #faf9f7;
  --bg-card: #ffffff;
  --fg: #1a1a1a;
  --fg-muted: #5c5c5c;
  --fg-subtle: #8a8a8a;
  --border: #e2dfd9;
  --border-light: #edeae4;
  --accent: #8b2332;
  --accent-light: #f3e8ea;
  --accent-dark: #6b1a27;
  --tag-abs: #1a6b4a;
  --tag-abs-bg: #e6f3ed;
  --tag-t1: #7c5a1e;
  --tag-t1-bg: #faf0da;
  --tag-t2: #2a5a8b;
  --tag-t2-bg: #e0edf7;
  --tag-t3: #6b3a8b;
  --tag-t3-bg: #f0e4f7;
  --tag-open: #5c5c5c;
  --tag-open-bg: #ececec;
  --bar-abs: #22956a;
  --bar-t1: #b8882e;
  --bar-t2: #3874b4;
  --bar-t3: #8a4eb4;
  --bar-open: #888888;
  --geo-1: #8b2332;
  --geo-2: rgba(139,35,50,0.75);
  --geo-3: rgba(139,35,50,0.55);
  --geo-4: rgba(139,35,50,0.38);
  --geo-5: rgba(139,35,50,0.22);
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
  --radius: 6px;
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141210;
    --bg-card: #1e1c18;
    --fg: #e8e4de;
    --fg-muted: #a8a49c;
    --fg-subtle: #6e6a62;
    --border: #2e2c26;
    --border-light: #252320;
    --accent: #d4737f;
    --accent-light: #2a1a1e;
    --accent-dark: #e8949e;
    --tag-abs: #5ebd8e;
    --tag-abs-bg: #142820;
    --tag-t1: #d4a84e;
    --tag-t1-bg: #2a2210;
    --tag-t2: #6eaad4;
    --tag-t2-bg: #12223a;
    --tag-t3: #b47ed4;
    --tag-t3-bg: #24142e;
    --tag-open: #8a8a8a;
    --tag-open-bg: #2a2a2a;
    --bar-abs: #5ebd8e;
    --bar-t1: #d4a84e;
    --bar-t2: #6eaad4;
    --bar-t3: #b47ed4;
    --bar-open: #8a8a8a;
    --geo-1: #d4737f;
    --geo-2: rgba(212,115,127,0.75);
    --geo-3: rgba(212,115,127,0.55);
    --geo-4: rgba(212,115,127,0.38);
    --geo-5: rgba(212,115,127,0.22);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141210;
  --bg-card: #1e1c18;
  --fg: #e8e4de;
  --fg-muted: #a8a49c;
  --fg-subtle: #6e6a62;
  --border: #2e2c26;
  --border-light: #252320;
  --accent: #d4737f;
  --accent-light: #2a1a1e;
  --accent-dark: #e8949e;
  --tag-abs: #5ebd8e;
  --tag-abs-bg: #142820;
  --tag-t1: #d4a84e;
  --tag-t1-bg: #2a2210;
  --tag-t2: #6eaad4;
  --tag-t2-bg: #12223a;
  --tag-t3: #b47ed4;
  --tag-t3-bg: #24142e;
  --tag-open: #8a8a8a;
  --tag-open-bg: #2a2a2a;
  --bar-abs: #5ebd8e;
  --bar-t1: #d4a84e;
  --bar-t2: #6eaad4;
  --bar-t3: #b47ed4;
  --bar-open: #8a8a8a;
  --geo-1: #d4737f;
  --geo-2: rgba(212,115,127,0.75);
  --geo-3: rgba(212,115,127,0.55);
  --geo-4: rgba(212,115,127,0.38);
  --geo-5: rgba(212,115,127,0.22);
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
  color-scheme: dark;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  padding-inline: 16px;
}

*, *::before, *::after { box-sizing: border-box; }

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

/* Header */
header {
  padding: 2.5rem 0 1.5rem;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 2rem;
}
header h1 {
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  color: var(--fg);
  letter-spacing: -0.01em;
}
header .subtitle {
  font-size: 0.9rem;
  color: var(--fg-muted);
  margin: 0;
}
header .institution {
  font-size: 0.75rem;
  color: var(--fg-subtle);
  margin-top: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Stats bar */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}
.stat {
  flex: 1 1 120px;
  background: var(--bg-card);
  padding: 1rem 1.25rem;
  min-width: 0;
}
.stat-value {
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 0.72rem;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.15rem;
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}
.filter-group label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-subtle);
  font-weight: 500;
}
.filter-group select {
  padding: 0.4rem 2rem 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 0.82rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235c5c5c'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  cursor: pointer;
  min-width: 0;
}
.filter-group select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.search-box {
  flex: 1 1 200px;
  min-width: 160px;
}
.search-box input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 0.82rem;
}
.search-box input::placeholder { color: var(--fg-subtle); }
.search-box input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.filter-count {
  font-size: 0.78rem;
  color: var(--fg-muted);
  padding-bottom: 0.45rem;
  white-space: nowrap;
}

/* Charts section */
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.chart-card h3 {
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--fg);
}
.bar-chart { display: flex; flex-direction: column; gap: 0.5rem; }
.bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.bar-label {
  width: 80px;
  font-size: 0.75rem;
  color: var(--fg-muted);
  text-align: right;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  flex: 1;
  height: 22px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
  min-width: 0;
}
.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
  min-width: 2px;
}
.bar-value {
  width: 28px;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted);
  flex-shrink: 0;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  margin-bottom: 2rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  font-size: 0.82rem;
}
thead th {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  padding: 0.65rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-subtle);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  z-index: 2;
}
thead th:hover { color: var(--accent); }
thead th .sort-arrow { font-size: 0.65rem; margin-left: 0.25rem; }
tbody tr {
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.15s;
}
tbody tr:hover { background: var(--accent-light); }
td {
  padding: 0.55rem 0.75rem;
  vertical-align: top;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
td.wrap-cell {
  white-space: normal;
  max-width: 280px;
}

/* Type tags */
.type-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
}
.type-tag.abs { background: var(--tag-abs-bg); color: var(--tag-abs); }
.type-tag.t1 { background: var(--tag-t1-bg); color: var(--tag-t1); }
.type-tag.t2 { background: var(--tag-t2-bg); color: var(--tag-t2); }
.type-tag.t3 { background: var(--tag-t3-bg); color: var(--tag-t3); }
.type-tag.open { background: var(--tag-open-bg); color: var(--tag-open); }

/* Evidence dot */
.ev-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.35rem;
  flex-shrink: 0;
}
.ev-confirmed { background: var(--tag-abs); }
.ev-reported { background: var(--tag-t2); }
.ev-other { background: var(--tag-open); }

/* Detail modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1rem;
  overflow-y: auto;
}
.modal-overlay[hidden] { display: none !important; }
.modal {
  background: var(--bg-card);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  max-width: 680px;
  width: 100%;
  overflow: hidden;
}
.modal-header {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.modal-header h2 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: var(--fg);
}
.modal-header .modal-id {
  font-size: 0.75rem;
  color: var(--fg-subtle);
  margin-top: 0.2rem;
}
.modal-close {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--fg-muted);
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--accent-light); color: var(--accent); }
.modal-body { padding: 1.25rem 1.5rem 1.5rem; }
.detail-grid {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 0.5rem 1rem;
  font-size: 0.82rem;
}
.detail-label {
  color: var(--fg-subtle);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 0.1rem;
}
.detail-value {
  color: var(--fg);
  line-height: 1.5;
}
.detail-value.notes {
  font-size: 0.8rem;
  color: var(--fg-muted);
  line-height: 1.6;
  grid-column: 1 / -1;
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}
.detail-section {
  grid-column: 1 / -1;
  font-family: var(--serif);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.75rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--fg);
}

/* (Disclosure removed) */
.disclosure {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  font-size: 0.78rem;
  color: var(--fg-muted);
  line-height: 1.6;
}
.disclosure summary {
  font-weight: 600;
  cursor: pointer;
  color: var(--fg);
  font-size: 0.8rem;
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2rem;
  font-size: 0.72rem;
  color: var(--fg-subtle);
  text-align: center;
  line-height: 1.6;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--fg-subtle);
  font-size: 0.88rem;
}

@media (max-width: 600px) {
  header h1 { font-size: 1.35rem; }
  .stat { padding: 0.75rem 1rem; }
  .stat-value { font-size: 1.35rem; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-label { margin-top: 0.5rem; }
  .charts { grid-template-columns: 1fr; }
  .filters { gap: 0.5rem; }
  .bar-label { width: 60px; font-size: 0.68rem; }
}

/* Sources section */
.sources-section { margin-top: 3rem; }
.sources-section h2 { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; margin-bottom: 1rem; color: var(--fg); }
.sources-count { color: var(--fg-muted); font-family: var(--sans); font-size: 0.85rem; font-weight: 400; margin-left: 0.5rem; }
.sources-search { margin-bottom: 1rem; }
.sources-search input { font-family: var(--sans); font-size: 0.85rem; padding: 0.4rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); color: var(--fg); width: 100%; max-width: 400px; }
.sources-search input:focus { outline: none; border-color: var(--accent); }
.src-table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 0.8rem; }
.src-table th { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 2px solid var(--border); color: var(--fg-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; position: sticky; top: 0; background: var(--bg); }
.src-table td { padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.src-table tr:hover td { background: var(--accent-light); }
.src-table .src-id { font-family: var(--sans); font-weight: 600; color: var(--accent); white-space: nowrap; font-size: 0.75rem; }
.src-table .src-ref { font-size: 0.75rem; color: var(--fg-muted); white-space: nowrap; }
.src-table .src-title { color: var(--fg); }
.src-table .src-title a { color: var(--accent); text-decoration: none; }
.src-table .src-title a:hover { text-decoration: underline; }
.src-type-badge { display: inline-block; font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 3px; font-weight: 500; }
.src-type-badge.primary { background: var(--tag-t2-bg); color: var(--tag-t2); }
.src-type-badge.secondary { background: var(--tag-open-bg); color: var(--tag-open); }
.src-ref-link { cursor: pointer; color: var(--accent); text-decoration: none; font-weight: 500; }
.src-ref-link:hover { text-decoration: underline; }

/* Source links in modal */
.modal-sources { margin-top: 0.75rem; }
.modal-sources .src-chip { display: inline-block; font-family: var(--sans); font-size: 0.72rem; padding: 0.15rem 0.45rem; margin: 0.15rem 0.2rem 0.15rem 0; border-radius: 3px; background: var(--accent-light); color: var(--accent); cursor: pointer; text-decoration: none; border: 1px solid var(--border-light); transition: background 0.15s; }
.modal-sources .src-chip:hover { background: var(--accent); color: #fff; }
.modal-sources .src-chip.primary { border-left: 2px solid var(--accent); }

.sources-table-wrap { max-height: 600px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
