/* 旅帳 — 預設（楓紅）：朱色、和紙底、落葉。其他風格在下面用 [data-theme] 覆蓋 */
:root {
  --bg: #f6efe2;        /* 和紙 */
  --card: #fffaf0;
  --soft: #ecdfc8;
  --text: #2c2320;      /* 墨 */
  --muted: #8a7a6c;
  --line: #e3d5bd;
  --brand: #c8372d;     /* 鳥居朱 */
  --brand-2: #e2603a;   /* 楓橘 */
  --brand-ink: #b02a22;
  --on-brand: #fff8ec;
  --gold: #b8922e;      /* 金箔 */
  --good: #3f7a57;      /* 松葉綠 */
  --good-bg: #dfeadb;
  --warn: #b02a22;
  --warn-bg: #f6dcd4;
  --notice: #f6e7b8;
  --shadow: 0 4px 16px rgb(90 50 30 / 0.1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --smooth: cubic-bezier(0.22, 1, 0.36, 1);
  --serif: 'Hiragino Mincho ProN', 'Songti TC', 'Noto Serif TC', 'Yu Mincho', serif;
  /* 主視覺卡上的花紋：青海波 */
  --pattern:
    radial-gradient(circle at 50% 100%, transparent 13px, rgb(255 255 255 / 0.1) 14px, transparent 15px) 0 0 / 32px 16px,
    radial-gradient(circle at 50% 100%, transparent 13px, rgb(255 255 255 / 0.1) 14px, transparent 15px) 16px 8px / 32px 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120f;      /* 夜裡的參道 */
    --card: #231b17;
    --soft: #33271f;
    --text: #f3e9da;
    --muted: #a8978a;
    --line: #3a2c24;
    --brand: #d9483b;
    --brand-2: #e8743f;
    --brand-ink: #f08a6c;
    --on-brand: #fff3e6;
    --gold: #d6b25a;
    --good: #8fcfa2;
    --good-bg: #1e3327;
    --warn: #f09a8a;
    --warn-bg: #40201b;
    --notice: #3a3018;
    --shadow: 0 4px 16px rgb(0 0 0 / 0.35);
  }
}

/* ───────── 藍瓷：白灰泥牆、藍瓷磚、赤陶與陽光 ───────── */
:root[data-theme='euro'] {
  --bg: #f7f2e8;        /* 灰泥牆 */
  --card: #fffdf8;
  --soft: #e4ebf2;
  --text: #1f2a37;
  --muted: #6f7b88;
  --line: #dfe3e2;
  --brand: #1f4e8c;     /* 藍瓷磚 */
  --brand-2: #2f79b8;
  --brand-ink: #1b4479;
  --on-brand: #fffaf0;
  --gold: #e0a93b;      /* 陽光 */
  --good: #4a7c3a;      /* 橄欖綠 */
  --good-bg: #e3edd9;
  --warn: #c0502f;      /* 赤陶 */
  --warn-bg: #f8e1d6;
  --notice: #fbeab8;
  --shadow: 0 4px 16px rgb(30 60 100 / 0.1);
  --serif: 'Didot', 'Bodoni 72', Georgia, 'Songti TC', 'Noto Serif TC', serif;
  /* 花紋：瓷磚菱格 */
  --pattern:
    radial-gradient(circle, rgb(255 255 255 / 0.16) 0 2.5px, transparent 3.5px) 0 0 / 28px 28px,
    linear-gradient(45deg, transparent 47%, rgb(255 255 255 / 0.1) 48% 52%, transparent 53%) 14px 14px / 28px 28px,
    linear-gradient(-45deg, transparent 47%, rgb(255 255 255 / 0.1) 48% 52%, transparent 53%) 14px 14px / 28px 28px;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme='euro'] {
    --bg: #101722;      /* 地中海的夜 */
    --card: #19222f;
    --soft: #243245;
    --text: #eef2f6;
    --muted: #98a6b5;
    --line: #2a384b;
    --brand: #3f86d0;
    --brand-2: #5aa0df;
    --brand-ink: #8fc0f0;
    --on-brand: #fffaf0;
    --gold: #f0c05a;
    --good: #a6d38f;
    --good-bg: #20331c;
    --warn: #f0a080;
    --warn-bg: #43241a;
    --notice: #3b3319;
    --shadow: 0 4px 16px rgb(0 0 0 / 0.35);
  }
}

