:root {
  --bg: #f8f9fa;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --ink: #212529;
  --muted: #6c757d;
  --accent: #0d6efd;
  --accent-ink: #ffffff;
  --accent-2: #fd7e14;
  --danger: #dc3545;
  --line: #dee2e6;
  --shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
  --radius: 0.5rem;
  --tab-h: 56px;
  --top-h: 56px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: #e9ecef;
  -webkit-font-smoothing: antialiased;
}

/* Full-viewport shell — avoids short map on mobile browsers */
#app {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  left: 0;
  right: 0;
  display: grid;
  grid-template-rows: var(--top-h) minmax(0, 1fr) calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: var(--top-h);
  background: #fff;
  border-bottom: 1px solid var(--line);
  z-index: 40;
}
.brand { display: flex; gap: 0.65rem; align-items: center; }
.brand-mark {
  width: 1.75rem; height: 1.75rem; border-radius: 0.375rem;
  background: linear-gradient(135deg, #0d6efd, #20c997);
}
.brand-name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: block;
  line-height: 1.1;
  color: var(--ink);
}
.brand-city { color: var(--muted); font-size: 0.75rem; }

.icon-btn {
  width: 2.25rem; height: 2.25rem;
  border-radius: 0.375rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

.views {
  position: relative;
  min-height: 0;
  overflow: hidden;
}
.view {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.view[hidden] { display: none !important; }

.map-shell,
#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#map {
  z-index: 1;
  background: #ced4da;
}

.radius-chip {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: #fff;
  border: 1px solid var(--line);
  padding: 0.3rem 0.75rem;
  border-radius: 50rem;
  font-size: 0.75rem;
  color: var(--muted);
  box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
}

.cat-chips {
  position: absolute;
  left: 0; right: 0;
  bottom: 0.75rem;
  z-index: 30;
  display: flex;
  gap: 0.4rem;
  padding: 0 0.75rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.cat-chips::-webkit-scrollbar { display: none; }
.cat-chips.static {
  position: static;
  padding: 0 0 0.75rem;
}

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 50rem;
  padding: 0.4rem 0.8rem;
  font: 500 0.8rem var(--font-body);
  cursor: pointer;
  box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.06);
}
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.chip-ico { font-size: 0.9rem; line-height: 1; }

/* Bootstrap-like bottom nav */
.tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: stretch;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 50;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  margin: 0;
  padding: 0.35rem 0.25rem;
  border: 0;
  border-top: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #6c757d;
  font: 400 0.7rem/1.2 var(--font-body);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tab .bi {
  font-size: 1.25rem;
  line-height: 1;
}
.tab:hover { color: #495057; }
.tab.active {
  color: var(--accent);
  border-top-color: var(--accent);
  font-weight: 600;
  background: transparent;
}

.panel-scroll {
  height: 100%;
  overflow: auto;
  padding: 1rem;
  background: var(--bg);
}
.panel-head h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0 0 0.15rem;
  letter-spacing: -0.02em;
}
.panel-head .muted { margin: 0 0 0.85rem; }

.card-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.place-card {
  border: 1px solid var(--line);
  padding: 0;
  text-align: left;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  color: inherit;
  box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.05);
  width: 100%;
  font: inherit;
}
.place-card-media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #e9ecef;
  overflow: hidden;
}
.place-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.place-card-badge {
  position: absolute;
  left: 0.65rem;
  bottom: 0.65rem;
  background: rgba(33, 37, 41, 0.8);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}
.place-card-play {
  position: absolute;
  right: 0.65rem;
  top: 0.65rem;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  background: rgba(13, 110, 253, 0.9);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.7rem;
}
.place-card-body { padding: 0.75rem 0.85rem 0.9rem; }
.place-card-body h3 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 600;
}
.place-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.stars { color: var(--accent-2); font-weight: 600; }

.sheet {
  border: 1px solid var(--line);
  border-radius: 0.75rem 0.75rem 0 0;
  padding: 0;
  width: min(560px, 100%);
  max-height: min(92vh, 960px);
  overflow: auto;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
  margin: auto auto 0;
}
.sheet.ficha { width: min(640px, 100%); }
.sheet::backdrop { background: rgba(33, 37, 41, 0.45); }
.sheet form, .sheet > form { padding: 1.15rem; }
.sheet h2 {
  font-family: var(--font-display);
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
}
.sheet label {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.sheet input, .sheet select, .sheet textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 0.375rem;
  padding: 0.55rem 0.75rem;
  font: 400 0.95rem var(--font-body);
}

.ficha-hero { position: relative; background: #e9ecef; }
.ficha-media-main {
  position: relative;
  aspect-ratio: 16 / 11;
  overflow: hidden;
  background: #e9ecef;
}
.ficha-media-main img,
.ficha-media-main video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ficha-media-main iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.ficha-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 5;
  width: 2rem; height: 2rem;
  border-radius: 0.375rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}
.ficha-thumbs {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  overflow-x: auto;
  background: #f8f9fa;
  border-bottom: 1px solid var(--line);
}
.ficha-thumbs button {
  flex: 0 0 auto;
  width: 4.5rem;
  height: 3.25rem;
  border-radius: 0.375rem;
  border: 2px solid transparent;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: #dee2e6;
  position: relative;
}
.ficha-thumbs button.active { border-color: var(--accent); }
.ficha-thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ficha-thumbs .thumb-video::after {
  content: "▶";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.35);
  color: #fff;
  font-size: 0.75rem;
}
.ficha-content { padding: 1rem 1.15rem 1.35rem; }
.ally-meta {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
}
.cat-pill {
  background: rgba(13, 110, 253, 0.1);
  color: var(--accent);
  padding: 0.15rem 0.5rem;
  border-radius: 0.25rem;
  font-weight: 600;
  font-size: 0.72rem;
}
.ficha-actions {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 0.5rem;
}
.review {
  border-top: 1px solid var(--line);
  padding: 0.7rem 0;
  font-size: 0.9rem;
}
.booking-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
}
.account-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 0.375rem;
  padding: 0.55rem 0.9rem;
  font: 500 0.9rem var(--font-body);
  cursor: pointer;
}
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
}
.btn.block { width: 100%; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.muted { color: var(--muted); font-size: 0.85rem; }
.error { color: var(--danger); font-size: 0.9rem; }
.ok { color: #198754; }
.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}

.leaflet-container { font: 400 12px var(--font-body); background: #ced4da; }
.leaflet-control-attribution {
  background: rgba(255,255,255,0.85) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--accent) !important; }
.leaflet-control-zoom a {
  background: #fff !important;
  color: var(--ink) !important;
  border-color: var(--line) !important;
}

.pin {
  width: 32px; height: 32px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  display: grid; place-items: center;
}
.pin span { transform: rotate(45deg); font-size: 13px; line-height: 1; }
.pin.gastronomia { background: #198754; }
.pin.alojamiento { background: #0d6efd; }
.pin.comercio { background: #fd7e14; }
.pin.transporte { background: #6f42c1; }
.user-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: #0d6efd;
  border: 2px solid #fff;
  box-shadow: 0 0 0 6px rgba(13,110,253,0.25);
}

@media (min-width: 720px) {
  #app {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
  .sheet {
    border-radius: var(--radius);
    margin: auto;
  }
}
