/* =========================================
   旅遊 APP — 主樣式
   設計風格：精緻旅行日誌，米白 + 深褐 + 橘金
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

:root {
  --cream:    #F5F0E8;
  --cream-d:  #EDE5D4;
  --brown:    #2C1F0E;
  --brown-m:  #5C3D1E;
  --brown-l:  #9C7A52;
  --gold:     #C8922A;
  --gold-l:   #E8B84B;
  --rust:     #C45C2A;
  --sage:     #6B8C6B;
  --sky:      #4A7FA5;
  --white:    #FDFBF7;
  --border:   rgba(92,61,30,.12);
  --border-m: rgba(92,61,30,.22);
  --shadow-s: 0 1px 4px rgba(44,31,14,.08);
  --shadow-m: 0 4px 20px rgba(44,31,14,.12);
  --shadow-l: 0 12px 40px rgba(44,31,14,.16);
  --r-s: 8px;
  --r-m: 14px;
  --r-l: 20px;
  --r-xl: 28px;
  --sans: 'DM Sans', sans-serif;
  --serif: 'DM Serif Display', serif;
  --nav-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  background: var(--cream);
  color: var(--brown);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Typography ── */
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: 1.2rem; }
p  { color: var(--brown-m); }
a  { color: inherit; text-decoration: none; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 100px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .2s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--brown);
  color: var(--cream);
}
.btn-primary:hover { background: var(--brown-m); transform: translateY(-1px); box-shadow: var(--shadow-m); }
.btn-gold {
  background: var(--gold);
  color: var(--white);
}
.btn-gold:hover { background: var(--gold-l); transform: translateY(-1px); }
.btn-outline {
  background: transparent;
  color: var(--brown);
  border: 1px solid var(--border-m);
}
.btn-outline:hover { background: var(--cream-d); }

/* ── Modal 按鈕 — 完全統一 ── */
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  align-items: center;
}
.modal-footer button {
  /* 清除所有繼承，從零開始定義 */
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 28px;
  border-radius: 100px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  min-width: 88px;
  white-space: nowrap;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
/* 取消 / 關閉 */
.modal-footer button.btn-outline,
.modal-footer button.modal-close:not(.btn-primary) {
  background: var(--cream-d);
  color: var(--brown-m);
}
.modal-footer button.btn-outline:hover,
.modal-footer button.modal-close:not(.btn-primary):hover {
  background: var(--border-m);
  color: var(--brown);
}
/* 主要動作按鈕 */
.modal-footer button.btn-primary {
  background: var(--brown);
  color: var(--cream);
}
.modal-footer button.btn-primary:hover {
  background: var(--brown-m);
}
.modal-footer button.btn-gold {
  background: var(--gold);
  color: var(--white);
}
.modal-footer button.btn-gold:hover { background: var(--gold-l); }
.btn-ghost {
  background: transparent;
  color: var(--brown-m);
  padding: 8px 14px;
}
.btn-ghost:hover { background: var(--cream-d); color: var(--brown); }
.btn-sm { padding: 7px 16px; font-size: 13px; }
.btn-icon { padding: 9px; border-radius: 50%; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

/* ── Form Elements ── */
.input, .textarea, .select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-m);
  border-radius: var(--r-s);
  font-family: var(--sans);
  font-size: 15px;
  color: var(--brown);
  background: var(--white);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200,146,42,.15);
}
.input::placeholder, .textarea::placeholder { color: var(--brown-l); }
.textarea { resize: vertical; min-height: 90px; }
.select { appearance: none; cursor: pointer; }
label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--brown-m);
  margin-bottom: 6px;
}
.field { margin-bottom: 18px; }

/* ── Card ── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-s);
}

/* ── Nav ── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(253,251,247,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
}
.nav-logo {
  font-family: var(--serif);
  font-size: 1.3rem;
  color: var(--brown);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-logo svg { color: var(--gold); }
.nav-spacer { flex: 1; }
.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--brown-m);
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* ── Page Layout ── */
.page { display: none; min-height: 100vh; }
.page.active { display: block; }
.page-content { padding-top: var(--nav-h); }
.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }

