/* 雲遊太平電子護照：茶綠 × 山嵐紙色，手機優先 */
:root {
  --ink: #1c2b26;
  --ink-2: #4b5a54;
  --ink-3: #7d8a84;
  --tea: #1f4d3f;
  --tea-2: #2e6b57;
  --tea-soft: #e4eee8;
  --paper: #f3f1ea;
  --card: #ffffff;
  --line: #e2ddd0;
  --amber: #c27a22;
  --amber-soft: #fbf0de;
  --ok: #2f7d5b;
  --ok-soft: #e3f2ea;
  --danger: #b4432b;
  --food: #d48a2a;
  --souvenir: #c0587b;
  --stay: #4e60b0;
  --bonus: #2a8c7a;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(28, 43, 38, .06), 0 6px 18px rgba(28, 43, 38, .06);
  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.55 var(--font); -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--tea-2); }
h1, h2, h3 { margin: 0; line-height: 1.3; }
p { margin: 0; }
.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; position: relative; }
.sub { color: var(--ink-3); font-size: 13px; }
.sub.light { color: rgba(255,255,255,.75); }
.hint { color: var(--ink-3); font-size: 13px; }
.center { text-align: center; }
.strong { font-weight: 700; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .02em; }
.small { font-size: 12px; }
.muted { color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.empty { text-align: center; color: var(--ink-3); padding: 28px 12px; font-size: 14px; }
.stack { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* 載入畫面 */
.splash { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 16px; padding: 24px; text-align: center; color: var(--ink-2); }
.splash-mark { width: 56px; height: 56px; border-radius: 50%; border: 4px solid var(--tea-soft); border-top-color: var(--tea); animation: spin 1s linear infinite; }
.splash-mark.muted { animation: none; border-color: var(--line); }
@keyframes spin { to { transform: rotate(360deg); } }

/* 本機測試列 */
.devbar { position: sticky; top: 0; z-index: 30; background: #fff7d6; border-bottom: 1px solid #ecd98c; font-size: 12px; padding: 6px 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.devbar a { color: #7a5b00; text-decoration: none; padding: 2px 8px; border-radius: 999px; border: 1px solid #ecd98c; }
.devbar a.on { background: #7a5b00; color: #fff; }

/* 按鈕 */
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; font-size: 15px; min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; transition: transform .1s, background .15s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--tea); color: #fff; }
.btn.primary:hover { background: var(--tea-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn.xl { min-height: 56px; font-size: 17px; border-radius: 14px; }
.btn:disabled { background: #cfd6d2; color: #fff; cursor: not-allowed; transform: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--paper); font-size: 18px; display: grid; place-items: center; }
.icon-btn.light { background: rgba(255,255,255,.16); color: #fff; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 600; min-height: 36px; }
.chip.on { background: var(--tea); border-color: var(--tea); color: #fff; }
.chip.light { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); color: #fff; }
.link-btn { background: none; border: 0; color: var(--ink-3); text-decoration: underline; font-size: 13px; padding: 16px; justify-self: center; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--paper); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.badge { display: inline-block; font-size: 13px; font-weight: 700; padding: 4px 12px; border-radius: 999px; }
.badge.warm { background: var(--amber-soft); color: var(--amber); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.input { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; font-size: 16px; }
.input:focus { border-color: var(--tea-2); outline: none; }
.input.upper { text-transform: uppercase; text-align: center; font-size: 20px; letter-spacing: .15em; }

/* 遊客端 */
.visitor { padding-bottom: calc(96px + var(--safe-b)); }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--tea); color: #fff; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.4); }
.avatar.ph { display: grid; place-items: center; background: var(--tea-2); font-weight: 700; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.passport {
  margin: 0 12px; padding: 22px 18px 18px; border-radius: 0 0 28px 28px;
  background:
    radial-gradient(120px 60px at 85% 18%, rgba(255,255,255,.65), transparent 70%),
    radial-gradient(160px 70px at 10% 70%, rgba(255,255,255,.55), transparent 70%),
    linear-gradient(160deg, #dcebe3 0%, #eef1e6 55%, #f6efe1 100%);
  box-shadow: var(--shadow); text-align: center;
}
.passport-head .eyebrow, .eyebrow { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--tea-2); }
.passport-head h1 { font-size: 22px; letter-spacing: .12em; margin-top: 2px; color: var(--tea); }
.balance { display: flex; justify-content: center; align-items: baseline; gap: 6px; margin-top: 10px; color: var(--tea); }
.balance .num { font-size: 64px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.balance .unit { font-size: 20px; font-weight: 700; }
.balance.small .num { font-size: 40px; }
.next { margin-top: 6px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.passport .badge { margin-top: 8px; }
.stamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px 4px; margin: 16px 0 10px; padding: 14px 8px; background: rgba(255,255,255,.55); border-radius: 18px; }
.stamp { position: relative; display: grid; place-items: center; height: 44px; }
.stamp svg { width: 46px; height: 46px; position: absolute; fill: #fff; filter: drop-shadow(0 1px 1px rgba(0,0,0,.06)); }
.stamp b { position: relative; font-size: 12px; color: #c9d4cf; padding-top: 4px; }
.stamp.food svg { fill: var(--food); } .stamp.souvenir svg { fill: var(--souvenir); } .stamp.stay svg { fill: var(--stay); } .stamp.bonus svg { fill: var(--bonus); }
.stamp:not(.empty) b { color: #fff; }
.stamp.used svg { opacity: .32; } .stamp.used b { color: var(--ink-2); }
.stamp:not(.empty) { animation: pop .35s ease-out both; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.more { font-size: 12px; color: var(--ink-3); }
.legend { display: flex; justify-content: center; gap: 12px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.sw { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--ink-3); flex: none; }
.sw.food { background: var(--food); } .sw.souvenir { background: var(--souvenir); } .sw.stay { background: var(--stay); } .sw.bonus { background: var(--bonus); } .sw.desk { background: var(--tea); }

.tabs { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); margin: 14px 12px 0; background: var(--card); border-radius: 14px; padding: 4px; box-shadow: var(--shadow); }
.tab { position: relative; border: 0; background: none; padding: 10px 0; border-radius: 10px; font-weight: 700; color: var(--ink-3); font-size: 15px; }
.tab.on { background: var(--tea-soft); color: var(--tea); }
.tab .dot { position: absolute; top: 8px; right: calc(50% - 22px); width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.tab-content { padding: 14px 12px 8px; }
.section-title { font-size: 15px; color: var(--ink-2); margin-top: 6px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; border: 1px solid transparent; }
.prize { display: flex; gap: 14px; align-items: center; }
.prize-cost { flex: none; width: 58px; height: 58px; border-radius: 14px; background: var(--paper); display: grid; place-content: center; text-align: center; font-size: 12px; color: var(--ink-3); line-height: 1.1; }
.prize-cost b { font-size: 22px; color: var(--ink); }
.prize-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.prize h3 { font-size: 16px; }
.prize.ready { border-color: var(--tea-2); }
.prize.ready .prize-cost { background: var(--tea); } .prize.ready .prize-cost, .prize.ready .prize-cost b { color: #fff; }
.prize.out { opacity: .55; }
.bar { height: 6px; background: var(--paper); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--tea-2), #5aa58a); border-radius: inherit; }

.route-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.route h3 { font-size: 17px; }
.route .sub { margin-top: 4px; }
.route-shops { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.route-shops li { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink-2); }
.route-shops .tick { width: 24px; height: 24px; border-radius: 50%; border: 2px dashed var(--line); display: grid; place-items: center; font-size: 13px; flex: none; }
.route-shops li.visited { color: var(--ink); }
.route-shops li.visited .tick { background: var(--tea); border: 0; color: #fff; }
.route.done { border-color: var(--ok); }
.reward { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 14px; color: var(--ink-2); }
.reward b { color: var(--amber); }

.coupon { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-left: 6px solid var(--amber); }
.coupon h3 { font-size: 16px; }
.coupon.used { opacity: .5; border-left-color: var(--line); }
.coupon-side { display: grid; justify-items: end; gap: 6px; }

.list { list-style: none; margin: 0; padding: 4px 16px; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--paper); }
.list li:last-child { border-bottom: 0; }
.delta { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 17px; }
.delta.plus { color: var(--ok); } .delta.minus { color: var(--danger); }
.rules { margin: 0; padding: 14px 16px 14px 34px; display: grid; gap: 8px; font-size: 14px; color: var(--ink-2); }

.qr-dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 12px 16px calc(12px + var(--safe-b)); background: linear-gradient(to top, var(--paper) 70%, rgba(243,241,234,0)); max-width: 480px; margin: 0 auto; }
.qr-dock .btn { box-shadow: 0 8px 20px rgba(31, 77, 63, .35); }
.qr-glyph { width: 20px; height: 20px; border: 3px solid #fff; border-radius: 4px; position: relative; }
.qr-glyph::after { content: ""; position: absolute; inset: 3px; background: #fff; border-radius: 1px; }
.qr-box { background: #fff; border-radius: 16px; padding: 12px; margin: 12px auto; width: min(78vw, 290px); aspect-ratio: 1; border: 1px solid var(--line); }
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-points { text-align: center; font-size: 20px; font-weight: 800; color: var(--tea); }

/* 地圖 */
.map { height: 340px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: #e6e9e4; z-index: 0; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; }
.shop-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; }
.shop-name { flex: 1; font-weight: 700; }
.pin-wrap { background: none; border: 0; }
.pin { display: flex; flex-direction: column; align-items: center; transform: translate(-50%, -100%); width: max-content; }
.pin-dot { width: 34px; height: 34px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 17px; border: 3px solid var(--tea); box-shadow: 0 3px 10px rgba(0,0,0,.25); }
.pin.food .pin-dot { border-color: var(--food); } .pin.souvenir .pin-dot { border-color: var(--souvenir); } .pin.stay .pin-dot { border-color: var(--stay); }
.pin-label { margin-top: 3px; background: rgba(28,43,38,.85); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 8px; }
.shop-photo { width: 100%; height: 180px; object-fit: cover; border-radius: 14px; }

/* 底部面板 */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(20, 30, 26, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease-out; }
.overlay.closing { animation: fade .18s ease-in reverse forwards; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet { width: 100%; max-width: 480px; max-height: 88dvh; overflow-y: auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 18px calc(20px + var(--safe-b)); animation: rise .22s cubic-bezier(.2,.9,.3,1); }
.sheet.tall { min-height: 70dvh; }
@keyframes rise { from { transform: translateY(40px); } to { transform: none; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 0 8px; position: sticky; top: -8px; background: var(--card); z-index: 1; }
.sheet-head h2 { font-size: 18px; }
.sheet-body { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.confirm-msg { font-size: 16px; color: var(--ink-2); }
.btn-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.reader { width: 100%; min-height: 280px; border-radius: 16px; overflow: hidden; background: #111; }
.dev-box { display: grid; gap: 8px; padding: 12px; border: 1px dashed #ecd98c; border-radius: 12px; background: #fffbea; }

/* 提示訊息 */
.toast { position: fixed; left: 50%; top: 16px; z-index: 200; transform: translate(-50%, -20px); opacity: 0; pointer-events: none; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); transition: .2s; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--ok); } .toast.error { background: var(--danger); }

/* 店家端／服務台 */
.staff { padding-bottom: calc(24px + var(--safe-b)); }
.staff-top { background: var(--tea); color: #fff; padding: 18px 16px 22px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.staff-top .eyebrow { color: #bfe0d1; }
.staff-top h1 { font-size: 22px; margin: 2px 0; }
.banner { margin: 12px 12px 0; padding: 10px 14px; border-radius: 12px; font-weight: 700; font-size: 14px; }
.banner.warm { background: var(--amber-soft); color: var(--amber); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; margin: 14px 12px 0; padding: 4px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); }
.segmented button { border: 0; background: none; padding: 11px 0; border-radius: 10px; font-weight: 700; color: var(--ink-3); }
.segmented button.on { background: var(--tea); color: #fff; }
.staff-stage { padding: 16px 12px; }
.scan-home { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 8px 8px 0; }
.scan-btn { width: 100%; min-height: 200px; border: 0; border-radius: 24px; background: linear-gradient(160deg, var(--tea-2), var(--tea)); color: #fff; font-size: 20px; font-weight: 800; display: grid; place-content: center; justify-items: center; gap: 14px; box-shadow: 0 10px 26px rgba(31,77,63,.35); }
.scan-btn:active { transform: scale(.99); }
.scan-ico { width: 64px; height: 64px; border-radius: 14px; border: 4px dashed rgba(255,255,255,.85); }
.scan-home h2 { font-size: 18px; margin-top: 8px; }
.step { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.who-line { font-size: 15px; color: var(--ink-2); }
.who-line b { color: var(--ink); font-size: 17px; }
.label { font-weight: 700; color: var(--ink-2); font-size: 14px; }
.amount-wrap { display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 6px 14px; }
.amount-wrap:focus-within { border-color: var(--tea-2); }
.cur { font-weight: 700; color: var(--ink-3); }
.amount-input { flex: 1; min-width: 0; width: 100%; border: 0; outline: none; font-size: 40px; font-weight: 800; text-align: right; background: none; font-variant-numeric: tabular-nums; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.preview { display: flex; align-items: baseline; justify-content: center; gap: 8px; background: var(--tea-soft); color: var(--tea); border-radius: 16px; padding: 14px; font-weight: 700; }
.preview b { font-size: 40px; line-height: 1; }
.preview em { font-style: normal; font-size: 12px; background: var(--amber-soft); color: var(--amber); padding: 2px 8px; border-radius: 999px; }
.done { display: grid; justify-items: center; text-align: center; gap: 10px; padding-top: 12px; }
.done-mark { width: 84px; height: 84px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 44px; font-weight: 800; display: grid; place-items: center; animation: pop .35s ease-out; }
.done h2 { font-size: 24px; }
.done .btn { margin-top: 12px; }
.serial { font-family: ui-monospace, Menlo, monospace; font-size: 26px; font-weight: 800; letter-spacing: .08em; background: var(--paper); padding: 6px 16px; border-radius: 10px; }
.visitor-card { display: flex; justify-content: space-between; align-items: center; background: var(--tea-soft); border-radius: var(--radius); padding: 16px; }
.visitor-card h2 { font-size: 20px; }
.prize-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.prize-row.disabled b { color: var(--ink-3); }
.desk-actions { display: grid; gap: 4px; padding: 6px 16px; }
.desk-actions .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--paper); }
.desk-actions .row:last-child { border-bottom: 0; }
.inline { display: flex; gap: 8px; align-items: center; }
.small-num { width: 70px; text-align: center; padding: 10px 6px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* 協會管理頁 */
.app.wide { max-width: 1100px; }
.admin { padding-bottom: 40px; }
.admin-nav { display: flex; gap: 6px; overflow-x: auto; padding: 12px; position: sticky; top: 0; z-index: 10; background: var(--paper); }
.admin-nav button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 16px; font-weight: 700; white-space: nowrap; color: var(--ink-2); }
.admin-nav button.on { background: var(--tea); border-color: var(--tea); color: #fff; }
.admin-body { padding: 4px 12px 24px; }
.admin-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: grid; gap: 4px; }
.stat-label { color: var(--ink-3); font-size: 13px; font-weight: 600; }
.stat b { font-size: 26px; color: var(--tea); font-variant-numeric: tabular-nums; }
.stat small { font-size: 13px; color: var(--ink-3); margin-left: 4px; }
.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th { text-align: left; color: var(--ink-3); font-weight: 700; font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--paper); vertical-align: top; }
table.grid tr.off td { color: var(--ink-3); }
table.grid td.actions { white-space: nowrap; text-align: right; }
table.grid td.actions .chip { margin-left: 4px; }
.card.off { opacity: .6; }
.narrow { max-width: 560px; }
.form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; }
.field.check { grid-template-columns: auto 1fr; align-items: center; }
.field.check input { width: 22px; height: 22px; }
.field.check .label { order: 2; }
textarea.input { resize: vertical; font: inherit; }
.picker { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; background: #fff; }
.pick.on { background: var(--tea-soft); border-color: var(--tea-2); color: var(--tea); font-weight: 700; }
.pick input { margin: 0; }

/* LINE 外開啟的說明頁 */
.landing-icon { width: 88px; height: 88px; border-radius: 22px; box-shadow: var(--shadow); }
.landing-title { font-size: 24px; color: var(--tea); letter-spacing: .1em; }
