/* 健康打卡 — App 风格样式（支持深色模式） */

:root {
  --bg: #f2f4f9;
  --surface: #ffffff;
  --border: #e6e9f2;
  --text-1: #1a2130;
  --text-2: #8189a0;
  --primary: #4f7cff;
  --primary-2: #6c5ce7;
  --ok: #22c07a;
  --ok-soft: #e2f8ee;
  --danger: #e5484d;
  --hero-grad: linear-gradient(135deg, #4f7cff 0%, #6c5ce7 60%, #22c07a 130%);
  --shadow: 0 6px 24px rgba(46, 66, 132, .08);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1320;
    --surface: #1a2032;
    --border: #27304a;
    --text-1: #e8ebf5;
    --text-2: #8b93ad;
    --ok-soft: #173427;
    --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: -apple-system, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}

.hidden { display: none !important; }
.empty { text-align: center; color: var(--text-2); padding: 44px 16px; font-size: 13.5px; line-height: 1.9; }
.empty-emoji { font-size: 40px; margin-bottom: 8px; }

/* ---------- 登录 ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(160deg, #eef2ff 0%, #f2f4f9 50%, #e9faf1 100%); }
@media (prefers-color-scheme: dark) {
  .login { background: linear-gradient(160deg, #141a2e 0%, #0f1320 55%, #101d1a 100%); }
}
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; padding: 40px 28px; text-align: center; box-shadow: var(--shadow); }
.login-logo { font-size: 46px; margin-bottom: 10px; }
.login-card h1 { font-size: 21px; margin-bottom: 4px; }
.login-card p { color: var(--text-2); font-size: 13px; margin-bottom: 22px; }
.login-card input { width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 14px;
  font-size: 15px; outline: none; text-align: center; background: var(--bg); color: var(--text-1); }
.login-card input:focus { border-color: var(--primary); }
.err { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 10px; }

/* ---------- Hero 渐变头部 ---------- */
.hero { background: var(--hero-grad); color: #fff; padding: calc(14px + env(safe-area-inset-top)) 20px 58px;
  border-radius: 0 0 28px 28px; }
.hero-row { display: flex; align-items: flex-start; justify-content: space-between; }
.hero-greet { font-size: 19px; font-weight: 700; }
.hero-date { font-size: 12.5px; opacity: .85; margin-top: 2px; }
.hero-logout { border: none; background: rgba(255,255,255,.18); color: #fff; width: 34px; height: 34px;
  border-radius: 50%; font-size: 15px; cursor: pointer; }

/* ---------- 主区 ---------- */
main { max-width: 520px; margin: -40px auto 0; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }

/* ---------- 今日：圆环卡 ---------- */
.ring-card { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow);
  padding: 18px; display: flex; align-items: center; gap: 16px; }
