:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e3e3e3;
  --accent: #1f4e79;
  --accent-soft: #e6eef7;
  --chart-line: #1f4e79;
  --chart-axis: #bbb;
  --pol-active: #1f7a3f;
  --pol-adopted: #4ca46b;
  --pol-inactive: #c94a4a;
  --pol-terminated: #a03030;
  --pol-no-mention: #d9d9d9;
  --pol-not-crawled: #f1f1f1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  padding: 2rem 1.5rem 1.25rem;
  max-width: 960px;
  margin: 0 auto;
}

.site-header.compact {
  padding-top: 1.25rem;
  padding-bottom: 0.5rem;
}

.site-header h1 {
  margin: 0.25rem 0 0.25rem;
  font-size: 1.75rem;
  font-weight: 600;
}

.tagline {
  margin: 0;
  color: var(--muted);
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.back-link {
  display: inline-block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.site-footer {
  max-width: 960px;
  margin: 3rem auto 2rem;
  padding: 1rem 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.site-footer .usage-note {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}

.site-footer .sources {
  margin: 0.25rem 0 0.75rem;
  font-size: 0.78rem;
}

.site-footer .sources summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 500;
  padding: 0.25rem 0;
  outline: none;
}

.site-footer .sources summary:hover {
  text-decoration: underline;
}

.site-footer .sources ul {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
}

.site-footer .sources li {
  margin-bottom: 0.35rem;
  line-height: 1.4;
}

/* ---- search ---- */

.search-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.search-box {
  position: relative;
}

#q {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

#q:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.status {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.25rem;
}

.results {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.results li {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.results li:hover {
  background: var(--accent-soft);
}

.results a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: inherit;
  text-decoration: none;
}

.results a:hover {
  text-decoration: none;
}

.result-main { font-weight: 500; }
.result-meta { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }

/* ---- profile ---- */

.profile-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 2rem;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
}

.stat-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  margin-top: 0.2rem;
  font-size: 1.15rem;
  font-weight: 500;
  word-break: break-word;
}

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem 1.25rem;
  margin-bottom: 1.5rem;
}

.panel h2 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.panel-note {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.chart { width: 100%; overflow: hidden; }
.chart svg { display: block; width: 100%; height: auto; }

/* ---- stacked chart slots + toggles/chips ---- */

.stats-grid.compact {
  margin: 0.5rem 0 0.75rem;
  gap: 0.5rem;
}
.stats-grid.compact .stat-card { padding: 0.4rem 0.75rem; }
.stats-grid.compact .stat-label { font-size: 0.7rem; }
.stats-grid.compact .stat-value { font-size: 1rem; margin-top: 0.1rem; }

.chart-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chart-slot {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.75rem 0.3rem;
}

.chart-slot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.15rem;
}

.chart-slot-head h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #333;
}

.toggle-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.toggle-segment {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.toggle {
  border: none;
  background: transparent;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--muted);
  border-right: 1px solid var(--border);
  font-family: inherit;
}
.toggle:last-child { border-right: none; }
.toggle:hover { background: var(--accent-soft); }
.toggle.active {
  background: var(--accent);
  color: #fff;
}

.chip-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0.75rem 0 1.5rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  justify-content: center;
}

.chip-group {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--border);
  background: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
}
.chip:hover { background: var(--accent-soft); border-color: var(--accent); }
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---- policy timelines ---- */

.pol-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.pol-label {
  font-size: 0.9rem;
  color: #333;
}

.pol-cells {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  min-height: 28px;
}

.pol-cell {
  background: var(--pol-not-crawled);
  color: transparent;
  font-size: 0.7rem;
  text-align: center;
}

.pol-cell.status-active { background: var(--pol-active); color: white; }
.pol-cell.status-adopted { background: var(--pol-adopted); color: white; }
.pol-cell.status-inactive { background: var(--pol-inactive); color: white; }
.pol-cell.status-terminated { background: var(--pol-terminated); color: white; }
.pol-cell.status-no_mention { background: var(--pol-no-mention); }
.pol-cell.status-not_crawled { background: var(--pol-not-crawled); }

.pol-axis {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 1px;
  font-size: 0.7rem;
  color: var(--muted);
  padding-left: calc(180px + 0.75rem);
  margin-bottom: 0.3rem;
}
.pol-axis span { text-align: center; }

.pol-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.pol-legend .swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  vertical-align: middle;
  margin-right: 0.35rem;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.05);
}

@media (max-width: 640px) {
  .pol-row { grid-template-columns: 1fr; }
  .pol-axis { padding-left: 0; }
}
