/* 視覺：C 溫暖日記（淡赭）。token 的來源是 docs/ROADMAP.md 第 8 步的「視覺」表。
   顏色、間距（4/8 尺度）、圓角、陰影、字級、欄寬一律走 token。
   例外只有兩種：1–2px 的框線寬，以及折線圖 SVG 內的字級（那是 viewBox 座標，不是 CSS px）。 */

:root {
  /* 顏色 */
  --canvas: #FFFBEB;
  --surface: #FFFFFF;
  --ink: #2B2118;
  --muted: #7A6E63;
  --line: #F1E8E2;
  --track: #F3E9DC;
  --dash: #E8DCCB;
  --faint: #CFC5B8;
  /* --accent 只當大面積填色；上面的字一律用 --ink（白字或 #5C3A28 的對比都不到 4.5:1） */
  --accent: #CD7A55;
  /* 小字與連結用的赭：在米色底上 4.7:1 */
  --accent-text: #B4552D;
  --protein: #5B7DB1;
  --carbs: #C9922B;
  --fat: #B86A8A;
  --danger: #B4362E;
  --danger-soft: #FDF0EE;
  --chip-low-bg: #FBE9DF;
  --chip-low-ink: #8F4222;
  --chip-corrected-bg: #E9E8FB;
  --chip-corrected-ink: #4F51B8;

  /* 間距：4/8 尺度 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* 尺寸 */
  --touch: 44px;
  --control: 48px;
  --shell-max: 560px;
  --col-time: 44px;
  --col-value: 56px;
  --col-kcal: 72px;
  --col-readonly-time: 96px;
  --row-meal: 64px;
  --ring-size: 118px;
  --ring-stroke: 12px;
  --tabbar-clearance: 88px;
  --editor-footer-clearance: 144px;

  /* 圓角 */
  --radius-field: 12px;
  --radius-input: 14px;
  --radius-card: 18px;
  --radius-hero: 22px;
  --radius-sheet: 26px;
  --radius-pill: 999px;

  /* 陰影：軟陰影，不做邊框 */
  --shadow-soft: 0 4px 14px rgba(43, 33, 24, .06);
  --shadow-card: 0 8px 24px rgba(43, 33, 24, .08);
  --shadow-sheet: 0 -6px 24px rgba(43, 33, 24, .08);
  --shadow-accent: 0 8px 24px rgba(205, 122, 85, .28);
  --focus-ring: 0 0 0 2px var(--accent);

  /* 字型：LINE Seed TC 只是「裝置上有就用」，沒有就退回 Noto Sans TC；數字與標題用 Nunito */
  --font-body: "LINE Seed TC", "Noto Sans TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Nunito", "Noto Sans TC", system-ui, sans-serif;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-md: 13px;
  --text-ui: 14px;
  --text-base: 15px;
  /* 輸入框至少 16px：iOS 在小於 16px 的欄位取得焦點時會自動放大整頁 */
  --text-input: 16px;
  --text-kcal: 17px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-hero: 28px;

  --motion: 160ms ease-out;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

.icon { display: block; flex: 0 0 auto; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---- 版面 ---- */

.shell { width: min(100%, var(--shell-max)); margin: 0 auto; padding-top: env(safe-area-inset-top); }
body.has-tabbar .shell { padding-bottom: calc(var(--tabbar-clearance) + env(safe-area-inset-bottom)); }
.page { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4); }
.page-editor { gap: var(--space-2); padding-top: var(--space-3); padding-bottom: calc(var(--editor-footer-clearance) + env(safe-area-inset-bottom)); }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-tight { display: flex; flex-direction: column; gap: var(--space-2); }

.page-title { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.card { border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); }
.section { padding: var(--space-4); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: var(--space-6); padding: 0 var(--space-1); margin-bottom: var(--space-1); }
.section .section-head { padding: 0; margin-bottom: var(--space-3); }
.section-title { font-family: var(--font-display); font-size: var(--text-input); font-weight: 800; }
.section-count { color: var(--muted); font-size: var(--text-sm); }
.empty { padding: var(--space-6) var(--space-3); color: var(--muted); text-align: center; }
.footnote { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); color: var(--muted); font-size: var(--text-sm); text-align: center; }

.status { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); padding: var(--space-5) var(--space-4); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-soft); color: var(--muted); text-align: center; }
.status.is-error { background: var(--danger-soft); color: var(--danger); }
.status-text { white-space: pre-line; }

/* ---- 按鈕與連結 ---- */

