:root {
  color-scheme: light dark;
  --background: #f7f7f5;
  --foreground: #1d1d1f;
  --surface: #ffffff;
  --muted: #e8e8e5;
  --muted-foreground: #656568;
  --border: #cfcfca;
  --accent: #e7eef8;
  --strong-left: #082f6b;
  --left: #4f82bd;
  --center-left: #abc8e6;
  --center: #c9bdcc;
  --center-border: #887b8d;
  --center-right: #edb9a6;
  --right: #d26442;
  --strong-right: #781f1f;
  --env-strong-positive: #176b45;
  --env-positive: #4c9a68;
  --env-light-positive: #add5b8;
  --env-neutral: #cbc8c5;
  --env-light-negative: #f4dda3;
  --env-negative: #e4a53d;
  --env-strong-negative: #b96516;
  --focus: #2867b2;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #171718;
    --foreground: #efefef;
    --surface: #232325;
    --muted: #343436;
    --muted-foreground: #b4b4b7;
    --border: #4b4b4e;
    --accent: #29384d;
    --strong-left: #b9dcff;
    --left: #67a3e3;
    --center-left: #3f678f;
    --center: #665b6b;
    --center-border: #b8aabd;
    --center-right: #854c3d;
    --right: #e07752;
    --strong-right: #ffb59d;
    --env-strong-positive: #8fd6aa;
    --env-positive: #5daf7c;
    --env-light-positive: #356c4c;
    --env-neutral: #625e5a;
    --env-light-negative: #806323;
    --env-negative: #dca23e;
    --env-strong-negative: #ffc268;
    --focus: #8fc2ff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Noto Sans JP", sans-serif;
  line-height: 1.5;
}

button, select, input { font: inherit; }

button, select, input {
  color: var(--foreground);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: .5rem .7rem;
}

button { cursor: pointer; }
button:hover { background: var(--accent); }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

a { color: inherit; }

.app {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: clamp(.75rem, 2vw, 1.5rem);
}

.legend,
.zoom-buttons,
.detail-meta,
.score-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem .8rem;
}

.page-header { display: grid; gap: .3rem; margin-bottom: .8rem; }
.page-title-row,
.page-subtitle-row { display: flex; align-items: center; justify-content: space-between; gap: .65rem 1rem; }
.page-title-row { min-width: 0; }
.page-header h1 { margin: 0; font-size: clamp(1.35rem, 3vw, 2rem); font-weight: 600; }
.page-header p { margin: .2rem 0 0; color: var(--muted-foreground); }
.page-subtitle-actions { display: flex; align-items: center; gap: .45rem; flex: 0 0 auto; }

.language-bar {
  flex: 0 0 auto;
}
.language-bar label {
  display: flex;
  align-items: center;
  gap: .35rem;
  color: var(--muted-foreground);
  font-size: .78rem;
  font-weight: 600;
}
.language-bar select { width: auto; min-width: 7.4rem; min-height: 2.15rem; padding: .3rem .55rem; font-size: .86rem; }

.about-entry-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .42rem;
  min-height: 2.2rem;
  margin-left: auto;
  padding: .38rem .72rem;
  border: 1px solid color-mix(in srgb, var(--focus) 58%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 82%, var(--surface));
  box-shadow: 0 .15rem .55rem color-mix(in srgb, var(--foreground) 10%, transparent);
  font-size: .84rem;
  font-weight: 720;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .16s ease, background-color .16s ease, transform .16s ease;
}

.about-entry-link:hover {
  border-color: var(--focus);
  background: color-mix(in srgb, var(--accent) 58%, var(--surface));
  transform: translateY(-1px);
}

.about-entry-icon {
  display: inline-grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: var(--focus);
  color: var(--surface);
  font-family: Georgia, serif;
  font-size: .78rem;
  font-weight: 800;
}

.about-entry-link-mobile { display: none; }

.status-badge,
.category-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: var(--muted);
  font-size: .875rem;
}

.controls {
  position: absolute;
  z-index: 8;
  top: .75rem;
  left: .75rem;
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) auto;
  align-items: end;
  gap: .5rem;
  width: min(24.5rem, calc(100% - 1.5rem));
  max-width: calc(100% - 1.5rem);
  margin: 0;
  padding: .5rem;
  border: 1px solid var(--border);
  border-radius: .65rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 .25rem .85rem color-mix(in srgb, var(--foreground) 14%, transparent);
  backdrop-filter: blur(.35rem);
}
.controls label,
.zoom-control { display: grid; gap: .18rem; min-width: 0; }
.controls label > span,
.control-label { color: var(--muted-foreground); font-size: .72rem; font-weight: 650; }
.controls select,
.zoom-buttons button { min-height: 2.4rem; }
.controls select { width: 100%; padding-block: .36rem; }
.zoom-buttons {
  display: grid;
  grid-template-columns: 2.4rem 2.4rem minmax(4.9rem, max-content);
  gap: .3rem;
}
.zoom-buttons button { min-width: 2.4rem; padding: .35rem .55rem; }
.zoom-buttons button:last-child { min-width: 0; white-space: nowrap; padding-inline: .65rem; }

