:root {
  --bg: #0f1115;
  --bg-elev: #161a22;
  --border: #232936;
  --text: #e7ebf2;
  --text-muted: #9aa3b2;
  --accent: #4ea1f3;
  --accent-2: #f3b94e;
  --zelensky: #4ea1f3;
  --putin: #d9534f;
  --warn: #f3c34e;
  --maxw: 1100px;
  --radius: 8px;
  --gap: 1.25rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* ---------- A11Y ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #0c1118;
  padding: 0.6rem 1rem;
  z-index: 100;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus {
  left: 0;
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

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

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---------- HEADER ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 17, 21, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 56px;
  flex-wrap: wrap;
}

.site-title {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.primary-nav {
  display: flex;
  gap: 1rem;
  flex: 1 1 auto;
  flex-wrap: wrap;
  font-size: 0.92rem;
}

.primary-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 1px solid transparent;
}

.primary-nav a:hover {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.lang-switcher {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.lang-switcher button {
  background: transparent;
  color: var(--text-muted);
  border: 0;
  padding: 0.35rem 0.7rem;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.lang-switcher button[aria-pressed="true"] {
  background: var(--accent);
  color: #0c1118;
  font-weight: 600;
}

/* ---------- SECTIONS ---------- */
.section {
  padding: 3.5rem 0;
  border-bottom: 1px solid var(--border);
}

.section h1,
.section h2 {
  margin: 0 0 0.6rem;
  letter-spacing: -0.015em;
}

.section h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); }
.section h2 { font-size: clamp(1.4rem, 2.2vw, 1.9rem); }

.hero {
  padding-top: 4.5rem;
}

.hero .lede {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 70ch;
  margin-bottom: 2rem;
}

.hero-radar-wrap {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  min-height: 320px;
}

#radar-chart {
  display: block;
  max-width: 620px;
  margin: 0 auto;
}

.radar-legend {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: center;
  font-size: 0.95rem;
}

.radar-legend .swatch {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 2px;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.chart-note {
  margin: 1rem 0 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.chart-loading {
  color: var(--text-muted);
  text-align: center;
  margin: 1rem 0;
  font-style: italic;
}

.hero-meta {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.hero-history {
  margin-top: 1.8rem;
  height: 360px;
  min-height: 360px;
}

#history-canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ---------- AXIS SECTIONS ---------- */
.axis-header {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin-bottom: 0.4rem;
}

.axis-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  border-radius: 6px;
  background: var(--accent);
  color: #0c1118;
  font-weight: 700;
  font-family: var(--mono);
  font-size: 0.95rem;
}

.axis-section p {
  color: var(--text-muted);
  max-width: 75ch;
}

.chart-block {
  margin-top: 1.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-block {
  display: block;
  padding: 0.5rem;
  min-height: 320px;
}

.chart-tall {
  display: block;
  padding: 0.75rem;
  min-height: 420px;
  height: 460px;
}

#indices-canvas {
  height: 100% !important;
  width: 100% !important;
}

.indices-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: center;
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  border: 0;
  padding: 0;
}

.indices-controls legend {
  padding: 0;
  margin-right: 0.3rem;
  color: var(--text-muted);
  font-weight: 500;
}

.indices-controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text);
  cursor: pointer;
}

.indices-controls input[type="radio"] {
  accent-color: var(--accent);
}

.timeline-mount {
  height: 360px;
  background: var(--bg);
  border-radius: 4px;
}

/* vis-timeline dark theme tweaks */
.vis-timeline,
.vis-panel.vis-bottom,
.vis-panel.vis-center,
.vis-panel.vis-left,
.vis-panel.vis-right,
.vis-panel.vis-top {
  border-color: var(--border) !important;
}

.vis-time-axis .vis-text,
.vis-labelset .vis-label {
  color: var(--text-muted) !important;
}

.vis-time-axis .vis-grid.vis-minor,
.vis-time-axis .vis-grid.vis-major {
  border-color: var(--border) !important;
}

.vis-item {
  border-radius: 4px !important;
  font-size: 0.85rem !important;
}

.vis-item.event-zelensky {
  background: rgba(78, 161, 243, 0.20) !important;
  border-color: var(--zelensky) !important;
  color: var(--text) !important;
}

.vis-item.event-putin {
  background: rgba(217, 83, 79, 0.20) !important;
  border-color: var(--putin) !important;
  color: var(--text) !important;
}

