:root {
  --primary: #db2777;
  --secondary: #2563eb;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --surface: #ffffff;
  --text: #111827;
  --neutral: #ffffff;
  --ink: var(--text);
  --muted: #5d6676;
  --soft: #f5f7fb;
  --soft-2: #eef2ff;
  --line: #cfd7e6;
  --soft-line: #e5e9f2;
  --panel: var(--surface);
  --panel-2: #f8fafc;
  --bg: #f7f4ff;
  --accent: var(--primary);
  --accent-2: var(--secondary);
  --good: var(--success);
  --shadow: 0 16px 0 rgba(17, 24, 39, 0.08);
  --shadow-soft: 0 16px 36px rgba(17, 24, 39, 0.08);
  --radius-sm: 4px;
  --radius-md: 8px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(37, 99, 235, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(219, 39, 119, 0.08) 1px, transparent 1px),
    #fff9fb;
  background-size: 32px 32px;
}

button,
select,
input,
textarea {
  font: inherit;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(219, 39, 119, 0.45);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: var(--space-5);
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(219, 39, 119, 0.98), rgba(37, 99, 235, 0.92)),
    #111827;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
  border-right: 4px solid #111827;
}

.brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: var(--space-3);
  align-items: center;
}

.brand strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1.15;
}

.brand span:last-child {
  display: block;
  margin-top: var(--space-1);
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.82rem;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background:
    linear-gradient(90deg, #ffffff 0 46%, transparent 46% 54%, #111827 54%),
    linear-gradient(#16a34a 0 50%, #d97706 50%);
  box-shadow: 6px 6px 0 #111827;
}

.nav-list {
  display: grid;
  gap: var(--space-2);
}

.nav-list a {
  color: #ffffff;
  text-decoration: none;
  padding: 10px var(--space-3);
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.nav-list a:hover,
.nav-list a.active {
  background: #ffffff;
  color: #111827;
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 #111827;
}

.source-note {
  margin-top: auto;
  padding: var(--space-4);
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: var(--radius-md);
  background: rgba(17, 24, 39, 0.18);
  min-width: 0;
}

.source-note p {
  margin: var(--space-2) 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.86rem;
  line-height: 1.45;
}

main {
  min-width: 0;
  max-width: 100%;
  padding: var(--space-6) clamp(20px, 4vw, 56px) 56px;
}

body:not(.map-page) .map-view,
body:not(.contact-page) .contact-view,
body.map-page .analysis-view,
body.map-page .contact-view,
body.contact-page .analysis-view,
body.contact-page .map-view {
  display: none !important;
}

body.map-page main,
body.contact-page main {
  padding-top: var(--space-6);
}

body.map-page .map-layout {
  margin-top: 0;
}

body.contact-page .contact-section {
  margin-top: 0;
}

.top-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 310px);
  gap: var(--space-5);
  align-items: stretch;
  margin-bottom: var(--space-5);
  min-width: 0;
}

.top-strip > div:first-child {
  position: relative;
  padding: var(--space-6);
  border: 2px solid #111827;
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(238, 242, 255, 0.96)),
    var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.top-strip > div:first-child::after {
  content: "";
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 136px;
  height: 72px;
  border: 2px solid rgba(17, 24, 39, 0.12);
  background:
    linear-gradient(90deg, var(--primary) 0 18%, transparent 18% 26%, var(--secondary) 26% 44%, transparent 44% 52%, var(--success) 52% 70%, transparent 70% 78%, var(--warning) 78%);
  transform: rotate(3deg);
}

.top-strip > *,
.insight-grid > *,
.place-layout > *,
.section-block,
.controls-band,
.status-panel {
  min-width: 0;
  max-width: 100%;
}

.eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--primary);
  text-transform: uppercase;
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  position: relative;
  z-index: 1;
  margin-bottom: var(--space-4);
  max-width: 980px;
  font-size: clamp(2rem, 4.3vw, 4rem);
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h2 {
  margin-bottom: var(--space-2);
  font-size: clamp(1.25rem, 1.8vw, 1.5rem);
  line-height: 1.2;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h3 {
  margin-bottom: var(--space-2);
  font-size: 1rem;
  letter-spacing: 0;
}

.intro {
  position: relative;
  z-index: 1;
  max-width: 780px;
  color: #334155;
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.summary-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-5);
  max-width: 960px;
}

