/* ═══════════════════════════════════════════════════
   INDONESIA FLOOD EXPLORER — Design System v4
   Calm HIG-inspired shell · Cool neutrals · Map-first
   ═══════════════════════════════════════════════════ */

:root {
  /* Surface — cool system neutrals */
  --bg: #e9edf3;
  --surface: rgba(248, 250, 253, 0.82);
  --surface-solid: #f9fbfd;
  --surface-hover: rgba(252, 253, 255, 0.96);
  --surface-card: #f2f5f9;
  --surface-raised: #ffffff;
  --border: rgba(92, 111, 136, 0.12);
  --border-strong: rgba(92, 111, 136, 0.2);

  /* Text — graphite / slate hierarchy */
  --ink: #17202d;
  --ink-secondary: #516173;
  --ink-tertiary: #7e8b9a;
  --ink-inverse: #f7f9fb;

  /* Accent — Apple-like blue */
  --accent: #0a84ff;
  --accent-hover: #0066cc;
  --accent-soft: rgba(10, 132, 255, 0.1);
  --accent-glow: rgba(10, 132, 255, 0.18);
  /* Data highlight accents */
  --accent-warm: #ff9f0a;
  --accent-warm-soft: rgba(255, 159, 10, 0.12);
  --accent-chart: #2ac3a2;
  --accent-chart-soft: rgba(42, 195, 162, 0.14);

  /* Status */
  --danger: #ff453a;
  --success: #30d158;
  --warn: #ff9f0a;

  /* Shadows — restrained system depth */
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05), 0 1px 1px rgba(17, 24, 39, 0.03);
  --shadow-md: 0 10px 24px rgba(28, 43, 61, 0.09), 0 2px 8px rgba(28, 43, 61, 0.05);
  --shadow-lg: 0 18px 40px rgba(28, 43, 61, 0.12), 0 6px 18px rgba(28, 43, 61, 0.07);
  --shadow-xl: 0 28px 72px rgba(28, 43, 61, 0.14), 0 10px 28px rgba(28, 43, 61, 0.08);

  /* Layout */
  --sidebar-w: 318px;
  --focus-w: 312px;
  --sidebar-collapse: 0px;
  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  /* Timing */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration: 280ms;
  --sidebar-duration: 170ms;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Map ─── */
#map {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  transition: left var(--sidebar-duration) var(--ease);
  will-change: left;
  z-index: 0;
}

body.sidebar-collapsed #map {
  left: 0;
}

/* ─── Sidebar ─── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  z-index: 100;
  background: linear-gradient(180deg, rgba(248, 250, 253, 0.92) 0%, rgba(243, 247, 251, 0.88) 100%);
  backdrop-filter: blur(28px) saturate(1.14);
  -webkit-backdrop-filter: blur(28px) saturate(1.14);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transition: transform var(--sidebar-duration) var(--ease);
  will-change: transform;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

.sidebar-inner {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 20px 16px;
  scroll-padding-bottom: 32px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.sidebar-inner::-webkit-scrollbar {
  width: 5px;
}

.sidebar-inner::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-inner::-webkit-scrollbar-thumb {
  background: rgba(120, 90, 50, 0.18);
  border-radius: var(--radius-pill);
}

/* ─── Brand ─── */
.sidebar-brand {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.brand-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 4px;
}

.brand-sub {
  font-size: 0.77rem;
  color: var(--ink-tertiary);
  line-height: 1.4;
  max-width: 26ch;
  white-space: pre-line;
}

.sidebar-toggle {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink-secondary);
  cursor: pointer;
  transition:
    background-color 120ms var(--ease),
    color 120ms var(--ease),
    border-color 120ms var(--ease),
    transform 120ms var(--ease);
}

.sidebar-toggle:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Collapsed state — show expand button on the map side */
.sidebar-expand {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 40px;
  height: 40px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(248, 250, 253, 0.84);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition:
    background-color 120ms var(--ease),
    color 120ms var(--ease),
    transform 120ms var(--ease),
    box-shadow 120ms var(--ease);
}

body.sidebar-collapsed .sidebar-expand {
  display: flex;
}

