/* =============================================================
   麦穗健康 · 移动端设计令牌
   视觉：冷静 / 温和 / 有信任感 —— Apple Health 风格
   · 浅色为默认（系统浅灰底 + 白卡片），深色自适应
   · 系统蓝为唯一强调色；浅紫/浅蓝/淡绿作功能分区
   · 红色仅用于异常指标与告警
   · 扁平化：无重阴影、无渐变堆砌，靠留白与浅底分区
   ============================================================= */

:root {
  --font-sans: -apple-system, "SF Pro Text", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  /* 手机尺寸 */
  --pw: 390px;
  --ph: 844px;
  --safe-t: 47px;   /* 状态栏（灵动岛机型） */
  --nav-h: 44px;    /* 紧凑标题栏 */
  --tab-h: 56px;    /* 底部标签栏 */
  --safe-b: 34px;   /* 底部安全区 */
  --edge: 16px;     /* 左右页边距 */

  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 22px;
  --r-pill: 999px;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;
  --sp-4: 16px; --sp-5: 20px; --sp-6: 24px;

  --sh-1: 0 1px 2px rgba(0, 0, 0, .04);
  --sh-2: 0 2px 10px rgba(0, 0, 0, .06);
  --sh-3: 0 8px 40px rgba(0, 0, 0, .16);

  --ease: cubic-bezier(.32, .72, 0, 1);
  --dur-fast: 150ms;
  --dur: 300ms;
}

/* ============================== 浅色（默认） ============================== */
[data-theme="light"] {
  --bg-app: #f2f3f7;
  --bg-group: #ffffff;
  --bg-card: #ffffff;
  --bg-raise: #f7f8fa;
  --bg-hover: #eef1f6;
  --bg-sunken: #eff1f5;

  --line-1: rgba(60, 66, 80, .09);
  --line-2: rgba(60, 66, 80, .14);
  --line-strong: rgba(60, 66, 80, .22);

  --tx-1: #1b1d21;
  --tx-2: #5f6673;
  --tx-3: #979cab;

  --brand: #0a84ff;
  --brand-deep: #0060df;
  --brand-soft: #e8f2ff;
  --brand-line: rgba(10, 132, 255, .26);

  --tint-blue: #e8f2ff;    --tint-blue-fg: #0a84ff;
  --tint-green: #e6f7ef;   --tint-green-fg: #1a9c62;
  --tint-purple: #f0ecff;  --tint-purple-fg: #7a5cf0;
  --tint-teal: #e4f6f7;    --tint-teal-fg: #17939b;
  --tint-amber: #fff4e2;   --tint-amber-fg: #b76e00;

  --ok: #1a9c62;      --ok-soft: #e6f7ef;
  --warn: #e08700;    --warn-soft: #fff4e2;
  --danger: #e0343e;  --danger-soft: #fdecec;  --danger-line: rgba(224, 52, 62, .26);
  --info: #0a84ff;    --info-soft: #e8f2ff;

  --radar: #17939b;   --radar-soft: #e4f6f7;
  --audio: #7a5cf0;   --audio-soft: #f0ecff;

  --sleep-deep: #0a84ff; --sleep-light: #56b8f5;
  --sleep-rem: #7a5cf0;  --sleep-awake: #f0a63c;

  --grid-line: rgba(60, 66, 80, .07);
  --scrim: rgba(20, 24, 32, .38);
  --status-fg: #1b1d21;
}

/* ============================== 深色 ============================== */
[data-theme="dark"] {
  --bg-app: #101216;
  --bg-group: #1c1f26;
  --bg-card: #1c1f26;
  --bg-raise: #23272f;
  --bg-hover: #2a2f38;
  --bg-sunken: #171a1f;

  --line-1: rgba(255, 255, 255, .09);
  --line-2: rgba(255, 255, 255, .15);
  --line-strong: rgba(255, 255, 255, .24);

  --tx-1: #f2f3f7;
  --tx-2: #a3a9b8;
  --tx-3: #71788a;

  --brand: #3d9bff;
  --brand-deep: #6fb4ff;
  --brand-soft: rgba(10, 132, 255, .18);
  --brand-line: rgba(61, 155, 255, .34);

  --tint-blue: rgba(10, 132, 255, .18);   --tint-blue-fg: #6fb4ff;
  --tint-green: rgba(26, 156, 98, .18);   --tint-green-fg: #4ecf8d;
  --tint-purple: rgba(122, 92, 240, .18); --tint-purple-fg: #a892ff;
  --tint-teal: rgba(23, 147, 155, .18);   --tint-teal-fg: #4bc2cb;
  --tint-amber: rgba(224, 135, 0, .18);   --tint-amber-fg: #ffb645;

  --ok: #4ecf8d;      --ok-soft: rgba(26, 156, 98, .18);
  --warn: #ffb645;    --warn-soft: rgba(224, 135, 0, .18);
  --danger: #ff6b6f;  --danger-soft: rgba(224, 52, 62, .18); --danger-line: rgba(255, 107, 111, .32);
  --info: #6fb4ff;    --info-soft: rgba(10, 132, 255, .18);

  --radar: #4bc2cb;   --radar-soft: rgba(23, 147, 155, .18);
  --audio: #a892ff;   --audio-soft: rgba(122, 92, 240, .18);

  --sleep-deep: #0a84ff; --sleep-light: #56b8f5;
  --sleep-rem: #7a5cf0;  --sleep-awake: #f0a63c;

  --grid-line: rgba(255, 255, 255, .07);
  --scrim: rgba(0, 0, 0, .56);
  --status-fg: #f2f3f7;
}

