:root {
  --teal: #0b5f5f;
  --teal-dark: #084949;
  --coral: #ff7a59;
  --sand: #faf6ef;
  --card: #ffffff;
  --ink: #22302e;
  --muted: #6b7a78;
  --line: #e7ded1;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--sand);
  color: var(--ink);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

/* ---------- Gate ---------- */
#gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--teal) 0%, #12908a 60%, #7fd1c0 100%);
}
#gate[hidden] { display: none; }
.gate-card {
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.gate-emoji { font-size: 44px; }
.gate-card h1 { margin: 8px 0 4px; font-size: 22px; }
#gate-form { display: flex; gap: 8px; margin-top: 12px; }
#gate-form input {
  flex: 1;
  padding: 12px;
  font-size: 16px;
  border: 2px solid var(--line);
  border-radius: 10px;
}
#gate-form button {
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--teal);
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
.error { color: #c0392b; font-weight: 600; }
.muted { color: var(--muted); }

/* ---------- App shell: desktop = plan left, map right ---------- */
#app { height: 100vh; height: 100dvh; }

@media (min-width: 900px) {
  #app {
    display: grid;
    grid-template-columns: 410px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "head map" "side map";
  }
  #topbar { grid-area: head; }
  #side { grid-area: side; overflow-y: auto; border-right: 1px solid var(--line); }
  #map-wrap { grid-area: map; position: relative; }
  #sheet { display: none !important; }
  #scrim { display: none !important; }
  #trip-map { height: 100%; }
}

@media (max-width: 899px) {
  #app { display: flex; flex-direction: column; height: auto; min-height: 100dvh; }
  #topbar { order: 0; }
  #map-wrap { order: 1; position: relative; height: 44vh; height: 44dvh; flex-shrink: 0; }
  #trip-map { height: 100%; }
  #side { order: 2; }
}

/* ---------- Top bar ---------- */
#topbar {
  background: linear-gradient(160deg, var(--teal) 0%, #12908a 70%, #53b8a8 100%);
  color: #fff;
  padding: 14px 18px;
  text-align: center;
}
.tb-title { font-weight: 800; font-size: 17px; }
.tb-sub { font-size: 13px; opacity: .92; margin-top: 2px; }
.sync-note {
  display: inline-block;
  margin: 8px 0 0;
  padding: 6px 12px;
  font-size: 12.5px;
  background: rgba(255,255,255,.18);
  border-radius: 999px;
}

/* ---------- Sidebar ---------- */
#side { background: var(--sand); padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 28px); }
#side-body { padding: 14px 14px 30px; max-width: 560px; margin: 0 auto; }
.ov-head h2 { margin: 4px 0 2px; font-size: 19px; }
.ov-head p { margin: 0 0 12px; font-size: 13.5px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 14px;
  box-shadow: 0 2px 10px rgba(11,95,95,.08);
  border: 1px solid var(--line);
}
.place-head { display: flex; align-items: flex-start; gap: 10px; }
.place-emoji { font-size: 34px; line-height: 1; }
.place-head h2 { margin: 0; font-size: 20px; }
.badge {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .4px;
  border-radius: 999px;
  color: #fff;
  background: var(--coral);
}
.badge.day { background: var(--teal); }

/* ---------- Overview summary cards (tappable) ---------- */
.sum-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  box-shadow: 0 2px 10px rgba(11,95,95,.08);
  transition: border-color .15s, transform .1s;
}
.sum-card:active { transform: scale(.99); }
.sum-card.sel { border-color: var(--coral); }
.sum-main { flex: 1; min-width: 0; }
.sum-main h3 { margin: 0; font-size: 17px; }
.sum-line { margin: 8px 0 2px; font-size: 13.5px; font-weight: 600; }
.sum-cta { margin: 2px 0 0; font-size: 13px; color: var(--teal); font-weight: 700; }

