@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,300&display=swap');

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

:root {
  /* OWID-inspired editorial light palette */
  --bg: #f7f4ec;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --glass: rgba(0, 0, 0, 0.04);
  --glass-soft: rgba(0, 0, 0, 0.02);
  --border: rgba(0, 0, 0, 0.12);
  --border-strong: rgba(0, 0, 0, 0.22);
  --accent: #6e3d8f;          /* muted purple — OWID signature */
  --accent-2: #d97706;        /* ochre */
  --accent-3: #1e7a4c;        /* forest green */
  --text: #1f1f1f;
  --muted: #6b6b6b;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  --font-mono: 'Space Mono', monospace;
  --font-sans: 'DM Sans', Arial, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

body::before {
  /* No grid overlay on the editorial light theme — keep it clean */
  content: none;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

header,
.controls,
.filter-sidebar,
.chart-area,
.references-intro,
.source-card,
.bee-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(22px) saturate(1.35);
  -webkit-backdrop-filter: blur(22px) saturate(1.35);
}

header {
  border-radius: 8px;
  padding: 0.95rem 1rem;
}

.title-block {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  flex-shrink: 0;
  display: block;
  filter: drop-shadow(0 10px 22px rgba(110, 61, 143, 0.26));
}

.title-text {
  display: flex;
  flex-direction: column;
}

header h1 {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0;
}

header p {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 0.25rem;
}

.controls {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  align-items: center;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  flex-wrap: wrap;
  font-weight: 600;
  position: relative;
  z-index: 20;
}

.viz-workspace {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.filter-sidebar {
  position: sticky;
  top: 1rem;
  z-index: 30;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.filter-sidebar-header {
  padding-bottom: 0.2rem;
}

.filter-sidebar-header strong {
  display: block;
  font-size: 1.1rem;
  line-height: 1.2;
}

.filter-sidebar .control-group {
  min-width: 0;
  width: 100%;
}

.source-hint,
.indicator-source {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.25;
}

.source-hint {
  min-height: 1rem;
}

.source-hint:empty,
.indicator-source:empty {
  display: none;
}

.source-hint::before,
.indicator-source::before {
  content: "Source: ";
  color: rgba(110, 61, 143, 0.82);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reset-filter-button {
  width: 100%;
  min-height: 42px;
  margin-top: 0.25rem;
  border: 1px solid rgba(110, 61, 143, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(110, 61, 143, 0.14), rgba(217, 119, 6, 0.08)),
    rgba(0, 0, 0, 0.06);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 800;
  letter-spacing: 0;
  padding: 0.68rem 0.8rem;
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.08);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.reset-filter-button:hover {
  border-color: rgba(110, 61, 143, 0.62);
  background:
    linear-gradient(135deg, rgba(110, 61, 143, 0.2), rgba(217, 119, 6, 0.12)),
    rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.viz-main {
  min-width: 0;
}

.viz-controls {
  width: 100%;
}

.viz-controls > span {
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.query-controls {
  width: fit-content;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  min-width: 200px;
}

.compact-control {
  flex: 0 0 130px;
  min-width: 130px;
}

.push-right {
  margin-left: auto;
}

.control-group label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-family: var(--font-mono);
}

select {
  appearance: none;
  background:
    linear-gradient(135deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.035)),
    var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.62rem 2.1rem 0.62rem 0.8rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.08);
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 61, 143, 0.16), inset 0 1px 0 rgba(0, 0, 0, 0.08);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.chart-area {
  position: relative;
  border-radius: 8px;
  padding: 1rem;
  height: 520px;
}

#chart { width: 100%; height: 100%; }
#chart svg { display: block; }

.tooltip {
  position: absolute;
  background: #1f1f1f;
  color: #f5f5f5;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
  line-height: 1.6;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.tooltip.hidden { display: none; }
.tooltip strong { color: #d0a8ec; font-family: var(--font-mono); font-size: 0.75rem; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.page-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0.35rem;
  width: fit-content;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--glass-soft);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.page-nav a {
  color: var(--muted);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 7px;
  padding: 0.55rem 0.75rem;
  transition: background 0.15s, color 0.15s;
}

.page-nav a:hover {
  background: rgba(0, 0, 0, 0.07);
  color: var(--text);
}

.page-nav a.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 16px rgba(110, 61, 143, 0.22);
}

/* References page ---------------------------------------------------------- */

.references-intro {
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
}

.references-intro p + p { margin-top: 0.75rem; }
.references-disclaimer { color: var(--muted); font-size: 0.8rem; }

.source-card {
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-top: 1rem;
}

.source-card h2 {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 0.25rem;
}

.source-card .source-url {
  display: inline-block;
  color: var(--accent);
  font-size: 0.8rem;
  text-decoration: none;
  margin-bottom: 0.75rem;
  word-break: break-all;
}
.source-card .source-url:hover { text-decoration: underline; }

.engineering-note {
  background: rgba(255, 167, 38, 0.07);
  border-left: 3px solid #ffa726;
  padding: 0.6rem 0.85rem;
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 0.75rem 0 1rem;
  border-radius: 3px;
  color: var(--text);
}
.engineering-note strong {
  color: #ffa726;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  margin-right: 0.25rem;
}

.indicator-heading {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-top: 0.85rem;
  margin-bottom: 0.5rem;
}

.indicator-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 1rem;
}

.indicator-list li {
  padding: 0.2rem 0;
  font-size: 0.85rem;
  color: var(--text);
}

.indicator-list .indicator-slug {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.7rem;
  margin-left: 0.5rem;
}

.indicator-list .indicator-unit {
  color: var(--muted);
  font-size: 0.7rem;
  margin-left: 0.4rem;
}

.indicator-empty {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

/* Footer source-credit line (shown on every viz page) ----------------------- */

.references-footer {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  letter-spacing: 0.04em;
}

.references-footer a {
  color: var(--accent);
  text-decoration: none;
}

.references-footer a:hover {
  text-decoration: underline;
}

.ask-ai-root {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 120;
  font-family: var(--font-sans);
}

.ask-ai-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.2rem;
  min-height: 52px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #a78bfa 0%, #7c3aed 100%);
  color: white;
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.35), 0 0 1px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: askAiPulse 3s ease-in-out infinite;
}

.ask-ai-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(124, 58, 237, 0.45), 0 0 1px rgba(0, 0, 0, 0.15);
}