.summary-grid article {
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.summary-grid article:nth-child(1) {
  border-top: 5px solid var(--primary);
}

.summary-grid article:nth-child(2) {
  border-top: 5px solid var(--secondary);
}

.summary-grid article:nth-child(3) {
  border-top: 5px solid var(--warning);
}

.summary-grid strong,
.summary-grid span {
  display: block;
}

.summary-grid span {
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.status-panel {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  min-height: 100%;
  background: #111827;
  color: #ffffff;
  border: 2px solid #111827;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.status-panel strong,
.status-panel span {
  display: block;
}

.status-panel span:last-child {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.86rem;
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 8px rgba(22, 163, 74, 0.18);
  flex: 0 0 auto;
}

.controls-band {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: var(--space-3);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  border: 2px solid #111827;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 0 rgba(17, 24, 39, 0.08);
}

.analysis-start .controls-band {
  margin: var(--space-4) 0;
}

.analysis-start .help-strip {
  margin-bottom: 0;
}

.help-strip {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  margin: -4px 0 var(--space-5);
  border: 1px solid rgba(37, 99, 235, 0.24);
  border-left: 5px solid var(--secondary);
  border-radius: var(--radius-md);
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 0.88rem;
  line-height: 1.45;
}

.help-strip strong {
  color: #172554;
  white-space: nowrap;
}

.help-strip span {
  min-width: 0;
}

.help-strip.inline {
  margin: var(--space-2) 0 var(--space-4);
}

.help-strip.compact-help {
  margin: var(--space-4) 0 0;
  font-size: 0.82rem;
}

label {
  display: grid;
  gap: var(--space-2);
  color: #334155;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  min-width: 0;
}

select,
button,
input,
textarea {
  width: 100%;
  border: 2px solid #111827;
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--ink);
  min-width: 0;
}

select,
button,
input {
  min-height: 42px;
}

select {
  padding: 0 var(--space-3);
}

input,
textarea {
  padding: 10px var(--space-3);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

button {
  padding: 0 var(--space-4);
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

button:hover,
.button-link:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 #111827;
}

button:active,
.button-link:active {
  transform: translate(0, 0);
  box-shadow: none;
}

.insight-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(520px, 1.18fr);
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.explain-panel,
.chart-panel,
.section-block,
.takeaways {
  background: var(--panel);
  border: 2px solid #111827;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.explain-panel,
.chart-panel {
  padding: var(--space-5);
}

.panel-heading {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--soft-line);
  margin-bottom: var(--space-4);
}

.big-read {
  min-height: 132px;
  color: #1f2937;
  font-size: 1.1rem;
  line-height: 1.55;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin: var(--space-5) 0;
}

.stat-row > div {
  padding: var(--space-3);
  background: var(--soft);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius-md);
}

.stat-value {
  display: block;
  color: var(--primary);
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1;
}

.stat-label {
  display: block;
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.callout {
  padding: var(--space-3);
  border-left: 5px solid var(--warning);
  background: #fff7ed;
  color: #7c2d12;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.45;
}

.chart-toolbar {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: start;
  margin-bottom: var(--space-3);
}

.chart-toolbar p,
.section-title p,
.compact p {
  color: var(--muted);
  margin-bottom: 0;
  line-height: 1.45;
}

.chart-toolbar button {
  width: auto;
  min-width: 88px;
  background: #fdf2f8;
}

.scatter-wrap {
  position: relative;
  min-height: 470px;
}

#scatterSvg,
.cluster-svg {
  display: block;
  width: 100%;
  height: 470px;
  background:
    linear-gradient(90deg, rgba(37, 99, 235, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(219, 39, 119, 0.05) 1px, transparent 1px),
    #ffffff;
  background-size: 24px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.cluster-explainer {
  display: flex;
  gap: var(--space-2) var(--space-3);
  flex-wrap: wrap;
  margin: var(--space-3) 0;
  padding: var(--space-3);
  background: #ecfdf5;
  border: 1px solid rgba(22, 163, 74, 0.26);
  border-left: 5px solid var(--success);
  border-radius: var(--radius-md);
  color: #14532d;
  font-size: 0.86rem;
  line-height: 1.4;
}

.cluster-explainer strong {
  color: #052e16;
}

.cluster-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-3);
  color: var(--muted);
  font-size: 0.84rem;
}

.legend-swatch {
  display: inline-block;
  width: 36px;
  height: 10px;
  border-radius: 999px;
}

.tooltip {
  position: fixed;
  pointer-events: none;
  max-width: 280px;
  padding: var(--space-3);
  background: #111827;
  color: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  font-size: 0.84rem;
  z-index: 4;
  line-height: 1.4;
}

.tooltip strong {
  display: block;
  margin-bottom: var(--space-1);
}

.section-block {
  padding: var(--space-5);
  margin-top: var(--space-5);
}

.takeaways {
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: var(--space-5);
  align-items: end;
  margin-bottom: var(--space-4);
}

.section-title > p {
  max-width: 580px;
}

.section-title.compact {
  display: block;
}

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

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

.takeaway-card {
  display: grid;
  gap: var(--space-3);
  min-height: 210px;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-top: 6px solid var(--party);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.takeaway-card h3 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

.takeaway-card p {
  margin: 0;
  color: #334155;
  line-height: 1.45;
}

.takeaway-card button {
  align-self: end;
  min-height: 38px;
  background: var(--soft);
}

.takeaway-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.takeaway-stats span {
  padding: 5px var(--space-2);
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid var(--soft-line);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.party-card {
  border: 1px solid var(--line);
  border-top: 6px solid var(--party);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: #ffffff;
}

.party-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: start;
}

.party-name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 900;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--party);
  flex: 0 0 auto;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.mini-stats div {
  background: var(--soft);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius-md);
  padding: var(--space-2);
}

.mini-stats strong,
.mini-stats span {
  display: block;
}

.mini-stats span {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
}

.mini-rel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 60px;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--soft-line);
}

