:root {
  color-scheme: dark;
  --ink: #f3f4ec;
  --muted: #aeb9ad;
  --panel: rgba(31, 39, 31, 0.8);
  --panel-strong: rgba(19, 27, 21, 0.92);
  --line: rgba(246, 231, 193, 0.22);
  --green: #86aa67;
  --gold: #c9a750;
  --water: #75b9b8;
  --trail: #cf5b44;
  --paper: #e7ddbd;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell,
#map {
  position: fixed;
  inset: 0;
}

#map {
  background: var(--paper);
}

.app-shell::before,
.app-shell::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.app-shell::before {
  opacity: 0.34;
  mix-blend-mode: multiply;
  background:
    radial-gradient(circle at 18% 24%, rgba(255, 246, 208, 0.7), transparent 24%),
    radial-gradient(circle at 75% 62%, rgba(100, 143, 111, 0.2), transparent 34%),
    linear-gradient(120deg, rgba(139, 112, 72, 0.12), transparent 44%, rgba(67, 118, 120, 0.12)),
    repeating-linear-gradient(8deg, rgba(83, 67, 38, 0.035) 0 1px, transparent 1px 6px);
}

.app-shell::after {
  opacity: 0.18;
  mix-blend-mode: soft-light;
  background:
    repeating-radial-gradient(circle at 22% 30%, rgba(49, 34, 18, 0.18) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(96deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 7px);
}

.topbar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.brand,
.icon-row,
.modebar,
.layer-panel,
.sheet {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(16px);
}

.brand-mark {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 35%, var(--water) 0 20%, transparent 22%),
    conic-gradient(from 210deg, var(--green), #4f6b42, var(--gold), var(--green));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.brand p,
.brand span {
  margin: 0;
  white-space: nowrap;
}

.brand p {
  font-size: 15px;
  font-weight: 760;
  line-height: 1.15;
}

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

.icon-row {
  display: flex;
  gap: 8px;
}

.icon-button,
.mode-chip,
.layer-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(16px);
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
}

.icon-button svg,
.mode-chip svg,
.layer-toggle svg,
.search-row svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.1;
}

.modebar {
  position: fixed;
  top: calc(max(12px, env(safe-area-inset-top)) + 62px);
  left: 12px;
  right: 12px;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mode-chip {
  height: 40px;
  gap: 7px;
  border-radius: 8px;
  color: var(--muted);
}

.mode-chip.active,
.layer-toggle.active {
  color: #07120f;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(238, 228, 190, 0.94);
}

.layer-panel {
  position: fixed;
  top: calc(max(12px, env(safe-area-inset-top)) + 116px);
  right: 12px;
  z-index: 3;
  display: grid;
  gap: 8px;
}

.layer-toggle {
  width: 54px;
  height: 54px;
  flex-direction: column;
  gap: 3px;
  border-radius: 8px;
  color: var(--muted);
}

.layer-toggle span {
  font-size: 11px;
  line-height: 1;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  max-height: min(58vh, 520px);
  min-height: 210px;
  display: flex;
  flex-direction: column;
  padding: 8px 14px max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: var(--panel-strong);
  box-shadow: 0 -18px 48px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(20px);
  transition: transform 180ms ease;
}

.sheet.collapsed {
  transform: translateY(calc(100% - 76px));
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 0 auto 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.3);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.18;
  letter-spacing: 0;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  margin: 14px 0 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.search-row svg {
  flex: 0 0 auto;
  color: var(--muted);
}

.search-row input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.search-row input::placeholder {
  color: rgba(235, 239, 227, 0.5);
}

.detail-card {
  min-height: 64px;
  margin-bottom: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.detail-card h2 {
  margin: 0 0 6px;
  font-size: 16px;
  line-height: 1.2;
}

.detail-card p,
.entity-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.meta-pill {
  padding: 4px 7px;
  border-radius: 999px;
  color: #0a1511;
  background: rgba(228, 238, 207, 0.86);
  font-size: 11px;
  font-weight: 700;
}

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

.entity-list {
  display: grid;
  gap: 8px;
  padding-bottom: 4px;
  overflow: auto;
}

.entity-item {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, 0.06);
}

.entity-item strong {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
}

.entity-kind {
  padding: 4px 7px;
  border-radius: 999px;
  color: #102018;
  background: var(--gold);
  font-size: 11px;
  font-weight: 750;
}

.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right {
  bottom: calc(210px + env(safe-area-inset-bottom));
}

@media (min-width: 780px) {
  .topbar {
    left: 20px;
    right: 20px;
  }

  .modebar {
    top: auto;
    right: auto;
    bottom: 24px;
    left: 50%;
    width: 360px;
    transform: translateX(-50%);
  }

  .layer-panel {
    top: 92px;
    right: 20px;
  }

  .sheet {
    top: 92px;
    left: 20px;
    right: auto;
    bottom: 24px;
    width: 360px;
    max-height: none;
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .sheet.collapsed {
    transform: translateX(calc(-100% - 24px));
  }

  .maplibregl-ctrl-bottom-left,
  .maplibregl-ctrl-bottom-right {
    bottom: 20px;
  }
}
