:root {
  --bg: #12141a;
  --surface: #1b1e27;
  --surface-2: #242833;
  --text: #eef0f4;
  --text-dim: #9aa1b0;
  --accent: #e0663e;
  --accent-2: #4e8cff;
  --border: #2e3340;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #0d1117;
}

/* --- Top bar: home button + day chips --- */

#topbar {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  left: 10px;
  right: 10px;
  z-index: 500;
  display: flex;
  gap: 8px;
  align-items: center;
}

#homeBtn, #infoBtn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}

#dayChips {
  flex: 1 1 auto;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}
#dayChips::-webkit-scrollbar { display: none; }

.day-chip {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}

.day-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* --- Day info banner --- */

#dayInfo {
  position: absolute;
  top: calc(var(--safe-top) + 62px);
  left: 10px;
  right: 10px;
  z-index: 480;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}

#dayLabel {
  font-weight: 700;
  font-size: 14px;
}

#dayTip {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
  line-height: 1.35;
}

/* --- Carousel of day stops --- */

#carousel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + 10px);
  z-index: 480;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 0 10px;
  scroll-snap-type: x proximity;
}
#carousel::-webkit-scrollbar { display: none; }

.stop-card {
  scroll-snap-align: start;
  flex: 0 0 auto;
  width: 168px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}

.stop-card .num {
  display: inline-flex;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
}

.stop-card .time {
  float: right;
  font-size: 11px;
  color: var(--text-dim);
}

.stop-card .name {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}

/* --- Leaflet marker override --- */

.poi-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.poi-marker span {
  transform: rotate(45deg);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.home-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-2);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
  font-size: 17px;
}

/* --- Bottom sheet --- */

#sheetBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
#sheetBackdrop.open {
  opacity: 1;
  pointer-events: auto;
}

#sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 950;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  max-height: 82vh;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.32,.72,0,1);
  padding-bottom: calc(var(--safe-bottom) + 16px);
  overflow-y: auto;
  box-shadow: 0 -6px 30px rgba(0,0,0,.5);
}
#sheet.open {
  transform: translateY(0);
}

#sheetHandle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 10px auto 4px;
}

#sheetClose {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.35);
  color: #fff;
  font-size: 15px;
  z-index: 2;
}

#sheetImageWrap {
  position: relative;
  width: 100%;
  height: 190px;
  background: linear-gradient(135deg, var(--surface-2), var(--bg));
  border-radius: 14px 14px 0 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}

#sheetImage {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}

#sheetBody {
  padding: 14px 18px 4px;
}

#sheetMeta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}
#sheetOrder {
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 2px 8px;
}

#sheetName {
  margin: 8px 0 4px;
  font-size: 20px;
  line-height: 1.2;
}

#sheetPrice {
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 8px;
}

#sheetNote {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
  margin: 0 0 16px;
}

#sheetLinks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.link-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 4px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}
.link-btn .icon { font-size: 20px; }
.link-btn.disabled {
  opacity: .35;
  pointer-events: none;
}

@media (min-width: 640px) {
  #sheet {
    left: auto;
    right: 16px;
    bottom: 16px;
    width: 380px;
    border-radius: 20px;
    max-height: calc(100vh - 32px);
  }
  #carousel { padding: 0 16px; }
}

.travel-day-card {
  width: auto;
  max-width: 260px;
  display: flex;
  align-items: center;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.4;
}

/* --- Sheet prev/next nav arrows --- */

.sheet-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.35);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sheet-nav:active { background: rgba(0,0,0,.55); }
#sheetPrev { left: 10px; }
#sheetNext.sheet-nav-right { right: 10px; }

/* --- Info panel --- */

#infoPanel {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: var(--bg);
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.32,.72,0,1);
  padding: calc(var(--safe-top) + 20px) 20px calc(var(--safe-bottom) + 40px);
}
#infoPanel.open {
  transform: translateY(0);
}

#infoPanelInner {
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

#infoClose {
  position: absolute;
  top: 0;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
}

#infoPanelInner h1 {
  font-size: 22px;
  margin: 0 0 20px;
}

#infoPanelInner h2 {
  font-size: 15px;
  margin: 28px 0 10px;
}

#infoPanelInner p,
#infoPanelInner li {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-dim);
}

#infoPanelInner ul {
  margin: 0;
  padding-left: 20px;
}

#infoPanelInner li {
  margin-bottom: 8px;
}

#infoPanelInner li strong {
  color: var(--text);
}

.info-link {
  width: auto;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  margin: 6px 0 4px;
}

/* --- Password lock overlay --- */

#lockOverlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#lockOverlay.hidden {
  display: none;
}

#lockForm {
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}

#lockForm h1 {
  font-size: 22px;
  margin: 0 0 6px;
}

#lockForm p {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 18px;
}

#lockInput {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 12px;
}

#lockForm button {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

#lockError {
  min-height: 18px;
  font-size: 12px;
  color: #ff6b6b;
  margin-top: 10px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #eef0f3;
    --text: #1a1c22;
    --text-dim: #666d7d;
    --border: #e1e4ea;
  }
}