/* ───────── 主頁專用：燕麥米底、鼠尾草綠、麥穗金（不是旅程風格） ───────── */
:root[data-theme='home'] {
  --bg: #f4efe6;
  --card: #fbf8f2;
  --soft: #e6e4d6;
  --text: #3b3a32;
  --muted: #8a8778;
  --line: #e3dfd2;
  --brand: #6b8169;
  --brand-2: #93a98f;
  --brand-ink: #55694f;
  --on-brand: #fbf8f2;
  --gold: #c9b88a;
  --good: #5b8a5a;
  --good-bg: #e2ecd9;
  --warn: #b8604a;
  --warn-bg: #f5e0d8;
  --notice: #f3ead0;
  --shadow: 0 4px 16px rgb(70 80 60 / 0.1);
  --serif: ui-rounded, 'SF Pro Rounded', 'Hiragino Maru Gothic ProN', 'Yuanti TC', 'PingFang TC', sans-serif;
  /* 花紋：細細的斜紋，像亞麻布 */
  --pattern: repeating-linear-gradient(135deg, rgb(255 255 255 / 0.08) 0 2px, transparent 2px 12px);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme='home'] {
    --bg: #171915;
    --card: #21241e;
    --soft: #2e3329;
    --text: #eeece2;
    --muted: #a3a595;
    --line: #343a2f;
    --brand: #7f987c;
    --brand-2: #9db59a;
    --brand-ink: #b5cbb1;
    --on-brand: #141a13;
    --gold: #c9b88a;
    --good: #a3cf92;
    --good-bg: #22331c;
    --warn: #f0a08c;
    --warn-bg: #43241c;
    --notice: #33301c;
    --shadow: 0 4px 16px rgb(0 0 0 / 0.35);
  }
}

/* ───────── 霜雪：雪白、冰湖藍、極光綠 ───────── */
:root[data-theme='nordic'] {
  --bg: #f2f6f7;
  --card: #ffffff;
  --soft: #dfeaee;
  --text: #1d2b33;
  --muted: #6b7f89;
  --line: #dbe5e8;
  --brand: #2a6f8f;
  --brand-2: #4fa3a5;
  --brand-ink: #215d79;
  --on-brand: #f7fdff;
  --gold: #b9ccd3;
  --good: #3d8168;
  --good-bg: #dcefe6;
  --warn: #b9553f;
  --warn-bg: #f6e0da;
  --notice: #e8f0dc;
  --shadow: 0 4px 16px rgb(30 70 90 / 0.1);
  --serif: 'Avenir Next', 'Helvetica Neue', 'PingFang TC', 'Noto Sans TC', sans-serif;
  /* 花紋：疏疏的雪點 */
  --pattern:
    radial-gradient(circle, rgb(255 255 255 / 0.22) 0 1.5px, transparent 2.5px) 0 0 / 34px 34px,
    radial-gradient(circle, rgb(255 255 255 / 0.14) 0 2.5px, transparent 3.5px) 17px 17px / 34px 34px;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme='nordic'] {
    --bg: #0d1519;
    --card: #162127;
    --soft: #213038;
    --text: #e9f2f5;
    --muted: #8fa5ae;
    --line: #263740;
    --brand: #3f93b5;
    --brand-2: #5fc0b8;
    --brand-ink: #8fd3e6;
    --on-brand: #f7fdff;
    --gold: #9fb6c0;
    --good: #86d3b0;
    --good-bg: #17332a;
    --warn: #f0a08c;
    --warn-bg: #41231c;
    --notice: #2b3520;
    --shadow: 0 4px 16px rgb(0 0 0 / 0.35);
  }
}