.baseline-control { display: grid; grid-column: 1 / -1; gap: .18rem; min-width: 0; }
.baseline-toggle {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  min-height: 2.4rem;
  padding: .18rem;
  border: 1px solid var(--border);
  border-radius: .55rem;
  background: var(--muted);
  isolation: isolate;
}
.baseline-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.baseline-toggle label {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: .38rem .55rem;
  border-radius: .4rem;
  color: var(--muted-foreground);
  font-size: .72rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: color .18s ease;
}
.baseline-toggle-slider {
  position: absolute;
  z-index: 1;
  top: .18rem;
  bottom: .18rem;
  left: .18rem;
  width: calc(50% - .18rem);
  border: 1px solid color-mix(in srgb, var(--border) 75%, var(--foreground));
  border-radius: .4rem;
  background: var(--surface);
  box-shadow: 0 .08rem .25rem color-mix(in srgb, var(--foreground) 13%, transparent);
  transition: transform .2s ease;
}
#baseline-relative:checked ~ .baseline-toggle-slider { transform: translateX(100%); }
#baseline-policy:checked + label,
#baseline-relative:checked + label { color: var(--foreground); }
#baseline-policy:focus-visible + label,
#baseline-relative:focus-visible + label { outline: 3px solid var(--focus); outline-offset: -2px; }

html[lang="ja-JP"] .baseline-toggle label,
html[lang="ko-KR"] .baseline-toggle label {
  padding-inline: .35rem;
  font-size: .68rem;
  white-space: nowrap;
}

.location-tools {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(20rem, .8fr);
  gap: 0;
  width: 100%;
  margin: 0 0 .7rem;
  border: 1px solid var(--border);
  border-radius: .75rem;
  background: var(--surface);
  overflow: hidden;
}
.place-search {
  min-width: 0;
  padding: .62rem .78rem;
}
.place-search form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: .35rem;
}
.place-search-copy { display: grid; gap: .1rem; }
.place-search-copy span { color: var(--muted-foreground); font-size: .875rem; }
.place-search-actions { display: flex; align-items: center; gap: .45rem; }
.place-search-actions input { min-width: 0; flex: 1 1 auto; }
.place-search-actions button { flex: 0 0 auto; font-weight: 650; }
.place-search-actions button:disabled { cursor: not-allowed; opacity: .55; }
.place-search-status { min-height: 1.2em; margin: 0; color: var(--muted-foreground); font-size: .8rem; }
.place-search-status:empty { display: none; }
.place-search-status.error { color: #bd2c2c; }

.ward-browser {
  display: grid;
  align-content: start;
  gap: .35rem;
  min-width: 0;
  padding: .62rem .78rem;
  border-left: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 64%, var(--surface));
}
.ward-browser-copy { display: grid; gap: .1rem; }
.ward-browser-copy span { color: var(--muted-foreground); font-size: .875rem; }
.ward-browser-actions { display: flex; align-items: center; gap: .45rem; min-width: 0; }
.ward-browser-actions select { min-width: 0; flex: 1 1 auto; }
.ward-browser-actions button { font-weight: 650; border-color: var(--focus); }
.ward-browser-actions button:disabled { cursor: not-allowed; opacity: .55; }

@media (max-width: 900px) {
  .location-tools { grid-template-columns: minmax(0, 1fr); }
  .ward-browser { border-top: 1px solid var(--border); border-left: 0; }
}

.legend { margin-bottom: .55rem; font-size: .875rem; color: var(--muted-foreground); }
.legend-key { display: inline-flex; align-items: center; gap: .3rem; }
.legend-swatch { width: .8rem; height: .8rem; border: 1px solid var(--border); border-radius: .15rem; }
.legend-swatch.strong-left { background: var(--strong-left); }
.legend-swatch.left { background: var(--left); }
.legend-swatch.center-left { background: var(--center-left); }
.legend-swatch.center { background: var(--center); }
.legend-swatch.center-right { background: var(--center-right); }
.legend-swatch.right { background: var(--right); }
.legend-swatch.strong-right { background: var(--strong-right); }
.legend-swatch.env-strong-positive { background: var(--env-strong-positive); }
.legend-swatch.env-positive { background: var(--env-positive); }
.legend-swatch.env-light-positive { background: var(--env-light-positive); }
.legend-swatch.env-neutral { background: var(--env-neutral); }
.legend-swatch.env-light-negative { background: var(--env-light-negative); }
.legend-swatch.env-negative { background: var(--env-negative); }
.legend-swatch.env-strong-negative { background: var(--env-strong-negative); }
.legend-swatch.pending { background: transparent; }
.legend-swatch.strong-left,
.legend-swatch.strong-right,
.legend-swatch.env-strong-positive,
.legend-swatch.env-strong-negative { border-color: var(--foreground); }

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 340px);
  gap: 1rem;
  align-items: stretch;
}

