/* ========================================================================
   TripBase — dark theme
   ======================================================================== */
:root {
  --bg:        #0b0f17;
  --bg-2:      #0f1623;
  --panel:     #131c2b;
  --panel-2:   #18243a;
  --panel-hi:  #1d2b44;
  --border:    #233149;
  --border-hi: #31415f;
  --border-soft:#1c2940;
  --text:      #e8eef9;
  --text-dim:  #9fb0c9;
  --text-mute: #6b7c97;
  --accent:    #6aa3ff;
  --accent-2:  #8b5cf6;
  --good:      #22c55e;
  --warn:      #eab308;
  --bad:       #ef4444;
  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 10px 30px rgba(0,0,0,.35);
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 70% -10%, #16223b 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, var(--bg-2), #0a0e16);
  border-right: 1px solid var(--border-soft);
  padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 6px 8px 14px; }
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 800;
}
.brand .name { font-weight: 700; letter-spacing: .2px; }
.nav-section { color: var(--text-mute); font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; margin: 14px 8px 6px; }
.nav-item, .trip-pill {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; color: var(--text-dim); padding: 8px 10px; border-radius: 9px;
  cursor: pointer; font-size: 13.5px;
}
.nav-item:hover, .trip-pill:hover { background: var(--panel); color: var(--text); }
.nav-item.active, .trip-pill.active { background: var(--panel-hi); color: #fff; }
.trip-pill { flex-direction: column; align-items: stretch; gap: 2px; }
.trip-pill .t-name { font-weight: 600; }
.trip-pill .t-meta { font-size: 11.5px; color: var(--text-mute); }
.btn-new {
  width: 100%; margin: 4px 0 6px; padding: 9px 10px; border-radius: 10px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: 0; font-weight: 600;
}

/* ---------- Main ---------- */
.main { padding: 18px 22px 60px; min-width: 0; }
.main-inner { max-width: 1180px; margin: 0 auto; }
html, body { overflow-x: hidden; }

/* Trip header */
.trip-head {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 16px; background: var(--panel);
}
.trip-head .cover {
  height: 132px; background: linear-gradient(120deg, #1b2c4a, #243b63 40%, #3a2b54);
  background-size: cover; background-position: center;
}
.trip-head .head-body { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: flex-end;
  padding: 14px 18px; }
.trip-head h1 { margin: 0; font-size: 22px; }
.trip-head .sub { color: var(--text-dim); margin-top: 3px; }
.head-stats { display: flex; gap: 22px; margin-left: auto; flex-wrap: wrap; }
.head-stats .stat .k { font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .05em; }
.head-stats .stat .v { font-weight: 700; font-size: 15px; }

/* Tabs */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 16px; border-bottom: 1px solid var(--border-soft); }
.tab { background: none; border: 0; color: var(--text-dim); padding: 9px 13px; cursor: pointer;
  border-radius: 9px 9px 0 0; font-size: 13.5px; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active { color: #fff; border-bottom-color: var(--accent); }

/* Cards / grid */
.grid { display: grid; gap: 14px; }
.dash { grid-template-columns: repeat(12, 1fr); }
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 15px;
  min-width: 0;
}
.card h3 { margin: 0 0 10px; font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.card .card-link { float: right; font-size: 12px; font-weight: 600; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }

/* Badges & chips */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--border); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px;
  font-size: 12px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim);
  cursor: pointer; user-select: none; }