.button { min-height: var(--control); padding: 0 var(--space-5); border: 0; border-radius: var(--radius-pill); font-family: var(--font-display); font-size: var(--text-input); font-weight: 800; transition: transform var(--motion), opacity var(--motion); }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { opacity: .5; }
.button-primary { background: var(--accent); color: var(--ink); box-shadow: var(--shadow-accent); }
.button-primary:disabled { box-shadow: none; }
.button-quiet { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }

.round-button { display: flex; align-items: center; justify-content: center; flex: 0 0 auto; width: var(--touch); height: var(--touch); padding: 0; border: 0; border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-soft); text-decoration: none; }
.round-button:disabled { color: var(--faint); }
.icon-button { display: flex; align-items: center; justify-content: center; flex: 0 0 auto; width: var(--touch); height: var(--touch); padding: 0; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--muted); }
.icon-button:disabled { color: var(--faint); }

.pill-button { min-height: var(--touch); padding: 0 var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface); color: var(--accent-text); font-size: var(--text-md); font-weight: 700; }
.pill-button:disabled { opacity: .5; }
.pill-button-icon { display: inline-flex; align-items: center; gap: var(--space-1); }
.quiet-button { min-height: var(--touch); padding: 0 var(--space-3); border: 0; background: transparent; color: var(--muted); font-size: var(--text-md); }
.danger-link { min-height: var(--touch); border: 0; background: transparent; color: var(--danger); font-size: var(--text-md); }
.quiet-button:disabled, .danger-link:disabled { opacity: .5; }
.dashed-button { display: flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--control); border: 2px dashed var(--dash); border-radius: var(--radius-card); background: transparent; color: var(--accent-text); font-size: var(--text-ui); font-weight: 700; }
.dashed-button:disabled { opacity: .5; }
.link-button { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--touch); padding: 0 var(--space-2); border: 0; background: transparent; color: var(--accent-text); font-size: var(--text-sm); font-weight: 700; }
.text-link { display: inline-flex; align-items: center; min-height: var(--touch); padding: 0 var(--space-1); color: var(--accent-text); font-weight: 700; }

/* ---- 日期列 ---- */

.datebar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.datebar-center { position: relative; display: flex; flex-direction: column; align-items: center; min-width: 0; min-height: var(--touch); padding: 0 var(--space-3); border-radius: var(--radius-input); cursor: pointer; }
.datebar-center:focus-within { box-shadow: var(--focus-ring); }
.datebar-relative { color: var(--muted); font-size: var(--text-sm); }
.datebar-date { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 800; }
/* 透明的原生 date input 蓋在日期文字上：點日期就開系統的日期選擇器 */
.datebar-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; font-size: var(--text-input); }

/* ---- 今日頁：熱量環與三大營養素 ---- */

.hero { display: flex; align-items: center; gap: var(--space-5); padding: var(--space-4); border-radius: var(--radius-hero); }
.ring { position: relative; flex: 0 0 auto; width: var(--ring-size); height: var(--ring-size); }
.ring svg { display: block; }
.ring-track, .ring-progress { fill: none; stroke-width: var(--ring-stroke); }
.ring-track { stroke: var(--track); }
.ring-progress { stroke: var(--accent); stroke-linecap: round; }
.ring-copy { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-value { font-family: var(--font-display); font-size: var(--text-hero); font-weight: 800; line-height: 1; }
.ring-unit { margin-top: var(--space-1); color: var(--muted); font-size: var(--text-xs); }
.hero-side { display: flex; flex-direction: column; gap: var(--space-2); flex: 1 1 0; min-width: 0; }
.hero-message { color: var(--muted); font-size: var(--text-md); }
.hero-gap { color: var(--accent-text); font-family: var(--font-display); font-size: var(--text-base); font-weight: 800; }
.hero-gap.is-over { color: var(--danger); }
.macro-list { display: flex; flex-direction: column; gap: var(--space-2); }
.macro-row { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-md); }
.macro-label { flex: 0 0 auto; width: var(--col-time); color: var(--muted); }
.macro-track { flex: 1 1 0; height: var(--space-2); border-radius: var(--radius-pill); background: var(--track); overflow: hidden; }
.macro-fill { height: 100%; border-radius: var(--radius-pill); transition: width var(--motion); }
.macro-value { flex: 0 0 auto; min-width: var(--col-value); text-align: right; }
.macro-value.is-plain { flex: 1 1 0; }
/* 限定在進度條上：編輯器的欄位標籤也用 tone-*，但顏色只放在標籤前的小圓點 */
.macro-fill.tone-protein { background: var(--protein); }
.macro-fill.tone-carbs { background: var(--carbs); }
.macro-fill.tone-fat { background: var(--fat); }

