:root {
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --coral: #f97316;
  --ink: #1e293b;
  --muted: #64748b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --danger: #dc2626;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }

/* editing controls only show once logged in */
body:not(.authed) .auth-only { display: none !important; }

/* offline indicator — a slim fixed bar shown only when the device is offline */
.offline-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  height: 26px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  background: #b45309;
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
}
body.offline .offline-bar { display: flex; }
/* nudge the headers down so the bar doesn't cover them while offline */
body.offline .app-header,
body.offline .trip-header { margin-top: calc(env(safe-area-inset-top) + 26px); }

.view {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ===== Trips list ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 20px) 20px 12px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff;
}
.app-header .lock-btn {
  background: rgba(255, 255, 255, 0.18);
  font-size: 1rem;
}
.trip-lock { font-size: 1rem; }
.login-error { color: var(--danger); font-size: 0.85rem; margin: 0 0 12px; }

/* ===== Login gate ===== */
.login-view {
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--teal), var(--teal-dark));
  padding: 24px;
}
.login-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.25);
  padding: 30px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-logo { font-size: 3rem; }
.login-card h1 { margin: 6px 0 4px; font-size: 1.5rem; }
.login-hint { margin: 0 0 18px; color: var(--muted); font-size: 0.9rem; }
.login-card input {
  width: 100%;
  padding: 13px;
  font-size: 1rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  margin-bottom: 12px;
}
.login-card input:focus { outline: 2px solid var(--teal); border-color: transparent; }
.login-card .btn-primary { width: 100%; }
.app-header h1 { margin: 0; font-size: 1.6rem; }
.app-header .subtitle { margin: 2px 0 0; opacity: 0.85; font-size: 0.9rem; }

.trips-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 96px;
}

.trip-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: stretch;
  gap: 12px;
  cursor: pointer;
  overflow: hidden;
}
/* alternating row tints within each year group */
.year-trips .trip-card:nth-child(even) { background: #ecfeff; }
.year-trips .trip-card:nth-child(odd) { background: #fff7ed; }

/* year groupings on the trips list */
.year-group { margin-bottom: 8px; }
.year-heading {
  margin: 4px 2px 10px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
/* archived year headings double as collapse toggles */
.year-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}
.year-toggle .year-count {
  background: var(--border);
  color: var(--muted);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  padding: 1px 8px;
  text-transform: none;
}
.year-toggle .year-caret { margin-left: auto; color: var(--muted); }

/* collapsible Archive section below the active trips */
.archive-section {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.archive-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 2px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}
.archive-toggle .archive-title { letter-spacing: 0.01em; }
.archive-toggle .archive-count {
  background: var(--border);
  color: var(--muted);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 1px 8px;
}
.archive-toggle .archive-caret { margin-left: auto; color: var(--muted); }
.archive-body { margin-top: 12px; }
/* archived cards read as muted/done */
.trip-card.is-archived { opacity: 0.7; }

/* archive/restore and delete buttons inside the Edit Trip sheet */
.trip-archive-btn {
  width: 100%;
  margin: 4px 0 10px;
}
.trip-delete-btn {
  width: 100%;
  margin: 0 0 4px;
  border-color: var(--danger);
  color: var(--danger);
}

/* ---- pop-up calendar ---- */
.cal-sheet { max-width: 480px; }
.cal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.cal-head h3 {
  flex: 1;
  text-align: center;
  margin: 0;
  font-size: 1.1rem;
}
.cal-head .icon-btn { font-size: 1.5rem; }

.cal-dow-row, .cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-dow {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  padding-bottom: 4px;
}
.cal-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 10px;
  font-size: 0.85rem;
}
.cal-cell.cal-empty { background: none; }
.cal-cell.has-trip {
  background: #ccfbf1;
  cursor: pointer;
  font-weight: 600;
}
.cal-cell.is-today { outline: 2px solid var(--coral); outline-offset: -2px; }
.cal-cell.is-today .cal-num { color: var(--coral); font-weight: 700; }
.cal-num { line-height: 1; }
.cal-dots {
  display: flex;
  gap: 2px;
  min-height: 6px;
  align-items: center;
}
.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  background: var(--teal);
}
.cal-place-dot { background: var(--coral); }

