:root {
  color-scheme: light;
  --font-sans: Figtree, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --background: #ffffff;
  --foreground: #1c1917;
  --card: #ffffff;
  --muted: #f5f5f4;
  --muted-foreground: #6b655d;
  --border: #e7e5e4;
  --primary: #059669;
  --primary-foreground: #ecfdf5;
  --accent: #ecfdf5;
  --accent-foreground: #064e3b;
  --destructive: #b91c1c;
  --discover-sidebar-background: #f0f5ee;
  --discover-sidebar-card: #ffffff;
  --overlay-clearcuts: #d9822b;
  --overlay-clearcuts-soft: rgba(217, 130, 43, 0.16);
  --overlay-clearcuts-pattern: #8a4a0f;
  --overlay-campability: #6d28d9;
  --overlay-campability-soft: rgba(109, 40, 217, 0.2);
  --overlay-campability-pattern: #3b0764;
  --overlay-trails: #4b5563;
  --overlay-nature: #0f766e;
  --shadow-panel: 0 18px 38px -24px rgba(15, 23, 42, 0.38), 0 6px 18px -16px rgba(15, 23, 42, 0.28);
}

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

html,
body,
#app {
  height: 100%;
  margin: 0;
}

body {
  min-height: 100%;
  overflow: hidden;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  line-height: 1.4;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  position: relative;
  display: flex;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  background: var(--background);
}

.top-nav {
  position: absolute;
  inset: 0 0 auto;
  z-index: 60;
  display: flex;
  height: 4rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 0 1.5rem;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  border-radius: 0.45rem;
  padding: 0.25rem;
  transition: background 160ms ease;
}

.brand-link:hover {
  background: rgba(255, 255, 255, 0.12);
}

.brand-link img {
  width: auto;
  height: 2.35rem;
  object-fit: contain;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-button,
.icon-button,
.account-button,
.tool-button,
.layer-button,
.filter-button,
.bottom-nav-item,
.text-button,
.clear-search,
.small-icon-button {
  border: 0;
  background: transparent;
  color: inherit;
}

.nav-button {
  position: relative;
  display: inline-flex;
  height: 2.25rem;
  align-items: center;
  gap: 0.45rem;
  border-radius: 0.45rem;
  padding: 0 0.75rem;
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 650;
  transition: background 150ms ease;
}

.nav-button svg,
.icon-button svg,
.tool-button svg,
.layer-button svg,
.bottom-nav-item svg,
.filter-button svg,
.clear-search svg,
.small-icon-button svg {
  width: 1rem;
  height: 1rem;
}

.nav-button:hover,
.nav-button.is-active,
.icon-button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.icon-button {
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.45rem;
  color: #ffffff;
}

.account-button {
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
}

.map-container {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  color: var(--foreground);
  --mobile-nav-height: 3.2rem;
}

.map-node {
  position: absolute;
  inset: 0;
}

.filter-anchor {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 4.6rem);
  left: 50%;
  z-index: 46;
  width: min(42rem, calc(100vw - 2rem));
  transform: translateX(-50%);
  pointer-events: none;
}

.filter-button {
  display: flex;
  height: 2.25rem;
  align-items: center;
  gap: 0.55rem;
  margin: 0 auto;
  border: 1px solid rgba(214, 211, 209, 0.9);
  border-radius: 999px;
  background: var(--card);
  color: var(--foreground);
  padding: 0 1rem;
  box-shadow: 0 9px 18px -16px rgba(15, 23, 42, 0.55), 0 1px 2px rgba(15, 23, 42, 0.08);
  font-size: 0.875rem;
  font-weight: 750;
  pointer-events: auto;
}

.filter-button:hover,
.filter-button[aria-expanded="true"] {
  border-color: rgba(5, 150, 105, 0.35);
  background: #ffffff;
}

.filter-count {
  display: inline-flex;
  min-width: 1.35rem;
  height: 1.35rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-foreground);
  font-size: 0.75rem;
}

.filter-popover {
  margin: 0.55rem auto 0;
  width: min(42rem, calc(100vw - 2rem));
  max-height: min(70vh, 40rem);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--card);
  box-shadow: var(--shadow-panel);
  padding: 0.85rem;
  pointer-events: auto;
}

.popover-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  padding: 0.2rem 0.15rem 0.8rem;
}