.sidebar-expand:hover {
  background: var(--accent-soft);
  color: var(--accent);
  transform: scale(1.05);
}

/* ─── Sidebar Sections ─── */
.sidebar-section {
  position: relative;
  overflow: visible;
  margin-bottom: 20px;
}

.sidebar-section:has(.select-shell.is-open) {
  z-index: 50;
}

.sidebar-section:last-of-type {
  margin-bottom: 8px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.section-head h2 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-secondary);
}

.section-intro {
  margin: -2px 0 12px;
  color: var(--ink-tertiary);
  font-size: 0.8rem;
  line-height: 1.55;
}

.accordion-panel {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.accordion-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
  cursor: pointer;
}

.accordion-summary::-webkit-details-marker {
  display: none;
}

.accordion-copy {
  display: grid;
  gap: 3px;
}

.accordion-copy strong {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-secondary);
}

.accordion-kicker {
  font-size: 0.78rem;
  color: var(--ink-tertiary);
}

.accordion-chevron {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--ink-tertiary);
  border-bottom: 2px solid var(--ink-tertiary);
  transform: rotate(45deg);
  transition: transform 160ms var(--ease);
}

.accordion-panel[open] .accordion-chevron {
  transform: rotate(225deg);
}

.accordion-content {
  padding-top: 12px;
}

.sidebar-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0 20px;
}

/* ─── Level Pill ─── */
.level-pill, .period-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.69rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.level-pill {
  background: rgba(10, 132, 255, 0.09);
  color: var(--accent);
}

.period-badge {
  background: rgba(92, 111, 136, 0.1);
  color: var(--ink-secondary);
}

/* ─── Search ─── */
.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-tertiary);
  pointer-events: none;
}

input[type="search"] {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  transition: all var(--duration) var(--ease);
  outline: none;
}

input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.search-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  text-align: left;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 160ms var(--ease);
}

.search-result:hover {
  background: rgba(10, 132, 255, 0.06);
  border-color: var(--accent);
  transform: translateX(2px);
}

.search-result strong {
  display: block;
  font-weight: 600;
}

.search-result span {
  display: block;
  color: var(--ink-tertiary);
  font-size: 0.78rem;
}

/* ─── Stat Grid ─── */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-card {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid var(--border);
  transition: all var(--duration) var(--ease);
}

.stat-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.stat-card--primary {
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.12), rgba(255, 255, 255, 0.92));
  border-color: rgba(10, 132, 255, 0.16);
  border-left: 3px solid var(--accent);
}

.stat-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-tertiary);
  margin-bottom: 4px;
}

.stat-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.stat-card--primary .stat-value {
  color: var(--accent);
}

/* ─── Filter Group ─── */
.filter-group {
  position: relative;
  margin-bottom: 10px;
}

.filter-group:last-child {
  margin-bottom: 0;
}

.filter-group label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-tertiary);
  margin-bottom: 6px;
}

.control-help {
  margin-top: 7px;
  font-size: 0.76rem;
  line-height: 1.45;
}

select {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23546a7b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: all var(--duration) var(--ease);
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.select-native {
  display: none;
}

.select-shell {
  position: relative;
}

.select-shell.is-open {
  z-index: 40;
}

.select-trigger {
  position: relative;
  width: 100%;
  padding: 10px 40px 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    background-color var(--duration) var(--ease);
}

.select-trigger::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 10px;
  height: 6px;
  transform: translateY(-50%);
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23546a7b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: transform 160ms var(--ease);
}

.select-shell.is-open .select-trigger,
.select-trigger:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.select-shell.is-open .select-trigger::after {
  transform: translateY(-50%) rotate(180deg);
}

.select-trigger-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: grid;
  gap: 4px;
  max-height: 216px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: rgba(249, 251, 253, 0.96);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px) scale(0.985);
  transform-origin: top center;
  z-index: 41;
  transition:
    opacity 140ms var(--ease),
    transform 140ms var(--ease);
}

.select-shell.is-open .select-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.select-menu::-webkit-scrollbar {
  width: 6px;
}

