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

:root {
  --ink: #1a1a2e;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #1d4ed8;
  --brand-dark: #1e3a8a;
  --dem: #2563eb;
  --rep: #dc2626;
  --lib: #d97706;
  --una: #6b7280;
  --dem-tint: #eff4ff;
  --rep-tint: #fef2f2;
  --lib-tint: #fff7ed;
  --una-tint: #f8fafc;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f2f5;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
  padding-top: calc(var(--appbar-height, 60px) + 1rem);
  flex: 1;
}
@media (max-width: 600px) {
  main { padding: 0 0.75rem 2rem; padding-top: calc(var(--appbar-height, 60px) + 0.5rem); }
}

/* ── Hero ─────────────────────────────────────────────── */
.hero { text-align: center; margin: 1rem 0 1.5rem; }
.hero-emoji { font-size: 2.75rem; line-height: 1; }
.hero-title {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--brand-dark);
  margin: 0.5rem 0 0.4rem;
  letter-spacing: -0.02em;
}
.hero-tagline {
  max-width: 640px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.5;
}
@media (max-width: 600px) {
  .hero-title { font-size: 1.5rem; }
  .hero-tagline { font-size: 0.95rem; }
}

.search-card {
  background: #fff;
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  max-width: 620px;
  margin: 1.25rem auto 0;
}
.search-row { display: flex; gap: 0.6rem; align-items: stretch; }
#address-input {
  flex: 1;
  padding: 0.8rem 1rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}
#address-input:focus { border-color: var(--brand); }
#search-btn {
  padding: 0.8rem 1.6rem;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#search-btn:hover { background: var(--brand-dark); }
.search-hint { margin-top: 0.6rem; font-size: 0.82rem; color: var(--muted); text-align: left; }

/* ── Status ──────────────────────────────────────────── */
.status {
  max-width: 620px;
  margin: 1rem auto;
  padding: 0.9rem 1.1rem;
  border-radius: 10px;
  font-size: 0.95rem;
  line-height: 1.5;
  text-align: center;
}
.status--info  { background: #eff6ff; color: #1e3a8a; }
.status--warn  { background: #fffbeb; color: #92400e; }
.status--error { background: #fef2f2; color: #991b1b; }

.spinner {
  display: inline-block;
  width: 1em; height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.15em;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Disambiguation ──────────────────────────────────── */
.panel {
  background: #fff;
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  max-width: 620px;
  margin: 1rem auto;
}
.panel-title { font-size: 1.2rem; color: var(--brand-dark); margin-bottom: 0.3rem; }
.panel-sub { color: var(--muted); font-size: 0.95rem; margin-bottom: 1rem; }
.disambig-options { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.disambig-btn {
  padding: 0.6rem 1rem;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
}
.disambig-btn:hover { border-color: var(--brand); background: #eff6ff; }

/* ── Results ─────────────────────────────────────────── */
.results-header { margin: 0.5rem 0 1.5rem; }
.matched {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-align: center;
}
.matched-label { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.matched-address { font-size: 1.3rem; font-weight: 700; color: var(--ink); }
.matched-loc { font-size: 0.95rem; color: var(--muted); }
.matched-town {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  margin: 0.85rem auto 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--brand);
  text-decoration: none;
}
.matched-town:hover { text-decoration: underline; }
.hero-browse { margin-top: 1rem; }
.hero-browse a {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--brand);
  text-decoration: none;
}
.hero-browse a:hover { text-decoration: underline; }

.notice {
  background: #fffbeb;
  color: #92400e;
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}
.notice i { margin-right: 0.5rem; }

.level { margin-bottom: 2rem; }
.level-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--line);
  margin-bottom: 1rem;
}
.level-title i { color: var(--brand); }

.level-group { margin-bottom: 1.4rem; }
.level-group:last-child { margin-bottom: 0; }
.group-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #64748b);
  margin: 0 0 0.7rem;
}

.rep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.rep-card {
  --party: #94a3b8;
  --party-tint: #fff;
  background: var(--party-tint);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  border-left: 5px solid var(--party);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.rep-card--dem { --party: var(--dem); --party-tint: var(--dem-tint); }
.rep-card--rep { --party: var(--rep); --party-tint: var(--rep-tint); }
.rep-card--lib { --party: var(--lib); --party-tint: var(--lib-tint); }
.rep-card--una { --party: var(--una); --party-tint: var(--una-tint); }
.rep-card--placeholder { --party: var(--una); opacity: 0.85; }

.rep-head { display: flex; align-items: center; gap: 0.85rem; }
.rep-headtext { min-width: 0; flex: 1; }

.rep-avatar {
  position: relative;
  flex-shrink: 0;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #fff;
  border: 2px solid var(--party);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}
.rep-initials {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--party);
}
.rep-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rep-office {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.rep-title { font-weight: 400; text-transform: none; letter-spacing: 0; }
.rep-name { font-size: 1.15rem; font-weight: 700; color: var(--ink); line-height: 1.25; }
.rep-party { font-size: 0.8rem; font-weight: 700; color: var(--party); }
.rep-district { font-size: 0.85rem; color: var(--muted); }

.rep-contacts { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.35rem; }
.contact {
  font-size: 0.9rem;
  color: var(--brand);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  word-break: break-word;
}
.contact:hover { text-decoration: underline; }
.contact i { width: 1rem; text-align: center; color: var(--muted); }

.rep-address {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.35rem;
  display: flex;
  gap: 0.5rem;
  line-height: 1.4;
}
.rep-address i { width: 1rem; text-align: center; margin-top: 0.15rem; }

.rep-term {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.rep-term i { width: 1rem; text-align: center; }

.results-disclaimer {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  max-width: 640px;
  margin: 1rem auto 0;
  line-height: 1.5;
}