.cal-legend { margin-top: 14px; }
.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: var(--bg);
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  text-align: left;
}
.cal-chip {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.cal-leg-name { flex: 1; font-weight: 600; font-size: 0.9rem; color: var(--ink); }
.cal-leg-dates { font-size: 0.8rem; color: var(--muted); flex-shrink: 0; }
.cal-note {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  justify-content: center;
  padding: 6px 0 2px;
}
.trip-card .trip-emoji {
  font-size: 1.6rem;
  background: #ccfbf1;
  border-radius: 12px;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: center;
}
.trip-card .trip-icon-slot {
  position: relative;
  flex-shrink: 0;
  align-self: center;
}
/* a custom photo spans to the top, bottom and left edges of the card */
.trip-card .trip-icon-slot.has-img {
  align-self: stretch;
  margin: -16px 0 -16px -16px;
  width: 110px;
  overflow: hidden;
}
.trip-card .trip-icon-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* trip photo control inside the Add/Edit Trip sheet */
.trip-photo-field { margin-bottom: 12px; }
.trip-photo-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.trip-photo-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.trip-photo-preview {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.trip-photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.trip-photo-placeholder { font-size: 1.8rem; opacity: 0.7; }
.trip-photo-buttons {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.trip-photo-buttons .btn-outline { margin: 0; }
.icon-remove-btn { color: var(--danger); }
.trip-card .trip-info { flex: 1; min-width: 0; align-self: center; }
.trip-card h3 { margin: 0 0 2px; font-size: 1.05rem; }
.trip-card p { margin: 0; font-size: 0.82rem; color: var(--muted); }
.trip-card .trip-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  align-self: center;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 60px 24px;
  font-size: 0.95rem;
}
.empty-state .big { font-size: 2.6rem; display: block; margin-bottom: 8px; }
.empty-state-sm {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 18px 12px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

/* ===== Trip detail ===== */
.trip-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  z-index: 500;
}
.trip-header-text { min-width: 0; flex: 1; }
.trip-edit { font-size: 1rem; }
.trip-header h2 {
  margin: 0;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trip-header p { margin: 0; font-size: 0.78rem; color: var(--muted); }

.icon-btn {
  border: none;
  background: var(--bg);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 1.15rem;
  cursor: pointer;
  flex-shrink: 0;
}

#btn-map-toggle.map-toggle-on {
  background: var(--teal);
  color: #fff;
}

#map {
  height: 42dvh;
  flex-shrink: 0;
  z-index: 1;
}
#map.pin-mode { cursor: crosshair; }

/* drag handle to resize the map height */
.map-resize {
  flex-shrink: 0;
  height: 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ns-resize;
  touch-action: none;
  z-index: 400;
}
.map-resize-grip {
  width: 44px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}
.map-resize:active .map-resize-grip { background: var(--teal); }

.pin-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 1000;
  box-shadow: var(--shadow);
  white-space: nowrap;
}

/* schedule / itinerary tabs */
.trip-tabs {
  display: flex;
  flex-shrink: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.trip-tabs::-webkit-scrollbar { display: none; }
/* when the tab bar scrolls (e.g. the 5th Itinerary tab on cruises), fade the
   edge that has more tabs so it reads as scrollable rather than cut off */
.trip-tabs.tabs-overflow {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 20px, #000 calc(100% - 20px), transparent 100%);
          mask-image: linear-gradient(to right, transparent 0, #000 20px, #000 calc(100% - 20px), transparent 100%);
}
.trip-tabs.tabs-overflow.tabs-at-start {
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 20px), transparent 100%);
          mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 20px), transparent 100%);
}
.trip-tabs.tabs-overflow.tabs-at-end {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 20px, #000 100%);
          mask-image: linear-gradient(to right, transparent 0, #000 20px, #000 100%);
}
.trip-tab {
  /* grow to fill when there are few tabs, but don't shrink — overflow scrolls */
  flex: 1 0 auto;
  border: none;
  background: none;
  padding: 11px 10px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.trip-tab.active {
  color: var(--teal-dark);
  border-bottom-color: var(--teal);
}
.tab-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* trip notes (shared by both tabs) */
.trip-notes-input {
  display: block;
  width: 100%;
  min-height: 260px;
  padding: 12px;
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.5;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  resize: vertical;
}
.trip-notes-input:focus { outline: 2px solid var(--teal); border-color: transparent; }
.trip-notes-status {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 6px;
  min-height: 1em;
}
.trip-notes-readonly {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-size: 0.95rem;
  line-height: 1.5;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px;
}

/* itinerary tab content */
.itin-block {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  overflow: hidden;
}
.itin-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 0.95rem;
}
.itin-block .itin-line { padding: 9px 12px; }

/* each ship's cruise details */
.cruise-ship { margin-bottom: 18px; }
.cruise-ship-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 8px;
  font-weight: 700;
  font-size: 1.12rem;
}

/* stateroom & dining — vertical label/value rows */
.cruise-field {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  font-size: 0.88rem;
  border-top: 1px solid var(--border);
}
.cruise-field:first-child { border-top: none; }
.cf-label { color: var(--muted); flex-shrink: 0; }
.cf-value { font-weight: 600; text-align: right; min-width: 0; overflow-wrap: anywhere; }

/* passengers (display) */
.pax-line {
  padding: 9px 12px;
  border-top: 1px solid var(--border);
}
.pax-line:first-child { border-top: none; }
.pax-line-name { font-weight: 600; font-size: 0.9rem; }
.pax-line-meta { color: var(--muted); font-size: 0.8rem; margin-top: 1px; }