/* ───────── 椰影：淺灘綠、潟湖藍、珊瑚橘 ───────── */
:root[data-theme='island'] {
  --bg: #f3faf7;
  --card: #ffffff;
  --soft: #d9f0ea;
  --text: #173a3a;
  --muted: #5f8583;
  --line: #d5ebe5;
  --brand: #0e8a8a;
  --brand-2: #2bb8a6;
  --brand-ink: #0b7272;
  --on-brand: #f5fffd;
  --gold: #ff9f6b;
  --good: #2f8f5b;
  --good-bg: #dcf3e3;
  --warn: #d9534a;
  --warn-bg: #fde2df;
  --notice: #fff0c9;
  --shadow: 0 4px 16px rgb(10 100 100 / 0.1);
  --serif: ui-rounded, 'SF Pro Rounded', 'Yuanti TC', 'PingFang TC', sans-serif;
  /* 花紋：一道道浪 */
  --pattern:
    radial-gradient(circle at 50% 0, transparent 15px, rgb(255 255 255 / 0.12) 16px, transparent 17px) 0 0 / 36px 18px,
    radial-gradient(circle at 50% 0, transparent 15px, rgb(255 255 255 / 0.12) 16px, transparent 17px) 18px 9px / 36px 18px;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme='island'] {
    --bg: #0b1a1b;
    --card: #122628;
    --soft: #1b3638;
    --text: #e6f6f3;
    --muted: #88b0ac;
    --line: #1f3d3f;
    --brand: #1aa7a0;
    --brand-2: #45cdb6;
    --brand-ink: #7fe0d2;
    --on-brand: #f5fffd;
    --gold: #ffb38a;
    --good: #7fdba3;
    --good-bg: #163626;
    --warn: #ff9d94;
    --warn-bg: #45211e;
    --notice: #3a3218;
    --shadow: 0 4px 16px rgb(0 0 0 / 0.35);
  }
}

