:root {
  --bg: linear-gradient(160deg, #faf7f2, #f3ece3, #eee1d6);
  --card: #ffffff;
  --ink: #1c2126;
  --muted: #6b7785;
  --line: #e4e7eb;
  --brand: #cf8a64;
  --brand-ink: #a35a3a;
  --accent: #cf8a5c;
  --gold: #c2904a;
  --good: #15803d;
  --tabbar-h: 60px;
  --header-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  background-attachment: fixed;          /* 漸層固定不隨捲動位移 */
  color: var(--ink);
  font-family: -apple-system, "PingFang TC", "Noto Sans TC", "Segoe UI", system-ui, sans-serif;
  font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
/* 整頁最底層霧面塗料顆粒：極淡 feTurbulence，疊在 --bg 漸層之上、所有內容之下；position:fixed 不隨捲動 */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  mix-blend-mode: soft-light; opacity: .5;
}

/* Header */
#app-header {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-ink));
  color: #fff;
}
#header-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .3px; }
#header-sub { font-size: 13px; opacity: .9; margin-top: 2px; min-height: 1px; }

/* Main view */
#view {
  padding: 14px max(14px, env(safe-area-inset-right))
           calc(var(--tabbar-h) + var(--safe-b) + 18px)
           max(14px, env(safe-area-inset-left));
  max-width: 720px; margin: 0 auto;
}
.loading { text-align: center; color: var(--muted); padding: 40px 0; }

/* Tab bar */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255,255,255,.96);
  backdrop-filter: saturate(180%) blur(10px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-decoration: none; color: var(--muted);
  font-size: 11px; font-weight: 600;
}
.tab .ico { display: flex; line-height: 1; }
.tab .ico .icn { width: 23px; height: 23px; }
.tab.active { color: var(--brand); }
.tab.active .ico .icn { stroke-width: 2.4; }

/* Inline SVG 線條圖示（Lucide 風格） */
.icn { width: 1.1em; height: 1.1em; flex: 0 0 auto; display: inline-block; vertical-align: -0.2em; }
.chev { transition: transform .15s ease; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(20,30,40,.04);
}
.card h2 { margin: 0 0 8px; font-size: 17px; }
.card h2 .icn { color: var(--brand); margin-right: 3px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 4px 8px; text-transform: none; }

