:root {
  --sea-deep: #0e5f68;
  --sea: #0e7c86;
  --sea-light: #2db2b4;
  --sand: #f2e2c4;
  --sand-dark: #e8c99b;
  --terracotta: #d1653b;
  --terracotta-dark: #b3502b;
  --ink: #1c2b2e;
  --ink-soft: #4a5c5f;
  --card-bg: #ffffff;
  --page-bg: #f6f1e6;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(14, 60, 66, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: 72px; /* space for bottom nav */
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, var(--sea-deep), var(--sea));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}

.app-header .back-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 1.05rem;
  margin: 0;
  font-weight: 600;
  line-height: 1.25;
}

.app-header .subtitle {
  font-size: 0.72rem;
  opacity: 0.85;
  margin-top: 1px;
}

.offline-pill {
  margin-left: auto;
  font-size: 0.65rem;
  background: rgba(255,255,255,0.18);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

main {
  padding: 14px 14px 20px;
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- Map (Leaflet) ---------- */
.map-wrap {
  background: #bfe3e6;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  position: relative;
}

#leaflet-map {
  width: 100%;
  height: 430px;
  background: #bfe3e6;
}

.leaflet-pin { background: transparent; border: none; }
.pin-dot {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(45deg);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.pin-dot { color: #fff; text-align: center; }
.pin-dot > span { display: inline-block; transform: rotate(-45deg); }

.leaflet-container { font-family: inherit; }
.leaflet-tooltip {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

/* ---------- Map popup (balloon) ---------- */
.leaflet-popup.place-popup .leaflet-popup-content-wrapper {
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0,0,0,0.25);
}
.leaflet-popup.place-popup .leaflet-popup-content {
  margin: 0;
  width: 100% !important;
}
.leaflet-popup.place-popup .leaflet-popup-tip-container { margin-top: -1px; }

.map-popup { width: 100%; padding: 8px; box-sizing: border-box; }

.popup-top {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.popup-carousel {
  position: relative;
  width: 84px;
  height: 84px;
  flex-shrink: 0;
  background: #ddd;
  overflow: hidden;
  border-radius: 10px;
}
.popup-carousel-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}
.popup-slides { position: relative; width: 100%; height: 100%; touch-action: pan-y; }
.popup-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.popup-slide.active { opacity: 1; }

.popup-dots {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 4px;
}
.popup-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.55);
  cursor: pointer;
}
.popup-dot.active { background: #fff; }

.popup-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.35);
  color: #fff;
  border: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.popup-nav.prev { left: 3px; }
.popup-nav.next { right: 3px; }

.popup-body { flex: 1; min-width: 0; padding-top: 1px; }
.popup-cat { font-size: 0.63rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.popup-title {
  font-size: 0.86rem;
  margin: 2px 0 3px;
  cursor: pointer;
  color: var(--ink);
  line-height: 1.2;
}
.popup-resum {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.popup-btn {
  width: 100%;
  margin-top: 8px;
  background: var(--terracotta);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- Detail page photo carousel ---------- */
.detail-carousel {
  position: relative;
  height: 220px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  background: #ddd;
}
.detail-slides { position: relative; width: 100%; height: 100%; touch-action: pan-y; }
.detail-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.detail-slide.active { opacity: 1; }

.detail-dots {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
}
.detail-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.6);
  cursor: pointer;
}
.detail-dot.active { background: #fff; }

.detail-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.35);
  color: #fff;
  border: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-nav.prev { left: 8px; }
.detail-nav.next { right: 8px; }

.detail-credit {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 0.62rem;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 10px 12px 12px;
  background: rgba(255,255,255,0.65);
  font-size: 0.7rem;
}
.map-legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- Offline map download ---------- */
.offline-map-download {
  padding: 10px 12px 12px;
  background: rgba(255,255,255,0.65);
  border-top: 1px solid rgba(0,0,0,0.06);
}
.offline-map-download .btn {
  width: 100%;
  padding: 9px 10px;
  font-size: 0.78rem;
}
.dl-progress-wrap { margin-top: 8px; }
.dl-progress-bar {
  height: 6px;
  border-radius: 999px;
  background: #e3d6b3;
  overflow: hidden;
}
.dl-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--sea);
  transition: width 0.15s ease;
}
.dl-progress-text {
  font-size: 0.7rem;
  color: var(--ink-soft);
  margin-top: 4px;
}
.offline-map-note {
  font-size: 0.7rem;
  color: var(--sea-deep);
  margin-top: 8px;
  font-weight: 600;
}

/* ---------- Section headers ---------- */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 18px 0 10px;
  color: var(--sea-deep);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title a.see-all {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--terracotta);
}

