:root {
  --navy: #1b2a4a;
  --navy-2: #24365c;
  --ink: #1d2433;
  --muted: #6b7488;
  --line: #e6e8ef;
  --bg: #f5f6fa;
  --card: #ffffff;
  --accent: #e8623d;
  --accent-soft: #fce9e2;
  --shadow: 0 6px 20px rgba(27, 42, 74, 0.08);
  --radius: 14px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Login screen ---------- */
.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #2c4272 0%, var(--navy) 60%);
}
.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 40px 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.login-emoji { font-size: 52px; line-height: 1; }
.login-card h1 { margin: 14px 0 10px; font-size: 26px; color: var(--navy); }
.login-sub { color: var(--muted); line-height: 1.55; margin: 0 0 16px; }
.login-hint { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.login-error {
  background: var(--accent-soft);
  color: #a83a1c;
  padding: 12px 14px;
  border-radius: 10px;
  line-height: 1.5;
  margin: 0 0 16px;
}

/* ---------- App shell ---------- */
.app { display: flex; flex-direction: column; height: 100dvh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: var(--navy);
  color: #fff;
  padding-top: max(12px, env(safe-area-inset-top));
}
.topbar-title { display: flex; align-items: center; gap: 12px; }
.topbar-emoji { font-size: 30px; }
.topbar h1 { margin: 0; font-size: 19px; letter-spacing: 0.2px; }
.topbar-sub { margin: 2px 0 0; font-size: 13px; color: #b9c3da; }
.logout {
  color: #cfd8ec;
  text-decoration: none;
  font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.logout:hover { background: rgba(255, 255, 255, 0.1); }

.layout { flex: 1; display: flex; min-height: 0; }

/* ---------- Timeline ---------- */
.timeline {
  width: 380px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--bg);
  border-right: 1px solid var(--line);
  padding: 16px 14px 40px;
}
.timeline-loading { color: var(--muted); padding: 24px 8px; }

.stop-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  margin: 0 0 12px 30px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.stop-card:hover { transform: translateY(-1px); }
.stop-card.active {
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(232, 98, 61, 0.22);
}

/* The route line + numbered node down the left of the timeline */
.stop-card::before {
  content: attr(data-num);
  position: absolute;
  left: -30px;
  top: 16px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
  border: 3px solid var(--bg);
  z-index: 1;
}
.stop-card.active::before { background: var(--accent); }
.stop-card::after {
  content: "";
  position: absolute;
  left: -19px;
  top: 34px;
  bottom: -22px;
  width: 2px;
  background: var(--line);
}
.stop-card:last-child::after { display: none; }

.stop-dates {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.stop-name { margin: 4px 0 2px; font-size: 18px; }
.stop-country { color: var(--muted); font-size: 13px; }
.stop-meta { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.stop-row { font-size: 14px; color: var(--ink); display: flex; gap: 8px; }
.stop-row .ic { width: 18px; text-align: center; flex-shrink: 0; }
.stop-row a { color: var(--navy-2); }
.stop-notes {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
}
.stop-activities { margin: 10px 0 0; padding: 0; list-style: none; }
.stop-activities li {
  font-size: 14px;
  padding: 6px 0 6px 22px;
  position: relative;
  border-top: 1px solid var(--line);
}
.stop-activities li::before {
  content: "•";
  position: absolute;
  left: 6px;
  color: var(--accent);
  font-weight: 700;
}
.act-time { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Map ---------- */
.map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; }
.fit-btn {
  position: absolute;
  bottom: 18px;
  right: 18px;
  z-index: 500;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.fit-btn:hover { background: #fff; }

.marker-pin {
  background: var(--navy);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  font-weight: 700;
  font-size: 13px;
}
.marker-pin span { transform: rotate(45deg); }
.marker-pin.active { background: var(--accent); }

.leaflet-popup-content { font-size: 14px; }
.leaflet-popup-content b { color: var(--navy); }

/* ---------- Mobile ---------- */
@media (max-width: 780px) {
  .layout { flex-direction: column-reverse; }
  .map-wrap { flex: none; height: 42vh; }
  .timeline {
    width: 100%;
    border-right: none;
    flex: 1;
    min-height: 0;
  }
}
