:root {
  /* 全新配色：海洋藍綠 × 珊瑚橘的手帳風，刻意跟記帳 App 的抹茶綠不同 */
  --brand: #1F8A8C;
  --brand-dark: #15686A;
  --brand-soft: #d9ecec;
  --accent: #E8845C;
  --bg: #F3F6F7;
  --card: #ffffff;
  --ink: #2A3340;
  --muted: #8A93A0;
  --line: #e4e9ec;

  /* 各類型代表色 */
  --flight: #5B6FB0;
  --stay: #1F8A8C;
  --car: #5FA77E;
  --voucher: #C77BA0;
  --move: #4C8DB8;
  --sight: #9B6BC4;
  --meal: #E0915A;
  --shop: #D98344;
  --danger: #d2685a;

  --radius: 18px;
  --shadow: 0 4px 16px rgba(40,60,70,.08);
  --tabbar-h: 62px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; }
.app { max-width: 720px; margin: 0 auto; min-height: 100%; position: relative; }

/* ---------- 書架（旅程列表）---------- */
.shelf { padding: 0 16px 40px; }
.shelf-top {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; margin: 0 -16px 22px; padding: 30px 20px 26px;
  border-radius: 0 0 26px 26px;
}
.shelf-top h1 { font-size: 1.6rem; margin: 0; letter-spacing: 1px; }
.shelf-top .sub { opacity: .9; margin: 4px 0 0; font-size: .92rem; }
.trip-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow); cursor: pointer; transition: transform .1s;
}
.trip-card:active { transform: scale(.99); }
.trip-card .cover {
  width: 58px; height: 58px; border-radius: 16px; flex: none;
  display: grid; place-items: center; font-size: 1.9rem; background: var(--brand-soft);
}
.trip-card .info { flex: 1; min-width: 0; }
.trip-card .info .name { font-weight: 700; font-size: 1.08rem; }
.trip-card .info .meta { color: var(--muted); font-size: .85rem; }
.trip-card .info .members { color: var(--brand-dark); font-size: .8rem; margin-top: 2px; }
.trip-card .go { color: var(--muted); font-size: 1.4rem; }

.new-trip-btn {
  width: 100%; padding: 16px; border-radius: var(--radius);
  background: var(--brand); color: #fff; font-size: 1rem; font-weight: 600;
  box-shadow: var(--shadow); margin-top: 6px;
}
.shelf-empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.shelf-empty .big { font-size: 2.8rem; }
.backup-row { display: flex; gap: 10px; margin-top: 14px; }
.backup-btn { flex: 1; text-align: center; padding: 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); color: var(--brand-dark); font-weight: 600; font-size: .92rem; cursor: pointer; }
.backup-btn:active { transform: scale(.99); }
.backup-hint { color: var(--muted); font-size: .8rem; text-align: center; margin: 10px 4px 0; }

