:root {
  --ink: #172231;
  --ink-soft: #596574;
  --paper: #f3f5f7;
  --panel: #ffffff;
  --line: #d9dee5;
  --line-strong: #b9c5ce;
  --accent: #a43f69;
  --accent-dark: #7e3155;
  --success: #1f9d61;
  --control-surface: #f8fafb;
  --control-track: #e9edf1;
  --selected-surface: #eaf0f5;
  --muted-surface: #f4f6f8;
  --focus-ring: rgba(164, 63, 105, 0.24);
  --panel-shadow: 0 8px 24px rgba(18, 36, 60, 0.06);
}

:root[data-theme="dark"] {
  --ink: #eaf0f7;
  --ink-soft: #aebccc;
  --paper: #10151c;
  --panel: #18212c;
  --line: #344151;
  --line-strong: #516174;
  --accent: #d66d99;
  --accent-dark: #f0a7c4;
  --success: #63c594;
  --control-surface: #162231;
  --control-track: #213145;
  --selected-surface: #2a4056;
  --muted-surface: #1d2b3b;
  --focus-ring: rgba(214, 109, 153, 0.34);
  --panel-shadow: 0 8px 24px rgba(0, 0, 0, 0.26);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

button,
input,
table {
  font: inherit;
}

button,
input {
  color: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(1380px, calc(100% - 40px));
  margin-inline: auto;
  padding: 0 0 42px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 54px 0 34px;
}

.hero-copy {
  max-width: 780px;
}

.eyebrow,
.detail-kicker,
.search-label,
.detail-status {
  margin: 0;
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
  line-height: 1.2;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 900px;
  margin: 12px 0 16px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 52px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 0.98;
  text-wrap: balance;
}

.lede {
  max-width: 68ch;
  margin: 0;
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.65;
  text-wrap: pretty;
}

.hero-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.hero-link,
.detail-link,
.toolbar-button,
.row-button,
.theme-toggle {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.25;
  text-decoration: none;
  transition:
    color 160ms cubic-bezier(0.22, 1, 0.36, 1),
    background 160ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.hero-link:hover,
.detail-link:hover,
.toolbar-button:hover,
.row-button:hover,
.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle {
  min-height: 40px;
  gap: 7px;
  padding-inline: 10px;
  font-size: 12px;
}

.theme-toggle-state {
  padding: 2px 6px;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  border-radius: 4px;
  font-size: 11px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--control-surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(82px, 1fr));
  gap: 3px;
  padding: 3px;
  background: var(--control-track);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.segment {
  min-height: 36px;
  padding: 0 14px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 750;
}

.segment:hover {
  color: var(--ink);
}

.segment.is-active {
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(18, 36, 60, 0.12);
}

.search-field {
  display: flex;
  min-width: min(100%, 390px);
  min-height: 42px;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.search-label {
  color: var(--ink-soft);
}

.search-field:focus-within {
  border-color: var(--accent);
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.search-field input {
  width: 100%;
  min-width: 0;
  padding: 0;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 14px;
}

.search-field input::placeholder {
  color: var(--ink-soft);
  opacity: 1;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 2px;
  border-bottom: 1px solid var(--line);
}

.chip-row,
.legend-scale,
.legend-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 750;
}

.chip-verified {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, transparent);
}

.chip-neutral {
  color: var(--ink-soft);
  background: var(--control-track);
}

.strip-note {
  max-width: 68ch;
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
  text-wrap: pretty;
}

.sponsor-slot {
  display: grid;
  min-height: 58px;
  margin-top: 18px;
  place-items: center;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.sponsor-slot span {
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.view-map,
.view-list {
  margin-top: 18px;
}

.legend-band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
  background: var(--control-surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.legend-scale,
.legend-meta {
  color: var(--ink-soft);
  font-size: 13px;
}

.legend-gradient {
  width: min(340px, 38vw);
  min-width: 210px;
  height: 10px;
  background: linear-gradient(90deg, #a51f2f 0%, #d35b64 36%, #7b5dae 50%, #4e6eca 64%, #184f9c 100%);
  border-radius: 999px;
}

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

.legend-swatch.verified {
  background: var(--success);
}

.legend-swatch.unavailable {
  background: var(--line-strong);
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 360px);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  box-shadow: var(--panel-shadow);
}

.map-stage {
  position: relative;
  min-height: clamp(520px, 62vh, 760px);
  overflow: hidden;
  background: var(--control-surface);
  border-right: 1px solid var(--line);
}

.map-fallback {
  max-width: 46ch;
  margin: 0;
  padding: 32px;
  color: var(--ink-soft);
  font-size: 14px;
}

#world-map {
  display: block;
  width: 100%;
  height: 100%;
  min-height: clamp(520px, 62vh, 760px);
  cursor: grab;
}

#world-map.is-dragging {
  cursor: grabbing;
}

#world-map path:focus-visible {
  outline: none;
  stroke: var(--accent-dark);
  stroke-width: 2;
}

.map-tooltip {
  position: absolute;
  z-index: 5;
  max-width: 260px;
  padding: 11px 13px;
  color: #ffffff;
  background: rgba(18, 36, 60, 0.94);
  border-radius: 6px;
  box-shadow: 0 6px 14px rgba(18, 36, 60, 0.24);
  pointer-events: none;
}

.tooltip-name {
  margin: 0 0 5px;
  font-size: 14px;
  font-weight: 750;
}

.tooltip-line,
.tooltip-meta {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.tooltip-meta {
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.78);
}

.detail-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 14px;
  padding: 26px;
  background: var(--panel);
}

.detail-panel h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 500;
  line-height: 1.1;
  text-wrap: balance;
}

