:root {
  font-family: "Manrope", sans-serif;
  color: #16202a;
  background: #f2f0eb;
  --blue: #1769E0;
  --red: #D82E37;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #f2f0eb; }
body { min-width: 1100px; }

.app-shell { min-height: 100vh; }
.masthead {
  height: 82px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 42px; background: #fcfbf8; border-bottom: 1px solid #d9d7d0;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  background: #16202a; color: white; font: 500 14px "DM Mono", monospace;
}
.brand-name { font-weight: 800; letter-spacing: -.03em; font-size: 16px; line-height: 1.15; }
.brand-sub { margin-top: 2px; color: #747b82; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.header-note { display: flex; align-items: center; gap: 8px; color: #6a7178; font-size: 12px; }
.header-note strong { color: #29333d; font-weight: 600; margin-left: 12px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #30a360; box-shadow: 0 0 0 4px #dff2e6; }

.context-bar {
  min-height: 54px; padding: 0 42px; display: flex; align-items: center;
  background: #fcfbf8; border-bottom: 1px solid #ddd9d1;
}
.breadcrumb { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #7c8389; }
.breadcrumb b { font-weight: 400; color: #b0b4b7; }
.breadcrumb button {
  background: none; border: none; padding: 0; font: inherit; color: #7c8389; cursor: pointer;
}
.breadcrumb .current { color: #16202a; font-weight: 700; }

.workspace {
  display: grid;
  grid-template-columns: minmax(640px, 1.65fr) minmax(400px, .85fr);
  min-height: calc(100vh - 136px);
}
.visual-panel { padding: 24px 34px 22px 42px; border-right: 1px solid #d7d5ce; display: flex; flex-direction: column; min-width: 0; }
.controls { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 5; }
.control-group { display: flex; align-items: center; gap: 5px; }
.control-label { margin-right: 6px; color: #777e85; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.segment {
  padding: 8px 13px; border-radius: 99px; font-size: 12px; font-weight: 600; color: #596169;
  background: transparent; cursor: pointer; user-select: none; border: none; font-family: inherit;
  transition: .18s ease;
}
.segment:hover { background: #e8e6df; }
.segment.on { color: #fff; background: #17222c; box-shadow: 0 2px 8px #15202b26; }

.map-wrap { position: relative; flex: 1; min-height: 520px; }
.map-caption {
  position: absolute;
  left: 52px;
  top: 10px;
  display: flex;
  flex-direction: column;
  z-index: 500;
  pointer-events: none;
}
.map-caption span:first-child { font-size: 13px; font-weight: 700; }
.map-caption span:last-child { color: #8b9196; margin-top: 3px; font-size: 10px; }
#map { width: 100%; height: 100%; min-height: 520px; background: #f2f0eb; }

.legend { position: absolute; left: 0; bottom: 8px; z-index: 500; }
.legend-title { margin-bottom: 9px; color: #777e84; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.legend-group { display: flex; align-items: center; gap: 3px; margin-bottom: 3px; color: #4d565e; font-size: 10px; }
.legend-group span { width: 38px; }
.legend i { display: inline-block; width: 20px; height: 7px; border-radius: 2px; }
.legend-scale { display: flex; justify-content: space-between; margin: 0 0 7px 41px; width: 89px; color: #969ba0; font-size: 8px; }
.legend-key { margin-top: 9px; display: flex; align-items: center; gap: 5px; color: #767d83; font-size: 9px; }
.legend-key i { width: 13px; }
.legend-group.progress i { width: 25px; height: 9px; }
.legend-scale.full { width: 165px; margin-left: 0; }

.score-panel { padding: 30px 40px 22px; background: #fcfbf8; overflow: auto; }
.eyebrow { color: #6a7279; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .13em; }
.score-intro { display: flex; align-items: flex-start; justify-content: space-between; margin-top: 11px; padding-bottom: 22px; }
.score-title { color: #121b24; font-size: 24px; font-weight: 800; letter-spacing: -.04em; line-height: 1.05; }
.score-description { max-width: 280px; color: #7a8085; font-size: 11px; line-height: 1.45; margin-top: 5px; }
.confidence { text-align: right; padding-left: 18px; border-left: 1px solid #dad8d1; }
.confidence span { display: block; color: #7e858b; font-size: 9px; }
.confidence strong { display: block; font: 500 19px "DM Mono", monospace; margin-top: 4px; }
.candidates { border-top: 1px solid #dcd9d2; }
.candidate { position: relative; display: flex; padding: 20px 0 17px; border-bottom: 1px solid #dedbd5; }
.candidate-accent { width: 5px; border-radius: 4px; margin-right: 15px; flex-shrink: 0; }
.candidate-main { flex: 1; min-width: 0; }
.candidate-meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.candidate-name { font-size: 15px; font-weight: 800; letter-spacing: -.02em; }
.party { color: #848a8f; font-size: 9px; margin-top: 2px; text-transform: uppercase; letter-spacing: .08em; }
.projected-votes { color: #4e575f; font: 500 13px "DM Mono", monospace; white-space: nowrap; }
.candidate-result { display: grid; grid-template-columns: 115px 1fr; align-items: center; gap: 15px; margin-top: 8px; }
.projected-percent { font: 500 33px "DM Mono", monospace; letter-spacing: -.07em; }
.bar { height: 5px; background: #e4e3df; border-radius: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; }
.official-row { display: flex; align-items: center; gap: 9px; color: #858b90; margin-top: 8px; font-size: 9px; }
.official-row strong { color: #525b63; font: 500 10px "DM Mono", monospace; }
.candidate-muted .candidate-name,
.candidate-muted .projected-percent,
.candidate-muted .projected-votes { color: #737a80; }
.lead-callout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 16px 0; border-bottom: 1px solid #dedbd5; }
.lead-callout > div + div { border-left: 1px solid #dedbd5; padding-left: 20px; }
.lead-callout span { display: block; color: #777e84; font-size: 9px; }
.lead-callout strong { display: block; margin-top: 4px; font: 500 13px "DM Mono", monospace; }
.official-section { padding-top: 19px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; }
.section-heading > div:first-child span { display: block; color: #777e85; font-size: 10px; text-transform: uppercase; letter-spacing: .11em; }
.section-heading > div:first-child strong { display: block; margin-top: 3px; font-size: 14px; }
.counted { text-align: right; }
.counted strong { display: block; font: 500 14px "DM Mono", monospace; }
.counted span { color: #8b9094; font-size: 8px; }
.official-track { height: 3px; margin: 10px 0 16px; background: #e0dfda; overflow: hidden; }
.official-track i { display: block; height: 100%; width: 0; background: #35424d; }
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 20px; }
.metric { padding-top: 9px; border-top: 1px solid #e2dfd9; }
.metric-label { color: #7b8287; font-size: 9px; }
.metric-value { margin-top: 5px; font: 500 13px "DM Mono", monospace; }
.metric-note { margin-top: 3px; color: #999d9f; font-size: 8px; }
.disclaimer { margin-top: 20px; padding-top: 13px; border-top: 1px solid #dedbd5; color: #8a8f93; font-size: 9px; line-height: 1.5; }
.disclaimer span:first-child { display: block; color: #545c63; font-weight: 700; }
.status { font-size: 11px; color: #a91f29; min-height: 1em; margin: 10px 0 0; }

.leaflet-container { background: #f2f0eb; font-family: inherit; -webkit-tap-highlight-color: transparent; }
.leaflet-container :focus,
.leaflet-container :focus-visible,
.leaflet-container path,
.leaflet-interactive:focus { outline: none !important; }
.leaflet-container .ext-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  text-align: center;
  pointer-events: none;
}
.leaflet-container .ext-label span {
  display: block;
  font-family: "Manrope", sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 14px;
  color: #59626b;
  white-space: nowrap;
}

@media (max-height: 800px) {
  .score-panel { padding-top: 22px; }
  .candidate { padding-top: 14px; padding-bottom: 12px; }
  .score-intro { padding-bottom: 15px; }
  .projected-percent { font-size: 29px; }
}

@media (max-width: 700px) {
  body { min-width: 0; }
  .masthead {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 14px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  }
  .brand { min-width: 0; }
  .brand-name { font-size: 15px; }
  .header-note { flex-wrap: wrap; row-gap: 2px; }
  .header-note strong { margin-left: 0; }
  .context-bar {
    min-height: 44px;
    padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  }
  .breadcrumb { flex-wrap: wrap; row-gap: 4px; }
  .workspace {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .score-panel {
    order: -1;
    padding: 18px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
    overflow: visible;
  }
  .visual-panel {
    padding: 14px max(16px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    border-right: none;
    border-top: 1px solid #d7d5ce;
  }
  .controls { flex-wrap: wrap; gap: 8px 14px; justify-content: flex-start; }
  .control-group { flex-wrap: wrap; }
  .segment { padding: 9px 14px; }
  .map-wrap {
    flex: none;
    height: 70vh;
    height: 70dvh;
    min-height: 440px;
    margin-top: 10px;
  }
  #map { height: 100%; min-height: 0; }
  .score-intro { gap: 12px; padding-bottom: 16px; }
  .score-intro > div:first-child { min-width: 0; }
  .score-title { font-size: 22px; }
  .confidence { flex-shrink: 0; }
  .candidate { padding: 16px 0 14px; }
  .candidate-result { grid-template-columns: minmax(92px, 108px) minmax(0, 1fr); gap: 10px; }
  .projected-percent { font-size: 28px; }
  .official-row { flex-wrap: wrap; row-gap: 3px; }
  .lead-callout { gap: 12px; }
  .lead-callout > div + div { padding-left: 12px; }
  .lead-callout strong { font-size: 12px; }
  .metrics-grid { gap: 12px 16px; }
}