.mini-rel span {
  color: var(--muted);
  font-size: 0.78rem;
}

.rho {
  font-weight: 900;
  text-align: right;
}

.factor-bars {
  display: grid;
  gap: var(--space-3);
}

.factor-row {
  display: grid;
  grid-template-columns: minmax(180px, 300px) minmax(180px, 1fr) 82px;
  gap: var(--space-3);
  align-items: center;
}

.bar-track {
  height: 16px;
  background: #e5e7eb;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--secondary);
}

.factor-row button {
  width: auto;
  min-height: 36px;
  font-size: 0.82rem;
}

.place-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: var(--space-5);
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: var(--space-5);
  align-items: start;
}

.map-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: var(--space-3);
  align-items: end;
  margin-bottom: var(--space-3);
}

.map-controls button {
  min-width: 0;
  background: #fdf2f8;
}

.uk-map-wrap {
  position: relative;
  width: 100%;
  min-height: 620px;
  background:
    linear-gradient(90deg, rgba(37, 99, 235, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(219, 39, 119, 0.05) 1px, transparent 1px),
    #f8fafc;
  background-size: 28px 28px;
  border: 2px solid #111827;
  border-radius: var(--radius-md);
  overflow: hidden;
}

#ukMapSvg {
  display: block;
  width: 100%;
  height: 620px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#ukMapSvg.dragging {
  cursor: grabbing;
}

.map-zoom-controls {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 2;
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 2px solid #111827;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 4px 4px 0 rgba(17, 24, 39, 0.18);
}

.map-zoom-controls button {
  width: auto;
  min-width: 36px;
  min-height: 34px;
  padding: 6px 10px;
  font-weight: 900;
}

.map-zoom-controls button:last-child {
  min-width: 58px;
}

.map-data-note {
  position: absolute;
  right: var(--space-3);
  bottom: var(--space-3);
  z-index: 2;
  max-width: 320px;
  padding: var(--space-3) 44px var(--space-3) var(--space-3);
  border: 2px solid #111827;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 4px 4px 0 rgba(17, 24, 39, 0.18);
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 1.4;
}

.map-data-note.is-hidden {
  display: none;
}

.map-data-note-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border-width: 1px;
  background: #fdf2f8;
  line-height: 1;
}

.map-data-note-close:hover {
  transform: none;
  box-shadow: none;
  background: #fce7f3;
}

.map-data-note strong,
.map-data-note span {
  display: block;
}

.map-data-note span {
  margin-top: var(--space-1);
  color: var(--muted);
}

.map-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin: var(--space-3) 0;
}