.detail-status {
  color: var(--ink-soft);
}

.detail-status.is-verified {
  color: var(--success);
}

.detail-lead {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
  font-weight: 500;
  line-height: 1.1;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 2px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-stats div {
  min-width: 0;
  padding: 12px 13px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.detail-stats div:nth-child(2n) {
  border-right: 0;
}

.detail-stats div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.detail-stats dt {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
  line-height: 1.2;
  text-transform: uppercase;
}

.detail-stats dd {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 750;
}

.detail-parties,
.detail-source,
.detail-note {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.detail-link {
  align-self: flex-start;
  margin-top: auto;
}

.detail-link.is-disabled,
.row-button.is-disabled {
  color: var(--ink-soft);
  background: var(--muted-surface);
  pointer-events: none;
}

.view-list {
  padding: 18px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--panel-shadow);
}

.is-hidden {
  display: none;
}

.list-meta {
  margin-bottom: 12px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--ink-soft);
  background: var(--control-surface);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--ink) 4%, transparent);
}

.row-country {
  font-weight: 750;
}

.row-source {
  max-width: 42ch;
  color: var(--ink-soft);
}

.row-button {
  min-width: 104px;
  min-height: 36px;
  padding-inline: 12px;
}

.hero-link:focus-visible,
.detail-link:focus-visible,
.toolbar-button:focus-visible,
.row-button:focus-visible,
.theme-toggle:focus-visible,
.segment:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

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

  .map-stage {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .detail-link {
    margin-top: 8px;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 22px, 1380px);
    padding-bottom: 30px;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 22px;
    padding: 42px 0 28px;
  }

  .hero h1 {
    font-size: 42px;
  }

  .lede {
    font-size: 16px;
  }

  .hero-actions,
  .hero-link {
    width: 100%;
  }

  .toolbar {
    align-items: stretch;
  }

  .segmented {
    flex: 1 1 190px;
  }

  .search-field {
    flex: 1 1 100%;
    min-width: 0;
  }

  .toolbar-button {
    min-height: 44px;
  }

  .status-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .legend-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .legend-gradient {
    width: min(260px, 55vw);
    min-width: 160px;
  }

  .map-stage,
  #world-map {
    min-height: 460px;
  }

  .detail-panel {
    padding: 22px 18px;
  }

  .view-list {
    padding: 12px;
  }

  table {
    font-size: 14px;
  }
}

@media (max-width: 460px) {
  .detail-stats {
    grid-template-columns: 1fr;
  }

  .detail-stats div,
  .detail-stats div:nth-child(2n),
  .detail-stats div:nth-last-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .detail-stats div:last-child {
    border-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-link,
  .detail-link,
  .toolbar-button,
  .row-button,
  .theme-toggle {
    transition: none;
  }
}
