/* G Family 咖啡烘焙所：樣式（後台＋客人下單頁共用）
   - 所有字級、間距都用 rem／em，切換「字」大小時整個版面一起放大。
   - 版型依「實際寬度 ÷ 字體倍率」切換：html.w-mid（較窄）、html.w-narrow（手機版排法）。
   - 觸控範圍至少 44×44 px（2.75rem）。 */

:root {
  --bg: #f5efe7; --surface: #fffdf9; --surface-2: #faf5ee;
  --ink: #2b211b; --ink-2: #4a3c32; --muted: #6f6055;
  --line: #e2d6c8; --line-strong: #cdbca9;
  --coffee: #5a3a28; --coffee-2: #6f4a34; --caramel: #b26d36; --caramel-soft: #f3e3d1;
  --alert: #a8321f; --alert-soft: #fbe7e2; --warn: #855300; --warn-soft: #fbf0d9;
  --ok: #2f6a45; --ok-soft: #e4f1e7; --info: #2b5079; --info-soft: #e7eef7;
  --radius: .5rem; --tap: 2.75rem;
  --shadow: 0 1px 2px rgba(60, 40, 25, .06), 0 2px 8px rgba(60, 40, 25, .05);
  --font: "Noto Sans TC", "Microsoft JhengHei", "微軟正黑體", "PingFang TC", "Heiti TC", system-ui, sans-serif;
  --mono: ui-monospace, "Consolas", "Menlo", monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 1rem; line-height: 1.6; overflow-wrap: anywhere; }