.chip.on { color: #fff; border-color: var(--accent); background: var(--panel-hi); }
.chip .dot { width: 9px; height: 9px; }

/* Up next */
.upnext { display: flex; gap: 12px; align-items: center; }
.upnext .when { text-align: center; min-width: 56px; padding: 8px; border-radius: 10px;
  background: var(--panel-hi); border: 1px solid var(--border); }
.upnext .when .d { font-size: 20px; font-weight: 800; line-height: 1; }
.upnext .when .m { font-size: 11px; color: var(--text-dim); text-transform: uppercase; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 9px; }
.row { display: flex; gap: 11px; align-items: flex-start; padding: 9px 10px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--border-soft); }
.row .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-size: 15px; flex: 0 0 auto; background: var(--panel-hi); border: 1px solid var(--border); }
.row .body { min-width: 0; flex: 1; }
.row .title { font-weight: 600; }
.row .meta { color: var(--text-mute); font-size: 12.5px; margin-top: 2px; }
.row .right { margin-left: auto; text-align: right; color: var(--text-dim); font-size: 12.5px; white-space: nowrap; }

/* Itinerary day */
.day { margin-bottom: 16px; }
.day-head { display: flex; align-items: baseline; gap: 10px; margin: 4px 2px 9px; }
.day-head .dow { font-weight: 700; }
.day-head .date { color: var(--text-mute); font-size: 12.5px; }
.day-line { display: grid; grid-template-columns: 70px 1fr; gap: 12px; }
.day-line .time { color: var(--text-dim); font-size: 12.5px; padding-top: 11px; }

/* Checklist */
.check { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--border-soft); }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.check.done .c-task { color: var(--text-mute); text-decoration: line-through; }
.check .c-cat { margin-left: auto; }
.progress { height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; border: 1px solid var(--border); }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* Map */
#map, .map-box { width: 100%; height: 100%; min-height: 280px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border); background: #0a1322; }
.map-tall #map { min-height: 64vh; }
.map-theme-toggle {
  position: absolute; top: 10px; right: 50px; z-index: 1000;
  width: 34px; height: 34px; padding: 0; line-height: 1;
  display: grid; place-items: center; cursor: pointer;
  font-size: 16px; border-radius: 8px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border-hi);
  box-shadow: 0 2px 8px rgba(0,0,0,.45);
}
.map-theme-toggle:hover { border-color: var(--text-dim); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #16233b; color: var(--text); }
.leaflet-popup-content { margin: 10px 12px; font: inherit; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
th { color: var(--text-mute); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .05em; }
td .muted { color: var(--text-mute); }

/* Empty / notes */
.note { color: var(--warn); background: rgba(234,179,8,.08); border: 1px solid rgba(234,179,8,.25);
  border-radius: 9px; padding: 8px 11px; font-size: 12.5px; }
.muted { color: var(--text-mute); }
.section-actions { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 7px 12px;
  border-radius: 9px; cursor: pointer; font-size: 13px; }
.btn:hover { background: var(--panel-hi); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; color: #fff; font-weight: 600; }

/* Modal (add/edit) */
.modal-bg { position: fixed; inset: 0; background: rgba(4,8,15,.6); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-bg.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; width: min(560px, 100%);
  max-height: 88vh; overflow: auto; box-shadow: var(--shadow); }
.modal header { padding: 15px 18px; border-bottom: 1px solid var(--border-soft); font-weight: 700; }
.modal .body { padding: 16px 18px; display: grid; gap: 11px; }
.modal label { font-size: 12px; color: var(--text-dim); display: block; margin-bottom: 4px; }
.modal input, .modal select, .modal textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 9px 10px; font: inherit; }
.modal textarea { min-height: 66px; resize: vertical; }
.modal footer { padding: 13px 18px; border-top: 1px solid var(--border-soft); display: flex; gap: 8px; justify-content: flex-end; }
.field-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }

/* Marker cluster bubbles (dark theme) */
.marker-cluster, .marker-cluster div {
  background: rgba(106,163,255,.25); color: #eaf1ff; border: 1px solid rgba(106,163,255,.5);
}
.marker-cluster div { background: rgba(106,163,255,.55); }
.marker-cluster span { color: #fff; font-weight: 700; }

/* Phase pill (Researching → Planned → Booked) */
.phase-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--border);
  cursor: pointer; user-select: none; }
.phase-pill:hover { background: var(--panel-hi); }
.phase-pill .dot { width: 8px; height: 8px; border-radius: 50%; }