/* ── Auth Page ── */
#page-auth {
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--cream);
}
#page-auth.active {
  display: flex;
}
.auth-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-l);
  padding: 52px 44px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.auth-card .auth-icon {
  font-size: 2.8rem;
  margin-bottom: 16px;
}
.auth-card h1 { font-size: 2rem; margin-bottom: 8px; }
.auth-card p { font-size: 15px; color: var(--brown-l); margin-bottom: 32px; }
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  font-size: 13px;
  color: var(--brown-l);
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.google-btn {
  width: 100%;
  justify-content: center;
  padding: 12px;
  border-radius: var(--r-s);
}

/* ── Home (trip list) ── */
.home-header {
  padding: 48px 0 32px;
}
.home-header h2 { margin-bottom: 4px; }
.trips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding-bottom: 40px;
}
.trip-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  box-shadow: var(--shadow-s);
}
.trip-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-m); }
.trip-card-cover {
  height: 160px;
  background: linear-gradient(135deg, var(--cream-d), var(--brown-l));
  position: relative;
  overflow: hidden;
}
.trip-card-cover img { width: 100%; height: 100%; object-fit: cover; }
.trip-card-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}
.trip-card-body { padding: 18px 20px; }
.trip-card-title { font-family: var(--serif); font-size: 1.15rem; margin-bottom: 6px; }
.trip-card-meta { font-size: 13px; color: var(--brown-l); display: flex; gap: 12px; flex-wrap: wrap; }
.trip-card-members { display: flex; margin-top: 12px; }
.trip-card-members .avatar { width: 26px; height: 26px; font-size: 11px; margin-right: -6px; border: 2px solid var(--white); }

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--brown-l);
}
.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: 16px; }
.empty-state h3 { font-family: var(--serif); font-size: 1.4rem; color: var(--brown-m); margin-bottom: 8px; }

/* ── Trip Detail ── */
.trip-hero {
  height: 260px;
  background: linear-gradient(135deg, var(--brown), var(--brown-m));
  position: relative;
  overflow: hidden;
}
.trip-hero img { width: 100%; height: 100%; object-fit: cover; opacity: .7; }
.trip-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(44,31,14,.7) 40%, transparent);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 28px;
}
.trip-hero-title {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  color: var(--white);
  text-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.trip-hero-meta { font-size: 14px; color: rgba(255,255,255,.75); margin-top: 4px; }
.trip-hero .btn-back {
  position: absolute;
  top: 20px; left: 20px;
  background: rgba(253,251,247,.18);
  backdrop-filter: blur(8px);
  color: var(--white);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 100px;
  padding: 7px 16px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.trip-tabs {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  gap: 0;
  position: sticky;
  top: var(--nav-h);
  z-index: 50;
}
.trip-tab {
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--brown-l);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.trip-tab.active { color: var(--brown); border-bottom-color: var(--gold); }
.trip-tab:hover:not(.active) { color: var(--brown-m); }

.trip-panel { display: none; padding: 28px 0 60px; }
.trip-panel.active { display: block; }

/* ── Day / Itinerary ── */
.day-section { margin-bottom: 32px; }
.day-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.day-number {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brown);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 1rem;
  flex-shrink: 0;
}
.day-date { font-size: 13px; color: var(--brown-l); }
.day-title { font-family: var(--serif); font-size: 1.1rem; }

.place-list { display: flex; flex-direction: column; gap: 10px; }
.place-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  padding: 14px 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: border-color .15s;
}
.place-item:hover { border-color: var(--border-m); }
.place-time { font-size: 12px; color: var(--gold); font-weight: 500; min-width: 44px; padding-top: 2px; }
.place-icon-wrap {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--cream-d);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.place-info { flex: 1; }
.place-name { font-weight: 500; font-size: 15px; margin-bottom: 3px; }
.place-note { font-size: 13px; color: var(--brown-l); }
.place-actions { display: flex; gap: 6px; opacity: 0; transition: opacity .15s; }
.place-item:hover .place-actions { opacity: 1; }

.add-place-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1.5px dashed var(--border-m);
  border-radius: var(--r-m);
  background: transparent;
  color: var(--brown-l);
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  transition: all .15s;
}
.add-place-btn:hover { border-color: var(--gold); color: var(--gold); background: rgba(200,146,42,.04); }