/* daily activity (display) */
.daily-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
}
.daily-thumb {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.daily-thumb img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}
.daily-cap {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink);
  padding: 6px 8px;
  text-align: left;
}

/* trip documents */
.doc-add { display: block; text-align: center; cursor: pointer; }
.daily-grid { /* shared with documents */ }
.doc-card {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
}
.doc-card .doc-thumb { width: 100%; border: none; border-radius: 0; }
.doc-card .doc-thumb img { object-position: top; }
.doc-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
}
.doc-label {
  flex: 1;
  min-width: 0;
  margin-top: 0 !important;
  padding: 7px 8px !important;
  font-size: 0.82rem;
  background: var(--bg);
}
.doc-del { width: 34px; flex-shrink: 0; }

/* PDF thumbnail */
.pdf-thumb {
  height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: #fef2f2;
}
.pdf-badge { font-size: 2.4rem; line-height: 1; }
.pdf-badge-txt { font-size: 0.7rem; font-weight: 700; color: var(--danger); letter-spacing: 0.05em; }

/* inline daily-activity editor */
.dly-edit { padding: 6px; }
.dly-date {
  width: 100%;
  margin-top: 0 !important;
  margin-bottom: 6px;
  padding: 7px 8px !important;
  font-size: 0.8rem;
  background: var(--bg);
}
.dly-edit .doc-meta { padding: 0; }
.dly-label {
  flex: 1;
  min-width: 0;
  margin-top: 0 !important;
  padding: 7px 8px !important;
  font-size: 0.82rem;
  background: var(--bg);
}
.dly-del { width: 34px; flex-shrink: 0; }

/* full-screen photo viewer */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1300;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
}
.lightbox-close {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 8px);
  right: 12px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}
.lightbox-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  touch-action: pinch-zoom;
  -webkit-overflow-scrolling: touch;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
#lightbox-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  cursor: zoom-in;
}
#lightbox-img.zoomed {
  max-width: none;
  max-height: none;
  width: 240%;
  margin: 0;
  cursor: zoom-out;
}
.lightbox-cap {
  flex-shrink: 0;
  color: #fff;
  text-align: center;
  font-size: 0.85rem;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 12px);
}
.lightbox-cap:empty { display: none; }

/* Menu field (collapsible) in the place form */
.menu-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.menu-toggle.has-menu { border-color: var(--teal); color: var(--teal); }
.menu-toggle .menu-chevron { color: var(--muted); }
.menu-toggle[aria-expanded="true"] .menu-chevron { transform: rotate(180deg); }
.menu-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
}
.menu-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.menu-row .menu-label { flex: 1; min-width: 0; margin-top: 0; }
.menu-view {
  flex-shrink: 0;
  border: none;
  background: none;
  padding: 0;
  cursor: zoom-in;
}
.menu-view.btn-outline {
  padding: 6px 10px;
  cursor: pointer;
}
.menu-thumb { border-radius: 8px; overflow: hidden; }
.menu-thumb img { display: block; height: 44px; border-radius: 8px; }

/* website link & menu button shown on a place card */
a.place-link,
button.place-menu-btn {
  display: inline-block;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}
button.place-menu-btn { border: 1px solid var(--border); }

