:root {
  --blue: #005587;
  --red: #db0032;
  --ink: #17202a;
  --muted: #5b6573;
  --line: #d8e0e8;
  --surface: #f4f8fb;
  --white: #ffffff;
  --district-1: #7652c8;
  --district-1-dark: #53369b;
  --district-2: #168a46;
  --district-2-dark: #0f6734;
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow-x: hidden; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--surface);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
.embed-shell,
.map-stage {
  position: relative;
  width: 100%;
  height: 100vh;
  min-height: 560px;
  overflow: hidden;
  background: #eaf1f6;
}
.map { width: 100%; height: 100%; }
.lookup-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 600;
  width: min(292px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 13px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 8px 22px rgba(20,39,63,.14);
  backdrop-filter: blur(12px);
}
h1 {
  margin: 0 0 7px;
  color: var(--blue);
  font-size: 16px;
  line-height: 1.05;
  letter-spacing: -.025em;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.lookup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
}
.lookup-row input {
  min-width: 0;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: var(--white);
  font-size: 12.5px;
}
.lookup-row input:focus {
  outline: 3px solid rgba(0,85,135,.15);
  border-color: var(--blue);
}
.lookup-row button {
  min-height: 34px;
  padding: 7px 10px;
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: var(--white);
  font-size: 12.5px;
  font-weight: 900;
  cursor: pointer;
}
.lookup-row button:hover { filter: brightness(.96); transform: translateY(-1px); }
.lookup-row button:disabled { opacity: .62; cursor: wait; transform: none; }
.lookup-result {
  margin-top: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 12px;
  background: var(--surface);
}
.lookup-result.is-d1 { border-left-color: var(--district-1-dark); }
.lookup-result.is-d2 { border-left-color: var(--district-2-dark); }
.lookup-result.is-warning { border-left-color: #c47f00; }
.lookup-result.is-error { border-left-color: var(--red); }
.lookup-result h2 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.15;
}
.lookup-result p {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.34;
}
.lookup-result p:last-child { margin-bottom: 0; }
.lookup-result .result-candidates {
  margin: 7px 0 8px;
}
.lookup-result .callout-candidate {
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
}
.lookup-result .callout-candidate img {
  width: 34px;
  height: 34px;
}
.lookup-result .result-detail {
  font-size: 10.5px;
}
.result-badge {
  display: inline-flex;
  align-items: center;
  margin-bottom: 5px;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--white);
  font-size: 11px;
  font-weight: 900;
}
.result-badge.d1 { background: var(--district-1-dark); }
.result-badge.d2 { background: var(--district-2-dark); }
.lookup-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.25;
}
.lookup-note a {
  color: var(--blue);
  font-weight: 850;
}
.search-marker {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--red);
  border: 4px solid #fff;
  box-shadow: 0 0 0 2px var(--red), 0 7px 18px rgba(0,0,0,.28);
}
.district-label-icon {
  background: transparent;
  border: 0;
}
.mini-district-label-icon {
  background: transparent;
  border: 0;
}
.mini-district-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 24px;
  padding: 5px 8px;
  border: 2px solid var(--blue);
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  color: var(--blue);
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: -.01em;
  white-space: nowrap;
  box-shadow: 0 7px 18px rgba(20,39,63,.18);
}
.mini-district-label-d1 {
  border-color: var(--district-1-dark);
  color: var(--district-1-dark);
}
.mini-district-label-d2 {
  border-color: var(--district-2-dark);
  color: var(--district-2-dark);
}
.district-callout-card {
  width: 300px;
  max-width: 100%;
  padding: 12px;
  border: 2px solid var(--blue);
  border-radius: 18px;
  background: rgba(255,255,255,.95);
  color: var(--ink);
  box-shadow: 0 14px 34px rgba(20,39,63,.20);
  backdrop-filter: blur(10px);
  pointer-events: none;
  overflow-wrap: anywhere;
}
.district-callout-d1 { border-color: var(--district-1-dark); }
.district-callout-d2 { border-color: var(--district-2-dark); }
.district-callout-card h2 {
  margin: 0 0 7px;
  font-size: 14px;
  line-height: 1.1;
  letter-spacing: -.015em;
  white-space: nowrap;
  color: var(--blue);
}
.district-callout-d1 h2 { color: var(--district-1-dark); }
.district-callout-d2 h2 { color: var(--district-2-dark); }
.district-callout-card p {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.32;
}
.callout-candidates {
  display: grid;
  gap: 8px;
}
.callout-candidate {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}
.callout-candidate img {
  display: block;
  width: 42px;
  height: 42px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  clip-path: circle(50%);
  object-fit: cover;
  object-position: center;
  overflow: hidden;
  border: 2px solid #fff;
  background: var(--white);
  box-shadow: 0 0 0 1px rgba(0,0,0,.12), 0 5px 14px rgba(0,0,0,.18);
}
.callout-candidate strong,
.callout-candidate span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.callout-candidate strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 950;
  line-height: 1.1;
}
.callout-candidate span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 850;
}
.mobile-callouts {
  display: none;
}
.leaflet-control-attribution {
  max-width: calc(100vw - 92px);
  white-space: normal;
  text-align: right;
  line-height: 1.15;
}
.leaflet-popup-content-wrapper { border-radius: 14px; }
.leaflet-popup-content { margin: 14px; color: var(--ink); }
.popup-title { margin: 0 0 6px; font-weight: 900; color: var(--blue); }
.popup-meta { margin: 0; color: var(--muted); }

@media (max-width: 900px) {
  .district-callout-card {
    width: 258px;
    padding: 10px;
  }
  .district-callout-card h2 { font-size: 14px; }
  .district-callout-card p { font-size: 11px; }
  .callout-candidate { grid-template-columns: 36px minmax(0, 1fr); }
  .callout-candidate img { width: 36px; height: 36px; }
}
@media (max-width: 720px) {
  html, body { height: auto; min-height: 100%; }
  .embed-shell {
    height: auto;
    min-height: 0;
    overflow: visible;
    background: var(--surface);
  }
  .map-stage {
    height: 620px;
    min-height: 620px;
    overflow: hidden;
  }
  .lookup-panel {
    top: 10px;
    left: 10px;
    width: min(270px, calc(100% - 20px));
    padding: 8px;
  }
  h1 { font-size: 14px; }
  .lookup-row input,
  .lookup-row button {
    min-height: 32px;
    font-size: 12px;
  }
  .lookup-note { font-size: 8px; }
  .mobile-callouts:not([hidden]) {
    display: grid;
    width: 100%;
    max-width: 100vw;
    gap: 10px;
    padding: 12px;
    overflow-x: hidden;
    background: var(--surface);
  }
  .mobile-callouts .district-callout-card {
    width: 100%;
    border-radius: 15px;
    background: var(--white);
    box-shadow: 0 8px 20px rgba(20,39,63,.13);
    pointer-events: auto;
  }
  .mobile-callouts .district-callout-card h2 { font-size: 14px; }
  .mobile-callouts .district-callout-card p { font-size: 11.5px; }
}
@media (max-width: 520px) {
  .map-stage { height: 600px; min-height: 600px; }
  .lookup-row { grid-template-columns: 1fr; }
  .lookup-row button { width: 100%; }
}