/* ---------- Stay math (Airbnb vs motels) ---------- */
.stay-math {
  margin: 14px 0;
  background: #f2f9f6;
  border: 1.5px solid #bfe3dc;
  border-radius: 14px;
  padding: 14px;
}
.stay-math h3 { margin: 0 0 10px; font-size: 16px; }
.stay-math h3 small { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.stay-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.stay-row .stay-left { display: flex; align-items: center; gap: 10px; }
.stay-ic { font-size: 24px; }
.stay-row b { display: block; font-size: 17px; }
.stay-row small { color: var(--muted); font-size: 12px; }
.stay-row .vs {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  background: var(--sand);
  border-radius: 999px;
  padding: 4px 10px;
}
.stay-verdict {
  margin-top: 10px;
  font-weight: 800;
  font-size: 14.5px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #e4f5e9;
  border: 1px solid #a9dcc0;
  color: #1c6b3a;
}
.stay-verdict small { display: block; font-weight: 400; color: #2c7a4b; font-size: 12.5px; margin-top: 2px; }
.stay-per { margin: 8px 0 0; font-size: 13px; font-weight: 700; }
.fine { margin: 6px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- Stats / blurb ---------- */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}
.stat {
  background: var(--sand);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}
.stat b { display: block; font-size: 15px; }
.stat span { color: var(--muted); font-size: 12px; }
.blurb { margin: 6px 0 0; font-size: 14px; color: var(--muted); }

/* ---------- Back button (desktop detail) ---------- */
.back {
  display: inline-block;
  margin-bottom: 10px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--teal);
  background: #fff;
  border: 1.5px solid var(--teal);
  border-radius: 999px;
  cursor: pointer;
}

/* ---------- Attendees ---------- */
.whos-in h3 { margin: 14px 0 8px; font-size: 15px; }
.attendee {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 4px;
  border-top: 1px solid var(--line);
  font-size: 15px;
}
.attendee .who { flex: 1; min-width: 0; }
.attendee .who small { display: block; color: var(--muted); font-size: 12px; }
.chip {
  flex-shrink: 0;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--teal);
  color: var(--teal);
  background: #fff;
}
.chip.wa { border-color: #25d366; color: #128c4b; }
.empty { color: var(--muted); font-size: 14px; margin: 4px 0 0; }

/* ---------- Tag form ---------- */
.tag-form { margin-top: 12px; padding-top: 12px; border-top: 2px dashed var(--line); }
.tag-form h3 { margin: 0 0 8px; font-size: 15px; }
.tag-form label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 3px; }
.tag-form input {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px;
  border: 2px solid var(--line);
  border-radius: 10px;
}
.tag-form input:focus { border-color: var(--teal); outline: none; }
.btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 13px;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  background: var(--coral);
  border: none;
  border-radius: 12px;
  cursor: pointer;
}
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .6; }

/* ---------- Transport panel ---------- */
.transport {
  margin-top: 12px;
  background: #eef7f5;
  border: 1.5px solid #bfe3dc;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
}
.transport h4 { margin: 0 0 6px; font-size: 15px; }
.transport ul { margin: 6px 0; padding-left: 18px; }
.transport li { margin-bottom: 8px; }
.transport a { color: var(--teal-dark); font-weight: 700; }
.fare-link {
  display: inline-block;
  margin-top: 2px;
  padding: 6px 12px;
  background: var(--teal);
  color: #fff !important;
  text-decoration: none;
  border-radius: 999px;
  font-size: 13px;
}
.est { color: var(--muted); font-size: 12.5px; }

/* ---------- Logistics / footer ---------- */
.logistics h2 { margin: 0 0 8px; font-size: 18px; }
.logistics ul { margin: 6px 0; padding-left: 18px; font-size: 14px; }
.logistics li { margin-bottom: 10px; }
#side-body footer { text-align: center; padding: 8px 16px 10px; font-size: 13px; }

/* ---------- Map ---------- */
#trip-map { background: #e8f0ee; z-index: 0; }
.map-pin {
  position: relative;
  font-size: 30px;
  line-height: 1;
  text-align: center;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.35));
  transition: transform .2s ease, opacity .2s ease;
  cursor: pointer;
}
.map-pin.dim { opacity: .4; }
.map-pin.active { transform: scale(1.4); }
.map-pin.active::after {
  content: '';
  position: absolute;
  left: 50%; top: 42%;
  width: 52px; height: 52px;
  margin: -26px 0 0 -26px;
  border: 3px solid var(--coral);
  border-radius: 50%;
  animation: pinping 1.3s ease-out infinite;
  pointer-events: none;
}
@keyframes pinping {
  from { transform: scale(.45); opacity: 1; }
  to { transform: scale(1.25); opacity: 0; }
}
.map-legend {
  position: absolute; left: 12px; bottom: 14px; z-index: 500;
  background: rgba(255,255,255,.92);
  border-radius: 999px; padding: 6px 12px;
  font-size: 12.5px; box-shadow: 0 2px 10px rgba(0,0,0,.15);
  pointer-events: none;
}

/* ---------- Mobile bottom sheet ---------- */
#scrim {
  position: fixed; inset: 0; z-index: 590;
  background: rgba(20, 30, 28, .38);
}
#scrim[hidden] { display: none; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 600;
  max-height: 78vh; max-height: 78dvh;
  background: var(--sand);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,.25);
  overflow-y: auto; padding: 8px 12px calc(env(safe-area-inset-bottom, 0px) + 24px);
  -webkit-overflow-scrolling: touch;
}
.sheet-grip {
  width: 44px; height: 5px; border-radius: 3px;
  background: rgba(0,0,0,.18); margin: 6px auto 4px;
}
#sheet-close {
  position: sticky; top: 0; float: right;
  width: 34px; height: 34px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.06);
  font-size: 15px; cursor: pointer; z-index: 2;
}
#sheet-body .card { box-shadow: none; margin-bottom: 10px; }