/* ───────── 霓虹：水泥灰、電光紫、霓虹桃 ───────── */
:root[data-theme='city'] {
  --bg: #f4f4f7;
  --card: #ffffff;
  --soft: #e6e6f0;
  --text: #1b1b2a;
  --muted: #73738a;
  --line: #e0e0ea;
  --brand: #4b3fd1;
  --brand-2: #c247c9;
  --brand-ink: #4035b8;
  --on-brand: #ffffff;
  --gold: #ffd23f;
  --good: #1e8f6a;
  --good-bg: #dcf2ea;
  --warn: #d43d6a;
  --warn-bg: #fde0e9;
  --notice: #fff3c4;
  --shadow: 0 4px 16px rgb(60 50 160 / 0.1);
  --serif: 'Futura', 'Avenir Next Condensed', 'Avenir Next', 'PingFang TC', 'Noto Sans TC', sans-serif;
  /* 花紋：大樓的窗格 */
  --pattern:
    linear-gradient(rgb(255 255 255 / 0.09) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(90deg, rgb(255 255 255 / 0.09) 1px, transparent 1px) 0 0 / 22px 22px;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme='city'] {
    --bg: #0e0e17;
    --card: #181826;
    --soft: #24243a;
    --text: #f0f0fa;
    --muted: #9a9ab5;
    --line: #2a2a42;
    --brand: #6f62f0;
    --brand-2: #e05ce0;
    --brand-ink: #a9a1ff;
    --on-brand: #ffffff;
    --gold: #ffe066;
    --good: #6fe0b8;
    --good-bg: #14332a;
    --warn: #ff86a8;
    --warn-bg: #45192a;
    --notice: #38321a;
    --shadow: 0 4px 16px rgb(0 0 0 / 0.4);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { transition: background 0.4s ease, color 0.4s ease; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 'Hiragino Sans', 'PingFang TC', 'Noto Sans TC', -apple-system, 'Segoe UI', sans-serif;
  -webkit-text-size-adjust: 100%;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
main { padding: 16px 16px calc(104px + env(safe-area-inset-bottom)); }
h1, h2 { font-family: var(--serif); font-weight: 700; letter-spacing: 0.08em; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 20px; }
h3 {
  font-family: var(--serif); font-size: 14px; color: var(--muted); font-weight: 700; letter-spacing: 0.1em;
  margin: 28px 2px 10px; display: flex; align-items: center; gap: 8px;
}
h3::before { content: ''; width: 4px; height: 14px; background: var(--brand); border-radius: 1px; flex: none; }
a { color: var(--brand-ink); }
code { font-family: ui-monospace, Menlo, monospace; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.good { color: var(--good); }
.warn { color: var(--warn); }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; white-space: nowrap; }
.title { font-weight: 700; }
.loading { color: var(--muted); text-align: center; padding: 48px 0; animation: breathe 1.2s ease-in-out infinite; }

/* ───────── 動畫 ───────── */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
@keyframes breathe { 50% { opacity: 0.45; } }
@keyframes wiggle { 0%, 100% { transform: rotate(-12deg) scale(1.1); } 50% { transform: rotate(12deg) scale(1.1); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes fab-in { from { opacity: 0; transform: translateY(24px) scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes stamp { from { opacity: 0; transform: scale(1.8) rotate(-14deg); } to { opacity: 1; transform: rotate(-6deg); } }
@keyframes fall {
  0%   { transform: translate3d(0, -10vh, 0) rotate(0deg); }
  25%  { transform: translate3d(calc(var(--sway) * 1), 22vh, 0) rotate(130deg); }
  50%  { transform: translate3d(calc(var(--sway) * -0.6), 54vh, 0) rotate(250deg); }
  75%  { transform: translate3d(calc(var(--sway) * 1.2), 86vh, 0) rotate(400deg); }
  100% { transform: translate3d(calc(var(--sway) * 0.2), 118vh, 0) rotate(540deg); }
}

.page-in { animation: rise 0.38s var(--smooth) both; }
.pop { animation: pop 0.42s var(--spring) both; animation-delay: calc(var(--d, 0) * 45ms); }

/* 飄落的楓葉：蓋在內容上、壓在頁首與面板下，不擋點擊 */
.leaves { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 4; }
.leaves i {
  position: absolute; top: 0; font-style: normal; opacity: 0.5; will-change: transform;
  animation: fall linear infinite;
}
.leaves i:nth-child(1) { left: 6%;  font-size: 16px; --sway: 30px; animation-duration: 17s; animation-delay: -2s; }
.leaves i:nth-child(2) { left: 22%; font-size: 12px; --sway: 46px; animation-duration: 23s; animation-delay: -11s; }
.leaves i:nth-child(3) { left: 41%; font-size: 18px; --sway: 24px; animation-duration: 19s; animation-delay: -7s; }
.leaves i:nth-child(4) { left: 58%; font-size: 13px; --sway: 52px; animation-duration: 26s; animation-delay: -18s; }
.leaves i:nth-child(5) { left: 73%; font-size: 17px; --sway: 34px; animation-duration: 21s; animation-delay: -4s; }
.leaves i:nth-child(6) { left: 88%; font-size: 12px; --sway: 40px; animation-duration: 28s; animation-delay: -14s; }
.leaves i:nth-child(7) { left: 33%; font-size: 14px; --sway: 58px; animation-duration: 31s; animation-delay: -24s; }

/* ───────── 頁首與分頁 ───────── */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.bar h1 { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back {
  width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--card);
  border: 1px solid var(--line); display: grid; place-items: center; font-size: 26px; line-height: 1;
  padding-bottom: 4px; text-decoration: none; transition: transform 0.25s var(--spring);
}
.back:active { transform: scale(0.85); }
.trip-emoji { font-size: 24px; }
/* 像朱印一樣的小章 */
.chip {
  font-family: var(--serif); font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 4px; border: 1.5px solid var(--brand); color: var(--brand-ink);
  white-space: nowrap; transform: rotate(-3deg);
}

/* 會滑動的選單（分頁、分攤方式共用） */
.seg {
  position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr);
  background: var(--soft); border-radius: 12px; padding: 4px;
}
.seg.tabs { margin: 0 16px; }
.seg .thumb {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc((100% - 8px) / var(--n)); border-radius: 9px;
  background: var(--brand); box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 35%, transparent);
  transform: translateX(calc(var(--i) * 100%));
  transition: transform 0.45s var(--spring);
}
.seg button {
  position: relative; border: 0; background: none; padding: 9px 4px; border-radius: 9px;
  color: var(--muted); font-family: var(--serif); font-weight: 700; font-size: 15px; letter-spacing: 0.1em;
  transition: color 0.25s; box-shadow: none;
}
.seg button.on { color: var(--on-brand); }

/* ───────── 清單與卡片 ───────── */
.list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform 0.25s var(--spring);
}
.item:active { transform: scale(0.97); }
.item.static { cursor: default; }
.item.static:active { transform: none; }
.item .title { overflow: hidden; text-overflow: ellipsis; }
.item.menu-item { align-items: flex-start; }
.note { margin-top: 4px; }
.chev { color: var(--brand); font-size: 22px; line-height: 1; }
/* 日期標題：大大的日 + 月份星期 + 一條延伸的線 */
.date { margin: 26px 2px 10px; gap: 10px; letter-spacing: 0; }
.date::before { display: none; }
.date .day { font-size: 30px; line-height: 1; color: var(--brand); font-weight: 700; }
.date .md { font-size: 11px; line-height: 1.35; color: var(--muted); letter-spacing: 0.08em; }
.date .rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }

/* 類別小籤：帳目篩選、記帳選類別、設定都用它 */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 14px -16px 0; padding: 2px 16px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.cat {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 7px 12px; border-radius: 9px; border: 1.5px solid var(--line); background: var(--card);
  color: var(--text); font-size: 14px; font-weight: 700; box-shadow: none;
  transition: transform 0.25s var(--spring), background 0.2s, color 0.2s, border-color 0.2s;
}
.cat small { font-weight: 400; font-size: 12px; color: var(--muted); transition: color 0.2s; }
.cat.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.cat.on small { color: var(--on-brand); opacity: 0.85; }
.cat.add { border-style: dashed; border-color: var(--brand); color: var(--brand-ink); background: none; }
.cat.icon { font-size: 22px; padding: 6px 10px; }
.cat.icon.on { background: var(--soft); border-color: var(--brand); transform: scale(1.1); }
.cat.static { cursor: default; }
.cat .x { padding: 0 2px 0 4px; background: none; color: var(--warn); font-size: 18px; line-height: 1; }
.new-cat { margin-top: 10px; align-items: center; }
input.emoji-input { width: 56px; flex: none; text-align: center; padding-left: 4px; padding-right: 4px; font-size: 20px; }

.bubble {
  width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--soft);
  display: grid; place-items: center; font-size: 22px;
}
.bubble.big { width: 52px; height: 52px; font-size: 28px; }
.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--serif); font-weight: 700; color: #2c2320;
  border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line);
}
.avatar.small { width: 30px; height: 30px; font-size: 13px; }

