/* ── Google Places Autocomplete dropdown ──────────────────────────── */
.pac-container {
  z-index: 9999 !important;   /* above Bootstrap offcanvas (z-index 1045) */
  border-radius: 10px;
  border: 1.5px solid var(--border, #E8DDD0);
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  font-family: inherit;
  font-size: 14px;
  margin-top: 4px;
}
.pac-item { padding: 8px 12px; cursor: pointer; }
.pac-item:hover { background: #FAF6F0; }
.pac-item-query { color: var(--text, #1C0A0A); font-weight: 600; }

/* ── Bootstrap override ───────────────────────────────────────────── */
button, input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
.btn:focus-visible { box-shadow: none; }
.form-control:focus, .form-select:focus {
  border-color: var(--purple1);
  box-shadow: 0 0 0 3px rgba(192,57,43,.08);
}

/* ── App button theme (override Bootstrap defaults) ───────────────── */
/* 儲存 / 建立 → 深色漸層（品牌色） */
.btn-primary {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 10px;
}
.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(135deg, #141d4a 0%, #a02f22 100%);
  border-color: transparent;
  color: #fff;
}
/* 刪除 → 淡紅底 深紅字 */
.btn-danger {
  background: #fde8e8;
  border-color: #f5c2c2;
  color: #b91c1c;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 10px;
}
.btn-danger:hover, .btn-danger:focus {
  background: #fbd5d5;
  border-color: #f09898;
  color: #991b1b;
}
/* 次要 / 取消 → 灰底 */
.btn-secondary {
  background: #f3ede8;
  border-color: var(--border, #E8DDD0);
  color: var(--muted, #9E8070);
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 10px;
}
.btn-secondary:hover {
  background: #ece4dc;
  border-color: #d4c8bc;
  color: var(--text, #1C0A0A);
}

/* ── reset & base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple1: #C0392B;
  --purple2: #7B1818;
  --grad: linear-gradient(135deg, #1B2860 0%, #C0392B 100%);
  --bg: #FAF6F0;
  --card: #FFFFFF;
  --text: #1C0A0A;
  --muted: #9E8070;
  --border: #EAD5C0;
  --radius: 14px;
  --shadow: 0 2px 16px rgba(198,40,40,.10);
  --nav-h: 62px;
  --header-h: 112px;
}

html, body {
  height: 100%;
  font-family: 'Hiragino Mincho ProN', 'Yu Mincho', 'Noto Serif CJK TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

/* ── header ───────────────────────────────────────────────────────── */
#app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--grad);
  padding: 14px 16px 10px;
  color: #fff;
  overflow: hidden;
}
#app-header::before {
  content: '🌸 　　　　🌸 　　　　🌸 　　　　🌸';
  position: absolute; top: 2px; left: 0; right: 0;
  font-size: 11px; letter-spacing: 6px;
  opacity: .18; pointer-events: none; white-space: nowrap;
}
#app-header h1 { font-size: 20px; font-weight: 700; letter-spacing: 2px; }
#trip-selector {
  margin-top: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: none;
  background: rgba(255,255,255,.22);
  color: #fff;
  font-size: 14px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23fff' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
#trip-selector option { color: #333; background: #fff; }

/* ── main content ─────────────────────────────────────────────────── */
#main {
  padding-top: var(--header-h);
  padding-bottom: calc(var(--nav-h) + 16px);
  min-height: 100%;
}

/* ── views ────────────────────────────────────────────────────────── */
.view { display: none; padding: 12px 14px; }
.view.active { display: block; }

/* ── day group ────────────────────────────────────────────────────── */
.day-group { margin-bottom: 10px; }
.day-label {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  font-size: 13px; font-weight: 700;
  color: var(--purple2); letter-spacing: 1px;
  padding: 10px 12px;
  border-left: 3px solid var(--purple1);
  background: linear-gradient(90deg, rgba(192,57,43,.09), transparent);
  border-radius: 0 8px 8px 0;
  user-select: none;
  -webkit-user-select: none;
}
.day-label-left { display: flex; align-items: center; gap: 10px; }
.day-badge {
  font-size: 11px; font-weight: 800; letter-spacing: 0;
  background: var(--purple1); color: #fff;
  padding: 2px 8px; border-radius: 20px;
}
.day-chevron {
  font-size: 12px; color: var(--purple1);
  transition: transform .2s;
}
.day-group.collapsed .day-chevron { transform: rotate(-90deg); }
.day-items { overflow: hidden; transition: max-height .25s ease; }
.day-group.collapsed .day-items { max-height: 0 !important; }
.day-add-btn {
  width: 100%; padding: 8px; margin-top: 4px; margin-bottom: 2px;
  border: 1.5px dashed var(--purple2); border-radius: var(--radius);
  background: transparent; color: var(--purple2);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.day-add-btn:active { background: rgba(99,44,144,.08); }

/* ── drag handle ─────────────────────────────────────────────────── */
.drag-handle {
  flex-shrink: 0; cursor: grab; color: var(--border);
  font-size: 16px; padding: 2px 4px 2px 0; line-height: 1;
  touch-action: none;
}
.drag-handle:active { cursor: grabbing; }
.sortable-ghost { opacity: .35; background: rgba(192,57,43,.06); }
.sortable-drag { box-shadow: 0 8px 24px rgba(0,0,0,.18) !important; }

/* ── time inline edit ─────────────────────────────────────────────── */
.item-time { cursor: pointer; }
.item-time:hover { text-decoration: underline dotted; }
.time-popover {
  position: fixed; z-index: 500;
  background: #fff; border-radius: 12px;
  padding: 10px 12px; box-shadow: 0 4px 20px rgba(0,0,0,.18);
  display: flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--border);
}
.time-popover input[type=time] {
  border: 1.5px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 15px; outline: none;
  color: var(--text); font-family: inherit;
}
.time-popover input[type=time]:focus { border-color: var(--purple1); }
.time-popover-save {
  background: var(--purple1); color: #fff;
  border: none; border-radius: 8px; padding: 6px 12px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}

/* ── itinerary card ───────────────────────────────────────────────── */
.item-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  -webkit-user-select: none; user-select: none;
}
.item-card:active { transform: scale(.98); box-shadow: none; }

.item-check {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
  transition: background .15s, border-color .15s;
}
.item-card.done .item-check { background: var(--grad); border-color: transparent; }
.item-check svg { display: none; }
.item-card.done .item-check svg { display: block; }

.item-body { flex: 1; min-width: 0; }
.item-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.item-time { font-size: 12px; color: var(--purple1); font-weight: 600; white-space: nowrap; }
.item-type-badge {
  font-size: 11px; padding: 1px 7px; border-radius: 20px;
  background: rgba(102,126,234,.1); color: var(--purple2); white-space: nowrap;
}
.item-name {
  font-size: 15px; font-weight: 600; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-card.done .item-name { text-decoration: line-through; color: var(--muted); }
.item-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 5px; }
.item-cost { font-size: 12px; color: var(--purple2); font-weight: 600; }
.maps-link {
  font-size: 11px; color: var(--purple1); text-decoration: none;
  padding: 3px 8px; border: 1px solid var(--purple1); border-radius: 20px;
  white-space: nowrap;
}

/* ── empty state ──────────────────────────────────────────────────── */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .emoji { font-size: 48px; margin-bottom: 12px; }
.empty p { font-size: 14px; }

/* ── expenses ─────────────────────────────────────────────────────── */
.expense-summary {
  background: var(--grad);
  border-radius: var(--radius);
  padding: 18px 16px;
  color: #fff;
  margin-bottom: 14px;
}
.expense-summary h2 { font-size: 13px; opacity: .85; font-weight: 500; }
.expense-total-jpy { font-size: 32px; font-weight: 800; margin: 4px 0 2px; }
.expense-total-twd { font-size: 13px; opacity: .8; }
.rate-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px; flex-wrap: wrap;
}
.rate-input {
  width: 80px; padding: 5px 8px; border-radius: 8px; border: none;
  font-size: 14px; font-weight: 600; text-align: center;
  background: rgba(255,255,255,.2); color: #fff;
  outline: none;
}
.rate-input:focus { background: rgba(255,255,255,.35); }
.rate-btn {
  padding: 5px 10px; border-radius: 8px; border: none; cursor: pointer;
  font-size: 12px; font-weight: 600;
  background: rgba(255,255,255,.2); color: #fff;
  transition: background .15s;
}
.rate-btn:active { background: rgba(255,255,255,.35); }
.rate-live-badge { font-size: 11px; opacity: .75; margin-left: 2px; }

.category-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.cat-chip {
  padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--card); color: var(--purple2); box-shadow: var(--shadow);
}
.cat-chip span { color: var(--muted); font-weight: 400; }

.section-title {
  font-size: 12px; font-weight: 700; color: var(--purple1);
  letter-spacing: .6px; text-transform: uppercase;
  margin-bottom: 8px; padding-left: 4px;
}

.expense-card {
  background: var(--card); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow);
  display: flex; justify-content: space-between; align-items: center;
}
.expense-card-left .exp-name { font-size: 14px; font-weight: 600; }
.expense-card-left .exp-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.expense-card-right { text-align: right; }
.exp-jpy { font-size: 16px; font-weight: 700; color: var(--purple2); }
.exp-twd { font-size: 11px; color: var(--muted); }