/* ── Members Panel ── */
.members-list { display: flex; flex-direction: column; gap: 10px; }
.member-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.member-name { font-weight: 500; flex: 1; }
.member-email { font-size: 13px; color: var(--brown-l); }
.role-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 100px;
  font-weight: 500;
}
.role-owner { background: rgba(200,146,42,.15); color: var(--gold); }
.role-editor { background: rgba(107,140,107,.15); color: var(--sage); }
.role-viewer { background: rgba(92,61,30,.1); color: var(--brown-l); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44,31,14,.45);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-l);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-header h3 { font-family: var(--serif); font-size: 1.3rem; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--cream-d);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--brown-m);
  transition: background .15s;
}
.modal-close:hover { background: var(--border-m); }
/* modal-footer moved to button section above */

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--brown);
  color: var(--cream);
  padding: 12px 20px;
  border-radius: 100px;
  font-size: 14px;
  box-shadow: var(--shadow-m);
  animation: toast-in .25s ease;
}
.toast.error { background: var(--rust); }
.toast.success { background: var(--sage); }
@keyframes toast-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ── Loading ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--brown-l);
}
.spinner {
  width: 32px; height: 32px;
  border: 2.5px solid var(--border-m);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Section header util ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

/* ── Category colors ── */
.cat-food    { background: rgba(196,92,42,.12); }
.cat-sight   { background: rgba(74,127,165,.12); }
.cat-hotel   { background: rgba(200,146,42,.12); }
.cat-transport { background: rgba(107,140,107,.12); }
.cat-other   { background: rgba(92,61,30,.08); }

/* ── Invite link box ── */
.invite-box {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--brown-m);
}
.invite-box input { flex: 1; border: none; background: transparent; font-size: 13px; color: var(--brown); outline: none; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .auth-card { padding: 36px 24px; }
  .trip-hero { height: 200px; }
  .trip-tabs { padding: 0 12px; overflow-x: auto; }
  .trip-tab { padding: 12px 12px; font-size: 13px; }
  .container { padding: 0 16px; }
  .nav { padding: 0 16px; }
  .modal { padding: 24px 20px; }
  .nav-user span { display: none; }
}