/* ============================== 重置 ============================== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--tx-1);
  background: #d9dbe0;
  -webkit-font-smoothing: antialiased;
  display: grid; place-items: center;
  overflow: hidden;
}
[data-theme="dark"] body { background: #08090b; }
h1, h2, h3, h4, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
canvas { display: block; }
svg { display: block; }

/* ============================== 排版 ============================== */
.t-title { font-size: 16px; font-weight: 600; }
.t-sub { font-size: 13px; color: var(--tx-2); }
.t-cap { font-size: 12px; color: var(--tx-3); }
.t-label { font-size: 12px; font-weight: 600; color: var(--tx-3); letter-spacing: .3px; }
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--tx-2); }
.dimmer { color: var(--tx-3); }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.readout { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 26px; font-weight: 600; letter-spacing: -.7px; line-height: 1.15; }
.readout-sm { font-size: 21px; }
.readout-lg { font-size: 32px; letter-spacing: -1px; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic-sm { width: 15px; height: 15px; stroke-width: 2; }
.ic-lg { width: 26px; height: 26px; }

/* ============================== 滚动条 ============================== */
.scroll { overflow: auto; scrollbar-width: none; }
.scroll::-webkit-scrollbar { display: none; }

/* ============================== 动效 ============================== */
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .32; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(224, 52, 62, .38); } 100% { box-shadow: 0 0 0 16px rgba(224, 52, 62, 0); } }
.blink { animation: blink 1.6s var(--ease) infinite; }
.fade-up { animation: fade-up var(--dur) var(--ease) both; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ============================== 长辈模式（APP-09） ============================== */
/* 超大字体、超大图标、高对比度，仅保留核心功能 */
body.elder { font-size: 19px; }
body.elder .screen { font-size: 19px; }
body.elder .t-sub, body.elder .t-cap { font-size: 17px; }
body.elder .t-label { font-size: 17px; }
body.elder .ic { width: 26px; height: 26px; }
body.elder .ic-sm { width: 22px; height: 22px; }
body.elder .readout { font-size: 34px; }
body.elder .readout-sm { font-size: 28px; }
body.elder .readout-lg { font-size: 42px; }
body.elder .large-title { font-size: 40px; }
body.elder .btn { height: 56px; font-size: 20px; font-weight: 700; border-radius: var(--r-md); }
body.elder .btn-sm { height: 46px; font-size: 18px; }
body.elder .tabbar { height: 88px; grid-template-columns: repeat(3, 1fr); }
body.elder .tab { font-size: 16px; gap: 6px; font-weight: 600; }
body.elder .tab .ic { width: 32px; height: 32px; }
body.elder .tab[data-tab="alarms"], body.elder .tab[data-tab="live"], body.elder .tab[data-tab="chat"] { display: none; }
body.elder .qa { height: 104px; font-size: 22px; gap: 10px; }
body.elder .qa .ic { width: 36px; height: 36px; }
body.elder .elder-hero { font-size: 26px; }
body.elder .quick-actions { grid-template-columns: 1fr; }
body.elder .quick-actions { grid-template-columns: 1fr; }
body.elder .qa { height: 96px; font-size: 21px; }
body.elder .qa .ic { width: 34px; height: 34px; }
body.elder .row { padding: 16px var(--edge); }
body.elder .row-t { font-size: 19px; }
body.elder .row-d { font-size: 16px; }
body.elder .med-item { padding: 16px 0; }
body.elder .med-main b { font-size: 20px; }
body.elder .alarm { padding: 18px var(--edge); }
body.elder .a-type { font-size: 19px; }
body.elder .badge { height: 26px; font-size: 15px; padding: 0 11px; }
body.elder .chip { height: 44px; font-size: 17px; padding: 0 16px; }
body.elder .seg button { height: 38px; font-size: 17px; }
body.elder .fm-chip { height: 60px; font-size: 17px; padding-right: 16px; }
body.elder .feed { columns: 1; }
body.elder .feed-body .txt { font-size: 18px; -webkit-line-clamp: 4; }
body.elder .feed-meta .nm { font-size: 15px; }
body.elder .cal-day { font-size: 17px; }
body.elder .cal-stat .v { font-size: 20px; }
body.elder .tree-root .tr-nm { font-size: 21px; }
body.elder .tree-child .tc-nm { font-size: 16px; }
body.elder .med-time b { font-size: 17px; }
body.elder .med-main .rule { font-size: 15px; }
body.elder .topic { height: 40px; font-size: 16px; }
body.elder .ci-nm { font-size: 19px; }
body.elder .ci-sub { font-size: 16px; }
body.elder .bubble { font-size: 18px; padding: 12px 15px; }
body.elder .chat-input .ci-box { font-size: 18px; min-height: 44px; }
body.elder .chat-input .ci-btn { width: 44px; height: 44px; }
body.elder .chat-input .ci-send { height: 44px; font-size: 17px; }
body.elder .msg .av { width: 40px; height: 40px; }
body.elder .fm-chip .av { width: 40px; height: 40px; font-size: 16px; }
body.elder .stat-v .readout { font-size: 32px; }
body.elder .stat-k { font-size: 16px; }
body.elder .stat-d { font-size: 15px; }
body.elder .todo-title { font-size: 18px; }
body.elder .todo-desc { font-size: 16px; }
