/*
 * SmartBite 網頁版的設計系統。顏色、圓角與字級對齊 Android 的 `ui/theme/Theme.kt`：
 * 淺色與深色是同一套品牌色的兩個版本，綠色是唯一的強調色；主要文字與底色的對比兩套都至少 4.5:1
 * （`js_tests` 的 theme 測試會檢查）。改色時兩邊一起改。
 */

:root {
  --green: #187c3a;
  --on-green: #ffffff;
  --ink: #0d2144;
  --muted: #596579;
  --canvas: #f7faf8;
  --surface: #ffffff;
  --mint: #eef7ef;
  --line: #e1e9e3;
  --warning: #aa4d05;
  --danger: #c83e45;
  --chip-selected: #ddefe0;
  --warning-container: #ffebd9;
  --ill-backdrop: #e3f0e5;
  --ill-body: #e3f0e5;
  --ill-line: #b9d9be;
  --ill-plate: #fdfdfb;
  --ill-carrot: #f0a86b;
  --ill-leaf: #6daf65;
  --ill-leaf-light: #91c77d;
  --ill-tomato: #e66a4e;
  --shadow: 0 1px 2px rgb(13 33 68 / 6%), 0 2px 8px rgb(13 33 68 / 5%);
  --scrim: rgb(13 33 68 / 38%);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-card: 16px;
  --radius-lg: 24px;
  --font-scale: 1;
  --sidebar-width: 288px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --green: #73d38e;
    --on-green: #06220f;
    --ink: #e8f1eb;
    --muted: #a6b6ac;
    --canvas: #0e1511;
    --surface: #16211b;
    --mint: #1c3226;
    --line: #2a3d32;
    --warning: #f3a865;
    --danger: #ff8f93;
    --chip-selected: #24402f;
    --warning-container: #3a2a1a;
    --ill-backdrop: #1c3226;
    --ill-body: #203a2b;
    --ill-line: #3f6b4c;
    --ill-plate: #2c3b32;
    --ill-carrot: #e39a5c;
    --ill-leaf: #6db266;
    --ill-leaf-light: #8cc07a;
    --ill-tomato: #e0745c;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    --scrim: rgb(0 0 0 / 55%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --green: #73d38e;
  --on-green: #06220f;
  --ink: #e8f1eb;
  --muted: #a6b6ac;
  --canvas: #0e1511;
  --surface: #16211b;
  --mint: #1c3226;
  --line: #2a3d32;
  --warning: #f3a865;
  --danger: #ff8f93;
  --chip-selected: #24402f;
  --warning-container: #3a2a1a;
  --ill-backdrop: #1c3226;
  --ill-body: #203a2b;
  --ill-line: #3f6b4c;
  --ill-plate: #2c3b32;
  --ill-carrot: #e39a5c;
  --ill-leaf: #6db266;
  --ill-leaf-light: #8cc07a;
  --ill-tomato: #e0745c;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  --scrim: rgb(0 0 0 / 55%);
  color-scheme: dark;
}

/* ---- 基礎 ------------------------------------------------------------------------------ */

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

html {
  /* 使用者在個人資料選的「介面文字大小」：縮放基準字級，瀏覽器本身的字級設定照常疊上去。 */
  font-size: calc(100% * var(--font-scale));
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, "Segoe UI", Roboto,
    sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--green);
}

img,
svg {
  display: block;
}

/* 元件的 display（例如 .btn 的 inline-flex）會蓋過瀏覽器對 hidden 屬性的預設，程式裡用 hidden 藏起來的東西就會露出來。 */
[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--green) 55%, transparent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 50;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--green);
  color: var(--on-green);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

/* ---- 字級（Material 3 的比例，與 Android 相同） ---------------------------------------- */

.headline {
  font-size: 1.75rem;
  line-height: 1.25;
  font-weight: 700;
}

.title-lg {
  font-size: 1.375rem;
  line-height: 1.3;
  font-weight: 700;
}

.title-md {
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 600;
}

.body-sm {
  font-size: 0.8125rem;
  line-height: 1.45;
}

.label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.muted {
  color: var(--muted);
}

.success-text {
  color: var(--green);
  font-size: 0.875rem;
}

