/* ============ 健康管家 - 样式 ============ */
:root {
  --primary: #0ea5a4;
  --primary-dark: #0b8f8e;
  --primary-soft: rgba(14, 165, 164, .12);
  --accent: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --bg: #f1f5f5;
  --card: #ffffff;
  --text: #1f2937;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --line: #e5e7eb;
  --shadow: 0 1px 3px rgba(17, 24, 39, .06), 0 4px 14px rgba(17, 24, 39, .05);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #2dd4bf;
    --primary-dark: #14b8a6;
    --primary-soft: rgba(45, 212, 191, .15);
    --bg: #0f1417;
    --card: #1a2126;
    --text: #e8edf0;
    --text-2: #9aa7ad;
    --text-3: #6b767c;
    --line: #2a343a;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; touch-action: manipulation; }
input, select, textarea { font-family: inherit; font-size: 16px; color: var(--text); }
[hidden] { display: none !important; }

/* ============ 布局骨架 ============ */
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: calc(22px + var(--safe-top)) 16px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.header-title { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.header-logo { font-size: 22px; }
.icon-btn { font-size: 21px; padding: 6px 10px; border-radius: 12px; }
.icon-btn:active { background: var(--primary-soft); }

.view-container { flex: 1; padding: 14px 14px calc(24px + var(--safe-bottom)); }
.view { display: block; animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; background: var(--card);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + var(--safe-bottom));
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0 4px; border-radius: 12px; color: var(--text-3); font-size: 11px;
  transition: color .15s;
}
.tab-icon { font-size: 22px; line-height: 1; }
.tab.active { color: var(--primary); font-weight: 600; }

/* ============ 通用组件 ============ */
.filter-chips {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 2px 2px 12px; margin-bottom: 0;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: none; padding: 7px 15px; border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow);
  font-size: 13.5px; font-weight: 600; color: var(--text-2);
  transition: all .15s;
}
.filter-chip.active { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; }

.undo-link {
  margin-left: auto; font-size: 12px; font-weight: 600;
  color: var(--text-3); padding: 4px 8px; border-radius: 8px; flex: none;
}
.undo-link:active { background: rgba(239,68,68,.12); color: var(--danger); }

.export-btn { width: 100%; margin-bottom: 12px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 12px; font-size: 15px; font-weight: 600;
  transition: opacity .15s, transform .05s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; }
.btn-primary:active { opacity: .85; }
.btn-ghost { background: var(--primary-soft); color: var(--primary-dark); }
.btn-danger { background: rgba(239,68,68,.12); color: var(--danger); }
.btn-sm { padding: 7px 13px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }

.add-btn {
  width: 100%; padding: 13px; border-radius: var(--radius); font-size: 15px; font-weight: 600;
  color: var(--primary-dark); background: var(--card); border: 1.5px dashed color-mix(in srgb, var(--primary) 55%, var(--line));
  margin-top: 4px;
}
.add-btn:active { background: var(--primary-soft); }
.add-wrap { display: flex; gap: 8px; margin-top: 4px; }
.add-wrap .add-btn { flex: 1; margin-top: 0; padding: 13px 6px; font-size: 13.5px; }

