/* ============================================================
   團購平台｜App 的殼：頂列、底部分頁、動作列、底部抽屜、清單
   一套手機 App 樣式的網頁：之後在 LINE 裡打開（LIFF）、加到主畫面（PWA）、包成上架的 App 都用這一套。
   ============================================================ */

.app-body { background: var(--c-bg); overscroll-behavior-y: none; }
.app { max-width: var(--content-max); margin: 0 auto; min-height: 100vh; min-height: 100dvh; background: var(--c-bg); }
@media (min-width: 520px) {
  .app-body { background: var(--c-fill); }
  .app { box-shadow: var(--sh-2); }
}

/* ---------- 頂列 ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20; background: var(--c-surface); border-bottom: 1px solid var(--c-line);
  min-height: var(--appbar-h); padding: env(safe-area-inset-top) 8px 0; display: flex; align-items: center; gap: 4px;
}
.appbar-title { flex: 1; min-width: 0; font-size: var(--f-md); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px; }
.appbar-title.center { text-align: center; padding: 0; }
.appbar .spacer { width: 40px; flex: none; }
.icon-btn {
  width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; background: transparent; color: var(--c-ink);
  display: grid; place-items: center; text-decoration: none; position: relative;
}
.icon-btn:hover { background: var(--c-primary-050); }
.icon-btn svg { width: 22px; height: 22px; }
.scope {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; border: 0; background: none; padding: 6px 8px; border-radius: var(--r-md);
  font-size: var(--f-md); font-weight: 700; white-space: nowrap;
}
.scope:hover { background: var(--c-primary-050); }
.scope span { overflow: hidden; text-overflow: ellipsis; }
.scope svg { width: 16px; height: 16px; flex: none; }
.brand-mark.sm { width: 26px; height: 26px; font-size: 14px; margin-left: 6px; flex: none; }

/* ---------- 內容 ---------- */
.view { padding: 12px 16px 32px; }
.has-tabbar .view { padding-bottom: calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
.has-actionbar .view { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.view-flush { padding-left: 0; padding-right: 0; }
.stack-xs { display: grid; gap: 4px; }
.sec { margin-top: 20px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.sec-title { font-size: var(--f-md); font-weight: 700; }
.sec-more { font-size: var(--f-sm); color: var(--c-ink-soft); text-decoration: none; white-space: nowrap; }
.empty { text-align: center; padding: 32px 16px; color: var(--c-ink-soft); font-size: var(--f-sm); display: grid; gap: 12px; justify-items: center; }

/* ---------- 底部分頁 ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--c-surface); border-top: 1px solid var(--c-line); }
.tabbar-in { max-width: var(--content-max); margin: 0 auto; height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom); box-sizing: content-box; display: grid; grid-template-columns: repeat(5, 1fr); }
.tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--c-ink-soft); font-size: 11px; }
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--c-ink); font-weight: 700; }
.tab-plus { width: 46px; height: 40px; border-radius: 14px; background: var(--c-duo); color: #fff; display: grid; place-items: center; }
.tab-plus svg { width: 22px; height: 22px; }
.tab-center[aria-current="page"] .tab-plus { background: var(--c-duo-600); }
.badge {
  position: absolute; top: 5px; left: calc(50% + 4px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--c-duo); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* ---------- 動作列（詳情頁取代底部分頁） ---------- */
.app-body .bottom-bar { z-index: 30; }

/* ---------- 搜尋 ---------- */
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--c-ink-soft); pointer-events: none; }
.search .input { padding-left: 38px; border-radius: var(--r-pill); background: var(--c-surface); min-height: 42px; }

/* 團購卡片（清單、格子、快成團）在 shop.css */

/* ---------- 圈子 ---------- */
.cav {
  width: 44px; height: 44px; border-radius: 14px; flex: none; display: grid; place-items: center;
  background: var(--c-primary-050); color: var(--c-ink); font-weight: 800; font-size: 18px; border: 1px solid var(--c-line);
}
.cav-lg { width: 64px; height: 64px; border-radius: 18px; font-size: 26px; }
.crow { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); text-decoration: none; }
.crow + .crow { margin-top: 8px; }
.crow-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.crow-name { font-weight: 700; font-size: var(--f-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chead { background: var(--c-surface); border-bottom: 1px solid var(--c-line); padding: 16px; display: grid; gap: 12px; margin: -12px -16px 0; }

/* ---------- 團購頁的商品清單 ---------- */
.irow { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--c-line-2); align-items: flex-start; }
.irow:last-child { border-bottom: 0; padding-bottom: 0; }
.irow:first-child { padding-top: 0; }
.ithumb { width: 76px; flex: none; aspect-ratio: 1; border-radius: var(--r-md); background: var(--c-paper); display: grid; place-items: center; padding: 6px; }
.ithumb .stamp-svg { max-height: 60px; }
.ibody { flex: 1; min-width: 0; display: grid; gap: 4px; }
.iname { font-size: var(--f-sm); font-weight: 700; line-height: 1.4; }
.iprice { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.iprice b { font-size: var(--f-md); color: var(--c-duo); font-variant-numeric: tabular-nums; }
.meter-sm { height: 4px; }
.leadrow { display: flex; align-items: center; gap: 10px; }
.bubble { position: relative; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); padding: 12px 14px; font-size: var(--f-sm); color: var(--c-ink-2); }

/* ---------- 選單（我的） ---------- */
.menu { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); overflow: hidden; }
.menu a, .menu button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--c-line-2);
  background: none; text-decoration: none; text-align: left; font-size: var(--f-sm);
}
.menu > :last-child { border-bottom: 0; }
.menu a:hover, .menu button:hover { background: var(--c-surface-2); }
.menu .grow { flex: 1; min-width: 0; }
.menu svg { width: 18px; height: 18px; color: var(--c-ink-soft); flex: none; }
.profile { display: flex; align-items: center; gap: 14px; }
.profile .avatar { width: 56px; height: 56px; font-size: 22px; }
.ostats { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.ostats a { display: grid; gap: 2px; justify-items: center; padding: 8px 0; text-decoration: none; font-size: var(--f-xs); color: var(--c-ink-2); position: relative; }
.ostats b { font-size: var(--f-lg); color: var(--c-ink); font-variant-numeric: tabular-nums; }
.lead-card { background: var(--c-ink); color: #fff; border-radius: var(--r-lg); padding: 16px; display: grid; gap: 12px; }
.lead-card .muted { color: rgba(255, 255, 255, .72); }
.lead-card .btn { border-color: rgba(255, 255, 255, .28); background: transparent; color: #fff; }
.lead-card .btn:hover { background: rgba(255, 255, 255, .1); }
.lead-card .btn-duo { background: var(--c-duo); border-color: var(--c-duo); }
.lead-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lead-nums b { display: block; font-size: var(--f-lg); font-variant-numeric: tabular-nums; }

/* ---------- 通知 ---------- */
.nrow { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--c-line-2); text-decoration: none; background: var(--c-surface); }
.nrow:hover { background: var(--c-surface-2); }
.nrow.unread { background: var(--c-duo-050); }
.nicon { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--c-primary-050); color: var(--c-ink-2); }
.nicon svg { width: 18px; height: 18px; }
.nbody { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ntitle { font-size: var(--f-sm); font-weight: 700; line-height: 1.4; }
.ntext { font-size: var(--f-xs); color: var(--c-ink-2); line-height: 1.5; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-duo); flex: none; margin-top: 6px; }

/* ---------- 檔期卡 ---------- */
.kcard { display: grid; gap: 10px; padding: 14px; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); text-decoration: none; }
.kcard:hover { box-shadow: var(--sh-2); }
.kthumbs { display: flex; gap: 6px; }
.kthumbs .ithumb { width: 64px; }
.kthumbs .ithumb .stamp-svg { max-height: 48px; }