/* itinerary "Places" editor */
.sp-sortbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 6px;
}
.sp-sortlabel { font-size: 0.82rem; color: var(--muted); }
.sp-sort {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.sp-sort.active { background: var(--teal); color: #fff; border-color: var(--teal); }

.ship-place {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sp-header {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.sp-header .place-name {
  flex: 1;
  min-width: 0;
  font-size: 1.02rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sp-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 1rem;
  cursor: pointer;
}
.sp-toggle {
  flex-shrink: 0;
  width: 28px;
  height: 32px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.ship-place.open .sp-toggle { transform: rotate(180deg); }
.sp-done {
  margin-left: auto;
  width: auto;
  padding: 0 16px;
  color: var(--teal);
  font-weight: 600;
}
.sp-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sp-body.hidden { display: none; }
.ship-place input,
.ship-place select,
.ship-place textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  background: var(--bg);
}
.ship-place .sp-name { font-weight: 600; }
.sp-row {
  display: flex;
  gap: 8px;
}
.sp-row .sp-deck { flex: 1; min-width: 0; }
.sp-row .sp-type { flex: 0 0 42%; }
.sp-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
}
.ship-place-view { gap: 4px; }
.ship-place-view .place-name { font-size: 1.02rem; }

/* in-app PDF viewer — the close bar stays fixed above the PDF, so there's
   always a way back even when the PDF itself is pinch-zoomed */
.pdfviewer {
  position: fixed;
  inset: 0;
  z-index: 1300;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
}
.pdfviewer-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
}
.pdfviewer-close {
  flex-shrink: 0;
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.pdfviewer-cap {
  flex: 1;
  min-width: 0;
  color: #fff;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdfviewer-zoom,
.pdfviewer-open {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 1.3rem;
  text-decoration: none;
  cursor: pointer;
}
.pdfviewer-open { font-size: 1.2rem; }
.pdfviewer-pages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px;
  text-align: center;
}
.pdfviewer-pages canvas.pdf-page {
  display: block;
  margin: 0 auto 10px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  max-width: none;
}
.pdfviewer-status {
  color: #fff;
  text-align: center;
  padding: 40px 24px;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* daily activity (editor) */
.daily-edit-row {
  background: var(--bg);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
}
.daily-edit-top { display: flex; gap: 8px; }
.daily-edit-top .daily-date { flex: 1; margin-top: 0; background: var(--card); }
.daily-del { flex-shrink: 0; }
.daily-label { margin-top: 8px !important; background: var(--card); }
.daily-upload { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.daily-edit-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.daily-pick {
  flex: 1;
  margin-bottom: 0;
  text-align: center;
  cursor: pointer;
}

/* passengers (editor) */
.pax-edit-row {
  background: var(--bg);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
}
.pax-edit-top { display: flex; gap: 8px; }
.pax-edit-top .pax-name { flex: 1; margin-top: 0; background: var(--card); }
.pax-edit-bottom { display: flex; gap: 8px; margin-top: 8px; }
.pax-edit-bottom input { flex: 1; min-width: 0; margin-top: 0; background: var(--card); }

.filter-bar {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.chip.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.places-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 90px;
}

.day-header {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--teal-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 6px 2px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.day-rule {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.day-header-muted { color: var(--muted); }
.day-route {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  width: 32px;
  height: 30px;
  font-size: 0.95rem;
  cursor: pointer;
}
.day-route:active { background: var(--bg); }

.place-card {
  background: var(--card);
  border: 1px solid #000;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 5px;
  margin-bottom: 14px;
}
/* per-card date label */
.place-date {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--teal-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 2px 2px 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.place-card.visited { opacity: 0.6; }
.place-card.visited .place-name { text-decoration: line-through; }
.place-top {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
.place-icon { font-size: 1.45rem; margin-top: 1px; }
.place-info { flex: 1; min-width: 0; }
.place-name { font-weight: 600; font-size: 1.12rem; line-height: 1.25; }
.place-addr {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.place-when {
  display: block;
  width: fit-content;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--teal-dark);
  background: #ccfbf1;
  border-radius: 8px;
  padding: 4px 9px;
  margin-top: 5px;
}
.place-room {
  display: block;
  width: fit-content;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 9px;
  margin-top: 5px;
}
/* itinerary shown on the card */
.itin-toggle {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 0;
  background: none;
  border: none;
  color: var(--teal-dark);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}
.itin-table {
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.itin-line {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 8px;
  padding: 8px 10px;
  font-size: 0.86rem;
  border-top: 1px solid var(--border);
}
.itin-line:first-child { border-top: none; }
.itin-line-date { color: var(--muted); font-weight: 600; }
.itin-line-port { font-weight: 600; }
.itin-line-times { color: var(--teal-dark); font-size: 0.8rem; margin-top: 1px; }
.place-notes {
  position: relative;
  font-size: 0.9rem;
  color: var(--coral);
  margin-top: 4px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  cursor: pointer;
}
.place-notes.expanded { display: block; -webkit-line-clamp: unset; }
/* fade the tail of the 2nd line so it's obvious there's more */
.place-notes.has-more:not(.expanded)::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 45%;
  height: 1.15em;
  background: linear-gradient(to right, rgba(255, 255, 255, 0), var(--card));
  pointer-events: none;
}
.notes-toggle {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 0;
  background: none;
  border: none;
  color: var(--teal-dark);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.place-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 9px;
}
.nav-btn {
  flex: 0 0 auto;          /* compact — sized to content, not stretched */
  height: 34px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  border-radius: 9px;
  padding: 0 11px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  white-space: nowrap;
}
.nav-walk { background: var(--teal); }
.nav-drive { background: var(--ink); }
.actions-spacer { flex: 1 1 auto; } /* push the icon buttons to the right */
.mini-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 9px;
  font-size: 1.05rem;
  cursor: pointer;
}
.mini-btn.danger { color: var(--danger); }

/* per-place photo (hotel / meal / place) */
.place-photo-wrap {
  position: relative;
  margin-top: 9px;
}
.place-photo {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  border-radius: 10px;
  overflow: hidden;
  cursor: zoom-in;
}
.place-photo img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
}
.place-photo-del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
}

/* ===== FAB ===== */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--coral);
  color: #fff;
  font-size: 1.9rem;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.45);
  cursor: pointer;
  z-index: 600;
}

/* ===== Bottom sheets ===== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1100;
  display: flex;
  align-items: flex-end;
}
.sheet {
  background: var(--card);
  width: 100%;
  border-radius: 20px 20px 0 0;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 20px);
  max-height: 86dvh;
  overflow-y: auto;
  animation: slideUp 0.22s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(40%); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 4px auto 10px;
}
.sheet h3 { margin: 0 0 14px; font-size: 1.15rem; }

.sheet label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
}
.sheet input {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.sheet input:focus { outline: 2px solid var(--teal); border-color: transparent; }
.when-optional { font-weight: 400; color: var(--muted); opacity: 0.7; }

/* itinerary editor in the place sheet */
#itinerary-section { margin-bottom: 12px; }
.itin-head {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.itin-row {
  background: var(--bg);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
}
.itin-row-top { display: flex; gap: 8px; }
.itin-row-top .itin-port {
  flex: 1;
  margin-top: 0;
  background: var(--card);
}
.itin-del {
  flex-shrink: 0;
  width: 38px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  color: var(--danger);
  font-size: 0.9rem;
  cursor: pointer;
}
.itin-row-times {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.itin-row-times input {
  flex: 1;
  min-width: 0;
  margin-top: 0;
  background: var(--card);
  font-size: 0.85rem;
  padding: 9px 8px;
}
#btn-add-stop { margin-bottom: 4px; }
.sheet textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 12px;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  resize: vertical;
  min-height: 90px;
}
.sheet textarea:focus { outline: 2px solid var(--teal); border-color: transparent; }
.row { display: flex; gap: 10px; }
.row label { flex: 1; }

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.btn-primary, .btn-secondary, .btn-outline {
  flex: 1;
  padding: 13px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
}
.btn-primary { background: var(--teal); color: #fff; border: none; }
.btn-secondary { background: var(--bg); color: var(--ink); border: none; }
.btn-outline {
  display: block;
  width: 100%;
  background: var(--card);
  border: 1.5px dashed var(--teal);
  color: var(--teal-dark);
  margin-bottom: 14px;
}

/* select & checkbox controls inside sheets (match the inputs) */
.sheet select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.sheet select:focus { outline: 2px solid var(--teal); border-color: transparent; }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.92rem;
  color: var(--ink);
}
.checkbox-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--teal);
}

/* ===== Budget tab ===== */
.budget-add { margin: 4px 0 14px; }
.budget-summary {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.budget-total-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.budget-total {
  font-size: 2rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
  margin: 2px 0 8px;
}
.budget-split {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--muted);
}
.budget-fx-note {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 6px;
}
.exp-amt-conv {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
  margin-top: 1px;
}
.field-currency { max-width: 38%; }
.budget-bar {
  height: 9px;
  border-radius: 5px;
  background: var(--bg);
  overflow: hidden;
  margin: 14px 0 7px;
}
.budget-bar-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 5px;
  transition: width 0.3s ease;
}
.budget-bar-fill.over { background: var(--danger); }
.budget-bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}
.budget-left { color: var(--teal-dark); font-weight: 600; }
.budget-over { color: var(--danger); font-weight: 600; }
.budget-settings {
  display: flex;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.budget-settings label {
  flex: 1;
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
}
.budget-settings input,
.budget-settings select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 10px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
}
.budget-settings input:focus,
.budget-settings select:focus { outline: 2px solid var(--teal); border-color: transparent; }

