:root {
  --lavender: #B8B5D6;
  --lavender-deep: #8D89B8;
  --sage: #9CAF88;
  --sage-deep: #74875F;
  --blush: #E8C4C4;
  --champagne: #D4AF7A;
  --champagne-deep: #B48F5C;
  --bg: #FAF8F5;
  --card: #FFFFFF;
  --ink: #3A362F;
  --ink-soft: #837C6E;
  --line: #E9E4DB;
  --shadow: 0 2px 14px rgba(58, 54, 47, 0.08);
  color-scheme: light only;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Noto Sans TC', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
  font-family: 'Noto Serif TC', serif;
  margin: 0;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 84px;
  position: relative;
}

/* ---------- 頂部航班區 ---------- */
.flight-header {
  background: linear-gradient(160deg, var(--lavender) 0%, var(--lavender-deep) 100%);
  padding: env(safe-area-inset-top, 16px) 0 18px;
  color: white;
}
.flight-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px 10px;
}
.app-title {
  font-size: 20px;
  font-weight: 700;
  color: white;
}
.countdown-badge {
  background: rgba(255,255,255,0.22);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
}
.boarding-pass-scroller {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 18px 4px;
  scroll-snap-type: x mandatory;
}
.boarding-pass {
  scroll-snap-align: start;
  flex: 0 0 auto;
  width: 250px;
  background: rgba(255,255,255,0.96);
  color: var(--ink);
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
  transition: transform .15s ease;
}
.boarding-pass:active { transform: scale(0.97); }
.boarding-pass .flight-no {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  background: var(--champagne);
  color: white;
  padding: 2px 8px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.boarding-pass .route {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'Noto Serif TC', serif;
  font-size: 24px;
  font-weight: 700;
}
.boarding-pass .route .arrow { color: var(--ink-soft); font-size: 15px; }
.boarding-pass .cities {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.boarding-pass .datetime {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
}
.boarding-pass .date-sub { font-size: 10px; color: var(--ink-soft); font-weight: 400; }

.boarding-pass-detail { font-size: 14px; line-height: 1.9; }
.boarding-pass-detail .row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--line); }

.header-weather {
  margin: 6px 18px 0;
  background: rgba(255,255,255,0.96);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
  cursor: pointer;
}
.header-weather .hw-left { display: flex; align-items: center; gap: 10px; }
.header-weather .hw-emoji { font-size: 26px; }
.header-weather .hw-temp { font-family: 'Noto Serif TC', serif; font-size: 20px; font-weight: 700; }
.header-weather .hw-city { font-size: 12px; color: var(--ink-soft); }
.header-weather .hw-hint { font-size: 11.5px; color: var(--ink-soft); }
.header-weather .hw-cities { display: flex; gap: 4px; }
.header-weather .hw-city-btn {
  border: none; background: var(--bg); color: var(--ink-soft); font-size: 11px;
  padding: 4px 8px; border-radius: 999px; font-family: inherit;
}
.header-weather .hw-city-btn.active { background: var(--champagne); color: white; }

.weather-modal-content .weather-hourly { display: flex; overflow-x: auto; gap: 14px; padding: 4px 2px 10px; }
.weather-modal-content .weather-hour { flex: 0 0 auto; text-align: center; font-size: 12.5px; color: var(--ink-soft); }
.weather-modal-content .weather-hour .h-temp { font-weight: 700; color: var(--ink); font-size: 14px; margin: 4px 0; }
.weather-modal-content .weather-days { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.weather-modal-content .weather-day-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg); border-radius: 12px; padding: 10px 14px; font-size: 14px;
}

.caution-box {
  background: var(--card);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--champagne);
}
.caution-box h3 { font-size: 15px; margin-bottom: 10px; }
.caution-box ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.caution-box li { font-size: 13.5px; line-height: 1.6; color: var(--ink); }

/* ---------- 主內容 ---------- */
#mainContent { padding: 18px 16px 8px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from{opacity:0; transform:translateY(4px);} to{opacity:1; transform:none;} }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}
.panel-head h2 { font-size: 21px; }

/* ---------- 按鈕 ---------- */
.btn-primary, .btn-secondary {
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary { background: var(--sage); color: white; }
.btn-primary:active { background: var(--sage-deep); }
.btn-secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); display: inline-block; text-align: center; }
.btn-full { width: 100%; margin-bottom: 14px; }

/* ---------- 清單 ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  background: var(--card);
  border-radius: 14px;
  padding: 13px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.list-item .check {
  width: 22px; height: 22px;
  border-radius: 7px;
  border: 2px solid var(--line);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  margin-top: 1px;
}
.list-item .check.checked { background: var(--sage); border-color: var(--sage); color: white; font-size: 13px; }
.list-item .item-body { flex: 1; min-width: 0; }
.list-item .item-title { font-weight: 600; font-size: 15px; }
.list-item .item-title.done { text-decoration: line-through; color: var(--ink-soft); }
.list-item .item-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.list-item .item-actions { display: flex; gap: 6px; }
.list-item .icon-btn {
  background: none; border: none; font-size: 16px; color: var(--ink-soft); cursor: pointer; padding: 4px;
}
.checklist-thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; flex-shrink: 0; cursor: pointer; }

/* ---------- 記帳 ---------- */
.expense-summary {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
  text-align: center;
}
.expense-summary .balance-line {
  font-family: 'Noto Serif TC', serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--champagne-deep);
}
.expense-summary .balance-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }
.rate-note { font-size: 12px; color: var(--ink-soft); margin-bottom: 14px; text-align: center; }