.ask-ai-toggle:active {
  transform: translateY(0);
}

.ask-ai-icon {
  font-size: 1.3rem;
  display: inline-block;
  animation: askAiSpin 2s linear infinite;
}

.ask-ai-toggle:hover .ask-ai-icon {
  animation: askAiSpin 0.6s linear;
}

.ask-ai-label {
  display: inline-block;
}

@keyframes askAiPulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(124, 58, 237, 0.35), 0 0 1px rgba(0, 0, 0, 0.1); }
  50% { box-shadow: 0 8px 28px rgba(124, 58, 237, 0.55), 0 0 2px rgba(0, 0, 0, 0.15); }
}

@keyframes askAiSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.ask-ai-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 1rem);
  width: min(420px, calc(100vw - 2rem));
  height: min(550px, calc(100vh - 8rem));
  display: none;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid rgba(167, 139, 250, 0.15);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(15, 10, 35, 0.98) 0%, rgba(25, 15, 50, 0.96) 100%);
  box-shadow: 0 20px 60px rgba(124, 58, 237, 0.2), 0 0 1px rgba(167, 139, 250, 0.1), inset 0 1px 0 rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  animation: askAiSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes askAiSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ask-ai-root.is-open .ask-ai-panel {
  display: grid;
}

.ask-ai-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ask-ai-header-content h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: white;
  letter-spacing: -0.5px;
}

.ask-ai-header-content p {
  margin: 0.3rem 0 0 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.65);
}

.ask-ai-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.ask-ai-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border-color: rgba(255, 255, 255, 0.25);
}

.ask-ai-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}

.ask-ai-messages::-webkit-scrollbar {
  width: 6px;
}

.ask-ai-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ask-ai-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.ask-ai-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.ask-ai-message {
  display: flex;
  gap: 0.6rem;
  animation: askAiFadeIn 0.3s ease;
}

@keyframes askAiFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ask-ai-message-content {
  flex: 1;
  padding: 0.75rem 0.95rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.ask-ai-assistant {
  justify-content: flex-start;
}

.ask-ai-assistant .ask-ai-message-content {
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: white;
}

.ask-ai-assistant.ask-ai-error .ask-ai-message-content {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.28);
  color: #fca5a5;
}

.ask-ai-user {
  justify-content: flex-end;
}

.ask-ai-user .ask-ai-message-content {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.2) 0%, rgba(168, 85, 247, 0.15) 100%);
  border: 1px solid rgba(167, 139, 250, 0.3);
  color: white;
}

.ask-ai-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.ask-ai-user .ask-ai-avatar {
  display: none;
}

.ask-ai-welcome {
  background-color: transparent;
}

.ask-ai-welcome .ask-ai-message-content {
  background: rgba(167, 139, 250, 0.1);
  border: 1px solid rgba(167, 139, 250, 0.2);
  color: white;
  font-size: 0.88rem;
}

/* The welcome messages in ask-ai.js use a bare <div> for their text instead of
   .ask-ai-message-content, so the styled-bubble rule above never matches them.
   Color every non-avatar direct child white so the welcome text is legible. */
.ask-ai-welcome > div:not(.ask-ai-avatar) {
  color: white;
  font-size: 0.88rem;
}

.ask-ai-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.25);
}

.ask-ai-form input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: white;
  font: inherit;
  font-size: 0.9rem;
  outline: none;
  padding: 0.7rem 0.95rem;
  transition: all 0.2s ease;
}

.ask-ai-form input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.ask-ai-form input:focus {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(167, 139, 250, 0.6);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

.ask-ai-send-btn {
  flex-shrink: 0;
  min-height: 44px;
  min-width: 44px;
  border: 1px solid rgba(167, 139, 250, 0.4);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.25) 0%, rgba(168, 85, 247, 0.15) 100%);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.ask-ai-send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.35) 0%, rgba(168, 85, 247, 0.25) 100%);
  border-color: rgba(167, 139, 250, 0.6);
  color: white;
  box-shadow: 0 4px 12px rgba(167, 139, 250, 0.2);
  transform: translateY(-1px);
}

