/* ===== 色彩（淺色／深色） ===== */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2129;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #06c755;          /* LINE 綠 */
  --brand-ink: #ffffff;
  --brand-soft: #e6f9ee;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --warn-soft: #fff4d6;
  --warn-ink: #7a5300;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .04);
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315;
    --card: #1c1f23;
    --text: #eceef0;
    --muted: #9aa1a9;
    --line: #2c3036;
    --brand-soft: #123524;
    --danger-soft: #3a1c1d;
    --warn-soft: #3a2e10;
    --warn-ink: #ffd27a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  padding-bottom: calc(96px + var(--safe-bottom));
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ===== 頂部 ===== */
.topbar { padding: 16px 16px 8px; }
.hello { font-size: 20px; font-weight: 700; }
.meta { color: var(--muted); font-size: 14px; }

.banner { padding: 10px 16px; font-size: 14px; font-weight: 600; }
.banner-mock { background: var(--warn-soft); color: var(--warn-ink); text-align: center; }

/* ===== 分頁籤 ===== */
.tabs {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 4px; padding: 8px 16px;
  background: var(--bg);
}
.tabs button {
  flex: 1; border: 0; border-radius: 999px; padding: 8px 0;
  background: transparent; color: var(--muted); font-weight: 600;
}
.tabs button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

main { padding: 4px 16px 16px; }

/* ===== 卡片與列表 ===== */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px;
}
.section-title { font-size: 14px; color: var(--muted); font-weight: 600; margin: 18px 4px 8px; }
.empty { color: var(--muted); text-align: center; padding: 28px 0; white-space: pre-line; }
.section-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ===== 場次切換 ===== */
.round-picker { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.round-picker::-webkit-scrollbar { display: none; }
.round-chip {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start;
  border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 7px 14px; cursor: pointer; text-align: left;
}
.round-chip-name { font-weight: 700; }
.round-chip-sub { font-size: 12px; color: var(--muted); }
.round-chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.round-chip[aria-pressed="true"] .round-chip-sub { color: var(--brand-ink); opacity: .9; }

/* ===== 購物車列 ===== */
.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 10px 16px calc(10px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.cartbar-btn {
  width: 100%; display: flex; align-items: center; gap: 12px;
  border: 0; border-radius: 14px; padding: 14px 16px; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}
.cartbar-total { font-size: 18px; }
.cartbar-go { margin-left: auto; }
.cart-line { margin-top: 10px; }

.item-btn {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px;
  border: 0; text-align: left; cursor: pointer;
}
.item-btn:disabled { opacity: .5; cursor: default; }
.item-name { font-weight: 600; }
.item-sub { color: var(--muted); font-size: 13px; }
.price { font-weight: 700; white-space: nowrap; }

.order-row { display: flex; justify-content: space-between; gap: 12px; }
.order-label { font-weight: 600; }
.order-note { color: var(--muted); font-size: 13px; }
.row-actions { display: flex; gap: 8px; margin-top: 10px; }
.row-actions .btn { flex: 1; white-space: nowrap; padding-left: 6px; padding-right: 6px; }

.total-card { display: flex; justify-content: space-between; align-items: center; }
.total-amount { font-size: 22px; font-weight: 800; }
.paid-tag { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.unpaid-tag { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.pay-text { white-space: pre-wrap; }
.qr { display: block; max-width: 220px; width: 100%; margin: 12px auto 0; border-radius: 8px; }

/* ===== 按鈕 ===== */
.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 8px 14px; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; padding: 14px; font-size: 17px; border-radius: 12px; }

/* ===== 膠囊選項（單選） ===== */
.group { margin-top: 14px; }
.group-label { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 7px 14px; cursor: pointer;
}
.pill[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 700; }
.pill small { opacity: .8; margin-left: 2px; }

/* ===== 數量與備註 ===== */
.qty { display: flex; align-items: center; gap: 14px; }
.qty button {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); font-size: 22px; line-height: 1; cursor: pointer;
}
.qty output { min-width: 28px; text-align: center; font-size: 20px; font-weight: 700; }
.note-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text); font: inherit;
}

