/* ==========================================================
   郭媽媽上菜 - 全站共用樣式
   手機優先，往上用 min-width 加寬
   ========================================================== */

/* ---------- 色彩與尺寸 ---------- */
:root {
  /* 中性色：暖米底、深棕墨字
     第 48 輪：底色小幅加深（原 #faf6ef 在色偏的螢幕上幾乎是白的），surface-2 與線條跟著微調保持層次 */
  --bg: #f6f0e6;
  --surface: #ffffff;
  --surface-2: #efe7da;
  --line: #e5dbcc;
  --line-strong: #d5c6b1;

  --ink: #2b2520;
  --ink-2: #5c5248;
  --ink-3: #776b5e;
  --ink-4: #a39787;   /* 最淡：還沒排菜這類「沒有內容」的狀態 */

  /* 主色：咖啡色（全站按鈕、選取狀態、身分標記、日曆等統一用這組） */
  --accent: #6f4a2f;
  --accent-hover: #583a24;
  --accent-soft: #ece1d2;
  --accent-soft-hover: #e1d2bf;
  --accent-ink: #5a3b25;

  --focus: #1f6fb2;

  /* 週末紅（日曆用） */
  --weekend: #c4392b;
  --weekend-ink: #b8301f;
  --weekend-line: #e2b2a8;

  /* 分類色：底色 / 文字色
     咖啡色是主色，所以肉類改用酒紅、紅、橘來和咖啡色區隔 */
  --cat-pork-bg: #f4d9e0;    --cat-pork-ink: #8e1f3d;   /* 酒紅 */
  --cat-beef-bg: #fadad6;    --cat-beef-ink: #b02a22;   /* 紅 */
  --cat-chicken-bg: #fde1c9; --cat-chicken-ink: #a84c08; /* 橘 */
  --cat-sea-bg: #d9e7f7;     --cat-sea-ink: #22579a;    /* 藍 */
  --cat-veg-bg: #e2efd9;     --cat-veg-ink: #3a6b2a;    /* 綠 */
  --cat-egg-bg: #fbefb8;     --cat-egg-ink: #735a00;    /* 黃 */
  --cat-soup-bg: #d5ecea;    --cat-soup-ink: #17665f;   /* 青綠 */
  --cat-other-bg: #ebe2f4;   --cat-other-ink: #64408a;  /* 紫 */

  /* 標籤灰 */
  --tag-bg: #ebe9e6;
  --tag-ink: #55504a;

  --radius-lg: 14px;   /* 卡片 */
  --radius: 10px;      /* 按鈕、輸入框 */
  --radius-sm: 8px;    /* 小元件 */
  --shadow: none;      /* 第 50 輪：卡片只留框線，不加陰影 */

  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;

  --tabbar-h: 64px;
  --gutter: 16px;
}

/* ---------- 基本 ---------- */
*, *::before, *::after { box-sizing: border-box; }

/* 圖示（Font Awesome Pro SVG，原檔在 icons/，內嵌使用以便跟著文字變色） */
.icon {
  display: inline-block;
  flex: none;
  width: 1em;
  height: 1em;
  vertical-align: -.125em;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.125rem;   /* 18px */
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-top: env(safe-area-inset-top);   /* 加入主畫面後避開 iPhone 狀態列 */
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

a { color: inherit; text-decoration: none; }

button { font: inherit; color: inherit; }

h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

[hidden] { display: none !important; }

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 20px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 1.0625rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--soft {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-ink);
}

.btn--block { width: 100%; }

.btn:disabled { opacity: .4; cursor: default; }

/* ---------- 頁首（只在桌機顯示） ---------- */
.site-header {
  display: none;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
}
.site-header__name {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: .04em;
}
.site-header__right {
  display: flex;
  align-items: center;
  gap: 20px;
}
/* 站標：郭媽媽頭像，跟在站名前面（原檔 source/kuomama_logo_b.svg） */
.site-logo { display: block; height: 32px; width: auto; flex-shrink: 0; }
.site-header__name .site-logo { height: 44px; }

.site-nav { display: flex; gap: 4px; }
.site-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-weight: 600;
}
.site-nav__link.is-current { color: var(--accent-ink); background: var(--accent-soft); }

/* ---------- 底部分頁列（手機） ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar__link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--tabbar-h);
  font-size: 1rem;
  line-height: 1.3;
  font-weight: 600;
  color: var(--ink-3);
  position: relative;
}
.tabbar__link .icon { font-size: 1.375rem; }
.tabbar__link.is-current { color: var(--accent-ink); }
.tabbar__link.is-current::before {
  content: "";
  position: absolute;
  top: -1px; left: 0; right: 0;   /* 蓋住上框線，佔滿整個按鈕寬 */
  height: 3px;
  background: var(--accent);
}

/* ---------- 頁尾 ---------- */
.site-footer {
  padding: 40px 0 32px;
  text-align: center;
}
.site-footer__link {
  display: inline-block;
  padding: 10px 16px;
  color: var(--ink-3);
  font-size: 1rem;
  text-decoration: underline;
  text-underline-offset: 4px;
  background: none;
  border: 0;
  cursor: pointer;
}