.error-text {
  color: var(--danger);
  font-size: 0.875rem;
}

.warning-text {
  color: var(--warning);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stack-xs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

/* ---- 啟動畫面 ---------------------------------------------------------------------------- */

.boot {
  display: grid;
  place-items: center;
  gap: 14px;
  min-height: 60vh;
  color: var(--muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.spinner.small {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- 品牌 -------------------------------------------------------------------------------- */

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand svg {
  flex: none;
  color: var(--green);
}

.brand-name {
  font-size: 1.375rem;
  font-weight: 700;
  white-space: nowrap;
}

/* 放不下時整個藏起來：只剩半個字看起來像壞掉（Android 的 BrandTagline 同一個規則）。 */
.brand-tagline {
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

@media (max-width: 340px) {
  .brand-tagline {
    display: none;
  }
}

.page-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.page-title p {
  color: var(--muted);
}

.section-title {
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.3;
}

/* ---- 卡片、徽章、膠囊 ---------------------------------------------------------------------- */

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.icon-badge {
  display: grid;
  flex: none;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--green) 9%, transparent);
  color: var(--green);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 9%, transparent);
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 600;
}

.pill.warning {
  background: var(--warning-container);
  color: var(--warning);
}

.pill.start {
  align-self: flex-start;
}

.hero {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 154px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--mint);
}

.hero-text {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 60%;
  padding: 18px;
}

.hero-art {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 66%;
  height: 100%;
}

/* ---- 按鈕 -------------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--green);
  color: var(--on-green);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.btn:hover:not(:disabled) {
  box-shadow: 0 1px 3px rgb(0 0 0 / 18%);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.tall {
  min-height: 50px;
}

.btn.block {
  width: 100%;
}

.btn.outline {
  border-color: var(--line);
  background: transparent;
  color: var(--green);
}

.btn.text {
  min-height: 40px;
  padding: 8px 12px;
  background: transparent;
  color: var(--green);
}

.btn.text:hover:not(:disabled) {
  background: color-mix(in srgb, var(--green) 8%, transparent);
  box-shadow: none;
}

.btn.danger {
  background: var(--danger);
  color: var(--surface);
}

.btn.danger.outline {
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  background: transparent;
  color: var(--danger);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.icon-btn {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.icon-btn:hover {
  background: color-mix(in srgb, var(--ink) 7%, transparent);
}

.icon-btn.accent {
  color: var(--green);
}

.round-btn {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--green);
  box-shadow: var(--shadow);
  cursor: pointer;
}

/* ---- 表單 -------------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--muted) 45%, transparent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green);
  outline: 2px solid color-mix(in srgb, var(--green) 30%, transparent);
  outline-offset: 0;
}

.field input:disabled,
.field textarea:disabled {
  opacity: 0.6;
}

.field .support {
  color: var(--muted);
  font-size: 0.75rem;
}

.field.invalid input,
.field.invalid textarea {
  border-color: var(--danger);
}

.field.invalid .support {
  color: var(--danger);
}

/* 篩選晶片（單選）。選取中的底色是 Android 的 secondaryContainer。 */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.chip[aria-pressed="true"],
.chip[aria-checked="true"] {
  border-color: transparent;
  background: var(--chip-selected);
}

.chip[aria-pressed="true"]::before,
.chip[aria-checked="true"]::before {
  content: "✓";
  font-size: 0.8125rem;
}

/* ---- 設定列 ------------------------------------------------------------------------------ */

.settings-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.settings-link .title {
  flex: 1 1 auto;
  font-size: 1rem;
  font-weight: 600;
}

.settings-link .value {
  color: var(--muted);
  font-size: 0.8125rem;
}

.settings-link .chevron {
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
}

.settings-link:hover .title {
  color: var(--green);
}

.settings-link:disabled {
  cursor: default;
}

.settings-link:disabled:hover .title {
  color: var(--ink);
}

.divider {
  height: 1px;
  margin: 0;
  border: 0;
  background: var(--line);
}

/* ---- 未登入 ------------------------------------------------------------------------------ */

.signed-out {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 16px 20px 40px;
}

.signed-out header {
  padding: 4px 0 16px;
}

.health {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* ---- 登入後的外框 ---------------------------------------------------------------------------- */

.shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  backdrop-filter: blur(8px);
}

.topbar .brand {
  flex: 1 1 auto;
}

.sidebar {
  display: none;
}

.nav {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
}

.nav-brand svg {
  color: var(--green);
}

.nav-heading {
  padding: 20px 28px 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  margin: 0 12px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}

.nav-item svg {
  color: var(--muted);
}

.nav-item:hover {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}

.nav-item[aria-current="page"] {
  background: var(--mint);
  color: var(--green);
  font-weight: 700;
}

.nav-item[aria-current="page"] svg {
  color: var(--green);
}

.nav .nav-divider {
  margin: 12px 0;
}

.nav-footer {
  margin-top: auto;
  padding: 22px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.drawer {
  width: min(300px, 86vw);
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--canvas);
  color: var(--ink);
  overflow-y: auto;
}

.drawer::backdrop {
  background: var(--scrim);
}

.drawer[open] {
  animation: drawer-in 0.2s ease-out;
}

@keyframes drawer-in {
  from {
    transform: translateX(-100%);
  }
}

.shell-main {
  min-width: 0;
}

.content {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 4px 16px 40px;
}

.content:focus {
  outline: none;
}

@media (min-width: 1024px) {
  .shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    display: block;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--line);
  }

  .topbar .menu-btn,
  .topbar .brand {
    visibility: hidden;
  }

  .topbar {
    justify-content: flex-end;
    padding: 12px 24px 0;
    background: transparent;
    backdrop-filter: none;
  }

  .content {
    padding: 0 32px 56px;
  }

  .headline {
    font-size: 2rem;
  }
}

