:root {
  --bg: #f2f4f8;
  --card: #ffffff;
  --ink: #1a2332;
  --ink-soft: #5a6577;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --line: #dde3ec;
  --dem: #2563eb;
  --rep: #dc2626;
  --ind: #7c3aed;
  --other: #64748b;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 14px rgba(16, 24, 40, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --card: #1a2130;
    --ink: #e8ecf3;
    --ink-soft: #9aa5b8;
    --accent: #3b6ef6;
    --line: #2a3348;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.site-header {
  background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
  color: #fff;
  text-align: center;
  padding: 28px 16px 22px;
}

.site-header h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -.01em;
}

.tagline {
  margin: 6px 0 0;
  font-size: .92rem;
  opacity: .85;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

/* ---------- address form ---------- */

.address-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin: -34px auto 20px;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.address-card label {
  font-weight: 600;
  font-size: .95rem;
}

#address-input {
  font: inherit;
  font-size: 1.05rem;
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  min-height: 48px;
}

#address-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

#search-btn {
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 13px;
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  transition: filter .15s;
}

#search-btn:hover { filter: brightness(1.1); }
#search-btn:disabled { opacity: .6; cursor: wait; }

.privacy-note {
  margin: 0;
  font-size: .78rem;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- status / errors ---------- */

#status {
  max-width: 560px;
  margin: 0 auto 16px;
  text-align: center;
  font-size: .95rem;
}

#status .error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 12px 14px;
}

@media (prefers-color-scheme: dark) {
  #status .error {
    background: #3b1215;
    color: #fca5a5;
    border-color: #7f1d1d;
  }
}

#status .loading { color: var(--ink-soft); }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: -3px;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- results ---------- */

.matched-address {
  text-align: center;
  color: var(--ink-soft);
  font-size: .9rem;
  margin-bottom: 18px;
}

.rep-section h2 {
  font-size: 1.15rem;
  margin: 22px 4px 12px;
}

.card-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 720px) {
  .card-list { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
}

.rep-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--party, var(--other));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.rep-card.party-democratic { --party: var(--dem); }
.rep-card.party-republican { --party: var(--rep); }
.rep-card.party-independent { --party: var(--ind); }

.rep-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.rep-photo, .rep-photo-fallback {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  flex-shrink: 0;
  border: 2px solid var(--line);
  background: var(--bg);
}

.rep-photo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--ink-soft);
}

.rep-name {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.rep-role {
  margin: 2px 0 0;
  font-size: .85rem;
  color: var(--ink-soft);
}

.party-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--party, var(--other));
  margin-top: 4px;
}

.rep-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  min-height: 42px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-size: .88rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}

.action-btn:hover { border-color: var(--accent); }

.action-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.rep-offices {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: .85rem;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rep-offices li {
  padding-left: 22px;
  position: relative;
}

.rep-offices .office-icon {
  position: absolute;
  left: 0;
  top: 1px;
}

.office-label {
  font-weight: 600;
  color: var(--ink);
}

.office-phone a { color: var(--accent); text-decoration: none; }

.no-match {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--ink-soft);
  font-size: .92rem;
}

.no-match a { color: var(--accent); }

.hours-note {
  max-width: 640px;
  margin: 26px auto 8px;
  font-size: .85rem;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}

/* ---------- footer ---------- */

.site-footer {
  text-align: center;
  font-size: .78rem;
  color: var(--ink-soft);
  padding: 24px 16px 32px;
}

.site-footer a { color: var(--ink-soft); }