/* ---------- 選品格子的「加入」 ---------- */
.pcard { position: relative; }
.pick-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2; min-height: 30px; padding: 0 10px; border-radius: var(--r-pill);
  border: 1px solid var(--c-line); background: var(--c-surface); font-size: var(--f-xs); font-weight: 700; box-shadow: var(--sh-1);
}
.pick-btn[aria-pressed="true"] { background: var(--c-ink); border-color: var(--c-ink); color: #fff; }

/* ---------- 底部抽屜 ---------- */
.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: var(--content-max); max-height: 88vh; max-height: 88dvh;
  border-radius: 20px 20px 0 0; background: var(--c-surface); box-shadow: var(--sh-3);
}
.sheet::backdrop { background: rgba(20, 22, 28, .45); }
.sheet[open] { animation: sheet-up .18s ease-out; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }
.sheet-in { display: flex; flex-direction: column; max-height: inherit; }
.sheet-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--c-fill-600); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 16px; flex: none; }
.sheet-title { flex: 1; font-weight: 700; }
.sheet-body { padding: 4px 16px 16px; overflow-y: auto; display: grid; gap: 12px; }
.sheet-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--c-line); flex: none; display: flex; gap: 10px; align-items: center; }
.sheet-foot .grow { flex: 1; min-width: 0; }
.pick-list .option { align-items: center; }
.pick-list .option input { margin-top: 0; }

/* ---------- 入口頁：手機框 ---------- */
.proto { display: grid; gap: 24px; align-items: start; }
@media (min-width: 960px) { .proto { grid-template-columns: 1fr 400px; } }
.phone { width: 390px; max-width: 100%; height: 800px; max-height: 86vh; margin: 0 auto; border: 10px solid var(--c-ink); border-radius: 44px; overflow: hidden; background: var(--c-bg); box-shadow: var(--sh-3); }
.phone iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (min-width: 960px) { .phone-wrap { position: sticky; top: 72px; } }

/* ---------- 接後端（live.js） ---------- */
/* 接後端時還用示範資料的頁面（或區塊） */
.demo-note { margin: 0 0 12px; padding: 8px 12px; border-radius: var(--r-md); background: var(--c-warn-050); color: var(--c-warn); font-size: var(--f-xs); }
/* 開發用登入：一位示範用戶一個按鈕 */
button.option { width: 100%; text-align: left; font: inherit; color: inherit; background: var(--c-surface); cursor: pointer; }
button.option:hover { border-color: var(--c-primary); }
button.option:disabled { opacity: .6; cursor: wait; }
.invite-code { font: 700 28px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 4px; text-align: center; padding: 12px 0; }
.code-input { font-size: 24px; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.sheet-err { margin: 8px 0 0; }