/* ---- 今日頁：餐點列 ---- */

.meal-row { display: flex; align-items: center; gap: var(--space-3); min-height: var(--row-meal); padding: var(--space-3) var(--space-4); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-soft); color: var(--ink); text-decoration: none; }
.meal-time { flex: 0 0 auto; width: var(--col-time); color: var(--muted); font-size: var(--text-md); }
.meal-body { display: flex; flex-direction: column; gap: var(--space-1); flex: 1 1 0; min-width: 0; }
.meal-title { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.meal-name { min-width: 0; overflow: hidden; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.meal-macros { color: var(--muted); font-size: var(--text-sm); }
.meal-kcal { flex: 0 0 auto; font-family: var(--font-display); font-size: var(--text-kcal); font-weight: 800; }
.meal-chevron { flex: 0 0 auto; color: var(--faint); }
.chip { flex: 0 0 auto; padding: var(--space-1) var(--space-2); border-radius: var(--radius-pill); font-size: var(--text-xs); line-height: 1.2; }
.chip-low { background: var(--chip-low-bg); color: var(--chip-low-ink); }
.chip-corrected { background: var(--chip-corrected-bg); color: var(--chip-corrected-ink); }

/* ---- 數值格（身體頁的最新一筆、設定頁的目前值與建議值） ---- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: var(--space-2); }
.stat { padding: var(--space-3); border-radius: var(--radius-input); background: var(--canvas); }
.stat-label { display: block; color: var(--muted); font-size: var(--text-sm); }
.stat-value { display: block; margin-top: var(--space-1); font-family: var(--font-display); font-size: var(--text-lg); font-weight: 800; }
.stat.is-unset .stat-value { color: var(--muted); font-family: var(--font-body); font-size: var(--text-base); font-weight: 500; }
/* 建議值不用實心底色——那是「已設定」的視覺語彙 */
.stat.is-outline { border: 1px solid var(--line); background: transparent; }

/* ---- 體重趨勢折線 ----
   取代橫向捲動的日期卡：「在降還是在升」要看形狀，不是看一排數字。 */

.trend { margin-top: var(--space-4); }
.trend svg { display: block; width: 100%; height: auto; touch-action: none; cursor: pointer; }
.trend svg:focus-visible { border-radius: var(--radius-field); }
.trend-area { fill: var(--accent); opacity: .14; }
.trend-line { fill: none; stroke: var(--accent-text); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
/* 端點與極值的圓點：2px surface ring 讓它壓在線上仍讀得出來 */
.trend-dot { fill: var(--accent-text); stroke: var(--surface); stroke-width: 2; }
.trend-extreme { fill: var(--accent-text); opacity: .45; }
.trend-value { fill: var(--ink); font-size: 11.5px; font-weight: 800; }
.trend-note { fill: var(--muted); font-size: 9.5px; }
.trend-cursor { stroke: var(--accent-text); stroke-width: 1; opacity: .3; }
.trend-hit { fill: transparent; }
.trend-empty { margin-top: var(--space-3); color: var(--muted); font-size: var(--text-md); }
.trend-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.trend-chip { padding: var(--space-2) var(--space-3); border-radius: var(--radius-field); background: var(--canvas); text-align: center; }
.trend-chip small { display: block; color: var(--muted); font-size: var(--text-xs); }
.trend-chip strong { display: block; margin-top: var(--space-1); font-size: var(--text-ui); }
.trend-table { margin-top: var(--space-2); }
.trend-table summary { display: inline-flex; align-items: center; min-height: var(--touch); color: var(--accent-text); font-size: var(--text-sm); font-weight: 700; cursor: pointer; }
.trend-table table { width: 100%; border-collapse: collapse; font-size: var(--text-md); }
.trend-table th, .trend-table td { padding: var(--space-2) var(--space-1); border-bottom: 1px solid var(--line); text-align: left; }
.trend-table th { color: var(--muted); font-weight: 500; }
.trend-table td { text-align: right; }

/* ---- 身體頁：與上一筆的差值、最近紀錄 ---- */

.change-list { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-3); color: var(--muted); font-size: var(--text-sm); }
.change-caption { flex: 1 0 100%; }
.change { padding: var(--space-1) var(--space-2); border-radius: var(--radius-pill); background: var(--canvas); color: var(--ink); }
.change strong { font-family: var(--font-display); font-weight: 800; }

/* 右側的刪除鍵自己就是一個觸控目標，所以右邊的留白比左邊少 */
.metric-row { display: flex; align-items: center; gap: var(--space-3); min-height: var(--row-meal); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-soft); }
.metric-when { display: flex; flex-direction: column; flex: 0 0 auto; width: var(--col-time); color: var(--muted); font-size: var(--text-md); }
.metric-time { font-size: var(--text-xs); }
.metric-body { display: flex; flex-direction: column; gap: var(--space-1); flex: 1 1 0; min-width: 0; }
.metric-main { font-family: var(--font-display); font-size: var(--text-kcal); font-weight: 800; }
.metric-rest { color: var(--muted); font-size: var(--text-sm); }

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

.field { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-3); color: var(--muted); font-size: var(--text-sm); }
.field-row { display: flex; gap: var(--space-2); }
.field-row .field { margin-bottom: 0; }
.field-grow { flex: 1 1 0; min-width: 0; }
.field-time { flex: 0 0 auto; width: var(--col-readonly-time); }
.input { width: 100%; min-width: 0; height: var(--control); padding: 0 var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-input); background: var(--surface); color: var(--ink); font-size: var(--text-input); }
.input:focus { outline: 0; border-color: var(--accent); box-shadow: var(--focus-ring); }
/* 切片 1 的時間是唯讀的：長得像欄位，但不是 input */
.input-static { display: flex; align-items: center; background: transparent; color: var(--muted); }
.hint { margin-bottom: var(--space-3); color: var(--muted); font-size: var(--text-sm); line-height: 1.6; }
.form-error { padding: var(--space-3); border-radius: var(--radius-field); background: var(--danger-soft); color: var(--danger); font-size: var(--text-md); white-space: pre-line; }
.field + .form-error, .hint + .form-error, .more-fields + .form-error, .section-head + .form-error { margin-bottom: var(--space-3); }
.form-actions { display: flex; gap: var(--space-2); }
.form-actions .button { flex: 1 1 0; }
/* 兩欄並排的欄位（身體紀錄表單）。欄位自己的 margin-bottom 就是列距 */
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-2); }
.more-fields { margin-bottom: var(--space-3); }
.more-fields summary { display: inline-flex; align-items: center; min-height: var(--touch); color: var(--accent-text); font-size: var(--text-sm); font-weight: 700; cursor: pointer; }
/* 邀請碼：顯示成大寫（送出前程式也會轉），字距拉開比較好對 */
.input-code { font-family: var(--font-display); letter-spacing: .12em; text-transform: uppercase; }
.coach-status { margin-bottom: var(--space-2); font-weight: 700; }