.input, .select, .textarea {
  width: 100%; padding: 11px 13px; border-radius: 12px; font-size: 16px;
  background: var(--bg); border: 1.5px solid var(--line); outline: none;
  -webkit-appearance: none; appearance: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px;
}
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.5; }
.chip-ok { background: rgba(34,197,94,.15); color: var(--accent); }
.chip-low { background: rgba(59,130,246,.15); color: #3b82f6; }
.chip-high { background: rgba(245,158,11,.18); color: var(--warn); }

.seg { display: flex; background: var(--card); border-radius: 13px; padding: 4px; margin-bottom: 12px; box-shadow: var(--shadow); }
.seg button { flex: 1; padding: 9px 0; border-radius: 10px; font-size: 15px; color: var(--text-2); font-weight: 600; }
.seg button.active { background: var(--primary); color: #fff; }

/* ============ 今日事项 ============ */
.summary-card { display: flex; align-items: center; justify-content: space-between; }
.summary-date { font-size: 18px; font-weight: 700; }
.summary-sub { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.summary-sub b { color: var(--primary-dark); font-size: 15px; }
.progress-wrap { margin-top: 12px; height: 8px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .3s ease; }
.ring-wrap { position: relative; width: 62px; height: 62px; flex: none; margin-left: 12px; }
.ring-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--primary-dark); }

.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  cursor: pointer; transition: opacity .2s;
}
.task-row:active { opacity: .7; }
.task-row.done { opacity: .55; }
.task-row.done .task-title { text-decoration: line-through; color: var(--text-3); }
.check {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff; transition: all .15s;
}
.task-row.done .check { background: var(--accent); border-color: var(--accent); }
.task-main { flex: 1; min-width: 0; }
.task-title { font-size: 16px; font-weight: 600; }
.task-note { font-size: 12.5px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.task-time { font-size: 15px; font-weight: 700; color: var(--primary-dark); font-variant-numeric: tabular-nums; }
.task-row.overdue .task-time { color: var(--danger); }
.task-badge { font-size: 11px; color: var(--text-3); }
.task-row.overdue .task-badge { color: var(--danger); font-weight: 600; }
.done-time { font-size: 11px; color: var(--accent); }

.empty-hint { text-align: center; color: var(--text-3); font-size: 14px; padding: 26px 0; }

/* ============ 记录 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-box { background: var(--bg); border-radius: 12px; padding: 10px 8px; text-align: center; }
.stat-num { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-num small { font-size: 11px; font-weight: 600; color: var(--text-3); }
.stat-label { font-size: 11px; color: var(--text-2); margin-top: 2px; }

.chart-svg { width: 100%; height: auto; display: block; }
.chart-empty { text-align: center; color: var(--text-3); font-size: 13px; padding: 30px 0; }

.rec-item { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.rec-item:last-child { border-bottom: none; }
.rec-main { flex: 1; min-width: 0; }
.rec-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.rec-value { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rec-date { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.rec-del { font-size: 16px; padding: 6px; border-radius: 9px; color: var(--text-3); }
.rec-del:active { background: rgba(239,68,68,.12); color: var(--danger); }
.rec-group-date { font-size: 13px; font-weight: 700; color: var(--text-2); margin: 12px 0 2px; }
.rec-group-date:first-child { margin-top: 0; }

/* ============ 食谱 ============ */
.meal-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.meal-head { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }
.meal-icon { font-size: 22px; }
.meal-head h3 { font-size: 16px; flex: 1; }
.meal-add { width: 30px; height: 30px; border-radius: 10px; background: var(--primary-soft); color: var(--primary-dark); font-size: 19px; font-weight: 700; line-height: 1; }
.meal-add:active { opacity: .7; }
.meal-list { list-style: none; }
.meal-item { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.meal-item:last-child { border-bottom: none; }
.meal-item:active { opacity: .7; }
.meal-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.meal-name { flex: 1; font-size: 15px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal-note { font-size: 12px; color: var(--text-3); max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal-del { font-size: 15px; color: var(--text-3); padding: 4px 6px; flex: none; }
.meal-del:active { color: var(--danger); }

/* ============ 我的 / 食谱汇总 ============ */
.hub-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 2px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.hub-row:last-child { border-bottom: none; }
.hub-row:active { opacity: .7; }
.hub-arrow { flex: none; font-size: 22px; color: var(--text-3); line-height: 1; }

.subpage-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 2px 10px;
}
.subpage-spacer { flex: none; width: 66px; }

/* ============ 今日食谱（选餐/备菜） ============ */
.copy-link { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--primary-dark); padding: 4px 8px; border-radius: 8px; flex: none; }
.copy-link:active { background: var(--primary-soft); }

.ing-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 2px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.ing-item:last-child { border-bottom: none; }
.ing-check {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 7px;
  border: 2px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff;
}
.ing-item.checked .ing-check { background: var(--accent); border-color: var(--accent); }
.ing-text { flex: 1; font-size: 14.5px; line-height: 1.5; min-width: 0; }
.ing-item.checked .ing-text { text-decoration: line-through; color: var(--text-3); }
.ing-src { font-size: 11.5px; color: var(--text-3); max-width: 34%; text-align: right; line-height: 1.5; }

.plan-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary-soft); color: var(--primary-dark);
  border-radius: 999px; padding: 5px 10px; font-size: 13px; font-weight: 600;
}
.plan-chip-x { font-size: 12px; padding: 0 2px; color: var(--text-3); }
.plan-chip-x:active { color: var(--danger); }

.picker-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 2px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.picker-row:last-child { border-bottom: none; }
.picker-row:active { opacity: .7; }
.picker-check {
  flex: none; width: 24px; height: 24px; border-radius: 8px;
  border: 2px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff;
}
.picker-row.picked .picker-check { background: var(--accent); border-color: var(--accent); }
.picker-main { flex: 1; min-width: 0; }
.back-btn {
  font-size: 15px; font-weight: 600; color: var(--primary-dark);
  padding: 8px 10px 8px 4px; border-radius: 10px; flex: none;
}
.back-btn:active { background: var(--primary-soft); }
.subpage-title { flex: 1; text-align: center; font-size: 17px; font-weight: 700; }
.subpage-add {
  flex: none; font-size: 14px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  padding: 8px 13px; border-radius: 10px;
}
.subpage-add:active { opacity: .8; }

.search-box { margin-bottom: 12px; border-radius: 999px; padding-left: 16px; }