/* category breakdown */
.cat-list { padding: 6px 12px 12px; }
.cat-row { margin-top: 12px; }
.cat-row:first-child { margin-top: 4px; }
.cat-row-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.88rem;
  margin-bottom: 5px;
}
.cat-name { color: var(--ink); }
.cat-amt { font-weight: 600; }
.cat-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg);
  overflow: hidden;
}
.cat-bar-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 3px;
}

/* expense rows */
.exp-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-top: 1px solid var(--border);
}
.exp-row:first-of-type { border-top: none; }
.exp-icon { font-size: 1.2rem; flex-shrink: 0; line-height: 1.4; }
.exp-main { flex: 1; min-width: 0; }
.exp-label { font-weight: 600; font-size: 0.92rem; overflow-wrap: anywhere; }
.exp-meta { font-size: 0.78rem; color: var(--muted); margin-top: 1px; }
.exp-paidby { font-size: 0.78rem; color: var(--teal-dark); margin-top: 2px; }
.exp-notes { font-size: 0.8rem; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.exp-right {
  flex-shrink: 0;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}
.exp-amt { font-weight: 700; font-size: 0.95rem; }
.exp-paid {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.exp-paid.is-paid {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}
.exp-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.budget-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 36px 24px;
  line-height: 1.5;
}

/* ===== Wishlist tab ===== */
.wish-list-wrap { display: flex; flex-direction: column; gap: 10px; }
/* a wishlist idea's photo sits full-width inside the card padding */
.wish-photo-wrap { margin: 0 12px 12px; }
.wish-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.wish-top { display: flex; gap: 10px; padding: 12px; }
.wish-icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px dashed var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
}
.wish-main { flex: 1; min-width: 0; }
.wish-name { font-weight: 700; font-size: 0.98rem; overflow-wrap: anywhere; }
.wish-loc { font-size: 0.8rem; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.wish-notes { font-size: 0.85rem; color: var(--ink); margin-top: 5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.wish-site {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--teal-dark);
  text-decoration: none;
  font-weight: 600;
}
.wish-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.wish-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 12px;
}
.wish-dir { display: flex; gap: 8px; flex: 1; }
.wish-go {
  flex: 1;
  text-align: center;
  padding: 8px 6px;
  border-radius: 9px;
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
}
.wish-add-plan {
  flex-shrink: 0;
  border: none;
  background: var(--teal);
  color: #fff;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
/* when a card has no location, the Add-to-plan button spans the footer */
.wish-foot:not(:has(.wish-dir)) .wish-add-plan { flex: 1; }
/* dashed map marker distinguishes wishlist ideas from planned spots */
.poi-marker.wish-marker {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.92);
}