.map-panel {
  position: relative;
  min-width: 0;
  min-height: 43rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: .75rem;
  background-color: var(--surface);
  background-image: radial-gradient(
    circle,
    color-mix(in srgb, var(--foreground) 16%, transparent) .68px,
    transparent .78px
  );
  background-size: 9px 9px;
}
#municipality-map {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 43rem;
  touch-action: none;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24'%3E%3Cpath d='M4 2.5v15.8l4.4-3.5 3.1 6.2 3-1.5-3.1-6.1 5.6-.9z' fill='%23172233' stroke='%23fff' stroke-width='3.4' stroke-linejoin='round'/%3E%3Cpath d='M4 2.5v15.8l4.4-3.5 3.1 6.2 3-1.5-3.1-6.1 5.6-.9z' fill='%23172233' stroke='%23172233' stroke-width='1.1' stroke-linejoin='round'/%3E%3C/svg%3E") 3 2, grab;
}
#municipality-map:active {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24'%3E%3Cpath d='M4 2.5v15.8l4.4-3.5 3.1 6.2 3-1.5-3.1-6.1 5.6-.9z' fill='%23172233' stroke='%23fff' stroke-width='3.4' stroke-linejoin='round'/%3E%3Cpath d='M4 2.5v15.8l4.4-3.5 3.1 6.2 3-1.5-3.1-6.1 5.6-.9z' fill='%23172233' stroke='%23172233' stroke-width='1.1' stroke-linejoin='round'/%3E%3C/svg%3E") 3 2, grabbing;
}

