:root {
  --tno-navy: #00205c;
  --tno-gold: #ffb600;
  --tno-blue: #2b3aa0;
  --tno-black: #0f0f0f;
  --paper: #ffffff;
  --ink: #0f0f0f;
  --muted: #5f6875;
  --line: #d7dce3;
  --map-bg: #edf1f5;
  font-family: Inter, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--map-bg);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  background: var(--map-bg);
}

button,
input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.lookup-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
}

.lookup-header {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(210px, 260px) minmax(235px, 0.72fr) minmax(480px, 1.45fr);
  gap: clamp(20px, 2.6vw, 42px);
  align-items: center;
  min-height: 122px;
  padding: 18px 24px;
  color: #fff;
  background: var(--tno-navy);
  border-bottom: 5px solid var(--tno-gold);
  box-shadow: 0 5px 18px rgba(0, 32, 92, 0.22);
}

.tno-lockup {
  display: inline-grid;
  justify-self: start;
  min-width: 218px;
  padding: 8px 12px 9px;
  border: 3px solid var(--tno-gold);
  background: var(--tno-navy);
  line-height: 0.9;
}

.tno-lockup strong,
.tno-lockup span {
  display: block;
  font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  text-transform: uppercase;
  white-space: nowrap;
}

.tno-lockup strong {
  color: #fff;
  font-size: 31px;
  font-stretch: condensed;
  font-weight: 900;
  letter-spacing: -0.045em;
}

.tno-lockup span {
  margin-top: 5px;
  color: var(--tno-gold);
  font-size: 18px;
  font-weight: 350;
  letter-spacing: 0.015em;
}

.tool-heading h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(27px, 2.3vw, 39px);
  line-height: 0.98;
  font-weight: 900;
  letter-spacing: -0.035em;
}

.lookup-actions {
  justify-self: stretch;
  display: grid;
  grid-template-columns: minmax(200px, 0.72fr) minmax(290px, 1fr);
  gap: 18px;
  align-items: end;
}

.lookup-instructions {
  align-self: center;
  color: #fff;
  font-size: 13px;
  line-height: 1.32;
}

.lookup-instructions strong,
.lookup-instructions span {
  display: block;
}

.lookup-instructions strong {
  margin-bottom: 3px;
  color: var(--tno-gold);
  font-size: 14px;
  font-weight: 900;
}

.lookup-instructions span { font-weight: 650; }

.address-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
}

.address-form input {
  min-width: 0;
  height: 48px;
  padding: 0 15px;
  color: var(--tno-black);
  background: #fff;
  border: 2px solid transparent;
  border-radius: 2px;
  outline: none;
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.15);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.address-form input::placeholder { color: #747d89; }

.address-form input:focus {
  border-color: var(--tno-gold);
  box-shadow: 0 0 0 3px rgba(255, 182, 0, 0.2), 0 2px 9px rgba(0, 0, 0, 0.14);
}

.address-form input:disabled { opacity: 0.78; }

.address-form button {
  min-width: 98px;
  height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 2px;
  color: var(--tno-navy);
  background: var(--tno-gold);
  font-weight: 900;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
}

.address-form button:hover:not(:disabled) { filter: brightness(1.06); }
.address-form button:active:not(:disabled) { transform: translateY(1px); }
.address-form button:disabled { cursor: wait; opacity: 0.62; }
.address-form.is-searching button::after { content: "…"; }

.lookup-map-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: var(--map-bg);
}

#map {
  position: absolute;
  inset: 0;
}

.lookup-note {
  position: absolute;
  z-index: 4;
  left: 12px;
  bottom: 12px;
  max-width: min(450px, calc(100% - 88px));
  padding: 6px 9px;
  color: #515b68;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 32, 92, 0.17);
  border-radius: 2px;
  font-size: 9.5px;
  line-height: 1.25;
  box-shadow: 0 2px 8px rgba(0, 32, 92, 0.08);
  backdrop-filter: blur(4px);
}

.lookup-status,
.lookup-error {
  position: absolute;
  z-index: 12;
  top: 16px;
  left: 50%;
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translate(-50%, -8px);
  padding: 10px 14px;
  border-radius: 2px;
  font-size: 13px;
  font-weight: 750;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 32, 92, 0.18);
}

.lookup-status {
  pointer-events: none;
  color: #fff;
  background: rgba(0, 32, 92, 0.96);
  border-bottom: 3px solid var(--tno-gold);
  opacity: 0;
  transition: opacity 140ms ease, transform 140ms ease;
}

.lookup-status.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.lookup-error {
  color: #7c1e20;
  background: #fff0f0;
  border: 1px solid #e5b6b8;
}

.lookup-error[hidden] { display: none; }

.result-leader {
  position: absolute;
  z-index: 7;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  opacity: 0;
  transition: opacity 120ms ease;
}

.result-leader.is-visible { opacity: 1; }