/* ── checklist view ──────────────────────────────────────────────── */
.checklist-category { margin-bottom: 14px; }
.checklist-cat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px 8px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none; -webkit-user-select: none;
}
.checklist-cat-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: #fff;
}
.checklist-cat-count {
  font-size: 11px; background: rgba(255,255,255,.25);
  padding: 1px 7px; border-radius: 12px; color: #fff;
}
.checklist-cat-chevron { color: rgba(255,255,255,.8); font-size: 11px; transition: transform .2s; }
.checklist-category.collapsed .checklist-cat-chevron { transform: rotate(-90deg); }
.checklist-cat-items { overflow: hidden; transition: max-height .2s ease; }
.checklist-category.collapsed .checklist-cat-items { max-height: 0 !important; }

.checklist-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--card); border-radius: 10px;
  margin-bottom: 5px; box-shadow: var(--shadow);
}
.checklist-cb {
  flex-shrink: 0; width: 20px; height: 20px;
  border-radius: 6px; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s;
}
.checklist-item.done .checklist-cb {
  background: var(--purple1); border-color: var(--purple1);
}
.checklist-cb svg { display: none; }
.checklist-item.done .checklist-cb svg { display: block; }
.checklist-item-text {
  flex: 1; font-size: 14px; cursor: pointer;
}
.checklist-item.done .checklist-item-text {
  text-decoration: line-through; color: var(--muted);
}
.checklist-item-del {
  flex-shrink: 0; color: var(--border); font-size: 16px;
  cursor: pointer; padding: 2px 4px; line-height: 1;
  transition: color .15s;
}
.checklist-item-del:hover { color: #C0392B; }

.checklist-add-row {
  display: flex; gap: 8px; margin-top: 6px;
}
.checklist-add-input {
  flex: 1; padding: 8px 12px; border-radius: 10px;
  border: 1.5px dashed var(--border); font-size: 13px;
  color: var(--text); background: transparent; outline: none;
  font-family: inherit;
}
.checklist-add-input:focus { border-color: var(--purple1); border-style: solid; }
.checklist-add-btn {
  padding: 8px 14px; border-radius: 10px; border: none;
  background: var(--purple1); color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.checklist-progress {
  height: 4px; border-radius: 2px; background: var(--border);
  margin-bottom: 14px; overflow: hidden;
}
.checklist-progress-bar {
  height: 100%; border-radius: 2px;
  background: var(--grad); transition: width .3s;
}
.checklist-summary {
  text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 14px;
}

/* ── trips view ───────────────────────────────────────────────────── */
.trip-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.trip-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.trip-name { font-size: 17px; font-weight: 700; }
.trip-badge { font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 600; }
.badge-計畫中 { background: #FFF0F0; color: #C0392B; border: 1px solid #EFC8C8; }
.badge-確認   { background: #FFF8E7; color: #92660A; border: 1px solid #E8D5A0; }
.badge-完成   { background: #EFF6F0; color: #1B6B38; border: 1px solid #B8DFC4; }
.trip-dates { font-size: 13px; color: var(--muted); margin-top: 6px; }
.trip-info { display: flex; gap: 16px; margin-top: 10px; }
.trip-info-item { font-size: 12px; color: var(--muted); }
.trip-info-item strong { display: block; font-size: 14px; color: var(--text); font-weight: 600; }

.trip-card-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
}
.trip-action-btn {
  padding: 5px 14px; border-radius: 20px; font-size: 12px;
  font-weight: 600; border: none; cursor: pointer; transition: opacity .15s;
}
.trip-action-btn:active { opacity: .7; }
.trip-edit-btn { background: rgba(21,101,192,.1); color: #1565C0; }
.trip-delete-btn { background: #fee2e2; color: #b91c1c; }

/* ── FAB ──────────────────────────────────────────────────────────── */
#fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--nav-h) + 14px);
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  font-size: 28px;
  line-height: 54px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(118,75,162,.45);
  cursor: pointer;
  z-index: 200;
  transition: transform .15s;
}
#fab:active { transform: scale(.9); }

/* ── bottom nav ───────────────────────────────────────────────────── */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
}
.nav-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; cursor: pointer; color: var(--muted);
  font-size: 11px; font-weight: 500;
  transition: color .15s;
  border: none; background: none; padding: 0;
}
.nav-btn .nav-icon { font-size: 22px; line-height: 1; }
.nav-btn.active { color: var(--purple1); }


.modal-handle {
  width: 40px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 12px auto 4px;
}

/* ── per-day add button ───────────────────────────────────────────── */
.day-add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 16px;
  margin-top: 4px;
  background: none;
  border: 1.5px dashed var(--border, #E8DDD0);
  border-radius: 10px;
  color: var(--muted, #9E8070);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.day-add-btn:hover {
  background: rgba(192,57,43,.06);
  border-color: var(--purple1, #C0392B);
  color: var(--purple1, #C0392B);
}

/* ── modal footer button row ──────────────────────────────────────── */
.modal-footer-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border, #E8DDD0);
}
.modal-footer-row .btn { flex: none; min-width: 90px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg); border: none; cursor: pointer;
  font-size: 18px; display: flex; align-items: center; justify-content: center;
}

.modal-body { padding: 16px 18px; }


.btn-danger { background: #fee2e2; color: #b91c1c; }


/* ── loading spinner ──────────────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--purple1);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── toast ────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: calc(var(--nav-h) + 70px); left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #333; color: #fff; font-size: 13px;
  padding: 9px 18px; border-radius: 22px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 999; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── map view ─────────────────────────────────────────────────────── */
#view-map { padding: 0 !important; }
#map-container {
  height: calc(100vh - var(--header-h) - var(--nav-h));
  width: 100%;
  position: relative;
}
#gmap { width: 100%; height: 100%; position: absolute; top: 0; left: 0; }
.map-legend {
  position: absolute; bottom: 16px; left: 12px; z-index: 999;
  background: rgba(255,255,255,.92); border-radius: 10px;
  padding: 8px 12px; font-size: 11px; box-shadow: var(--shadow);
  max-width: 180px;
}
.legend-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.map-loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; color: var(--muted); gap: 12px;
  font-size: 13px;
}

.transit-label {
  background: rgba(21, 101, 192, 0.90);
  color: #fff; font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 12px; white-space: nowrap;
  box-shadow: 0 1px 5px rgba(0,0,0,.35); cursor: pointer;
  border: 1.5px solid rgba(255,255,255,.35); letter-spacing: .3px;
}
.transit-label:active { opacity: .8; }
.transit-label-walk { background: rgba(46, 125, 50, 0.90); pointer-events: none; cursor: default; }

.day-filter-bar {
  position: absolute; top: 8px; left: 50%;
  transform: translateX(-50%); z-index: 999;
  display: flex; gap: 4px;
  max-width: calc(100% - 20px); overflow-x: auto;
  padding: 5px 6px;
  background: rgba(255,255,255,.94);
  border-radius: 22px;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.day-filter-bar::-webkit-scrollbar { display: none; }
.day-chip {
  flex-shrink: 0; padding: 4px 11px; border-radius: 14px;
  font-size: 12px; font-weight: 600; border: none; cursor: pointer;
  background: transparent; transition: background .15s, color .15s;
  white-space: nowrap; display: flex; align-items: center; gap: 5px;
  -webkit-tap-highlight-color: transparent;
}

/* ── transit query button ─────────────────────────────────────────── */
.transit-query-btn {
  font-size: 11px; color: #1565C0;
  padding: 3px 9px; border: 1.5px solid #1565C0; border-radius: 20px;
  background: rgba(21,101,192,.08); white-space: nowrap;
  cursor: pointer; font-weight: 600; font-family: inherit;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.transit-query-btn:active { background: rgba(21,101,192,.2); }

/* ── map sidebar ──────────────────────────────────────────────────── */
#map-sidebar {
  position: absolute; top: 52px; left: 0; bottom: 0;
  z-index: 998; display: flex; pointer-events: none;
}
#map-sidebar-panel {
  width: 180px; background: rgba(255,255,255,.96);
  box-shadow: 2px 0 12px rgba(0,0,0,.15);
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform .25s cubic-bezier(.32,.72,0,1);
  pointer-events: all; overflow: hidden;
}
#map-sidebar.open #map-sidebar-panel { transform: translateX(0); }
#map-sidebar-toggle {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 28px; height: 52px;
  background: rgba(255,255,255,.96);
  border: none; border-radius: 0 10px 10px 0;
  box-shadow: 2px 0 8px rgba(0,0,0,.15);
  cursor: pointer; font-size: 14px; color: #555;
  display: flex; align-items: center; justify-content: center;
  pointer-events: all; transition: left .25s cubic-bezier(.32,.72,0,1);
  z-index: 1;
}
#map-sidebar.open #map-sidebar-toggle { left: 180px; }
#map-sidebar-title {
  font-size: 11px; font-weight: 700; color: var(--muted);
  padding: 10px 12px 6px; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}
#map-sidebar-list {
  overflow-y: auto; flex: 1;
  scrollbar-width: none;
}
#map-sidebar-list::-webkit-scrollbar { display: none; }
.sidebar-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-item:active, .sidebar-item.active { background: rgba(99,44,144,.08); }
.sidebar-num {
  width: 22px; height: 22px; border-radius: 50%;
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-info { min-width: 0; }
.sidebar-name {
  font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-time { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ── map bottom cards ─────────────────────────────────────────────── */
#map-spot-cards {
  position: absolute; bottom: 10px; left: 0; right: 0;
  z-index: 998; display: flex; gap: 8px;
  overflow-x: auto; padding: 4px 12px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
#map-spot-cards::-webkit-scrollbar { display: none; }
.spot-card {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.96); border-radius: 12px;
  padding: 8px 12px; box-shadow: 0 2px 10px rgba(0,0,0,.18);
  cursor: pointer; scroll-snap-align: start;
  min-width: 150px; max-width: 200px;
  transition: box-shadow .15s, transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.spot-card:active { transform: scale(.97); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.spot-card.active { box-shadow: 0 0 0 2px var(--purple1), 0 2px 10px rgba(0,0,0,.18); }
.spot-card-num {
  width: 26px; height: 26px; border-radius: 50%;
  color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.spot-card-body { min-width: 0; }
.spot-card-name {
  font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.spot-card-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ── transit bottom sheet ─────────────────────────────────────────── */


.transit-sheet-title {
  font-size: 16px; font-weight: 700;
}
.transit-sheet-subtitle {
  font-size: 12px; color: var(--muted); margin-top: 2px;
}

.transit-route-card {
  background: var(--bg); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px;
  border: 1.5px solid var(--border);
}
.transit-route-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 6px;
}
.transit-time-block { flex: 1; }
.transit-times {
  font-size: 19px; font-weight: 800; color: var(--text); line-height: 1.1;
}
.transit-duration-badge {
  font-size: 12px; font-weight: 600; color: var(--purple2);
  background: rgba(192,57,43,.1); padding: 3px 10px;
  border-radius: 12px; flex-shrink: 0; margin-left: 8px;
}
.transit-fare {
  font-size: 13px; font-weight: 700; color: var(--purple1); margin-top: 3px;
}
.transit-step {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 7px 0; border-top: 1px solid var(--border); margin-top: 4px;
}
.transit-step-icon {
  width: 26px; height: 26px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0; background: #1565C0; color: #fff;
}
.transit-step-info { flex: 1; min-width: 0; }
.transit-step-line { font-size: 13px; font-weight: 700; }
.transit-step-headsign { font-size: 11px; color: var(--muted); margin-top: 1px; }
.transit-step-stops { font-size: 11px; color: var(--muted); }

.transit-error {
  background: #FFF8E7; border-radius: 12px; padding: 14px;
  font-size: 13px; color: #92660A; line-height: 1.6;
  border: 1px solid #E8D5A0;
}
.transit-empty {
  text-align: center; padding: 30px 16px; color: var(--muted); font-size: 13px;
}

/* ── map bottom spot strip ────────────────────────────────────────── */
.map-spot-strip {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  gap: 10px;
  padding: 10px 14px calc(10px + var(--safe-bottom, 0px));
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(to top, rgba(0,0,0,.45) 0%, transparent 100%);
  z-index: 10;
  /* hide scrollbar */
  scrollbar-width: none;
}
.map-spot-strip::-webkit-scrollbar { display: none; }

.map-spot-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 150px;
  max-width: 200px;
  flex-shrink: 0;
  scroll-snap-align: start;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  border: 2px solid transparent;
  transition: border-color .15s, transform .15s;
}
.map-spot-card:active { transform: scale(.97); }
.map-spot-card.active { border-color: var(--purple1); }

.map-spot-card-body { overflow: hidden; }
.map-spot-card-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.map-spot-card-meta {
  font-size: 11px; color: var(--muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── scrollbar ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(192,57,43,.25); border-radius: 2px; }

/* ── washi texture overlay ────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Ccircle cx='30' cy='30' r='1' fill='%23C0392B' opacity='.04'/%3E%3Ccircle cx='10' cy='10' r='.8' fill='%23C0392B' opacity='.03'/%3E%3Ccircle cx='50' cy='10' r='.8' fill='%23C0392B' opacity='.03'/%3E%3C/svg%3E");
}

/* ── RWD & safe area ──────────────────────────────────────────────── */

/* iOS safe area (notch / home bar) */
:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}
#bottom-nav {
  padding-bottom: var(--safe-bottom);
  height: calc(var(--nav-h) + var(--safe-bottom));
}
#main {
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
}
#modal, #trip-modal, #expense-modal, #transit-sheet {
  padding-bottom: calc(34px + var(--safe-bottom));
}
/* override Bootstrap's fixed 30vh offcanvas-bottom height for all modals */
#modal, #trip-modal, #expense-modal, #transit-sheet {
  --bs-offcanvas-height: auto;
}
#fab {
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 14px);
}

