/* ============ 健康打卡 · Health Bubbles ============ */
:root {
  --bg: #f3f7f4;
  --card: #ffffff;
  --ink: #1f2937;
  --ink-2: #6b7280;
  --ink-3: #9ca3af;
  --line: #e8edeb;
  --p1: #10b981;
  --p2: #0ea5e9;
  --grad: linear-gradient(135deg, #10b981, #0ea5e9);
  --ok: #10b981;
  --warn: #f59e0b;
  --miss: #ef4444;
  --skip: #9ca3af;
  --shadow: 0 6px 24px rgba(31, 41, 55, .07);
  --radius: 18px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background:
    radial-gradient(800px 400px at 85% -10%, rgba(14, 165, 233, .10), transparent 60%),
    radial-gradient(700px 380px at -10% 0%, rgba(16, 185, 129, .12), transparent 60%),
    var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
.hidden { display: none !important; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; padding: 0 16px calc(84px + env(safe-area-inset-bottom)); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px 10px;
  background: linear-gradient(var(--bg) 78%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 42px; height: 42px; border-radius: 14px;
  background: var(--grad); color: #fff;
  display: grid; place-items: center; font-size: 20px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(16, 185, 129, .35);
}
.app-name { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.date-line { font-size: 12px; color: var(--ink-2); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink-2); display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { transform: scale(.94); }

.user-chip {
  max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); font-size: 13px; color: var(--ink-2);
  text-decoration: none; cursor: pointer;
}
.user-chip.admin { color: var(--p1); font-weight: 600; }

.score-mini { position: relative; width: 46px; height: 46px; }
.ring { width: 46px; height: 46px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4.5; }
.ring-bg { stroke: #e5e7eb; }
.ring-fg { stroke: url(#gradRingMini); stroke-linecap: round; stroke-dasharray: 0 200; transition: stroke-dasharray .5s ease; }
.score-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: var(--ink);
}
.score-num small { font-size: 9px; color: var(--ink-3); margin-left: 1px; }

/* ---------- 视图 ---------- */
.view { display: none; animation: fadein .25s ease; }
.view.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.sec-title { font-size: 15px; font-weight: 700; margin: 20px 4px 10px; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.6);
}

/* ---------- 智能提示卡 ---------- */
.suggest {
  margin-top: 4px;
  background: var(--grad); color: #fff; border: none;
  display: flex; align-items: center; gap: 12px;
}
.suggest .sg-icon { flex: none; width: 44px; height: 44px; border-radius: 14px; background: rgba(255,255,255,.18); display: grid; place-items: center; }
.suggest .sg-txt { flex: 1; min-width: 0; }
.suggest .sg-title { font-size: 16px; font-weight: 700; }
.suggest .sg-sub { font-size: 12px; opacity: .85; }
.suggest .sg-btn {
  flex: none; border: none; cursor: pointer;
  background: rgba(255,255,255,.92); color: #0f766e;
  font-size: 13px; font-weight: 700; padding: 9px 14px; border-radius: 999px;
}
.suggest .sg-btn:active { transform: scale(.95); }

/* ---------- 气泡 ---------- */
.bubble-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 8px; }
.bubble {
  position: relative; border: none; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-family: inherit;
}
.bubble .ball {
  width: 66px; height: 66px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--c, #cbd5e1);
  display: grid; place-items: center; color: var(--c, #64748b);
  box-shadow: 0 4px 14px rgba(31,41,55,.08);
  transition: transform .12s ease, box-shadow .12s ease;
}
.bubble:active .ball { transform: scale(.92); }
.bubble .b-label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.bubble .badge {
  position: absolute; top: -4px; right: calc(50% - 40px);
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--c, #64748b); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.bubble.logged .ball { background: color-mix(in srgb, var(--c) 14%, #fff); }
.bubble.logged .b-label { color: var(--c); }
.bubble .b-time { font-size: 10px; color: var(--ink-3); line-height: 1; }

/* ---------- 时间轴 ---------- */
.timeline { padding: 6px 14px; }
.tl-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.tl-item:last-child { border-bottom: none; }
.tl-item .tl-icon { flex: none; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 13%, #fff); color: var(--c); }
.tl-item .tl-main { flex: 1; min-width: 0; }
.tl-item .tl-title { font-size: 14px; font-weight: 600; }
.tl-item .tl-sub { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-item .tl-time { flex: none; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tl-item .tl-src { flex: none; font-size: 10px; padding: 2px 6px; border-radius: 6px; background: #f1f5f9; color: var(--ink-2); }
.tl-item .tl-del { flex: none; width: 28px; height: 28px; border: none; background: transparent; color: #cbd5e1; cursor: pointer; display: grid; place-items: center; border-radius: 8px; }
.tl-item .tl-del:active { color: var(--miss); background: #fef2f2; }
.empty { text-align: center; color: var(--ink-3); font-size: 13px; padding: 18px 0; }

/* ---------- 快记 ---------- */
textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 12px; font-size: 15px; font-family: inherit; resize: vertical;
  background: #fafcfa; color: var(--ink); outline: none;
}
textarea:focus { border-color: var(--p1); background: #fff; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; margin-top: 12px; }
.row.right { justify-content: flex-end; gap: 10px; margin-top: 16px; }
.btn {
  border: none; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; font-weight: 700; padding: 11px 18px; border-radius: 12px;
  transition: transform .1s ease, opacity .15s ease;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(16,185,129,.3); }
.btn.ghost { background: #f1f5f4; color: var(--ink-2); }
.btn.rec { background: #ef4444; color: #fff; animation: pulse 1.2s infinite; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4);} 50% { box-shadow: 0 0 0 8px rgba(239,68,68,0);} }
.hint { font-size: 12px; color: var(--ink-2); margin-top: 8px; }

/* 解析结果 */
.parse-panel { margin-top: 14px; }
.parse-engine { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; margin-bottom: 8px; }
.parse-engine.ai { background: #ecfdf5; color: #059669; }
.parse-engine.local { background: #eff6ff; color: #2563eb; }
.compare-box { display: grid; grid-template-columns: 1fr; gap: 12px; }
.raw-box { background: #f8fafc; border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--ink-2); }
.raw-box b { color: var(--ink); }
table.etab { width: 100%; border-collapse: collapse; font-size: 13px; }
.etab th { text-align: left; font-size: 11px; color: var(--ink-3); font-weight: 600; padding: 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.etab td { padding: 8px 6px; border-bottom: 1px dashed var(--line); vertical-align: middle; }
.etab tr:last-child td { border-bottom: none; }
.etab .t-type { display: inline-block; width: 26px; height: 26px; border-radius: 9px; display: inline-grid; place-items: center; background: color-mix(in srgb, var(--c) 13%, #fff); color: var(--c); }
.etab input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--p1); }
.unknown-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.unknown-chips span { font-size: 11px; background: #fef2f2; color: #b91c1c; border-radius: 8px; padding: 4px 8px; }

/* ---------- 分析 ---------- */
.score-card { text-align: center; }
.big-ring { position: relative; width: 132px; height: 132px; margin: 6px auto 2px; }
.big-ring svg { transform: rotate(-90deg); width: 132px; height: 132px; }
.big-ring circle { fill: none; stroke-width: 10; }
.br-bg { stroke: #eef2f1; }
.br-fg { stroke: url(#gradRingBig); stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.br-center { position: absolute; inset: 0; display: grid; place-content: center; }
.br-center .num { font-size: 34px; font-weight: 800; line-height: 1.1; }
.br-center .grade { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.score-card .grade { font-size: 14px; color: var(--ink); }
.breakdown { margin-top: 16px; text-align: left; }
.bd-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; }
.bd-row .bd-name { flex: none; width: 52px; font-size: 13px; color: var(--ink-2); }
.bd-row .bd-bar { flex: 1; height: 9px; border-radius: 999px; background: #eef2f1; overflow: hidden; }
.bd-row .bd-bar i { display: block; height: 100%; border-radius: 999px; background: var(--grad); transition: width .5s ease; }
.bd-row .bd-val { flex: none; width: 52px; text-align: right; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

table.cmp { width: 100%; border-collapse: collapse; font-size: 13px; }
.cmp th { text-align: left; font-size: 11px; color: var(--ink-3); padding: 4px 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.cmp td { padding: 10px 6px; border-bottom: 1px dashed var(--line); }
.cmp tr:last-child td { border-bottom: none; }
.cmp .c-name { font-weight: 700; }
.cmp .c-act { color: var(--ink); }
.cmp .c-act.none { color: var(--ink-3); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.pill.ok { background: #ecfdf5; color: #059669; }
.pill.warn { background: #fffbeb; color: #b45309; }
.pill.miss { background: #fef2f2; color: #b91c1c; }
.pill.skip { background: #f3f4f6; color: #6b7280; }

.trend-bars { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 8px; }
.tbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.tbar .bar { width: 100%; max-width: 34px; border-radius: 8px 8px 4px 4px; background: #d7e7e2; min-height: 4px; }
.tbar.today .bar { background: var(--grad); }
.tbar .t-val { font-size: 10px; color: var(--ink-2); }
.tbar .t-date { font-size: 10px; color: var(--ink-3); }
.tbar.today .t-date { color: var(--p1); font-weight: 700; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 30;
  display: flex; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; border: none; background: transparent; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ink-3); font-size: 11px; font-weight: 600; padding: 6px 0; border-radius: 12px;
}
.tab.active { color: var(--p1); }

/* ---------- 弹层 / 对话框 / Toast ---------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, .4);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .18s ease;
}
.sheet {
  width: 100%; max-width: 480px; background: #fff;
  border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: slideup .22s ease;
}
@keyframes slideup { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet h3 { font-size: 16px; margin-bottom: 4px; }
.sheet .sheet-sub { font-size: 12px; color: var(--ink-2); margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 9px; margin: 6px 0 14px; }
.chip {
  border: 1.5px solid var(--line); background: #fff; cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 600; color: var(--ink); padding: 9px 15px; border-radius: 999px;
}
.chip:active { transform: scale(.94); }
.chip.sel { border-color: var(--p1); background: #ecfdf5; color: #059669; }
.sheet .input-inline { width: 100%; }
.sheet .row.gap { margin-top: 4px; }
.sheet .btn { flex: 1; }

dialog {
  border: none; border-radius: 20px; padding: 22px 20px; width: min(92vw, 400px);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .25); color: var(--ink);
}
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog h2 { font-size: 17px; margin-bottom: 14px; }
.field { display: block; font-size: 12px; color: var(--ink-2); font-weight: 600; margin-bottom: 12px; }
.field input {
  display: block; width: 100%; margin-top: 5px;
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 14px; font-family: inherit; outline: none; background: #fafcfa;
}
.field input:focus { border-color: var(--p1); background: #fff; }

.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 60;
  background: rgba(31, 41, 55, .92); color: #fff; font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 999px; pointer-events: none;
  animation: fadein .2s ease; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

@media (min-width: 480px) {
  .bubble .ball { width: 72px; height: 72px; }
}

/* ===== v4：AI 自由解析（物品/属性/记忆推测） ===== */
.it-cat {
  font-style: normal; font-size: 10px; color: var(--p1);
  border: 1px solid var(--p1); border-radius: 6px;
  padding: 0 4px; margin-left: 4px; vertical-align: 1px; opacity: .85;
}
.recall-box {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: #f0fdf4; border: 1px dashed #86efac;
}
.recall-box > b { font-size: 13px; color: #15803d; margin-right: 8px; }
.recall-box .hint { display: block; font-size: 11px; margin: 2px 0 6px; }
.recall-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 2px; font-size: 13px; cursor: pointer;
}
.recall-row input { accent-color: var(--p1); }

/* ===== v5：我的数据面板 ===== */
.me-grid { display: flex; gap: 10px; margin: 14px 0 8px; }
.me-grid > div {
  flex: 1; background: #fafcfa; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 8px; text-align: center;
}
.me-grid b { display: block; font-size: 15px; }
.me-grid span { font-size: 11px; color: var(--ink-2); }
#btnMine { cursor: pointer; border: 0; font-family: inherit; }
