/* =========================================================================
   Regeringssimulatorn — style.css
   Art direction: nordisk civic-data — sober, precis, neutral gentemot alla
   block. Accentfärg (indigo) tillhör inget parti, för att inte antyda
   politisk vinkling. Partifärger reserveras uteslutande för datavisualisering.
   ========================================================================= */

/* ---------- Design tokens ---------- */
:root, [data-theme="light"] {
  --color-bg: #f4f5fa;
  --color-surface: #ffffff;
  --color-surface-2: #fbfbfe;
  --color-surface-offset: #edeef6;
  --color-divider: #e3e5f0;
  --color-border: #d7d9e8;
  --color-text: #14162b;
  --color-text-muted: #565a75;
  --color-text-faint: #9598b3;
  --color-text-inverse: #f7f8fc;

  --color-primary: #4249d6;
  --color-primary-hover: #333ab0;
  --color-primary-active: #262c8a;
  --color-primary-highlight: #e2e3fa;

  --color-success: #1f9d55;
  --color-success-highlight: #d9f2e2;
  --color-error: #d23c3c;
  --color-error-highlight: #f9dede;
  --color-warning: #c9821f;
  --color-warning-highlight: #f4e4cb;

  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(20, 22, 43, 0.05);
  --shadow-md: 0 6px 20px rgba(20, 22, 43, 0.08);
  --shadow-lg: 0 16px 40px rgba(20, 22, 43, 0.12);

  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --font-display: 'General Sans', 'Segoe UI', sans-serif;
  --font-body: 'General Sans', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', monospace;

  --text-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.83rem + 0.2vw, 0.9375rem);
  --text-base: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1.02rem + 0.5vw, 1.375rem);
  --text-xl: clamp(1.375rem, 1.15rem + 1vw, 1.875rem);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem;
  --space-16: 4rem; --space-20: 5rem;
}

[data-theme="dark"] {
  --color-bg: #0d0e1a;
  --color-surface: #14162a;
  --color-surface-2: #171a30;
  --color-surface-offset: #1b1e38;
  --color-divider: #262a48;
  --color-border: #2d3154;
  --color-text: #e6e7f5;
  --color-text-muted: #9498b8;
  --color-text-faint: #666a8f;
  --color-text-inverse: #14162a;

  --color-primary: #8891ff;
  --color-primary-hover: #a2a9ff;
  --color-primary-active: #6c74e8;
  --color-primary-highlight: #262a52;

  --color-success: #4ade80;
  --color-success-highlight: #163829;
  --color-error: #f87171;
  --color-error-highlight: #3a1f24;
  --color-warning: #fbbf6d;
  --color-warning-highlight: #3a2c17;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.35);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.45);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.55;
  transition: background var(--transition-interactive), color var(--transition-interactive);
}

h1, h2, h3 { text-wrap: balance; line-height: 1.2; font-family: var(--font-display); }
p, li { text-wrap: pretty; }

a { color: var(--color-primary); }

button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.tabular { font-variant-numeric: tabular-nums lining-nums; font-family: var(--font-mono); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-divider);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.brand { display: flex; align-items: center; gap: var(--space-3); }
.brand-mark { width: 30px; height: 30px; color: var(--color-primary); flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 700; font-size: var(--text-sm); letter-spacing: -0.01em; }
.brand-subtitle { font-size: var(--text-xs); color: var(--color-text-muted); }

.topbar-actions { display: flex; align-items: center; gap: var(--space-3); }
.update-pill {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.theme-toggle {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  transition: background var(--transition-interactive), border-color var(--transition-interactive);
}
.theme-toggle:hover { background: var(--color-surface-offset); }

/* ---------- Layout ---------- */
.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) var(--space-20);
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.intro { max-width: 860px; }
.page-title { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.02em; margin-bottom: var(--space-3); }
.page-lede { color: var(--color-text-muted); font-size: var(--text-base); }
.page-lede strong { color: var(--color-text); font-weight: 600; }

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