/* 建議攝取量：刻意與已設定的目標分開視覺分組，避免看起來像已經生效的數字 */
.suggestion { margin: var(--space-3) 0; padding: var(--space-3); border: 2px dashed var(--dash); border-radius: var(--radius-input); }
.suggestion-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-2); }
.suggestion-head h3 { font-size: var(--text-md); font-weight: 700; }
.suggestion-note { margin-top: var(--space-3); color: var(--muted); font-size: var(--text-xs); line-height: 1.6; }
.suggestion-missing { margin: 0; padding-left: var(--space-5); color: var(--muted); font-size: var(--text-sm); line-height: 1.7; }
.suggestion-missing strong { color: var(--ink); }

/* ---- 品項編輯器 ---- */

.editor-bar { display: flex; align-items: center; gap: var(--space-1); }
.editor-title { flex: 1 1 0; min-width: 0; padding-left: var(--space-2); font-family: var(--font-display); font-size: var(--text-lg); font-weight: 800; }

.total-card { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-card); background: var(--accent); color: var(--ink); box-shadow: var(--shadow-accent); }
.total-main { display: flex; flex-direction: column; }
.total-caption { font-size: var(--text-xs); }
.total-kcal { font-family: var(--font-display); font-size: var(--text-hero); font-weight: 800; line-height: 1.1; }
.total-unit { font-size: var(--text-sm); font-weight: 500; }
.total-macros { display: flex; gap: var(--space-4); }
.total-macro { display: flex; flex-direction: column; align-items: center; font-size: var(--text-md); }
.total-macro-value { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 800; }