.result-leader line {
  stroke: var(--tno-navy);
  stroke-width: 2.25;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.result-leader circle {
  fill: var(--tno-gold);
  stroke: var(--tno-navy);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.result-card {
  position: absolute;
  z-index: 8;
  width: min(300px, calc(100% - 24px));
  color: var(--tno-black);
  background: #fff;
  border: 2px solid var(--tno-navy);
  border-top: 7px solid var(--tno-gold);
  border-radius: 2px;
  box-shadow: 0 14px 34px rgba(0, 32, 92, 0.24);
  transform: translate3d(0, 0, 0);
}

.result-card[hidden] { display: none; }

.result-card-inner { padding: 15px 17px 17px; }

.result-card-close {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 27px;
  height: 27px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--tno-navy);
  background: transparent;
  font-size: 22px;
  line-height: 25px;
  font-weight: 500;
  cursor: pointer;
}

.result-card-close:hover { background: #eef1f6; }

.result-address {
  padding: 0 30px 12px 0;
  color: #5c6673;
  font-size: 11.5px;
  line-height: 1.35;
  font-weight: 650;
  border-bottom: 1px solid #dfe3e8;
}

.result-stat-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 12px;
  padding-top: 13px;
}

.result-stat + .result-stat {
  padding-left: 12px;
  border-left: 1px solid #dfe3e8;
}

.result-label {
  color: #5f6875;
  font-size: 9px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: 0.105em;
  text-transform: uppercase;
}

.result-precinct,
.result-voters {
  margin-top: 5px;
  line-height: 0.95;
  font-weight: 950;
  letter-spacing: -0.02em;
}

.result-precinct {
  color: var(--tno-navy);
  font-size: 29px;
}

.result-voters {
  color: var(--tno-blue);
  font-size: 30px;
}

.result-voters-note {
  margin-top: 5px;
  color: #737c88;
  font-size: 9px;
  line-height: 1.2;
  font-weight: 650;
}

.mapboxgl-popup.institution-popup { z-index: 9; }

.institution-popup .mapboxgl-popup-content {
  min-width: 250px;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--tno-navy);
  border-top: 5px solid var(--tno-gold);
  border-radius: 2px;
  box-shadow: 0 12px 32px rgba(0, 32, 92, 0.22);
}

.institution-popup .mapboxgl-popup-tip { border-top-color: var(--tno-navy); }

.institution-popup .mapboxgl-popup-close-button {
  top: 4px;
  right: 5px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  color: var(--tno-navy);
  font-size: 21px;
  line-height: 24px;
}

.institution-popup .mapboxgl-popup-close-button:hover { background: #eef1f6; }

.institution-card {
  padding: 14px 16px 16px;
  background: #fff;
}

.institution-kicker {
  padding-right: 28px;
  color: var(--tno-blue);
  font-size: 9px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.institution-name {
  margin-top: 5px;
  color: var(--tno-navy);
  font-size: 17px;
  line-height: 1.15;
  font-weight: 900;
}

.institution-address {
  margin-top: 6px;
  color: #626b77;
  font-size: 11px;
  line-height: 1.35;
}

.institution-precinct {
  margin-top: 10px;
  padding-top: 9px;
  color: #515b68;
  border-top: 1px solid #dfe3e8;
  font-size: 11px;
  line-height: 1.3;
}

.institution-precinct strong { color: var(--tno-navy); }

.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl,
.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl-attrib { font-size: 9px; }

.mapboxgl-ctrl-group {
  border-radius: 2px;
  box-shadow: 0 2px 10px rgba(0, 32, 92, 0.14) !important;
}

@media (max-width: 1120px) {
  .lookup-header {
    grid-template-columns: 205px minmax(210px, 0.55fr) minmax(430px, 1.2fr);
    gap: 18px;
    padding: 15px 18px;
  }

  .tno-lockup { min-width: 195px; }
  .tno-lockup strong { font-size: 28px; }
  .tno-lockup span { font-size: 16px; }
  .lookup-actions { gap: 13px; }
  .lookup-instructions { font-size: 12px; }
}

@media (max-width: 900px) {
  body { overflow: auto; }

  .lookup-shell {
    min-height: 100dvh;
    height: 100dvh;
  }

  .lookup-header {
    grid-template-columns: auto 1fr;
    gap: 13px 20px;
    min-height: 0;
    padding: 13px 15px 15px;
  }

  .tno-lockup {
    grid-row: 1 / span 2;
    min-width: 174px;
    padding: 7px 10px 8px;
  }

  .tno-lockup strong { font-size: 25px; }
  .tno-lockup span { font-size: 14px; }

  .tool-heading h1 { font-size: 27px; }

  .lookup-actions {
    grid-column: 2;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .lookup-instructions span { display: inline; }
  .lookup-instructions strong { display: inline; margin-right: 4px; }
}

@media (max-width: 620px) {
  .lookup-header {
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 10px 11px 12px;
  }

  .tno-lockup {
    grid-row: auto;
    min-width: 0;
    width: fit-content;
    padding: 5px 8px 6px;
    border-width: 2px;
  }

  .tno-lockup strong { font-size: 20px; }
  .tno-lockup span { margin-top: 3px; font-size: 11.5px; }
  .tool-heading h1 { font-size: 24px; }
  .lookup-actions { grid-column: 1; gap: 7px; }
  .lookup-instructions { font-size: 11.5px; }
  .lookup-instructions strong { font-size: 12px; }

  .address-form { gap: 6px; }
  .address-form input { height: 43px; padding: 0 11px; font-size: 14px; }
  .address-form button { min-width: 80px; height: 43px; padding: 0 12px; }

  .result-card { width: min(270px, calc(100% - 20px)); }
  .result-card-inner { padding: 13px 14px 15px; }
  .result-precinct { font-size: 25px; }
  .result-voters { font-size: 26px; }

  .lookup-note {
    left: 7px;
    bottom: 7px;
    max-width: calc(100% - 66px);
    padding: 5px 7px;
    font-size: 8.5px;
  }

  .institution-popup .mapboxgl-popup-content { min-width: 225px; }
}