/* ── Home tabs ── */
.home-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}
.home-tab {
  padding: 9px 20px;
  border-radius: 100px;
  border: 1px solid var(--border-m);
  background: transparent;
  color: var(--brown-m);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.home-tab:hover { background: var(--cream-d); }
.home-tab.active {
  background: var(--brown);
  color: var(--cream);
  border-color: var(--brown);
}

/* ── Visibility badge on card ── */
.trip-card-cover { position: relative; }
.visibility-badge {
  position: absolute;
  top: 10px; left: 10px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 100px;
  backdrop-filter: blur(6px);
}
.visibility-badge.public  { background: rgba(107,140,107,.85); color: #fff; }
.visibility-badge.private { background: rgba(44,31,14,.55);   color: #F5F0E8; }

/* ── Toggle button on card ── */
.visibility-toggle {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 100px;
  border: 1px solid rgba(255,255,255,.5);
  background: rgba(253,251,247,.2);
  backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  transition: background .15s;
}
.visibility-toggle:hover { background: rgba(253,251,247,.35); }

/* ── Budget ── */
.budget-summary { text-align:center; padding:28px 0 20px; border-bottom:1px solid var(--border); }
.budget-total-label { font-size:13px; color:var(--brown-l); margin-bottom:6px; }
.budget-total-amount { font-family:var(--serif); font-size:2.4rem; color:var(--brown); }
.budget-cats { display:flex; flex-direction:column; gap:8px; margin:16px 0; }
.budget-cat-row { display:flex; justify-content:space-between; font-size:14px; color:var(--brown-m); padding:8px 0; border-bottom:1px solid var(--border); }
.expense-list { display:flex; flex-direction:column; gap:8px; margin-top:12px; padding-bottom:40px; }
.expense-item { background:var(--white); border:1px solid var(--border); border-radius:var(--r-m); padding:12px 16px; display:flex; align-items:center; gap:12px; }
.expense-icon { font-size:1.2rem; flex-shrink:0; }
.expense-info { flex:1; }
.expense-title { font-weight:500; font-size:15px; }
.expense-meta { font-size:12px; color:var(--brown-l); }
.expense-amount { font-weight:500; color:var(--gold); white-space:nowrap; }

/* ── Weather ── */
.weather-location { font-size:14px; color:var(--brown-l); margin-bottom:16px; }
.weather-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(120px,1fr)); gap:12px; }
.weather-card { background:var(--white); border:1px solid var(--border); border-radius:var(--r-m); padding:16px 12px; text-align:center; }
.weather-day { font-size:11px; color:var(--brown-l); margin-bottom:8px; }
.weather-icon { font-size:2rem; margin-bottom:4px; }
.weather-desc { font-size:12px; color:var(--brown-m); margin-bottom:8px; }
.weather-temp { font-size:14px; font-weight:500; }
.t-max { color:var(--rust); }
.t-min { color:var(--sky); }
.weather-rain { font-size:12px; color:var(--brown-l); margin-top:4px; }

/* ── Book ── */
.book-preview { background:var(--white); border:1px solid var(--border); border-radius:var(--r-l); padding:40px; max-height:70vh; overflow-y:auto; }
.book-cover { text-align:center; padding:40px 0 48px; border-bottom:2px solid var(--border); margin-bottom:32px; }
.book-cover-emoji { font-size:3.5rem; margin-bottom:12px; }
.book-cover-title { font-family:var(--serif); font-size:2rem; color:var(--brown); margin-bottom:8px; }
.book-cover-sub { font-size:14px; color:var(--brown-l); margin-bottom:12px; }
.book-cover-desc { font-size:14px; color:var(--brown-m); max-width:400px; margin:0 auto; }
.book-day { margin-bottom:32px; padding-bottom:32px; border-bottom:1px solid var(--border); }
.book-day-header { display:flex; align-items:baseline; gap:14px; margin-bottom:16px; }
.book-day-num { font-family:var(--serif); font-size:1.3rem; color:var(--gold); }
.book-day-date { font-size:14px; color:var(--brown-l); }
.book-place { display:flex; align-items:flex-start; gap:10px; margin-bottom:10px; font-size:14px; }
.book-place-time { min-width:44px; color:var(--gold); font-size:12px; padding-top:2px; }
.book-place-icon { flex-shrink:0; }
.book-place-info { display:flex; flex-direction:column; gap:2px; }
.book-place-info strong { font-weight:500; color:var(--brown); }
.book-place-info span { color:var(--brown-l); font-size:12px; }
.book-note { margin-top:12px; padding:10px 14px; background:var(--cream); border-radius:var(--r-s); font-size:13px; color:var(--brown-m); font-style:italic; }

/* ── Split checklist ── */
.split-checklist { display:flex; flex-wrap:wrap; gap:8px; margin-top:4px; }
.split-check-item {
  display:flex; align-items:center; gap:6px;
  padding:6px 12px 6px 8px;
  border:1px solid var(--border-m);
  border-radius:100px;
  cursor:pointer;
  font-size:13px;
  color:var(--brown-m);
  transition:all .15s;
  user-select:none;
}
.split-check-item:has(input:checked) {
  background:var(--brown);
  color:var(--cream);
  border-color:var(--brown);
}
.split-check-item input { display:none; }
.split-avatar {
  width:22px; height:22px; border-radius:50%;
  background:var(--gold); color:var(--white);
  display:flex; align-items:center; justify-content:center;
  font-size:11px; font-weight:500; flex-shrink:0;
  overflow:hidden;
}
.split-avatar img { width:100%; height:100%; object-fit:cover; }

/* ── Expense meta ── */
.expense-meta { display:flex; flex-wrap:wrap; gap:4px; font-size:12px; color:var(--brown-l); margin-top:2px; }
.expense-payer { color:var(--sky); font-weight:500; }
.expense-per   { color:var(--gold); }

/* ── Settlement ── */
.settlement-list { display:flex; flex-direction:column; gap:8px; margin-bottom:8px; }
.settlement-row {
  display:flex; align-items:center; justify-content:space-between;
  background:var(--white); border:1px solid var(--border);
  border-radius:var(--r-m); padding:12px 16px;
  font-size:14px;
}
.settlement-row.is-me  { border-color:var(--rust); background:rgba(196,92,42,.05); }
.settlement-row.to-me  { border-color:var(--sage); background:rgba(107,140,107,.05); }
.settlement-names { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.settlement-from  { font-weight:500; color:var(--rust); }
.settlement-to    { font-weight:500; color:var(--sage); }
.settlement-arrow { color:var(--brown-l); }
.settlement-amount { font-weight:500; color:var(--brown); white-space:nowrap; }

/* ── PWA Install Banner ── */
#pwa-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  width: calc(100% - 32px);
  max-width: 480px;
  background: var(--brown);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-l);
  z-index: 999;
  transition: transform .4s cubic-bezier(.34,1.56,.64,1), opacity .4s;
  opacity: 0;
}
#pwa-banner.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.pwa-banner-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}
.pwa-banner-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
}
.pwa-banner-text {
  flex: 1;
  min-width: 0;
}
.pwa-banner-title {
  font-weight: 500;
  font-size: 14px;
  color: var(--cream);
  margin-bottom: 2px;
}
.pwa-banner-sub {
  font-size: 12px;
  color: var(--brown-l);
  color: rgba(245,240,232,.65);
}
.pwa-share-icon {
  display: inline-block;
  background: rgba(245,240,232,.2);
  border-radius: 4px;
  padding: 0 4px;
  font-style: normal;
}
.pwa-banner-install {
  flex-shrink: 0;
}
.pwa-banner-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: rgba(245,240,232,.5);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  line-height: 1;
  transition: color .15s;
}
.pwa-banner-close:hover { color: var(--cream); }

