:root {
  --bg: #0f1720;
  --surface: #151f2a;
  --surface-2: #1d2a36;
  --text: #eef4f2;
  --muted: #a9b8b6;
  --border: #344554;
  --accent: #2f9e8f;
  --accent-2: #d7a84f;
  --danger: #d26666;
  --map-filter: saturate(0.82) brightness(0.72);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #e8efec;
  --text: #1d2729;
  --muted: #5f6f72;
  --border: #cbd7d4;
  --accent: #197d72;
  --accent-2: #9b6a12;
  --danger: #a33b3b;
  --map-filter: none;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto auto;
  gap: 18px;
  align-items: center;
  padding: 14px clamp(16px, 3vw, 36px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  line-height: 1.15;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--accent-2);
  font-weight: 800;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.main-nav a,
.theme-toggle,
.secondary-button,
.primary-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 8px 12px;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.main-nav a:hover,
.theme-toggle:hover,
.secondary-button:hover {
  border-color: var(--accent);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.research-note {
  padding: 18px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.research-note p {
  max-width: 1180px;
  margin: 0 auto;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  min-height: calc(100vh - 154px);
  border-bottom: 1px solid var(--border);
}

.control-panel {
  padding: 18px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.panel-block {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.panel-block label,
.check-row {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--text);
}

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

.panel-grid .panel-block {
  margin-bottom: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  grid-column: 1 / -1;
  min-height: 38px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 18px;
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.results-list {
  display: grid;
  gap: 8px;
  max-height: 48vh;
  overflow: auto;
  padding-right: 4px;
}

.result-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.result-item strong {
  display: block;
  font-size: 14px;
}

.result-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.map-shell {
  min-width: 0;
  background: var(--bg);
}

.map-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  padding: 18px clamp(16px, 2vw, 26px);
}

.map-toolbar h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.05;
  letter-spacing: 0;
}

.map-toolbar p {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
}

.map-status {
  min-width: 150px;
  text-align: right;
  color: var(--muted);
  font-size: 13px;
}

.map-canvas {
  width: 100%;
  height: min(72vh, 760px);
  min-height: 520px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

[data-theme="dark"] .leaflet-tile-pane {
  filter: var(--map-filter);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--surface);
  color: var(--text);
}

.section-band {
  padding: 34px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--border);
}

.section-title {
  max-width: 1180px;
  margin: 0 auto 18px;
}

.section-title span {
  color: var(--accent-2);
  font-weight: 750;
  text-transform: uppercase;
  font-size: 12px;
}

.section-title h2 {
  margin: 5px 0 0;
  font-size: clamp(22px, 3vw, 34px);
  letter-spacing: 0;
}

.indicator-grid,
.download-grid {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.indicator-card,
.download-card,
.timeline-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.indicator-card strong {
  display: block;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1;
}

.indicator-card span,
.download-card span,
.timeline-item span {
  color: var(--muted);
  font-size: 13px;
}

.download-card {
  display: grid;
  gap: 10px;
}

.download-card a {
  color: var(--accent);
  font-weight: 750;
  text-decoration: none;
}

.timeline {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.timeline-item strong {
  display: block;
  margin: 6px 0;
}

.timeline-item p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(16px, 3vw, 36px);
  color: var(--muted);
  background: var(--surface);
}

@media (max-width: 980px) {
  .app-header {
    grid-template-columns: 1fr auto;
  }

  .main-nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
  }

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

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .results-list {
    max-height: 280px;
  }

  .indicator-grid,
  .download-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-header,
  .map-toolbar,
  .app-footer {
    display: grid;
    grid-template-columns: 1fr;
  }

  .theme-toggle,
  .map-status {
    width: 100%;
    text-align: left;
  }

  .panel-grid,
  .panel-actions,
  .indicator-grid,
  .download-grid {
    grid-template-columns: 1fr;
  }

  .map-canvas {
    min-height: 430px;
    height: 64vh;
  }
}
