:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --primary: #0f172a;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --success: #047857;
  --warning: #b45309;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
}

header {
  background: var(--primary);
  color: #f8fafc;
  padding: 1.75rem 1.25rem 1.5rem;
  text-align: center;
}
header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
header p {
  margin: 0.4rem 0 0;
  opacity: 0.85;
  font-size: 0.95rem;
  font-weight: 400;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.search-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.search-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
}
.search-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.search-row input {
  flex: 1 1 240px;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s;
}
.search-row input:focus {
  border-color: var(--accent);
}
.search-row button {
  padding: 0.85rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.search-row button:hover { background: #1d4ed8; }
.search-row button:disabled { opacity: 0.55; cursor: not-allowed; }

.key-toggle {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.key-toggle button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  text-decoration: underline;
}
#civic-key-wrap { display: none; margin-top: 0.5rem; }
#civic-key-wrap input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.notice {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #78350f;
  padding: 0.9rem 1.1rem;
  border-radius: 10px;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  line-height: 1.45;
}

.status {
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.status.error { color: #b91c1c; }

.results { display: flex; flex-direction: column; gap: 1rem; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 1.15rem 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  user-select: none;
}
.card-header:hover { background: #f8fafc; }
.badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-top: 2px;
}
.badge.measure { background: #f0fdf4; color: var(--success); }
.card-title-wrap { flex: 1; }
.card-title {
  font-weight: 650;
  font-size: 1.05rem;
  margin: 0;
  line-height: 1.3;
}
.card-summary {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.chevron {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 1.1rem;
  transition: transform 0.2s;
  margin-top: 4px;
}
.card.open .chevron { transform: rotate(180deg); }

.card-body {
  display: none;
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}
.card.open .card-body { display: block; }

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 1.1rem 0 0.5rem;
}
.candidate-list, .measure-text {
  margin: 0;
  padding: 0;
}
.candidate {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}
.candidate:last-child { border-bottom: none; }
.candidate-name { font-weight: 600; }
.candidate-party { color: var(--muted); font-size: 0.9rem; margin-left: 0.4rem; }
.measure-text p { margin: 0.4rem 0; }
.measure-text strong { color: var(--text); }

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.links a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: 7px;
  transition: background 0.15s;
}
.links a:hover { background: #dbeafe; }

.coverage {
  margin-top: 1rem;
  padding: 0.65rem 0.8rem;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

footer {
  text-align: center;
  padding: 2rem 1rem 3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 600px) {
  header { padding: 1.5rem 1rem; }
  header h1 { font-size: 1.5rem; }
  main { padding: 1.25rem 1rem 2.5rem; }
  .search-row { flex-direction: column; }
  .search-row button { width: 100%; }
}