/* ---------- 身分標記（媽媽登入時，純文字狀態，不是按鈕） ---------- */
.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-ink);
  font-size: .9375rem;
  font-weight: 700;
}
.role-chip::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- 手機版站名列 ---------- */
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  margin-bottom: 10px;
}
.brand-row__name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--accent-ink);
}

/* ---------- 今天：餐卡 ---------- */
.today-grid {
  display: grid;
  gap: 16px;
}

.meal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px 18px 20px;
  display: flex;
  flex-direction: column;
}
.meal__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.meal__name { font-size: 1.25rem; font-weight: 700; }
.meal__count { font-size: 1rem; color: var(--ink-3); }

.meal__action { margin-top: 16px; }

/* 菜色列（含縮圖） */
.dish-list > li + li { border-top: 1px solid var(--line); }

.dish {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  min-height: 64px;
}

.dish__thumb {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  font-weight: 700;
  overflow: hidden;
}
.dish__thumb img { width: 100%; height: 100%; object-fit: cover; }

.dish__name {
  flex: 1;
  font-size: 1.1875rem;
  font-weight: 600;
  line-height: 1.4;
}

/* 分類標籤 */
.cat-chip {
  flex: none;
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1.6;
}

/* 分類配色 */
[data-cat="pork"]    { background: var(--cat-pork-bg);    color: var(--cat-pork-ink); }
[data-cat="chicken"] { background: var(--cat-chicken-bg); color: var(--cat-chicken-ink); }
[data-cat="beef"]    { background: var(--cat-beef-bg);    color: var(--cat-beef-ink); }
[data-cat="sea"]     { background: var(--cat-sea-bg);     color: var(--cat-sea-ink); }
[data-cat="veg"]     { background: var(--cat-veg-bg);     color: var(--cat-veg-ink); }
[data-cat="egg"]     { background: var(--cat-egg-bg);     color: var(--cat-egg-ink); }
[data-cat="soup"]    { background: var(--cat-soup-bg);    color: var(--cat-soup-ink); }
[data-cat="other"]   { background: var(--cat-other-bg);   color: var(--cat-other-ink); }

/* 標籤 */
.tag-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-ink);
  font-size: .9375rem;
  font-weight: 600;
}

/* 不開伙 / 還沒排 */
.meal-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 120px;
  border-radius: var(--radius);
  text-align: center;
}
.meal-state__title { font-size: 1.1875rem; font-weight: 700; }
/* 不開伙：實心底＋禁止圖示，是「確定的狀態」 */
.meal-state--off { background: var(--surface-2); color: var(--ink-2); gap: 6px; }
.meal-state--off .icon { font-size: 1.75rem; }
/* 還沒排菜：虛線＋淡字，是「還沒有內容」 */
.meal-state--empty {
  border: 2px dashed var(--line);
  color: var(--ink-4);
}
.meal-state--empty .meal-state__title { font-weight: 600; }


/* ==========================================================
   M1 排這一餐
   ========================================================== */
.page-plan { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

/* 頂部固定列 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
}
.topbar__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding-right: 12px;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--accent-ink);
}
.topbar__back .icon { font-size: 1rem; }
/* 子頁右側：身分標記（＋各頁自己的東西） */
.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.topbar__right .role-chip { font-size: .875rem; white-space: nowrap; }
/* M1：身分標記和「已自動儲存」上下疊，避免擠在一行 */
.topbar__right--stack {
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  line-height: 1.35;
}
.topbar__right--stack .save-state { font-size: .8125rem; }
.save-state {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--ink-3);
}
.save-state.is-saving { color: var(--accent-ink); }
.save-state.is-error { color: var(--weekend-ink); }

/* 復原（第 70 輪）：在頂部狀態區，取代身分標記和儲存狀態；不浮在畫面上；第 73 輪起 10 秒後淡出 */
.topbar__right.has-undo > :not(.undo-bar) { display: none; }
/* 第 72 輪：看起來是「狀態文字」不是按鈕（第 71 輪的咖啡底膠囊太像主要按鈕、一直醒目會吵）
   - 平常：和「已自動儲存」同一類的文字＋底線文字按鈕〔復原〕
   - 剛出現時：像螢光筆畫過一樣亮黃底一下，約 2.5 秒淡掉，吸引視線但不會一直搶眼 */
.undo-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding-left: 10px;
  border-radius: var(--radius-sm);
  animation: undo-flash 2.6s ease-out;
  transition: opacity .3s ease;
}
.undo-bar[hidden] { display: none; }
.undo-bar.is-leaving { opacity: 0; }   /* 時間到了淡出，不要突然消失 */
.undo-bar__text {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;   /* 菜名太長時截斷，〔復原〕一定看得到 */
  font-size: .9375rem;
  font-weight: 600;
  color: var(--ink-2);
}
.undo-bar .undo-bar__btn {
  flex: none;
  min-height: 44px;          /* 字小但點得到的範圍夠大 */
  padding: 0 10px;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font-size: 1rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}
