body {
  --sidebar-width: 380px;
  --panel-edge: 14px;
  margin: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: Arial, sans-serif;
  background: #fff;
  color: #111827;
}
header {
  position: fixed;
  top: var(--panel-edge);
  left: var(--panel-edge);
  z-index: 10;
  box-sizing: border-box;
  width: calc(var(--sidebar-width) - (var(--panel-edge) * 2));
  padding: 10px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(8px);
}
h1 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
p {
  margin: 7px 0 0;
  font-size: 11px;
  line-height: 1.25;
  color: #64748b;
}
.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px 112px;
  gap: 6px;
  margin-top: 8px;
}
.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;
}
select {
  width: 100%;
  min-width: 0;
  height: 30px;
  border: 1px solid rgba(148, 163, 184, 0.75);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  color: #111827;
  font: 600 12px Arial, sans-serif;
  padding: 4px 7px;
}
select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.28);
  outline-offset: 1px;
}
.turnout-toggle {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  font: 600 11px Arial, sans-serif;
  color: #111827;
}
.turnout-toggle[hidden] {
  display: none;
}
.legend {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  font-size: 11px;
  color: #64748b;
}
.winner-legend {
  flex-wrap: wrap;
  gap: 5px 9px;
}
.legend--turnout {
  margin-top: 4px;
}
.party-key {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.party-key i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1px solid rgba(17, 24, 39, 0.25);
}
.scale {
  flex: 1;
  min-width: 96px;
  height: 8px;
  border: 1px solid #cbd5e1;
  background: linear-gradient(90deg, #dbeafe, #1e40af);
}
.unattached-box {
  margin-top: 8px;
  padding: 7px 8px 2px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 6px;
  background: rgba(248, 250, 252, 0.85);
}
.unattached-box[hidden] {
  display: none;
}
.unattached-box__title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  color: #111827;
}
.unattached-box__note {
  margin: 2px 0 0;
  font-size: 10px;
}
.map-wrap {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: 100vh;
  padding: 0;
}
/* All four fixed corners are now claimed: header+.sections-panel stack
   top-left, .demographics-panel top-right, .map-tools bottom-right,
   .section-popup bottom-left-of-map. A fifth floating element will need to
   either double up in an occupied column (positionSectionsPanel-style JS
   stacking) or move one of these again. */
