/* 外送 App 風格：白底黑字、粗體標題、灰色膠囊分類、菜色列右側方圖＋疊加按鈕、底部黑色長鈕 */
:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --field: #f3f3f3;
  --chip: #eeeeee;
  --text: #000000;
  --muted: #5e5e5e;
  --line: #e8e8e8;
  --accent: #000000;      /* 主要按鈕 */
  --on-accent: #ffffff;
  --accent-soft: #f6f6f6;
  --green: #06c167;       /* 點綴：已點、提示通過 */
  --warn-soft: #fff4e5;
  --ok: #05944f;
  --ok-soft: #e6f7ee;
  --spicy: #d93a1f;
  --spicy-soft: #fdeae6;
  --thumb-s: 70%;
  --thumb-l: 90%;
  --float: #ffffff;       /* 圖上那顆＋的底 */
  --shadow: 0 2px 8px rgba(0, 0, 0, .16);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --panel: #141414; --field: #262626; --chip: #262626; --text: #ffffff; --muted: #afafaf;
    --line: #2b2b2b; --accent: #ffffff; --on-accent: #000000; --accent-soft: #1c1c1c;
    --green: #06c167; --warn-soft: #3a2c14; --ok: #3ad08a; --ok-soft: #10301f; --spicy: #ff7a5c; --spicy-soft: #3a1a12;
    --thumb-s: 30%; --thumb-l: 22%; --float: #262626; --shadow: 0 2px 8px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --panel: #141414; --field: #262626; --chip: #262626; --text: #ffffff; --muted: #afafaf;
  --line: #2b2b2b; --accent: #ffffff; --on-accent: #000000; --accent-soft: #1c1c1c;
  --green: #06c167; --warn-soft: #3a2c14; --ok: #3ad08a; --ok-soft: #10301f; --spicy: #ff7a5c; --spicy-soft: #3a1a12;
  --thumb-s: 30%; --thumb-l: 22%; --float: #262626; --shadow: 0 2px 8px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
button {
  font: inherit;
  font-weight: 600;
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}
button.ghost { background: var(--chip); color: var(--text); }
button:active { transform: scale(.97); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
input, select, textarea {
  font: inherit;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  width: 100%;
}

/* 頂欄 */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding-block: 14px 6px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  max-width: 1300px; margin: 0 auto;
}
.ico { width: 24px; height: 24px; flex: 0 0 auto; }
.party-chip {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 6px 0; background: none; color: var(--text); border-radius: 0;
  font-size: 1.15rem; font-weight: 600;
}
.party-chip #partyText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.party-chip .chev { width: 18px; height: 18px; }
.topbar nav { display: flex; gap: 4px; flex-shrink: 0; }
.icon-btn { position: relative; background: none; color: var(--text); width: 44px; height: 44px; padding: 0; display: grid; place-items: center; }
.num-badge {
  position: absolute; top: -2px; right: -2px; min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 999px; background: var(--green); color: #fff; font-size: .78rem; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  padding-block: 4px 24px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  max-width: 1300px;
  margin: 0 auto;
}

/* 分類大圖示、篩選膠囊、精選推薦 */
.menu { min-width: 0; }
.cat-icons {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding-block: 10px 6px; border-bottom: 1px solid var(--line);
  margin-left: calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  margin-right: calc(-1 * max(16px, env(safe-area-inset-right, 0px)));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.cat-icons::-webkit-scrollbar, .filters::-webkit-scrollbar, .carousel::-webkit-scrollbar { display: none; }
.cat-icons button {
  flex: 0 0 auto; width: 72px; padding: 4px 0 8px; border-radius: 0;
  background: none; color: var(--text); font-weight: 500; font-size: .9rem;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border-bottom: 3px solid transparent;
}
.cat-icons .ic { font-size: 2.3rem; line-height: 1.1; }
.cat-icons button.active { font-weight: 700; border-bottom-color: var(--text); }
.filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-block: 14px 4px; }
.filters button { flex: 0 0 auto; background: var(--chip); color: var(--text); padding: 10px 18px; font-weight: 500; }
.filters button.active { background: var(--accent); color: var(--on-accent); }
.sec-title { margin: 20px 0 12px; font-size: 1.45rem; font-weight: 800; letter-spacing: -.3px; }
.carousel { display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x mandatory; padding-bottom: 4px; }
.feat-card {
  flex: 0 0 72%; max-width: 280px; scroll-snap-align: start;
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--panel);
}
.feat-img {
  position: relative; height: 130px; display: grid; place-items: center;
  background: hsl(var(--h, 30) var(--thumb-s) var(--thumb-l));
}
.feat-img > span { font-size: 4rem; }
.feat-body { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 2px; }
.feat-body .name { font-weight: 700; font-size: 1.05rem; }
.feat-tag { color: var(--ok); font-size: .9rem; }
.feat-body .price { font-size: .95rem; }