.undo-bar .undo-bar__btn:active { background: rgba(111, 74, 47, .1); }
@media (hover: hover) {
  .undo-bar .undo-bar__btn:hover { background: rgba(111, 74, 47, .1); }
}
@keyframes undo-flash {
  0%   { opacity: 0; background: #f8d97a; }
  8%   { opacity: 1; background: #f8d97a; }
  35%  { background: #f8d97a; }
  100% { background: rgba(248, 217, 122, 0); }
}
@media (prefers-reduced-motion: reduce) {
  /* 不做動畫時，留一圈淡黃底一直標出來 */
  .undo-bar { animation: none; background: #fcefc4; }
}

.plan__title {
  padding: 18px 0 14px;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.25;
}
.plan__title small {
  margin-left: 10px;
  font-size: 1.25rem;
  color: var(--accent-ink);
}
.plan__locked {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink-2);
  font-weight: 600;
}

.plan__layout { display: grid; gap: 28px; }
.plan__side { display: grid; gap: 16px; align-content: start; }

/* 要煮 / 不開伙 */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  gap: 4px;
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface-2);
}
.seg__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
}
.seg__btn[aria-checked="true"] {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(70, 45, 20, .2);
}

.seg__btn .icon { font-size: 1.25rem; }

/* 不開伙說明：純文字狀態，不用底色塊，避免看起來像按鈕 */
.off-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 8px;
  text-align: center;
}
.off-note__icon {
  display: inline-flex;
  font-size: 2.25rem;
  color: var(--ink-3);
}
.off-note__title { font-size: 1.25rem; font-weight: 700; }
.off-note__text { margin-top: 2px; font-size: 1rem; color: var(--ink-2); }

/* 已選的菜 */
.picked {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px 16px 8px;
}
.picked__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}
.picked__title { font-size: 1.25rem; font-weight: 700; }
.picked__count { font-size: 1rem; color: var(--ink-3); }
.picked__empty {
  padding: 20px 0 24px;
  text-align: center;
  color: var(--ink-3);
}
.picked-list > li + li { border-top: 1px solid var(--line); }
.picked-list .dish { min-height: 68px; }
.picked-list .dish__name { min-width: 0; }

.btn--line {
  flex: none;
  min-height: 44px;
  padding: 0 14px;
  font-size: 1rem;
}

.plan__done { display: none; }

/* 選菜 */

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: text;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search__icon { display: inline-flex; font-size: 1.125rem; color: var(--ink-3); }
.search__input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 1.125rem;    /* 16px 以上，iPhone 點擊才不會自動放大 */
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
.search__input:focus { outline: none; }
.search__input::placeholder { color: var(--ink-3); }
/* 搜尋框有字時右邊的「清除」：用字不用小 ✕，媽媽看得懂也點得到 */
.search__clear {
  flex: none;
  min-height: 40px;
  margin-right: -8px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.search__clear[hidden] { display: none; }

.filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 6px;
}
.filter__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}
.filter__btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.filter__num {
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: .875rem;
  line-height: 1.6;
  text-align: center;
}
.filter__btn[aria-pressed="true"] .filter__num { background: rgba(255, 255, 255, .25); color: #fff; }

.pick-list > li + li { border-top: 1px solid var(--line); }
.pick {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 10px 0;
}
.pick__body { flex: 1; min-width: 0; }
.pick__name {
  display: block;
  font-size: 1.1875rem;
  font-weight: 600;
  line-height: 1.4;
}
.pick__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 2px;
  font-size: .9375rem;
  color: var(--ink-3);
}
.pick__meta .cat-chip { font-size: .8125rem; padding: 0 8px; }
.pick__flag {
  padding: 0 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
}
.pick__same { color: var(--accent-ink); font-weight: 600; }

.pick__btn {
  flex: none;
  width: 96px;
  min-height: 48px;
  padding: 0;
}
.pick__btn .icon { font-size: .9375rem; }

/* 已加入：只是狀態提示，不是按鈕 */
.pick__added {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 96px;
  min-height: 48px;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--accent-ink);
}
.pick__added .icon { font-size: .9375rem; }

.pick-empty { padding: 32px 0; text-align: center; color: var(--ink-3); }

/* 不開伙或已過日子時，選菜區隱藏 */
.plan.is-off .picked,
.plan.is-off .addmore,
.plan.is-locked .seg,
.plan.is-locked .addmore { display: none; }