/* ── tablet / desktop (≥600px) ───────────────────────────────────── */
@media (min-width: 600px) {
  :root {
    --header-h: 80px;
    --nav-h: 62px;
  }

  /* 內容置中 + 限寬 */
  #app-header { padding: 14px 24px 12px; }
  #app-header h1 { display: inline; margin-right: 16px; }
  #app-header { display: flex; align-items: center; }
  #trip-selector { margin-top: 0; max-width: 320px; }

  #main { max-width: 720px; margin: 0 auto; }

  .view { padding: 16px 20px; }

  .modal-handle { display: none; }

  /* ── offcanvas → centered dialog on desktop ──────────────────────── */
  #modal.offcanvas,
  #trip-modal.offcanvas,
  #expense-modal.offcanvas {
    /* 距頂部 5vh，底部留 5vh，幾乎佔滿螢幕高度 */
    top: 5vh !important;
    bottom: 5vh !important;
    left: 50% !important;
    right: auto !important;
    width: min(720px, 92vw) !important;
    height: auto !important;
    max-height: 90vh !important;
    border-radius: 18px !important;
    /* hide state: fade + slight drop */
    transform: translateX(-50%) translateY(-16px) !important;
    opacity: 0;
    transition: transform .25s cubic-bezier(.32,.72,0,1), opacity .2s !important;
  }
  #modal.offcanvas.showing,
  #modal.offcanvas.show:not(.hiding),
  #trip-modal.offcanvas.showing,
  #trip-modal.offcanvas.show:not(.hiding),
  #expense-modal.offcanvas.showing,
  #expense-modal.offcanvas.show:not(.hiding) {
    transform: translateX(-50%) translateY(0) !important;
    opacity: 1;
    visibility: visible !important;
  }
  /* transit stays as bottom sheet on desktop, just width-capped */
  #transit-sheet.offcanvas {
    left: 50% !important;
    right: auto !important;
    width: min(640px, 96vw) !important;
    border-radius: 22px 22px 0 0 !important;
    transform: translateX(-50%) translateY(100%) !important;
  }
  #transit-sheet.offcanvas.showing,
  #transit-sheet.offcanvas.show:not(.hiding) {
    transform: translateX(-50%) translateY(0) !important;
    visibility: visible !important;
  }

  /* 地圖 */
  #map-container {
    height: calc(100vh - var(--header-h) - var(--nav-h));
  }

  /* 卡片 grid */
  #trips-content .trip-card { max-width: 640px; }

  }

/* ── large desktop (≥1024px) ─────────────────────────────────────── */
@media (min-width: 1024px) {
  .view { padding: 20px 32px; }
  #modal.offcanvas,
  #trip-modal.offcanvas,
  #expense-modal.offcanvas { width: min(760px, 90vw) !important; }
}