.item-card { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-soft); }
/* 正在編輯的那一張：淡赭的框 */
.item-card:focus-within { box-shadow: var(--focus-ring), var(--shadow-soft); }
.item-head { display: flex; align-items: center; gap: var(--space-2); }
.line-input { min-width: 0; height: var(--touch); padding: 0 var(--space-2); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); font-size: var(--text-input); }
.line-input:focus { outline: 0; border-bottom-color: var(--accent); box-shadow: 0 1px 0 var(--accent); }
.line-input::placeholder { color: var(--muted); }
.item-name { flex: 1 1 0; font-weight: 500; }
/* 份量描述：自己一整列、隨內容長高（高度由 meal-editor.js 的 autosize 設）。最少一個觸控目標高 */
.item-portion { display: block; width: 100%; min-height: var(--touch); padding: var(--space-3) var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-field); background: var(--canvas); color: var(--muted); font-size: var(--text-input); line-height: 1.4; resize: none; overflow: hidden; }
.item-portion:focus { outline: 0; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--surface); color: var(--ink); }
.item-portion::placeholder { color: var(--muted); }
.item-grams { display: flex; align-items: flex-end; gap: var(--space-2); }
/* 三大營養素的顏色放在小圓點上，標籤文字用 --muted：三個色直接當 11px 的字色，對比只有 2.8–4.2:1 */
.gram-field { display: flex; flex-direction: column; gap: var(--space-1); flex: 1 1 0; min-width: 0; color: var(--muted); font-size: var(--text-xs); }
.gram-label { display: flex; align-items: center; gap: var(--space-1); white-space: nowrap; }
.gram-label::before { content: ""; flex: 0 0 auto; width: var(--space-2); height: var(--space-2); border-radius: var(--radius-pill); }
.gram-label.tone-protein::before { background: var(--protein); }
.gram-label.tone-carbs::before { background: var(--carbs); }
.gram-label.tone-fat::before { background: var(--fat); }
.gram-input { width: 100%; min-width: 0; height: var(--touch); padding: 0 var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-field); background: var(--canvas); color: var(--ink); font-size: var(--text-input); text-align: right; -moz-appearance: textfield; appearance: textfield; }
.gram-input::-webkit-outer-spin-button, .gram-input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }
.gram-input:focus { outline: 0; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--surface); }
.gram-input[aria-invalid="true"] { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.item-kcal { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); flex: 0 0 auto; width: var(--col-kcal); }
.item-kcal-label { color: var(--muted); font-size: var(--text-xs); white-space: nowrap; }
.item-kcal-value { display: flex; align-items: center; height: var(--touch); font-family: var(--font-display); font-size: var(--text-kcal); font-weight: 800; }
.item-card.is-converted .item-kcal-label, .item-card.is-converted .item-kcal-value { color: var(--accent-text); }

.editor-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; flex-direction: column; gap: var(--space-1); width: min(100%, var(--shell-max)); margin: 0 auto; padding: var(--space-3) var(--space-4) max(var(--space-3), env(safe-area-inset-bottom)); border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; background: var(--surface); box-shadow: var(--shadow-sheet); }

/* ---- tabbar ---- */

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; width: min(100%, var(--shell-max)); margin: 0 auto; padding: var(--space-2) var(--space-2) max(var(--space-3), env(safe-area-inset-bottom)); border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; background: var(--surface); box-shadow: var(--shadow-sheet); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1); flex: 1 1 0; min-height: var(--control); color: var(--muted); font-size: var(--text-xs); font-weight: 500; text-decoration: none; }
.tab.is-active { color: var(--accent-text); font-weight: 700; }

/* ---- toast／snackbar ---- */

.toast-host { position: fixed; left: 0; right: 0; bottom: calc(var(--editor-footer-clearance) + env(safe-area-inset-bottom)); z-index: 10; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: 0 var(--space-4); pointer-events: none; }
body.has-tabbar .toast-host { bottom: calc(var(--tabbar-clearance) + env(safe-area-inset-bottom)); }
.toast { display: flex; align-items: center; gap: var(--space-2); max-width: 100%; min-height: var(--control); padding: 0 var(--space-2) 0 var(--space-4); border-radius: var(--radius-input); background: var(--ink); color: var(--canvas); box-shadow: var(--shadow-card); font-size: var(--text-ui); pointer-events: auto; animation: toast-in var(--motion); }
.toast-text { padding-right: var(--space-2); }
.toast-action { min-height: var(--touch); padding: 0 var(--space-3); border: 0; border-radius: var(--radius-field); background: transparent; color: var(--accent); font-weight: 800; }
@keyframes toast-in { from { opacity: 0; transform: translateY(var(--space-2)); } to { opacity: 1; transform: none; } }

@media (max-width: 360px) {
  .hero { gap: var(--space-3); }
  .total-macros { gap: var(--space-3); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