/* 還可以加：這一餐還沒有的類別各一顆捷徑（不是待辦，所以用柔和的按鈕，不做成空位） */
.addmore__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.addmore__btns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
/* 自動排餐：外框按鈕（白底咖啡框咖啡字），和主要按鈕、下面米色的捷徑都分得出來 */
.btn--outline {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.autoplan { min-height: 52px; margin-bottom: 20px; font-size: 1.0625rem; font-weight: 700; }
.autoplan[hidden] { display: none; }

/* 已選的菜：分類標籤在菜名下面，右邊放「鎖定」「移除」 */
.dish__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.picked-list .dish { gap: 10px; }
.picked-list .btn--line { padding: 0 12px; }
/* 已鎖定：柔和咖啡底，一眼看得出這道不會被換掉 */
.lock-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.addmore__btn { position: relative; min-height: 52px; font-size: 1.0625rem; }
.addmore__btn .icon { font-size: .875rem; }
/* 這一類已經排了幾道：按鈕右上角的小數字 */
.addmore__num {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: .875rem;
  font-weight: 700;
  line-height: 24px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* 篩選：膠囊形、固定 3 欄等寬（M1 選菜面板、P3 圖鑑共用） */
.filter--grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.filter--grid .filter__btn { justify-content: center; width: 100%; padding: 0 6px; }

/* 開關（例：只看好久沒煮）：整行都可以點，至少 48px 高 */
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin-top: 8px;
  cursor: pointer;
  font-size: 1.0625rem;
  font-weight: 600;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__ui {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background-color .2s;
}
.switch__ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(40, 25, 10, .25);
  transition: transform .2s;
}
.switch input:checked + .switch__ui { background: var(--accent); }
.switch input:checked + .switch__ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__ui { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch .filter__num { margin-left: auto; }

/* 底部列（手機） */
.bottombar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottombar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 76px;
}
.bottombar__count { font-size: 1.0625rem; font-weight: 700; }
.bottombar__done { min-width: 160px; }

/* 操作提示條 */
.toast {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 520px;
  margin: 0 auto;
  padding: 8px 8px 8px 18px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  box-shadow: 0 8px 24px rgba(40, 25, 10, .25);
  font-size: 1.0625rem;
  font-weight: 600;
}

/* ==========================================================
   M2 加一道新菜（食材選擇元件之後 A2 共用）
   ========================================================== */
.page-form { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

.add__form { display: grid; gap: 28px; max-width: 720px; }
.add__submit { display: none; }   /* 手機用底部列的按鈕；桌機才顯示這顆 */

.field__label {
  display: block;
  margin-bottom: 10px;
  font-size: 1.25rem;
  font-weight: 700;
}
.field__label small {
  margin-left: 8px;
  font-size: .9375rem;
  font-weight: 600;
  color: var(--ink-3);
}

.input {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.is-error { border-color: var(--weekend); box-shadow: 0 0 0 3px #f8dedb; }

/* 重複提示 */
.dup {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 1rem;
  color: var(--ink-2);
}
.dup a { font-weight: 700; color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.dup--block { background: #fbe6e3; color: var(--weekend-ink); font-weight: 600; }
.dup--block a { color: var(--weekend-ink); }

/* 分類單選 */
.cat-pick {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.cat-pick__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 52px;
  padding: 0 4px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
}
.cat-pick__btn .icon { display: none; font-size: .8125rem; }
/* 選中：換成該分類的顏色 */
.cat-pick__btn[aria-checked="true"] { border-width: 2px; border-color: currentColor; }
.cat-pick__btn[aria-checked="true"] .icon { display: inline-block; }
.cat-pick__btn[aria-checked="false"] { background: var(--surface); color: var(--ink-2); }

/* 食材：已加入的一樣一樣列出來（外觀同 P2 的食材：小圓角、字重 500），右邊 ✕ 拿掉 */
.ing-added { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ing-added__empty { font-size: 1.0625rem; color: var(--ink-4); }
.ing-chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-left: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  font-size: 1.0625rem;
  font-weight: 500;
}
.ing-chip__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 42px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}
.ing-chip__remove .icon { font-size: .875rem; }
/* 很長、沒有空白的名字（英文、數字）也會換行，不撐破版面 */
.dish__name, .pick__name, .card__name, .ing-chip, .ing-toggle { overflow-wrap: anywhere; }
/* 兩種加法各一顆，一樣大 */
.ing-add__btns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ing-add__btn { min-height: 52px; font-size: 1.0625rem; }
.ing-add__btn .icon { font-size: .875rem; }

/* 下方滑出的面板（寫做法、加照片、選食材…）
   - 第 52 輪：取消 / 儲存 / 完成移到頂部標題列（比照 iPhone 備忘錄、行事曆），手機鍵盤彈出時不會被蓋住
   - 面板高度跟著「鍵盤留下的可見高度」走（JS 寫入 --vv-h / --vv-top），輸入時一定看得到自己打的字
   - 桌機改成置中對話框（見桌機段） */
.sheet {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--vv-h, 100%);
  transform: translateY(var(--vv-top, 0px));
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: rgba(43, 37, 32, .45);
  animation: sheet-fade .3s ease-out;
}
.sheet__panel {
  display: flex;
  flex-direction: column;
  height: calc(100% - 12px - env(safe-area-inset-top));
  border-radius: 14px 14px 0 0;
  background: var(--bg);
  box-shadow: 0 -8px 30px rgba(40, 25, 10, .2);
  animation: sheet-up .32s cubic-bezier(.2, .8, .2, 1);
}
/* 關閉時往下滑出 */
.sheet.is-closing { animation: sheet-fade-out .26s ease-in forwards; }
.sheet.is-closing .sheet__panel { animation: sheet-down .26s ease-in forwards; }

@keyframes sheet-fade { from { background: rgba(43, 37, 32, 0); } }
@keyframes sheet-fade-out { to { background: rgba(43, 37, 32, 0); } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-down { from { transform: none; } to { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet__panel, .sheet.is-closing, .sheet.is-closing .sheet__panel { animation: none; }
}

.sheet__head {
  flex: none;
  padding: 8px var(--gutter) 10px;
  border-bottom: 1px solid var(--line);
}
/* 標題列：左「取消」、中標題、右主要按鈕 */
.sheet__bar {
  display: grid;
  grid-template-columns: minmax(64px, auto) minmax(0, 1fr) minmax(64px, auto);
  align-items: center;
  gap: 8px;
  min-height: 52px;
}
.sheet__title {
  min-width: 0;
  font-size: 1.1875rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet__cancel {
  justify-self: start;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--accent-ink);
  cursor: pointer;
}
.sheet__ok {
  justify-self: end;
  min-height: 44px;
  padding: 0 18px;
  font-size: 1.0625rem;
}
.sheet__ok:disabled { opacity: .45; cursor: default; }
.sheet__summary { margin-top: 4px; font-size: 1rem; color: var(--ink-2); line-height: 1.5; text-align: center; }
.sheet__summary.is-empty { color: var(--ink-4); }

.sheet__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px var(--gutter) calc(24px + env(safe-area-inset-bottom));
}
/* 寫做法：文字框撐滿剩下的空間（鍵盤彈出時跟著變矮） */
.sheet__body--editor { display: flex; flex-direction: column; }

body.has-sheet { overflow: hidden; }

/* 從清單選：分類只是小標題（不能點），下面是勾選方塊 */
.ing-section + .ing-section { margin-top: 22px; }
.ing-section__title { font-size: 1.0625rem; font-weight: 700; color: var(--ink-2); }
.ing-search { margin-top: 10px; }
/* 搜尋不到：一句話＋一顆按鈕 */
.ing-nomatch { padding: 24px 0; text-align: center; }
.ing-nomatch__text { font-size: 1.0625rem; color: var(--ink-2); }
.ing-nomatch__btn { margin-top: 12px; min-height: 52px; padding: 0 22px; font-size: 1.0625rem; }

/* 食材勾選方塊：方形格子＋左側核取框，一看就知道是「勾選」；點一下選取、再點一下取消 */
.ing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.ing-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 10px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.ing-toggle__box {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: #fff;
}
.ing-toggle__box .icon { display: none; font-size: .75rem; }
.ing-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.ing-toggle[aria-pressed="true"] .ing-toggle__box { border-color: var(--accent); background: var(--accent); }
.ing-toggle[aria-pressed="true"] .ing-toggle__box .icon { display: inline-block; }


/* 草稿提示列 */
.draft-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding: 10px 10px 10px 16px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
  max-width: 720px;
}
.draft-bar .btn { flex: none; min-height: 44px; padding: 0 14px; font-size: 1rem; background: var(--surface); }

/* 確認對話框（只用在「離開後無法復原」的情況） */
.dialog {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(43, 37, 32, .45);
}
.dialog__panel {
  width: 100%;
  max-width: 400px;
  padding: 24px 20px 20px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(40, 25, 10, .3);
}
.dialog__title { font-size: 1.25rem; font-weight: 700; }
.dialog__text { margin-top: 6px; color: var(--ink-2); }
.dialog__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

/* 自己輸入：內容少，面板只有需要的高度，貼在鍵盤上方 */
.sheet--short .sheet__panel { height: auto; max-height: calc(100% - 12px - env(safe-area-inset-top)); }
.ing-type__cats { margin-top: 20px; }
.ing-type__cats .filter { margin-top: 0; }

/* 照片 */
.photo-pick__btn { cursor: pointer; }
.photo-preview {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
/* 預覽顯示整張照片（不裁切），和 P2 加照片的預覽一致；照片在各頁正式顯示時才會撐滿裁切 */
.photo-preview img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 420px);
  max-height: 420px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

/* 送出按鈕不能按時（必填沒填、菜名重複） */
[data-submit]:disabled { opacity: .45; cursor: default; }

/* 一般提示條（沒有復原按鈕） */
.toast--plain { padding: 14px 18px; }

/* ==========================================================
   P3 菜色圖鑑
   ========================================================== */
.page-head { padding: 14px 0 4px; }
.page-head__row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.page-head__title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: .02em;
}
.page-head__sub { margin-top: 2px; font-size: 1.0625rem; font-weight: 600; color: var(--ink-2); }
.page-head__action { flex: none; padding: 0 16px; }
.page-head__action .icon { font-size: .9375rem; }

.group { padding-top: 20px; }
.group__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.group__title small {
  margin-left: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-3);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card__photo {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
}
.card__photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 2.5rem;
  font-weight: 700;
}
.card__name {
  padding: 10px 12px 12px;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
}

/* ==========================================================
   P2 菜色詳情
   ========================================================== */
.page-sub { padding-bottom: calc(48px + env(safe-area-inset-bottom)); }

.topbar__action { min-height: 44px; padding: 0 14px; font-size: 1rem; }

.dish-page { padding-top: 16px; }
.dish-page__missing { padding: 48px 0; text-align: center; color: var(--ink-3); }
.dish-page__layout { display: grid; gap: 24px; }

/* 照片 */
.gallery__main {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-2);
}
.gallery__main img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 5rem;
  font-weight: 700;
}
.gallery__thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.gallery__thumb {
  width: 76px;
  height: 57px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
  opacity: .7;
}
.gallery__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery__thumb[aria-pressed="true"] { border-color: var(--accent); opacity: 1; }