.select-menu::-webkit-scrollbar-thumb {
  background: rgba(92, 111, 136, 0.24);
  border-radius: 999px;
}

.select-option {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  transition:
    background-color 140ms var(--ease),
    color 140ms var(--ease);
}

.select-option:hover,
.select-option:focus-visible {
  background: rgba(120, 90, 50, 0.07);
  outline: none;
}

.select-option.is-selected {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.select-option:disabled {
  cursor: default;
  opacity: 0.55;
}

/* ─── Ghost Button ─── */
.btn-ghost {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 160ms var(--ease);
}

.btn-ghost:hover {
  background: rgba(10, 132, 255, 0.08);
  color: var(--accent);
  border-color: var(--accent);
}

/* ─── Selection Detail ─── */
.selection-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.selection-header h3 {
  font-size: 1.48rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-grid dt {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-tertiary);
  margin-bottom: 3px;
}

.detail-grid dd {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.detail-grid > div {
  padding: 10px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid var(--border);
}

/* ─── Chart ─── */
.chart-shell {
  position: relative;
  min-height: 180px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--border);
}

.chart-shell--focus {
  min-height: 146px;
}

/* ─── Qualitative Panel ─── */
.qualitative-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qualitative-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.qualitative-featured-card {
  display: grid;
  gap: 14px;
  padding: 18px 18px 16px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 252, 248, 0.98) 0%, rgba(251, 247, 241, 0.94) 100%);
  border: 1px solid rgba(192, 173, 149, 0.32);
  box-shadow: 0 12px 28px rgba(78, 57, 28, 0.08);
}

.qualitative-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.qualitative-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.qualitative-header strong {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.3;
}

.qualitative-headline {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 400 !important;
  line-height: 1.45;
  color: var(--ink);
}

.qualitative-source-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.qualitative-summary {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--ink);
}

.qualitative-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.qualitative-related {
  display: grid;
  gap: 12px;
}

.section-head--compact {
  margin-bottom: 0;
}

.section-head--compact h3 {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--ink);
}

.qualitative-related-list {
  display: grid;
  gap: 12px;
}

.qualitative-related-item {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 252, 248, 0.96) 0%, rgba(251, 247, 241, 0.9) 100%);
  border: 1px solid rgba(192, 173, 149, 0.28);
  box-shadow: 0 10px 22px rgba(78, 57, 28, 0.06);
}

.qualitative-related-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.qualitative-related-date {
  font-size: 0.78rem;
  color: var(--ink-secondary);
}

.qualitative-related-headline {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 400 !important;
  line-height: 1.42;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.qualitative-related-meta {
  font-size: 0.84rem;
}

.qualitative-related-meta,
.qualitative-related-summary,
.qualitative-state-note,
.qualitative-focus-methodology,
.qualitative-focus-subtitle {
  margin: 0;
}

.qualitative-related-summary {
  font-size: 0.89rem;
  line-height: 1.58;
  color: var(--ink);
}

.qualitative-related-item .source-link {
  margin-top: 2px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 500;
  border: 1px solid rgba(192, 173, 149, 0.22);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink-secondary);
  box-shadow: none;
  letter-spacing: 0.01em;
}

.qualitative-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.source-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.source-link:hover {
  text-decoration: underline;
}

.qualitative-media {
  margin-block: 0;
  border-radius: 18px;
  overflow: hidden;
  background-color: var(--surface-raised);
  border: 1px solid rgba(0,0,0,0.05);
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
  transform: translateZ(0); /* Force GPU */
}

.qualitative-image {
  width: 100%;
  height: auto;
  display: block;
}

.qualitative-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
}

/* ─── Evidence Panel ─── */
.evidence-panel {
  display: grid;
  gap: 10px;
}

.evidence-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.evidence-gap-signal {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
}

.evidence-gap-signal--none {
  background: rgba(13, 148, 136, 0.1);
  color: #0f766e;
  border-color: rgba(13, 148, 136, 0.18);
}

.evidence-gap-signal--internal_only {
  background: rgba(255, 159, 10, 0.1);
  color: #b36400;
  border-color: rgba(255, 159, 10, 0.2);
}

