:root {
  --primary: #1A73E8; --primary-bg: #E8F0FE; --danger: #D93025; --warn-bg: #FEF7E0;
  --bg: #F8F9FA; --card: #FFFFFF; --text: #202124; --muted: #5F6368; --line: #E3E5E8;
  --shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px rgba(60,64,67,.15);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 'Roboto', 'Noto Sans TC', -apple-system, 'PingFang TC', sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; }
.err { color: var(--danger); min-height: 1.5em; }
.warn { background: var(--warn-bg); padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.row { display: flex; align-items: center; } .between { justify-content: space-between; }
.gap { gap: 8px; } .grow { flex: 1; }

main { max-width: 560px; margin: 0 auto; padding: 0 16px calc(88px + env(safe-area-inset-bottom)); }
.top { display: flex; justify-content: space-between; align-items: center; padding: 16px 0 8px;
  position: sticky; top: 0; background: var(--bg); z-index: 5; }
.trip { font-size: 20px; font-weight: 500; }
.me { background: var(--primary-bg); color: var(--primary); border-radius: 16px; padding: 4px 12px; font-size: 13px; font-weight: 500; }

.card { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 > .card { margin-bottom: 0; } .view > .grid2 { margin-bottom: 12px; }
.label { font-size: 12px; font-weight: 500; color: var(--muted); }
.big { font-size: 24px; font-weight: 500; margin-top: 4px; }
.sec { font-size: 16px; font-weight: 500; margin: 20px 0 8px; } .sec0 { font-size: 16px; font-weight: 500; margin: 0; }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 8px 0 6px; }
.bar > div { height: 100%; background: var(--primary); width: 0; transition: width .4s; }
.bar.over > div { background: var(--danger); }

/* 記錄列 */
.day-h { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin: 16px 4px 6px; }
.rec { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 12px; box-shadow: var(--shadow);
  padding: 12px; margin-bottom: 8px; cursor: pointer; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 500; flex: none;
  background: var(--primary-bg); color: var(--primary); }
.avatar.Una { background: #F1F3F4; color: #202124; }
.rec .mid { flex: 1; min-width: 0; }
.rec .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec .meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { border: 1px solid var(--line); border-radius: 10px; padding: 0 6px; }
.rec .amt { text-align: right; flex: none; } .rec .amt b { font-weight: 500; }
.empty { text-align: center; color: var(--muted); padding: 24px 0; }

/* 表單 */
label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
.btn { display: inline-block; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  font: inherit; font-weight: 500; color: var(--primary); cursor: pointer; text-align: center; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.danger { color: var(--danger); }
.btn.text { border: none; background: none; }
.btn.block { display: block; width: 100%; margin-top: 8px; }
.btn.small { padding: 4px 8px; font-size: 13px; }
details { margin-bottom: 12px; font-size: 14px; } summary { cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 500; }
.item { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.item span:first-child { min-width: 0; overflow-wrap: anywhere; }

.seg { display: flex; background: #fff; border-radius: 10px; box-shadow: var(--shadow); padding: 4px; margin: 4px 0 8px; }
.seg button { flex: 1; border: none; background: none; padding: 8px; border-radius: 8px; font: inherit; color: var(--muted); }
.seg button.on { background: var(--primary-bg); color: var(--primary); font-weight: 500; }

.preview { max-width: 100%; max-height: 240px; border-radius: 8px; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--primary);
  border-radius: 50%; animation: sp 1s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* 統計 */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; margin-top: 12px; overflow-x: auto; }
.bars .b { flex: 1 0 22px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bars .b i { display: block; width: 100%; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b span { font-size: 10px; color: var(--muted); margin-top: 4px; }
.hrow { margin-top: 10px; }
.hrow .row { justify-content: space-between; font-size: 13px; }
.hrow .bar { margin: 4px 0 0; height: 6px; }

.bottom { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; box-shadow: 0 -1px 3px rgba(60,64,67,.15);
  display: flex; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
.bottom button { flex: 1; border: none; background: none; font: inherit; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; }
.bottom button span { font-size: 20px; line-height: 1; }
.bottom button.on { color: var(--primary); font-weight: 500; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 32px 24px; width: 100%; max-width: 360px; text-align: center; }
.login-card .logo { font-size: 48px; } .login-card h1 { margin: 8px 0 0; font-weight: 500; }
.login-card input { margin: 16px 0 8px; text-align: center; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 50; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #202124; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 60; max-width: 90%; }

/* ---- 修正:display:block 的 input 規則蓋掉了 hidden 屬性 ---- */
[hidden] { display: none !important; }
/* 寬螢幕時底部導覽跟內容同寬 */
.bottom { max-width: 560px; margin: 0 auto; border-radius: 16px 16px 0 0; }
/* 每日長條:天數少時不要撐成一大片 */
.bars .b { flex: 0 1 36px; }
.bars { justify-content: center; }
.bars .b em { font-style: normal; font-size: 10px; color: var(--muted); margin-bottom: 2px; }

/* ================= 小樣:小屋風(?theme=house) ================= */
body.theme-house {
  --primary: #5c466e; --primary-bg: #efe7f1; --bg: #fbf7ef; --card: #fffdf9;
  --text: #2b2931; --muted: #6d6570; --line: rgba(79,66,72,.14);
  --shadow: 0 8px 24px rgba(20,18,28,.08), 0 1px 2px rgba(20,18,28,.06);
  background: radial-gradient(circle at 10% 0%, rgba(148,102,142,.10), transparent 40%), var(--bg);
}
.theme-house .card, .theme-house .rec, .theme-house .seg { border-radius: 18px; border: 1px solid var(--line); }
.theme-house .trip, .theme-house .big, .theme-house .login-card h1 { font-family: "Noto Serif TC", "Songti TC", Georgia, serif; font-weight: 600; letter-spacing: .02em; }
.theme-house .top { background: transparent; backdrop-filter: blur(8px); }
.theme-house .view > .grid2 > .card:first-child {
  background: linear-gradient(155deg, #1c1d36, #2a2544); color: #fbf7ef; border: none;
}
.theme-house .view > .grid2 > .card:first-child .label,
.theme-house .view > .grid2 > .card:first-child .muted { color: rgba(251,247,239,.7); }
.theme-house .view > .grid2 > .card:first-child .big { color: #f2d69a; }
.theme-house .btn.primary { border-radius: 14px; box-shadow: 0 6px 16px rgba(92,70,110,.25); }
.theme-house .btn { border-radius: 14px; }
.theme-house .avatar.Una { background: #f6e7ea; color: #8a4a5c; }
.theme-house .bottom { background: rgba(255,253,249,.92); backdrop-filter: blur(10px); border: 1px solid var(--line); border-bottom: none; }
.theme-house .bar > div, .theme-house .bars .b i { background: linear-gradient(90deg, #8e6e94, #5c466e); }
.theme-house .bars .b i { background: linear-gradient(180deg, #8e6e94, #5c466e); }
.theme-house #scanPick .btn.primary { padding: 28px 16px; font-size: 18px; }
body.theme-house { min-height: 100vh; } html:has(body.theme-house) { background: #fbf7ef; }

/* ================= 質感升級:封面／預算圓環／儲存動畫 ================= */
.cover { position: relative; height: 168px; border-radius: 22px; overflow: hidden; margin: 4px 0 12px;
  background: radial-gradient(circle at 80% 20%, rgba(242,214,154,.35), transparent 45%), linear-gradient(155deg, #1c1d36, #3a2f55 60%, #5c466e); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(16,14,30,.7)); }
.cover-txt { position: absolute; left: 18px; bottom: 14px; right: 18px; z-index: 1; color: #fbf7ef; }
.cover-region { font-family: "Noto Serif TC", "Songti TC", Georgia, serif; font-size: 26px; font-weight: 600; letter-spacing: .04em; }
.cover-hint { position: absolute; top: 12px; right: 12px; z-index: 2; border: 1px solid rgba(251,247,239,.5); background: rgba(251,247,239,.12);
  color: #fbf7ef; border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 12px; cursor: pointer; }

.budget { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: center; position: relative; }
.ring { width: 96px; height: 96px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--primary); stroke-linecap: round; stroke-dasharray: 314.16; stroke-dashoffset: 314.16; transition: stroke-dashoffset 1s cubic-bezier(.2,.8,.2,1); }
.budget.over .ring-fg { stroke: var(--danger); }
.ring-pct { position: absolute; left: 16px; top: 50%; width: 96px; transform: translateY(-50%); text-align: center; line-height: 1.1; }
.ring-pct b { display: block; font-size: 22px; font-weight: 600; font-family: "Noto Serif TC", "Songti TC", Georgia, serif; }
.ring-pct span { font-size: 10px; color: var(--muted); }
.budget-used { font-size: 15px; font-weight: 500; margin: 2px 0; overflow-wrap: anywhere; }

.savedfx { position: fixed; inset: 0; display: grid; place-items: center; z-index: 70; background: rgba(251,247,239,.55);
  backdrop-filter: blur(3px); animation: fxIn .2s ease-out; }
.savedfx-card { background: var(--card); border-radius: 22px; padding: 24px 32px; text-align: center; box-shadow: 0 16px 42px rgba(20,18,28,.18);
  font-weight: 500; color: var(--primary); animation: pop .45s cubic-bezier(.2,1.4,.4,1); }
.savedfx svg { width: 64px; height: 64px; display: block; margin: 0 auto 8px; }
.savedfx circle { fill: none; stroke: var(--primary); stroke-width: 3; stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw .5s ease-out forwards; }
.savedfx path { fill: none; stroke: var(--primary); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .35s .4s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
@keyframes fxIn { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .savedfx, .savedfx * { animation: none !important; } .savedfx circle, .savedfx path { stroke-dashoffset: 0; } .ring-fg { transition: none; } }

/* ================= 去重複編碼(一個意思只表達一次) ================= */
.home-link { color: var(--primary); text-decoration: none; font-size: 13px; font-weight: 500; padding: 4px 4px; }
/* 卡片:有柔和陰影就不再加外框線 */
.theme-house .card, .theme-house .rec, .theme-house .seg { border: none; }
/* 分段切換:底色+顏色已足夠,不再加粗 */
.seg button.on { font-weight: 400; }
/* 類別:用淡底小字,不要框線+底色+文字三重 */
.rec .meta { flex-wrap: nowrap; min-width: 0; }
.rec .cat { flex: none; background: var(--primary-bg); color: var(--primary); border-radius: 6px; padding: 0 6px; font-size: 11px; }
.rec .store { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 導覽:單色線條 icon,選中只靠顏色+淡底膠囊 */
.bottom svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; padding: 2px 14px; box-sizing: content-box; border-radius: 999px; }
.bottom button.on { font-weight: 400; }
.bottom button.on svg { background: var(--primary-bg); }

/* ================= 首頁:頂列疊進封面 ================= */
.cover { margin-top: 12px; }
.cover-top { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 2; display: flex; justify-content: space-between; }
.cover-chip { background: rgba(16,14,30,.35); backdrop-filter: blur(6px); color: #fbf7ef; border-radius: 999px;
  padding: 4px 12px; font-size: 13px; font-weight: 500; text-decoration: none; }
.cover-hint { top: auto; bottom: 14px; }
/* ================= 兩人配色:David 梅紫/Una 玫瑰 ================= */
.theme-house .avatar.David { background: #e6ddf0; color: #5c466e; }
.theme-house .avatar.Una { background: #f6dde4; color: #9c4560; }
.theme-house .u-Una .bar > div { background: linear-gradient(90deg, #d49baa, #9c4560); }
.cover { background: url(cover-default.svg) center/cover no-repeat, #3a2f55; }

.settle { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; }
.settle:empty { display: none; }

/* ===================== v6 質感整理（2026-09-24 預覽） ===================== */
/* 線條 icon：跟小屋同一套筆畫 */
.ic { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; margin-right: 6px; }
.cover-chip, .me { display: inline-flex; align-items: center; }
.cover-chip .ic, .me .ic { width: 14px; height: 14px; margin-right: 4px; }
.btn .ic { margin-right: 8px; }

/* 數字：等寬直立數字，金額上下對齊不跳動 */
.big, .budget-used, .rec .amt, .ring-pct b, .hrow, #perUser, .settle, .bars em { font-variant-numeric: tabular-nums lining-nums; }
.theme-house .big { font-size: 26px; letter-spacing: 0; line-height: 1.2; margin-top: 6px; }
.label { letter-spacing: 0.04em; }
.stat { display: flex; flex-direction: column; min-height: 112px; }
.stat .small { margin-top: auto; padding-top: 4px; }

/* 預算卡：主數字放大，一眼看到「用了多少」 */
.budget-used { font-family: "Noto Serif TC", "Songti TC", Georgia, serif; font-size: 18px; font-weight: 600; margin: 4px 0 2px; }

/* 各自負擔：名字與金額同一層級、金額靠右對齊 */
#perUser .row { font-size: 14px; }
.settle { line-height: 1.6; color: var(--text); }
.settle .ic { color: var(--primary); margin-right: 4px; }

/* 區塊標題跟小屋同一套襯線字 */
.theme-house .sec { font-family: "Noto Serif TC", "Songti TC", Georgia, serif; font-size: 18px; font-weight: 600;
  letter-spacing: 0.04em; margin: 24px 4px 10px; }
.rec { padding: 14px; }
.rec .amt b { font-size: 16px; }

/* ===================== 列表：左滑刪除＋多選刪除（2026-09-24） ===================== */
.list-tools { display: flex; align-items: center; gap: 8px; margin: 4px 0 4px; }
.list-tools .seg { flex: 1; margin: 0; }
.sel-btn { flex: none; min-height: 44px; padding: 0 16px; border: 0; border-radius: 14px; background: var(--card);
  box-shadow: var(--shadow); color: var(--primary); font: inherit; font-weight: 500; cursor: pointer; }
.list-hint { margin: 8px 4px 0; }
.selecting .list-hint { visibility: hidden; }

/* 左滑：紅色刪除鈕藏在卡片後面，滑開才出現 */
.rec-wrap { position: relative; margin-bottom: 8px; border-radius: 18px; }
.rec-wrap .rec { position: relative; z-index: 1; margin-bottom: 0; transition: transform .22s cubic-bezier(.2,.8,.2,1); }
.rec-del { position: absolute; top: 0; right: 0; bottom: 0; width: 100px; padding-left: 12px; border: 0; border-radius: 18px;
  background: #b8475a; color: #fff; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; opacity: 0; pointer-events: none; }
.rec-del .ic { width: 20px; height: 20px; margin: 0; }
.rec-wrap.open .rec-del, .rec-wrap.swiping .rec-del { opacity: 1; pointer-events: auto; }

/* 選取模式：左邊出現勾選圈 */
.rec .pick { display: none; flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.8px solid rgba(92,70,110,.35); }
.rec .pick svg { width: 100%; height: 100%; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.selecting .rec .pick { display: block; }
.selecting .rec { user-select: none; -webkit-user-select: none; }
.rec.picked { box-shadow: 0 0 0 2px var(--primary), var(--shadow); }
.rec.picked .pick { background: var(--primary); border-color: var(--primary); }
.rec.picked .pick svg { opacity: 1; }
.rec { -webkit-touch-callout: none; }

/* 底部操作列：貼在導覽列上方 */
.sel-bar { position: fixed; left: 0; right: 0; max-width: 560px; margin: 0 auto; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 11;
  display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; background: var(--card);
  border-radius: 18px 18px 0 0; box-shadow: 0 -6px 20px rgba(20,18,28,.1); }
.sel-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.sel-info b { font-weight: 500; }
.btn.danger-fill { background: #b8475a; color: #fff; border-color: #b8475a; min-height: 44px; }
.btn.danger-fill:disabled { background: #e8dfe2; border-color: #e8dfe2; color: #9a8f95; box-shadow: none; }
.sel-bar .btn.text { min-height: 44px; }
#v-list.selecting { padding-bottom: 80px; }
/* 滑動只在卡片自己的框裡，不衝出螢幕；選取列出現時提示往上讓位 */
.rec-wrap { overflow: hidden; box-shadow: var(--shadow); }
.rec-wrap .rec { box-shadow: none; }
.rec-wrap .rec.picked { box-shadow: inset 0 0 0 2px var(--primary); }
body:has(#v-list.selecting:not(.hidden)) .toast { bottom: calc(150px + env(safe-area-inset-bottom)); }

/* ===================== 幣別切換＋iPhone 日期欄溢出修正（2026-09-25） ===================== */
.amt-field { margin-bottom: 12px; min-width: 0; }
.amt-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.flabel { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.cur { display: inline-flex; padding: 2px; border-radius: 999px; background: var(--primary-bg); }
.cur button { min-width: 40px; min-height: 30px; padding: 0 8px; border: 0; border-radius: 999px; background: none;
  color: var(--muted); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; }
.cur button.on { background: var(--card); color: var(--primary); box-shadow: 0 1px 3px rgba(20,18,28,.12); }
.amt-field input { margin-top: 4px; }
.conv { min-height: 1.5em; margin-top: 4px; }
/* iPhone 的日期欄有自己的最小寬度，會撐出格子外 */
.grid2 > * { min-width: 0; }
input[type="date"] { -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; min-height: 44px; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
/* 金額與日期兩格的輸入框對齊（金額那格標題列有切換鈕，比較高） */
.amt-head { min-height: 34px; }
.grid2:has(.amt-field) > label { line-height: 34px; }
.grid2:has(.amt-field) > label input { line-height: normal; margin-top: 4px; }