/* 之後才開放的功能：先標出位置 */
.soon {
  display: flex;
  align-items: center;
  gap: 10px;
}
.gallery .soon { margin-top: 12px; }
.soon .btn { min-height: 44px; padding: 0 14px; font-size: 1rem; }
.soon .btn:disabled { opacity: .55; }

/* 菜名與資訊 */
.dish-info__name { font-size: 1.875rem; font-weight: 700; line-height: 1.3; }
.dish-info__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 8px;
}
.dish-info__last { font-size: 1rem; color: var(--ink-2); }

.dish-block {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.dish-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.dish-block__head .dish-block__title { margin-bottom: 0; }
.dish-block__title { font-size: 1.25rem; font-weight: 700; margin-bottom: 10px; }
.dish-block__empty { color: var(--ink-4); }

.ing-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ing-list li {
  padding: 4px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 1.0625rem;
}

.ing-note-text { margin-top: 10px; font-size: 1.0625rem; color: var(--ink-2); }

/* 寫做法面板 */
.recipe-input {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 140px;
  padding: 14px 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  font-size: 1.125rem;      /* 16px 以上，iPhone 點擊才不會自動放大 */
  line-height: 1.8;
  color: var(--ink);
  resize: vertical;
}
.recipe-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.recipe-input::placeholder { color: var(--ink-4); }
.recipe-hint { margin-top: 8px; font-size: .9375rem; color: var(--ink-3); }

/* 加照片 */
.photo-add, .photo-again { cursor: pointer; }
.photo-again { display: flex; width: 100%; margin-top: 12px; }
.photo-check {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}
/* 預覽顯示整張照片（不裁切），讓人看清楚拍到什麼 */
.photo-check img { display: block; max-width: 100%; max-height: 60vh; object-fit: contain; }
.photo-check.is-loading::after { content: "照片處理中…"; color: var(--ink-3); }

/* 只給螢幕報讀器看的文字 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.recipe {
  white-space: pre-line;   /* 保留換行 */
  font-size: 1.125rem;
  line-height: 1.9;
}