.vis-item.impact-negative {
  border-style: dashed !important;
}

.vis-item.vis-selected {
  background: rgba(255, 255, 255, 0.12) !important;
}

.placeholder-note {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  margin: 0;
}

/* ---------- MAP (axis B) ---------- */
.map-block {
  margin-top: 1.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.map-controls {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.9rem;
  margin-bottom: 0.9rem;
  color: var(--text-muted);
  border: 0;
  padding: 0;
}

.map-controls legend {
  padding: 0;
  margin-right: 0.3rem;
  color: var(--text-muted);
  font-weight: 500;
}

.map-controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text);
  cursor: pointer;
}

.map-controls input[type="radio"] {
  accent-color: var(--accent);
}

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

.map-mount {
  height: 520px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  min-width: 0;
}

.leaflet-container {
  background: #0c1118 !important;
  font-family: var(--font);
}

.leaflet-control-zoom a {
  background: var(--bg-elev) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.leaflet-control-attribution {
  background: rgba(15, 17, 21, 0.85) !important;
  color: var(--text-muted) !important;
  font-size: 0.75rem !important;
}

.country-tooltip {
  background: var(--bg-elev) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
  font-size: 0.85rem !important;
  padding: 0.5rem 0.7rem !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5) !important;
}

.country-tooltip .iso {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.country-tooltip .badge {
  display: inline-block;
  padding: 0 0.35rem;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.72rem;
  background: rgba(255,255,255,0.08);
}

.country-tooltip .badge.v-no { color: var(--putin); }
.country-tooltip .badge.v-abstain { color: #f3c34e; }
.country-tooltip .badge.v-absent { color: var(--text-muted); }
.country-tooltip .badge.v-yes { color: #3aa17a; }

.docs-sidebar {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.9rem;
  overflow-y: auto;
  max-height: 520px;
}

.docs-sidebar h3 {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
  color: var(--text);
}

.docs-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.docs-list a {
  color: var(--text);
  text-decoration: none;
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: 4px;
  border: 1px solid transparent;
  font-size: 0.85rem;
  line-height: 1.35;
  transition: border-color 120ms;
}

.docs-list a:hover {
  border-color: var(--accent);
  background: rgba(78, 161, 243, 0.06);
}

.docs-list .doc-meta {
  display: block;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  margin-bottom: 0.15rem;
}

.docs-list .doc-title {
  display: block;
}

.map-legend {
  margin-top: 0.9rem;
}

.map-legend ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.map-legend .swatch {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 2px;
  margin-right: 0.4rem;
  vertical-align: middle;
}

@media (max-width: 820px) {
  .map-content { grid-template-columns: 1fr; }
  .docs-sidebar { max-height: 320px; }
  .map-mount { height: 420px; }
}

/* ---------- METHODOLOGY ---------- */
.methodology .principles {
  padding-left: 1.25rem;
  max-width: 75ch;
}

.methodology .principles li {
  margin-bottom: 0.6rem;
  color: var(--text-muted);
}

.methodology .principles strong {
  color: var(--text);
  margin-right: 0.4rem;
}

.methodology .contact {
  margin-top: 2rem;
  padding: 1rem 1.25rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}

/* methodology-detail */
.methodology-detail {
  margin-top: 2rem;
}

.formula-block h3,
.axes-details h3 {
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  margin: 1.5rem 0 0.6rem;
  color: var(--text);
}

.formula-line {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin: 0 0 1.25rem;
  overflow-x: auto;
}

.axis-summary,
.component-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}

.axis-summary th,
.axis-summary td,
.component-table th,
.component-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.axis-summary thead th,
.component-table thead th {
  background: rgba(78, 161, 243, 0.06);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.axis-summary tbody tr:last-child td,
.axis-summary tbody tr:last-child th,
.component-table tbody tr:last-child td {
  border-bottom: 1px solid var(--border);
}

.axis-summary tfoot th,
.axis-summary tfoot td {
  background: rgba(78, 161, 243, 0.10);
  font-weight: 600;
  border-top: 1px solid var(--border);
  border-bottom: none;
}

.axis-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--accent);
  color: #0c1118;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.8rem;
  margin-right: 0.5rem;
}

.score { font-variant-numeric: tabular-nums; text-align: right; }
.score-z { color: var(--zelensky); font-weight: 600; }
.score-p { color: var(--putin); font-weight: 600; }

.conf {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.conf-high { color: #3aa17a; }
.conf-medium { color: var(--warn); }
.conf-preliminary { color: var(--text-muted); }
.conf-unknown { color: var(--text-muted); }

.as-of {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.gap {
  text-align: right;
  color: var(--text-muted);
  font-style: italic;
}

.axis-detail {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
  padding: 0;
}

.axis-detail > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  user-select: none;
}

.axis-detail > summary::-webkit-details-marker { display: none; }

.axis-detail > summary::before {
  content: "▸";
  color: var(--text-muted);
  display: inline-block;
  transition: transform 120ms ease;
  width: 1ch;
}

.axis-detail[open] > summary::before { transform: rotate(90deg); }

.axis-detail .ax-title {
  font-weight: 600;
  flex: 1 1 auto;
  min-width: 0;
}

.axis-detail .ax-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.axis-detail .formula {
  margin: 0 1rem;
  padding: 0.7rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--text);
  white-space: pre-wrap;
  overflow-x: auto;
}

.axis-detail .component-table {
  margin: 1rem;
  width: calc(100% - 2rem);
}

.comp-title {
  max-width: 26ch;
}

.evidence-row td {
  padding-top: 0.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border);
  background: rgba(78, 161, 243, 0.02);
}

.ev-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.4rem;
}