.evidence-gap-signal--external_only {
  background: rgba(2, 132, 199, 0.1);
  color: #0369a1;
  border-color: rgba(2, 132, 199, 0.18);
}

.evidence-gap-signal--mixed {
  background: rgba(96, 93, 236, 0.08);
  color: #4a47d4;
  border-color: rgba(96, 93, 236, 0.16);
}

.evidence-window-note {
  margin-top: -4px;
}

.evidence-note {
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.58;
}

.evidence-gap-context {
  margin-top: -2px;
  font-size: 0.78rem;
  line-height: 1.45;
}

.evidence-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.evidence-metric-grid > div {
  padding: 10px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid var(--border);
}

.evidence-metric-grid dt {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

.evidence-source-head {
  justify-content: space-between;
}

.info-dot {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(120, 90, 50, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-secondary);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
}

.evidence-metric-grid dd {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.btn-ghost:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ─── Empty State ─── */
.empty-state {
  padding: 20px 0;
  color: var(--ink-tertiary);
  font-size: 0.85rem;
  text-align: center;
  line-height: 1.55;
}

.is-hidden {
  display: none !important;
}

/* ─── Text Utilities ─── */
.text-muted {
  color: var(--ink-secondary);
  font-size: 0.82rem;
  line-height: 1.5;
}

.method-summary {
  margin-bottom: 8px;
}

.methodology-list {
  padding-left: 16px;
  color: var(--ink-secondary);
  font-size: 0.82rem;
  line-height: 1.7;
}

/* ─── Sidebar Footer ─── */
.sidebar-footer {
  padding: 16px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.sidebar-footer p {
  font-size: 0.72rem;
  color: var(--ink-tertiary);
  line-height: 1.5;
}

.footer-owner-link {
  color: inherit;
  text-decoration-color: rgba(120, 90, 50, 0.3);
  text-underline-offset: 2px;
}

.footer-owner-link:hover {
  color: var(--ink-secondary);
  text-decoration-color: currentColor;
}

.map-attribution-copy {
  margin-top: 6px;
  font-size: 0.68rem;
  line-height: 1.55;
}

.map-attribution-copy a {
  color: inherit;
  text-decoration-color: rgba(120, 90, 50, 0.3);
  text-underline-offset: 2px;
}

.map-attribution-copy a:hover {
  color: var(--ink-secondary);
  text-decoration-color: currentColor;
}

/* ─── Hover Metric Popup ─── */
.map-hover-popup.maplibregl-popup {
  pointer-events: none;
}

.map-hover-popup .maplibregl-popup-content {
  min-width: 138px;
  padding: 9px 11px;
  border-radius: 12px;
  border: 1px solid rgba(92, 111, 136, 0.16);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(29, 43, 59, 0.18);
}

.map-hover-popup .maplibregl-popup-tip {
  border-top-color: rgba(255, 255, 255, 0.96);
}

.map-hover-popup__content {
  display: grid;
  gap: 4px;
}

.map-hover-popup__title {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.25;
}

.map-hover-popup__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.map-hover-popup__level {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

.map-hover-popup__value {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--accent);
}

/* ═══════════ MAP OVERLAYS ═══════════ */

/* Top-right controls */
.map-controls-tr {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
  transition: right var(--duration) var(--ease), top var(--duration) var(--ease);
}

.language-toggle {
  display: flex;
  border-radius: var(--radius-pill);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-strong);
}

.lang-btn {
  padding: 8px 14px;
  border: none;
  background: rgba(248, 250, 253, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--ink-secondary);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 160ms var(--ease);
}

.lang-btn:first-child {
  border-right: 1px solid var(--border);
}

.lang-btn.is-active {
  background: var(--accent);
  color: var(--ink-inverse);
}

.lang-btn:hover:not(.is-active) {
  background: var(--accent-soft);
  color: var(--accent);
}

.basemap-toggle {
  display: flex;
  border-radius: var(--radius-pill);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-strong);
}

.segmented-btn {
  padding: 8px 16px;
  border: none;
  border-right: 1px solid var(--border);
  background: rgba(248, 250, 253, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--ink-secondary);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 160ms var(--ease);
}

.segmented-btn:last-child {
  border-right: none;
}

.segmented-btn.is-active {
  background: var(--accent);
  color: var(--ink-inverse);
}

.segmented-btn:hover:not(.is-active) {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ─── Legend ─── */
.legend-panel {
  position: fixed;
  bottom: 68px;
  left: calc(var(--sidebar-w) + 16px);
  z-index: 50;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(248, 250, 253, 0.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  min-width: 0;
}

.legend-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.legend-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-tertiary);
}

.legend-head strong {
  font-size: 0.82rem;
  font-weight: 700;
}

.legend-bar {
  display: flex;
  gap: 0;
  height: 8px;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.legend-swatch {
  flex: 1;
  border-radius: 0;
  transition: transform 160ms var(--ease);
}

.legend-swatch:hover {
  transform: scaleY(1.6);
}

.legend-note {
  margin-top: 6px;
  font-size: 0.7rem;
  line-height: 1.4;
}

/* ─── Timeline Bar ─── */
.timeline-bar {
  position: fixed;
  bottom: 10px;
  left: calc(var(--sidebar-w) + 10px);
  width: calc(100vw - var(--sidebar-w) - 20px);
  max-width: calc(100vw - var(--sidebar-w) - 20px);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(248, 250, 253, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

body.sidebar-collapsed .legend-panel {
  left: 16px;
}

body.sidebar-collapsed .timeline-bar {
  left: 10px;
  width: calc(100vw - 20px);
  max-width: calc(100vw - 20px);
}

.timeline-value {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 60px;
  text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Single-track dual-thumb container */
.timeline-track-wrap {
  position: relative;
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
}

/* Both range inputs sit on the same track */
.timeline-range {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: transparent;
  outline: none;
  pointer-events: none;
  z-index: 2;
  margin: 0;
}

/* The 'from' slider renders the base track */
.timeline-range--from {
  z-index: 2;
  background: var(--border);
  border-radius: var(--radius-pill);
}

/* The 'to' slider is fully transparent (stacked on top) */
.timeline-range--to {
  z-index: 3;
  background: transparent;
}

/* Coloured fill between the two thumbs */
.timeline-track-fill {
  position: absolute;
  height: 6px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, rgba(10, 132, 255, 0.92), rgba(42, 195, 162, 0.92));
  pointer-events: none;
  z-index: 1;
  transition: left 60ms, right 60ms;
}

/* Thumb styling — both visible and draggable */
.timeline-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface-solid);
  box-shadow: var(--shadow-md), 0 0 0 2px rgba(10, 132, 255, 0.12);
  cursor: grab;
  pointer-events: auto;
  transition: transform 160ms var(--ease-spring), box-shadow 160ms var(--ease);
  position: relative;
  z-index: 5;
}

.timeline-range--to::-webkit-slider-thumb {
  background: #2ac3a2;
  box-shadow: var(--shadow-md), 0 0 0 2px rgba(42, 195, 162, 0.16);
}

.timeline-range::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow: var(--shadow-lg), 0 0 0 4px var(--accent-glow);
}

.timeline-range::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
}