/* ===== Packing checklist tab ===== */
/* per-person packing selector + overview */
.pack-persons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0 12px;
}
.chip.pack-person.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.pack-add-person {
  display: flex;
  gap: 6px;
  margin: 0 0 12px;
}
.pack-add-person input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.85rem;
}
.pack-add-person button { flex-shrink: 0; cursor: pointer; }
.pack-person-block { margin-bottom: 16px; }
.pack-person-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: var(--ink);
  font-size: 1.02rem;
  padding: 4px 2px 8px;
  border-bottom: 2px solid var(--teal);
  margin-bottom: 8px;
}
.pack-person-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.pack-add {
  display: flex;
  gap: 8px;
  margin: 4px 0 10px;
}
.pack-add input {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
}
.pack-add input:focus { outline: 2px solid var(--teal); border-color: transparent; }
.pack-add select {
  flex-shrink: 0;
  max-width: 38%;
  padding: 11px 8px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
}
.pack-add button {
  flex-shrink: 0;
  width: 46px;
  border: none;
  border-radius: 10px;
  background: var(--teal);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.pack-tpls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
}
.pack-tpls-label {
  font-size: 0.78rem;
  color: var(--muted);
  width: 100%;
}
.pack-tpls-hint { opacity: 0.8; font-weight: 400; }
.pack-tpl { cursor: pointer; }
.pack-tpl-edit {
  cursor: pointer;
  border-style: dashed;
  color: var(--teal-dark);
}

/* quick-add list editor */
.tpl-intro { margin: -6px 0 14px; font-size: 0.82rem; color: var(--muted); }
#tpl-editor { display: flex; flex-direction: column; gap: 14px; }
.tpl-list {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}
.tpl-list-head { display: flex; gap: 8px; align-items: center; }
.tpl-list-head .tpl-icon {
  flex-shrink: 0;
  width: 46px;
  text-align: center;
  margin-top: 0;
  background: var(--card);
}
.tpl-list-head .tpl-label {
  flex: 1;
  min-width: 0;
  margin-top: 0;
  font-weight: 600;
  background: var(--card);
}
.tpl-list-del {
  flex-shrink: 0;
  width: 40px;
  align-self: stretch;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  color: var(--danger);
  cursor: pointer;
}
.tpl-items { margin: 10px 0; display: flex; flex-direction: column; gap: 7px; }
.tpl-item { display: flex; gap: 7px; align-items: center; }
.tpl-item .tpl-item-label { flex: 1; min-width: 0; margin-top: 0; background: var(--card); font-size: 0.92rem; padding: 9px 10px; }
.tpl-item .tpl-item-cat {
  flex-shrink: 0;
  max-width: 38%;
  margin-top: 0;
  background: var(--card);
  font-size: 0.85rem;
  padding: 9px 8px;
}
.tpl-item-del {
  flex-shrink: 0;
  width: 34px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 9px;
  color: var(--danger);
  cursor: pointer;
}
.tpl-item-add { margin: 0; padding: 9px; font-size: 0.85rem; }
#tpl-add-list { margin-top: 14px; }
.tpl-restore {
  margin-top: 8px;
  border-style: solid;
  border-color: var(--border);
  color: var(--muted);
}
.pack-progress { margin-bottom: 12px; }
.pack-bar {
  height: 9px;
  border-radius: 5px;
  background: var(--bg);
  overflow: hidden;
}
.pack-bar-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 5px;
  transition: width 0.3s ease;
}
.pack-progress-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 5px;
  font-weight: 600;
}
.pack-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-top: 1px solid var(--border);
  cursor: pointer;
}
.pack-row:first-of-type { border-top: none; }
.pack-check { font-size: 1.05rem; flex-shrink: 0; }
.pack-label { flex: 1; min-width: 0; font-size: 0.92rem; overflow-wrap: anywhere; }
.pack-row.is-packed .pack-label { text-decoration: line-through; color: var(--muted); }
.pack-move {
  flex-shrink: 0;
  max-width: 36%;
  font-size: 0.78rem;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}