/* ---------- 滑鼠移上效果：只給有滑鼠的裝置
   手機點擊後瀏覽器會讓 :hover 卡住，造成「點擊狀態殘留」，所以不套用 ---------- */
@media (hover: hover) {
  .btn:hover { background: var(--surface-2); }
  .btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
  .btn--soft:hover { background: var(--accent-soft-hover); }
  .btn--outline:hover { background: var(--accent-soft); }
  .site-nav__link:hover { color: var(--accent-ink); background: var(--accent-soft); }
  .dish:hover .dish__name { color: var(--accent-ink); }
  .site-footer__link:hover { color: var(--accent-ink); }
  .seg__btn[aria-checked="false"]:hover { background: var(--surface); }
  .filter__btn[aria-pressed="false"]:hover { border-color: var(--accent); color: var(--accent-ink); }
  .topbar__back:hover { text-decoration: underline; }
  .gallery__thumb:hover { opacity: 1; }
  .cat-pick__btn[aria-checked="false"]:hover { border-color: var(--accent); color: var(--accent-ink); }
  .ing-toggle[aria-pressed="false"]:hover { border-color: var(--accent); color: var(--accent-ink); }
  .card { transition: border-color .15s, transform .15s; }
  .card:hover { border-color: var(--accent); transform: translateY(-2px); }
  .card:hover .card__name { color: var(--accent-ink); }
}

/* 按下當下的回饋（手指離開就消失） */
.btn--soft:active { background: var(--accent-soft-hover); }
.btn--outline:active { background: var(--accent-soft); }

/* ---------- 桌機 ---------- */
@media (min-width: 768px) {
  :root { --gutter: 32px; }
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .site-header { display: block; }

  .brand-row { display: none; }

  .today-grid { grid-template-columns: 1fr 1fr; gap: 20px; }
  .meal { padding: 22px 24px 24px; }

  /* M1：左右兩欄，左欄固定 */
  .page-plan { padding-bottom: 48px; }
  .bottombar { display: none; }
  .toast { bottom: 32px; }
  .plan__title { padding-top: 28px; font-size: 2rem; }
  .plan__layout { max-width: 560px; }
  .plan__done { display: flex; }

  /* M2：桌機用表單內的送出按鈕 */
  .page-form { padding-bottom: 48px; }
  .add__submit { display: flex; }

  /* 選食材面板：桌機改成置中對話框 */
  .sheet { align-items: center; justify-content: center; padding: 40px; }
  .sheet__panel {
    flex: none;
    width: 100%;
    max-width: 640px;
    height: auto;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(40, 25, 10, .3);
    animation: dialog-in .22s ease-out;
  }
  .sheet--short .sheet__panel { max-width: 480px; }
  .sheet.is-closing .sheet__panel { animation: dialog-out .18s ease-in forwards; }
  @keyframes dialog-in { from { transform: translateY(12px) scale(.98); opacity: 0; } }
  @keyframes dialog-out { to { transform: translateY(12px) scale(.98); opacity: 0; } }
  .sheet__head { padding-left: 28px; padding-right: 28px; }
  .ing-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sheet__body { padding-left: 28px; padding-right: 28px; }

  /* P3：一排 4 張卡片 */
  .page-head { padding-top: 32px; }
  .page-head__title { font-size: 2rem; }
  .page-head .search { max-width: 720px; }
  .page-head .filter--grid { max-width: 720px; grid-template-columns: repeat(9, minmax(0, 1fr)); }
  .card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
  .group { padding-top: 28px; }

  /* P2：左照片、右資訊 */
  .dish-page { padding-top: 32px; }
  .dish-page__layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; align-items: start; }
  .gallery { position: sticky; top: 76px; }
  .dish-info__name { font-size: 2.125rem; }
}

