:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --text-2: #6b7280;
  --indigo: #4f46e5;
  --indigo-2: #6366f1;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --radius: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
}

/* ── 头部 ── */
.header h1 { font-size: 22px; font-weight: 700; }
.header .date { margin-top: 2px; font-size: 13px; color: var(--text-2); }

/* ── 今日主卡 ── */
.hero {
  position: relative;
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  color: #fff;
  text-align: center;
  background: linear-gradient(135deg, var(--indigo-2), var(--indigo));
  box-shadow: 0 12px 32px rgba(79, 70, 229, 0.24);
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

.hero.trend-green  { background: linear-gradient(135deg, #22c55e, #16a34a); box-shadow: 0 12px 32px rgba(34, 197, 94, 0.24); }
.hero.trend-yellow { background: linear-gradient(135deg, #f59e0b, #d97706); box-shadow: 0 12px 32px rgba(245, 158, 11, 0.24); }
.hero.trend-red    { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 12px 32px rgba(239, 68, 68, 0.24); }

.alert {
  position: absolute;
  top: 14px;
  right: 16px;
  max-width: 58%;
  font-size: 22px;
  line-height: 1.2;
  text-align: right;
  overflow-wrap: anywhere;
  animation: pulse 1.2s ease infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.hero-label { font-size: 14px; opacity: 0.85; }

.hero-count {
  font-size: 88px;
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.hero-count.bump { animation: bump 0.35s ease; }

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.hero-unit { font-size: 14px; opacity: 0.85; margin-top: -4px; }

.hero-message { margin-top: 12px; font-size: 14px; font-weight: 600; opacity: 0.92; }

/* ── 记录按钮 ── */
.tap-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 6px 20px rgba(31, 41, 55, 0.08);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.tap-btn:active { transform: scale(0.97); }

.tap-btn.is-loading { opacity: 0.7; pointer-events: none; }

.tap-btn-plus {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--indigo-2), var(--indigo));
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tap-btn-text { font-size: 16px; font-weight: 700; }

/* ── 通用卡片 ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 6px 20px rgba(31, 41, 55, 0.06);
}

.card-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 12px; }

/* ── 渐变色标尺 ── */
.scale-bar {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #4f46e5, #16a34a 60%, #d97706 80%, #dc2626);
}

.scale-labels {
  position: relative;
  height: 16px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-2);
}

.scale-labels span { position: absolute; transform: translateX(-50%); }
.scale-labels span:nth-child(1) { left: 0; transform: none; }
.scale-labels span:nth-child(2) { left: 60%; }
.scale-labels span:nth-child(3) { left: 80%; }
.scale-labels span:nth-child(4) { right: 0; transform: none; }

.legend-tip { margin-top: 8px; font-size: 12px; color: var(--text-2); }

/* ── 柱状图 ── */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
}

.bar-track {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bar {
  width: 100%;
  max-width: 22px;
  border-radius: 6px 6px 3px 3px;
  background: #c7d2fe;
  min-height: 3px;
  transition: height 0.35s ease;
}

.bar.has-data { background: linear-gradient(180deg, var(--indigo-2), var(--indigo)); }
.bar.is-today { background: linear-gradient(180deg, #34d399, #10b981); }

.bar-label { font-size: 10px; color: var(--text-2); white-space: nowrap; }
.bar-label.is-today { color: var(--indigo); font-weight: 700; }

/* ── 底部 ── */
.footer { text-align: center; font-size: 11px; color: var(--text-2); padding-top: 4px; }

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(48px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(31, 41, 55, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 99;
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