/* ---------- 人物切換 ---------- */
.person-toggle, .city-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.person-btn, .city-btn {
  flex: 1;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.person-btn.active, .city-btn.active { background: var(--lavender); border-color: var(--lavender); color: white; }

/* ---------- 卡片格 (備註/自駕) ---------- */
.card-grid { display: flex; flex-direction: column; gap: 12px; }
.note-card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.note-card img { width: 100%; border-radius: 10px; margin-top: 8px; cursor: pointer; display: block; }
.note-card .note-text { font-size: 14.5px; line-height: 1.6; white-space: pre-wrap; }
.note-card a.note-link { color: var(--sage-deep); font-weight: 600; word-break: break-all; }
.note-card .note-meta { font-size: 11.5px; color: var(--ink-soft); margin-top: 8px; }
.note-card .note-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- 天氣 ---------- */
.weather-today {
  background: linear-gradient(160deg, var(--champagne) 0%, var(--champagne-deep) 100%);
  color: white;
  border-radius: 16px;
  padding: 18px;
  text-align: center;
  margin-bottom: 14px;
}
.weather-today .temp-now { font-family: 'Noto Serif TC', serif; font-size: 40px; font-weight: 700; }
.weather-hourly { display: flex; overflow-x: auto; gap: 14px; padding: 4px 2px 10px; }
.weather-hour { flex: 0 0 auto; text-align: center; font-size: 12.5px; color: var(--ink-soft); }
.weather-hour .h-temp { font-weight: 700; color: var(--ink); font-size: 14px; margin: 4px 0; }
.weather-days { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.weather-day-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow);
  font-size: 14px;
}

/* ---------- 住宿 ---------- */
.stay-card { background: var(--card); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.stay-card .stay-date { font-size: 12.5px; color: var(--champagne-deep); font-weight: 700; }
.stay-card .stay-name { font-family: 'Noto Serif TC', serif; font-size: 17px; margin: 4px 0; }
.stay-card .stay-area { font-size: 13px; color: var(--ink-soft); }
.stay-card .stay-address { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }
.status-pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; margin-top: 8px; }
.status-pill.booked { background: #E4EFDD; color: var(--sage-deep); }
.status-pill.pending { background: #F5E3D6; color: var(--champagne-deep); }
.stay-photos { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; }
.stay-photos img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; flex-shrink: 0; cursor: pointer; }
.stay-note { font-size: 13px; margin-top: 10px; white-space: pre-wrap; color: var(--ink); background: var(--bg); border-radius: 10px; padding: 10px; }
.stay-actions { display: flex; gap: 8px; margin-top: 12px; }
.candidate-block { margin-top: 26px; }
.candidate-block h3 { font-size: 15px; margin-bottom: 10px; color: var(--ink-soft); }

/* ---------- 地圖 ---------- */
#mapContainer { height: 62vh; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }

/* ---------- 底部導覽 ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 560px;
  margin: 0 auto;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex;
  padding: 6px 2px calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
}
.nav-item {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: var(--ink-soft);
  padding: 6px 2px;
  font-family: inherit;
  cursor: pointer;
}
.nav-item .nav-icon { font-size: 19px; }
.nav-item.active { color: var(--lavender-deep); font-weight: 700; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(58,54,47,0.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg);
  width: 100%;
  max-width: 560px;
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  max-height: 88vh;
  overflow-y: auto;
  animation: slideUp .22s ease;
}
@keyframes slideUp { from{transform:translateY(24px); opacity:0;} to{transform:none; opacity:1;} }
.modal h3 { font-size: 18px; margin-bottom: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  background: white;
}
.field textarea { min-height: 80px; resize: vertical; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .btn-primary, .modal-actions .btn-secondary { flex: 1; padding: 12px; text-align: center; }
.split-options { display: flex; flex-wrap: wrap; gap: 6px; }
.split-options button {
  border: 1px solid var(--line); background: white; border-radius: 999px;
  padding: 6px 12px; font-size: 12.5px; font-family: inherit; cursor: pointer; color: var(--ink-soft);
}
.split-options button.active { background: var(--lavender); border-color: var(--lavender); color: white; }
.person-check-row { display: flex; gap: 14px; margin-top: 6px; font-size: 14px; }
.person-check-row label { display: flex; align-items: center; gap: 6px; }

.upload-progress-wrap { margin: 8px 0 4px; }
.upload-progress-bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.upload-progress-fill { height: 100%; width: 0%; background: var(--sage); transition: width .15s ease; }
.upload-progress-text { font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: white;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
  z-index: 200;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty-state { text-align: center; color: var(--ink-soft); font-size: 14px; padding: 40px 20px; }

.stay-map-icon { font-size: 22px; text-align: center; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3)); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