/* Pills / chips */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.today  { background: var(--accent); color: #fff; }
.pill.ticket { background: #fef3c7; color: var(--gold); }
.pill.city   { background: #e0f2fe; color: var(--brand-ink); }
.chip { display: inline-block; padding: 3px 9px; margin: 2px 4px 2px 0; border-radius: 8px;
  background: #eef2f5; color: var(--muted); font-size: 12px; }
.chip-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  border-radius: 12px; font-size: 13px; font-weight: 600;
  text-decoration: none; background: #e0f2fe; color: var(--brand-ink); }

/* Day list (itinerary) */
.daycard { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.daycard .date { flex: 0 0 54px; text-align: center; }
.daycard .date .d { font-size: 22px; font-weight: 800; color: var(--brand); line-height: 1; }
.daycard .date .w { font-size: 18px; color: var(--muted); }
.daycard .body { flex: 1; min-width: 0; }
.daycard .city { font-weight: 700; font-size: 17px; }
.daycard .preview { color: var(--muted); font-size: 13px; margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.daycard .meta { margin-top: 6px; }

/* Booked activity (voucher) */
.voucher {
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border: 1px solid #fdba74; border-left: 4px solid var(--accent);
}
.voucher .vtitle { font-weight: 700; color: var(--accent); }
.voucher .vtime { font-weight: 700; font-size: 18px; }

/* Timeline of stops — 編號節點＋豎線（TripIt/Wanderlog 風格，純 CSS counter） */
.timeline { position: relative; margin-left: 2px; counter-reset: stopn; }
.stop { position: relative; padding: 0 0 6px 38px; }
.stop::before {
  counter-increment: stopn; content: counter(stopn);
  position: absolute; left: 0; top: 10px; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--brand); color: #fff;
  font-size: 12px; font-weight: 700; box-shadow: 0 0 0 3px #fff;
  z-index: 1;
}
.stop:not(:last-child)::after { content: ""; position: absolute; left: 11px; top: 20px; bottom: -12px;
  width: 2px; background: #cfe3ea; }
.stop .row { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  min-height: 44px; padding: 6px 0; cursor: pointer; }
.stop .name { font-weight: 600; }
.stop .type-ico { color: var(--brand); }
.stop .type-ico .icn { width: 17px; height: 17px; vertical-align: -0.22em; }
.stop .toggle { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; flex: 0 0 auto; }
.stop.open .toggle .chev { transform: rotate(180deg); }
.stop .detail { display: none; padding: 4px 0 12px; }
.stop.open .detail { display: block; }
.btn-row { display: flex; gap: 8px; margin: 4px 0 8px; flex-wrap: wrap; }
.stop .nav-btn {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  min-height: 44px; background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-weight: 700; font-size: 14px;
}
.stop .nav-btn.alt { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.stop .ai-btn {
  display: inline-flex; align-items: center; min-height: 44px;
  background: #eef2f5; color: var(--brand-ink); border: none;
  padding: 10px 14px; border-radius: 12px; font-weight: 600; font-size: 13px; margin: 2px 6px 4px 0; cursor: pointer;
}
.kv { display: flex; gap: 8px; font-size: 15px; margin: 3px 0; }
.kv .k { color: var(--muted); flex: 0 0 76px; }
.culture { background: #f8fafc; border-left: 3px solid var(--brand); padding: 8px 10px; border-radius: 8px;
  font-size: 15px; color: #334; margin-top: 6px; }
.estimate-note { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* Meals */
.meal { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.meal:last-child { border-bottom: none; }
.meal .micn { color: var(--accent); display: flex; align-items: center; flex: 0 0 auto; }
.meal .micn .icn { width: 18px; height: 18px; }
.meal .mtype { flex: 0 0 56px; color: var(--accent); font-weight: 700; font-size: 13px; align-self: center; }
.meal .mname { flex: 1; font-weight: 600; }
.meal .mnav { display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; text-decoration: none; color: var(--brand); align-self: center; }
.meal .mnav .icn { width: 21px; height: 21px; }
.meal .mnote { color: var(--muted); font-size: 12px; font-weight: 400; display: block; }

/* Buttons / links */
.btn {
  display: block; width: 100%; text-align: center; text-decoration: none;
  background: var(--brand); color: #fff; padding: 13px; border-radius: 12px;
  font-weight: 700; font-size: 15px; border: none; cursor: pointer; margin: 6px 0;
}
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.route-btn { background: linear-gradient(135deg, var(--brand), var(--brand-ink)); font-size: 16px; }
.btn.gas-btn { background: var(--brand-ink); margin-top: 0; }
.btn.danger { background: #fee2e2; color: #b91c1c; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 4px;
  color: var(--brand); text-decoration: none; font-weight: 600; margin-bottom: 4px; }

/* Useful tab accordion */
.kb-item { border-bottom: 1px solid var(--line); }
.kb-item:last-child { border-bottom: none; }
.kb-head { display: flex; justify-content: space-between; align-items: center; min-height: 44px;
  padding: 13px 2px; cursor: pointer; font-weight: 700; }
.kb-title { display: inline-flex; align-items: center; gap: 8px; }
.kb-title .icn { width: 19px; height: 19px; color: var(--brand-ink); }
.warn .kb-title .icn { color: #b91c1c; }
.kb-item.open .kb-head .chev { transform: rotate(180deg); }
.kb-body { display: none; padding: 0 2px 12px; }
.kb-item.open .kb-body { display: block; }
.kb-body ul { margin: 4px 0; padding-left: 20px; }
.kb-body li { margin: 5px 0; }
/* 可折疊子段落 */
.kb-sub { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; background: #fafbfc; }
.kb-sub > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center;
  padding: 10px 12px; font-weight: 700; font-size: 14px; list-style: none; }
.kb-sub > summary::-webkit-details-marker { display: none; }
.kb-sub > summary::after { content: " ▾"; color: var(--muted); font-weight: 400; }
.kb-sub[open] > summary::after { content: " ▴"; }
.kb-sub > summary:hover { color: var(--brand); }
.kb-sub ul { margin: 0 0 10px; padding: 0 14px 0 32px; }
.kb-sub li { margin: 6px 0; font-size: 15px; }
.warn { border: 1px solid #fecaca; background: #fef2f2; }
.warn .kb-head { color: #b91c1c; }

/* 緊急聯絡與證件區塊（置頂、電話可撥號）*/
.emergency { border: 1px solid #fca5a5; background: #fff5f5; border-left: 4px solid #dc2626; }
.emergency .em-title { font-weight: 800; font-size: 17px; color: #b91c1c; margin-bottom: 6px; }
.em-group { padding: 10px 0; border-top: 1px solid #fecaca; }
.em-group:first-of-type { border-top: none; padding-top: 4px; }
.em-head { font-weight: 700; font-size: 14px; color: #7f1d1d; margin-bottom: 6px; }
.em-line { font-size: 13px; color: var(--muted); margin: 2px 0 6px; }
.em-contact { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 6px 0; }
.em-label { font-size: 14px; flex: 1 1 100%; }
/* 撥號（主）＋WhatsApp（輔）並排，沿用陶土主色變數 */
.em-actions { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.em-phone {
  display: inline-flex; align-items: center; gap: 5px; min-height: 44px; text-decoration: none;
  background: var(--brand); color: #fff; padding: 9px 16px; border-radius: 12px;
  font-weight: 700; font-size: 15px; letter-spacing: .3px;
}
.em-wa {
  display: inline-flex; align-items: center; gap: 5px; min-height: 44px; text-decoration: none;
  background: #fff; color: var(--brand-ink); border: 1px solid var(--brand); padding: 9px 14px; border-radius: 12px;
  font-weight: 700; font-size: 14px;
}
.em-note { font-size: 12px; color: var(--muted); flex: 1 1 100%; }
.em-pending { display: inline-flex; align-items: center; gap: 5px; padding: 7px 13px; border-radius: 10px;
  border: 1px dashed #cbd5e1; background: #f8fafc; color: var(--muted); font-size: 13px; }
.em-important { margin-top: 8px; background: #fff; border-radius: 10px; padding: 4px 12px; }
.em-important ul { margin: 6px 0; padding-left: 20px; font-size: 13px; }
.em-important li { margin: 4px 0; }
.em-docs { margin-top: 10px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.em-docs-head { font-weight: 700; font-size: 14px; color: var(--brand-ink); }
.em-docs p { font-size: 13px; margin: 6px 0; }
.em-docs ul { margin: 6px 0; padding-left: 20px; font-size: 13px; }
.em-docs li { margin: 3px 0; }

/* 返程提醒框（行李＋退稅，醒目藍綠色）*/
.return-reminder { border: 1px solid #5eead4; background: #f0fdfa; border-left: 4px solid #0d9488; }
.return-reminder .rr-title { font-weight: 800; font-size: 16px; color: #0f766e; }
.return-reminder .rr-lead { font-size: 14px; margin: 6px 0; color: #134e4a; }
.return-reminder .rr-list { font-size: 14px; color: #243b39; margin: 6px 0; padding-left: 20px; }
.return-reminder .rr-list > li { margin: 7px 0; }
.return-reminder .rr-list ol { margin: 6px 0; padding-left: 20px; }
.return-reminder .rr-list ol li { margin: 5px 0; }
.return-reminder .rr-link { background: #0d9488; margin-top: 6px; }

/* 前後日切換 */
.day-nav { display: flex; justify-content: space-between; gap: 10px; margin: 6px 0 4px; }
.day-nav-btn {
  flex: 1; display: flex; flex-direction: column; text-decoration: none;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px;
  color: var(--brand); font-weight: 700; font-size: 15px;
}
.day-nav-btn.next { text-align: right; }
.day-nav-btn span { font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.day-nav-spacer { flex: 1; }

/* 規劃提醒框（類似實用頁提醒框，琥珀色「小提醒」樣式）*/
.planning-note { border: 1px solid #fcd34d; background: #fffbeb; border-left: 4px solid var(--gold); }
.planning-note .pn-title { font-weight: 800; color: var(--gold); margin-bottom: 4px; }
.planning-note .pn-body { font-size: 14px; color: #3f3a2e; }
.planning-note .pn-body p { margin: 6px 0; }
.planning-note .pn-body ol,
.planning-note .pn-body ul { margin: 6px 0; padding-left: 22px; }
.planning-note .pn-body li { margin: 6px 0; }

/* 洗衣提醒（連住入住日）— 沿用提醒框卡片樣式，改陶土主色 */
.laundry-note { border: 1px solid var(--brand); background: #f8efe9; border-left: 4px solid var(--brand); }
.laundry-note .ln-title { font-weight: 800; color: var(--brand-ink); margin-bottom: 4px; }
.laundry-note .ln-body { font-size: 14px; color: #4a3b31; }
.laundry-note .ln-body p { margin: 6px 0; }

table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini th, table.mini td { text-align: left; padding: 6px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.mini th { color: var(--muted); font-weight: 600; }

/* Expenses */
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tot-box { background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 12px; padding: 10px 12px; }
.tot-box.grand { grid-column: 1 / -1; background: var(--brand); border-color: var(--brand); color: #fff; }
.tot-box .who { font-size: 12px; color: var(--muted); }
.tot-box.grand .who { color: #d8f3fc; }
.tot-box .amt { font-size: 20px; font-weight: 800; }
.exp-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.exp-row .ex-main { flex: 1; min-width: 0; }
.exp-row .ex-item { font-weight: 600; }
.exp-row .ex-sub { font-size: 12px; color: var(--muted); }
.exp-row .ex-amt { font-weight: 800; white-space: nowrap; }
.exp-row .ex-edit { min-width: 44px; min-height: 44px; background: none; border: none;
  font-size: 18px; cursor: pointer; color: var(--muted); }
.field { margin: 10px 0; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 16px; background: #fff; font-family: inherit;
}
.tagrow { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-btn { min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; font-size: 14px; cursor: pointer; }
.tag-btn.sel { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Misc */
.muted { color: var(--muted); }
.center { text-align: center; }
.amenity-row { margin-top: 6px; }
.dev-bar { font-size: 12px; display: flex; align-items: center; gap: 6px; }
.dev-bar select { flex: 1; min-height: 44px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); font-size: 14px; background: #fff; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; display: flex; align-items: flex-end; }
.modal { background: #fff; width: 100%; max-width: 720px; margin: 0 auto; border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(var(--safe-b) + 16px); max-height: 88vh; overflow-y: auto; }
.modal h2 { margin-top: 4px; }
.countdown { font-size: 40px; font-weight: 800; color: var(--brand); }
.egg-modal { text-align: center; }
.egg-modal h2 { margin: 8px 0 12px; }
.egg-emoji { font-size: 40px; line-height: 1.2; }
.egg-text { font-size: 16px; line-height: 1.8; margin: 10px 0; }
.egg-modal .btn { margin-top: 12px; }

/* 日期快速切換列（行程頁／單日頁頂部，可橫向滑動，Klook 風格） */
.date-chips { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 2px 2px 10px; margin: 0 -2px 6px; scrollbar-width: none; }
.date-chips::-webkit-scrollbar { display: none; }
.date-chip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 56px; min-height: 48px; padding: 5px 10px; border-radius: 12px;
  background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.date-chip .dc-d { font-size: 15px; font-weight: 800; line-height: 1.25; }
.date-chip .dc-w { font-size: 13px; color: var(--muted); }
.date-chip.sel { background: var(--brand); border-color: var(--brand); color: #fff; }
.date-chip.sel .dc-w { color: #cdeaf3; }
.date-chip.is-today:not(.sel) { border-color: var(--accent); color: var(--accent); }

/* 今日儀表板摘要卡（第 X 天／城市／倒數／下一個重要時間點） */
.hero { background: linear-gradient(135deg, var(--brand), var(--brand-ink)); color: #fff; border: none; }
.hero .hero-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hero .hero-day { font-size: 13px; font-weight: 700; opacity: .92; letter-spacing: .6px; }
.hero .hero-count { font-size: 13px; opacity: .92; }
.hero .hero-city { font-size: 23px; font-weight: 800; margin-top: 2px; }
.hero .hero-next { margin-top: 10px; background: rgba(255,255,255,.16); border-radius: 10px;
  padding: 9px 12px; font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.hero .hero-next .hn-time { font-size: 18px; white-space: nowrap; }

/* 回到頂部浮動按鈕 */
#to-top {
  position: fixed; right: max(14px, env(safe-area-inset-right));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 25;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(255,255,255,.95); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(20,30,40,.18); cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#to-top .icn { width: 20px; height: 20px; }
#to-top.show { opacity: 1; pointer-events: auto; }