/* ---------- 旅程內部 ---------- */
.trip-view { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 10px rgba(40,60,70,.12); }
.trip-header {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; padding: 14px 14px;
  display: flex; align-items: center; gap: 10px;
}
.trip-header .back { background: rgba(255,255,255,.2); color: #fff; border-radius: 12px; padding: 6px 13px; font-size: 1.2rem; line-height: 1; }
.trip-header .title { flex: 1; min-width: 0; }
.trip-header .title .t { font-weight: 700; font-size: 1.08rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-header .title .d { font-size: .78rem; opacity: .9; }
.icon-btn.head { color: #fff; font-size: 1.15rem; }

.pane { padding: 14px 14px 28px; }
.pane-title { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 14px; }
.pane-title h2 { font-size: 1.2rem; margin: 0; }
.add-btn { background: var(--brand); color: #fff; border-radius: 999px; padding: 8px 15px; font-size: .9rem; font-weight: 600; }
.add-btn.ghost { background: var(--card); color: var(--brand-dark); border: 1.5px solid var(--brand-soft); }

/* 日期橫排 */
.daystrip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 14px; }
.daystrip::-webkit-scrollbar { height: 0; }
.daychip {
  flex: none; min-width: 58px; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 15px;
  padding: 8px 8px; font-size: .78rem; color: var(--muted); line-height: 1.35;
}
.daychip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.daychip .num { font-size: 1.2rem; font-weight: 700; color: inherit; }
.daychip.prep { font-weight: 700; }

/* ---------- 縱向時間軸 ---------- */
.timeline { position: relative; margin: 6px 0 4px; padding-left: 4px; }
.tl-item { position: relative; display: flex; gap: 12px; padding-bottom: 4px; }
.tl-time { flex: none; width: 50px; text-align: right; padding-top: 14px; }
.tl-time .s { font-weight: 700; font-size: .9rem; }
.tl-time .e { font-size: .72rem; color: var(--muted); }
.tl-rail { flex: none; width: 18px; position: relative; display: flex; justify-content: center; }
.tl-rail::before {
  content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--line);
}
.tl-item:first-child .tl-rail::before { top: 16px; }
.tl-item:last-child .tl-rail::before { bottom: calc(100% - 28px); }
.tl-dot {
  width: 14px; height: 14px; border-radius: 50%; margin-top: 16px;
  background: #fff; border: 3px solid var(--brand); z-index: 1;
}
.tl-body { flex: 1; min-width: 0; }

/* 卡片通用 */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 14px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.card.lline { border-left: 5px solid var(--line); }
.card.flight { border-left-color: var(--flight); }
.card.stay { border-left-color: var(--stay); }
.card.car { border-left-color: var(--car); }
.card.voucher { border-left-color: var(--voucher); }
.card.move { border-left-color: var(--move); }
.card.sight { border-left-color: var(--sight); }
.card.meal { border-left-color: var(--meal); }
.card.shop { border-left-color: var(--shop); }
.card.split { border-left-color: var(--accent); }
.card.split .ctype { color: var(--accent); }
.card .chead { display: flex; align-items: center; gap: 8px; }
.card .ctype { font-size: .76rem; font-weight: 700; }
.card.flight .ctype { color: var(--flight); }
.card.stay .ctype { color: var(--stay); }
.card.car .ctype { color: var(--car); }
.card.voucher .ctype { color: var(--voucher); }
.card.move .ctype { color: var(--move); }
.card.sight .ctype { color: var(--sight); }
.card.meal .ctype { color: var(--meal); }
.card.shop .ctype { color: var(--shop); }
.card .ctitle { font-weight: 700; flex: 1; min-width: 0; }
.card .cactions { display: flex; gap: 2px; }
.card .fields { margin-top: 6px; font-size: .9rem; }
.card .fields div { margin-top: 2px; }
.card .fields .lab { color: var(--muted); margin-right: 5px; }
.pill { display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 999px; font-weight: 700; }
.pill.ok { background: #def0e6; color: #2e7d54; }
.pill.no { background: #fae3df; color: var(--danger); }
.maplink { color: var(--brand); text-decoration: none; font-weight: 600; }
.card.clickable { cursor: pointer; }
.card.clickable:active { transform: scale(.995); }
.card .goto { color: var(--brand); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.card.flash { animation: flash 1.4s ease; }
@keyframes flash {
  0%, 100% { box-shadow: var(--shadow); }
  20%, 60% { box-shadow: 0 0 0 3px var(--brand); }
}
/* 機票：航線視覺 + 細節格 */
.flight-sum { border-left-color: var(--flight); }
.fs-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fs-airline { font-weight: 700; }
.fs-cities { font-size: .84rem; color: var(--muted); margin-top: 3px; }
.fs-cities b { color: var(--ink); font-weight: 700; }
.fs-cabin { background: var(--brand-soft); color: var(--brand-dark); font-size: .72rem; font-weight: 700; padding: 2px 11px; border-radius: 999px; white-space: nowrap; }
.fs-route { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; }
.fs-end { flex: 1; min-width: 0; }
.fs-end.right { text-align: right; }
.fs-time { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.fs-air { font-size: .95rem; font-weight: 700; color: var(--flight); margin-top: 3px; }
.fs-term { font-size: .72rem; color: var(--muted); margin-top: 1px; }
.fs-mid { flex: 0 0 92px; text-align: center; }
.fs-dur { font-size: .74rem; color: var(--muted); margin-bottom: 3px; }
.fs-line { display: flex; align-items: center; justify-content: center; color: var(--flight); font-size: .95rem; }
.fs-line span { height: 2px; width: 24px; background: var(--line); }
.fs-foot { text-align: right; border-top: 1px solid var(--line); padding-top: 7px; margin-top: 8px; }
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.statgrid .stat { background: #f5f9f9; border-radius: 10px; padding: 7px 11px; }
.statgrid .sl { font-size: .72rem; color: var(--muted); }
.statgrid .sv { font-weight: 600; font-size: .92rem; word-break: break-word; }
/* 住宿卡 */
.stay-cover { width: 100%; height: 170px; object-fit: cover; border-radius: 12px; margin: 4px 0 10px; display: block; }
.navbtn { background: var(--flight); color: #fff; text-decoration: none; font-size: .78rem; font-weight: 700; padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
.stay-boxes { display: flex; gap: 8px; margin-bottom: 4px; }
.stay-box { flex: 1; background: #f5f9f9; border-radius: 12px; padding: 9px 12px; text-align: center; }
.stay-box .bl { font-size: .74rem; color: var(--muted); }
.stay-box .bv { font-weight: 700; font-size: .9rem; margin-top: 2px; }
.irow { margin-top: 4px; }
.irow .ii { margin-right: 6px; }

/* 憑證縮圖 + 放大檢視 */
.docs-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.doc-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; }
.docs-thumbs.edit .docwrap { position: relative; display: inline-block; }
.docs-thumbs.edit .docwrap img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.docs-thumbs.edit .rm { position: absolute; top: -7px; right: -7px; width: 21px; height: 21px; border-radius: 50%; background: var(--danger); color: #fff; font-size: .7rem; line-height: 1; }
.rm-mini { margin-top: 6px; padding: 7px 13px; font-size: .85rem; }
.uploader { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 8px; padding: 18px 14px; border: 2px dashed var(--brand); border-radius: 14px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: .98rem; cursor: pointer; text-align: center; }
.uploader:active { transform: scale(.99); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: none; align-items: center; justify-content: center; z-index: 80; padding: 12px; }
.lightbox.show { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.shop-thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex: none; }
.photo-prev { max-width: 100%; max-height: 200px; border-radius: 10px; margin-bottom: 6px; display: block; }
.icon-btn { background: transparent; color: var(--muted); padding: 5px 7px; border-radius: 8px; font-size: .95rem; }
.icon-btn:hover { background: rgba(0,0,0,.05); }

.section-label { font-size: .85rem; color: var(--muted); font-weight: 700; margin: 16px 2px 8px; }
.empty-hint { color: var(--muted); text-align: center; padding: 26px 12px; font-size: .9rem; }

/* 天氣卡 */
.weather {
  background: linear-gradient(135deg, #6fb3c4, #4d8fb0); color: #fff;
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.weather .city { font-weight: 700; }
.weather .temp { font-size: 1.8rem; font-weight: 700; }
.weather .note { font-size: .82rem; opacity: .92; }
.weather.placeholder { background: #d3dde0; color: var(--brand-dark); }

/* 行前 checklist */
.checkrow {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
}
.checkrow input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--brand); }
.checkrow .txt { flex: 1; }
.checkrow.done .txt { color: var(--muted); text-decoration: line-through; }

/* 必買購物清單 */
.shoprow {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
}
.shoprow input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--shop); }
.shoprow .txt { flex: 1; min-width: 0; }
.shoprow .txt .it { font-weight: 600; }
.shoprow .txt .meta { color: var(--muted); font-size: .8rem; }
.shoprow.done .txt .it { color: var(--muted); text-decoration: line-through; }

/* 成員（在設定裡） */
.member-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-soft); color: var(--brand-dark);
  border-radius: 999px; padding: 5px 12px; margin: 0 6px 6px 0; font-size: .9rem; font-weight: 600;
}
.member-chip button { background: transparent; color: var(--brand-dark); padding: 0 0 0 2px; font-size: .9rem; }

/* 分帳 */
.settle-row { display: flex; align-items: center; gap: 6px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.settle-row:last-child { border-bottom: none; }
.settle-row .amt { margin-left: auto; font-weight: 700; color: var(--brand-dark); }
.net-row { display: flex; align-items: center; justify-content: space-between; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; }
.net-row .nm { font-weight: 600; }
.twd { color: var(--muted); font-size: .82rem; margin-left: 6px; }
.checkpicks { display: flex; flex-wrap: wrap; gap: 8px; }
.checkpick { display: inline-flex; align-items: center; gap: 6px; background: #f5f9f9; border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px; font-size: .9rem; cursor: pointer; }
.checkpick input { width: 18px; height: 18px; accent-color: var(--brand); }

/* 記帳串接卡 */
.link-card {
  background: var(--card); border: 1.5px dashed var(--brand); border-radius: var(--radius);
  padding: 22px 18px; text-align: center;
}
.link-card .big { font-size: 2.2rem; }
.link-card a {
  display: inline-block; margin-top: 10px; background: var(--brand); color: #fff;
  text-decoration: none; padding: 11px 20px; border-radius: 999px; font-weight: 600;
}

/* 預訂子分頁 */
.subtabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; }
.subtab { flex: 1; min-width: max-content; white-space: nowrap; text-align: center; padding: 9px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: .88rem; font-weight: 600; }
.subtab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- 頂部櫃子 tab bar ---------- */
.tabbar {
  width: 100%; height: var(--tabbar-h);
  background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; z-index: 30;
}
.tabbar button {
  flex: 1; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .66rem; border-bottom: 3px solid transparent;
}
.tabbar button .ic { font-size: 1.2rem; }
.tabbar button.active { color: var(--brand-dark); font-weight: 700; border-bottom-color: var(--brand); }

/* ---------- 彈出表單 ---------- */
.overlay { position: fixed; inset: 0; background: rgba(30,40,45,.5); display: none; align-items: flex-end; justify-content: center; z-index: 60; }
.overlay.show { display: flex; }
.sheet { background: var(--card); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 18px 18px 26px; max-height: 90vh; overflow-y: auto; animation: rise .18s ease; }
@keyframes rise { from { transform: translateY(26px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet h3 { margin: 0 0 14px; font-size: 1.12rem; }
.sheet .sub-label { font-size: .82rem; color: var(--muted); margin: 14px 2px 8px; font-weight: 700; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .83rem; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; font-family: inherit; font-size: 1rem; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.field textarea { min-height: 70px; resize: vertical; }
.field.inline { display: flex; align-items: center; gap: 8px; }
.field.inline input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--brand); }
.field.inline label { margin: 0; }
.two { display: flex; gap: 10px; }
.two > .field { flex: 1; min-width: 0; }
.field input[type=date] { -webkit-appearance: none; appearance: none; }
.sheet-actions { display: flex; gap: 8px; margin-top: 6px; }
.sheet-actions button { flex: 1; padding: 12px; border-radius: 12px; font-size: 1rem; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #ecc6c0; }

@media (min-width: 600px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 22px; }
}