.map-status div {
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.map-status strong {
  display: block;
  color: var(--secondary);
  font-size: 1.25rem;
  overflow-wrap: anywhere;
}

.map-status span {
  display: block;
  margin-top: var(--space-1);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.3;
}

.map-area {
  stroke: #ffffff;
  stroke-width: 0.75;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: opacity 0.15s ease, fill 0.15s ease;
}

.map-area:hover {
  stroke: #111827;
  stroke-width: 1.5;
  opacity: 1;
}

.map-area.dimmed {
  opacity: 0.18;
}

.map-area.unmatched {
  fill: #d9e2ef;
  opacity: 0.58;
  stroke: #ffffff;
  stroke-width: 0.45;
}

.map-side {
  display: grid;
  gap: var(--space-4);
  align-self: start;
  position: sticky;
  top: var(--space-5);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: var(--space-4);
  border: 2px solid #111827;
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.map-selected-card,
.map-legend-card {
  min-width: 0;
}

.map-selected-card {
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--soft-line);
}

.map-legend-card {
  display: grid;
  gap: var(--space-2);
}

.map-side p {
  color: var(--muted);
  line-height: 1.45;
}

.map-side.has-selection {
  border-color: var(--primary);
  box-shadow: 6px 6px 0 rgba(219, 39, 119, 0.18);
}

.map-legend,
.map-party-list {
  display: grid;
  gap: var(--space-2);
}

.legend-row,
.map-party-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-2);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius-md);
  background: #f8fafc;
  font-size: 0.84rem;
}

.legend-row span,
.map-party-row span {
  color: var(--muted);
}

.map-party-row strong,
.legend-row strong {
  overflow-wrap: anywhere;
}

.legend-more {
  border: 1px solid var(--soft-line);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.legend-more summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-2);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
}

.legend-more summary span {
  color: var(--muted);
}

.legend-more-list {
  display: grid;
  gap: var(--space-2);
  padding: 0 var(--space-2) var(--space-2);
}

.area-list {
  display: grid;
  gap: var(--space-2);
  max-height: 470px;
  overflow: auto;
  padding-right: var(--space-1);
}

.area-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--soft);
  border: 1px solid var(--soft-line);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius-md);
}

.area-row strong {
  overflow-wrap: anywhere;
}

.area-row span {
  color: var(--muted);
  font-size: 0.78rem;
}

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

.note-grid p {
  margin: 0;
  padding: var(--space-4);
  background: #ffffff;
  border: 1px solid var(--line);
  border-top: 5px solid var(--danger);
  border-radius: var(--radius-md);
  color: #334155;
  line-height: 1.45;
}

.contact-section {
  margin-bottom: 0;
}

.contact-form {
  display: grid;
  gap: var(--space-4);
  max-width: 720px;
}

.contact-form button {
  background: #fdf2f8;
}