/* ---- 提示訊息 ------------------------------------------------------------------------------ */

.toast-region {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 480px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--canvas);
  box-shadow: 0 4px 16px rgb(0 0 0 / 25%);
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---- 對話框 -------------------------------------------------------------------------------- */

.dialog {
  width: min(92vw, 480px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 12px 40px rgb(0 0 0 / 28%);
}

.dialog::backdrop {
  background: var(--scrim);
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
}

/* ---- 空白狀態 ------------------------------------------------------------------------------ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  text-align: center;
}

/* ---- 對話框的延伸：長內容、手機上的底部面板 ------------------------------------------------ */

.dialog {
  max-height: min(92vh, 860px);
  overflow-y: auto;
}

.dialog.wide {
  width: min(94vw, 560px);
}

@media (max-width: 600px) {
  .dialog.sheet {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--canvas);
  }
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* ---- 首頁摘要輪播（Android 的 TodayProgressPager） ---------------------------------------- */

.pager-card {
  padding: 0;
  overflow: hidden;
}

.pager {
  display: flex;
  height: 280px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.pager::-webkit-scrollbar {
  display: none;
}

.pager-page {
  display: flex;
  flex: 0 0 100%;
  flex-direction: column;
  gap: 9px;
  padding: 16px;
  overflow-y: auto;
  scroll-snap-align: start;
  cursor: pointer;
}

.pager-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 2px;
}

.pager-dot-btn {
  display: grid;
  place-items: center;
  padding: 8px 3px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.pager-dot {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 7px;
  background: var(--line);
  transition: width 0.25s, background-color 0.25s;
}

.pager-dot-btn[aria-current="true"] .pager-dot {
  width: 18px;
  background: var(--green);
}

.summary-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.summary-action {
  flex: none;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--green);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.big-number {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.huge-number {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.15;
}

.label-value {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 8px;
  font-size: 0.8125rem;
}

.label-value .value {
  color: var(--muted);
}

.progress {
  height: 6px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--mint);
}

.progress.thin {
  height: 5px;
  background: var(--line);
}

.progress > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 0.8s ease-out;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 7 天柱狀圖：沒紀錄的日子是一條淡線，不是高度 0 的柱子。 */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 96px;
}

.bar-col {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.bar-track {
  display: flex;
  flex: 1;
  align-items: flex-end;
  width: 100%;
}

.bar {
  width: 100%;
  height: 0;
  border-radius: 6px;
  background: var(--green);
  transition: height 0.8s ease-out;
}

.bar.over {
  background: var(--danger);
}

.bar.missing {
  height: 2px;
  border-radius: 2px;
  background: var(--line);
  transition: none;
}

.bar-label {
  color: var(--muted);
  font-size: 0.6875rem;
  white-space: nowrap;
}

.bar-label.today {
  color: var(--ink);
  font-weight: 600;
}

/* 本月格子：有紀錄用深淺、過去沒記是淡底、還沒到更淡且沒有底。 */
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.weekday {
  color: var(--muted);
  font-size: 0.6875rem;
  text-align: center;
}

.month-cell {
  display: grid;
  place-items: center;
  height: 20px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--line) 40%, transparent);
  font-size: 0.6875rem;
}