/* ---------- Why panel ("varför appen finns") ---------- */
.why-panel { border-left: 3px solid var(--color-primary); }

/* ---------- Facit (tillagt 25 sep 2026, jämfört mot förhandsregistreringen) ---------- */
.facit-panel { border-left: 3px solid var(--color-success); }
.facit-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  background: var(--color-success-highlight);
  color: var(--color-success);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 0.2em 0.7em;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* ---------- Förhandsregistrerad prognos (låst 8 sep 2026) ---------- */
.prereg-panel { border-left: 3px solid var(--color-warning); }
.prereg-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  background: var(--color-warning-highlight);
  color: var(--color-warning);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 0.2em 0.7em;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.prereg-commit {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  padding: 0.1em 0.5em;
  border-radius: var(--radius-sm);
}
.prereg-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin: var(--space-5) 0;
}
@media (max-width: 720px) {
  .prereg-grid { grid-template-columns: 1fr; }
}
.prereg-box {
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.prereg-box h3 {
  font-size: var(--text-sm);
  font-weight: 650;
  margin-bottom: var(--space-2);
}
.prereg-box .prereg-winner {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
}
.prereg-box .prereg-detail {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}
.why-lede {
  font-size: var(--text-base);
  color: var(--color-text);
  max-width: 82ch;
  margin-bottom: var(--space-5);
}
.why-lede strong { font-weight: 650; }
.why-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}
.why-column h3 {
  font-size: var(--text-xs);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-faint);
  margin-bottom: var(--space-2);
}
.why-column p { font-size: var(--text-sm); color: var(--color-text-muted); }
.why-caveat {
  background: var(--color-warning-highlight);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text);
  max-width: 82ch;
}
.why-caveat strong { color: var(--color-warning); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}
.panel-title { font-size: var(--text-lg); font-weight: 650; letter-spacing: -0.01em; }
.panel-meta { font-size: var(--text-xs); color: var(--color-text-faint); font-family: var(--font-mono); white-space: nowrap; }
.panel-note { font-size: var(--text-sm); color: var(--color-text-muted); margin: var(--space-2) 0 var(--space-5); max-width: 78ch; }
.panel-updated {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-faint);
  margin-top: 0.2rem;
}
.panel-updated a { color: var(--color-text-muted); }
.panel-header-actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.update-confirm {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-success);
  background: var(--color-success-highlight);
  padding: 0.15em 0.6em;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.threshold-chip {
  display: inline-block;
  background: var(--color-warning-highlight);
  color: var(--color-warning);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.1em 0.5em;
  border-radius: var(--radius-sm);
}

.results-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--space-6);
  background: none;
  border: none;
  padding: 0;
  box-shadow: none;
}
.results-grid > .panel { margin: 0; }

/* ---------- Sliders ---------- */
.btn-secondary {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-offset);
  transition: background var(--transition-interactive), border-color var(--transition-interactive);
}
.btn-secondary:hover { background: var(--color-divider); }

.snapshot-btn-group { display: flex; align-items: center; gap: var(--space-2); }
.btn-snapshot {
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: var(--font-mono);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  transition: background var(--transition-interactive), border-color var(--transition-interactive), color var(--transition-interactive);
  cursor: pointer;
}
.btn-snapshot:hover {
  background: var(--color-primary-highlight);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.sliders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
}

.slider-card {
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--color-surface-2);
  position: relative;
}
.slider-card.is-swing { border-color: color-mix(in srgb, var(--swing-color, var(--color-warning)) 45%, var(--color-divider)); }

.slider-card.is-locked { background: color-mix(in srgb, var(--color-warning-highlight) 55%, var(--color-surface-2)); border-color: color-mix(in srgb, var(--color-warning) 35%, var(--color-divider)); }