.recipe-item {
  position: relative; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 13px 36px 13px 14px; margin-bottom: 10px; cursor: pointer;
}
.recipe-item:active { opacity: .7; }
.recipe-item .hub-arrow { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
.recipe-item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.recipe-name { font-size: 16px; font-weight: 700; }
.recipe-preview {
  font-size: 12.5px; color: var(--text-2); margin-top: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.recipe-block {
  background: var(--bg); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px;
}
.recipe-block-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.recipe-block-body { font-size: 14.5px; line-height: 1.75; white-space: pre-line; word-break: break-word; }

/* ============ 检查报告识别 ============ */
.report-img {
  width: 100%; max-height: 260px; object-fit: contain;
  border-radius: 12px; background: var(--bg); margin: 8px 0;
  border: 1px solid var(--line);
}
.ocr-status {
  font-size: 12.5px; color: var(--text-2); line-height: 1.6;
  min-height: 18px; margin-top: 6px; word-break: break-all;
}

/* ============ 检查图片（复查记录） ============ */
.ck-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 2px; -webkit-overflow-scrolling: touch; }
.ck-thumb-wrap { position: relative; flex: none; }
.ck-thumb {
  display: block; width: 78px; height: 78px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
}
.ck-thumb-x {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px;
  border-radius: 50%; background: rgba(17, 24, 39, .72); color: #fff;
  font-size: 12px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.ck-thumb-name {
  font-size: 10px; color: var(--text-3); max-width: 78px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.img-view {
  width: 100%; max-height: 62vh; object-fit: contain;
  border-radius: 12px; background: #000;
}

/* ============ 左滑删除 ============ */
.swipe-item { position: relative; }
.swipe-content { position: relative; z-index: 1; will-change: transform; }
.swipe-del {
  position: absolute; top: 0; right: 0; bottom: 0; width: 76px; z-index: 0;
  background: var(--danger); color: #fff; font-size: 14px; font-weight: 600;
  border-radius: 0 var(--radius) var(--radius) 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .12s ease;
}
.swipe-item.swiped .swipe-del { opacity: 1; pointer-events: auto; }

/* ============ 弹层 / 抽屉 ============ */
.modal-mask {
  position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: maskin .18s ease;
}
@keyframes maskin { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 85vh; max-height: 88dvh; overflow-y: auto;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 10px 16px calc(18px + var(--safe-bottom));
  animation: sheetin .22s cubic-bezier(.32,.72,.34,1);
  -webkit-overflow-scrolling: touch;
}
@keyframes sheetin { from { transform: translateY(60px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-grab { width: 40px; height: 4px; border-radius: 999px; background: var(--line); margin: 4px auto 12px; }
.sheet-title { font-size: 17px; font-weight: 700; text-align: center; margin-bottom: 14px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }

.setting-item { display: flex; align-items: center; gap: 12px; padding: 13px 2px; border-bottom: 1px solid var(--line); }
.setting-item:last-child { border-bottom: none; }
.setting-icon { font-size: 19px; flex: none; }
.setting-main { flex: 1; min-width: 0; }
.setting-name { font-size: 15px; font-weight: 600; }
.setting-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; line-height: 1.5; }
.setting-item button.action { font-size: 13.5px; font-weight: 600; color: var(--primary-dark); background: var(--primary-soft); padding: 7px 12px; border-radius: 10px; flex: none; }
.setting-item button.action:active { opacity: .7; }

.switch { position: relative; width: 50px; height: 30px; border-radius: 999px; background: var(--line); flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(20px); }

.steps { padding: 4px 0 8px 2px; }
.steps li { list-style: none; display: flex; gap: 10px; padding: 7px 0; font-size: 14px; line-height: 1.55; color: var(--text); }
.step-no { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); font-size: 12.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-top: 1px; }

/* ============ 提醒横幅 / Toast ============ */
.reminder-banner {
  position: fixed; top: calc(12px + var(--safe-top)); left: 12px; right: 12px; z-index: 60;
  max-width: 536px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.22);
  border: 1px solid color-mix(in srgb, var(--primary) 45%, var(--line));
  padding: 12px 14px; animation: bannerin .3s cubic-bezier(.32,.72,.34,1);
}
@keyframes bannerin { from { transform: translateY(-90px); opacity: 0; } to { transform: none; opacity: 1; } }
.reminder-icon { font-size: 30px; animation: shake 1s ease infinite; }
@keyframes shake {
  0%, 60%, 100% { transform: rotate(0); }
  65%, 75%, 85% { transform: rotate(-12deg); }
  70%, 80%, 90% { transform: rotate(12deg); }
}
.reminder-body { flex: 1; min-width: 0; }
.reminder-title { font-size: 16px; font-weight: 700; }
.reminder-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.reminder-actions { display: flex; gap: 6px; flex: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translateX(-50%);
  z-index: 80; background: rgba(17,24,39,.9); color: #fff; font-size: 14px;
  padding: 10px 18px; border-radius: 999px; max-width: 86vw; text-align: center;
  animation: toastin .2s ease;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ 安装提示 ============ */
.install-tip {
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff;
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow);
}
.install-tip .txt { flex: 1; font-size: 13.5px; line-height: 1.55; }
.install-tip b { font-size: 15px; display: block; margin-bottom: 2px; }
.install-tip button { color: #fff; font-size: 19px; padding: 4px 8px; flex: none; }