.eyebrow {
  margin: 0 0 0.1rem;
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.popover-header h2 {
  margin: 0;
  font-size: 0.96rem;
}

.text-button {
  border-radius: 0.45rem;
  color: var(--muted-foreground);
  padding: 0.4rem 0.55rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.text-button:hover {
  background: var(--muted);
  color: var(--foreground);
}

.filter-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  padding-top: 0.85rem;
}

.filter-group {
  min-width: 0;
  border: 1px solid rgba(231, 229, 228, 0.86);
  border-radius: 0.65rem;
  background: rgba(245, 245, 244, 0.36);
  padding: 0.7rem;
}

.filter-group h3 {
  margin: 0 0 0.55rem;
  font-size: 0.84rem;
}

.filter-option {
  display: flex;
  min-height: 2rem;
  align-items: center;
  gap: 0.55rem;
  border-radius: 0.45rem;
  padding: 0.35rem 0.3rem;
  color: var(--foreground);
  font-size: 0.86rem;
}

.filter-option:hover {
  background: #ffffff;
}

.filter-option input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
}

.right-tools {
  position: absolute;
  top: 50%;
  right: 1rem;
  z-index: 45;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transform: translateY(-50%);
  pointer-events: none;
}

.tool-button,
.layer-toggle-panel {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-panel);
  pointer-events: auto;
}

.tool-button {
  display: flex;
  width: 2.5rem;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
  color: var(--foreground);
}

.tool-button:hover,
.tool-button[aria-pressed="true"] {
  border-color: rgba(5, 150, 105, 0.36);
  background: var(--accent);
  color: var(--primary);
}

.layer-toggle-panel {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.45rem;
}

.layer-button {
  position: relative;
  display: flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: #ffffff;
  color: var(--foreground);
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.layer-button:hover {
  background: var(--muted);
}

.layer-button[aria-pressed="true"] {
  border-color: var(--layer-color, var(--primary));
  background: var(--layer-soft, var(--accent));
  color: var(--layer-color, var(--primary));
}

.sidebar-stack {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 4.75rem);
  bottom: 0.75rem;
  left: 0.75rem;
  z-index: 45;
  display: flex;
  width: min(24rem, calc(100% - 4.5rem));
  max-width: 100%;
  flex-direction: column;
  pointer-events: auto;
}

.discovery-panel {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--discover-sidebar-card);
  box-shadow: var(--shadow-panel);
}

.panel-view {
  min-height: 0;
  flex: 1;
}

.panel-scroll {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  overscroll-behavior: contain;
}

.sidebar-header {
  display: grid;
  gap: 0.55rem;
  padding-bottom: 0.75rem;
}

.sidebar-logo {
  width: 10rem;
  height: auto;
}

.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted-foreground);
  font-size: 0.85rem;
  font-weight: 650;
}