.pill {
  font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 8px;
  background: var(--soft); color: var(--muted); white-space: nowrap;
}
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

/* 主視覺卡：朱色底 + 青海波紋 + 金線框，像一張御朱印 */
.hero {
  position: relative; text-align: center; padding: 26px 16px; border-radius: 16px; color: var(--on-brand);
  background:
    var(--pattern),
    linear-gradient(160deg, var(--brand-2), var(--brand));
  box-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 28%, transparent);
}
.hero::after {
  content: ''; position: absolute; inset: 6px; border-radius: 11px; pointer-events: none;
  border: 1px solid color-mix(in srgb, var(--gold) 80%, white);
  opacity: 0.75;
}
.hero-label { font-family: var(--serif); font-size: 14px; font-weight: 700; letter-spacing: 0.2em; opacity: 0.95; }
.hero-amount {
  font-family: var(--serif); font-size: 34px; font-weight: 700; letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums; margin: 2px 0;
}
.hero-sub { font-size: 13px; opacity: 0.92; }
.hero.good {
  background:
    var(--pattern),
    linear-gradient(160deg, #5c9a72, #2f6447);
  box-shadow: 0 10px 24px rgb(47 100 71 / 0.28);
}
.hero.even { background: var(--card); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--line); }
.hero .big-emoji { font-size: 44px; margin-bottom: 2px; }

.empty { text-align: center; padding: 44px 0 16px; }
.empty p { margin: 4px 0; font-family: var(--serif); font-weight: 700; letter-spacing: 0.08em; }
.empty p.muted { font-family: inherit; font-weight: 400; letter-spacing: 0; }
.empty button { margin-top: 14px; }
.big-emoji { font-size: 60px; line-height: 1.2; display: inline-block; animation: float 3s ease-in-out infinite; }
.big-emoji.still { animation: pop 0.6s var(--spring) both; }