/* ==========================================================
   精修（第 50 輪定案併入）：降低「兒童版／AI 樣板」感
   - 圓角收斂（變數在 :root：卡片 14、按鈕 10、小元件 8；標籤 6）；篩選按鈕維持膠囊形，跟其他元件區分
   - 卡片只留淡框線、不加陰影（--shadow: none）
   - 沒照片的佔位改中性米色底＋淡色字，分類顏色只留在標籤上
   - 菜名、標籤、食材改一般字重，只有標題粗體
   - 分類顏色、「排這一餐」實心底色維持原樣（使用者決定）
   ========================================================== */

/* 沒照片的佔位 */
.dish__thumb[data-cat],
.card__empty[data-cat],
.gallery__empty[data-cat] {
  background: var(--surface-2);
  color: var(--ink-4);
  font-weight: 500;
}

/* 圓角：標籤 6、縮圖與日曆 8 */
.cat-chip,
.tag-chip,
.ing-list li,
.pick__flag { border-radius: 6px; }
.dish__thumb,
.gallery__thumb { border-radius: 8px; }
.seg { border-radius: 12px; }

/* 字重層級 */
.dish__name,
.pick__name,
.card__name,
.ing-toggle,
.ing-list li,
.cat-chip,
.tag-chip,
.filter__btn,
.page-head__sub,
.meal__count { font-weight: 500; }

/* ==========================================================
   P1 菜單頁（第 52 輪改版）：週日期列＋一次看一天
   ========================================================== */
.menu .brand-row { padding-top: 14px; margin-bottom: 4px; }

/* 週與日期列：捲動時固定在上方 */
.weekbar {
  position: sticky;
  /* 換週按鈕用絕對定位疊在上面 */
  top: 0;
  z-index: 12;
  margin: 0 calc(var(--gutter) * -1);
  padding: 6px var(--gutter) 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
/* 換週那一行：固定不滑。左右是有文字的按鈕（媽媽主要用按鈕換週），中間是日期區間 */
.weekbar__head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}
.weekbar__btn {
  min-height: 44px;
  padding: 0 12px;
  gap: 4px;
  font-size: 1rem;
}
.weekbar__btn .icon { font-size: .875rem; color: var(--accent); }
.weekbar__range {
  position: relative;          /* 換字時新舊兩段疊在一起淡入淡出 */
  height: 44px;
  overflow: hidden;
  text-align: center;
}
.weekbar__label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.weekbar__label b { font-size: 1rem; font-weight: 700; white-space: nowrap; }
.weekbar__label small { font-size: .8125rem; font-weight: 600; color: var(--ink-3); }
/* 換字淡入淡出（全站共用 .swap-label）：新舊兩段疊在一起，舊的淡出、新的淡入，
   帶一點點左右位移，方向跟切換方向一致。原則：會換字的地方都不要硬跳 */
.swap-label.is-out { animation: label-out .18s ease-in forwards; }
.swap-label.is-in  { animation: label-in .22s ease-out; }
.swap-label.is-in.from-right { --from: 10px; }
.swap-label.is-in.from-left  { --from: -10px; }
.swap-label.is-out.to-left   { --to: -10px; }
.swap-label.is-out.to-right  { --to: 10px; }
@keyframes label-in  { from { opacity: 0; transform: translateX(var(--from, 0)); } to { opacity: 1; transform: none; } }
@keyframes label-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(var(--to, 0)); } }
@media (prefers-reduced-motion: reduce) { .swap-label.is-in, .swap-label.is-out { animation: none; } }

/* 7 天日期格（不滑動，換週只靠上一週 / 下一週按鈕） */
.daystrip__days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-top: 6px;
}
.daycell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 72px;
  padding: 6px 0 8px;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}