@media (max-width: 480px) {
  #pwa-banner { bottom: 16px; width: calc(100% - 24px); }
}

/* ── Place edit button ── */
.place-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.place-item:hover .place-actions { opacity: 1; }

/* ── Time mode toggle ── */
.time-mode-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
}
.time-mode-pills {
  display: flex;
  gap: 4px;
  background: var(--cream-d);
  border-radius: 100px;
  padding: 3px;
}
.time-mode-pill {
  padding: 4px 12px;
  border-radius: 100px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-family: var(--sans);
  color: var(--brown-l);
  cursor: pointer;
  transition: all .15s;
}
.time-mode-pill.active {
  background: var(--white);
  color: var(--brown);
  font-weight: 500;
  box-shadow: var(--shadow-s);
}

/* ── Place cost & meta ── */
.place-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
}
.place-cost {
  font-size: 12px;
  font-weight: 500;
  color: var(--gold);
  background: rgba(200,146,42,.1);
  padding: 1px 7px;
  border-radius: 100px;
}
/* 讓時間欄位寬一點以容納區間 */
.place-time {
  min-width: 90px;
  font-size: 12px;
}

/* ── Budget: place-linked expense badge ── */
.expense-from-place {
  font-size: 11px;
  color: var(--brown-l);
  background: var(--cream-d);
  padding: 1px 7px;
  border-radius: 100px;
  margin-left: 4px;
}

/* ── Day jump bar ── */
.day-jump-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 16px 0 8px;
  position: sticky;
  top: calc(var(--nav-h) + 48px);
  background: var(--cream);
  z-index: 40;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.day-jump-btn {
  padding: 5px 14px;
  border-radius: 100px;
  border: 1px solid var(--border-m);
  background: var(--white);
  color: var(--brown-m);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--sans);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.day-jump-btn:hover { background: var(--cream-d); }
.day-jump-btn.active {
  background: var(--brown);
  color: var(--cream);
  border-color: var(--brown);
}