/* 結算：還款建議、結清印章 */
.pair { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.arrow { color: var(--brand); font-weight: 700; }
button.compact { padding: 8px 14px; font-size: 14px; }
button.wide { display: block; width: 100%; margin-top: 8px; }
.stamp-card {
  display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.stamp-card p { margin: 0; font-weight: 700; }
.stamp {
  flex: none; font-family: var(--serif); font-size: 18px; font-weight: 700; letter-spacing: 0.1em;
  color: var(--brand); border: 2.5px solid var(--brand); border-radius: 8px; padding: 4px 8px;
  transform: rotate(-6deg); animation: stamp 0.5s var(--spring) both 0.2s;
}
.card-form {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 2px 14px 14px;
}
.card-form input, .card-form select { background-color: var(--bg); }
.card-form .row { margin-top: 4px; }
.card-form .primary { padding: 12px; }
.leaves[hidden] { display: none; }
select.wide-select { width: 100%; }

/* ───────── 表單元件 ───────── */
button, input, select { font: inherit; color: inherit; }
button {
  border: 0; background: var(--card); border-radius: 10px; padding: 11px 18px;
  cursor: pointer; white-space: nowrap; font-weight: 700;
  transition: transform 0.25s var(--spring), opacity 0.2s;
}
button:active { transform: scale(0.93); }
button:disabled { opacity: 0.55; cursor: default; }
button.primary {
  background: linear-gradient(160deg, var(--brand-2), var(--brand)); color: var(--on-brand);
  box-shadow: 0 5px 12px color-mix(in srgb, var(--brand) 30%, transparent); letter-spacing: 0.08em;
}
button.ghost { background: none; color: var(--brand-ink); padding: 8px 10px; }
button.danger { color: var(--warn); background: var(--warn-bg); }
input, select {
  width: 100%; min-width: 0; padding: 11px 14px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--card); outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }
/* 下拉選單：拿掉系統樣式，換成明朝體 + 朱色小箭頭 */
select {
  width: auto; appearance: none; -webkit-appearance: none; cursor: pointer;
  font-family: var(--serif); font-weight: 700; letter-spacing: 0.08em;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--brand) 50%),
    linear-gradient(135deg, var(--brand) 50%, transparent 50%);
  background-repeat: no-repeat; background-size: 6px 6px;
  background-position: right 18px center, right 12px center;
}
input.narrow { width: 104px; flex: none; text-align: right; }
input.narrow.grow { flex: 1; width: auto; }
input[type='checkbox'] {
  appearance: none; -webkit-appearance: none; width: 26px; height: 26px; flex: none; padding: 0;
  border-radius: 7px; border: 2px solid var(--brand); background: var(--card);
  display: grid; place-content: center; cursor: pointer; transition: background 0.2s, transform 0.3s var(--spring);
}
input[type='checkbox']::after {
  content: '✓'; color: var(--on-brand); font-size: 15px; font-weight: 900;
  transform: scale(0); transition: transform 0.3s var(--spring);
}
input[type='checkbox']:checked { background: var(--brand); transform: scale(1.06); }
input[type='checkbox']:checked::after { transform: scale(1); }
label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-top: 14px; }
label input, label select { display: block; margin-top: 5px; font-size: 16px; font-weight: 400; color: var(--text); }
label select { width: 100%; font-weight: 700; }

/* 日期欄：顯示好讀的日期，真正的日期輸入框透明蓋在上面 */
.date-field {
  position: relative; display: block; margin-top: 5px; padding: 11px 14px; white-space: nowrap;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--card);
  font-family: var(--serif); font-size: 16px; font-weight: 700; letter-spacing: 0.06em; color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.date-field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }
.date-field input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
label small { display: block; margin-top: 4px; font-weight: 400; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.field-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 0 6px; }

.split-list { margin-top: 10px; animation: rise 0.3s var(--smooth) both; }
.split-row {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 9px 0;
  font-size: 16px; font-weight: 400; color: var(--text); border-bottom: 1px dashed var(--line);
}
.split-row input { margin-top: 0; }
.split-row.check { cursor: pointer; }
.split-row .muted { font-size: 13px; }

.notice { background: var(--notice); border-left: 4px solid var(--gold); border-radius: 8px; padding: 10px 14px; font-size: 14px; margin: 0 0 12px; }
.error { color: var(--warn); background: var(--warn-bg); border-radius: 8px; padding: 8px 12px; font-size: 14px; margin: 12px 0 0; }
.code {
  background: var(--card); border: 1.5px dashed var(--brand); border-radius: 10px;
  padding: 9px 14px; letter-spacing: 1px; overflow: hidden; text-overflow: ellipsis;
}

