:root {
  /* 🕊️ Heirloom Palette */
  --rose: #c98a9b; --rose-deep: #b06e84; --blush: #e7cdd3; --lilac: #c9bcd8;
  --lavender: #c3b3d6; --apricot: #e6c6a0; --sage: #a6bca6; --coastal: #a9bccb;
  --bg: #ffffff; --card: #ffffff; --field: #faf6f4; --text: #6a5a5e;
  --muted: #a99aa0; --border: #ecdfe1; --danger: #c17689;
  --radius: 20px; --shadow: 0 6px 18px rgba(176, 110, 132, .12);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #241f24; --card: #302a30; --field: #3a333a; --text: #ece2e6;
    --muted: #b3a3aa; --border: #453d45; --shadow: 0 6px 18px rgba(0,0,0,.3); }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  background: var(--bg); color: var(--text); padding-bottom: 30px; -webkit-font-smoothing: antialiased; }

/* ===== 登入頁 ===== */
.login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(160deg, #fbf4f6 0%, #f4f1f8 100%); }
.login-view[hidden] { display: none; }
@media (prefers-color-scheme: dark) { .login-view { background: linear-gradient(160deg, #2a2330, #241f28); } }
.login-card { background: var(--card); border: 2px solid var(--border); border-radius: 26px; box-shadow: var(--shadow);
  padding: 32px 26px; width: 100%; max-width: 380px; text-align: center; }
.login-logo { font-size: 52px; }
.login-card h1 { font-size: 26px; margin: 6px 0; color: var(--rose-deep); letter-spacing: 1px; }
.login-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.login-card input { margin-bottom: 14px; text-align: center; font-size: 18px; letter-spacing: 1px; }

/* ===== Header ===== */
.app-header { position: sticky; top: 0; z-index: 10; color: #fff; padding: 14px 18px;
  background: linear-gradient(120deg, var(--rose), var(--lavender));
  display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow); border-radius: 0 0 24px 24px; }
.app-header h1 { font-size: 20px; letter-spacing: .5px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.today-stat { font-size: 13px; font-weight: 700; background: rgba(255,255,255,.26); padding: 6px 12px; border-radius: 18px; }
.logout-btn { background: rgba(255,255,255,.22); border: none; color: #fff; width: 34px; height: 34px; border-radius: 50%; font-size: 16px; cursor: pointer; }

main { max-width: 640px; margin: 0 auto; padding: 14px; }

/* ===== 模式切換 ===== */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab { flex: 1; padding: 12px; border-radius: 16px; background: var(--card); color: var(--muted);
  font-size: 15px; font-weight: 700; cursor: pointer; border: 2px solid var(--border); transition: all .15s; }
.tab.active { background: var(--rose); color: #fff; border-color: var(--rose); box-shadow: var(--shadow); }
.mode-panel { display: none; }
.mode-panel.active { display: block; animation: pop .25s; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ===== 加入飲食：左時間軸 + 右新增 ===== */
.log-layout { display: flex; gap: 10px; align-items: flex-start; }
.timeline-col { width: 38%; min-width: 116px; flex-shrink: 0; }
.timeline-head { font-size: 12px; font-weight: 800; color: var(--rose-deep); text-align: center; margin-bottom: 8px; }
.timeline { position: relative; padding-left: 4px; border-left: 2px dashed var(--border); }
.tl-item { display: flex; gap: 8px; margin-bottom: 14px; position: relative; }
.tl-left { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 46px; flex-shrink: 0; }
.tl-time { font-size: 12px; font-weight: 800; color: var(--rose-deep); }
.tl-photo { width: 42px; height: 42px; object-fit: cover; border-radius: 10px; border: 2px solid var(--border); }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--rose); margin-top: 3px; }
.tl-body { flex: 1; min-width: 0; background: var(--card); border: 2px solid var(--border); border-radius: 14px; padding: 8px 10px; box-shadow: var(--shadow); }
.tl-food { font-weight: 800; font-size: 14px; word-break: break-word; }
.tl-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.tl-del { background: none; border: none; color: var(--danger); font-size: 11px; cursor: pointer; padding: 3px 0 0; font-weight: 600; }
.tl-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 6px; line-height: 1.8; }
.tl-now { color: var(--rose-deep); font-weight: 700; }
.stage-badge { font-size: 10px; padding: 1px 6px; border-radius: 8px; font-weight: 700; vertical-align: middle; }
.stage-badge.before { background: #eef3ec; color: #789072; }
.stage-badge.after { background: #f6ebee; color: var(--rose-deep); }

/* 右：新增區 */
.add-col { flex: 1; min-width: 0; background: var(--card); border: 2px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.add-head { display: flex; gap: 8px; margin-bottom: 10px; }
.time-picker { flex: 1; }
.time-picker label { font-size: 12px; color: var(--muted); font-weight: 700; }
.add-head select { flex: 1; align-self: flex-end; }
.method-row { display: flex; gap: 6px; margin-bottom: 8px; }
.method-btn { flex: 1; text-align: center; padding: 10px 4px; border-radius: 12px; font-size: 13px; font-weight: 700;
  background: linear-gradient(120deg, var(--rose), var(--rose-deep)); color: #fff; border: none; cursor: pointer; }
.method-btn:active { transform: scale(.97); }
.tutorial-link { width: 100%; background: none; border: none; color: var(--rose-deep); font-size: 12px; font-weight: 700; cursor: pointer; margin-bottom: 8px; text-decoration: underline; }
.photo-preview { width: 100%; max-height: 180px; object-fit: contain; border-radius: 12px; margin-bottom: 8px; border: 2px solid var(--border); }
.ai-status { font-size: 13px; color: var(--muted); min-height: 18px; margin-bottom: 8px; }
.ai-status.working { color: var(--rose-deep); font-weight: 700; }
.ai-status.error { color: var(--danger); }

.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 10px; font-size: 15px; border: 2px solid var(--border);
  border-radius: 12px; background: var(--field); color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--rose); }
.name-row { display: flex; gap: 6px; }
.name-row input { flex: 1; }
.mini-btn { white-space: nowrap; padding: 0 10px; border-radius: 12px; border: 2px solid var(--rose); background: var(--card); color: var(--rose-deep); font-weight: 700; font-size: 13px; cursor: pointer; }
.row { display: flex; gap: 8px; }
.row > .field { flex: 1; }

button.primary { width: 100%; padding: 13px; border: none; border-radius: 16px;
  background: linear-gradient(120deg, var(--rose), var(--rose-deep)); color: #fff; font-size: 15px; font-weight: 800; cursor: pointer; box-shadow: var(--shadow); }
button.primary:active { transform: scale(.98); }
.msg { margin-top: 8px; font-size: 13px; text-align: center; min-height: 16px; font-weight: 600; }
.msg.success { color: var(--rose-deep); } .msg.error { color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ===== 卡片 / 建議 ===== */
.card { background: var(--card); border: 2px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-title { font-size: 15px; color: var(--rose-deep); margin-bottom: 10px; }
.progress-box { margin-bottom: 12px; }
.prog-nums { font-size: 14px; margin-bottom: 6px; } .prog-nums b { color: var(--rose-deep); }
.prog-bar { height: 12px; background: var(--field); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.prog-fill { height: 100%; background: linear-gradient(90deg, var(--sage), var(--rose)); }
.prog-meals { font-size: 12px; color: var(--muted); margin-top: 6px; }
.suggest-summary { font-size: 13px; color: var(--text); background: var(--field); padding: 10px; border-radius: 12px; margin: 10px 0; }
.suggest-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 12px; border: 2px solid var(--border); border-radius: 14px; margin-bottom: 8px; }
.s-meal { font-size: 11px; color: var(--muted); font-weight: 700; }
.s-food { font-weight: 800; margin: 2px 0; }
.s-reason { font-size: 12px; color: var(--muted); }
.s-kcal { color: var(--rose-deep); font-weight: 800; white-space: nowrap; }

/* ===== Modal / 餐廳 ===== */
.modal { position: fixed; inset: 0; background: rgba(106, 90, 94, .45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 18px; backdrop-filter: blur(2px); }
.modal[hidden] { display: none; }
.modal-card { background: var(--card); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 420px; max-height: 84vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(176,110,132,.28); border: 2px solid var(--border); }
.modal-card h3 { margin-bottom: 12px; color: var(--rose-deep); }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions button { flex: 1; padding: 12px; border-radius: 14px; border: 2px solid var(--border); background: var(--field); color: var(--text); font-weight: 700; cursor: pointer; }
.modal-actions button.primary { background: linear-gradient(120deg, var(--rose), var(--rose-deep)); color: #fff; border: none; }
.tutorial-list { padding-left: 18px; font-size: 14px; line-height: 1.9; } .tutorial-list ul { padding-left: 16px; }
.dish-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.dish { display: flex; justify-content: space-between; align-items: center; padding: 12px; border: 2px solid var(--border); border-radius: 14px; cursor: pointer; background: var(--field); }
.dish:active { border-color: var(--rose); }
.d-name { font-weight: 700; } .d-cat { font-size: 11px; color: var(--muted); }
.d-kcal { color: var(--rose-deep); font-weight: 800; font-size: 14px; }