.slider-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  gap: var(--space-2);
}
.lock-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text-faint);
  cursor: pointer;
  transition: background var(--transition-interactive), color var(--transition-interactive), border-color var(--transition-interactive);
}
.lock-btn:hover { background: var(--color-surface-offset); color: var(--color-text-muted); }
.lock-btn.is-locked { color: var(--color-warning); background: var(--color-warning-highlight); border-color: color-mix(in srgb, var(--color-warning) 40%, transparent); }
.lock-btn svg { width: 14px; height: 14px; pointer-events: none; }

input[type="range"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
input[type="range"]:disabled::-webkit-slider-thumb { cursor: not-allowed; }
input[type="range"]:disabled::-moz-range-thumb { cursor: not-allowed; }
.slider-party {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--space-2);
  font-weight: 600;
  font-size: var(--text-sm);
  padding-top: 0.15rem;
  min-width: 0;
  flex: 1;
}
.slider-party-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 100%;
  font-size: 0.92em;
}
.party-swatch {
  width: 11px; height: 11px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.slider-value {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 3.6em;
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-divider);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--thumb-color, var(--color-primary));
  border: 3px solid var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-border);
  cursor: pointer;
  transition: transform var(--transition-interactive);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--thumb-color, var(--color-primary));
  border: 3px solid var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-border);
  cursor: pointer;
}

.slider-badge {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.15em 0.55em;
  border-radius: var(--radius-sm);
}
.slider-badge.above { color: var(--color-success); background: var(--color-success-highlight); }
.slider-badge.below { color: var(--color-error); background: var(--color-error-highlight); }
.swing-tag-row { margin-top: calc(-1 * var(--space-2)); margin-bottom: var(--space-2); }
.swing-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-warning);
  background: var(--color-warning-highlight);
  padding: 0.1em 0.5em;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.sum-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-divider);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.sum-value { font-family: var(--font-mono); font-weight: 700; color: var(--color-text); }
.sum-warning { font-size: var(--text-xs); color: var(--color-text-faint); }

/* ---------- Seat bar (hemicycle-style stacked bar) ---------- */
.seat-bar-wrap { position: relative; margin-top: var(--space-8); margin-bottom: var(--space-5); }
.seat-bar {
  display: flex;
  height: 44px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
}
.seat-bar-segment {
  height: 100%;
  transition: width 500ms cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  min-width: 2px;
}
.majority-marker {
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: calc(175 / 349 * 100%);
  width: 0;
  border-left: 2px dashed var(--color-text-faint);
}
.majority-label {
  position: absolute;
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  line-height: 1.3;
  text-align: center;
  background: var(--color-surface);
  padding: 0 var(--space-2);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}
.legend-item .party-swatch { width: 10px; height: 10px; }
.legend-value { font-family: var(--font-mono); font-weight: 600; color: var(--color-text-muted); }

.chart-container { position: relative; height: 280px; }

.trend-chart-wrap { position: relative; height: 300px; margin-bottom: var(--space-6); }

.trend-chips-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}
@media (max-width: 900px) { .trend-chips-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .trend-chips-grid { grid-template-columns: 1fr; } }

.trend-chip {
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  padding: var(--space-3);
}
.trend-chip-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.trend-chip-name { font-weight: 700; font-size: var(--text-sm); }
.trend-chip-current {
  margin-left: auto;
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.trend-chip-row, .trend-chip-row-sub {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.trend-chip-row { font-size: var(--text-sm); margin-bottom: 2px; }
.trend-arrow, .trend-arrow-sm { font-weight: 700; }

/* ---------- Trendprognos till valdagen ---------- */
.trend-forecast-caveat { margin-bottom: var(--space-5); }
.forecast-block-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
@media (max-width: 640px) { .forecast-block-grid { grid-template-columns: 1fr; } }
.forecast-block-card {
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  padding: var(--space-4);
}
.forecast-block-name { font-weight: 700; font-size: var(--text-sm); margin-bottom: var(--space-2); }
.forecast-block-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-lg);
  font-variant-numeric: tabular-nums;
}
.forecast-block-pi { font-size: var(--text-xs); color: var(--color-text-faint); margin-top: var(--space-2); line-height: 1.5; }
.forecast-block-nochange { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-1); }
.forecast-block-seats { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: var(--space-2); }
.forecast-sig-yes { color: var(--color-success); font-weight: 600; }
.forecast-sig-no { color: var(--color-text-faint); }
.trend-forecast-table-wrap { margin-bottom: var(--space-3); }
.trend-arrow-sm { font-size: 0.85em; }
.trend-up { color: var(--color-success); }
.trend-down { color: var(--color-error); }
.trend-flat { color: var(--color-text-muted); }