/* 菜色列 */
.dish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); column-gap: 24px; }
.cat-head { grid-column: 1 / -1; margin: 22px 0 4px; font-size: 1.35rem; font-weight: 800; }
.dish {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.dish-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; padding-top: 2px; }
.dish .name { font-weight: 700; font-size: 1.05rem; }
.dish .price { font-size: .95rem; }
.dish .sub { color: var(--muted); font-size: .85rem; }
.dish.selected .name::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 6px; vertical-align: middle; }
.tag { font-size: .72rem; font-weight: 600; padding: 2px 7px; border-radius: 4px; margin-left: 6px; vertical-align: 2px; }
.tag.spicy { background: var(--spicy-soft); color: var(--spicy); }
.tag.veg { background: var(--ok-soft); color: var(--ok); }

.thumb {
  position: relative; flex: 0 0 auto;
  width: 104px; height: 104px; border-radius: 10px;
  background: hsl(var(--h, 30) var(--thumb-s) var(--thumb-l));
  display: grid; place-items: center;
}
.thumb > span { font-size: 3rem; }
.qty-ctl {
  position: absolute; right: 6px; bottom: 6px;
  display: flex; align-items: center; gap: 2px;
  background: var(--float); border-radius: 999px; box-shadow: var(--shadow);
}
.qty-ctl button { background: none; color: var(--text); width: 34px; height: 34px; padding: 0; font-size: 1.3rem; line-height: 1; }
.qty-ctl span { min-width: 1.2em; text-align: center; font-weight: 700; }

/* 份數加減（點菜單裡） */
.stepper { display: flex; align-items: center; gap: 4px; background: var(--chip); border-radius: 999px; }
.stepper button { background: none; color: var(--text); width: 32px; height: 32px; padding: 0; font-size: 1.15rem; }
.stepper span { min-width: 1.2em; text-align: center; font-weight: 700; }