.timeline-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface-solid);
  box-shadow: var(--shadow-md);
  cursor: grab;
  pointer-events: auto;
}

.timeline-range--to::-moz-range-thumb {
  background: #2ac3a2;
}

/* ═══════════ MAPLIBRE OVERRIDES ═══════════ */

.maplibregl-ctrl-group {
  border-radius: var(--radius-sm) !important;
  overflow: hidden;
  box-shadow: var(--shadow-md) !important;
  border: 1px solid var(--border-strong) !important;
}

.maplibregl-ctrl-group button {
  width: 36px !important;
  height: 36px !important;
}

.maplibregl-ctrl-attrib {
  background: var(--surface) !important;
  backdrop-filter: blur(12px) !important;
  border-radius: var(--radius-xs) !important;
  padding: 4px 8px !important;
  font-size: 0.65rem !important;
}

.maplibregl-ctrl-bottom-right {
  bottom: 102px !important;
  transition: right var(--duration) var(--ease), bottom var(--duration) var(--ease);
}

.maplibregl-ctrl-bottom-left {
  bottom: 102px !important;
  left: 8px !important;
}

/* ═══════════ RESPONSIVE ═══════════ */

@media (max-width: 1024px) {
  :root {
    --sidebar-w: 296px;
    --focus-w: 288px;
  }
}