.month-cell.filled {
  background: color-mix(in srgb, var(--green) calc(25% + 75% * var(--intensity, 0)), transparent);
}

.month-cell.strong {
  color: var(--on-green);
}

.month-cell.future {
  background: transparent;
  color: color-mix(in srgb, var(--muted) 45%, transparent);
}

.month-cell.blank {
  background: transparent;
}

.month-cell.today {
  font-weight: 700;
}

/* ---- 營養詳細：熱量圓環與營養素欄 ---------------------------------------------------------- */

.nutrition-overview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
}

/* 圓環跟著使用者的文字大小一起放大，中央的三行字才放得進內圈。 */
.ring {
  position: relative;
  flex: none;
  width: calc(124px * max(1, var(--font-scale)));
  aspect-ratio: 1;
}

.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring .track {
  stroke: var(--mint);
}

.ring .value {
  stroke: var(--green);
  transition: stroke-dashoffset 0.9s ease-out;
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
  text-align: center;
}

.ring-center .label {
  color: var(--muted);
}

.ring-value {
  font-size: 1.75rem;
  font-weight: 700;
}

.macro-column {
  display: flex;
  flex: 1 1 170px;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* ---- 飲食日記的月曆 ----------------------------------------------------------------------- */

.calendar-head {
  display: flex;
  align-items: center;
}

.calendar-head h2 {
  flex: 1;
  text-align: center;
}

.month-arrow {
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--green);
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
}

.month-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.calendar-grid .weekday {
  padding-bottom: 4px;
  font-size: 0.875rem;
  font-weight: 600;
}

.calendar-cell {
  display: grid;
  place-items: center;
  height: 42px;
}

.day-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
}

.day-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--green) 10%, transparent);
}

.day-btn.today {
  color: var(--green);
  font-weight: 700;
}

.day-btn.selected {
  background: var(--green);
  color: var(--on-green);
  font-weight: 700;
}

.day-btn:disabled {
  color: color-mix(in srgb, var(--muted) 50%, transparent);
  cursor: default;
}

.day-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--green);
}

.day-btn.selected .day-dot {
  background: var(--on-green);
}

/* ---- 餐點卡片（Android 的 MealCard；Material 的 Card 底色是 mint） -------------------------- */

.meal-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--mint);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---- 開關與單選清單 --------------------------------------------------------------------- */

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

input.switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 32px;
  margin: 0;
  border-radius: 16px;
  background: var(--line);
  cursor: pointer;
  appearance: none;
  transition: background-color 0.2s;
}

input.switch::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 30%);
  content: "";
  transition: transform 0.2s;
}

input.switch:checked {
  background: var(--green);
}

input.switch:checked::after {
  background: var(--on-green);
  transform: translateX(20px);
}

/* ---- 庫存（Android 的 InventoryContent） ------------------------------------------------ */