/* 點菜單 */
.order {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  position: sticky; top: calc(16px + env(safe-area-inset-top, 0px));
  align-self: start;
  max-height: calc(100vh - 32px);
  overflow: auto;
  min-width: 0;
}
.order-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.order h2 { margin: 0; font-size: 1.4rem; font-weight: 800; }
.info { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.info label, .note { font-size: .8rem; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.hint { font-size: .85rem; padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); margin: 14px 0; }
.hint.ok { background: var(--ok-soft); }
.order-list { list-style: none; padding: 0; margin: 0 0 12px; }
.order-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.order-list li > div:first-child { font-weight: 600; }
.order-list .cat { font-size: .78rem; font-weight: 400; color: var(--muted); }
.order-list .empty { color: var(--muted); display: block; text-align: center; border: none; padding: 24px 0; }
.totals { margin: 14px 0; display: grid; gap: 6px; }
.totals div { display: flex; justify-content: space-between; }
.totals b { font-size: 1.1rem; }
.muted { color: var(--muted); font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* 對話框 */
dialog { border: none; border-radius: 16px; padding: 20px; width: min(680px, 94vw); background: var(--panel); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
dialog h2 { margin-top: 0; font-weight: 800; }
.dish-form { display: grid; grid-template-columns: 2fr 1.2fr 1fr auto auto auto; gap: 8px; align-items: center; }
.dish-form .inline { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.dish-form .inline input { width: auto; }
.manage-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .9rem; }
.manage-table th, .manage-table td { padding: 8px 5px; border-bottom: 1px solid var(--line); text-align: left; }
.history-list { list-style: none; padding: 0; max-height: 60vh; overflow: auto; }
.history-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.history-list .btns { display: flex; gap: 6px; }

/* 提示訊息 */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--accent); color: var(--on-accent); padding: 10px 18px; border-radius: 999px; z-index: 40; font-weight: 600;
}

/* 列印 */
.print-area { display: none; }
@media print {
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block; padding: 20px; color: #000; }
  .print-area table { width: 100%; border-collapse: collapse; }
  .print-area th, .print-area td { border: 1px solid #999; padding: 6px; }
}

.sheet-only, .sheet-backdrop, .sheet-handle { display: none; }

/* 底部懸浮列 */
body { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; align-items: center; gap: 12px;
  padding-top: 10px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  pointer-events: none;
}
.bottom-nav > * { pointer-events: auto; }
.float-btn {
  position: relative; flex: 0 0 auto; width: 58px; height: 58px; padding: 0; display: grid; place-items: center;
  background: var(--float); color: var(--text); box-shadow: var(--shadow);
}
.search-pill {
  flex: 1; min-width: 0; height: 58px; display: flex; align-items: center; gap: 10px; padding: 0 18px;
  border-radius: 999px; background: var(--float); box-shadow: var(--shadow); color: var(--text);
}
.search-pill input { background: none; padding: 0; font-size: 1.1rem; height: 100%; border-radius: 0; }
.search-pill input:focus-visible { outline: none; }
.search-pill:focus-within { outline: 2px solid var(--text); }
.to-top:not([hidden]) {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 26;
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  background: var(--float); color: var(--text); box-shadow: var(--shadow); padding: 9px 18px;
}
@media (min-width: 821px) {
  .bottom-nav { max-width: 640px; margin: 0 auto; }
  .float-btn.cart { display: none; }
}

/* ===== 手機：底部黑色長鈕、點菜單從下方拉起 ===== */
@media (max-width: 820px) {
  input, select, textarea { font-size: 16px; } /* iOS 小於 16px 會自動放大畫面 */
  .desk-only { display: none; }
  .topbar h1 { font-size: 1.4rem; }
  .topbar nav button { padding: 7px 12px; font-size: .85rem; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .dish-grid { grid-template-columns: minmax(0, 1fr); }
  .thumb { width: 96px; height: 96px; }

  .sheet-only { display: inline-block; }
  .sheet-handle { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: -6px auto 12px; }
  .sheet-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 29; }
  .order {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 30;
    max-height: 90vh; border: none; border-radius: 18px 18px 0 0;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    transform: translateY(105%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  }
  .order.open { transform: translateY(0); }
  .order .actions button { flex: 1; padding: 13px; }
  .dish-form { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { .order { transition: none; } }

/* ===== 會客菜小幫手 ===== */
/* 會客菜／合作社／寄錢：仿外送 App 頂端那排大分頁 */
.mode-wrap {
  border-bottom: 1px solid var(--line);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.mode-tabs { display: flex; gap: 22px; max-width: 1300px; margin: 0 auto; }
.mode-tabs button {
  background: none; color: var(--muted); border-radius: 0; padding: 8px 2px 10px;
  font-size: 1.15rem; display: flex; align-items: center; gap: 6px;
  border-bottom: 3px solid transparent;
}
.mode-tabs .ic { font-size: 1.5rem; }
.mode-tabs button.active { color: var(--text); border-bottom-color: var(--text); }

.status-card {
  margin: 14px 0 4px; padding: 16px 18px; border-radius: 14px;
  background: var(--accent); color: var(--on-accent);
}
.st-label { font-size: .9rem; opacity: .75; font-weight: 600; }
.st-big { font-size: 1.9rem; font-weight: 800; letter-spacing: -.5px; margin: 2px 0 6px; }
.st-sub { font-size: .88rem; opacity: .8; line-height: 1.5; }

.notice {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px; line-height: 1.55; font-size: .92rem;
  background: var(--warn-soft);
}
button.link { background: none; color: var(--text); padding: 0; margin-left: 6px; border-radius: 0; text-decoration: underline; font-weight: 600; }
.warn { margin: 6px 0 0; color: var(--spicy); font-size: .88rem; font-weight: 600; }

.rules { margin: 22px 0 8px; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); }
.rules summary { font-weight: 700; cursor: pointer; }
.rules ul { margin: 10px 0 0; padding-left: 20px; line-height: 1.7; font-size: .92rem; }

.form-card { display: grid; gap: 10px; margin-top: 8px; }
.form-card label, .form-grid label { font-size: .8rem; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.form-card button[type="submit"] { padding: 13px; font-size: 1rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid label.inline, .weekdays label { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: .95rem; }
.form-grid input[type="checkbox"] { width: auto; }
.weekdays { display: flex; flex-wrap: wrap; gap: 6px 14px; }
dialog h3 { margin: 18px 0 8px; font-size: 1.05rem; }

.rec-list { list-style: none; padding: 0; margin: 0; }
.rec-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rec-main { min-width: 0; line-height: 1.5; }
button.small { padding: 6px 12px; font-size: .85rem; flex-shrink: 0; }

.weight { margin-bottom: 8px; }
.weight-row { display: flex; justify-content: space-between; margin-bottom: 6px; }
.weight-row b.bad { color: var(--spicy); }
.weight-bar { height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.weight-bar > div { height: 100%; width: 0; background: var(--green); transition: width .2s; }
.weight-bar > div.bad { background: var(--spicy); }
.order label.note { margin-top: 10px; }
button:disabled { opacity: .35; cursor: not-allowed; }

/* 只有「會客菜」分頁有右側（手機為抽屜）的這次寄菜 */
body:not([data-tab="food"]) .order { display: none; }
@media (min-width: 821px) {
  body:not([data-tab="food"]) .layout { grid-template-columns: minmax(0, 720px); justify-content: center; }
}