/* ---------- Activities ---------- */
.sect-title { margin: 16px 0 6px; font-size: 16px; }
.act-sub { font-weight: 700; margin: 10px 0 6px; color: #0e5f56; font-size: 14px; }
.act-list { display: flex; flex-direction: column; gap: 6px; }
.act-item {
  display: flex; gap: 9px; align-items: flex-start;
  background: #f7f3ea; border: 1px solid #e8ddc4;
  border-radius: 10px; padding: 8px 10px; font-size: 14px;
}
.act-ic { font-size: 18px; line-height: 1.3; }
.act-note { color: #6b5f4c; font-size: 13px; margin-top: 1px; }
.crew-item {
  background: #fff; border: 1px dashed #c9bfa8;
  border-radius: 10px; padding: 8px 10px; font-size: 14px; margin-bottom: 6px;
}
.crew-link { color: #0e5f56; font-weight: 600; font-size: 13px; white-space: nowrap; }
.kid-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  background: #e3f2ee; color: #0e5f56; border-radius: 20px; padding: 1px 8px; margin-left: 4px;
}
.kid-badge.local { background: #f0e6d2; color: #8a6d3b; }
.crew-empty { color: #8a7f6a; font-size: 13px; font-style: italic; margin: 4px 0 8px; }
.act-form {
  background: #f7f3ea; border: 1px solid #e8ddc4; border-radius: 12px;
  padding: 12px; margin-top: 8px; display: flex; flex-direction: column; gap: 8px;
}
.act-form h4 { margin: 0; font-size: 14px; }
.act-form input[type="text"] {
  width: 100%; padding: 9px 10px; border: 1px solid #d8ccb0; border-radius: 8px; font-size: 14px;
}
.kid-check { font-size: 14px; display: flex; align-items: center; gap: 6px; }
.act-hint { font-size: 13px; color: #8a6d3b; background: #fdf6e3; border-radius: 8px; padding: 8px; }

/* ---------- Drive planner ---------- */
.drive-planner label { display: block; font-size: 13px; font-weight: 600; margin: 8px 0 4px; color: #5c5344; }
.drive-planner input[type="text"], .drive-planner select {
  width: 100%; padding: 9px 10px; border: 1px solid #d8ccb0; border-radius: 8px;
  font-size: 14px; background: #fff;
}
.drive-planner .btn { margin-top: 10px; width: 100%; }
.drive-planner .btn:disabled { opacity: 0.6; }
.drive-msg {
  margin-top: 10px; font-size: 14px; background: #eef7f5;
  border: 1px solid #cbe5e0; border-radius: 10px; padding: 9px 10px;
}
.drive-msg button {
  margin-left: 6px; border: none; background: none; color: #0e5f56;
  font-weight: 700; cursor: pointer; font-size: 13px;
}

/* ---------- Drive planner: vehicle + POIs ---------- */
.veh-row { display: flex; gap: 6px; margin-top: 2px; }
.veh {
  flex: 1; border: 1px solid #d8ccb0; background: #fff; border-radius: 10px;
  padding: 8px 4px; font-size: 13px; cursor: pointer;
}
.veh.on { background: #0e5f56; color: #fff; border-color: #0e5f56; font-weight: 700; }
.poi-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.poi {
  border: 1px solid #cbe5e0; background: #fff; border-radius: 20px;
  padding: 5px 10px; font-size: 13px; cursor: pointer;
}
.poi.on { background: #0e7c72; color: #fff; border-color: #0e7c72; font-weight: 700; }
.poi-note { font-size: 12px; color: #8a7f6a; margin-top: 6px; }
.poi-loading { font-size: 13px; color: #6b5f4c; margin-top: 6px; font-style: italic; }
.poi-pin {
  width: 26px; height: 26px; border-radius: 50%; background: #fff;
  border: 2px solid #0e5f56; display: flex; align-items: center; justify-content: center;
  font-size: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.fine-inline { font-size: 12px; color: #8a7f6a; }

/* Trip dates picker */
.dates-card h2 { margin-bottom: 6px; }
.dates-row { display: flex; gap: 10px; }
.dates-row label { flex: 1; font-size: 13px; font-weight: 600; color: #5c5344; display: flex; flex-direction: column; gap: 4px; }
.dates-card input[type="date"] { padding: 8px; border: 1px solid #d8ccb0; border-radius: 8px; font-size: 14px; width: 100%; background: #fff; }
#dates-note { margin-top: 8px; font-size: 13px; }

/* Narrow phones: stack the date pickers instead of squeezing them */
@media (max-width: 560px) {
  .dates-row { flex-direction: column; }
  .dates-card input[type="date"] { padding: 12px 10px; font-size: 16px; }
}

/* Crew roster */
.crew-card h2 { margin-bottom: 4px; }
.crew-card h2 small { font-weight: 400; color: #8a7a5c; font-size: 13px; }
.travel-sum { font-size: 13px; color: #5c5344; margin: 2px 0 8px; }
.fam-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.fam-row { display: flex; flex-direction: column; gap: 6px; background: #fff; border: 1px solid #eee3cb; border-radius: 10px; padding: 8px; }
.fam-top { display: flex; gap: 6px; align-items: center; }
.fam-bottom { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fam-name { flex: 1; min-width: 0; padding: 7px 8px; border: 1px solid #d8ccb0; border-radius: 8px; font-size: 14px; font-weight: 600; }
.fam-ppl { display: flex; align-items: center; gap: 3px; font-size: 13px; font-weight: 700; color: #5c5344; white-space: nowrap; }
.fam-ppl input { width: 48px; padding: 7px 6px; border: 1px solid #d8ccb0; border-radius: 8px; font-size: 14px; }
.fam-from { flex: 1; min-width: 100px; padding: 7px 8px; border: 1px solid #d8ccb0; border-radius: 8px; font-size: 13px; }
.fam-travel, .fam-share { padding: 7px 6px; border: 1px solid #d8ccb0; border-radius: 8px; font-size: 13px; background: #fff; max-width: 130px; }
.fam-del { border: none; background: none; color: #b09a7a; font-size: 16px; cursor: pointer; padding: 4px 6px; }
.fam-del:hover { color: #a33; }
.btn-ghost { background: none; border: 1px dashed #c9b98f; border-radius: 8px; padding: 8px 12px; color: #7a6a4d; font-size: 14px; cursor: pointer; width: 100%; }
.btn-ghost:hover { background: #faf5e9; }

/* Editable house estimate */
.stay-row .edit-est { border: none; background: none; font-size: 16px; cursor: pointer; padding: 4px 6px; }
.house-edit { margin: 6px 0 10px; padding: 10px; background: #faf5e9; border-radius: 8px; }
.house-edit label { font-size: 13px; font-weight: 600; color: #5c5344; display: block; margin-bottom: 6px; }
.he-row { display: flex; gap: 8px; }
.he-row input { flex: 1; min-width: 0; padding: 8px; border: 1px solid #d8ccb0; border-radius: 8px; font-size: 15px; }
.he-row .btn { width: auto; margin: 0; padding: 8px 16px; }
.he-row .btn-ghost { width: auto; margin: 0; }

/* Real-listing proof links */
.proof { font-size: 12px; color: #6b5f4a; line-height: 1.7; margin-top: 10px; }
.proof a { color: #2a7a8a; }

/* Stay math: researched length comparison table */
.house-head { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.house-head b { font-size: 15px; }
.house-head .edit-est { margin-left: auto; }
.muted-sm { font-size: 12px; color: #8a7a5c; margin: 0 0 4px; }
.len-table { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 4px; }
.len-row { display: grid; grid-template-columns: 30px 1fr 1fr 1fr auto; gap: 6px; align-items: center; background: #fff; border: 1px solid #eee3cb; border-radius: 8px; padding: 7px 9px; font-size: 13px; }
.len-row.len-head { background: none; border: none; font-size: 11px; color: #8a7a5c; padding: 0 9px; }
.len-row.sel { border-color: var(--teal); background: #eef7f5; }
.len-n { font-weight: 800; }
.len-t { font-weight: 700; }
.len-tags { display: flex; gap: 4px; }
.len-tag { font-size: 10px; font-weight: 700; background: var(--teal); color: #fff; border-radius: 20px; padding: 2px 8px; white-space: nowrap; }
.len-tag.best { background: #b8860b; }
.len-best { font-size: 13px; font-weight: 600; color: #5c5344; margin: 6px 0 2px; }

/* Crew: compact one-line family rows */
.fam-compact { flex-direction: row; align-items: center; gap: 6px; padding: 6px; }
.fam-expand { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; background: none; border: none; padding: 6px 8px; font-size: 14px; text-align: left; cursor: pointer; color: inherit; font-family: inherit; }
.fam-expand:active { opacity: 0.6; }
.fam-cname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.fam-cak { font-weight: 700; color: #8a6d2f; font-size: 12px; background: #faf3e3; border-radius: 12px; padding: 2px 8px; white-space: nowrap; }
.fam-cfrom { font-size: 12px; color: #8a7a5c; font-weight: 700; white-space: nowrap; }
.fam-cmode { margin-left: auto; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fam-done { border: 1px solid #d8ccb0; background: #eef7f5; color: var(--teal); font-size: 16px; font-weight: 700; border-radius: 8px; padding: 5px 10px; cursor: pointer; }