.button-link {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  padding: 0 var(--space-4);
  border: 2px solid #111827;
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.contact-note {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.contact-note a {
  color: var(--secondary);
  font-weight: 800;
}

.axis-text {
  fill: #475569;
  font-size: 12px;
}

.grid-line {
  stroke: #e2e8f0;
  stroke-width: 1;
}

.axis-line {
  stroke: #94a3b8;
  stroke-width: 1.2;
}

.point {
  cursor: pointer;
  transition: opacity 0.15s ease, r 0.15s ease;
}

.point:hover {
  opacity: 1;
  r: 8;
}

.regression-line {
  stroke-width: 3;
  stroke-dasharray: 6 5;
  fill: none;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: var(--space-4);
  }

  .brand {
    flex: 0 0 auto;
  }

  .source-note {
    margin-top: 0;
    flex-basis: 100%;
  }

  .nav-list {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: var(--space-1);
  }

  .nav-list a {
    flex: 0 0 auto;
  }

  .top-strip,
  .insight-grid,
  .place-layout,
  .map-layout,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .top-strip > div:first-child::after {
    opacity: 0.5;
  }

  .controls-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-side {
    position: static;
    max-height: none;
  }
}

@media (max-width: 680px) {
  body {
    background-size: 24px 24px;
    font-size: 14px;
  }

  .app-shell {
    display: block;
  }

  main {
    padding: var(--space-3) 10px 32px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    gap: var(--space-3);
    padding: var(--space-3) 10px;
    border-right: 0;
    border-bottom: 3px solid #111827;
  }

  .brand {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    box-shadow: 4px 4px 0 #111827;
  }

  .brand strong {
    font-size: 1rem;
  }

  .brand span:last-child {
    font-size: 0.76rem;
  }

  .nav-list {
    margin: 0 -2px;
    gap: var(--space-2);
    scrollbar-width: none;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-list a {
    padding: 8px 10px;
    font-size: 0.86rem;
    box-shadow: none;
  }

  .source-note {
    display: none;
  }

  h1 {
    font-size: clamp(1.55rem, 8vw, 2rem);
    line-height: 1.08;
    max-width: calc(100vw - 20px);
  }

  h2 {
    font-size: 1.06rem;
  }

  p,
  .intro,
  .big-read {
    font-size: 0.84rem;
    line-height: 1.48;
  }

  .top-strip > div:first-child,
  .explain-panel,
  .chart-panel,
  .section-block,
  .takeaways {
    padding: var(--space-3);
    box-shadow: 6px 6px 0 rgba(17, 24, 39, 0.08);
  }

  .intro,
  .summary-grid,
  .top-strip,
  .controls-band,
  .help-strip,
  .insight-grid,
  .section-block,
  .takeaways,
  .status-panel {
    max-width: calc(100vw - 20px);
  }

  .controls-band,
  .stat-row,
  .factor-row,
  .help-strip,
  .map-status,
  .map-controls,
  .mini-stats,
  .summary-grid,
  .takeaway-cards,
  .party-cards,
  .note-grid {
    grid-template-columns: 1fr;
  }

  .top-strip,
  .insight-grid,
  .place-layout,
  .map-layout {
    gap: var(--space-3);
  }

  .top-strip > div:first-child::after {
    display: none;
  }

  .summary-grid,
  .takeaway-cards,
  .party-cards {
    gap: var(--space-3);
  }

  .summary-grid article,
  .takeaway-card,
  .party-card,
  .note-grid p {
    padding: 10px;
  }

  .takeaway-card {
    min-height: 0;
  }

  .controls-band {
    position: static;
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    box-shadow: 4px 4px 0 rgba(17, 24, 39, 0.08);
  }

  .map-view.section-block {
    padding: 10px;
  }

  .map-view .section-title.compact > p {
    font-size: 0.82rem;
  }

  label {
    font-size: 0.72rem;
  }

  select,
  button,
  input {
    min-height: 38px;
    font-size: 0.82rem;
  }

  .section-title,
  .chart-toolbar {
    display: grid;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
  }

  .help-strip {
    display: block;
    padding: var(--space-3);
    margin: var(--space-2) 0 var(--space-3);
    font-size: 0.82rem;
  }

  .map-view .help-strip {
    font-size: 0.76rem;
    line-height: 1.38;
    max-height: 104px;
    overflow: auto;
  }

  .map-status {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
  }

  .map-status div {
    padding: 9px;
  }

  .map-status strong {
    font-size: 1rem;
  }

  .map-status span {
    font-size: 0.66rem;
  }

  .map-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .help-strip strong {
    display: block;
    margin-bottom: var(--space-1);
    white-space: normal;
  }

  .factor-row {
    align-items: stretch;
  }

  .factor-row button {
    width: 100%;
  }

  .stat-row {
    gap: var(--space-2);
    margin: var(--space-3) 0;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .chart-toolbar button {
    justify-self: start;
  }

  #scatterSvg,
  .cluster-svg {
    height: 330px;
  }

  #ukMapSvg {
    height: 500px;
  }

  .scatter-wrap,
  .cluster-svg {
    min-height: 330px;
  }

  .uk-map-wrap {
    min-height: 500px;
  }

  .map-data-note {
    display: none;
  }

  .map-zoom-controls {
    top: var(--space-2);
    left: var(--space-2);
    gap: var(--space-1);
    padding: var(--space-1);
  }

  .map-zoom-controls button {
    min-width: 32px;
    min-height: 32px;
    padding: 4px 8px;
  }

  .map-side {
    padding: var(--space-3);
    box-shadow: 6px 6px 0 rgba(17, 24, 39, 0.08);
  }

  .map-legend {
    max-height: 260px;
    overflow: auto;
    padding-right: var(--space-1);
  }

  .legend-row,
  .map-party-row {
    font-size: 0.78rem;
  }

  .area-list {
    max-height: 340px;
  }

  .contact-form {
    gap: var(--space-3);
  }
}