/* ===== 底部抽屜 ===== */
.sheet-backdrop, .modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-height: 88vh; overflow-y: auto;
  background: var(--bg); border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(16px + var(--safe-bottom));
}
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet-title { font-size: 19px; font-weight: 800; }
.close-x { border: 0; background: transparent; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; }
.sheet-foot {
  position: sticky; bottom: calc(-16px - var(--safe-bottom));
  margin: 18px -16px 0; padding: 12px 16px calc(12px + var(--safe-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.sheet-foot .subtotal { font-size: 20px; font-weight: 800; white-space: nowrap; }
.sheet-foot .btn { flex: 1; }

/* ===== 對話框與提示 ===== */
.modal-backdrop { display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 30; }
.modal { background: var(--card); border-radius: var(--radius); width: 100%; max-width: 420px; padding: 18px; }
.modal-body { white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
  z-index: 40; max-width: calc(100% - 32px);
  background: rgba(20, 20, 20, .9); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 15px;
}

.loading { display: flex; justify-content: center; padding: 48px 0; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 送出中遮罩：一出現就擋住點擊，畫面效果延遲 0.3 秒淡入（快的操作不閃爍） */
.busy {
  position: fixed; inset: 0; z-index: 35;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .35);
  opacity: 0; animation: busy-in .2s ease .3s forwards;
}
.busy[hidden] { display: none; }
.busy-box {
  background: var(--card); border-radius: var(--radius); padding: 20px 28px;
  display: flex; flex-direction: column; align-items: center; gap: 12px; font-size: 15px;
}
@keyframes busy-in { to { opacity: 1; } }

/* ===== 管理頁 ===== */
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.select {
  width: 100%; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit;
}
.form-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.form-row label { flex: 0 0 64px; color: var(--muted); font-size: 14px; }
.form-row .select { flex: 1; }
.time-input { min-height: 42px; }
.btn-block-sm { width: 100%; padding: 10px; }
.btn-add { font-size: 15px; padding: 10px; margin-bottom: 10px; }
.btn-sm { padding: 5px 10px; font-size: 14px; border-radius: 8px; white-space: nowrap; }
.btn-ghost { border-style: dashed; width: 100%; margin-top: 8px; color: var(--muted); }

/* 管理頁訂單明細 */
.admin-order { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-top: 1px solid var(--line); margin-top: 8px; }
.admin-order-text { flex: 1; font-size: 15px; min-width: 0; }

/* 我的訂單：截單提示、團長動過的訂單 */
.mine-round { padding-top: 12px; padding-bottom: 12px; }
.mine-round summary { cursor: pointer; list-style: none; }
.mine-round summary::-webkit-details-marker { display: none; }
.mine-round-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mine-round-head .order-label::before { content: "▸ "; color: var(--muted); }
.mine-round[open] .mine-round-head .order-label::before { content: "▾ "; }
.mine-round[open] summary { margin-bottom: 4px; }
.mine-line { padding: 10px 0; border-top: 1px solid var(--line); }
.mine-line .row-actions { margin-top: 6px; justify-content: flex-end; }
.mine-line .row-actions .btn { flex: 0 0 auto; min-width: 64px; }
.flag { display: inline-block; margin-left: 6px; font-size: 12px; font-weight: 700; padding: 1px 8px;
  border-radius: 999px; background: var(--warn-soft); color: var(--warn-ink); vertical-align: 1px; }
.flag-cancel { background: var(--danger-soft); color: var(--danger); }
.is-cancelled .order-text, .is-cancelled .price { text-decoration: line-through; color: var(--muted); }

/* 管理頁：場次總覽 */
.round-list { padding: 4px 12px; }
.round-row {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 6px; border: 0; border-top: 1px solid var(--line); background: transparent;
  color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 0;
}
.round-row:first-child { border-top: 0; }
.round-row[aria-pressed="true"] { background: var(--brand-soft); border-radius: 10px; }
.round-row > span { flex: 0 0 auto; }
.muted { color: var(--muted); font-size: 13px; }
/* 目前查看的場次：黏在分頁籤下方，一行高 */
.current-round {
  position: sticky; top: var(--tabs-h, 52px); z-index: 4;
  display: flex; align-items: center; gap: 8px;
  margin: 18px -16px 4px; padding: 6px 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.current-round-name { flex: 1; min-width: 0; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.current-round > span:not(.current-round-name) { flex: 0 0 auto; }
.anchor { scroll-margin-top: calc(var(--tabs-h, 52px) + 8px); }
.status-text { margin-bottom: 10px; }
.settings summary { cursor: pointer; font-weight: 600; }
.settings[open] summary { margin-bottom: 12px; }

/* 對話框 */
.modal-title { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.modal-hint { margin: 8px 0; white-space: normal; }
.modal-hint.warn { color: var(--danger); }
/* 送出結果 */
.hint.warn { background: var(--warn-soft); color: var(--warn-ink); padding: 8px 10px; border-radius: 8px; }
.done-list { list-style: none; margin: 8px 0; padding: 0; border-top: 1px solid var(--line); }
.done-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.done-total { font-weight: 800; text-align: right; margin-top: 4px; }
.modal .tbl { margin-top: 8px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat-num { font-size: 20px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--muted); }

.tbl { width: 100%; border-collapse: collapse; }
.tbl td { padding: 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num { text-align: right; white-space: nowrap; font-weight: 700; padding-left: 12px; }
/* 叫餐彙總中品項底下的備註細項：縮排、淡色，與上一列之間不畫線 */
.tbl tr.note-row td { padding: 0 0 8px 16px; color: var(--muted); font-size: 14px; }
.tbl tr.note-row td.num { font-weight: 400; }
.tbl tr:has(+ tr.note-row) td { border-bottom: 0; }
.pay-btn { min-width: 64px; }