@media (min-width: 769px) {
  .map-controls-tr {
    max-width: calc(100vw - var(--sidebar-w) - 20px);
  }

  .legend-panel {
    width: min(220px, calc(100vw - var(--sidebar-w) - 32px));
    max-width: calc(100vw - var(--sidebar-w) - 32px);
  }

  body.sidebar-collapsed .map-controls-tr {
    max-width: calc(100vw - 20px);
  }

  body.sidebar-collapsed .legend-panel {
    width: min(220px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
  }
}

@media (max-height: 860px) and (min-width: 769px) {
  .map-controls-tr {
    top: 12px;
    right: 12px;
    gap: 6px;
  }

  .lang-btn,
  .segmented-btn {
    padding: 7px 12px;
    font-size: 0.74rem;
  }

  .legend-panel {
    bottom: 74px;
    left: calc(var(--sidebar-w) + 12px);
    width: min(220px, calc(100vw - var(--sidebar-w) - 24px));
    max-width: calc(100vw - var(--sidebar-w) - 24px);
    padding: 10px 14px;
  }

  .timeline-bar {
    bottom: 12px;
    left: calc(var(--sidebar-w) + 12px);
    width: calc(100vw - var(--sidebar-w) - 24px);
    max-width: calc(100vw - var(--sidebar-w) - 24px);
    gap: 10px;
    padding: 10px 18px;
  }

  body.sidebar-collapsed .legend-panel {
    left: 12px;
    width: min(220px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
  }

  body.sidebar-collapsed .timeline-bar {
    left: 12px;
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }

  .maplibregl-ctrl-bottom-right {
    bottom: 110px !important;
  }

  .maplibregl-ctrl-bottom-left {
    bottom: 110px !important;
    left: 8px !important;
  }

}

@media (max-width: 768px) {
  :root {
    --sidebar-w: min(340px, 85vw);
    --mobile-timeline-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    --mobile-control-clearance: calc(env(safe-area-inset-bottom, 0px) + 116px);
  }

  /* Left slide-out drawer instead of bottom sheet */
  .sidebar {
    top: 0;
    left: 0;
    right: auto;
    width: var(--sidebar-w);
    height: 100dvh;
    border-right: 1px solid var(--border);
    border-top: none;
    border-radius: 0;
    transform: translateX(0);
    z-index: 200;
  }

  body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }

  .sidebar-inner {
    padding: 16px 16px 20px;
  }

  .sidebar-brand {
    position: sticky;
    top: -16px;
    z-index: 5;
    margin: -16px -16px 14px;
    padding: 16px 16px 12px;
    background:
      linear-gradient(180deg, rgba(250, 249, 246, 0.97) 0%, rgba(250, 249, 246, 0.92) 72%, rgba(250, 249, 246, 0.8) 100%);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
  }

  .sidebar-toggle svg {
    transform: none;
  }

  body.sidebar-collapsed .sidebar-toggle svg {
    transform: none;
  }

  .sidebar-expand {
    display: none;
    top: 12px;
    left: 12px;
    z-index: 200;
  }

  body.sidebar-collapsed .sidebar-expand {
    display: flex !important;
  }

  .brand-title {
    font-size: 1.05rem;
  }

  .brand-sub {
    max-width: none;
    font-size: 0.74rem;
    line-height: 1.35;
  }

  .sidebar-section {
    margin-bottom: 16px;
  }

  .sidebar-divider {
    margin: 2px 0 16px;
  }

  .section-head {
    margin-bottom: 8px;
  }

  .section-head h2 {
    font-size: 0.76rem;
  }

  .section-intro {
    font-size: 0.76rem;
    margin-bottom: 10px;
  }

  .stat-card,
  .detail-grid > div {
    padding: 10px;
  }

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

  .filter-group {
    margin-bottom: 8px;
  }

  .select-trigger,
  .select-option,
  input[type="search"] {
    font-size: 0.84rem;
  }

  .selection-header {
    margin-bottom: 10px;
  }

  .selection-header h3 {
    font-size: 1.16rem;
  }

  .chart-shell {
    min-height: 144px;
    padding: 6px;
  }

  #trend-chart {
    height: 132px !important;
  }

  .method-summary,
  .methodology-list,
  .text-muted {
    font-size: 0.78rem;
  }

  .qualitative-panel {
    padding: 14px;
    gap: 12px;
  }

  .qualitative-header strong {
    font-size: 0.94rem;
  }

  .qualitative-summary {
    font-size: 0.84rem;
  }

  .sidebar-footer {
    padding-top: 12px;
  }

  .legend-panel {
    left: 12px;
    bottom: calc(var(--mobile-control-clearance) + 8px);
    width: min(180px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    min-width: 0;
    padding: 10px 12px;
  }

  .timeline-bar {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    bottom: var(--mobile-timeline-bottom);
    align-items: center;
    column-gap: 8px;
    row-gap: 4px;
    padding: 10px 12px;
  }

  .timeline-play-btn {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .timeline-value {
    min-width: 0;
    font-size: 0.68rem;
  }

  #timeline-from-label {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
    text-align: left;
  }

  #timeline-to-label {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
    text-align: right;
  }

  .timeline-track-wrap {
    grid-column: 2 / 4;
    grid-row: 1;
    height: 24px;
  }

  .timeline-range::-webkit-slider-thumb,
  .timeline-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
  }

  .legend-note {
    display: none;
  }

  .map-controls-tr {
    top: 12px;
    left: 12px;
    right: 12px;
    gap: 6px;
    justify-content: flex-end;
    align-items: stretch;
  }

  .language-toggle,
  .basemap-toggle {
    box-shadow: var(--shadow-sm);
  }

  .lang-btn {
    min-width: 42px;
    padding: 7px 10px;
    font-size: 0.72rem;
  }

  .segmented-btn {
    padding: 7px 12px;
    font-size: 0.72rem;
  }

  .maplibregl-ctrl-bottom-right,
  .maplibregl-ctrl-bottom-left {
    bottom: var(--mobile-control-clearance) !important;
  }

  .maplibregl-ctrl-attrib {
    max-width: min(62vw, 220px);
    font-size: 0.62rem !important;
  }

}

