/* 顏色與尺寸都來自 theme.css */
* { 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(--sans); font-size: var(--text); line-height: 1.7; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.35; margin: 0; text-wrap: pretty; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }
p { margin: 0; }
a { color: inherit; }
small, .hint { font-size: var(--text-xs); color: var(--soil); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── 客人頁面：手機一欄 ── */
.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top .in { max-width: var(--col); margin: 0 auto; padding: 10px max(var(--gutter), env(safe-area-inset-right, 0px)) 10px max(var(--gutter), env(safe-area-inset-left, 0px)); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--serif); font-weight: 600; }
.brand img { width: 32px; height: 32px; }
.who { font-size: var(--text-xs); color: var(--soil); display: flex; align-items: center; gap: 8px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--soil); text-decoration: underline; cursor: pointer; }
.main { max-width: var(--col); margin: 0 auto; padding: 22px max(var(--gutter), env(safe-area-inset-right, 0px)) 48px max(var(--gutter), env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 18px; }
.foot { max-width: var(--col); margin: 0 auto; padding: 0 var(--gutter) 32px; font-size: var(--text-xs); color: var(--soil); display: flex; flex-wrap: wrap; gap: 6px 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.steps { display: flex; gap: 4px; }
.steps span { height: 4px; flex: 1; background: var(--line); }
.steps span.on { background: var(--accent); }

.flash { border: 1px solid var(--warn); border-left-width: 4px; background: var(--surface); padding: 12px 14px; color: var(--warn); }
.notice { background: var(--sage); border: 1px solid var(--leaf); padding: 12px 14px; }
.card { background: var(--surface); border: 1px solid var(--line); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card.soft { background: var(--sage); border-color: var(--leaf); }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.tag { display: inline-block; background: var(--kraft); color: var(--soil); font-size: var(--text-xs); padding: 1px 8px; white-space: nowrap; }
.tag.ok { background: var(--sage); color: var(--ok); }
.tag.due { background: transparent; border: 1px solid var(--warn); color: var(--warn); }

/* 選項：整塊都可以按 */
.opt { position: relative; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); padding: 14px 16px 14px 48px; cursor: pointer; min-height: var(--tap); }
.opt input { position: absolute; left: 16px; top: 18px; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.opt:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.opt:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }
.opt b { font-weight: 600; }
.opt.out .name { text-decoration: line-through; color: var(--soil); }
.opt .swap { color: var(--accent); font-size: var(--text-s); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 10px 18px; font: inherit; font-weight: 600; border: 1px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; text-align: center; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.block { width: 100%; }
.btn.small { min-height: var(--tap-s); padding: 6px 12px; font-size: var(--text-s); font-weight: 400; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.nav { display: flex; gap: 10px; }
.nav .btn.primary { flex: 1; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; }

.sum { margin: 0; border-top: 1px solid var(--line); }
.sum div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.sum dt { color: var(--soil); white-space: nowrap; }
.sum dd { margin: 0; text-align: right; }
.total { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: var(--text-s); color: var(--soil); }
.field input, .field textarea, .field select { font: inherit; padding: 10px 12px; min-height: var(--tap-s); border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); width: 100%; }
.field textarea { min-height: 5.5em; resize: vertical; }
.list { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 4px; }

/* ── 後台 ── */
.admin .top .in, .admin .main { max-width: var(--wide); }
.tabs { border-bottom: 1px solid var(--line); background: var(--surface); }
.tabs .in { max-width: var(--wide); margin: 0 auto; display: flex; flex-wrap: wrap; padding: 0 max(var(--gutter), env(safe-area-inset-right, 0px)) 0 max(var(--gutter), env(safe-area-inset-left, 0px)); }
.tabs a { padding: 12px 16px; text-decoration: none; color: var(--soil); border-bottom: 2px solid transparent; font-size: var(--text-s); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a.right { margin-left: auto; }
.stages { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.stages li { font-size: var(--text-s); padding: 8px 14px; border: 1px solid var(--line); background: var(--surface); color: var(--soil); display: flex; gap: 8px; align-items: center; }
.stages li b { font-family: var(--serif); }
.stages li.past { color: var(--ok); }
.stages li.now { border-color: var(--ink); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 600; }
.jobs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.jobs li { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; border: 1px solid var(--line); background: var(--surface); padding: 12px 14px; }
.jobs li > div { flex: 1 1 15em; min-width: 0; }
.jobs li.must { border-left: 3px solid var(--accent); }
.jobs small { display: block; }
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.figure { border: 1px solid var(--line); background: var(--surface); padding: 10px 12px; }
.figure span { display: block; font-size: var(--text-xs); color: var(--soil); }
.figure b { font-size: 1.125rem; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: var(--text-s); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: var(--text-xs); color: var(--soil); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.nw { white-space: nowrap; }
table.wide { min-width: 760px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; align-items: start; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.devbar { background: var(--kraft); font-size: var(--text-xs); }
.devbar .in { max-width: var(--wide); margin: 0 auto; padding: 6px var(--gutter); display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.devbar .btn.small { min-height: 30px; padding: 2px 10px; font-size: var(--text-xs); }
@media (prefers-reduced-motion: no-preference) { .btn, .opt { transition: background-color .15s, border-color .15s; } }

/* ── 單據：選要印什麼 ── */
.docs { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 12px; align-items: start; }
.doc { display: flex; flex-direction: column; }
.docopts { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; border: 1px solid var(--line); border-top: 0; background: var(--bg); padding: 8px 16px; font-size: var(--text-s); }
.docopts > span { color: var(--soil); font-size: var(--text-xs); }
.check { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap-s); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

/* ── 一週多檔：客人首頁每一檔一段；後台切換檔期的那一條 ── */
.cyclesec { border-top: 2px solid var(--ink); padding-top: 18px; }
.cyclebar { border-bottom: 1px solid var(--line); font-size: var(--text-s); }
.cyclebar .in { max-width: var(--wide); margin: 0 auto; padding: 8px max(var(--gutter), env(safe-area-inset-right, 0px)) 8px max(var(--gutter), env(safe-area-inset-left, 0px)); display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.pickcycle { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.pickcycle label { color: var(--soil); }
.pickcycle select { font: inherit; min-height: var(--tap-s); padding: 6px 10px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); max-width: 100%; min-width: 0; }
.card.narrow { max-width: var(--col); }

/* 匯款資訊：照後台打的換行顯示 */
.pre { white-space: pre-line; overflow-wrap: anywhere; }

/* 後台表格裡的小表單：下拉和按鈕排成一列 */
.inline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.inline select, .field select { font: inherit; min-height: var(--tap-s); padding: 6px 10px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); max-width: 100%; }

/* 加價購：每樣一張卡片，右邊填份數 */
.qty { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qty > span { font-size: var(--text-s); color: var(--soil); }
.qty input, .inline input { font: inherit; min-height: var(--tap-s); padding: 6px 10px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); }
.qty input { width: 6em; min-height: var(--tap); text-align: center; }
.inline input { width: 7em; }
.code { font-family: var(--mono, ui-monospace, monospace); letter-spacing: 0.08em; }

/* LINE 選單圖的預覽、本機示範的假聊天室 */
.menuart { display: block; width: 100%; max-width: 22rem; height: auto; border: 1px solid var(--line); }
.chat { display: flex; flex-direction: column; gap: 10px; }
.chat p { margin: 0; }
.chat > .me { align-self: flex-end; max-width: 80%; background: var(--sage); border: 1px solid var(--leaf); padding: 8px 12px; overflow-wrap: anywhere; }
.chat > .bot { align-self: flex-start; max-width: 90%; background: var(--surface); border: 1px solid var(--line); padding: 8px 12px; }
.chatcard { align-self: flex-start; width: 100%; max-width: 22rem; background: var(--surface); border: 1px solid var(--line-strong); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.chatcard h3 { margin: 0; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.chatcard .kv { display: flex; gap: 12px; }
.chatcard .kv span { flex: 0 0 5.5em; color: var(--soil); font-size: var(--text-s); }
.chatcard .kv b { font-weight: 400; min-width: 0; overflow-wrap: anywhere; }
.chatcard form { display: flex; flex-direction: column; margin: 0; }
.chatcard .linkbtn { min-height: var(--tap-s); color: var(--warn); }
#say input { flex: 1; width: auto; min-width: 0; }
.richmenu { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.richmenu form { margin: 0; display: flex; }
.richmenu button { width: 100%; min-height: 76px; border: 0; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.richmenu button b { font-family: var(--serif); font-size: 1.25rem; }
.richmenu button small { color: var(--soil); }
.richmenu form:first-child button { background: var(--accent); color: var(--accent-ink); }
.richmenu form:first-child button small { color: var(--accent-ink); }
.richmenu .menulink { min-height: 76px; background: var(--sage); color: var(--ink); text-decoration: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.richmenu .menulink b { font-family: var(--serif); font-size: 1.25rem; }
.richmenu .menulink small { color: var(--soil); }

/* 多訂幾次：一組單選，不要瀏覽器預設的框線 */
fieldset.stack { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.stack > legend { padding: 0; margin-bottom: 4px; font-weight: 700; }

/* ── 首頁上半：照片、取貨資訊、怎麼訂 ── */
.hero { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.hero img { display: block; width: 100%; max-width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; background: var(--sage); }
.hero figcaption { display: flex; flex-direction: column; gap: 4px; }
.kicker { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.12em; color: var(--leaf); }
.lede { font-family: var(--serif); font-size: 1.25rem; line-height: 1.45; text-wrap: balance; }
@media (max-width: 32rem) {
  /* 手機上照片滿版，字照樣留邊 */
  .main > .hero:first-child { margin-top: -22px; }
  .hero img { width: calc(100% + 2 * var(--gutter)); max-width: none; margin-left: calc(-1 * var(--gutter)); }
}
.facts { margin: 0; border-top: 2px solid var(--ink); }
.facts > div { display: grid; grid-template-columns: 4.5em minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--soil); font-size: var(--text-s); padding-top: 1px; }
.facts dd { margin: 0; }
.facts .nb { display: block; }
.howto { list-style: none; counter-reset: step; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.howto li { counter-increment: step; display: grid; grid-template-columns: 2.25rem minmax(0, 1fr); column-gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.howto li::before { content: counter(step); grid-row: span 2; font-family: var(--serif); font-size: 1.5rem; line-height: 1.2; color: var(--accent); }
.howto b { font-weight: 600; }
.howto span { font-size: var(--text-s); color: var(--soil); }
.facts .nw { white-space: nowrap; }

/* 只能看的人：後台頁面裡的按鈕都藏起來（印單據除外）。藏起來只是好看，真正擋的是伺服器（web/roles.ts）。 */
body.viewonly main form[method="post"]:not([action="/admin/docs/print"]) { display: none; }
tr.muted td { color: var(--soil); }