/* ── Mobile fixes ── */
@media (max-width: 640px) {
  /* 時間模式 toggle：避免文字擠壓 */
  .time-mode-toggle {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .time-mode-pills { align-self: stretch; }
  .time-mode-pill  { flex: 1; text-align: center; }

  /* place-form 幣別欄位不被擠掉 */
  #modal-add-place .modal { padding: 20px 16px; }

  /* 費用欄位在手機也排好 */
  #modal-add-place [style*="grid-template-columns:2fr 1fr"] {
    grid-template-columns: 3fr 2fr;
  }

  /* 行程卡片時間文字不換行 */
  .place-time { font-size: 11px; min-width: 80px; }

  /* trip hero 按鈕不重疊 */
  .trip-hero-overlay { padding: 16px; }
  .trip-hero-title   { font-size: 1.4rem; }

  /* Day jump bar 在手機橫向捲動 */
  .day-jump-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .day-jump-bar::-webkit-scrollbar { display: none; }

  /* modal 費用欄位 grid fix */
  .modal [style*="grid-template-columns:2fr 1fr"],
  .modal [style*="grid-template-columns: 2fr 1fr"] {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Trip tabs actions (編輯/邀請 放 tab 列右側) ── */
.trip-tabs-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.trip-action-btn {
  font-size: 13px;
  padding: 6px 12px;
  color: var(--brown-m);
  border-radius: var(--r-s);
  white-space: nowrap;
}
.trip-action-btn:hover {
  background: var(--cream-d);
  color: var(--brown);
}
@media (max-width: 640px) {
  .trip-action-btn span { display: none; }
  .trip-tabs { gap: 0; }
  .trip-tabs-actions { gap: 2px; }
  .trip-action-btn { padding: 6px 8px; font-size: 15px; }
}

/* ── Guest banner ── */
#guest-banner {
  padding: 10px 24px;
  font-size: 13px;
}

/* ── Invite modal sections ── */
.invite-section { margin-bottom: 4px; }
.invite-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--brown);
  margin-bottom: 4px;
}

/* ── Trip card footer + delete ── */
.trip-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}
.trip-card-delete {
  border: none;
  background: transparent;
  color: var(--brown-l);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-s);
  transition: background .15s, color .15s;
  white-space: nowrap;
  font-family: var(--sans);
}
.trip-card-delete:hover {
  background: rgba(196,92,42,.1);
  color: var(--rust);
}

/* ── Time select UI ── */
.time-select-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}
.time-select {
  width: 72px !important;
  padding: 10px 6px !important;
  text-align: center;
  cursor: pointer;
}
.time-colon {
  font-size: 18px;
  font-weight: 500;
  color: var(--brown-m);
  flex-shrink: 0;
}
.time-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
@media (max-width: 400px) {
  .time-range-row { flex-direction: column; align-items: flex-start; }
}

/* ── Location search ── */
.location-search-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}
.location-search-wrap .input {
  flex: 1;
}
#location-results {
  margin-top: 6px;
  border: 1px solid var(--border-m);
  border-radius: var(--r-s);
  overflow: hidden;
  background: var(--white);
  max-height: 200px;
  overflow-y: auto;
}
.location-result-item {
  padding: 9px 14px;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.location-result-item:last-child { border-bottom: none; }
.location-result-item:hover { background: var(--cream-d); }
.location-result-name { font-size: 14px; font-weight: 500; color: var(--brown); }
.location-result-sub  { font-size: 12px; color: var(--brown-l); }
.location-result-empty { padding: 10px 14px; font-size: 13px; color: var(--brown-l); }
.location-selected-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  padding: 8px 12px;
  background: rgba(200,146,42,.08);
  border: 1px solid rgba(200,146,42,.25);
  border-radius: var(--r-s);
  font-size: 12px;
  color: var(--brown-m);
}

/* ── Place nav button ── */
.btn-nav-map {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 15px;
  text-decoration: none;
  transition: background .15s;
}
.btn-nav-map:hover { background: var(--cream-d); }
.place-coords {
  font-size: 11px;
  color: var(--sky);
}

/* ── 導航按鈕對齊修正 ── */
.place-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.btn-nav-map {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 15px;
  text-decoration: none;
  transition: background .15s;
  flex-shrink: 0;
}

/* ── Location result source badge ── */
.location-result-item { justify-content: space-between; }
.location-result-src {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 100px;
  background: var(--cream-d);
  color: var(--brown-l);
  flex-shrink: 0;
  align-self: center;
}