/* 拍照按鈕（掃發票、拍菜單） */
.scan {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px;
  padding: 12px; border-radius: 12px; border: 1.5px dashed var(--brand); background: var(--soft);
  color: var(--brand-ink); font-size: 15px; font-weight: 700; cursor: pointer;
  transition: transform 0.25s var(--spring);
}
.scan:active { transform: scale(0.97); }
.scan.big { margin-top: 0; padding: 18px; font-size: 17px; border-radius: 14px; }
.scan-emoji { font-size: 22px; display: inline-block; }
.scan.busy { cursor: default; animation: breathe 1.2s ease-in-out infinite; }
.scan.busy .scan-emoji { animation: wiggle 0.7s ease-in-out infinite; }

/* ───────── 記一筆按鈕與底部面板 ───────── */
.fab {
  position: fixed; z-index: 6;
  right: max(16px, calc(50vw - 264px)); bottom: calc(22px + env(safe-area-inset-bottom));
  background: linear-gradient(160deg, var(--brand-2), var(--brand)); color: var(--on-brand);
  padding: 15px 22px; font-family: var(--serif); font-size: 17px; font-weight: 700; letter-spacing: 0.12em;
  border-radius: 14px; outline: 1px solid color-mix(in srgb, var(--gold) 80%, white); outline-offset: -5px;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--brand) 40%, transparent);
  animation: fab-in 0.5s var(--spring) both 0.15s;
}
.fab .plus { display: inline-block; transition: transform 0.4s var(--spring); }
.fab:active .plus { transform: rotate(90deg); }

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 10; background: rgb(30 15 10 / 0.5);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in 0.25s ease both;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 20px 20px 0 0; border-top: 4px solid var(--brand);
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  animation: sheet-up 0.45s var(--smooth) both;
}
.sheet-backdrop.closing { animation: fade-out 0.22s ease both; }
.sheet-backdrop.closing .sheet { animation: sheet-down 0.22s ease-in both; }
.grabber { width: 44px; height: 4px; border-radius: 999px; background: var(--line); margin: 0 auto 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet-actions .primary { padding: 14px; font-size: 16px; }

/* ───────── 確認框 / 輸入框 ───────── */
@keyframes dialog-in { from { opacity: 0; transform: translateY(16px) scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes dialog-out { to { opacity: 0; transform: scale(0.94); } }
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 20; padding: 24px;
  display: grid; place-items: center; background: rgb(20 15 10 / 0.5);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade-in 0.2s ease both;
}
.dialog {
  width: 100%; max-width: 340px; padding: 22px 20px 18px; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--brand);
  border-radius: 18px; box-shadow: 0 20px 50px rgb(0 0 0 / 0.3);
  animation: dialog-in 0.38s var(--spring) both;
}
.dialog-backdrop.closing { animation: fade-out 0.18s ease both; }
.dialog-backdrop.closing .dialog { animation: dialog-out 0.18s ease-in both; }
.dialog-emoji { font-size: 40px; line-height: 1.2; animation: pop 0.5s var(--spring) both 0.08s; }
.dialog h2 { font-size: 18px; letter-spacing: 0.04em; margin-top: 6px; overflow-wrap: anywhere; }
.dialog p { margin: 8px 0 0; font-size: 14px; }
.dialog input { margin-top: 14px; text-align: center; background-color: var(--bg); }
.dialog-actions { display: flex; gap: 10px; margin-top: 18px; }
.dialog-actions button { flex: 1; padding: 12px; }
button.plain { background: var(--soft); color: var(--text); }
button.danger.solid { background: var(--warn); color: var(--card); box-shadow: 0 5px 12px color-mix(in srgb, var(--warn) 30%, transparent); }

/* ───────── 登入頁 ───────── */
.auth { padding-top: 10vh; text-align: center; }
.auth h1 { font-size: 34px; letter-spacing: 0.3em; margin-left: 0.3em; }
.auth form { text-align: left; }
.auth form button { width: 100%; margin-top: 20px; padding: 14px; }
.auth > button { width: 100%; margin-top: 8px; }
.auth > button.google {
  display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 22px; padding: 13px;
  background: var(--card); color: var(--text); border: 1.5px solid var(--line); box-shadow: var(--shadow);
}
.or { display: flex; align-items: center; gap: 12px; margin: 20px 0 0; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
  .leaves { display: none; }
}