@media (max-width: 480px) {
  .brand-row {
    gap: 10px;
  }

  .stat-grid {
    gap: 8px;
  }

  .detail-grid {
    gap: 8px;
  }

  .timeline-bar {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    column-gap: 6px;
    row-gap: 3px;
    padding: 9px 10px;
  }

  .timeline-value {
    font-size: 0.64rem;
  }

  .selection-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .map-controls-tr {
    justify-content: flex-end;
  }
}

@media (max-width: 360px) {
  .stat-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* ═══════════ PLAY BUTTON ═══════════ */

.timeline-play-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  color: var(--accent);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 180ms var(--ease);
}

.timeline-play-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
  transform: scale(1.08);
  box-shadow: var(--shadow-md);
}

.timeline-play-btn.is-playing {
  background: var(--accent);
  color: var(--ink-inverse);
  border-color: var(--accent);
}

.timeline-play-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* ═══════════ TITLE HIGHLIGHT ═══════════ */

.brand-highlight {
  color: var(--accent);
}

/* ═══════════ ANIMATIONS ═══════════ */

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

.sidebar-section {
  animation: fadeSlideIn 400ms var(--ease) both;
}

.sidebar-section:nth-child(1) { animation-delay: 0ms; }
.sidebar-section:nth-child(2) { animation-delay: 50ms; }
.sidebar-section:nth-child(3) { animation-delay: 100ms; }
.sidebar-section:nth-child(4) { animation-delay: 150ms; }
.sidebar-section:nth-child(5) { animation-delay: 200ms; }
.sidebar-section:nth-child(6) { animation-delay: 250ms; }
.sidebar-section:nth-child(7) { animation-delay: 300ms; }

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
