:root {
  --forest-deep: #0f2922;
  --forest-accent: #14532d;
  --forest-tint: #f0fdf4;
  --forest-border: #bbf7d0;
  --bg-surface: #ffffff;
  --bg-muted: #f8fafc;
  --ink-primary: #0f172a;
  --ink-secondary: #475569;
  --ink-muted: #64748b;
  --line-subtle: rgba(15, 23, 42, 0.1);
  --shadow-float: 0 10px 28px rgba(15, 41, 34, 0.14), 0 2px 6px rgba(15, 41, 34, 0.08);
  --shadow-sheet: 0 -12px 36px rgba(15, 41, 34, 0.2);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --walker-blue: #1d4ed8;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-muted);
  color: var(--ink-primary);
  font-family: "Noto Sans Georgian", -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.hidden {
  display: none !important;
}

/* Top Compact Bar */
.top-bar {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 12px;
  right: 12px;
  max-width: 540px;
  margin: 0 auto;
  z-index: 500;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-float);
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.brand-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-badge {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--forest-deep);
  color: #ecfdf5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink-primary);
  line-height: 1.2;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  line-height: 1.2;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.count-pill {
  font-size: 11px;
  font-weight: 700;
  color: var(--forest-accent);
  background: var(--forest-tint);
  border: 1px solid var(--forest-border);
  border-radius: 999px;
  padding: 4px 8px;
  white-space: nowrap;
}

.nearest-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: 999px;
  background: var(--forest-deep);
  color: #ffffff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.nearest-btn:active {
  transform: scale(0.97);
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 11px;
  font-size: 16px;
  color: var(--ink-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  color: var(--ink-primary);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 34px 8px 34px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

#search-input::placeholder {
  color: var(--ink-muted);
}

#search-input:focus {
  background: #ffffff;
  border-color: var(--forest-accent);
}

.search-clear {
  position: absolute;
  right: 6px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}

.search-results {
  max-height: 240px;
  overflow-y: auto;
  border-top: 1px solid var(--line-subtle);
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-item {
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 9px 10px;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.search-item:hover,
.search-item:active {
  background: var(--forest-tint);
}

.search-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.search-item-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-primary);
}

.search-item-sub {
  font-size: 12px;
  color: var(--ink-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item-era {
  font-size: 11px;
  font-weight: 700;
  color: var(--forest-accent);
  white-space: nowrap;
}

/* Right-Side Floating Map Controls */
.map-controls {
  position: absolute;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 28px);
  z-index: 450;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-ctrl-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line-subtle);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink-primary);
  box-shadow: var(--shadow-float);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.map-ctrl-btn:active {
  transform: scale(0.95);
}

.gps-btn {
  background: var(--forest-deep);
  color: #ffffff;
  border-color: var(--forest-deep);
}

.gps-btn.active {
  background: var(--walker-blue);
  border-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.28), var(--shadow-float);
}

/* Floating GPS Activation Prompt */
.gps-prompt {
  position: absolute;
  left: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 28px);
  z-index: 450;
  border: 0;
  border-radius: 999px;
  background: var(--walker-blue);
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 11px 15px;
  box-shadow: var(--shadow-float);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  max-width: calc(100vw - 82px);
}

.gps-prompt:active {
  transform: scale(0.97);
}

/* Nearby Landmark Proximity Bar */
.nearby-bar {
  position: absolute;
  left: 12px;
  right: 68px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 28px);
  max-width: 460px;
  z-index: 460;
  border: 1px solid var(--forest-border);
  border-radius: 16px;
  background: var(--forest-deep);
  color: #ffffff;
  font-family: inherit;
  padding: 11px 14px;
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
}

.nearby-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.nearby-kicker {
  font-size: 11px;
  font-weight: 700;
  color: #a7f3d0;
}

