:root {
  --bg: #f8fafa;
  --surface: rgba(248, 250, 250, 0.97);
  --text: #1a2e2e;
  --muted: #5f7398;
  --accent: #1f6fff;
  --accent-strong: #184fbe;
  --border: rgba(0, 0, 0, 0.06);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-strong: 0 8px 24px rgba(0, 0, 0, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --sheet-peek: 112px;
  --sheet-half: 55dvh;
  --sheet-full: 85dvh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  border: none;
  cursor: pointer;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
  --sheet-current-height: var(--sheet-peek);
}

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

.top-panel {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: 12px;
  right: 12px;
  z-index: 1300;
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.top-panel > * {
  pointer-events: auto;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
}

.brand-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.brand-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.brand-pill h1 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.fountain-count {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  background: #edf3ff;
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  padding: 0;
  min-height: unset;
}

.lang-btn {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.lang-btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.search-overlay {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: 12px;
  right: 12px;
  z-index: 1300;
  animation: fadeSlideDown 0.2s ease-out;
}

.search-overlay[hidden] {
  display: none;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 14px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
  border: 2px solid var(--accent);
}

.search-bar input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: 16px;
  color: var(--text);
  min-height: 2.2rem;
  padding: 0;
}

@keyframes fadeSlideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.results-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1200;
  height: var(--sheet-current-height);
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.08);
  transition: height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.results-sheet.is-dragging {
  transition: none;
}

.sheet-handle {
  padding: 12px 0 8px;
  display: flex;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: none;
}

.sheet-handle-bar {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #c8d8d0;
}

.sheet-header {
  padding: 0 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  touch-action: none;
}

.sheet-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.sheet-subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.sheet-chevron {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: #f0f4f2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  padding: 0;
  min-height: unset;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.results-sheet[data-sheet-state="full"] .sheet-chevron {
  transform: rotate(180deg);
}

.fountain-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 24px;
  margin: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.fountain-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  animation: slideUp 0.3s ease-out backwards;
}

.fountain-item:hover,
.fountain-item.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(31, 111, 255, 0.24);
  transform: scale(1.01);
}

.fountain-item:hover *,
.fountain-item.is-selected * {
  color: #fff !important;
}

.fountain-item:nth-child(1) {
  animation-delay: 0s;
}

.fountain-item:nth-child(2) {
  animation-delay: 0.06s;
}

.fountain-item:nth-child(3) {
  animation-delay: 0.12s;
}

.fountain-item:nth-child(4) {
  animation-delay: 0.18s;
}

.fountain-item:nth-child(5) {
  animation-delay: 0.24s;
}

.fountain-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #edf3ff;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fountain-info {
  flex: 1;
  min-width: 0;
}

.fountain-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fountain-details {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.fountain-details .separator {
  opacity: 0.4;
}

.fountain-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  padding: 0;
  min-height: unset;
}

.donation-banner {
  margin: 0 16px 16px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.donation-banner[hidden] {
  display: none !important;
}

.donation-text {
  margin: 0;
  font-size: 0.77rem;
  line-height: 1.3;
  color: var(--text);
}

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

.donation-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  background: var(--accent-strong);
  color: #fff;
}

.donation-dismiss {
  border-radius: 999px;
  padding: 6px 10px;
  background: #e8efe5;
  color: #284126;
  font-size: 0.74rem;
}

.locate-fab {
  position: absolute;
  right: 12px;
  bottom: calc(var(--sheet-current-height) + 16px);
  z-index: 1100;
  width: 50px;
  height: 50px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  padding: 0;
  min-height: unset;
  transition: bottom 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fountain-marker {
  background: none !important;
  border: none !important;
}

.fountain-marker-body {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--accent);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.fountain-marker-tail {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #fff;
  margin: -1px auto 0;
}

.fountain-marker.is-active .fountain-marker-body {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.fountain-marker.is-active .fountain-marker-body svg {
  fill: #fff;
}

.fountain-marker.is-active .fountain-marker-tail {
  border-top-color: var(--accent);
}

.user-marker {
  background: none !important;
  border: none !important;
}

.user-marker-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(31, 111, 255, 0.35);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.user-marker-pulse {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(31, 111, 255, 0.18);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: userPulse 2s ease-in-out infinite;
}

@keyframes userPulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.6;
  }

  50% {
    transform: translate(-50%, -50%) scale(1.6);
    opacity: 0;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.leaflet-popup-content {
  line-height: 1.35;
}

.leaflet-top,
.leaflet-bottom {
  z-index: 700;
}

.seo-city-content {
  padding: 20px 14px calc(24px + var(--safe-bottom));
  background: #f6f9fb;
}

.seo-city-content-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.seo-city-content h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.seo-city-content p {
  margin: 0 0 8px;
  color: #3f4d6f;
  font-size: 0.94rem;
  line-height: 1.35;
}

.seo-fountain-list {
  margin: 10px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.seo-fountain-list li {
  color: #1f2d3d;
  font-size: 0.93rem;
  line-height: 1.35;
}

.seo-fountain-meta {
  color: #516181;
  margin-left: 4px;
}

.seo-fountain-extra {
  display: block;
  color: #6b7a95;
}

@media (max-width: 420px) {
  .brand-pill h1 {
    font-size: 0.86rem;
  }

  .fountain-count {
    display: none;
  }

  .donation-banner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 979px) {
  .leaflet-control-container .leaflet-top {
    top: calc(var(--safe-top) + 92px);
  }
}

@media (min-width: 980px) {
  .app-shell {
    --desktop-panel-width: clamp(360px, 32vw, 430px);
    display: grid;
    grid-template-columns: var(--desktop-panel-width) 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    background: #f7f9fc;
  }

  .map {
    position: relative;
    grid-column: 2;
    grid-row: 1 / span 2;
    z-index: 1;
  }

  .top-panel {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    grid-column: 1;
    grid-row: 1;
    padding: 14px 12px 10px;
    z-index: 4;
    background: #f7f9fc;
    border-right: 1px solid var(--border);
    pointer-events: auto;
  }

  .brand-pill,
  .icon-btn {
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: var(--shadow);
  }

  .search-overlay {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    grid-column: 1;
    grid-row: 1;
    margin: 74px 12px 0;
    width: auto;
    z-index: 5;
  }

  .results-sheet {
    position: relative;
    grid-column: 1;
    grid-row: 2;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100% !important;
    max-height: none;
    border-radius: 0;
    border-top: 1px solid var(--border);
    border-right: 1px solid var(--border);
    box-shadow: none;
    background: #fff;
    transition: none;
  }

  .sheet-handle,
  .sheet-chevron {
    display: none;
  }

  .sheet-header {
    padding: 12px 16px 10px;
  }

  .fountain-list {
    padding: 0 12px 16px;
    min-height: 0;
  }

  .donation-banner {
    margin: 0 12px 12px;
  }

  .locate-fab {
    right: 24px;
    bottom: 24px !important;
  }

  .leaflet-control-container .leaflet-top {
    top: 12px;
  }

  .seo-city-content {
    margin-left: var(--desktop-panel-width);
    padding: 28px 24px 44px;
    background: #f7f9fc;
  }
}
