:root {
  --bg: #0d1410;
  --bg-elev: #131c17;
  --surface: rgba(20, 30, 24, 0.78);
  --surface-strong: rgba(15, 22, 18, 0.92);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --moss: #5fb585;
  --moss-deep: #2f6e4a;
  --rust: #d97757;
  --bone: #f1ede2;
  --text: #ecf0ec;
  --text-dim: #a0aaa3;
  --text-faint: #6b756f;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.3);
  --radius: 16px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.maplibregl-ctrl-attrib {
  background: rgba(13, 20, 16, 0.7) !important;
  color: var(--text-faint) !important;
  font-size: 10px !important;
}
.maplibregl-ctrl-attrib a { color: var(--text-dim) !important; }

/* ── Top bar ────────────────────────────────── */
.topbar {
  position: fixed;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-strong);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--border);
  padding: 12px 18px 12px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background:
    radial-gradient(circle at 30% 30%, var(--moss) 0%, var(--moss-deep) 70%);
  position: relative;
  flex: none;
}
.mark::after {
  content: '';
  position: absolute;
  inset: 7px;
  background: radial-gradient(circle, rgba(255,255,255,0.25) 0%, transparent 60%);
  border-radius: 50%;
}

.brand-text h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-text .sub {
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stats {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.stat {
  background: var(--surface-strong);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
  box-shadow: var(--shadow);
}
.stat b {
  font-size: 16px;
  font-weight: 600;
  color: var(--moss);
  font-variant-numeric: tabular-nums;
}
.stat em {
  font-size: 10px;
  font-style: normal;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ── Chat panel ─────────────────────────────── */
.panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 380px;
  max-height: calc(100vh - 120px);
  background: var(--surface-strong);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  z-index: 10;
  overflow: hidden;
}

.panel-header {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.panel-header h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}
.panel-header p {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-faint);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  max-width: 100%;
}
.msg.user { justify-content: flex-end; }

.bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  max-width: 85%;
  word-wrap: break-word;
}
.msg.assistant .bubble {
  background: rgba(95, 181, 133, 0.08);
  border: 1px solid rgba(95, 181, 133, 0.18);
  color: var(--text);
}
.msg.user .bubble {
  background: var(--moss-deep);
  color: var(--bone);
}
.msg.assistant.thinking .bubble {
  color: var(--text-dim);
  font-style: italic;
}

.composer {
  display: flex;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: rgba(10, 16, 12, 0.4);
}
.composer input {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.composer input:focus {
  border-color: var(--moss);
  background: rgba(95, 181, 133, 0.05);
}
.composer input::placeholder { color: var(--text-faint); }

.composer button {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: var(--moss);
  color: var(--bg);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.composer button:hover { background: #6dc193; }
.composer button:active { transform: scale(0.96); }
.composer button:disabled { background: var(--text-faint); cursor: not-allowed; }

/* ── Loader ─────────────────────────────────── */
.loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: grid;
  place-items: center;
  z-index: 100;
  transition: opacity 0.5s ease, visibility 0.5s;
}
.loader.hidden { opacity: 0; visibility: hidden; }
.loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 0.04em;
}
.pulse {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--moss) 0%, var(--moss-deep) 70%);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
}

/* ── Mobile ────────────────────────────────── */
@media (max-width: 640px) {
  .topbar { top: 12px; left: 12px; right: 12px; flex-direction: column; gap: 8px; align-items: stretch; }
  .stats { justify-content: stretch; }
  .stat { flex: 1; }
  .panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 50vh;
  }
}