.pack-del {
  flex-shrink: 0;
  border: none;
  background: none;
  font-size: 0.9rem;
  cursor: pointer;
  opacity: 0.6;
}

/* type selector */
.type-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.type-toggle button {
  flex: 1 1 28%;
  border: 1px solid var(--border);
  background: var(--card);
  padding: 9px 6px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.type-toggle button.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

/* search */
.search-wrap { position: relative; margin-bottom: 14px; }
.search-wrap input {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.search-results { margin-top: 6px; }
.search-result {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  cursor: pointer;
}
.search-result:active { background: var(--bg); }
.search-result .sr-name { font-weight: 600; }
.search-result .sr-addr { color: var(--muted); font-size: 0.78rem; margin-top: 1px; }
.search-hint { color: var(--muted); font-size: 0.82rem; padding: 8px 2px; }

.picked-summary {
  background: #ccfbf1;
  color: var(--teal-dark);
  font-size: 0.82rem;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.picked-summary:has(.picked-clear) {
  display: flex;
  align-items: center;
  gap: 8px;
}
.picked-summary .picked-text {
  flex: 1;
  min-width: 0;
}
.picked-clear {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0.75;
}
.picked-clear:hover {
  opacity: 1;
}
.change-loc-btn {
  background: none;
  border: none;
  color: var(--teal-dark);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 2px 0 12px;
  cursor: pointer;
}

/* toast */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 92px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 1200;
  box-shadow: var(--shadow);
  white-space: nowrap;
}

/* map marker */
.poi-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  background: var(--card);
  border: 2px solid var(--teal);
  border-radius: 50% 50% 50% 4px;
  box-shadow: var(--shadow);
}
.poi-marker.restaurant { border-color: var(--coral); }
.leaflet-popup-content { margin: 12px 14px; }
.popup-name { font-weight: 700; margin-bottom: 8px; }
.popup-actions { display: flex; gap: 6px; }
.popup-actions a {
  text-decoration: none;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
}

/* slightly roomier on tablets/desktop */
@media (min-width: 700px) {
  .trips-list, .places-list { max-width: 820px; margin: 0 auto; width: 100%; }
  .sheet { max-width: 560px; margin: 0 auto; border-radius: 20px; margin-bottom: 24px; }
  .sheet-backdrop { align-items: center; }
}

/* ===== Drag-to-reorder + day route ===== */
.day-stops { display: flex; flex-direction: column; }
.drag-handle {
  flex: 0 0 auto;
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--muted);
  cursor: grab;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 6px 2px 0;
  margin-top: 2px;
  touch-action: none; /* let the pointer drag instead of scrolling the page */
}
.drag-handle:active { cursor: grabbing; }
.place-card.drag-source, .trip-card.drag-source { opacity: 0.35; }
/* on a trip card the grip sits centered at the left edge */
.trip-card .trip-drag {
  align-self: center;
  margin-top: 0;
  padding: 2px 2px 2px 0;
}
/* when the grip is showing (logged in), a photo no longer bleeds to the very
   left edge — it sits just after the handle, still spanning the card height */
body.authed .trip-card .trip-icon-slot.has-img { margin-left: 0; }
.drag-clone {
  position: fixed;
  z-index: 1200;
  margin: 0;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
  transform: scale(1.02);
  opacity: 0.96;
}
body.dragging-active { user-select: none; -webkit-user-select: none; }

.day-route-map.active {
  background: var(--teal);
  border-color: var(--teal);
}
.route-num-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.3);
}

