:root {
  --bg: #f5f4ef;
  --panel: #ffffff;
  --border: #d7d4cb;
  --text: #222222;
  --muted: #666666;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  --radius: 14px;
  --drawer-shadow: 0 -10px 30px rgba(0, 0, 0, 0.16);
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: Inter, system-ui, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

body {
  overflow: hidden;
}

#app {
  height: 100%;
  display: grid;
  grid-template-columns: 320px 1fr 360px;
}

#sidebar-left,
#sidebar-right {
  overflow-y: auto;
  background: #fbfaf7;
  padding: 18px;
  min-width: 0;
}

#sidebar-left {
  border-right: 1px solid var(--border);
}

#sidebar-right {
  border-left: 1px solid var(--border);
}

#map {
  position: relative;
  min-height: 100vh;
  min-width: 0;
}

.panel-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.static-header-panel {
  position: relative;
  z-index: 21;
}

h1 {
  font-size: 1.35rem;
  margin: 0 0 8px 0;
  line-height: 1.2;
}

h2 {
  font-size: 1rem;
  margin: 0 0 10px 0;
}

.subtle {
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
}

label {
  display: block;
  margin-bottom: 6px;
}

.checkrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  color: var(--text);
  min-height: 40px;
}

.checkrow input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

select {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fff;
}

input[type="range"] {
  width: 100%;
  min-height: 34px;
}

.impact-card,
.summary-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  line-height: 1.45;
}

.impact-card.empty {
  color: var(--muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.metric {
  background: #f8f6ef;
  border: 1px solid #e4dfd2;
  border-radius: 10px;
  padding: 8px 10px;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.metric-value {
  font-weight: 700;
  font-size: 1rem;
  margin-top: 2px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #faf8f2;
  font-size: 0.85rem;
}

.legend-group + .legend-group {
  margin-top: 14px;
}

.legend-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}

.swatch {
  width: 18px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.swatch-low {
  background: #f1c40f;
}

.swatch-med {
  background: #e67e22;
}

.swatch-high {
  background: #c0392b;
}

.poi-symbol {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom-width: 13px;
  border-bottom-style: solid;
  display: inline-block;
}

.poi-poi {
  border-bottom-color: navy;
}

.poi-th {
  border-bottom-color: forestgreen;
}

.poi-camp {
  border-bottom-color: orange;
}

.poi-trib {
  border-bottom-color: deepskyblue;
}

.poi-rafting {
  border-bottom-color: mediumspringgreen;
}

.raster-swatch {
  width: 28px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
  border: 1px solid #ccc;
}

.raster-viewshed {
  background: linear-gradient(to right, #50f5eb, #1ec8ff, #ff1493);
}

.raster-light {
  background: linear-gradient(to right, #0a1450, #9bc3f5, #fff000);
}

.maplibregl-popup-content {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.92rem;
  max-width: 260px;
}

.mobile-drawer summary {
  list-style: none;
}

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

.mobile-drawer-toggle {
  display: none;
}

.mobile-drawer-body {
  display: block;
}

@media (max-width: 1200px) {
  #app {
    grid-template-columns: 280px 1fr 300px;
  }
}

@media (max-width: 960px) {
  body {
    overflow: auto;
  }

  #app {
    display: block;
    height: 100vh;
    position: relative;
  }

  #map {
    min-height: 100vh;
    height: 100vh;
    width: 100%;
  }

  #sidebar-left,
  #sidebar-right {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 20;
    padding: 10px 12px;
    background: transparent;
    overflow: visible;
    border: none;
    pointer-events: none;
  }

  #sidebar-left {
    top: 0;
  }

  #sidebar-right {
    bottom: 0;
  }

  #sidebar-left .static-header-panel {
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(8px);
    pointer-events: auto;
  }

  #sidebar-left .mobile-drawer {
    pointer-events: auto;
  }

  .mobile-drawer {
    pointer-events: auto;
  }

  .mobile-drawer-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 14px 16px;
    font-weight: 700;
    font-size: 0.98rem;
    cursor: pointer;
    backdrop-filter: blur(6px);
  }

  .mobile-drawer-toggle::after {
    content: "▾";
    font-size: 1rem;
    color: var(--muted);
  }

  .mobile-drawer[open] .mobile-drawer-toggle::after {
    content: "▴";
  }

  .mobile-drawer-body {
    margin-top: 10px;
    max-height: min(56vh, 520px);
    overflow-y: auto;
    padding-right: 2px;
  }

  #sidebar-left .mobile-drawer-body {
    padding-bottom: 4px;
  }

  #sidebar-right .mobile-drawer-body {
    padding-top: 4px;
  }

  #sidebar-left .panel-section,
  #sidebar-right .panel-section {
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(8px);
  }

  #sidebar-right .mobile-drawer-toggle {
    box-shadow: var(--drawer-shadow);
  }

  .panel-section {
    padding: 14px;
  }

  h1 {
    font-size: 1.05rem;
  }

  h2 {
    font-size: 0.98rem;
  }

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

  .legend-item {
    align-items: center;
  }

  .maplibregl-ctrl-top-right {
    top: 72px;
    right: 10px;
  }
}

@media (max-width: 640px) {
  .mobile-drawer-body {
    max-height: min(62vh, 560px);
  }

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

  .metric {
    padding: 10px 12px;
  }

  .pill {
    font-size: 0.8rem;
  }

  .subtle {
    font-size: 0.92rem;
  }

  .checkrow {
    min-height: 44px;
  }

  .mobile-drawer-toggle {
    padding: 13px 14px;
  }

  #sidebar-left,
  #sidebar-right {
    padding-left: 10px;
    padding-right: 10px;
  }

  #sidebar-left .static-header-panel {
    padding: 12px;
  }

  #sidebar-left .static-header-panel h1 {
    font-size: 1rem;
  }
}