/* ---------- Coalitions ---------- */
.coalition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
}
.coalition-card {
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  background: var(--color-surface-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.coalition-card.leading { border-color: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary); }
.coalition-name { font-size: var(--text-base); font-weight: 700; }
.coalition-subtitle { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: -0.35rem; }
.coalition-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  display: inline-flex; align-items: center; gap: 0.35em;
  font-size: var(--text-xs); font-weight: 600;
  padding: 0.2em 0.6em; border-radius: var(--radius-full);
  background: var(--color-surface-offset); border: 1px solid var(--color-border);
}
.chip.tolerating { opacity: 0.65; border-style: dashed; }

.coalition-stats {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.coalition-stats strong { color: var(--color-text); font-family: var(--font-mono); }

.probability-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.probability-value { font-family: var(--font-mono); font-weight: 700; font-size: var(--text-xl); font-variant-numeric: tabular-nums; }
.probability-track {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-divider);
  overflow: hidden;
}
.probability-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  transition: width 500ms cubic-bezier(0.16, 1, 0.3, 1);
}
.majority-badge {
  align-self: flex-start;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.15em 0.6em;
  border-radius: var(--radius-sm);
}
.majority-badge.yes { color: var(--color-success); background: var(--color-success-highlight); }
.majority-badge.no { color: var(--color-text-muted); background: var(--color-surface-offset); }

.no-majority-card {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface-offset);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border);
}

/* ---------- Valkretsbaserad mandatfördelning ---------- */
.constituency-validation-note {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-success);
  margin-bottom: var(--space-3);
}
.constituency-validation-note.is-error { color: var(--color-warning); }
#constituency-result { margin-top: var(--space-4); }
.table-scroll { overflow-x: auto; margin-bottom: var(--space-3); }
.compare-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  margin-bottom: 0;
  font-size: var(--text-sm);
}
.compare-table th, .compare-table td {
  border: 1px solid var(--color-border);
  padding: var(--space-1) var(--space-2);
  text-align: left;
}
.compare-table th { background: var(--color-surface-alt, rgba(120,120,160,0.08)); font-weight: 600; }
.compare-table td.tabular, .compare-table th.tabular { text-align: right; font-family: var(--font-mono); }
.constituency-note {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-top: var(--space-2);
}