/* ---------- Chips / filters ---------- */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 4px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  background: #fff;
  border: 1px solid #ddd0b3;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 5px;
}
.chip.active {
  background: var(--sea);
  border-color: var(--sea);
  color: #fff;
}

/* ---------- Cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (min-width: 480px) {
  .card-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.place-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.place-card .thumb {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  overflow: hidden;
  position: relative;
}
.place-card .info { padding: 8px 10px 12px; }
.place-card .zone { font-size: 0.68rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }
.place-card .name { font-size: 0.86rem; font-weight: 600; margin-top: 2px; line-height: 1.2; }
.place-card .stars-mini { font-size: 0.7rem; color: var(--terracotta); margin-top: 4px; min-height: 14px; }

.list-row {
  display: flex;
  gap: 12px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  margin-bottom: 10px;
  cursor: pointer;
  align-items: center;
}
.list-row .thumb {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.list-row .body { flex: 1; min-width: 0; }
.list-row .name { font-weight: 600; font-size: 0.9rem; }
.list-row .zone { font-size: 0.72rem; color: var(--ink-soft); }
.list-row .chevron { color: var(--ink-soft); font-size: 1.1rem; }

/* ---------- Itinerary cards ---------- */
.itin-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
  cursor: pointer;
}
.itin-card .itin-name { font-weight: 700; font-size: 0.98rem; color: var(--sea-deep); }
.itin-card .itin-desc { font-size: 0.82rem; color: var(--ink-soft); margin-top: 4px; }
.itin-card .itin-meta { margin-top: 8px; font-size: 0.72rem; color: var(--terracotta); font-weight: 600; }

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  background: #ece0c4;
  border-radius: 999px;
  padding: 4px;
}
.tabs button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 4px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.tabs button.active {
  background: var(--sea);
  color: #fff;
}

/* ---------- Detail pages ---------- */
.detail-hero {
  border-radius: var(--radius);
  padding: 26px 18px;
  color: #fff;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.detail-hero .zone-tag {
  font-size: 0.72rem;
  background: rgba(255,255,255,0.22);
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.detail-hero h2 { margin: 0; font-size: 1.3rem; }
.detail-hero .durada { font-size: 0.8rem; opacity: 0.9; margin-top: 6px; }

.detail-block {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.detail-block h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--sea);
  margin: 0 0 6px;
}
.detail-block p { margin: 0; font-size: 0.9rem; line-height: 1.45; }

.action-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.btn {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 12px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}
.btn-primary { background: var(--terracotta); color: #fff; }
.btn-secondary { background: #fff; color: var(--sea-deep); box-shadow: var(--shadow); }

/* ---------- Rating ---------- */
.rating-block .stars {
  font-size: 1.6rem;
  letter-spacing: 4px;
  cursor: pointer;
  user-select: none;
}
.rating-block .star { color: #d9cfae; }
.rating-block .star.filled { color: var(--terracotta); }
.rating-block textarea {
  width: 100%;
  margin-top: 10px;
  border: 1px solid #ddd0b3;
  border-radius: 10px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  resize: vertical;
  min-height: 60px;
}
.rating-block .done-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.85rem;
}
.rating-block .save-msg {
  font-size: 0.75rem;
  color: var(--sea);
  margin-top: 8px;
  min-height: 1em;
}

/* ---------- Itinerary detail stops ---------- */
.stop-row {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
}
.stop-row .time-col {
  width: 46px;
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--sea);
  padding-top: 12px;
  text-align: right;
}
.stop-row .line-col {
  width: 16px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stop-row .line-col .dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--sea);
  margin-top: 10px;
  flex-shrink: 0;
}
.stop-row .line-col .line {
  width: 2px;
  flex: 1;
  background: #ddd0b3;
}
.stop-row:last-child .line-col .line { display: none; }
.stop-row .stop-card {
  flex: 1;
  margin-bottom: 14px;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  background: #fff;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  display: flex;
  max-width: 640px;
  margin: 0 auto;
}
.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 9px 4px 8px;
  font-size: 0.68rem;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.bottom-nav a.active { color: var(--sea); font-weight: 700; }
.bottom-nav .nav-icon { font-size: 1.15rem; }

.empty-state {
  text-align: center;
  padding: 30px 10px;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.install-banner {
  display: none;
  background: var(--sand-dark);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 0.8rem;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}
.install-banner.show { display: flex; }
.install-banner button {
  background: var(--sea);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  margin-left: auto;
}
.install-banner .dismiss {
  background: transparent;
  color: var(--ink-soft);
  font-size: 1rem;
  padding: 0 4px;
  margin-left: 6px;
}