.status-pill {
  display: inline-flex;
  min-height: 1.55rem;
  align-items: center;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  background: #ecfdf5;
  color: #166534;
  padding: 0.18rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill[data-tone="error"] {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 0.75rem;
}

.search-field > svg {
  position: absolute;
  left: 0.75rem;
  z-index: 1;
  width: 1rem;
  height: 1rem;
  color: var(--muted-foreground);
}

.search-field input {
  width: 100%;
  height: 2.55rem;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: #ffffff;
  color: var(--foreground);
  outline: none;
  padding: 0 2.25rem 0 2.2rem;
  font-size: 0.9rem;
}

.search-field input:focus {
  border-color: rgba(5, 150, 105, 0.45);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.clear-search {
  position: absolute;
  right: 0.45rem;
  display: flex;
  width: 1.55rem;
  height: 1.55rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
}

.search-results,
.area-list {
  display: grid;
  gap: 0.65rem;
}

.search-results {
  margin-bottom: 0.75rem;
}

.empty-note,
.loading-note {
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

.result-button {
  display: flex;
  width: 100%;
  align-items: start;
  gap: 0.6rem;
  border: 0;
  border-radius: 0.55rem;
  background: transparent;
  color: var(--foreground);
  padding: 0.55rem;
  text-align: left;
}

.result-button:hover {
  background: var(--muted);
}

.result-icon {
  display: inline-flex;
  width: 2.15rem;
  height: 2.15rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 0.55rem;
  background: var(--accent);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 900;
}

.result-name,
.card-title {
  display: block;
  color: var(--foreground);
  font-weight: 760;
}

.result-meta {
  display: block;
  margin-top: 0.12rem;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.area-card {
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  background: #ffffff;
  color: var(--foreground);
  box-shadow: 0 6px 18px -14px rgba(15, 23, 42, 0.5), 0 0 0 1px rgba(214, 211, 209, 0.65);
  padding: 0.85rem;
  text-align: left;
  transition: box-shadow 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.area-card:hover,
.area-card.is-selected {
  border-color: rgba(120, 113, 108, 0.55);
  box-shadow: 0 12px 26px -18px rgba(15, 23, 42, 0.52), 0 0 0 1px rgba(120, 113, 108, 0.65);
}

.area-card:hover {
  transform: translateY(-1px);
}

.area-card-body {
  display: flex;
  align-items: stretch;
  gap: 0.85rem;
}

.area-thumb {
  position: relative;
  width: 4.5rem;
  height: 4.5rem;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 0.55rem;
  background:
    linear-gradient(135deg, rgba(5, 150, 105, 0.18), rgba(120, 113, 108, 0.16)),
    repeating-linear-gradient(135deg, rgba(5, 150, 105, 0.16) 0 0.18rem, transparent 0.18rem 0.55rem);
}

.area-thumb::after {
  content: "";
  position: absolute;
  inset: 30% 18% 18%;
  border-radius: 50% 50% 42% 42%;
  background: rgba(5, 150, 105, 0.28);
  transform: rotate(-12deg);
}

.area-card-main {
  display: flex;
  min-width: 0;
  min-height: 4.5rem;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
}

.card-title {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1rem;
  line-height: 1.22;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.65rem;
}

.badge {
  display: inline-flex;
  min-height: 1.45rem;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.74rem;
  font-weight: 760;
  white-space: nowrap;
}

.badge.secondary {
  background: var(--muted);
  color: var(--foreground);
}

.badge.outline {
  border-color: var(--border);
  background: #ffffff;
  color: var(--foreground);
}

.badge.primary {
  border-color: rgba(5, 150, 105, 0.26);
  background: var(--accent);
  color: var(--accent-foreground);
}

.badge.wilderness {
  margin-left: auto;
  border-color: #166534;
  background: linear-gradient(135deg, #166534, #059669);
  color: #ecfdf5;
}

.detail-scroll {
  height: 100%;
  overflow: auto;
  background: var(--discover-sidebar-background);
  overscroll-behavior: contain;
}

.detail-section {
  background: var(--discover-sidebar-card);
  padding: 1rem;
}

.detail-divider {
  height: 0.5rem;
  background: var(--discover-sidebar-background);
}

.detail-topbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.65rem;
}

.small-icon-button {
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  color: var(--foreground);
}

.small-icon-button:hover {
  background: var(--muted);
}

.detail-title {
  margin: 0.65rem 0 0.35rem;
  overflow-wrap: anywhere;
  font-size: 1.18rem;
  line-height: 1.2;
}

.detail-hero {
  position: relative;
  min-height: 9.5rem;
  overflow: hidden;
  border-radius: 0.7rem;
  background:
    linear-gradient(180deg, rgba(6, 78, 59, 0.18), rgba(6, 78, 59, 0.03)),
    radial-gradient(circle at 18% 22%, rgba(5, 150, 105, 0.28), transparent 28%),
    radial-gradient(circle at 76% 64%, rgba(217, 130, 43, 0.18), transparent 34%),
    linear-gradient(135deg, #eef7ee, #e7ece2);
  margin-top: 0.85rem;
}

.detail-hero svg {
  position: absolute;
  inset: auto 0 0;
  width: 100%;
  height: 76%;
  color: rgba(6, 78, 59, 0.22);
  stroke-width: 1.5;
}

.detail-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.stat-tile {
  min-width: 0;
  border-radius: 0.6rem;
  background: var(--muted);
  padding: 0.75rem;
}

.stat-label {
  display: block;
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  margin-top: 0.2rem;
  color: var(--foreground);
  font-size: 1rem;
  font-weight: 800;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.primary-action,
.secondary-action,
.danger-action {
  display: inline-flex;
  min-height: 2.35rem;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  padding: 0 0.8rem;
  font-weight: 760;
}

.primary-action {
  background: var(--primary);
  color: var(--primary-foreground);
}

.secondary-action {
  border-color: rgba(5, 150, 105, 0.35);
  background: #ffffff;
  color: var(--primary);
}

.danger-action {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.prose {
  color: var(--muted-foreground);
  font-size: 0.92rem;
}

.prose p {
  margin: 0 0 0.85rem;
}

.detail-list {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}

.detail-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.9rem;
}

.detail-row dt {
  color: var(--muted-foreground);
}

.detail-row dd {
  margin: 0;
  text-align: right;
  font-weight: 720;
}

.planning-summary {
  display: grid;
  gap: 0.65rem;
}

.planning-point-list {
  display: grid;
  gap: 0.4rem;
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
}

.planning-point-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-radius: 0.5rem;
  background: var(--muted);
  padding: 0.45rem 0.55rem;
  color: var(--muted-foreground);
  font-size: 0.82rem;
}

.toast {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 80;
  max-width: min(24rem, calc(100vw - 2rem));
  border: 1px solid rgba(187, 247, 208, 0.55);
  border-radius: 0.7rem;
  background: rgba(6, 78, 59, 0.94);
  color: #ecfdf5;
  box-shadow: var(--shadow-panel);
  padding: 0.72rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 650;
}

.bottom-nav {
  display: none;
}

.sidebar-sheet-handle {
  display: none;
}

.maplibregl-ctrl-top-right,
.mapboxgl-ctrl-top-right {
  top: 4.6rem;
  right: 1rem;
}

.maplibregl-ctrl-attrib {
  font-size: 0.68rem;
}

@media (max-width: 960px) {
  .top-nav {
    display: none;
  }

  .bottom-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 70;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.25rem;
    border-top: 1px solid var(--border);
    background: #ffffff;
    padding: 0.25rem 0.4rem calc(0.25rem + env(safe-area-inset-bottom));
  }

  .bottom-nav-item {
    display: flex;
    min-width: 0;
    height: 2.7rem;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.05rem;
    border-radius: 0.6rem;
    color: var(--muted-foreground);
    font-size: 0.68rem;
    font-weight: 760;
  }

  .bottom-nav-item svg {
    width: 1rem;
    height: 1rem;
  }

  .bottom-nav-item.is-active {
    background: var(--muted);
    color: var(--foreground);
  }

  .filter-anchor {
    top: calc(env(safe-area-inset-top) + 0.75rem);
    width: calc(100vw - 6rem);
  }

  .filter-button {
    height: 2.2rem;
    padding: 0 0.72rem;
  }

  .filter-button span:not(.filter-count) {
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .filter-popover {
    width: calc(100vw - 1rem);
    max-height: 62vh;
  }

  .filter-groups {
    grid-template-columns: 1fr;
  }

  .right-tools {
    top: calc(env(safe-area-inset-top) + 4.4rem);
    right: 0.75rem;
    transform: none;
  }

  .sidebar-stack {
    position: fixed;
    inset: auto 0 calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)) 0;
    width: auto;
    height: min(70dvh, 42rem);
    max-height: calc(100dvh - 5.25rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    transition: height 180ms ease;
  }

  .sidebar-stack--mobile-collapsed {
    height: 15.5rem;
  }

  .sidebar-stack--mobile-expanded {
    height: min(70dvh, 42rem);
  }

  .sidebar-sheet-handle {
    display: flex;
    width: 100%;
    min-height: 2.45rem;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 1rem 1rem 0 0;
    background: var(--card);
    padding: 0.55rem 0 0.4rem;
    touch-action: none;
  }

  .sidebar-sheet-handle__bar {
    width: 3rem;
    height: 0.3rem;
    border-radius: 999px;
    background: rgba(28, 25, 23, 0.28);
  }

  .discovery-panel {
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0;
  }

  .panel-scroll {
    padding: 0.8rem;
  }

  .sidebar-logo {
    display: none;
  }

  .area-card {
    padding: 0.65rem;
  }

  .area-thumb {
    width: 3.5rem;
    height: 3.5rem;
  }

  .area-card-main {
    min-height: 3.5rem;
  }

  .card-title {
    font-size: 0.92rem;
  }

  .maplibregl-ctrl-top-right,
  .mapboxgl-ctrl-top-right {
    top: calc(env(safe-area-inset-top) + 4.35rem);
    right: 0.72rem;
  }

  .toast {
    right: 0.75rem;
    bottom: calc(var(--mobile-nav-height) + 16rem + env(safe-area-inset-bottom));
    left: 0.75rem;
    max-width: none;
  }
}

@media (max-width: 520px) {
  .status-line {
    align-items: start;
    flex-direction: column;
    gap: 0.4rem;
  }

  .detail-stat-grid {
    grid-template-columns: 1fr;
  }

  .right-tools {
    gap: 0.55rem;
  }
}