.southern-inset-frame {
  fill: url(#southern-inset-dot-pattern);
  stroke: #8b9096;
  stroke-width: 1;
  stroke-dasharray: 5 4;
  stroke-linejoin: round;
  opacity: .82;
  vector-effect: non-scaling-stroke;
}
.southern-inset-dot {
  fill: color-mix(in srgb, var(--foreground) 16%, transparent);
}
.southern-inset-surface {
  fill: var(--surface);
}
.municipality {
  fill: color-mix(in srgb, var(--muted) 75%, transparent);
  stroke: var(--border);
  stroke-width: .48;
  vector-effect: non-scaling-stroke;
  cursor: inherit;
}
.municipality.strong-left { fill: var(--strong-left); }
.municipality.left { fill: var(--left); }
.municipality.center-left { fill: var(--center-left); }
.municipality.center {
  fill: var(--center);
  stroke: var(--center-border);
  stroke-width: .68;
}
.municipality.center-right { fill: var(--center-right); }
.municipality.right { fill: var(--right); }
.municipality.strong-right { fill: var(--strong-right); }
.municipality.env-strong-positive { fill: var(--env-strong-positive); }
.municipality.env-positive { fill: var(--env-positive); }
.municipality.env-light-positive { fill: var(--env-light-positive); }
.municipality.env-neutral { fill: var(--env-neutral); stroke: var(--center-border); stroke-width: .68; }
.municipality.env-light-negative { fill: var(--env-light-negative); }
.municipality.env-negative { fill: var(--env-negative); }
.municipality.env-strong-negative { fill: var(--env-strong-negative); }
.municipality.strong-left,
.municipality.strong-right,
.municipality.env-strong-positive,
.municipality.env-strong-negative { stroke-width: .72; }
.municipality.designated-city { stroke: var(--focus); stroke-width: 1.25; }
.municipality:hover, .municipality.selected { stroke: var(--foreground); stroke-width: 2.2; }
.municipality:focus { outline: none; stroke: var(--focus); stroke-width: 3.2; }
.municipality:focus-visible { filter: drop-shadow(0 0 2px var(--surface)); }
.municipality.ward { stroke-width: .8; }
.municipality.ward:hover, .municipality.ward.selected { stroke-width: 2.4; }

.detail-panel {
  height: 100%;
  min-height: 19rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .75rem;
  padding: 1rem;
}
.detail-panel h2 { margin: 0 0 .35rem; font-size: 1.2rem; }
.detail-panel h3 { margin: 1rem 0 .25rem; font-size: 1rem; }
.detail-panel p { margin: .45rem 0 0; }
.detail-panel dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .25rem .65rem;
  margin: .75rem 0 0;
}
.detail-panel dt { color: var(--muted-foreground); }
.detail-panel dd { margin: 0; font-variant-numeric: tabular-nums; white-space: pre-line; }
.confidence-help { position: relative; display: inline-flex; vertical-align: middle; }
.confidence-help-button {
  display: inline-grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--muted-foreground);
  border-radius: 50%;
  background: transparent;
  color: var(--muted-foreground);
  font: 700 .72rem/1 sans-serif;
}
.confidence-tooltip {
  position: absolute;
  z-index: 20;
  left: 50%;
  bottom: calc(100% + .5rem);
  display: none;
  width: min(18rem, 72vw);
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: .4rem;
  background: var(--foreground);
  color: var(--surface);
  box-shadow: 0 .3rem 1rem color-mix(in srgb, #000 24%, transparent);
  font-size: .78rem;
  font-weight: 400;
  line-height: 1.45;
  transform: translateX(-50%);
}
.confidence-help-button:focus-visible + .confidence-tooltip,
.confidence-help.open .confidence-tooltip { display: block; }
@media (hover: hover) {
  .confidence-help:hover .confidence-tooltip { display: block; }
}
.detail-meta { color: var(--muted-foreground); font-size: .875rem; }
.score-line { margin-top: .7rem; }
.score-value { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.axis-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; margin-top: .75rem; }
.axis-item { border-top: 1px solid var(--border); padding-top: .4rem; }
.axis-item span { display: block; color: var(--muted-foreground); font-size: .8rem; }
.axis-item strong { font-variant-numeric: tabular-nums; }
.source-list { margin: .35rem 0 0; padding-left: 1.15rem; }
.ward-action { width: 100%; margin-top: 1rem; font-weight: 600; background: var(--accent); }
.share-result-button { width: 100%; margin-top: .65rem; border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); font-weight: 700; }
.share-dialog { width: min(46rem, calc(100% - 1.5rem)); max-height: calc(100dvh - 1.5rem); padding: 1rem; border: 1px solid var(--border); border-radius: .85rem; background: var(--surface); color: var(--foreground); box-shadow: 0 1rem 3rem #0006; }
.share-dialog::backdrop { background: #08101dcc; backdrop-filter: blur(3px); }
.share-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0; }
.share-dialog-head h2 { margin: 0; font-size: 1.2rem; }
.share-close { min-width: 2.4rem; min-height: 2.4rem; padding: 0; border-radius: 50%; font-size: 1.35rem; }
.share-dialog > p { color: var(--muted-foreground); }
.share-preview { overflow: hidden; border: 1px solid var(--border); border-radius: .65rem; background: var(--muted); aspect-ratio: 1200 / 630; }
.share-preview img { display: block; width: 100%; height: 100%; object-fit: contain; }
.share-preview img[hidden] { display: none; }
.share-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; }
.share-actions button { min-width: 0; }
.share-status { min-height: 1.4em; margin: .55rem 0; font-size: .86rem; }
.ward-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .75rem; }
.ward-toolbar button { flex: 0 0 auto; }
.calculation-audit { margin-top: 1rem; }
.calculation-audit[hidden] { display: none; }
.calculation-trace { border: 1px solid var(--border); border-radius: .75rem; padding: .85rem 1rem; background: var(--surface); }
.calculation-trace > summary { cursor: pointer; font-size: 1.05rem; font-weight: 700; }
.calculation-trace-help { max-width: 70rem; color: var(--muted-foreground); font-size: .875rem; line-height: 1.55; }
.calculation-year { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.calculation-year > h3 { display: inline; margin: 0; font-size: 1.05rem; }
.calculation-year-meta { display: inline; margin-left: .6rem; color: var(--muted-foreground); font-size: .82rem; }
.calculation-party-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; margin-top: .65rem; }
.calculation-party-card {
  --party-color: #77808b;
  min-width: 0;
  padding: .75rem;
  border: 1px solid color-mix(in srgb, var(--party-color) 38%, var(--border));
  border-left: 4px solid var(--party-color);
  border-radius: .6rem;
  background: linear-gradient(135deg, color-mix(in srgb, var(--party-color) 10%, var(--surface)), var(--surface) 72%);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--party-color) 10%, transparent);
}
.calculation-party-card.party-ldp { --party-color: #d71920; }
.calculation-party-card.party-cdp { --party-color: #004098; }
.calculation-party-card.party-ishin { --party-color: #69ad2d; }
.calculation-party-card.party-komei { --party-color: #e85298; }
.calculation-party-card.party-dpfp { --party-color: #f2a000; }
.calculation-party-card.party-jcp { --party-color: #c9151e; }
.calculation-party-card.party-reiwa { --party-color: #df0a78; }
.calculation-party-card.party-sdp { --party-color: #00a0d2; }
.calculation-party-card.party-sanseito { --party-color: #e87524; }
.calculation-party-card.party-hoshuto { --party-color: #243b68; }
.calculation-party-card.party-mirai { --party-color: #00a18a; }
.calculation-party-card.party-chudo { --party-color: #2775b6; }
.calculation-party-card.party-nhk { --party-color: #27a9df; }
.calculation-party-card.party-saisei { --party-color: #168b83; }
.calculation-party-card.party-genzei { --party-color: #18378a; }
.calculation-party-card.party-seishinkai { --party-color: #6f2c91; }
.calculation-party-card.party-independent-alliance { --party-color: #526b78; }
.calculation-party-card.party-kaikaku { --party-color: #245aa8; }
.calculation-party-card.party-tsukuru { --party-color: #ef7b2d; }
.calculation-party-card.party-euthanasia { --party-color: #7965a8; }
.calculation-party-card.party-other { --party-color: #77808b; }
.calculation-party-card > header { display: flex; align-items: baseline; flex-wrap: wrap; gap: .25rem .65rem; }
.calculation-party-card h4 { margin: 0; color: var(--foreground); font-size: .95rem; }
.calculation-party-card h4::before { display: inline-block; width: .55rem; height: .55rem; margin-right: .38rem; border-radius: 50%; background: var(--party-color); content: ""; vertical-align: .03rem; }
.party-share { font-weight: 700; font-variant-numeric: tabular-nums; }
.party-confidence { margin-left: auto; color: var(--muted-foreground); font-size: .78rem; }
.calculation-axis-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .35rem; margin-top: .6rem; }
.calculation-axis-item { min-width: 0; padding: .4rem .45rem; border-radius: .35rem; background: var(--surface); }
.calculation-axis-item span { display: block; overflow: hidden; color: var(--muted-foreground); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.calculation-axis-item strong { display: block; margin-top: .1rem; font-size: .72rem; font-variant-numeric: tabular-nums; line-height: 1.35; }
.calculation-party-links { margin: .55rem 0 0; font-size: .78rem; }
.calculation-metadata { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .3rem 1rem; margin-top: 1rem; padding-top: .85rem; border-top: 1px dashed var(--border); }
.calculation-metadata h4 { grid-column: 1 / -1; margin: .25rem 0 0; font-size: .9rem; }
.calculation-metadata dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem .6rem; margin: 0; }
.calculation-metadata dd { margin: 0; font-variant-numeric: tabular-nums; }
.calculation-metadata .source-list { margin-top: 0; }

.national-overview { display: grid; gap: .8rem; margin-top: 1rem; }
.methodology { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .8rem; }
.methodology summary { cursor: pointer; font-weight: 600; }
.method-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1.2rem; margin-top: .7rem; }
.method-grid h2 { margin: 0; font-size: 1rem; }
.method-grid p { margin: .3rem 0 0; }
.national-index-card { grid-column: 1 / -1; padding: .9rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--surface); }
.national-index-headline { display: flex; align-items: baseline; flex-wrap: wrap; gap: .35rem .7rem; margin-top: .55rem; }
.national-index-headline > span:first-child { font-weight: 600; }
.national-index-headline strong { color: var(--strong-right); font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.national-index-headline strong small { font-size: .8rem; color: var(--muted-foreground); }
.national-index-weighted { color: var(--muted-foreground); }
.national-index-scale { position: relative; height: .7rem; margin: .7rem 0 .45rem; border-radius: 999px; background: linear-gradient(90deg, var(--strong-left), var(--center) 50%, var(--strong-right)); }
.national-index-center { position: absolute; left: 50%; top: -.18rem; width: 1px; height: 1.05rem; background: var(--foreground); opacity: .65; }
.national-index-marker { position: absolute; left: 60.1%; top: 50%; width: 1rem; height: 1rem; border: 2px solid var(--surface); border-radius: 50%; background: var(--foreground); box-shadow: 0 0 0 1px var(--foreground); transform: translate(-50%, -50%); }
.national-index-years { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; }
.national-index-years span { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: .25rem; padding: .35rem .45rem; border: 1px solid var(--border); border-radius: .45rem; font-variant-numeric: tabular-nums; }
.national-index-years strong { justify-self: end; }
.national-index-years small { grid-column: 1 / -1; color: var(--muted-foreground); font-size: .72rem; }
.national-index-caveat { color: var(--muted-foreground); font-size: .86rem; }
.national-axis-card { grid-column: 1 / -1; padding: .9rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--surface); }
.national-axis-card > p { margin: .45rem 0 0; }
.national-axis-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16.5rem, 1fr)); gap: .65rem; margin-top: .8rem; }
.national-axis-item { min-width: 0; padding: .7rem; border: 1px solid var(--border); border-radius: .55rem; background: var(--muted); }
.national-axis-item h3 { margin: 0 0 .35rem; font-size: .95rem; }
.national-axis-scale-labels { display: grid; grid-template-columns: 1fr auto 1fr; gap: .35rem; color: var(--muted-foreground); font-size: .67rem; }
.national-axis-scale-labels span:nth-child(2) { justify-self: center; }
.national-axis-scale-labels span:last-child { justify-self: end; text-align: right; }
.national-axis-years { display: grid; gap: .28rem; margin-top: .3rem; }
.national-axis-row { display: grid; grid-template-columns: minmax(4.2rem, auto) minmax(5rem, 1fr) 3.15rem; align-items: center; gap: .42rem; min-height: 1.5rem; font-size: .78rem; font-variant-numeric: tabular-nums; }
.national-axis-row > strong { text-align: right; }
.national-axis-row.weighted { margin-top: .12rem; padding-top: .35rem; border-top: 1px solid var(--border); font-weight: 650; }
.national-axis-track { position: relative; height: .4rem; border-radius: 999px; background: linear-gradient(90deg, var(--strong-right), var(--center) 50%, var(--strong-left)); }
.national-axis-track::after { content: ""; position: absolute; left: 50%; top: -.14rem; width: 1px; height: .68rem; background: var(--foreground); opacity: .55; }
.axis-marker { position: absolute; z-index: 1; top: 50%; width: .68rem; height: .68rem; border: 2px solid var(--surface); border-radius: 50%; background: var(--foreground); box-shadow: 0 0 0 1px var(--foreground); transform: translate(-50%, -50%); }
.axis-pos-2743 { left: 27.43%; }
.axis-pos-2821 { left: 28.21%; }
.axis-pos-3483 { left: 34.83%; }
.axis-pos-3659 { left: 36.59%; }
.axis-pos-3833 { left: 38.33%; }
.axis-pos-4079 { left: 40.79%; }
.axis-pos-4153 { left: 41.53%; }
.axis-pos-4413 { left: 44.13%; }
.axis-pos-4614 { left: 46.14%; }
.axis-pos-4661 { left: 46.61%; }
.axis-pos-4670 { left: 46.70%; }
.axis-pos-4841 { left: 48.41%; }
.axis-pos-4903 { left: 49.03%; }
.axis-pos-4915 { left: 49.15%; }
.axis-pos-4996 { left: 49.96%; }
.axis-pos-5037 { left: 50.37%; }
.axis-pos-5316 { left: 53.16%; }
.axis-pos-5344 { left: 53.44%; }
.axis-pos-5663 { left: 56.63%; }
.axis-pos-5984 { left: 59.84%; }
.axis-marker.leftward { background: var(--strong-left); }
.axis-marker.rightward { background: var(--strong-right); }
.national-axis-item.environment .national-axis-track { background: linear-gradient(90deg, var(--env-strong-negative), var(--env-neutral) 50%, var(--env-strong-positive)); }
.national-axis-item.environment .axis-marker.positive { background: var(--env-strong-positive); }
.national-axis-item.environment .axis-marker.negative { background: var(--env-strong-negative); }
.national-axis-interpretation { padding: .65rem .75rem; border-left: 3px solid var(--right); border-radius: 0 .45rem .45rem 0; background: var(--muted); }
.absolute-change-card { grid-column: 1 / -1; padding: .9rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--surface); }
.absolute-change-axis { position: relative; height: .72rem; margin: .75rem 0 .25rem; border-radius: 999px; background: linear-gradient(90deg, var(--strong-left), var(--center) 50%, var(--strong-right)); }
.absolute-change-zero { position: absolute; left: 50%; top: -.2rem; width: 1px; height: 1.12rem; background: var(--foreground); opacity: .7; }
.absolute-change-observed { position: absolute; left: 58.5%; top: -.14rem; width: 38%; height: 1rem; border-top: 2px solid var(--foreground); border-bottom: 2px solid var(--foreground); background: color-mix(in srgb, var(--strong-right) 28%, transparent); }
.absolute-change-min,
.absolute-change-max { position: absolute; top: 50%; width: .78rem; height: .78rem; border: 2px solid var(--surface); border-radius: 50%; background: var(--foreground); box-shadow: 0 0 0 1px var(--foreground); transform: translate(-50%, -50%); }
.absolute-change-min { left: 58.5%; }
.absolute-change-max { left: 96.5%; }
.absolute-change-axis-labels { display: flex; justify-content: space-between; color: var(--muted-foreground); font-size: .72rem; font-variant-numeric: tabular-nums; }
.absolute-change-range { text-align: center; font-weight: 600; }
.absolute-change-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; margin-top: .7rem; }
.absolute-change-stats p { margin: 0; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: .5rem; background: var(--muted); }
.absolute-change-rankings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; margin-top: .8rem; }
.absolute-change-rankings section { min-width: 0; padding: .7rem; border: 1px solid var(--border); border-radius: .55rem; }
.absolute-change-rankings h3 { margin: 0 0 .4rem; font-size: .95rem; }
.absolute-change-rankings ol { margin: 0; padding: 0; list-style: none; counter-reset: absolute-rank; }
.absolute-change-rankings li { display: grid; grid-template-columns: 1.35rem minmax(0, 1fr) auto; gap: .4rem; padding: .3rem 0; border-bottom: 1px solid var(--border); counter-increment: absolute-rank; }
.absolute-change-rankings li::before { content: counter(absolute-rank) "."; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.absolute-change-rankings li:last-child { border-bottom: 0; }
.absolute-change-rankings li > strong { color: var(--strong-right); font-variant-numeric: tabular-nums; }
.absolute-change-rankings small { display: inline-flex; margin-left: .25rem; padding: .02rem .28rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted-foreground); font-size: .68rem; vertical-align: .08rem; }
.absolute-change-note { color: var(--muted-foreground); font-size: .82rem; }
.absolute-change-interpretation { margin-top: .8rem; padding: .75rem .85rem; border-left: 3px solid var(--strong-right); border-radius: 0 .5rem .5rem 0; background: var(--muted); }
.absolute-change-interpretation p { margin: 0; }
.absolute-change-interpretation p + p { margin-top: .6rem; }
.absolute-change-interpretation strong { margin-right: .12em; }
.layer-explanations, .party-scoring, .environment-party-scoring { margin-top: .8rem; border-top: 1px solid var(--border); padding-top: .8rem; }
.layer-explanations > summary, .party-scoring > summary, .environment-party-scoring > summary { cursor: pointer; font-weight: 600; }
.layer-explanations-content { margin-top: .75rem; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.layer-explanations-content.single-layer-explanation { grid-template-columns: 1fr; }
.layer-explanations-content section { padding: .75rem; border: 1px solid var(--border); border-radius: .55rem; background: var(--surface); }
.layer-explanations-content h2 { margin: 0 0 .35rem; font-size: 1rem; }
.layer-explanations-content p { margin: 0; color: var(--muted-foreground); }
.layer-explanations-note { grid-column: 1 / -1; }
.party-scoring-content { margin-top: .75rem; }
.party-scoring-content > p { margin: 0; }
.party-localized-summary { display: block; }
.party-axis-notes { margin: .65rem 0; padding-left: 1.2rem; }
.party-axis-notes li + li { margin-top: .25rem; }
.party-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: .65rem; background: var(--surface); }
.party-table-wrap:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.party-score-table { width: 100%; min-width: 55rem; border-collapse: collapse; font-size: .84rem; }
.party-score-table th,
.party-score-table td { padding: .5rem .55rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.party-score-table thead th { position: sticky; top: 0; background: var(--muted); white-space: nowrap; }
.party-score-table tbody tr:last-child > * { border-bottom: 0; }
.party-score-table th:nth-child(10),
.party-score-table td:nth-child(10) { display: none; }
.party-score-table th:nth-child(n+3):nth-child(-n+7),
.party-score-table td:nth-child(n+3):nth-child(-n+7) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.party-score-table th:nth-child(8),
.party-score-table td:nth-child(8),
.party-score-table th:nth-child(9),
.party-score-table td:nth-child(9) { text-align: center; white-space: nowrap; }
.party-score-table a { color: inherit; text-underline-offset: .15em; }
.party-direction { display: inline-flex; padding: .08rem .4rem; border: 1px solid var(--border); border-radius: 999px; white-space: nowrap; }
.party-direction.strong-left { background: color-mix(in srgb, var(--strong-left) 28%, var(--surface)); }
.party-direction.left,
.party-direction.mild-left { background: color-mix(in srgb, var(--left) 20%, var(--surface)); }
.party-direction.mixed { background: color-mix(in srgb, var(--center) 35%, var(--surface)); }
.party-direction.right,
.party-direction.mild-right { background: color-mix(in srgb, var(--right) 20%, var(--surface)); }
.party-direction.strong-right { background: color-mix(in srgb, var(--strong-right) 25%, var(--surface)); }
.environment-party-score-table { min-width: 42rem; }
.environment-party-score-table th:nth-child(3),
.environment-party-score-table td:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.environment-party-score-table th:nth-child(4),
.environment-party-score-table td:nth-child(4),
.environment-party-score-table th:nth-child(5),
.environment-party-score-table td:nth-child(5) { text-align: center; white-space: nowrap; }
.environment-direction { display: inline-flex; padding: .08rem .4rem; border: 1px solid var(--border); border-radius: 999px; white-space: nowrap; }
.environment-direction.strong-phaseout { background: color-mix(in srgb, var(--env-strong-positive) 32%, var(--surface)); }
.environment-direction.phaseout,
.environment-direction.mild-phaseout { background: color-mix(in srgb, var(--env-positive) 22%, var(--surface)); }
.environment-direction.nuclear { background: color-mix(in srgb, var(--env-negative) 24%, var(--surface)); }
.environment-direction.strong-nuclear { background: color-mix(in srgb, var(--env-strong-negative) 28%, var(--surface)); }
.party-scoring-notes { margin-top: .8rem; padding: .1rem .8rem; border-left: 3px solid var(--border); color: var(--muted-foreground); }
.party-scoring-notes p { margin: .55rem 0; }
code { overflow-wrap: anywhere; }
footer { margin-top: .8rem; color: var(--muted-foreground); font-size: .8rem; }
.open-source-attribution a { text-underline-offset: .15em; }

.error { color: #bd2c2c; }

@media (max-width: 720px) {
  .share-actions { grid-template-columns: 1fr; }
  .map-layout { grid-template-columns: 1fr; }
  .page-title-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    column-gap: .65rem;
  }
  .page-title-row h1 { min-width: 0; overflow-wrap: anywhere; }
  .page-title-row .language-bar { grid-column: 2; grid-row: 1; align-self: start; }
  .page-title-row > .about-entry-link { display: none; }
  .page-subtitle-row { align-items: flex-start; flex-wrap: wrap; }
  .page-subtitle-row > p { flex: 1 0 100%; }
  .page-subtitle-actions { width: 100%; justify-content: flex-end; }
  .page-subtitle-actions .status-badge { width: auto; min-width: 0; font-size: .78rem; }
  .about-entry-link-mobile {
    display: inline-flex;
    flex: 0 0 auto;
    min-height: 1.75rem;
    margin-left: 0;
    padding: .2rem .52rem;
    font-size: .78rem;
    box-shadow: none;
  }
  .about-entry-link-mobile .about-entry-icon { width: 1rem; height: 1rem; font-size: .68rem; }
  .language-bar label > span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .language-bar select { min-width: 6.8rem; max-width: 7.6rem; min-height: 2rem; font-size: .8rem; }
  .controls {
    top: .5rem;
    left: .5rem;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .4rem;
    width: calc(100% - 1rem);
    max-width: calc(100% - 1rem);
  }
  .controls select { width: 100%; min-width: 0; }
  .layer-control { width: 100%; min-width: 0; }
  .zoom-buttons { grid-template-columns: 2.25rem 2.25rem minmax(4.7rem, max-content); gap: .25rem; }
  .zoom-buttons button { min-width: 0; padding-inline: .4rem; }
  .location-tools { width: 100%; border-radius: .65rem; }
  .place-search,
  .ward-browser { padding: .55rem .68rem; }
  .ward-browser-actions { width: 100%; }
  .ward-browser-actions select { min-width: 0; flex: 1 1 auto; }
  .map-panel { min-height: min(72vh, 40rem); }
  #municipality-map { min-height: min(72vh, 40rem); max-height: none; }
  .detail-panel { min-height: 0; }
  .calculation-trace { padding: .75rem; }
  .calculation-year-meta { display: block; margin: .2rem 0 0; }
  .calculation-party-list { grid-template-columns: 1fr; }
  .calculation-axis-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .party-confidence { width: 100%; margin-left: 0; }
  .calculation-metadata { grid-template-columns: 1fr; }
  .calculation-metadata h4 { grid-column: 1; }
  .method-grid { grid-template-columns: 1fr; }
  .absolute-change-stats { grid-template-columns: 1fr; }
  .absolute-change-rankings { grid-template-columns: 1fr; }
  .layer-explanations-content { grid-template-columns: 1fr; }
  .layer-explanations-note { grid-column: auto; }
}

@media (max-width: 390px) {
  .controls { grid-template-columns: 1fr; align-items: stretch; }
  .baseline-control,
  .zoom-control { grid-column: 1; }
  .controls select { width: 100%; }
  .zoom-buttons { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .axis-grid { grid-template-columns: 1fr; }
  .national-index-years { grid-template-columns: 1fr; }
  .place-search-actions { align-items: stretch; flex-direction: column; }
  .place-search-actions button { width: 100%; }
  .ward-browser-actions { align-items: stretch; flex-direction: column; }
}

@media (max-width: 520px) {
  .place-search-actions,
  .ward-browser-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
  }
  .place-search-actions button,
  .ward-browser-actions button { width: auto; padding-inline: .5rem; font-size: .78rem; }
  .ward-browser-actions select { width: auto; min-width: 0; }
}