/* ---------- Network ---------- */
.network-container { width: 100%; height: 380px; }
.network-legend { display: flex; gap: var(--space-5); margin-top: var(--space-3); font-size: var(--text-xs); color: var(--color-text-muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 0.4em; }
.dot.pos { background: var(--color-success); }
.dot.neg { background: var(--color-error); }

.cohesion-bars { display: flex; flex-direction: column; gap: var(--space-4); }
.cohesion-row { display: flex; flex-direction: column; gap: var(--space-1); }
.cohesion-label { display: flex; justify-content: space-between; font-size: var(--text-sm); font-weight: 600; }
.cohesion-value { font-family: var(--font-mono); color: var(--color-text-muted); }
.cohesion-track { height: 8px; border-radius: var(--radius-full); background: var(--color-divider); position: relative; overflow: hidden; }
.cohesion-fill { position: absolute; top: 0; bottom: 0; border-radius: var(--radius-full); }
.cohesion-zero { position: absolute; top: -2px; bottom: -2px; left: 50%; width: 1px; background: var(--color-text-faint); }

/* ---------- Methodology ---------- */
.methodology { padding: 0; overflow: hidden; }
.methodology-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  font-weight: 650;
  font-size: var(--text-base);
}
.methodology-toggle svg { transition: transform var(--transition-interactive); }
.methodology-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.methodology-body {
  padding: 0 var(--space-6) var(--space-6);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 90ch;
}
.methodology-body h3 { font-size: var(--text-base); color: var(--color-text); margin: var(--space-5) 0 var(--space-2); }
.methodology-body h3:first-child { margin-top: 0; }
.methodology-body p, .methodology-body ul, .methodology-body ol { margin-bottom: var(--space-3); }
.methodology-body ul, .methodology-body ol { padding-left: 1.3em; }
.methodology-body li { margin-bottom: var(--space-1); }
.methodology-body a { text-decoration: underline; text-underline-offset: 2px; }
.methodology-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
}
.methodology-body th, .methodology-body td {
  border: 1px solid var(--color-border);
  padding: var(--space-1) var(--space-2);
  text-align: left;
}
.methodology-body th { background: var(--color-surface-alt, rgba(120,120,160,0.08)); font-weight: 600; }
.methodology-body td.tabular, .methodology-body th.tabular { text-align: right; }
.methodology-body table caption { text-align: left; font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: var(--space-1); caption-side: top; }

.site-footer {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  padding-top: var(--space-4);
}

.footer-copyright {
  margin-top: var(--space-2);
  opacity: 0.8;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .results-grid { grid-template-columns: 1fr; }
  .topbar-inner { padding: var(--space-3) var(--space-4); }
  .layout { padding: var(--space-6) var(--space-4) var(--space-16); }
  .majority-label { font-size: 0.65rem; }
}

@media (max-width: 480px) {
  .weight-slider-control { padding: var(--space-3); }
  .weight-slider-label { font-size: var(--text-xs); }
  .topbar-inner { gap: var(--space-2); }
  .topbar-actions { gap: var(--space-2); flex-shrink: 0; }
  .update-pill {
    font-size: 0.65rem;
    padding: var(--space-1) var(--space-2);
    white-space: normal;
    max-width: 92px;
    text-align: center;
    line-height: 1.15;
  }
  .brand-subtitle { display: none; }
  .theme-toggle { width: 30px; height: 30px; flex-shrink: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ---------- Sammanhållningsviktning (historik/ideologi-reglage) ---------- */
.weight-slider-control {
  background: var(--color-surface-alt, rgba(127, 127, 127, 0.06));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.weight-slider-label {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.weight-slider-label span:first-child { color: var(--color-text); }
.weight-slider-label #weight-slider-value { color: var(--color-text-muted); font-weight: 500; white-space: nowrap; }
.weight-slider-label #momentum-slider-value { color: var(--color-text-muted); font-weight: 500; white-space: nowrap; }

#weight-slider, #momentum-slider { width: 100%; margin: var(--space-1) 0; }

.weight-slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: -2px;
}

.weight-slider-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: var(--space-3) 0 0;
  line-height: 1.5;
}

.weight-slider-hint a { color: var(--color-primary); }

.weight-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-2);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full, 999px);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.weight-reset-btn:hover:not(:disabled) {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.weight-reset-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.weight-live-effect {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--color-border);
}

.weight-live-effect-title {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.weight-live-effect-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.weight-effect-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  white-space: nowrap;
}

.weight-effect-chip strong { font-weight: 700; }
.weight-effect-chip.pos strong { color: var(--color-success); }
.weight-effect-chip.neg strong { color: var(--color-error); }

@media (max-width: 480px) {
  .weight-effect-chip { white-space: normal; }
}