.evidence-link {
  display: inline-block;
  margin: 0.15rem 0.25rem 0.15rem 0;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--accent);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.78rem;
  background: var(--bg);
}

.evidence-link:hover {
  border-color: var(--accent);
  background: rgba(78, 161, 243, 0.08);
}

.evidence-bad {
  color: var(--putin);
  font-family: var(--mono);
  font-size: 0.78rem;
  background: rgba(217, 83, 79, 0.10);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.notes-row td {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.notes-row .notes {
  margin: 0;
  padding: 0.6rem 0.9rem;
  white-space: pre-wrap;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.85rem;
  line-height: 1.5;
}

.muted { color: var(--text-muted); }

@media (max-width: 720px) {
  .axis-summary,
  .component-table { font-size: 0.82rem; }
  .axis-summary th,
  .axis-summary td,
  .component-table th,
  .component-table td { padding: 0.45rem 0.55rem; }
  .axis-detail .ax-meta { font-size: 0.75rem; }
}

/* ---------- DEEPSTATEMAP iframe ---------- */
.deepstate-block {
  margin-top: 1.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
}

.deepstate-block > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.8rem 1rem;
  font-weight: 600;
  user-select: none;
}

.deepstate-block > summary::-webkit-details-marker { display: none; }

.deepstate-block > summary::before {
  content: "▸";
  color: var(--text-muted);
  display: inline-block;
  transition: transform 120ms ease;
  width: 1ch;
  margin-right: 0.5rem;
}

.deepstate-block[open] > summary::before { transform: rotate(90deg); }

.deepstate-block .chart-note {
  margin: 0 1rem 0.6rem;
  text-align: left;
}

.deepstate-iframe {
  width: 100%;
  height: 600px;
  border: 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
  display: block;
}

@media (max-width: 720px) {
  .deepstate-iframe { height: 420px; }
}

/* ---------- 404 ---------- */
.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 0;
}

.error-inner {
  text-align: center;
  max-width: 640px;
}

.error-code {
  font-family: var(--mono);
  font-size: clamp(5rem, 16vw, 9rem);
  font-weight: 700;
  color: var(--accent);
  margin: 0;
  line-height: 1;
  letter-spacing: -0.04em;
}

.error-title {
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin: 0.5rem 0 1.25rem;
  color: var(--text);
}

.error-lede {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin: 0.4rem 0;
  max-width: 60ch;
  margin-left: auto;
  margin-right: auto;
}

.error-actions {
  margin: 1.8rem 0 1.2rem;
}

.error-btn {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  transition: border-color 120ms, background 120ms;
}

.error-btn.primary {
  background: var(--accent);
  color: #0c1118;
  border-color: var(--accent);
}

.error-btn:hover { border-color: var(--accent); }

.error-axes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.error-axes a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0;
  font-size: 0.95rem;
}

.error-axes a:hover {
  color: var(--text);
}

/* ---------- FOOTER ---------- */
.site-footer {
  padding: 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--mono);
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 720px) {
  .header-inner { gap: 0.75rem; padding: 0.5rem 0; }
  .primary-nav { font-size: 0.85rem; gap: 0.6rem; }
  .section { padding: 2.5rem 0; }
}