/* ===== Trip countdown banner ===== */
.trip-countdown {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 7px 12px;
  letter-spacing: 0.01em;
}
.trip-countdown.upcoming { background: #ccfbf1; color: var(--teal-dark); }
.trip-countdown.active { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: #fff; }
.trip-countdown.past { background: var(--bg); color: var(--muted); }

/* ===== Weather strip (Schedule tab) ===== */
.weather-strip { padding: 6px 10px; }
.weather-strip:empty { display: none; }
.wx-bar { display: flex; align-items: center; gap: 4px; }
.wx-days {
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}
.wx-days::-webkit-scrollbar { display: none; }
.wx-toggle {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 4px 6px;
}

/* compact one-line mode */
.wx-days.compact { gap: 16px; align-items: center; }
.wx-mini { flex: 0 0 auto; font-size: 0.82rem; white-space: nowrap; }
.wx-mini b { font-weight: 700; color: var(--muted); margin-right: 4px; }
.wx-mini .hi { font-weight: 600; color: var(--ink); margin-left: 3px; }
.wx-mini .sep { color: var(--border); margin: 0 1px; }
.wx-mini .lo { color: var(--muted); }
.wx-mini.is-today b { color: var(--teal-dark); }

/* expanded card mode */
.wx-days.expanded { gap: 8px; padding-top: 2px; }
.wx-card {
  flex: 0 0 auto;
  min-width: 64px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 6px;
  text-align: center;
  box-shadow: var(--shadow);
}
.wx-card.is-today { border-color: var(--teal); background: #f0fdfa; }
.wx-day { font-size: 0.68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.wx-icon { font-size: 1.35rem; line-height: 1.5; }
.wx-temp { font-size: 0.78rem; font-weight: 600; color: var(--ink); }
.wx-temp .lo { color: var(--muted); font-weight: 500; }
.wx-pop { font-size: 0.62rem; color: var(--teal-dark); }
.wx-note { color: var(--muted); font-size: 0.8rem; padding: 4px 4px 0; }

/* ===== Budget: travelers + settle-up ===== */
.travelers-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.traveler-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 0.82rem;
}
.traveler-chip button {
  border: none; background: none; cursor: pointer; color: var(--muted);
  font-size: 0.95rem; line-height: 1; padding: 0 2px;
}
.traveler-chip button:hover { color: var(--danger); }
.traveler-add { display: flex; gap: 6px; margin-top: 8px; align-items: stretch; }
.traveler-add input {
  flex: 1; min-width: 0; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 10px; font-size: 0.85rem;
}
/* the shared .btn-outline is a full-width dashed CTA; here it's just a small
   submit beside the input, so keep it compact and aligned with the field */
.traveler-add .btn-outline {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
  padding: 8px 18px;
  font-size: 0.85rem;
  border-radius: 10px;
  border-width: 1.5px;
}
.settle-body { padding: 4px 12px 12px; }
.settle-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem;
}
.settle-row:last-child { border-bottom: none; }
.settle-person { display: flex; flex-direction: column; gap: 1px; }
.settle-name { font-weight: 600; }
.settle-detail { font-size: 0.72rem; color: var(--muted); }
.settle-status { font-weight: 700; flex-shrink: 0; }
.settle-pos { color: var(--teal-dark); }
.settle-neg { color: var(--coral); }
.settle-even { color: var(--muted); }

.settle-sub-head {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
  margin: 14px 0 4px;
}
.settle-transfers, .settle-payments { display: flex; flex-direction: column; }
.settle-transfer, .settle-payment {
  font-size: 0.88rem; color: var(--ink); padding: 8px 0;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border);
}
.settle-transfer:last-child, .settle-payment:last-child { border-bottom: none; }
.settle-tx-text, .settle-pay-text { min-width: 0; }
.settle-transfer .amt, .settle-payment .amt { margin-left: auto; font-weight: 700; flex-shrink: 0; }
.settle-pay-btn {
  flex-shrink: 0;
  background: var(--teal); color: #fff; border: none;
  border-radius: 999px; padding: 6px 12px; font-size: 0.78rem; font-weight: 600;
  cursor: pointer;
}
.settle-pay-btn:active { background: var(--teal-dark); }
.settle-pay-form {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto; flex-shrink: 0;
}
.settle-pay-form input {
  width: 84px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  text-align: right;
}
.settle-pay-cancel {
  border: none; background: none; cursor: pointer;
  color: var(--muted); font-size: 0.95rem; line-height: 1; padding: 2px 4px;
}
.settle-payment .settle-pay-text { color: var(--muted); }
.settle-done { color: var(--teal-dark); font-weight: 600; margin-top: 10px; }

/* split fields inside the expense sheet */
.split-fields { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; }
.split-with-list { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; }
.split-with-list label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.85rem; font-weight: 400;
}
.split-with-list input { width: auto; }

.split-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.split-mode-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.split-mode-toggle button {
  border: none; background: var(--card); color: var(--muted);
  font-size: 0.8rem; font-weight: 600; padding: 5px 12px; cursor: pointer;
}
.split-mode-toggle button.active { background: var(--teal); color: #fff; }
.split-custom { margin-top: 6px; }
.split-custom-row {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0; border-bottom: 1px solid var(--border);
}
.split-custom-row:last-child { border-bottom: none; }
.split-custom-name { flex: 1; font-size: 0.9rem; }
.split-fields .split-custom-amt {
  width: 100px; flex-shrink: 0; margin-top: 0;
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.9rem; text-align: right;
}
.split-shares-row {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0; border-bottom: 1px solid var(--border);
}
.split-shares-row:last-child { border-bottom: none; }
.split-fields .split-shares-amt {
  width: 60px; flex-shrink: 0; margin-top: 0;
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.9rem; text-align: center;
}
.split-share-preview {
  width: 80px; flex-shrink: 0; text-align: right;
  font-size: 0.82rem; font-weight: 600; color: var(--teal-dark);
}
.split-remaining { margin-top: 8px; font-size: 0.8rem; font-weight: 600; }
.split-remaining.ok { color: var(--teal-dark); }
.split-remaining.off { color: var(--coral); }