/* ── 地標庫 ── */
.landmark-search-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}
.landmark-search-bar .input { flex: 1; min-width: 120px; }
.landmark-search-bar select {
  flex: 0 0 auto;
  min-width: 110px;
  max-width: 160px;
  width: auto;
}
.landmark-public-search {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.landmark-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  padding: 12px 16px;
  margin-bottom: 8px;
  transition: border-color .15s;
}
.landmark-item:hover { border-color: var(--border-m); }
.landmark-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.landmark-info { flex: 1; min-width: 0; }
.landmark-name { font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.landmark-meta { font-size: 12px; color: var(--brown-l); margin-top: 2px; }
.landmark-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* ── Landmark note ── */
.landmark-note {
  font-size: 12px;
  color: var(--brown-l);
  margin-top: 2px;
  font-style: italic;
}

/* ── 封面圖上傳 ── */
.cover-upload-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cover-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  border: 2px dashed var(--border-m);
  border-radius: var(--r-m);
  cursor: pointer;
  color: var(--brown-l);
  font-size: 14px;
  transition: border-color .15s, background .15s;
  text-align: center;
  padding: 12px;
}
.cover-upload-btn:hover { border-color: var(--gold); background: rgba(200,146,42,.04); color: var(--gold); }
#cover-preview {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: var(--r-m);
  border: 1px solid var(--border);
}

/* ── 景點照片 ── */
.place-photo-wrap { display: flex; flex-direction: column; gap: 8px; }
.place-photo-previews { display: flex; flex-wrap: wrap; gap: 8px; }
.place-photo-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--r-s);
  overflow: hidden;
  flex-shrink: 0;
}
.place-photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.place-photo-thumb button {
  position: absolute;
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(44,31,14,.7);
  color: #fff;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.place-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.place-photo-thumb-img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--r-s);
  cursor: pointer;
  transition: opacity .15s;
}
.place-photo-thumb-img:hover { opacity: .85; }

/* ── 拖曳排序 ── */
.place-drag-handle {
  cursor: grab;
  color: var(--brown-l);
  font-size: 16px;
  padding: 0 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity .15s;
  touch-action: none;
  user-select: none;
}
.place-item:hover .place-drag-handle { opacity: 1; }
/* 手機：一直顯示拖把（hover 在手機不易觸發） */
@media (hover: none) {
  .place-drag-handle { opacity: 0.4; }
}
.place-item.sortable-ghost  { opacity: .4; background: var(--cream-d); }
.place-item.sortable-chosen { box-shadow: var(--shadow-m); }

/* ── Presence ── */
.presence-avatar {
  position: relative;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500;
  border: 2px solid var(--white);
  overflow: visible;
  flex-shrink: 0;
}
.presence-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.presence-dot {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  border: 1.5px solid var(--white);
}

/* ── Undo Toast ── */
.toast-undo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}
.toast-undo-btn {
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.4);
  color: var(--cream);
  border-radius: 100px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--sans);
  white-space: nowrap;
  transition: background .15s;
}
.toast-undo-btn:hover { background: rgba(255,255,255,.3); }

/* ── AI 排程 ── */
.landmark-check {
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0 4px;
}
.landmark-check input[type=checkbox] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  cursor: pointer;
  accent-color: var(--gold);
  margin: 0;
}
.landmark-selected {
  border-color: var(--gold) !important;
  background: rgba(200,146,42,.04);
}
.ai-place-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.ai-place-item:last-child { border-bottom: none; }
.ai-place-time {
  font-size: 12px;
  color: var(--gold);
  font-weight: 500;
  min-width: 42px;
  padding-top: 2px;
}
.ai-place-info { flex: 1; }
.ai-place-name { font-size: 14px; font-weight: 500; color: var(--brown); margin-bottom: 2px; }
.ai-place-note { font-size: 12px; color: var(--brown-l); }

/* ── AI Loading Overlay ── */
#ai-loading-overlay { display: none; }
.ai-loading-spinner {
  width: 52px;
  height: 52px;
  border: 4px solid rgba(255,255,255,.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: ai-spin 0.9s linear infinite;
}
@keyframes ai-spin {
  to { transform: rotate(360deg); }
}