.ask-ai-send-btn:disabled {
  cursor: default;
  opacity: 0.5;
}

.multi-select { position: relative; }
.multi-select-dropdown {
  background: rgba(0, 0, 0, 0.055);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 100;
  padding: 0.75rem;
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.55rem;
}
.multi-select-dropdown label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.58rem 0.7rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 8px;
  min-width: 0;
}
.multi-select-dropdown label:hover { background: rgba(0, 0, 0, 0.08); }

.trends-controls {
  width: 100%;
  align-items: center;
}

.country-filter-menu {
  position: relative;
  min-width: 250px;
}

.filter-sidebar .country-filter-menu {
  min-width: 0;
  width: 100%;
}

.country-filter-menu summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  min-height: 42px;
  padding: 0.55rem 0.72rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.035)),
    var(--surface-strong);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.08);
}

.country-filter-menu summary strong {
  display: block;
  font-size: 0.9rem;
  line-height: 1.15;
}

.country-filter-menu summary::-webkit-details-marker {
  display: none;
}

.country-filter-menu summary::after {
  content: "v";
  color: var(--accent);
  font-size: 1rem;
  line-height: 1;
  transition: transform 0.15s;
}

.country-filter-menu[open] summary {
  border-color: rgba(110, 61, 143, 0.48);
  box-shadow: 0 0 0 3px rgba(110, 61, 143, 0.12), inset 0 1px 0 rgba(0, 0, 0, 0.08);
}

.country-filter-menu[open] summary::after {
  transform: rotate(180deg);
}

.country-filter-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 0.55rem);
  width: min(680px, calc(100vw - 2rem));
  z-index: 50;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.filter-sidebar .country-filter-popover {
  position: static;
  width: 100%;
  margin-top: 0.65rem;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.filter-sidebar .multi-select-dropdown {
  grid-template-columns: 1fr;
  max-height: 300px;
  margin-top: 0;
}

.country-filter-popover .multi-select-dropdown {
  margin-top: 0.75rem;
}

.country-filter-actions {
  display: flex;
  justify-content: flex-end;
}

.country-search {
  width: 100%;
  min-height: 38px;
  margin-top: 0.65rem;
  padding: 0.55rem 0.72rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background:
    linear-gradient(135deg, rgba(0, 0, 0, 0.09), rgba(0, 0, 0, 0.025)),
    rgba(0, 0, 0, 0.055);
  color: var(--text);
  font: inherit;
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.08);
}

.country-search::placeholder {
  color: var(--muted);
}

.country-search:focus {
  border-color: rgba(110, 61, 143, 0.58);
  box-shadow: 0 0 0 3px rgba(110, 61, 143, 0.12), inset 0 1px 0 rgba(0, 0, 0, 0.08);
}

.country-filter-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.country-filter-heading strong {
  display: block;
  margin-top: 0.15rem;
  font-size: 1rem;
}

.ghost-button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.07);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 700;
  padding: 0.58rem 0.78rem;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.ghost-button:hover:not(:disabled) {
  background: rgba(110, 61, 143, 0.13);
  border-color: rgba(110, 61, 143, 0.48);
  transform: translateY(-1px);
}

.ghost-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.country-chip {
  background: rgba(0, 0, 0, 0.055);
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.08);
  outline: none;
}

.country-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.country-chip.is-selected,
.country-chip:has(input:checked) {
  background: linear-gradient(135deg, rgba(110, 61, 143, 0.22), rgba(217, 119, 6, 0.16));
  border-color: rgba(110, 61, 143, 0.5);
  color: #ffffff;
}

.country-chip:focus-visible {
  border-color: rgba(110, 61, 143, 0.62);
  box-shadow: 0 0 0 3px rgba(110, 61, 143, 0.16), inset 0 1px 0 rgba(0, 0, 0, 0.08);
}

.country-flag {
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  flex: 0 0 1.25rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
  font-size: 0.82rem;
  line-height: 1;
}

.selected-country-flags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.8rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.selected-country-flag,
.selected-country-more {
  display: inline-grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  background: rgba(110, 61, 143, 0.14);
  border: 1px solid rgba(110, 61, 143, 0.28);
  font-size: 0.88rem;
  line-height: 1;
}

.selected-country-more {
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 700;
}

.country-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .layout {
    padding: 1rem;
  }

  .chart-area {
    height: 440px;
  }

  .viz-workspace {
    grid-template-columns: 1fr;
  }

  .filter-sidebar {
    position: static;
  }

  .query-controls,
  .page-nav {
    width: 100%;
  }

  .country-filter-menu {
    width: 100%;
    min-width: 0;
    margin-left: 0;
  }

  .country-filter-popover {
    left: 0;
    right: auto;
    width: 100%;
  }

  .country-filter-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}
