:root {
  --bg: #f5f6f3;
  --panel: rgba(250, 251, 248, 0.98);
  --ink: #15231e;
  --muted: #65726c;
  --line: #dce1dc;
  --accent: #165f48;
  --accent-soft: #e1ebe5;
  --white: #ffffff;
  --shadow: 0 14px 40px rgba(18, 34, 28, 0.12);
  --sidebar: 332px;
  --header: 82px;
  --timeline: 92px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Canva Sans", Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input {
  font: inherit;
}

.topbar {
  height: var(--header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 12px;
  background: #f7f8f5;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 1200;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: var(--sidebar);
}

.brand-logo {
  width: 66px;
  height: 66px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.brand-tagline {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-maps {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.22em;
  font-weight: 700;
}

.topbar-copy {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.workspace {
  height: calc(100vh - var(--header));
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
}

.sidebar {
  min-width: 0;
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1100;
}

.sidebar-scroll {
  overflow-y: auto;
  padding: 8px 20px 18px;
  flex: 1;
}

.panel-block {
  padding: 17px 0 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.variable-kicker {
  font-size: 10px;
  letter-spacing: 0.16em;
  font-weight: 760;
  color: var(--accent);
  margin-bottom: 13px;
}

.field-label {
  display: block;
  margin: 12px 0 6px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 650;
}

.select,
.speed-control select {
  width: 100%;
  border: 1px solid #cfd7d1;
  border-radius: 8px;
  padding: 9px 34px 9px 10px;
  background: var(--white);
  color: var(--ink);
  outline: none;
}

.select:focus,
.speed-control select:focus {
  border-color: #789486;
  box-shadow: 0 0 0 3px rgba(35, 78, 61, 0.08);
}

.variable-info h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.variable-info p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.metadata {
  margin: 15px 0 0;
  padding: 0;
}

.metadata > div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid rgba(220, 225, 220, 0.72);
}

.metadata dt,
.metadata dd {
  margin: 0;
  font-size: 11px;
}

.metadata dt {
  color: var(--muted);
}

.metadata dd {
  text-align: right;
  font-weight: 620;
}

.block-title {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 9px;
}

.legend-gradient {
  height: 12px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #e5e8e5;
}

.legend-labels {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.legend-labels span:nth-child(2) {
  text-align: center;
}

.legend-labels span:nth-child(3) {
  text-align: right;
}

.legend-unit {
  margin-top: 5px;
  font-size: 10px;
  color: var(--muted);
}

.compact-controls {
  padding-bottom: 8px;
}

.control-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 7px;
}

.control-row label {
  color: var(--muted);
}

.range {
  width: 100%;
  accent-color: var(--accent);
}

.sidebar-footer {
  padding: 13px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.03em;
}

.map-shell {
  position: relative;
  min-width: 0;
  height: 100%;
}

#map {
  position: absolute;
  inset: 0;
  background: #e8ebe8;
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow) !important;
}

.leaflet-control-zoom a {
  border-color: var(--line) !important;
  color: var(--ink) !important;
}

.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(255, 255, 255, 0.74) !important;
}

.timeline {
  position: absolute;
  z-index: 1000;
  left: 18px;
  right: 18px;
  bottom: 16px;
  min-height: var(--timeline);
  background: rgba(249, 250, 247, 0.96);
  backdrop-filter: blur(9px);
  border: 1px solid rgba(207, 215, 209, 0.9);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 14px 17px;
}

.timeline-buttons {
  display: flex;
  align-items: center;
  gap: 7px;
}

.round-button,
.play-button,
.icon-button {
  border: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.round-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e8ece8;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  font-weight: 800;
}

.play-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--white);
  font-size: 14px;
  padding-left: 2px;
}

.round-button:hover {
  background: #dfe5e0;
}

.play-button:hover {
  filter: brightness(0.96);
}

.timeline-main {
  min-width: 80px;
}

.timeline-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 10px;
  color: var(--muted);
}

.timeline-head strong {
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0.02em;
}

.timeline-head span:last-child {
  text-align: right;
}

.timeline-range {
  display: block;
}

.speed-control {
  min-width: 84px;
}

.speed-control label {
  display: block;
  font-size: 9px;
  color: var(--muted);
  margin-bottom: 4px;
}

.speed-control select {
  padding: 6px 25px 6px 8px;
  font-size: 11px;
}

.time-stamp {
  position: absolute;
  z-index: 900;
  right: 24px;
  top: 18px;
  pointer-events: none;
  font-size: clamp(30px, 5vw, 72px);
  font-weight: 770;
  letter-spacing: -0.055em;
  color: rgba(20, 36, 30, 0.78);
  text-shadow: 0 1px 10px rgba(255, 255, 255, 0.55);
}

.status-badge {
  position: absolute;
  z-index: 1050;
  top: 18px;
  left: 18px;
  border-radius: 999px;
  background: rgba(249, 250, 247, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(18, 34, 28, 0.1);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid #c9d2cc;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error-box {
  position: absolute;
  z-index: 1060;
  top: 18px;
  left: 18px;
  right: 18px;
  max-width: 660px;
  margin: 0 auto;
  background: #fff7f4;
  color: #7b2c1f;
  border: 1px solid #e6b5aa;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 11px;
  box-shadow: 0 8px 20px rgba(80, 30, 20, 0.08);
}

.hidden {
  display: none !important;
}

.mobile-only {
  display: none;
}

.leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.popup-value {
  min-width: 150px;
  font-size: 11px;
  line-height: 1.45;
}

.popup-value strong {
  display: block;
  font-size: 17px;
  color: var(--ink);
  margin-bottom: 2px;
}

.popup-value .muted {
  color: var(--muted);
}

@media (max-width: 820px) {
  :root {
    --header: 70px;
  }

  .topbar {
    padding: 0 12px;
  }

  .brand {
    min-width: 0;
    gap: 9px;
  }

  .brand-logo {
    width: 54px;
    height: 54px;
  }

  .brand-tagline {
    font-size: 11.5px;
  }

  .brand-maps {
    font-size: 9px;
  }

  .topbar-copy {
    display: none;
  }

  .mobile-only {
    display: grid;
  }

  .icon-button {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #e8ece8;
    color: var(--ink);
  }

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

  .sidebar {
    position: absolute;
    z-index: 1300;
    top: var(--header);
    left: 0;
    width: min(88vw, 340px);
    height: calc(100vh - var(--header));
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .map-shell {
    height: calc(100vh - var(--header));
  }

  .timeline {
    left: 8px;
    right: 8px;
    bottom: 8px;
    grid-template-columns: auto 1fr;
    gap: 10px;
    padding: 10px 11px;
    min-height: 80px;
  }

  .speed-control {
    display: none;
  }

  .round-button {
    width: 30px;
    height: 30px;
  }

  .play-button {
    width: 38px;
    height: 38px;
  }

  .time-stamp {
    right: 12px;
    top: 12px;
    font-size: 38px;
  }
}