.daycell__wd { font-size: .875rem; font-weight: 600; color: var(--ink-3); line-height: 1.3; }
.daycell__date { font-size: 1.25rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.daycell.is-weekend .daycell__wd,
.daycell.is-weekend .daycell__date { color: var(--weekend-ink); }
/* 今天：「今天」字樣＋外框 */
.daycell.is-today { border-color: var(--accent); }
.daycell.is-today .daycell__wd { color: var(--accent-ink); font-weight: 700; }
/* 正在看的那一天：實心 */
.daycell[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.daycell[aria-pressed="true"] .daycell__wd,
.daycell[aria-pressed="true"] .daycell__date { color: #fff; }

/* 中餐、晚餐兩個小點：實心＝已排、空心＝還沒排、短橫線＝不開伙 */
.daycell__dots { display: flex; gap: 4px; margin-top: 2px; height: 8px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot--planned { background: var(--accent); }
.dot--empty { box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.dot--off { height: 2px; border-radius: 1px; background: var(--ink-4); }
.daycell[aria-pressed="true"] .dot--planned { background: #fff; }
.daycell[aria-pressed="true"] .dot--empty { box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .7); }
.daycell[aria-pressed="true"] .dot--off { background: rgba(255, 255, 255, .7); }

/* 這一天 */
.dayview { padding-top: 16px; }
/* 這一天的標題列：固定不滑，換天時標題淡入淡出；「回到今天」在右側 */
.dayview__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.dayview__title {
  position: relative;          /* 新舊標題疊在一起淡入淡出 */
  flex: 1;
  min-width: 0;
  height: 44px;
  overflow: hidden;
}
.dayview__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  white-space: nowrap;
  font-size: 1.5rem;
  font-weight: 700;
}
.dayview__label small { margin-left: 8px; font-size: 1.0625rem; font-weight: 600; color: var(--ink-3); }
.dayview__today {
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  font-size: 1rem;
  animation: label-in .22s ease-out;   /* 出現時淡入，不要突然冒出來 */
}

/* 左右滑動：三格並排，跟著手指拖動 */
.dayview__viewport {
  overflow: hidden;
  touch-action: pan-y;          /* 上下捲動交給瀏覽器，左右交給程式 */
  transition: height .25s ease;
  margin: 0 calc(var(--gutter) * -1);
}
.dayview__track {
  display: flex;
  align-items: flex-start;
  width: 300%;
  transform: translateX(-33.3333%);
  will-change: transform;
}
.dayview__pane {
  width: 33.3333%;
  padding: 0 var(--gutter);
}
.dayview__pane .today-grid { margin: 0; }
@media (prefers-reduced-motion: reduce) {
  .dayview__viewport { transition: none; }
}

@media (hover: hover) {
  .daycell:not([aria-pressed="true"]):hover { background: var(--surface-2); }
}

@media (min-width: 768px) {
  .weekbar { top: 0; margin: 0; padding: 16px 0 12px; }
  .daystrip { max-width: 640px; margin: 0 auto; }
  .weekbar__head { max-width: 640px; margin: 0 auto; }
  .dayview { padding-top: 24px; }
  .dayview__label { font-size: 1.75rem; }
  .dayview__viewport { margin: 0; }
  .dayview__pane { padding: 0; }
}

/* ==========================================================
   正式版：登入、安裝頁（第 83 輪）
   ========================================================== */
.login { max-width: 440px; padding-top: 24px; padding-bottom: 48px; }
.login__title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 1.75rem;
  font-weight: 700;
}
.login__title .site-logo { height: 44px; }
.login__note { margin-bottom: 16px; color: var(--ink-2); }
.login__error {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #f8dedb;
  color: var(--weekend-ink);
  font-weight: 600;
}
.login__card {
  display: grid;
  gap: 10px;
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.login__card .btn { margin-top: 6px; }
.login__pin { font-size: 1.5rem; letter-spacing: .3em; text-align: center; }
/* 管理者登入：預設收起來，媽媽不會誤點 */
.login__admin { margin-top: 28px; }
.login__admin summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--ink-3);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.login__admin[open] summary { margin-bottom: 10px; }
/* 面板開著時的提示（例如做法沒存到）要浮在面板上面，不然看不到 */
body.has-sheet .toast { z-index: 60; }

/* 換頁中：頂端一條跑動的細線（第 86 輪）。0.15 秒內就換好的不顯示，避免一閃 */
body.is-navigating::before {
  content: "";
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  width: 40%;
  height: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  animation: nav-bar 1.1s ease-in-out .15s infinite backwards;
}
@keyframes nav-bar {
  from { transform: translateX(-100%); }
  to   { transform: translateX(250%); }
}
@media (prefers-reduced-motion: reduce) {
  body.is-navigating::before { width: 100%; animation: none; opacity: .6; }
}

/* ==========================================================
   正式版：Excel 匯入匯出（管理者，第 90 輪）
   ========================================================== */
.excel { max-width: 720px; padding-top: 20px; padding-bottom: 48px; }
.excel__title { margin-bottom: 16px; font-size: 1.75rem; font-weight: 700; }
.excel__card {
  margin-bottom: 16px;
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.excel__h { margin-bottom: 6px; font-size: 1.25rem; font-weight: 700; }
.excel__sub { margin: 18px 0 6px; font-size: 1.0625rem; font-weight: 700; }
.excel__sub.is-error { color: var(--weekend-ink); }
.excel__muted { margin-bottom: 12px; color: var(--ink-3); }
.excel__notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}
.excel__file { display: block; width: 100%; margin-bottom: 12px; font-size: 1rem; }
.excel__sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 8px 0 4px; }
.excel__sum li {
  padding: 10px 8px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: .9375rem;
  text-align: center;
}
.excel__sum b { display: block; font-size: 1.375rem; color: var(--ink); }
.excel__sum li.is-error { background: #f8dedb; color: var(--weekend-ink); }
.excel__sum li.is-error b { color: var(--weekend-ink); }
.excel__list { display: grid; gap: 6px; padding-left: 1.2em; list-style: disc; overflow-wrap: anywhere; }
.excel__change { display: block; color: var(--ink-2); font-size: .9375rem; }
.excel__actions { display: grid; gap: 10px; margin-top: 20px; }
.excel__cancel { color: var(--ink-2); }
.excel__inline { display: inline-block; margin-left: 8px; }
.site-footer__link + .site-footer__link { margin-left: 4px; }