body.no-scroll { overflow: hidden; }
a { color: var(--coffee-2); }
h1 { font-size: 1.5rem; line-height: 1.35; margin: 0; letter-spacing: .02em; }
h2 { font-size: 1.12rem; margin: 0 0 .75rem; color: var(--coffee); }
code { font-family: var(--mono); background: var(--caramel-soft); padding: 0 .3em; border-radius: .25rem; }
.muted { color: var(--muted); }
.small { font-size: .875em; }
.neg { color: var(--alert); font-weight: 700; }
.warn { color: var(--warn); }
.ok { color: var(--ok); }
[hidden] { display: none !important; }
.loading { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------------- 上方列 ---------------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; background: var(--coffee); color: #f6efe6; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; flex: none; min-height: var(--tap); }
.brand-mark { display: inline-grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: .55rem; background: #f6efe6; color: var(--coffee); font: 700 1.3rem/1 Georgia, "Times New Roman", serif; }
.brand-mark.big { width: 3.5rem; height: 3.5rem; font-size: 2rem; border-radius: .9rem; background: var(--coffee); color: #f6efe6; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text b { font-size: 1rem; letter-spacing: .03em; }
.brand-text small { font-size: .75rem; opacity: .8; }
.mainnav { display: flex; gap: .15rem; flex: 1; flex-wrap: wrap; min-width: 0; }
.mainnav a { color: #eadccb; text-decoration: none; padding: .35rem .7rem; border-radius: .4rem; display: inline-flex; align-items: center; gap: .3rem; min-height: var(--tap); }
.mainnav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.mainnav a.active { background: #f6efe6; color: var(--coffee); font-weight: 700; }
.nav-ico { font-size: .9em; opacity: .85; }
.topbar-right { display: flex; align-items: center; gap: .4rem; margin-left: auto; flex-wrap: wrap; }
.mock-badge { white-space: nowrap; border: 1px dashed #e8c79f; background: transparent; color: #f3d6b3; border-radius: 999px; padding: .2rem .8rem; font: inherit; font-size: .82rem; cursor: pointer; min-height: var(--tap); }
.mock-badge:hover { background: rgba(255, 255, 255, .08); }
.font-btn { display: inline-flex; align-items: center; gap: .35rem; min-height: var(--tap); min-width: var(--tap); padding: .2rem .7rem; border-radius: .5rem; border: 2px solid #f3d6b3; background: #f6efe6; color: var(--coffee); font: inherit; font-weight: 800; cursor: pointer; white-space: nowrap; }
.font-btn .font-a { font-size: 1.2em; font-family: Georgia, serif; }
.font-btn small { font-size: .78em; font-weight: 700; }
.topbar .btn-ghost { color: #f6efe6; border-color: rgba(255, 255, 255, .4); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, .1); }
.mobilenav, .more-sheet { display: none; }

/* ---------------- 版面 ---------------- */
main { outline: none; }
.page { max-width: 80rem; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; min-height: var(--tap); text-decoration: none; color: var(--muted); }
.back:hover { color: var(--coffee); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.cards-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.cards-2 > .card { margin-bottom: 0; }
.quick { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.note-box { background: var(--info-soft); color: var(--info); border-radius: .4rem; padding: .6rem .9rem; margin: 0 0 1rem; }

/* ---------------- 按鈕 ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-height: var(--tap); padding: .35rem 1rem; border: 1px solid var(--line-strong); border-radius: .4rem; background: var(--surface); color: var(--ink); font: inherit; text-decoration: none; cursor: pointer; text-align: center; line-height: 1.3; }
.btn:hover { background: var(--surface-2); border-color: var(--coffee-2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .tab:focus-visible, a:focus-visible, button:focus-visible { outline: 3px solid var(--caramel); outline-offset: 1px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--coffee); border-color: var(--coffee); color: #fff; }
.btn-primary:hover { background: var(--coffee-2); border-color: var(--coffee-2); }
.btn-accent { background: var(--caramel); border-color: var(--caramel); color: #fff; font-weight: 700; }
.btn-accent:hover { background: #9b5c2b; }
.btn-danger { background: var(--alert); border-color: var(--alert); color: #fff; }
.btn-danger:hover { background: #8e2817; }
.btn-danger-ghost { color: var(--alert); border-color: #e6b9ae; }
.btn-danger-ghost:hover { background: var(--alert-soft); border-color: var(--alert); }
.btn-ghost { background: transparent; }
.btn-sm { padding: .25rem .7rem; font-size: .92rem; }
.btn-lg { padding: .55rem 1.6rem; font-size: 1.08rem; }
.btn-block { width: 100%; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; min-width: var(--tap); min-height: var(--tap); border-radius: .4rem; font-size: 1.05rem; font-family: inherit; }
.icon-btn:hover { background: var(--alert-soft); color: var(--alert); }

/* ---------------- 表單 ---------------- */
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line-strong); border-radius: .4rem; background: #fff; padding: .4rem .6rem; min-height: var(--tap); width: 100%; min-width: 0; }
textarea { resize: vertical; }
input[type=checkbox], input[type=radio] { width: 1.3rem; height: 1.3rem; min-height: 0; accent-color: var(--coffee); flex: none; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
input.auto { background: var(--caramel-soft); }
.has-error, input.combo-unmatched { border-color: var(--alert) !important; background: #fff8f6; }
.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.field > span:first-child, .field-label { font-size: .9rem; color: var(--ink-2); font-weight: 700; }
.hint { font-size: .85rem; color: var(--muted); font-weight: 400; }
.req { color: var(--alert); font-style: normal; }
.field-error { color: var(--alert); font-size: .85rem; margin-top: .15rem; }
.form-error { background: var(--alert-soft); color: var(--alert); border: 1px solid #ecc1b7; border-radius: .4rem; padding: .55rem .8rem; margin-bottom: .8rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1rem; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-all { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; align-items: center; }
.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; user-select: none; min-height: var(--tap); }
.calc { display: flex; align-items: center; min-height: var(--tap); padding: .4rem .6rem; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: .4rem; font-variant-numeric: tabular-nums; }
.input-with-btn { display: flex; gap: .4rem; flex-wrap: wrap; }
.input-with-btn .combo { flex: 1 1 12rem; }
.seg { display: flex; gap: .35rem; flex-wrap: wrap; }
.seg label { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line-strong); border-radius: .4rem; padding: .3rem .8rem; cursor: pointer; background: #fff; min-height: var(--tap); }
.seg label:has(input:checked) { border-color: var(--coffee); background: var(--caramel-soft); font-weight: 700; }
.seg label:has(input:disabled) { opacity: .6; cursor: not-allowed; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: .8rem; }
.toolbar .search { flex: 1 1 14rem; max-width: 22rem; }
.toolbar select { width: auto; max-width: 100%; }
.inline { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.inline input[type=date] { width: auto; }
.inline.grow { flex: 1 1 14rem; }
.inline.grow .combo { flex: 1; }
.switch { position: relative; display: inline-flex; align-items: center; width: 3rem; min-height: var(--tap); }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { width: 3rem; height: 1.6rem; background: #cfc3b5; border-radius: 1rem; position: relative; transition: background .15s; pointer-events: none; }
.switch span::before { content: ""; position: absolute; width: 1.2rem; height: 1.2rem; left: .2rem; top: .2rem; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(1.4rem); }
.switch input:focus-visible + span { outline: 3px solid var(--caramel); outline-offset: 2px; }

/* ---------------- 表格（電腦版像整齊的 Excel） ---------------- */
.grid { width: 100%; border-collapse: collapse; background: var(--surface); font-variant-numeric: tabular-nums; }
.grid th, .grid td { border: 1px solid var(--line); padding: .45rem .6rem; text-align: left; vertical-align: middle; }
.grid thead th { background: #efe5d8; color: var(--ink-2); font-size: .88rem; font-weight: 700; }
.grid tbody tr:nth-child(even) td { background: #fcf8f2; }
.grid tbody tr:hover td { background: #f6ecdf; }
.grid tr.clickable { cursor: pointer; }
.grid .num { text-align: right; white-space: nowrap; }
.grid .code { font-family: var(--mono); font-size: .9em; white-space: nowrap; }
.grid .wrap { min-width: 10em; }
.grid .actions { text-align: right; }
.grid .actions > * { margin: .15rem 0 .15rem .3rem; }
.grid .empty-row td { text-align: center; color: var(--muted); padding: 1.6rem; background: var(--surface) !important; }
.grid tr.row-low td { background: var(--warn-soft) !important; }
.grid tr.row-short td { background: var(--alert-soft) !important; }
.grid tr.row-cancelled td { color: var(--muted); }
.grid tfoot td { background: #efe5d8; font-weight: 700; border-top: 2px solid var(--line-strong); }
.pager { display: flex; justify-content: center; align-items: center; gap: .8rem; padding: .7rem 0 0; color: var(--muted); flex-wrap: wrap; }

/* ---------------- 標籤與狀態 ---------------- */
.tag { display: inline-block; font-size: .78rem; padding: .05rem .5rem; border-radius: 999px; background: var(--caramel-soft); color: var(--coffee); white-space: nowrap; vertical-align: middle; max-width: 100%; line-height: 1.6; }
.wrap .tag, .tag.long { white-space: normal; text-align: left; }
.tag-muted { background: #ece6de; color: var(--muted); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-alert { background: var(--alert); color: #fff; font-weight: 700; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-info { background: var(--info-soft); color: var(--info); }
.status { display: inline-block; font-size: .85rem; font-weight: 700; padding: .05rem .6rem; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; line-height: 1.6; }
.status-pending_confirmation { background: #fff1c2; color: #6b4b00; border-color: #e7c55c; }
.status-pending_payment { background: var(--warn-soft); color: var(--warn); border-color: #ecd49f; }
.status-pending_shipment { background: var(--info-soft); color: var(--info); border-color: #c1d2e6; }
.status-shipped { background: var(--caramel-soft); color: var(--coffee); border-color: #e2c4a2; }
.status-completed { background: var(--ok-soft); color: var(--ok); border-color: #bcd9c4; }
.status-cancelled { background: #ece6de; color: var(--muted); border-color: #d6ccc0; text-decoration: line-through; }
.mstatus { display: inline-block; font-size: .85rem; font-weight: 700; padding: .05rem .6rem; border-radius: 999px; white-space: nowrap; line-height: 1.6; }
.mstatus-draft { background: #ece6de; color: var(--muted); }
.mstatus-open { background: var(--ok-soft); color: var(--ok); }
.mstatus-closed { background: var(--caramel-soft); color: var(--coffee); }
.error-box, .info-box, .ok-box, .alert-box { border-radius: .4rem; padding: .8rem 1rem; margin: 0 0 1rem; }
.error-box, .alert-box { background: var(--alert-soft); color: var(--alert); }
.info-box { background: var(--warn-soft); color: var(--warn); }
.ok-box { background: var(--ok-soft); color: var(--ok); }

/* ---------------- 首頁 ---------------- */
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; margin-bottom: .4rem; }
.stat { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); border-left: .35rem solid var(--line-strong); min-width: 0; }
.stat:hover { border-color: var(--coffee-2); }
.stat-label { font-weight: 700; color: var(--ink-2); }
.stat-num { font-size: 2.3rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-unit { color: var(--muted); font-size: .9rem; }
.stat-warm { border-left-color: var(--caramel); }
.stat-alert { border-left-color: var(--alert); }
.stat-alert .stat-num { color: var(--alert); }
.stat-hot { border: 2px solid #d9a400; border-left-width: .5rem; background: #fff8dc; }
.stat-hot .stat-num { color: #8a5d00; }
.menu-banner { display: flex; gap: .5rem 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.menu-banner .mb-text { min-width: 0; }
.link-box { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.link-box code { padding: .3rem .5rem; word-break: break-all; }
.low-list, .order-list { list-style: none; margin: 0; padding: 0; }
.low-list li, .order-list li > a { display: flex; justify-content: space-between; gap: .5rem 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); align-items: center; flex-wrap: wrap; }
.low-list li > div:first-child { min-width: 0; flex: 1 1 12rem; }
.low-list .code { font-family: var(--mono); font-size: .88em; color: var(--muted); }
.low-kg { text-align: right; white-space: nowrap; }
.low-kg b { font-size: 1.25rem; }
.order-list li > a { color: inherit; text-decoration: none; min-height: var(--tap); }
.order-list li > a:hover { background: var(--surface-2); }
.order-list .right { text-align: right; white-space: nowrap; }

/* ---------------- 分頁籤（換行排列，不出現捲軸） ---------------- */
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .9rem; padding-bottom: .6rem; border-bottom: 2px solid var(--line); }
.tab { border: 1px solid var(--line-strong); background: var(--surface); font: inherit; padding: .3rem .9rem; cursor: pointer; color: var(--ink-2); border-radius: 999px; min-height: var(--tap); display: inline-flex; align-items: center; gap: .35rem; }
.tab:hover { border-color: var(--coffee-2); }
.tab.active { background: var(--coffee); color: #fff; border-color: var(--coffee); font-weight: 700; }
.tab .count { font-size: .8em; background: rgba(0, 0, 0, .08); border-radius: 999px; padding: 0 .45rem; }
.tab.active .count { background: rgba(255, 255, 255, .25); }
.tab.hot:not(.active) { border-color: #d9a400; background: #fff8dc; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem .9rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; }

/* ---------------- 合計區 ---------------- */
.totals { display: grid; gap: .3rem; margin-left: auto; max-width: 26rem; margin-top: .8rem; font-variant-numeric: tabular-nums; }
.totals > div { display: flex; justify-content: space-between; align-items: baseline; gap: .3rem 1rem; flex-wrap: wrap; }
.totals .grand { border-top: 2px solid var(--coffee); padding-top: .4rem; margin-top: .2rem; font-size: 1.2rem; color: var(--coffee); }

/* ---------------- 訂單品項編輯（格狀排列，窄版自動上下排） ---------------- */
.lines { display: flex; flex-direction: column; gap: .5rem; }
.line, .line-head { display: grid; grid-template-columns: 2rem minmax(12rem, 3fr) 8.5rem 5.5rem 7rem 6rem minmax(8rem, 1.6fr) var(--tap); gap: .4rem; align-items: start; }
.line-head { font-size: .85rem; font-weight: 700; color: var(--ink-2); background: #efe5d8; padding: .35rem .5rem; border-radius: .3rem; }
.line { padding: .5rem; border: 1px solid var(--line); border-radius: .4rem; background: #fff; }
.line > .ln { color: var(--muted); padding-top: .55rem; text-align: center; }
.line .sub { padding-top: .55rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.line .lbl { display: none; font-size: .82rem; color: var(--muted); }
.line .line-full { margin-top: .2rem; line-height: 1.35; font-size: .85rem; color: var(--muted); }
.line .usage { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.line-actions { display: flex; gap: .5rem; margin-top: .7rem; flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 75%, rgba(245, 239, 231, 0)); padding: .8rem 0 .4rem; z-index: 5; }
.sticky-total { margin-right: auto; font-size: 1.1rem; color: var(--coffee); font-variant-numeric: tabular-nums; }

/* 豆單品項編輯 */
.mi-row { display: grid; grid-template-columns: 2rem minmax(12rem, 3fr) 7.5rem 7.5rem 6.5rem auto; gap: .5rem; align-items: center; padding: .5rem; border: 1px solid var(--line); border-radius: .4rem; background: #fff; margin-bottom: .5rem; }
.mi-row.off { background: #f4f0ea; }
.mi-row .mi-move { display: flex; gap: .2rem; justify-content: flex-end; flex-wrap: wrap; }
.mi-row .lbl { display: none; font-size: .82rem; color: var(--muted); }

/* 烘焙預覽／缺料 */
.stock-preview { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: .4rem; padding: .7rem 1rem; }
.sp-item { display: flex; flex-direction: column; }
.sp-item span { font-size: .82rem; color: var(--muted); }
.sp-item b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.sum-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin: .2rem 0 1rem; }
.sum-cards > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: .4rem; padding: .55rem .8rem; display: flex; flex-direction: column; min-width: 0; }
.sum-cards span { font-size: .82rem; color: var(--muted); }
.sum-cards b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.sum-cards .bad { background: var(--alert-soft); border-color: #ecc1b7; }
.sum-cards .bad b { color: var(--alert); }

/* ---------------- 快速搜尋選單 ---------------- */
.combo { position: relative; width: 100%; min-width: 0; }
.combo-list { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 50; min-width: min(22rem, 90vw); max-height: 20rem; overflow-y: auto; background: #fff; border: 1px solid var(--line-strong); border-radius: .4rem; box-shadow: 0 8px 24px rgba(40, 25, 15, .15); }
.combo-list.open { display: block; }
.combo-item { padding: .5rem .7rem; cursor: pointer; display: flex; gap: .2rem .5rem; align-items: baseline; flex-wrap: wrap; border-bottom: 1px solid #f3ece3; min-height: var(--tap); }
.combo-item.active, .combo-item:hover { background: var(--caramel-soft); }
.combo-code { font-family: var(--mono); font-size: .85em; color: var(--muted); min-width: 3.5em; }
.combo-full { color: var(--muted); font-size: .85em; flex: 1 1 10em; }
.combo-empty { padding: .7rem; color: var(--muted); }

/* ---------------- 對話框與提示 ---------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(35, 22, 14, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 1rem 1rem; z-index: 100; overflow-y: auto; }
.modal { background: var(--surface); border-radius: .65rem; width: 100%; max-width: 30rem; box-shadow: 0 20px 50px rgba(30, 15, 5, .3); }
.modal-wide { max-width: 48rem; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .6rem .6rem .6rem 1.1rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 1rem 1.1rem 1.1rem; }
.confirm-msg { margin: 0 0 .5rem; }
#toasts { position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; max-width: min(28rem, calc(100vw - 2rem)); }
.toast { padding: .7rem 1rem; border-radius: .5rem; color: #fff; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); transition: opacity .3s, transform .3s; }
.toast-ok { background: var(--ok); } .toast-error { background: var(--alert); } .toast-info { background: var(--coffee-2); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------------- 登入 ---------------- */
body.is-login { background: radial-gradient(circle at 30% 20%, #f8f1e7, #eadcc9); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 26rem; background: var(--surface); padding: 2rem 1.6rem; border-radius: .9rem; box-shadow: 0 10px 40px rgba(60, 35, 20, .15); display: grid; gap: 1rem; }
.login-top { display: flex; justify-content: flex-end; }
.login-brand { text-align: center; }
.login-brand h1 { margin-top: .6rem; color: var(--coffee); font-size: 1.4rem; }
.login-brand p { margin: .2rem 0 0; color: var(--muted); }
.login-hint { margin: 0; font-size: .9rem; color: var(--muted); background: var(--surface-2); border: 1px dashed var(--line-strong); padding: .6rem .8rem; border-radius: .4rem; text-align: center; }
.login-card .font-btn { border-color: var(--line-strong); }

/* ---------------- 出貨單（列印版型固定，不跟著字體放大） ---------------- */
.sheet-scroll { padding-bottom: 1rem; }
.sheet { width: 210mm; min-height: 148mm; margin: 0 auto; padding: 14mm 14mm 12mm; background: #fff; color: #000; box-shadow: 0 2px 16px rgba(0, 0, 0, .12); font-family: var(--font); font-size: 11pt; line-height: 1.45; position: relative; }
.sheet.capture { box-shadow: none; }
.sn-head { text-align: center; border-bottom: 2px solid #000; padding-bottom: 4mm; margin-bottom: 4mm; }
.sn-title { font-size: 20pt; font-weight: 800; letter-spacing: .08em; }
.sn-sub { display: flex; justify-content: center; gap: 8mm; margin-top: 1mm; font-size: 11pt; }
.sn-doc { font-weight: 800; letter-spacing: .3em; border: 1.5px solid #000; padding: 0 3mm; }
.sn-stamp { position: absolute; top: 12mm; right: 14mm; border: 2.5px solid #000; padding: 1mm 4mm; font-size: 14pt; font-weight: 800; letter-spacing: .2em; transform: rotate(-6deg); }
.sn-meta { display: flex; gap: 6mm; flex-wrap: wrap; margin-bottom: 3mm; }
.sn-meta > div { display: flex; gap: 1mm; }
.sn-meta > div:first-child { flex: 1; }
.sn-meta .grow { flex: 1; }
.sn-delivery { font-size: 10pt; }
.sn-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.sn-table th, .sn-table td { border: 1px solid #000; padding: 1.6mm 2mm; vertical-align: middle; word-break: break-word; }
.sn-table thead th { font-weight: 700; background: #fff; border-bottom: 2px solid #000; font-size: 10pt; white-space: nowrap; }
.sn-table .c { text-align: center; } .sn-table .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sn-table .w1 { width: 13mm; } .sn-table .w2 { width: 17mm; } .sn-table .w3 { width: 22mm; } .sn-table .w4 { width: 26mm; }
.sn-table .note { font-size: 9.5pt; }
.sn-table tr.blank td { height: 7.5mm; }
.sn-table tfoot td { border-top: 1px solid #000; }
.sn-table tfoot tr:first-child td { border-top: 2px solid #000; }
.sn-table .lbl { font-weight: 700; }
.sn-table .sum td { border-top: 2px solid #000; font-size: 12pt; }
.sn-table .sum small { font-weight: 400; font-size: 9pt; }
.sn-notes { margin-top: 3mm; font-size: 10pt; }
.sn-thanks { margin-top: 6mm; text-align: center; font-size: 10pt; letter-spacing: .2em; }
@page { size: A4; margin: 10mm; }
@media print {
  html { font-size: 16px !important; }
  body { background: #fff; }
  .topbar, .mobilenav, .more-sheet, .no-print, #toasts, .modal-backdrop { display: none !important; }
  .page { padding: 0; max-width: none; }
  .sheet-holder { zoom: 1 !important; }
  .sheet { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
  .sn-stamp { top: 0; right: 0; }
  .sn-table tr { break-inside: avoid; }
  .sn-table thead { display: table-header-group; }
}

/* ======================= 較窄（或字體放大後） ======================= */
html.w-mid .brand-text small { display: none; }
html.w-mid .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
html.w-mid .form-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
html.w-mid .form-grid .span-3 { grid-column: 1 / -1; }
html.w-mid .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
html.w-mid .sum-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
html.w-mid .grid .code { white-space: normal; }
html.w-mid .line-head { display: none; }
html.w-mid .line { grid-template-columns: 2rem minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "ln item item item" "ln spec qty price" "ln sub notes x"; }
html.w-mid .line > .ln { grid-area: ln; }
html.w-mid .line > .c-item { grid-area: item; } html.w-mid .line > .c-spec { grid-area: spec; } html.w-mid .line > .c-qty { grid-area: qty; }
html.w-mid .line > .c-price { grid-area: price; } html.w-mid .line > .sub { grid-area: sub; text-align: left; } html.w-mid .line > .c-notes { grid-area: notes; }
html.w-mid .line > .c-x { grid-area: x; justify-self: end; }
html.w-mid .line .lbl { display: block; }
html.w-mid .mi-row { grid-template-columns: 2rem minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "n bean bean" "n half drip" "n avail move"; }
html.w-mid .mi-row > .mi-n { grid-area: n; } html.w-mid .mi-row > .mi-bean { grid-area: bean; } html.w-mid .mi-row > .mi-half { grid-area: half; }
html.w-mid .mi-row > .mi-drip { grid-area: drip; } html.w-mid .mi-row > .mi-avail { grid-area: avail; } html.w-mid .mi-row > .mi-move { grid-area: move; }
html.w-mid .mi-row .lbl { display: block; }
html.w-mid .mi-head { display: none; }

/* ======================= 手機排法 ======================= */
html.w-mid body { padding-bottom: 5rem; }
html.w-narrow .topbar { padding: .4rem .6rem; gap: .4rem; }
html.w-mid .mainnav { display: none; }
html.w-narrow .brand-text { display: none; }
html.w-narrow .mock-badge { font-size: .75rem; padding: .1rem .55rem; }
html.w-mid .mobilenav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--line-strong); padding-bottom: env(safe-area-inset-bottom); }
html.w-mid .mobilenav a, html.w-mid .mobilenav button { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .05rem; padding: .3rem .1rem; text-decoration: none; color: var(--muted); font: inherit; font-size: .78rem; min-height: 3.6rem; background: none; border: 0; cursor: pointer; line-height: 1.2; }
html.w-mid .mobilenav .nav-ico { font-size: 1.3rem; opacity: 1; }
html.w-mid .mobilenav .active { color: var(--coffee); font-weight: 700; background: var(--caramel-soft); }
html.w-mid .more-sheet.open { display: block; position: fixed; left: 0; right: 0; bottom: 3.6rem; z-index: 45; background: var(--surface); border-top: 1px solid var(--line-strong); box-shadow: 0 -8px 24px rgba(0, 0, 0, .15); padding: .6rem; max-height: 70vh; overflow-y: auto; }
html.w-mid .more-sheet a { display: flex; align-items: center; gap: .6rem; min-height: 3rem; padding: .3rem .8rem; text-decoration: none; color: var(--ink); border-radius: .4rem; }
html.w-mid .more-sheet a.active { background: var(--caramel-soft); font-weight: 700; }
html.w-narrow .page { padding: .9rem .75rem 2rem; }
html.w-narrow h1 { font-size: 1.35rem; }
html.w-narrow .cards-2 { grid-template-columns: minmax(0, 1fr); }
html.w-narrow .form-grid, html.w-narrow .form-grid.cols-3, html.w-narrow .form-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
html.w-narrow .span-2, html.w-narrow .span-3 { grid-column: 1 / -1; }
html.w-narrow .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
html.w-narrow .stat { padding: .6rem .7rem; }
html.w-narrow .stat-num { font-size: 1.9rem; }
html.w-narrow .toolbar > *, html.w-narrow .toolbar .search, html.w-narrow .toolbar select { flex: 1 1 100%; max-width: none; width: 100%; }
html.w-narrow .inline { width: 100%; }
html.w-narrow .inline input[type=date] { flex: 1; width: auto; }
html.w-mid #toasts { bottom: 4.6rem; }
html.w-narrow #toasts { left: .75rem; right: .75rem; max-width: none; }
html.w-narrow .modal-backdrop { padding: 0; align-items: flex-end; }
html.w-narrow .modal { border-radius: .9rem .9rem 0 0; max-height: 92vh; overflow-y: auto; }
html.w-narrow .head-actions { width: 100%; }
html.w-narrow .head-actions > .btn { flex: 1 1 auto; }
html.w-mid .sticky-actions { bottom: 3.6rem; }
html.w-narrow .sticky-actions { flex-wrap: wrap; }
html.w-narrow .sticky-actions .btn { flex: 1 1 8rem; }
html.w-narrow .sticky-total { width: 100%; text-align: right; }
html.w-narrow .line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "item item" "spec qty" "price sub" "notes notes" "ln x"; }
html.w-narrow .line > .ln { text-align: left; padding-top: .5rem; }
html.w-narrow .mi-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "bean bean" "half drip" "avail move" "n n"; }
html.w-narrow .mi-row > .mi-n { display: none; }
html.w-narrow .sum-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
html.w-narrow .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
html.w-narrow .kv dt { margin-top: .4rem; font-size: .88rem; }

/* 一般表格在手機上改成一張一張的卡片 */
html.w-mid .rtable thead { display: none; }
html.w-mid .rtable, html.w-mid .rtable tbody, html.w-mid .rtable tfoot, html.w-mid .rtable tr, html.w-mid .rtable td { display: block; width: 100%; }
html.w-mid .rtable { background: transparent; }
html.w-mid .rtable tr { background: var(--surface) !important; border: 1px solid var(--line); border-radius: .6rem; margin-bottom: .7rem; padding: .5rem .8rem; box-shadow: var(--shadow); }
html.w-mid .rtable tr.row-low { border-left: .4rem solid var(--warn); background: var(--warn-soft) !important; }
html.w-mid .rtable tr.row-short { border-left: .4rem solid var(--alert); background: var(--alert-soft) !important; }
html.w-mid .rtable td { border: 0; padding: .2rem 0; display: flex; justify-content: space-between; gap: .3rem 1rem; text-align: right; background: transparent !important; flex-wrap: wrap; }
html.w-mid .rtable td::before { content: attr(data-label); color: var(--muted); font-size: .88rem; text-align: left; flex: none; }
html.w-mid .rtable td[data-label=""]::before { content: none; }
html.w-mid .rtable td.wrap { display: block; text-align: left; padding: .2rem 0 .35rem; min-width: 0; }
html.w-mid .rtable td.wrap::before { display: block; margin-bottom: .1rem; }
html.w-mid .rtable td.wrap b { font-size: 1.08rem; margin-right: .3rem; }
html.w-mid .rtable td.actions { justify-content: flex-end; gap: .4rem; padding-top: .5rem; }
html.w-mid .rtable td.actions > * { margin: 0; flex: 1 1 auto; }
html.w-mid .rtable .empty-row { border: 0; box-shadow: none; }
html.w-mid .rtable .empty-row td { justify-content: center; }
html.w-mid .rtable .empty-row td::before { content: none; }
html.w-mid .rtable tfoot tr { background: #efe5d8 !important; }
html.w-mid .m-hide { display: none !important; }

/* ======================= 客人下單頁 ======================= */
body.public { background: #f7f1e8; }
.pub-wrap { max-width: 36rem; margin: 0 auto; padding: 0 .9rem 6rem; }
.pub-top { position: sticky; top: 0; z-index: 20; background: var(--coffee); color: #f6efe6; }
.pub-top-in { max-width: 36rem; margin: 0 auto; display: flex; align-items: center; gap: .6rem; padding: .45rem .9rem; }
.pub-top .brand-text b { font-size: 1.02rem; }
.pub-top .font-btn { margin-left: auto; }
.pub-hero { text-align: center; padding: 1.2rem .5rem .6rem; }
.pub-hero h1 { color: var(--coffee); font-size: 1.45rem; }
.pub-hero p { margin: .3rem 0 0; color: var(--muted); }
.pub-steps { display: flex; gap: .3rem; justify-content: center; flex-wrap: wrap; margin: .4rem 0 1rem; }
.pub-steps span { padding: .15rem .7rem; border-radius: 999px; background: #ece6de; color: var(--muted); font-size: .85rem; }
.pub-steps span.on { background: var(--coffee); color: #fff; font-weight: 700; }
.pub-item { background: var(--surface); border: 1px solid var(--line); border-radius: .7rem; padding: .9rem 1rem; margin-bottom: .8rem; box-shadow: var(--shadow); }
.pub-item h3 { margin: 0; font-size: 1.08rem; line-height: 1.45; }
.pub-item .proc { display: inline-block; margin-top: .3rem; }
.pub-item .flavor { margin: .4rem 0 .6rem; color: var(--ink-2); font-size: .95rem; }
.pub-item.picked { border-color: var(--caramel); box-shadow: 0 0 0 2px var(--caramel-soft); }
.pub-spec { display: flex; align-items: center; justify-content: space-between; gap: .4rem .8rem; padding: .45rem 0; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.pub-spec .ps-label { min-width: 0; }
.pub-spec .ps-label b { font-size: 1.05rem; }
.pub-spec.na { color: var(--muted); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: .5rem; overflow: hidden; background: #fff; }
.stepper button { width: var(--tap); height: var(--tap); border: 0; background: var(--surface-2); font: inherit; font-size: 1.35rem; font-weight: 700; color: var(--coffee); cursor: pointer; }
.stepper button:disabled { color: #c9bcae; cursor: default; }
.stepper input { width: 3.2rem; min-height: var(--tap); border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0; text-align: center; font-weight: 700; font-size: 1.1rem; padding: 0; }
.pub-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line-strong); box-shadow: 0 -6px 18px rgba(0, 0, 0, .1); padding-bottom: env(safe-area-inset-bottom); }
.pub-bar-in { max-width: 36rem; margin: 0 auto; display: flex; align-items: center; gap: .6rem; padding: .55rem .9rem; flex-wrap: wrap; }
.pub-bar .pb-sum { flex: 1 1 8rem; min-width: 0; }
.pub-bar .pb-sum b { font-size: 1.15rem; color: var(--coffee); }
.pub-bar .btn { flex: 0 1 auto; }
.pub-section { background: var(--surface); border: 1px solid var(--line); border-radius: .7rem; padding: 1rem; margin-bottom: 1rem; }
.pub-section h2 { font-size: 1.1rem; }
.pub-section .field { margin-bottom: .8rem; }
.pub-privacy { font-size: .9rem; color: var(--muted); background: var(--surface-2); border-radius: .4rem; padding: .6rem .8rem; }
.pub-confirm-list { list-style: none; margin: 0; padding: 0; }
.pub-confirm-list li { display: flex; justify-content: space-between; gap: .3rem 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pub-confirm-list li > span:first-child { flex: 1 1 12rem; min-width: 0; }
.pub-total { display: flex; justify-content: space-between; font-size: 1.2rem; font-weight: 800; color: var(--coffee); padding-top: .6rem; flex-wrap: wrap; gap: .3rem; }
.pub-ship-note { background: var(--warn-soft); color: var(--warn); border-radius: .4rem; padding: .6rem .8rem; font-weight: 700; margin-top: .6rem; }
.pub-done { text-align: center; padding: 2rem 1rem; }
.pub-done .big-check { width: 4.5rem; height: 4.5rem; border-radius: 50%; background: var(--ok); color: #fff; display: inline-grid; place-items: center; font-size: 2.4rem; margin-bottom: .6rem; }
.pub-done .ono { display: inline-block; font-family: var(--mono); font-size: 1.25rem; font-weight: 800; background: var(--caramel-soft); padding: .3rem .8rem; border-radius: .4rem; margin: .5rem 0; word-break: break-all; }
.pub-closed { text-align: center; padding: 3rem 1rem; }
.pub-closed .icon { font-size: 3rem; }
.pub-kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .3rem .8rem; }
html.w-mid body.public { padding-bottom: 0; }
html.w-narrow .pub-kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
html.w-narrow .pub-kv dt { margin-top: .4rem; }
html.w-narrow .sticky-actions { position: static; background: none; padding-top: .4rem; }
.mainnav .nav-ico { display: none; }
.mainnav a { padding: .35rem .6rem; }
html.w-mid:not(.w-narrow) .more-sheet.open { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .3rem; }

.more-extra { display: flex; gap: .5rem; flex-wrap: wrap; padding: .5rem .3rem 0; border-top: 1px solid var(--line); margin-top: .3rem; grid-column: 1 / -1; }
.more-extra .btn { flex: 1 1 8rem; }
html.w-narrow .topbar-right #mockBadge, html.w-narrow .topbar-right #logoutBtn { display: none; }
html.w-narrow .topbar { flex-wrap: nowrap; }
html.w-narrow .login-wrap { padding: .5rem; }
html.w-narrow .login-card { padding: 1.2rem .9rem; }
html.w-narrow .login-card input[type=email] { font-size: .85em; }
#fontSlot { margin-left: auto; }
.pub-top-in { flex-wrap: wrap; }
html.w-narrow .pub-top .brand-text { display: flex; }
html.w-narrow .pub-top .brand-text small { display: none; }

html.w-mid:not(.w-narrow) .rtable tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; align-items: start; }
html.w-mid:not(.w-narrow) .rtable tbody tr { margin-bottom: 0; }
html.w-mid:not(.w-narrow) .rtable .empty-row { grid-column: 1 / -1; }
html.w-mid .rtable tfoot tr { margin-top: .7rem; }
html.w-tiny .sum-cards { grid-template-columns: minmax(0, 1fr); }
html.w-tiny .rtable td { flex-direction: column; align-items: flex-start; text-align: left; gap: 0; }
html.w-tiny .rtable td.actions { flex-direction: row; }

/* ---------- v3 第一段：運費設定、查單、完成頁 ---------- */
.settings-card { max-width: 32rem; }
.ship-rows { display: grid; gap: .2rem; }
.ship-row { display: grid; grid-template-columns: 5rem minmax(0, 1fr); align-items: center; gap: .3rem .8rem; }
.ship-row > span:first-child { font-weight: 700; }
.input-unit { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.input-unit input { flex: 1 1 auto; min-width: 0; max-width: 10rem; }
.input-unit .unit { color: var(--muted); }
html.w-narrow .ship-row { grid-template-columns: minmax(0, 1fr); }
.pub-toplink { margin: .7rem 0 0; text-align: right; }
.pub-toplink a { display: inline-flex; align-items: center; min-height: var(--tap); padding: .2rem .8rem; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--coffee); font-weight: 700; text-decoration: none; }
.pub-toplink a[data-lk-back] { border: 0; background: none; padding-left: 0; }
.seg .seg-sub { display: block; font-size: .8em; color: var(--muted); font-weight: 400; }
.seg label { flex-wrap: wrap; line-height: 1.3; }
.pub-sumrows { padding-top: .5rem; }
.pub-sumrows > div { display: flex; justify-content: space-between; gap: .2rem 1rem; flex-wrap: wrap; padding: .2rem 0; }
.pub-sumrows > div > span:last-child { text-align: right; margin-left: auto; }
.pub-done .ono-big { word-break: normal; overflow-wrap: normal; font-size: 1.6rem; letter-spacing: .04em; padding: .4rem 1rem; border: 2px dashed var(--caramel); }
.shot-tip { background: var(--warn-soft); color: var(--warn); border-radius: .4rem; padding: .6rem .8rem; }
.done-sum { text-align: left; }
.done-actions { display: grid; gap: .5rem; margin: 1rem 0; }
.done-actions p { margin: 0; }
.copy-box { width: 100%; font-size: .95rem; line-height: 1.5; padding: .6rem; border: 1px solid var(--line-strong); border-radius: .4rem; background: #fff; resize: vertical; user-select: text; -webkit-user-select: text; }
.lk-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem 1rem; flex-wrap: wrap; }
.lk-head .ono { display: inline-block; font-family: var(--mono); font-size: 1.15rem; font-weight: 800; word-break: break-all; }
.lk-status { display: inline-block; padding: .2rem .8rem; border-radius: 999px; font-weight: 700; background: var(--info-soft); color: var(--info); }
.lk-status.lk-pending_confirmation, .lk-status.lk-pending_payment { background: var(--warn-soft); color: var(--warn); }
.lk-status.lk-shipped, .lk-status.lk-completed { background: var(--ok-soft, #e3f1e6); color: var(--ok); }
.lk-status.lk-cancelled { background: var(--surface-2); color: var(--muted); }

/* ---------- v3 第二段：記住資料、跟上次一樣 ---------- */
.reuse-field { background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: .5rem; padding: .6rem .8rem; }
.reuse-check { display: flex; align-items: center; gap: .6rem; min-height: var(--tap); font-weight: 700; cursor: pointer; }
.reuse-check input { width: 1.4rem; height: 1.4rem; flex: 0 0 auto; }
.pub-privacy p { margin: 0 0 .4rem; }
.pub-privacy .btn { margin-top: .2rem; }
.done-privacy { margin-top: 1rem; }
.tag-needinfo { background: var(--alert-soft); color: var(--alert); border: 1px solid currentColor; }
.cust-missing { color: var(--alert); font-weight: 700; }

/* ---------- v3 第三段：本期推薦 ---------- */
.mi-row, .mi-head { grid-template-columns: 2rem minmax(12rem, 3fr) 7.5rem 7.5rem 8rem auto; }
.mi-avail { display: flex; flex-direction: column; align-items: flex-start; gap: 0; }
.feat-check { font-size: .92em; min-height: 2.75rem; }
.feat-item { border: 1px solid var(--caramel); border-radius: .5rem; padding: .8rem 1rem; margin-bottom: .8rem; background: #fffaf3; }
.feat-item h3 { margin: 0 0 .5rem; font-size: 1.05rem; }
.feat-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(12rem, 1fr); gap: .6rem 1rem; }
.feat-story textarea { width: 100%; min-height: 8rem; }
.feat-photo { display: flex; flex-direction: column; gap: .4rem; }
.photo-thumb { width: 100%; max-width: 18rem; aspect-ratio: 4 / 3; object-fit: cover; border-radius: .4rem; border: 1px solid var(--line); background: #f3ede5; }
.photo-ph { width: 100%; max-width: 18rem; aspect-ratio: 4 / 3; display: grid; place-items: center; border: 1px dashed var(--line-strong); border-radius: .4rem; color: var(--muted); background: #f8f4ee; }
.photo-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.photo-pick { cursor: pointer; }
.photo-pick.disabled { opacity: .6; pointer-events: none; }
html.w-mid .feat-grid { grid-template-columns: minmax(0, 1fr); }

/* 客人頁：推薦卡片 */
.pub-feat-title { font-size: 1.15rem; color: var(--coffee); margin: .4rem 0 .6rem; }
.pub-feat { background: var(--surface); border: 2px solid var(--caramel); border-radius: .8rem; overflow: hidden; margin-bottom: 1rem; box-shadow: var(--shadow); }
.pub-feat.picked { box-shadow: 0 0 0 3px var(--caramel-soft); }
.pub-feat img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; background: #efe7dc; }
.pub-feat-body { padding: .8rem 1rem 1rem; }
.pub-feat-body h3 { margin: .2rem 0 .3rem; font-size: 1.1rem; line-height: 1.45; }
.tag-feat { display: inline-block; background: var(--caramel); color: #fff; font-weight: 700; border-radius: 999px; padding: .05rem .6rem; font-size: .82rem; }
.story { white-space: pre-line; margin: .4rem 0 .2rem; line-height: 1.7; color: var(--ink-2); }
.story.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.story-toggle { background: none; border: 0; color: var(--coffee); font-weight: 700; padding: .3rem 0; min-height: var(--tap); cursor: pointer; text-decoration: underline; font-size: .95em; }

/* ---------- v4：電話辨識、首購 ---------- */
.phone-row { display: flex; gap: .5rem; align-items: stretch; flex-wrap: wrap; }
.phone-row input { flex: 1 1 10rem; min-width: 0; }
.phone-row .btn { flex: 0 0 auto; }
.who-box { border-radius: .6rem; padding: .8rem 1rem; margin: .4rem 0 1rem; }
.who-returning { background: var(--ok-soft); border: 1px solid #bcd9c4; }
.who-new { background: var(--caramel-soft); border: 1px solid var(--caramel); }
.who-title { font-size: 1.15rem; font-weight: 800; margin: 0 0 .4rem; color: var(--coffee); }
.who-box .pub-kv { margin: 0 0 .3rem; }
.who-box p:last-child { margin-bottom: 0; }
.tag-first { display: inline-block; background: #2f6a45; color: #fff; font-weight: 700; border-radius: 999px; padding: .05rem .6rem; font-size: .8rem; vertical-align: middle; }
.pub-ship-note.first-free { background: var(--ok-soft); color: var(--ok); }
.pending-warn p { margin: 0 0 .5rem; }
.pw-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* v4：後台頁面內分頁 */
.subtabs { display: flex; flex-wrap: wrap; gap: .4rem; padding: 1rem 1.25rem 0; max-width: 80rem; margin: 0 auto; }
.subtabs a { display: inline-flex; align-items: center; min-height: var(--tap); padding: .2rem 1rem; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); text-decoration: none; font-weight: 700; }
.subtabs a.active { background: var(--coffee); border-color: var(--coffee); color: #fff; }
.subtabs + div > .page { padding-top: .8rem; }
html.w-narrow .subtabs { padding: .8rem .75rem 0; }
html.w-mid .mobilenav button.active { color: var(--coffee); font-weight: 700; background: var(--caramel-soft); }
.sn-first { display: inline-block; margin-left: .4rem; border: 1px solid #333; border-radius: .2rem; padding: 0 .3rem; font-size: .8em; }