.nearby-title {
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nearby-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #ecfdf5;
  color: var(--forest-deep);
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 3-Tier Heritage Map Markers */
.leaflet-marker-icon.history-marker-wrap,
.leaflet-marker-icon.walker-marker-wrap {
  background: transparent;
  border: 0;
}

/* Tier 1 (zoom >= 16 or selected): full action pill */
.history-pill {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  transform: translate(-50%, -100%);
  background: #ffffff;
  border: 2px solid var(--forest-deep);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(15, 41, 34, 0.24);
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.history-pill:active {
  transform: translate(-50%, -100%) scale(0.96);
}

.history-pill.selected {
  border-color: var(--forest-accent);
  box-shadow: 0 0 0 3px rgba(20, 83, 45, 0.28), 0 10px 24px rgba(15, 41, 34, 0.28);
}

.history-pill-head {
  width: 100%;
  background: var(--forest-deep);
  color: #ecfdf5;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.01em;
  padding: 3px 9px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.history-pill-label {
  padding: 4px 9px 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-pill-dist {
  font-size: 11px;
  font-weight: 700;
  color: var(--forest-accent);
}

/* Tier 2 (zoom 14–15): compact heritage label pill */
.history-compact-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transform: translate(-50%, -100%);
  background: var(--forest-deep);
  color: #ffffff;
  border: 1.5px solid #ffffff;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(15, 41, 34, 0.28);
  cursor: pointer;
}

.history-compact-pill i {
  font-size: 12px;
  color: #a7f3d0;
}

/* Tier 3 (zoom <= 13): circular dot pin */
.history-dot-pin {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--forest-deep);
  color: #ecfdf5;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 12px rgba(15, 41, 34, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transform: translate(-50%, -50%);
}

/* Live Walker ("კაცუნა") Avatar */
.walker-pin {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.walker-halo {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.walker-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 999px;
  background: rgba(29, 78, 216, 0.24);
  animation: walkerPulse 2s ease-out infinite;
}

.walker-heading {
  position: absolute;
  top: -12px;
  left: 50%;
  width: 0;
  height: 0;
  margin-left: -8px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 12px solid rgba(29, 78, 216, 0.72);
  transform-origin: 8px 30px;
}

.walker-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--walker-blue);
  color: #ffffff;
  border: 3px solid #ffffff;
  box-shadow: 0 4px 14px rgba(29, 78, 216, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
}

.walker-label {
  margin-top: 3px;
  background: var(--ink-primary);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.28);
  white-space: nowrap;
}

@keyframes walkerPulse {
  0% {
    transform: scale(0.92);
    opacity: 0.85;
  }
  70% {
    transform: scale(1.55);
    opacity: 0;
  }
  100% {
    transform: scale(1.55);
    opacity: 0;
  }
}

/* Toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 92px);
  transform: translateX(-50%);
  z-index: 550;
  background: var(--forest-deep);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 15px;
  border-radius: 999px;
  box-shadow: var(--shadow-float);
  max-width: calc(100vw - 32px);
  text-align: center;
}

/* Backdrop & Bottom Reading Sheet */
.sheet-backdrop {
  position: absolute;
  inset: 0;
  z-index: 600;
  background: rgba(15, 23, 42, 0.36);
  opacity: 1;
  transition: opacity 0.22s ease;
}

.reading-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 680px;
  margin: 0 auto;
  height: 85dvh;
  max-height: 85dvh;
  z-index: 700;
  background: var(--bg-surface);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  box-shadow: var(--shadow-sheet);
  display: flex;
  flex-direction: column;
  transform: translateY(105%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.reading-sheet.open {
  transform: translateY(0);
}

.sheet-handle-area {
  padding: 10px 0 4px;
  display: flex;
  justify-content: center;
  cursor: grab;
  flex-shrink: 0;
}

.sheet-handle {
  width: 40px;
  height: 5px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.18);
}

.sheet-sticky-head {
  padding: 4px 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line-subtle);
  flex-shrink: 0;
}

.sheet-meta-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.era-pill {
  font-size: 12px;
  font-weight: 700;
  color: #ecfdf5;
  background: var(--forest-deep);
  border-radius: 999px;
  padding: 4px 11px;
}

.distance-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--walker-blue);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 4px 10px;
}

.close-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--ink-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.sheet-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 20px 26px;
}

.sheet-title {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.24;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
}

.sheet-toponym {
  margin: 0 0 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--forest-accent);
  line-height: 1.45;
}

.story-prose {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

.story-prose p {
  margin: 0;
  font-size: 18px;
  line-height: 1.72;
  color: var(--ink-primary);
}

.section-heading {
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 800;
  color: var(--forest-deep);
}

.facts-section {
  margin-bottom: 24px;
}

.facts-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fact-card {
  background: var(--forest-tint);
  border-left: 4px solid var(--forest-accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 16px;
}

.fact-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 800;
  color: var(--forest-deep);
  line-height: 1.38;
}

.fact-body {
  margin: 0;
  font-size: 17px;
  line-height: 1.68;
  color: var(--ink-primary);
}

.sources-section {
  padding-top: 16px;
  border-top: 1px solid var(--line-subtle);
}

.sources-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.source-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-subtle);
  background: var(--bg-muted);
  color: var(--forest-deep);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.source-link:active {
  background: var(--forest-tint);
}

.sheet-footer {
  padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
  border-top: 1px solid var(--line-subtle);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.nav-pair {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-step-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line-subtle);
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--ink-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 14px;
  cursor: pointer;
}

.nav-step-btn:active {
  transform: scale(0.97);
}

.walk-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  background: var(--forest-deep);
  color: #ffffff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 16px;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .walker-pulse {
    animation: none;
  }
  .reading-sheet,
  .sheet-backdrop,
  .history-pill,
  .nearest-btn,
  .map-ctrl-btn {
    transition: none;
  }
}