/* 一排可左右捲的選項（Android 的 ChoiceRow）：選中的是實心按鈕。 */
.choice-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.choice-row .btn {
  flex: none;
  min-height: 38px;
  padding: 6px 14px;
  font-size: 0.875rem;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill.muted {
  background: color-mix(in srgb, var(--muted) 12%, transparent);
  color: var(--muted);
}

.pill.danger {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.pill.warning-soft {
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  color: var(--warning);
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.metric {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.icon-badge.warning {
  background: color-mix(in srgb, var(--warning) 10%, transparent);
  color: var(--warning);
}

.message-card {
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 24%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  color: var(--danger);
}

.search-field {
  position: relative;
}

.search-field svg {
  position: absolute;
  left: 12px;
  bottom: 12px;
  color: var(--muted);
  pointer-events: none;
}

.search-field input {
  padding-left: 44px;
}

.attention-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* ---- 食譜與分享圖卡 ------------------------------------------------------------------ */

.pre-line {
  white-space: pre-line;
}

.clamp-2 {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* 分享預覽固定淺色：實際產生的圖卡圖片是淺色的，預覽看到的必須就是分享出去的樣子。 */
.share-preview {
  --ink: #0d2144;
  --muted: #596579;
  --surface: #ffffff;
  --line: #e1e9e3;
  --green: #187c3a;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  color-scheme: light;
}

.share-preview .share-mark {
  color: var(--green);
}

/* ---- Google／LINE 登入按鈕（照兩家的品牌規範） ---------------------------------------------- */

.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.divider-text::before,
.divider-text::after {
  flex: 1;
  height: 1px;
  background: var(--line);
  content: "";
}

.btn.social-google {
  border-color: #747775;
  background: #ffffff;
  color: #1f1f1f;
  font-weight: 500;
}

.btn.social-line {
  background: #06c755;
  color: #ffffff;
}

.btn.social-line:hover:not(:disabled) {
  background: #05b34c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn.social-google {
    border-color: #8e918f;
    background: #131314;
    color: #e3e3e3;
  }
}

:root[data-theme="dark"] .btn.social-google {
  border-color: #8e918f;
  background: #131314;
  color: #e3e3e3;
}

/* ---- 設定頁的資料與備份 ------------------------------------------------------------------ */

.settings-row {
  min-height: 40px;
  align-items: center;
}

.selectable {
  user-select: text;
}

/* ---- 其他小元件 -------------------------------------------------------------------------- */

.accent {
  color: var(--green);
}

.row.align-start,
.row-between.align-start {
  align-items: flex-start;
}

.message-card.success {
  border-color: color-mix(in srgb, var(--green) 24%, transparent);
  background: color-mix(in srgb, var(--green) 8%, transparent);
  color: var(--green);
}

.choice-row .btn {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- 網頁版只能查看 ------------------------------------------------------------------------ */

/* 各頁上方的說明（components.js 的 readOnlyNotice）：告訴人要去哪裡改。 */
.read-only-note {
  margin: 0;
  padding: 12px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-card);
  color: var(--muted);
  font-size: 0.92rem;
  background: var(--surface);
}

/* 設定頁的「隱私權政策」是連到公開頁面的連結，外觀跟其他設定列一樣。 */
a.settings-link {
  text-decoration: none;
}

/* 餐點有兩樣以上的食物時列出來（和 App 的餐點卡片相同）。 */
.meal-items {
  margin: 0;
  padding-left: 1.2em;
}

/* 列印食譜（pages/recipes.js 的 printRecipe）：平常看不到，列印時只印這張紙。 */
.print-sheet {
  display: none;
}

@media print {
  body.printing > :not(.print-sheet) {
    display: none !important;
  }

  body.printing .print-sheet {
    display: block;
    color-scheme: light;
    color: CanvasText;
    background: Canvas;
    font-size: 12pt;
    line-height: 1.6;
  }

  .print-sheet h1 {
    margin: 0 0 12pt;
    font-size: 20pt;
  }

  .print-sheet h2 {
    margin: 16pt 0 6pt;
    font-size: 14pt;
  }

  .print-sheet .print-footer {
    margin-top: 24pt;
    font-size: 9pt;
  }
}

/* ---- 公開頁面（首頁、隱私權政策、刪除帳號） ------------------------------------------------ */

/* 首頁的介紹沒有插圖，文字用滿整張卡片。 */
.hero.plain .hero-text {
  width: 100%;
}

.feature-list,
.policy ul {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding-left: 1.2em;
}

.download-list {
  display: flex;
  flex-direction: column;
}

.download-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  border-top: 1px solid var(--line);
}

.download-row:first-child {
  border-top: 0;
}

.policy h3 {
  margin-top: 8px;
}

.public-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  padding-top: 8px;
}