/* Guide (rendered markdown) */
.guide-doc { padding: 6px 20px 18px; line-height: 1.6; }
.guide-doc h1 { font-size: 20px; margin: 20px 0 8px; }
.guide-doc h2 { font-size: 16px; margin: 18px 0 6px; color: var(--text); }
.guide-doc h3 { font-size: 14px; margin: 14px 0 4px; color: var(--accent); }
.guide-doc h1 + hr, .guide-doc hr { border: 0; border-top: 1px solid var(--border-soft); margin: 14px 0; }
.guide-doc p { margin: 8px 0; color: var(--text-dim); }
.guide-doc ul, .guide-doc ol { margin: 8px 0 8px 4px; padding-left: 20px; color: var(--text-dim); }
.guide-doc li { margin: 3px 0; }
.guide-doc strong { color: var(--text); }
.guide-doc .md-table { margin: 12px 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.guide-doc .md-table th { background: var(--panel-2); }
.guide-doc .md-table td, .guide-doc .md-table th { white-space: nowrap; }

/* Mobile menu button + scrim — hidden on desktop so they don't become stray grid items */
.menu-btn { display: none; position: fixed; top: 12px; left: 12px; z-index: 50; }
.scrim { display: none; }

/* ---------- Responsive (phone on the road) ---------- */
@media (max-width: 920px) {
  .span-3,.span-4,.span-5,.span-6,.span-7,.span-8 { grid-column: span 12; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 86%; max-width: 320px; z-index: 60;
    transform: translateX(-103%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .app.nav-open .sidebar { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .main { padding: 56px 14px 60px; }
  .head-stats { gap: 16px; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 55; display: none; }
  .app.nav-open .scrim { display: block; }
}

/* ========================================================================
   TripBase — additions (Aug 2026)
   Alerts, contacts, drive legs, structured notes, itinerary legs.
   ======================================================================== */

/* ---------- header stat links ---------- */
.head-stats .stat .v .stat-link { font-weight: 700; font-size: 15px; }
.head-stats .stat .v .stat-link.danger { color: #ff6b6b; }
.head-stats .stat .v .stat-link.warn { color: var(--warn); }

/* ---------- Needs attention ---------- */
.card.alerts { border-color: rgba(239,68,68,.35);
  background: linear-gradient(180deg, rgba(239,68,68,.06), var(--panel) 60%); }
.alert { display: flex; gap: 11px; align-items: flex-start; padding: 11px 12px;
  border-radius: 11px; border: 1px solid var(--border-soft); background: var(--bg-2);
  margin-bottom: 8px; border-left-width: 3px; }
.alert-risk { border-left-color: #ef4444; }
.alert-warn { border-left-color: #f59e0b; }
.alert-info { border-left-color: #38bdf8; }
.alert .a-mark { font-size: 14px; line-height: 1.4; }
.alert .a-body { min-width: 0; flex: 1; }
.alert .a-title { font-weight: 700; margin-bottom: 3px; }
.alert .a-text { color: var(--text-dim); font-size: 13px; line-height: 1.55; }
.alert .a-foot { display: flex; gap: 10px; align-items: center; margin-top: 7px; flex-wrap: wrap; font-size: 12.5px; }
.a-more { margin-top: 4px; }

.badge.overdue { color: #ff8080; border-color: rgba(239,68,68,.5); background: rgba(239,68,68,.12); }

/* ---------- structured notes ----------
   Each ⚠️ / 🔴 / ✅ / 📸 segment becomes its own accented line instead of
   disappearing into a paragraph of gold text. */
.nlines { margin-top: 5px; }
.nline { color: var(--text-dim); font-size: 12.8px; line-height: 1.55; }
.nlines .nline { padding: 3px 0 3px 9px; border-left: 2px solid transparent; margin-top: 3px; }
.nline-warn { color: #f3c14b; border-left-color: rgba(234,179,8,.55) !important; }
.nline-risk { color: #ff8f8f; border-left-color: rgba(239,68,68,.6) !important; }
.nline-ok   { color: #7fdba0; border-left-color: rgba(34,197,94,.5) !important; }
.nline-photo{ color: #fcd34d; border-left-color: rgba(251,191,36,.5) !important; }
.nline-hist { color: #e0a75e; border-left-color: rgba(217,119,6,.5) !important; }
.nline-wait { color: #a5b4fc; border-left-color: rgba(129,140,248,.5) !important; }
.nline.small, .nlines.small .nline { font-size: 12.2px; }
.note .nline, .note .nlines .nline { color: inherit; }
.note .nline-risk { color: #ff8f8f; }
.note .nline-ok { color: #7fdba0; }

/* ---------- contacts ---------- */
.c-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.c-actions .chip { text-decoration: none; }
.c-actions a.chip:hover { border-color: var(--accent); text-decoration: none; }
.row.contact .title { font-weight: 700; }

/* ---------- drive legs ---------- */
.drive-chip { display: inline-flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-top: 6px; padding: 4px 9px; border-radius: 8px;
  background: rgba(20,184,166,.10); border: 1px solid rgba(20,184,166,.30);
  color: #7fd8cc; font-size: 12.2px; }
.drive-chip .d-route { font-weight: 600; }

/* ---------- itinerary legs ---------- */
.leg-bar { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 0 16px; }
.leg-chip { font-size: 12px; }
.leg-head { position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 22px 0 10px; padding: 9px 12px; border-radius: 11px;
  background: linear-gradient(90deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(0,0,0,.28); }
.leg-head .l-name { font-weight: 800; font-size: 14.5px; }
.leg-head .l-dates { color: var(--text-mute); font-size: 12.5px; }
.leg-head .l-phase { font-size: 11.5px; border: 1px solid; border-radius: 999px; padding: 2px 8px; }
.leg-head a { margin-left: auto; font-size: 12.5px; }

.day.is-today { background: rgba(106,163,255,.06); border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(106,163,255,.25); padding: 8px 8px 2px; }
.day.is-past { opacity: .62; }
.day-head .day-bed { color: var(--text-dim); font-size: 12px; margin-left: auto;
  background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: 999px; padding: 2px 9px; }
.day-head .day-today { color: var(--accent); font-weight: 700; font-size: 12px; }
.day-open { color: var(--text-mute); font-size: 12.5px; padding: 4px 2px 8px; }

/* ---------- places ---------- */
.search { background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 7px 10px; min-width: 220px; font-size: 13px; }
.search:focus { outline: none; border-color: var(--accent); }
.place-group { font-size: 14px; margin: 18px 2px 8px; }
.place-card.is-must { border-color: rgba(34,197,94,.32); }
.place-card.is-skip { opacity: .55; }
.stay-card.unbooked { border-color: rgba(239,68,68,.35); }
.conf { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  color: var(--text-dim); background: var(--bg-2); border: 1px solid var(--border-soft);
  border-radius: 6px; padding: 2px 7px; }

/* ---------- checklist ---------- */
.check-group { font-size: 13px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-mute); margin: 20px 2px 8px; }
.check-group .muted { text-transform: none; letter-spacing: 0; font-size: 12px; }
.check.overdue { box-shadow: inset 0 0 0 1px rgba(239,68,68,.30); }

/* ---------- lodging timeline ---------- */
.row.bed.now { background: rgba(106,163,255,.08); box-shadow: inset 0 0 0 1px rgba(106,163,255,.22); }
.row.bed.past { opacity: .55; }

/* ---------- budget ---------- */
td.num, th.num { text-align: right; white-space: nowrap; }
tr.unpriced td { opacity: .65; }

@media (max-width: 820px) {
  .leg-head { position: static; }
  .day-head .day-bed { margin-left: 0; }
  .search { min-width: 0; width: 100%; }
}

/* ========================================================================
   TIMELINE VIEW — the broad, at-a-glance ribbon (desktop) and rail (mobile).
   All selectors namespaced .tl-* / .mb-* so nothing above is affected.
   Hue carries city identity; phase rides on fill + left cap, so the two
   encodings never compete for the same channel.
   ======================================================================== */
.tl-seg { display:inline-flex; border:1px solid var(--border-hi); border-radius:10px; overflow:hidden; }
.tl-seg button { background:none; border:0; color:var(--text-dim); padding:7px 13px; cursor:pointer; font-size:13px; }
.tl-seg button:hover { background:var(--panel); color:var(--text); }
.tl-seg button.on { background:var(--panel-hi); color:#fff; font-weight:600; }

.tl-legend { display:flex; gap:12px; flex-wrap:wrap; font-size:11.5px; color:var(--text-mute);
             align-items:center; margin-left:auto; }
.tl-legend i { display:inline-block; width:16px; height:9px; border-radius:3px; margin-right:5px; vertical-align:-1px }
.lg-booked { background:#22c55e33; border:1px solid #22c55e }
.lg-planned{ background:#0ea5e933; border:1px dashed #0ea5e9 }
.lg-res    { background:repeating-linear-gradient(45deg,#eab30822 0 4px,transparent 4px 8px); border:1px dashed #eab308 }
.lg-gap    { background:repeating-linear-gradient(45deg,#ef444433 0 4px,transparent 4px 8px); border:1px dashed #ef4444 }

.tl-scroll { overflow-x:auto; overflow-y:visible; border:1px solid var(--border);
             border-radius:var(--radius); background:var(--panel); padding:0 0 10px; }
.tl-scroll.mini { padding:6px; border-radius:var(--radius-sm) }
.tl-grid { display:grid; position:relative; align-items:stretch; }
.tl-grid.wide { min-width:1900px }
.tl-grid.mini { min-height:0 }

/* Column backgrounds span every lane, so weekends and today read as
   vertical bands rather than per-lane decoration. */
.tl-col      { grid-row:1 / -1; border-left:1px solid var(--border-soft); pointer-events:none }
.tl-col.wknd { background:rgba(255,255,255,.022) }
.tl-col.today{ background:rgba(106,163,255,.10); border-left:2px solid var(--accent) }
/* Transition rule — where the city changes. */
.tl-cut      { grid-row:3 / -1; border-left:2px dashed #ffffff33; pointer-events:none; z-index:3 }
.tl-grid.mini .tl-cut { grid-row:1 / -1 }

.tl-lab { grid-column:1; display:flex; align-items:center; font-size:11px; letter-spacing:.06em;
          text-transform:uppercase; color:var(--text-mute); padding:0 10px; position:sticky; left:0;
          background:var(--panel); z-index:6; border-right:1px solid var(--border) }
.tl-lab.head { background:var(--panel-2) }

.tl-month { grid-row:1; background:var(--panel-2); font-size:11.5px; font-weight:700; letter-spacing:.08em;
            text-transform:uppercase; color:var(--text-dim); padding:6px 8px;
            border-left:1px solid var(--border); position:relative; z-index:2 }
.tl-day { grid-row:2; text-align:center; padding:4px 0 6px; position:relative; z-index:2; font-size:11px;
          color:var(--text-dim); background:var(--panel-2); cursor:pointer;
          border-bottom:1px solid var(--border) }
.tl-day .dw { display:block; font-size:9.5px; color:var(--text-mute); letter-spacing:.04em }
.tl-day .dn { display:block; font-weight:700; font-size:12px; color:var(--text) }
.tl-day.today .dn { color:var(--accent) }
.tl-day:hover { background:var(--panel-hi) }
.tl-day .pip { position:absolute; top:1px; right:2px; font-size:8px; line-height:1 }

.tl-bar { position:relative; z-index:4; margin:3px 2px; min-width:0; border-radius:7px; padding:4px 7px;
          font-size:11.5px; line-height:1.25; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
          border:1px solid transparent }
.tl-bar[onclick], .tl-bar { cursor:default }
.tl-bar.tl-sleep, .tl-bar.tl-car, .tl-bar.tl-move { cursor:pointer }
.tl-bar:hover { filter:brightness(1.16) }
.tl-bar .sub { color:#ffffffaa; font-weight:400 }
.tl-grid.mini .tl-bar { margin:2px 1px; padding:0; min-height:15px; border-radius:4px }

.tl-where { min-height:30px; display:flex; align-items:center; font-weight:650;
            color:#0b0f17; text-shadow:0 1px 0 #ffffff30 }
.tl-where.split { color:var(--text); text-shadow:none; justify-content:center;
                  font-size:10.5px; border-color:#ffffff22 }
.tl-sleep { min-height:34px; display:flex; align-items:center }
.tl-sleep b { font-weight:650 }

/* Phase: fill + a solid left cap, never hue. */
.ph-booked      { background:#22c55e22; border-color:#22c55e88; box-shadow:inset 3px 0 0 #22c55e }
.ph-planned     { background:#0ea5e91f; border:1px dashed #0ea5e999; box-shadow:inset 3px 0 0 #0ea5e9 }
.ph-researching { background:repeating-linear-gradient(45deg,#eab30818 0 5px,transparent 5px 10px);
                  border:1px dashed #eab308aa; box-shadow:inset 3px 0 0 #eab308 }

/* The three meanings of an empty night, kept visually distinct. */
.tl-gap     { min-height:34px; display:flex; align-items:center; justify-content:center;
              background:repeating-linear-gradient(45deg,#ef444426 0 5px,transparent 5px 10px);
              border:1px dashed #ef4444aa; color:#fca5a5; font-size:10.5px }
.tl-transit { min-height:34px; display:flex; align-items:center; justify-content:center;
              background:#ffffff08; border:1px dashed #ffffff22; color:var(--text-mute); font-size:10.5px }

.tl-car { min-height:26px; display:flex; align-items:center; color:#cbd5e1 }
.tl-car.ph-booked { background:#64748b26; border-color:#94a3b880; box-shadow:inset 3px 0 0 #94a3b8 }
.tl-move { min-height:26px; display:flex; align-items:center; justify-content:center; font-size:11px; padding:3px 5px }
.mv-air  { background:#0ea5e926; border-color:#0ea5e988; color:#bae6fd }
.mv-rail { background:#94a3b826; border-color:#94a3b888; color:#e2e8f0 }
.mv-road { background:#14b8a622; border-color:#14b8a677; color:#99f6e4 }

.tl-plans { display:flex; align-items:center; justify-content:center; gap:2px; min-height:22px;
            padding:4px 0; position:relative; z-index:4; cursor:pointer }
.tl-plans span { width:5px; height:5px; border-radius:50%; background:var(--accent); opacity:.7 }
.tl-plans:hover span { opacity:1 }

/* Overview roll-up legend */
.tl-mini-key { display:flex; gap:12px; flex-wrap:wrap; margin-top:9px; font-size:11.5px; color:var(--text-dim) }
.tl-mini-city i { display:inline-block; width:9px; height:9px; border-radius:2px; margin-right:5px }

/* Flash the day the timeline just sent you to. */
.day-flash { animation: tlflash 1.4s ease-out 1 }
@keyframes tlflash { 0%,40% { box-shadow:0 0 0 2px var(--accent) inset } 100% { box-shadow:none } }

/* ---------- MOBILE RAIL ----------
   The same model rotated: days run down, and a stay becomes a continuous
   coloured spine, so a multi-day item is still one unbroken object. */
/* The rail and the desktop grid used to be rendered together and toggled
   by this media query. They are now separate, explicitly-chosen modes, so
   whichever one is in the DOM is the one meant to be visible. */
.tl-mobile { display:block }
.mb-leg { position:sticky; top:0; z-index:5; display:flex; align-items:center; gap:8px; padding:8px 10px;
          background:var(--panel-2); border:1px solid var(--border); border-radius:10px;
          margin:14px 0 0; font-size:12.5px }
.mb-leg .nm { font-weight:700 }
.mb-leg .dt { color:var(--text-mute); margin-left:auto; font-size:11.5px }
.mb-day { display:grid; grid-template-columns:44px 10px 1fr; align-items:stretch; cursor:pointer }
.mb-day:active { background:var(--panel) }
.mb-date { text-align:right; padding:7px 6px 7px 0; font-size:11px; color:var(--text-mute) }
.mb-date b { display:block; font-size:14px; color:var(--text) }
.mb-day.today .mb-date b { color:var(--accent) }
.mb-spine { position:relative }
.mb-spine i { position:absolute; left:3px; top:0; bottom:0; width:4px; border-radius:2px }
.mb-spine.first i { top:7px; border-radius:4px 4px 2px 2px }
.mb-spine.last i  { bottom:7px; border-radius:2px 2px 4px 4px }
.mb-body { padding:7px 0 7px 8px; min-width:0; border-bottom:1px solid var(--border-soft) }
.mb-city { font-weight:650; font-size:13px }
.mb-sub  { font-size:11.5px; color:var(--text-mute) }
.mb-chips{ display:flex; gap:5px; flex-wrap:wrap; margin-top:4px }
.mb-chip { font-size:11px; padding:2px 7px; border-radius:20px; border:1px solid var(--border-hi);
           background:var(--panel); color:var(--text-dim) }
.mb-chip.air { border-color:#0ea5e977; color:#bae6fd; background:#0ea5e91a }
.mb-chip.road{ border-color:#14b8a666; color:#99f6e4; background:#14b8a614 }
.mb-chip.car { border-color:#94a3b866; color:#e2e8f0 }
.mb-chip.warn{ border-color:#ef444488; color:#fca5a5; background:#ef44441a; white-space:normal }
.mb-quiet { opacity:.72 }
.mb-quiet:hover { opacity:1 }
.mb-quiet .mb-date b { font-size:11.5px; color:var(--text-mute); padding-top:6px }
.mb-quiet .mb-body { padding-top:6px; padding-bottom:6px }

@media (max-width: 820px) {
  .tl-legend { margin-left:0 }
}
.tl-sleep .sub { margin-left:6px }

/* ========================================================================
   VERTICAL TIMELINE — the ribbon rotated 90°. Lanes are columns, days are
   rows. Shares the phase classes (.ph-*) with the horizontal view, so a
   booked stay looks the same in either orientation.
   ======================================================================== */
.vt-scroll { border:1px solid var(--border); border-radius:var(--radius); background:var(--panel);
             overflow:hidden; max-width:760px }
.vt-wrap { position:relative }

.vt-head { position:sticky; top:0; z-index:8; display:grid; background:var(--panel-2);
           border-bottom:1px solid var(--border); font-size:10px; letter-spacing:.07em;
           text-transform:uppercase; color:var(--text-mute) }
.vt-head div { padding:6px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap }

.vt-grid { display:grid; position:relative }
.vt-row { grid-column:1 / -1; border-top:1px solid var(--border-soft); pointer-events:none }
.vt-row.wknd  { background:rgba(255,255,255,.022) }
.vt-row.today { background:rgba(106,163,255,.10); border-top:2px solid var(--accent) }
.vt-row.mstart{ border-top:1px solid var(--border-hi) }
.vt-cut { grid-column:1 / -1; border-top:2px dashed #ffffff33; pointer-events:none; z-index:5 }

.vt-date { grid-column:1; display:flex; align-items:center; gap:4px; padding:0 6px; position:relative;
           z-index:3; font-size:10.5px; color:var(--text-mute); cursor:pointer }
.vt-date b { font-size:12.5px; color:var(--text); font-weight:700; min-width:15px; text-align:right }
.vt-date.today b { color:var(--accent) }
.vt-date .mo { position:absolute; left:6px; top:-1px; font-size:8.5px; font-weight:700;
               letter-spacing:.08em; color:var(--accent-2) }
.vt-date .pip { position:absolute; right:1px; top:3px; font-size:7.5px; line-height:1 }
.vt-date:hover { background:var(--panel-hi) }

.vt-bar { position:relative; z-index:4; margin:1px 2px; border-radius:6px; padding:2px 5px;
          font-size:10.5px; line-height:1.25; overflow:hidden; border:1px solid transparent;
          display:flex; flex-direction:column; justify-content:flex-start; cursor:default }
.vt-bar .nm { font-weight:650; white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
.vt-bar .sub { color:#ffffff99; font-weight:400; font-size:9.5px; white-space:nowrap;
               overflow:hidden; text-overflow:ellipsis }
.vt-bar.vt-sleep, .vt-bar.vt-car { cursor:pointer }
.vt-bar:hover { filter:brightness(1.16) }
.vt-where { color:#0b0f17; text-shadow:0 1px 0 #ffffff30 }
.vt-where .nm { font-weight:700 }
.vt-where.split { color:var(--text); text-shadow:none; border-color:#ffffff22;
                  align-items:center; justify-content:center; font-size:10px }
.vt-car { color:#cbd5e1; align-items:center; text-align:center; font-size:9.5px }
/* Wheels is slate, not phase-green — .ph-booked would otherwise tint it the
   same colour as a booked stay and the two lanes would stop reading apart. */
.vt-car.ph-booked { background:#64748b26; border-color:#94a3b880; box-shadow:inset 0 3px 0 #94a3b8 }
.vt-gap     { background:repeating-linear-gradient(45deg,#ef444426 0 5px,transparent 5px 10px);
              border:1px dashed #ef4444aa; color:#fca5a5; align-items:center;
              justify-content:center; font-size:9.5px }
.vt-transit { background:#ffffff08; border:1px dashed #ffffff22; color:var(--text-mute);
              align-items:center; justify-content:center; font-size:9.5px }
/* Phase caps run along the TOP edge here, since the bar grows downward. */
.vt-bar.ph-booked      { box-shadow:inset 0 3px 0 #22c55e }
.vt-bar.ph-planned     { box-shadow:inset 0 3px 0 #0ea5e9 }
.vt-bar.ph-researching { box-shadow:inset 0 3px 0 #eab308 }

.vt-move { position:relative; z-index:4; margin:2px 1px; border-radius:6px; display:flex;
           align-items:center; justify-content:center; font-size:10px;
           border:1px solid transparent; cursor:pointer }
.vt-move:hover { filter:brightness(1.2) }
.vt-plans { position:relative; z-index:4; align-self:center; justify-self:start; height:5px;
            border-radius:3px; background:var(--accent); opacity:.65; margin-left:3px; cursor:pointer }
.vt-plans:hover { opacity:1 }

@media (max-width: 820px) {
  .vt-scroll { max-width:none }
}

/* Dark map theme for OpenStreetMap tiles (OSM has no dark style) — invert the
   tiles only; markers, popups and controls live in other panes and stay as-is. */
.tb-map-dark .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.6); }
.tb-map-dark.leaflet-container { background: #1b2230; }

/* Route view (LAB-339): numbered day markers + Pins/Route switch */
.route-pin { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font: 800 11px/1 Inter, system-ui, sans-serif; color: #0b0f17;
  border: 2px solid #0b0f17; box-shadow: 0 2px 8px rgba(0,0,0,.55); }
.seg.map-mode { display: inline-flex; border: 1px solid #263552; border-radius: 10px; overflow: hidden; }
.seg.map-mode button { background: transparent; color: inherit; border: 0; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.seg.map-mode button.on { background: #1d2a44; font-weight: 700; }
