/* 旅遊分帳本 — 手機優先、大字、按鈕為主。色票＝喵爸工具站品牌色（象牙底／深藍字／香檳金點綴） */
:root {
  --bg: #f1ece3;
  --panel: #ffffff;
  --panel2: #faf7f1;
  --line: #e2dace;
  --line2: #cfc3b2;
  --tx: #13293d;
  --tx2: #45576a;
  --tx3: #5a6875;
  --navy: #13293d;
  --ivory: #f4efe6;
  --accent: #1b4f7a;
  --gold: #c9a24b;
  --gold-dk: #6f5210;
  --gold-bg: #fbf3df;
  --ok: #24704f;
  --ok-bg: #e5f1ea;
  --err: #a8150f;
  --err-bg: #fbeaea;
  --brand: #e00000;
  --r: 14px;
  --shadow: 0 1px 2px rgba(19, 41, 61, .06), 0 4px 14px rgba(19, 41, 61, .06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--tx);
  font: 17px/1.6 system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.noscroll { overflow: hidden; }
/* LINE 提示條出現時整頁往下推（--iab 由 common.js 量出來） */
body { padding-top: var(--iab, 0px); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* ---------- 頂條 ---------- */
.top {
  background: var(--navy);
  color: var(--ivory);
  border-bottom: 3px solid var(--gold);
  position: sticky;
  top: var(--iab, 0px);
  z-index: 20;
}
.topin { display: flex; align-items: center; gap: 8px; min-height: 58px; }
.top .brand { font-weight: 800; font-size: 19px; letter-spacing: .04em; color: var(--ivory); text-decoration: none; }
.top .ttl { flex: 1; min-width: 0; }
.top .ttl .t1 { font-weight: 800; font-size: 19px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .ttl .t2 { font-size: 13px; color: #d8cfbf; line-height: 1.3; }
.tbtn {
  background: transparent;
  color: var(--ivory);
  border: 1.5px solid rgba(244, 239, 230, .55);
  border-radius: 10px;
  min-height: 40px;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.tbtn.icon { min-width: 44px; padding: 0; font-size: 20px; line-height: 1; }

/* ---------- 卡片與文字 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin: 14px 0;
}
h1, h2, h3 { line-height: 1.35; margin: 0 0 8px; }
h2 { font-size: 21px; }
h3 { font-size: 18px; }
.hint { color: var(--tx2); font-size: 15px; margin: 4px 0 10px; }
.fine { color: var(--tx3); font-size: 14px; margin: 12px 0 0; }
.lbl { display: block; font-weight: 700; font-size: 16px; margin: 18px 0 8px; }
.lbl .opt { font-weight: 400; color: var(--tx3); font-size: 14px; }
.err { color: var(--err); background: var(--err-bg); border-radius: 10px; padding: 10px 12px; font-size: 15px; margin: 12px 0 0; }
.warn { color: var(--gold-dk); background: var(--gold-bg); border-radius: 10px; padding: 10px 12px; font-size: 15px; margin: 12px 0 0; }
.center { text-align: center; }
.muted { color: var(--tx3); }

/* ---------- 輸入框 ---------- */
input[type=text], input[type=date], input:not([type]), select, textarea {
  width: 100%;
  min-height: 52px;
  border: 1.5px solid var(--line2);
  border-radius: 12px;
  background: #fff;
  padding: 10px 14px;
  font-size: 18px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--tx2) 50%), linear-gradient(135deg, var(--tx2) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(27, 79, 122, .16); }
input::placeholder { color: #6b7681; }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 50px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1.5px solid var(--line2);
  background: #fff;
  color: var(--tx);
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
}
.btn.primary { background: var(--navy); border-color: var(--navy); color: var(--ivory); }
.btn.big { width: 100%; min-height: 58px; font-size: 19px; }
.btn.line { background: #04893a; border-color: #04893a; color: #fff; }
.btn.danger { color: var(--err); border-color: #e3b4b1; background: #fff; }
.btn.danger.armed { background: var(--err); border-color: var(--err); color: #fff; }
.btn:disabled { background: #e8e2d6; border-color: #e8e2d6; color: #645d50; }
.btn + .btn { margin-top: 10px; }
.btnrow { display: flex; gap: 10px; }
.btnrow .btn { flex: 1; margin-top: 0; }
.inrow { display: flex; gap: 8px; align-items: stretch; }
.inrow input { flex: 1 1 auto; min-width: 0; width: auto; }
.inrow .btn { flex: 0 0 auto; margin: 0; min-height: 52px; }
.gap { height: 16px; }
.link { background: none; border: 0; padding: 6px 2px; color: var(--accent); font-weight: 700; font-size: 16px; text-decoration: underline; text-underline-offset: 3px; }

/* 分段選擇（幣別） */
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 4px;
  min-height: 50px;
  border-radius: 12px;
  border: 1.5px solid var(--line2);
  background: #fff;
  font-size: 17px;
  font-weight: 700;
}
.seg button.on { background: var(--navy); color: var(--ivory); border-color: var(--navy); }

/* 名字膠囊（單選／多選） */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 46px;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line2);
  background: #fff;
  font-size: 17px;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip.on { background: var(--navy); color: var(--ivory); border-color: var(--navy); }
.chips.multi .chip.on::before { content: "✓ "; }
.chips.multi .chip:not(.on) { color: var(--tx3); border-style: dashed; }
.chips.big .chip { min-height: 56px; font-size: 19px; padding: 8px 22px; }
.mini { display: flex; gap: 14px; margin-top: 6px; }

/* ---------- 首頁 ---------- */
.hero { padding: 26px 2px 6px; }
.hero h1 { font-size: 32px; line-height: 1.25; letter-spacing: .01em; margin-bottom: 12px; }
.hero .lead { font-size: 18px; color: var(--tx2); margin: 0 0 16px; }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 0 0 14px; }
.steps li { counter-increment: s; position: relative; padding: 8px 0 8px 46px; font-size: 18px; }
.steps li::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: 6px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gold-bg);
  border: 1.5px solid var(--gold);
  color: var(--gold-dk);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero .btn.big { margin: 6px 0 14px; }
#create { scroll-margin-top: calc(70px + var(--iab, 0px)); }
.free { display: inline-block; background: var(--gold-bg); color: var(--gold-dk); border-radius: 999px; padding: 4px 14px; font-size: 15px; font-weight: 700; margin: 0; }
.origin { color: var(--tx3); font-size: 14px; margin: 10px 0 0; }
.nmrow { display: flex; gap: 8px; margin-bottom: 8px; }
.nmrow input { flex: 1; }
.nmrow .rm { flex: 0 0 48px; min-height: 52px; border-radius: 12px; border: 1.5px solid var(--line2); background: #fff; color: var(--tx3); font-size: 20px; }
.recent a { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 52px; padding: 8px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--tx); font-weight: 700; font-size: 18px; }
.recent a:last-child { border-bottom: 0; }
.recent a span:last-child { color: var(--accent); font-size: 15px; white-space: nowrap; }
.faq { margin: 26px 0 10px; }
.faq h2 { font-size: 20px; }
.faq details { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin: 8px 0; padding: 0 14px; }
.faq summary { min-height: 52px; display: flex; align-items: center; font-weight: 700; cursor: pointer; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "＋"; margin-left: auto; color: var(--tx3); }
.faq details[open] summary::after { content: "－"; }
.faq details p { margin: 0 0 14px; color: var(--tx2); }

/* ---------- 帳本頁 ---------- */
.me { padding: 14px 16px; }
.mebar { display: flex; align-items: center; gap: 6px; font-size: 16px; color: var(--tx2); }
.mebar b { color: var(--tx); font-size: 18px; }
.mebar .link { margin-left: auto; font-size: 15px; }
.mesum { margin-top: 8px; }
.mesum .l1 { font-size: 15px; color: var(--tx2); }
.mesum .l2 { font-size: 22px; font-weight: 800; margin-top: 2px; }
.pos { color: var(--ok); }
.neg { color: var(--err); }

.tabs { display: flex; background: #e6dfd3; border-radius: 14px; padding: 4px; gap: 4px; margin: 14px 0 6px; }
.tabs button { flex: 1; min-height: 48px; border: 0; border-radius: 11px; background: transparent; font-size: 17px; font-weight: 700; color: var(--tx2); }
.tabs button.on { background: #fff; color: var(--tx); box-shadow: 0 1px 3px rgba(19, 41, 61, .12); }

.tot { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 6px 2px 2px; color: var(--tx2); font-size: 15px; }
.tot b { color: var(--tx); font-size: 18px; }
.day { font-weight: 800; color: var(--tx2); font-size: 15px; margin: 18px 2px 6px; }
.rows { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.row {
  display: flex;
  width: 100%;
  text-align: left;
  gap: 10px;
  padding: 12px 14px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
  min-height: 64px;
}
.row:last-child { border-bottom: 0; }
.row .l, .row .r, .row .it, .row .sub, .row .a1, .row .a2 { display: block; }
.row .l { flex: 1; min-width: 0; }
.row .it { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .it.none { color: var(--tx3); font-weight: 600; }
.row .sub { color: var(--tx2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r { text-align: right; white-space: nowrap; }
.row .a1 { font-weight: 800; font-size: 17px; }
.row .a2 { color: var(--tx2); font-size: 14px; }
.empty { text-align: center; padding: 30px 16px; color: var(--tx2); }
.empty b { display: block; color: var(--tx); font-size: 19px; margin-bottom: 6px; }

.settle-head { font-size: 22px; font-weight: 800; margin: 2px 0 10px; }
.xfers { list-style: none; margin: 0 0 14px; padding: 0; }
.xfers li { display: flex; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 18px; }
.xfers li:last-child { border-bottom: 0; }
.xfers .nm { font-weight: 800; max-width: 34%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xfers .arrow { color: var(--tx3); font-size: 15px; white-space: nowrap; }
.xfers .amt { margin-left: auto; font-weight: 800; white-space: nowrap; }
.xfers li.mine { background: var(--gold-bg); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.people .p { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.people .p:last-child { border-bottom: 0; }
.people .p.mine { background: var(--gold-bg); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.people .nm { font-weight: 800; font-size: 18px; }
.people .dt { color: var(--tx2); font-size: 14px; }
.people .nt { text-align: right; font-weight: 800; font-size: 17px; white-space: nowrap; }
.people .nt small { display: block; font-weight: 600; font-size: 13px; }
.rule { color: var(--tx2); font-size: 14px; margin: 10px 0 0; }

/* 帳本頁的頂條：深藍標題列＋正下方的「記一筆」，兩列一起固定在最上面 */
.top.tripTop { background: transparent; border-bottom: 0; }
.tripTop .topbar { background: var(--navy); border-bottom: 3px solid var(--gold); }
.tripTop .addrow {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}
.tripTop .addrow .wrap { display: flex; }
.spacer { height: calc(32px + env(safe-area-inset-bottom)); }

/* ---------- 全螢幕面板（記一筆／邀請／設定） ---------- */
.sheet {
  position: fixed;
  inset: 0;
  top: var(--iab, 0px);
  z-index: 60;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--navy);
  color: var(--ivory);
  border-bottom: 3px solid var(--gold);
}
.sheet-head .wrap { display: flex; align-items: center; gap: 10px; min-height: 58px; }
.sheet-head h2 { margin: 0; font-size: 20px; flex: 1; }
/* 記一筆：取消在左、儲存在右上（填完金額不用滑到底、不用先收鍵盤） */
.ehead h2 { text-align: center; }
.hsave {
  background: var(--gold);
  color: var(--navy);
  border: 0;
  border-radius: 10px;
  min-height: 42px;
  padding: 0 18px;
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
}
.hsave:disabled { opacity: .55; }
.x { background: none; border: 0; color: var(--ivory); font-size: 16px; font-weight: 700; min-height: 44px; padding: 0 4px; text-decoration: underline; text-underline-offset: 3px; }
.sheet-body { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; background: rgba(241, 236, 227, .97); border-top: 1px solid var(--line); padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); }
.savebar .wrap { display: flex; }

.amtrow { display: flex; align-items: center; gap: 10px; }
.amtrow input { font-size: 30px; font-weight: 800; min-height: 64px; letter-spacing: .02em; }
/* 金額前面直接標幣別符號（₩／NT$），一眼看得出現在記的是哪種錢 */
.amtrow .sym { flex: 0 0 auto; font-size: 26px; font-weight: 800; color: var(--navy); min-width: 1.1em; text-align: center; }
.tapHint { color: var(--tx3); font-size: 14px; margin: 6px 2px 0; }
.conv { margin: 10px 2px 0; font-size: 20px; font-weight: 800; min-height: 32px; }
.conv .eq { color: var(--tx3); font-weight: 600; font-size: 16px; }
.ratebox { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 8px; font-size: 15px; color: var(--tx2); }
.ratebox .rl { display: flex; align-items: baseline; gap: 8px; }
.ratebox .rl span { flex: 1; min-width: 0; font-size: 14px; line-height: 1.5; }
.ratebox .rl .link { flex: 0 0 auto; font-size: 15px; padding: 2px 0; }
.rateedit { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.rateedit input { width: 9.5em; flex: 0 0 auto; min-height: 48px; font-size: 18px; }
.per { font-weight: 600; color: var(--tx2); font-size: 15px; margin-left: 6px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.quick button { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line2); background: var(--panel2); font-size: 15px; color: var(--tx2); }
.meta { color: var(--tx3); font-size: 13px; margin-top: 14px; }
.urlbox { background: #fff; border: 1.5px dashed var(--line2); border-radius: 12px; padding: 12px 14px; font-size: 15px; word-break: break-all; margin: 10px 0 14px; user-select: all; -webkit-user-select: all; }
.copybox { width: 100%; min-height: 260px; font-size: 15px; line-height: 1.6; padding: 12px; border-radius: 12px; border: 1.5px solid var(--line2); }
.mrow { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mrow:last-child { border-bottom: 0; }
.mrow .nm { flex: 1; font-weight: 700; font-size: 17px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .btn { min-height: 42px; padding: 0 12px; font-size: 15px; margin: 0; }
.mrow .btn.quiet { border-color: transparent; background: transparent; color: var(--tx3); text-decoration: underline; text-underline-offset: 3px; padding: 0 6px; }
.mrow .btn.quiet.armed { background: var(--err); border-color: var(--err); color: #fff; text-decoration: none; padding: 0 12px; }
.drow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.drow:last-child { border-bottom: 0; }
.drow .l { flex: 1; min-width: 0; }
.drow .btn { min-height: 42px; padding: 0 12px; font-size: 15px; margin: 0; }

/* ---------- 提示 ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  z-index: 80;
  background: var(--navy);
  color: var(--ivory);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 16px;
  width: max-content;
  max-width: calc(100% - 32px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  display: flex;
  align-items: center;
  gap: 14px;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { background: none; border: 0; color: #f0d79a; font-weight: 800; font-size: 16px; text-decoration: underline; min-height: 36px; }

/* ---------- 頁尾 ---------- */
.foot { text-align: center; color: var(--tx3); font-size: 13px; padding: 22px 0 18px; line-height: 2; }
.foot a { color: var(--tx3); }
.foot .dot { margin: 0 6px; }

@media (min-width: 600px) {
  .hero h1 { font-size: 38px; }
}