.map-tools {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 11;
  display: grid;
  gap: 6px;
}
.map-tools button {
  width: 36px;
  height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: #111827;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.14);
  font: 700 18px Arial, sans-serif;
  line-height: 1;
  cursor: pointer;
}
.map-tools button:hover {
  background: #f8fafc;
}
.sections-panel,
.demographics-panel {
  position: fixed;
  z-index: 12;
  box-sizing: border-box;
  width: calc(var(--sidebar-width) - (var(--panel-edge) * 2));
  display: grid;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(8px);
}
.sections-panel {
  top: 144px;
  left: var(--panel-edge);
  max-height: calc(100vh - 164px);
  grid-template-rows: auto auto minmax(0, 1fr);
}
.sections-panel[hidden],
.demographics-panel[hidden] {
  display: none;
}
.sections-panel.is-collapsed {
  width: calc(var(--sidebar-width) - (var(--panel-edge) * 2));
  grid-template-rows: auto;
}
.sections-panel.is-collapsed .sections-panel__sort,
.sections-panel.is-collapsed .sections-list {
  display: none;
}
.sections-panel.is-collapsed .sections-panel__header {
  border-bottom: 0;
}
.sections-panel__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 8px;
  align-items: center;
  padding: 10px 10px 8px;
}
.sections-panel__title,
.demographics-panel__title {
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sections-panel__meta {
  margin-top: 2px;
  color: #64748b;
  font-size: 11px;
}
.sections-panel__toggle {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(148, 163, 184, 0.75);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: #111827;
  font: 700 16px Arial, sans-serif;
  cursor: pointer;
}
.sections-panel__sort {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 10px;
}
.sections-panel__sort button {
  min-width: 0;
  height: 30px;
  border: 1px solid rgba(148, 163, 184, 0.75);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: #334155;
  font: 700 11px Arial, sans-serif;
  cursor: pointer;
}
.sections-panel__sort button.is-active {
  border-color: rgba(37, 99, 235, 0.6);
  background: #dbeafe;
  color: #1e3a8a;
}
.sections-list,
.demographics-list {
  overflow: auto;
  padding: 6px;
}
.section-rank-row {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #111827;
  text-align: left;
  cursor: pointer;
}
.section-rank-row:hover {
  background: #f8fafc;
}
.section-rank-row.is-selected {
  background: #fef3c7;
}
.section-rank-row__title {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}
.section-rank-row__meta {
  display: block;
  margin-top: 2px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #64748b;
  font-size: 11px;
}
.section-rank-row__score {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #111827;
}
.section-rank-row__votes {
  margin-top: 2px;
  text-align: right;
  color: #64748b;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.sections-empty,
.demographics-empty {
  padding: 18px 10px;
  color: #64748b;
  font-size: 12px;
  text-align: center;
}
.demographics-panel {
  top: var(--panel-edge);
  right: 14px;
  max-height: calc(100vh - (var(--panel-edge) * 2));
  grid-template-rows: auto minmax(0, 1fr);
}
.demographics-panel__header {
  padding: 10px 10px 8px;
}
.demographics-topic {
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}
.demographics-topic:last-child {
  border-bottom: 0;
}
.demographics-topic__header {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 0;
  background: transparent;
  color: #111827;
  font: 700 12px Arial, sans-serif;
  text-align: left;
  cursor: pointer;
}
.demographics-topic__header:hover {
  background: #f8fafc;
}
.demographics-topic__toggle {
  color: #64748b;
  font-weight: 700;
}
.demographics-topic__body {
  display: none;
  padding: 0 8px 8px;
}
.demographics-topic.is-expanded .demographics-topic__body {
  display: grid;
  gap: 4px;
}
.demographics-variable {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  font-size: 11px;
}
.demographics-variable__label {
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.demographics-variable__value {
  color: #111827;
  font-weight: 700;
  white-space: nowrap;
}
.section-popup {
  position: fixed;
  left: calc(var(--sidebar-width) + var(--panel-edge));
  bottom: 14px;
  z-index: 12;
  width: min(320px, calc(100vw - 28px));
  max-height: min(58vh, 430px);
  overflow: auto;
  padding: 11px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(203, 213, 225, 0.95);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(10px);
}
.section-popup[hidden] {
  display: none;
}
.section-popup__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  gap: 8px;
  align-items: start;
}
.section-popup h2 {
  margin: 0;
  font-size: 13px;
  line-height: 1.25;
}
.section-popup__meta {
  margin: 3px 0 0;
  color: #64748b;
  font-size: 11px;
  line-height: 1.3;
}
.section-popup__close {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(148, 163, 184, 0.75);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: #111827;
  font: 700 18px Arial, sans-serif;
  line-height: 1;
  cursor: pointer;
}
.section-popup__summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.section-popup__summary span {
  display: block;
  color: #64748b;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.section-popup__summary strong {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #111827;
}
.section-results {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}
.section-result {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto auto;
  gap: 7px;
  align-items: center;
  min-height: 24px;
  padding: 3px 4px;
  border-radius: 6px;
  font-size: 12px;
}
.section-result.is-current {
  background: rgba(219, 234, 254, 0.7);
}
.section-result i {
  width: 10px;
  height: 10px;
  border: 1px solid rgba(17, 24, 39, 0.25);
}
.section-result__party {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}
.section-result__votes {
  font-variant-numeric: tabular-nums;
  color: #111827;
}
.section-result__share {
  width: 46px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #64748b;
}
svg {
  width: 100%;
  height: 100%;
  display: block;
  background: white;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
svg.is-panning {
  cursor: grabbing;
}
.section {
  fill: #eff6ff;
  fill-opacity: 0.62;
  fill-rule: evenodd;
  stroke: #1e3a8a;
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill-opacity 120ms ease;
}
.section:hover {
  fill-opacity: 0.76;
}
.section.is-selected {
  fill-opacity: 0.86;
}
.section-selection-outline {
  fill: none;
  stroke: #facc15;
  stroke-width: 3.25;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  filter: drop-shadow(0 0 2px rgba(15, 23, 42, 0.38));
}
@media (max-width: 720px) {
  body {
    --sidebar-width: 0px;
    --panel-edge: 10px;
  }
  header {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: 55vh;
    overflow-y: auto;
    padding: 9px;
  }
  .controls {
    grid-template-columns: minmax(0, 1fr) 68px 96px;
  }
  .boundary-note {
    display: none;
  }
  .map-tools {
    top: 136px;
    bottom: auto;
    right: 10px;
  }
  .map-tools button {
    width: 34px;
    height: 34px;
  }
  .map-wrap {
    left: 0;
  }
  .section-popup {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: min(42vh, 340px);
    padding: 10px;
  }
  .sections-panel {
    display: none;
  }
  .demographics-panel {
    display: none;
  }
}

/* OSM context layer (roads, rail, water, parks, stations) */
.osm-road {
  fill: none;
  stroke: #4b5563;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.osm-road-primary {
  stroke: #111827;
  stroke-width: 4.2;
}
.osm-rail {
  fill: none;
  stroke: #27272a;
  stroke-width: 2;
  stroke-dasharray: 7 7;
  vector-effect: non-scaling-stroke;
}
.osm-water {
  fill: #bae6fd;
  fill-opacity: 0.58;
  stroke: #0284c7;
  stroke-opacity: 0.5;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}
.osm-water-line {
  fill: none;
  stroke: #0284c7;
  stroke-opacity: 0.68;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.osm-park {
  fill: #d9f99d;
  fill-opacity: 0.55;
  stroke: #65a30d;
  stroke-opacity: 0.7;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}
.osm-protected {
  fill: #bbf7d0;
  fill-opacity: 0.38;
  stroke: #15803d;
  stroke-opacity: 0.75;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}
.osm-station {
  fill: #ffffff;
  stroke: #18181b;
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
}
.osm-label {
  font-size: 42px;
  fill: #111827;
  stroke: #ffffff;
  stroke-width: 8px;
  paint-order: stroke;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