.ring { width: 104px; height: 104px; flex-shrink: 0; transform: rotate(-90deg); }
.ring-bg, .ring-fg { fill: none; stroke-width: 10; stroke-linecap: round; }
.ring-bg { stroke: var(--border); }
.ring-fg { stroke: url(#ringGrad); stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset .5s cubic-bezier(.22,1,.36,1); }
.ring-center { position: absolute; width: 104px; height: 104px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; }
.ring-card { position: relative; }
.ring-card > .ring-center { position: absolute; left: 18px; top: 18px; }
.ring-center b { font-size: 20px; }
.ring-center span { font-size: 11px; color: var(--text-2); }
.ring-side { flex: 1; }
.ring-title { font-weight: 700; font-size: 15.5px; }
.ring-sub { color: var(--text-2); font-size: 12.5px; margin-top: 3px; }

/* ---------- 日期导航 ---------- */
.date-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 16px 0 12px;
  font-weight: 600; font-size: 14.5px; }
.nav-btn { border: none; background: var(--surface); color: var(--text-2); width: 32px; height: 32px;
  border-radius: 10px; font-size: 17px; cursor: pointer; box-shadow: var(--shadow); }
.nav-btn:active { color: var(--primary); }

/* ---------- 习惯卡 ---------- */
.habit-row { display: flex; align-items: center; gap: 13px; background: var(--surface);
  border-radius: var(--radius); padding: 14px 15px; margin-bottom: 10px; box-shadow: var(--shadow);
  animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.habit-emoji { width: 46px; height: 46px; border-radius: 14px; display: flex; align-items: center;
  justify-content: center; font-size: 23px; flex-shrink: 0; }
.habit-info { flex: 1; min-width: 0; }
.habit-name { font-weight: 600; font-size: 15px; }
.habit-note { color: var(--text-2); font-size: 12.5px; margin-top: 2px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.habit-streak { display: inline-block; font-size: 11px; color: #ff7a1a; background: rgba(255,122,26,.12);
  border-radius: 8px; padding: 1px 7px; margin-left: 6px; font-weight: 600; vertical-align: 1px; }
.habit-note-btn { border: none; background: none; color: var(--text-2); font-size: 17px; cursor: pointer;
  padding: 6px; }
.habit-check { width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--border);
  background: none; font-size: 20px; color: transparent; cursor: pointer; flex-shrink: 0;
  transition: all .18s cubic-bezier(.34,1.56,.64,1); }
.habit-check.on { background: var(--ok); border-color: var(--ok); color: #fff; transform: scale(1.06); }
.habit-check:active { transform: scale(.92); }

/* ---------- 日历 ---------- */
.cal-card { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 14px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
#cal-head { margin-bottom: 8px; }
#cal-head div { text-align: center; color: var(--text-2); font-size: 12px; padding: 4px 0; }
.cal-cell { aspect-ratio: 1; border-radius: 12px; background: var(--bg); display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 13px; cursor: pointer; border: 1.5px solid transparent; }
.cal-cell.out { opacity: 0; pointer-events: none; }
.cal-cell.today { border-color: var(--primary); font-weight: 700; }
.cal-cell.part { background: var(--ok-soft); }
.cal-cell.all { background: var(--ok); color: #fff; font-weight: 700; }
.cal-detail { background: var(--surface); border-radius: var(--radius); padding: 15px; margin-top: 12px;
  font-size: 13.5px; box-shadow: var(--shadow); }
.cal-detail h4 { margin-bottom: 8px; font-size: 14px; }
.cal-detail li { list-style: none; padding: 3px 0; }
.cal-detail .miss { color: var(--text-2); }
.cal-legend { display: flex; gap: 16px; justify-content: center; color: var(--text-2); font-size: 11.5px;
  margin: 12px 0 4px; }
.cal-legend .lg { display: inline-block; width: 11px; height: 11px; border-radius: 4px; margin-right: 4px;
  vertical-align: -1px; }
.lg-none { background: var(--border); }
.lg-part { background: var(--ok-soft); border: 1px solid var(--ok); }
.lg-all { background: var(--ok); }

/* ---------- 统计 ---------- */
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow); }
.stat-top { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 12px; }
.stat-nums { display: flex; gap: 8px; }
.stat-num { flex: 1; background: var(--bg); border-radius: 12px; padding: 11px 0; text-align: center; }
.stat-num b { display: block; font-size: 20px; color: var(--primary); }
.stat-num.streak b { color: #ff7a1a; }
.stat-num span { font-size: 11px; color: var(--text-2); }

/* ---------- 管理 ---------- */
.habit-form { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px; }
.emoji-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.emoji-row button { border: 1.5px solid var(--border); background: var(--bg); border-radius: 10px;
  font-size: 19px; width: 40px; height: 40px; cursor: pointer; }
.emoji-row button.on { border-color: var(--primary); background: var(--bg); transform: scale(1.08); }
.habit-form input { width: 100%; padding: 11px 13px; border: 1.5px solid var(--border); border-radius: 12px;
  font-size: 14px; outline: none; background: var(--bg); color: var(--text-1); margin-bottom: 10px; }
.habit-form input:focus { border-color: var(--primary); }
.manage-item { display: flex; align-items: center; gap: 10px; background: var(--surface);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.manage-item .habit-name { flex: 1; }
.manage-item .remind-tag { font-size: 11px; color: var(--primary); background: var(--ok-soft);
  border-radius: 6px; padding: 2px 6px; }
.manage-item .op { border: none; background: none; cursor: pointer; font-size: 15px; padding: 4px 6px;
  color: var(--text-2); }
.manage-item.archived { opacity: .45; }

/* ---------- 底部导航 ---------- */
.bottombar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 520px;
  background: var(--surface); border-top: 1px solid var(--border); display: flex;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 40; }
.btab { flex: 1; border: none; background: none; color: var(--text-2); font-size: 11px; cursor: pointer;
  padding: 4px 0; border-radius: 12px; }
.btab .bicon { display: block; font-size: 21px; margin-bottom: 1px; filter: grayscale(1) opacity(.55);
  transition: all .15s; }
.btab.active { color: var(--primary); font-weight: 600; }
.btab.active .bicon { filter: none; transform: translateY(-2px) scale(1.12); }

/* ---------- 按钮 / 弹层 / Toast ---------- */
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-1);
  border-radius: 13px; padding: 11px 18px; font-size: 14px; cursor: pointer; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); border-color: var(--danger); }

.sheet { position: fixed; inset: 0; background: rgba(10,14,25,.45); z-index: 50; display: flex;
  align-items: flex-end; justify-content: center; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet-box { background: var(--surface); width: 100%; max-width: 520px; border-radius: 22px 22px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); animation: up .22s cubic-bezier(.22,1,.36,1); }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.sheet-box .ttl { font-weight: 700; margin-bottom: 12px; display: block; }
.sheet-box textarea { width: 100%; height: 90px; border: 1.5px solid var(--border); border-radius: 12px;
  padding: 10px 12px; font-size: 14px; resize: none; outline: none; background: var(--bg); color: var(--text-1); }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: rgba(28,35,51,.92);
  color: #fff; padding: 9px 18px; border-radius: 20px; font-size: 13.5px; z-index: 99; }
