html, body { margin: 0; height: 100%; font-family: system-ui, sans-serif; }
#map { position: absolute; inset: 0; }
.panel {
  position: absolute; top: 12px; left: 12px; width: 240px; max-height: calc(100% - 48px); overflow-y: auto;
  background: rgba(255, 255, 255, 0.95); border-radius: 6px;
  padding: 10px 14px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); font-size: 13px;
}
.panel h1 { font-size: 15px; margin: 0 0 8px; }
.panel ul { list-style: none; margin: 0; padding: 0; }
.panel li { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.field[hidden] { display: none; }
.field { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; color: #555; font-size: 12px; }
.field select { font: inherit; font-size: 13px; padding: 3px; color: #111; }
.swatch { width: 14px; height: 14px; border-radius: 2px; flex: none; }
.count { margin-left: auto; color: #666; font-variant-numeric: tabular-nums; }
#scale { margin-bottom: 8px; }
.scale-bar { height: 10px; border-radius: 2px; }
.scale-labels { display: flex; justify-content: space-between; color: #666; font-size: 11px; }
.source { margin: 8px 0 0; color: #888; font-size: 11px; }
.popup h2 { font-size: 14px; margin: 0 0 2px; }
.popup .meta { color: #666; margin-bottom: 6px; }
.popup table { border-collapse: collapse; }
.popup td { padding: 1px 6px 1px 0; }
.popup td.pct { text-align: right; font-variant-numeric: tabular-nums; }
.panel.error { top: auto; bottom: 12px; left: 50%; transform: translateX(-50%); width: auto; max-width: 420px; background: #fdecea; color: #b71c1c; }
.map-settings { border-top: 1px solid #e5e5e5; margin-top: 8px; padding-top: 8px; }
.field input[type="range"] { width: 100%; margin: 2px 0 0; }
.hover-popup { pointer-events: none; }
.popup td.bar { width: 70px; }
.popup td.bar span { display: block; height: 7px; border-radius: 2px; opacity: 0.85; }
.popup tr.extra { display: none; }
.popup.expanded tr.extra { display: table-row; }
.popup .more { margin-top: 4px; padding: 2px 0; border: 0; background: none; color: #2563eb; font: inherit; font-size: 12px; cursor: pointer; }
.hover-popup .popup .more { color: #888; }
.popup .rank { color: #888; font-size: 11px; }
.popup.expanded tr { display: table-row; }
.advanced { margin-top: 4px; }
.advanced summary { cursor: pointer; color: #555; font-size: 12px; }
.advanced-body { padding: 6px 0 0; }
.advanced-title { color: #333; font-size: 12px; margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; color: #555; font-size: 12px; }
.field input[type="range"]:disabled { opacity: 0.4; }
.hint { margin: 0; color: #888; font-size: 11px; }
.popup td.votes { text-align: right; color: #777; font-size: 11px; font-variant-numeric: tabular-nums; padding-left: 4px; }
.panel li.note { color: #888; font-size: 11px; margin-top: 4px; }

.popup .missing { color: #c62828; font-weight: 600; }
.panel .share { width: 46px; flex: none; text-align: right; color: #333; font-variant-numeric: tabular-nums; }
.panel li.head { color: #888; font-size: 11px; margin-bottom: 4px; }
.panel li.head .share, .panel li.head .count { color: #888; }
#crumbs { margin: -4px 0 8px; }
#crumbs .trail { margin-bottom: 2px; line-height: 1.4; }
#crumbs .crumb { border: 0; padding: 0; background: none; color: #2563eb; font: inherit; cursor: pointer; }
#crumbs .crumb:hover { text-decoration: underline; }
.panel.toast { top: auto; bottom: 24px; left: 50%; transform: translateX(-50%); width: auto; max-width: 420px; }
/* Country box above the main panel; the two stack in the sidebar, the main panel scrolling when tall */
#sidebar { position: absolute; top: 12px; left: 12px; width: 268px; max-height: calc(100% - 36px);
  display: flex; flex-direction: column; gap: 8px; }
#sidebar .panel { position: static; width: auto; max-height: none; }
#sidebar #legend { overflow-y: auto; min-height: 0; flex: 0 1 auto; }
#country-panel { padding: 8px 14px 2px; }
#country-panel .field { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: #333; font-weight: 600; }
#country-panel select { flex: 1; font-weight: normal; }

/* live results badge (elections of 24 October 2026) */
.live-status { margin: -4px 0 8px; font-size: 12px; color: #b71c1c; font-weight: 600; }
.live-status::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px;
  border-radius: 50%; background: #e53935; vertical-align: 1px; animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: 0.25; } }

/* panel header: title and live status, language button, menu button (phones) */
.panel-head { display: flex; align-items: flex-start; gap: 6px; }
.panel-title { flex: 1; min-width: 0; }
.head-button { flex: none; border: 1px solid #ccc; background: #fff; border-radius: 4px; font: inherit; font-size: 11px;
  font-weight: 600; padding: 3px 7px; cursor: pointer; color: #333; }
.head-button:hover { background: #f2f2f2; }
#menu-toggle { display: none; }
.panel[hidden] { display: none; }

/* phones: the panel is a sheet at the bottom, collapsed to its header until "Menu" opens it, so the map stays free */
@media (max-width: 700px) {
  #sidebar { z-index: 3; top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 72vh; gap: 0; }
  #sidebar .panel { background: #fff; border-radius: 12px 12px 0 0; box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2); }
  #sidebar #country-panel { border-radius: 12px 12px 0 0; border-bottom: 1px solid #e5e5e5; }
  #sidebar #country-panel + #legend { border-radius: 0; }
  #sidebar.collapsed #country-panel, #sidebar.collapsed #legend-body { display: none; }
  #sidebar.collapsed #legend { border-radius: 12px 12px 0 0; }
  #menu-toggle { display: inline-block; }
  .panel h1 { font-size: 14px; margin-bottom: 4px; }
  .live-status { margin: 0 0 2px; font-size: 11px; }
  .field select, .head-button { font-size: 15px; }   /* (16px-ish controls: no zoom-in on focus, easy to tap) */
  .head-button { padding: 5px 10px; }
  .maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: 72px; }
  .panel.toast { bottom: 96px; max-width: 90vw; }
  .maplibregl-popup { max-width: 88vw !important; }
}

/* results of the area in view (horizontal bars): right on wide screens, on top on phones; minimisable */
#results-panel { left: auto; right: 12px; top: 12px; width: 300px; max-height: calc(100% - 150px); z-index: 2; }
#results-panel h2 { font-size: 14px; margin: 0; }
.results-sub { color: #777; font-size: 11px; margin-top: 2px; }
.results-summary { display: none; margin-top: 4px; font-size: 12px; color: #333; }
#results-panel.minimised .results-summary { display: block; }
#results-panel.minimised #results-body { display: none; }
#results-body { margin-top: 6px; }
.results-bars li { display: block; margin: 0 0 7px; }
.results-bars .row { display: flex; gap: 6px; align-items: baseline; font-size: 12px; }
.results-bars .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results-bars .pct { font-weight: 600; font-variant-numeric: tabular-nums; }
.results-bars .votes { color: #888; font-size: 11px; font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.results-bars .bar { height: 9px; background: #eee; border-radius: 2px; margin-top: 2px; overflow: hidden; }
.results-bars .bar span { display: block; height: 100%; border-radius: 2px; }
.results-bars li.empty { color: #888; font-size: 12px; }
@media (max-width: 700px) {
  #results-panel { top: 0; left: 0; right: 0; width: auto; max-height: 42vh; border-radius: 0 0 12px 12px;
    background: #fff; padding: 8px 14px; }
}
