:root {
  --bg-0: #0b1026;
  --bg-1: #151a3d;
  --ink: #f3f4fb;
  --ink-2: rgba(243, 244, 251, 0.72);
  --ink-3: rgba(243, 244, 251, 0.45);
  --line: rgba(255, 255, 255, 0.09);
  --card: rgba(255, 255, 255, 0.06);
  --card-2: rgba(255, 255, 255, 0.1);
  --gold: #f6c453;
  --gold-2: #ffd978;
  --mint: #6fe3a5;
  --coral: #ff8a7a;
  --radius: 20px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(120% 80% at 50% -10%, #2a2a66 0%, #151a3d 45%, #070a1c 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; }
[hidden] { display: none !important; }

/* ---------- 星空 ---------- */
.sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.sky i {
  position: absolute; display: block; border-radius: 50%; background: #fff;
  animation: twinkle var(--d, 4s) ease-in-out infinite alternate; animation-delay: var(--delay, 0s);
}
@keyframes twinkle { from { opacity: 0.08; transform: scale(0.8); } to { opacity: 0.85; transform: scale(1.15); } }

/* ---------- 外框 ---------- */
.phone {
  position: relative; z-index: 1; max-width: 520px; height: 100vh; height: 100dvh;
  margin: 0 auto; display: flex; flex-direction: column;
}
@media (min-width: 640px) {
  .phone {
    height: min(100dvh - 48px, 920px); width: 100%;
    border-radius: 36px; border: 1px solid rgba(255, 255, 255, 0.08); overflow: hidden;
    background: linear-gradient(180deg, #171d4a 0%, #0b1026 100%);
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }
}

.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 22px 6px;
}
.topbar__title { font-size: 17px; font-weight: 600; letter-spacing: 0.06em; }
.topbar__date { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- 页面切换 ---------- */
.views { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.views::-webkit-scrollbar { display: none; }
.view { padding: 6px 20px 28px; }
.view.enter { animation: viewIn 0.28s cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view__title { font-size: 24px; font-weight: 600; margin: 8px 2px 14px; }

.tabbar {
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(11, 16, 38, 0.72);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.tab {
  appearance: none; border: 0; background: transparent; color: var(--ink-3);
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 0 6px; border-radius: 14px; cursor: pointer; transition: color 0.2s;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-selected="true"] { color: var(--gold); }
.tab:focus-visible, .btn:focus-visible, .cta:focus-visible, .seg button:focus-visible, .switch:focus-visible, .cal__day:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- 首页 · 月亮与倒计时 ---------- */
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; }
.moon-wrap { width: 176px; height: 176px; }
.moon { width: 100%; height: 100%; animation: float 6s ease-in-out infinite; filter: drop-shadow(0 0 22px rgba(246, 196, 83, 0.22)); }
.moon #mshadow { transition: cx 0.9s cubic-bezier(0.2, 0.7, 0.2, 1); }
.moon #mring { transition: stroke-dashoffset 0.9s cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.hero__text { display: flex; flex-direction: column; align-items: center; min-height: 150px; }
.hero__text.enter { animation: viewIn 0.35s cubic-bezier(0.2, 0.7, 0.2, 1); }
.hero__eyebrow { font-size: 14px; color: var(--ink-2); letter-spacing: 0.02em; }
.hero__big {
  display: flex; align-items: baseline; justify-content: center; gap: 4px; margin-top: 6px;
  font-size: 46px; font-weight: 600; line-height: 1.15; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.hero__big span { font-size: 13px; color: var(--ink-3); margin: 0 6px 0 2px; }
.hero__big--text { font-size: 32px; letter-spacing: 0.02em; }
.hero__clock { font-size: 46px; letter-spacing: 0.02em; }
.hero__sub { margin-top: 8px; font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.hero__live { margin-top: 4px; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.hero__undo {
  appearance: none; border: 0; background: transparent; color: var(--ink-3); font-size: 13px;
  margin-top: 10px; padding: 4px 10px; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px;
}
.hero__undo:hover { color: var(--ink-2); }

.hero[data-phase="soon"] .hero__eyebrow, .hero[data-phase="bedtime"] .hero__eyebrow { color: var(--gold); }
.hero[data-phase="soon"] .hero__big, .hero[data-phase="bedtime"] .hero__big { color: var(--gold-2); }
.hero[data-phase="bedtime"] .moon { filter: drop-shadow(0 0 40px rgba(246, 196, 83, 0.5)); }
.hero[data-phase="late"] .hero__eyebrow, .hero[data-phase="late"] .hero__big { color: var(--coral); }
.hero[data-phase="done-ok"] .hero__big { color: var(--mint); }
.hero[data-phase="done-late"] .hero__big { color: var(--coral); }

/* ---------- 主按钮 ---------- */
.cta {
  display: block; width: 100%; margin-top: 20px; padding: 18px 20px; border: 0; border-radius: var(--radius);
  font-size: 18px; font-weight: 600; color: #1b1500; cursor: pointer;
  background: linear-gradient(180deg, #ffd978, #f0b03a);
  box-shadow: 0 10px 30px rgba(246, 196, 83, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.12s, box-shadow 0.3s, background 0.3s;
}
.cta:active { transform: scale(0.98); }
.cta--bedtime { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 10px 30px rgba(246, 196, 83, 0.3), 0 0 0 0 rgba(246, 196, 83, 0.45); }
  50% { box-shadow: 0 10px 30px rgba(246, 196, 83, 0.5), 0 0 0 16px rgba(246, 196, 83, 0); }
}
.cta--late { background: linear-gradient(180deg, #ffb3a7, #f08373); box-shadow: 0 10px 30px rgba(255, 138, 122, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.cta--ghost { background: var(--card-2); color: var(--ink); border: 1px solid var(--line); box-shadow: none; font-weight: 500; }

/* ---------- 卡片与统计 ---------- */
.card { margin-top: 16px; padding: 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.card__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 10px; margin-bottom: 14px; }
.card__title { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.card__sub { font-size: 12px; color: var(--ink-3); }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat-row--2 { grid-template-columns: repeat(2, 1fr); }
.stat { padding: 14px 10px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); text-align: center; }
.stat b { display: block; font-size: 26px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat b small { font-size: 12px; font-weight: 400; color: var(--ink-3); margin-left: 3px; }
.stat span { display: block; margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.stat--gold b { color: var(--gold); }

/* ---------- 柱状图 ---------- */
.bars { position: relative; display: grid; grid-template-columns: repeat(14, 1fr); gap: 5px; }
.bars--dense { grid-template-columns: repeat(30, 1fr); gap: 2px; }
.bars::before { content: ""; position: absolute; left: 0; right: 0; top: 44px; height: 1px; background: var(--line); }
.bar { display: flex; flex-direction: column; align-items: center; }
.bar__col { position: relative; width: 100%; height: 88px; }
.bar__col i { position: absolute; left: 18%; right: 18%; border-radius: 3px; }
.bars--dense .bar__col i { left: 10%; right: 10%; }
.bar__col i.up { bottom: 50%; background: var(--mint); }
.bar__col i.down { top: 50%; background: var(--coral); }
.bar__col i.none { top: calc(50% - 1px); height: 2px; left: 28%; right: 28%; background: rgba(255, 255, 255, 0.14); }
.bar em { margin-top: 6px; font-style: normal; font-size: 10px; color: var(--ink-3); font-variant-numeric: tabular-nums; height: 12px; }
.bar em:empty { visibility: hidden; }

/* ---------- 日历 ---------- */
.cal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal__title { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.btn--icon { width: 36px; height: 36px; padding: 0; font-size: 22px; line-height: 1; border-radius: 50%; }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal__wd { text-align: center; font-size: 11px; color: var(--ink-3); padding: 6px 0; }
.cal__day {
  position: relative; aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center;
  font-size: 14px; color: var(--ink-2); background: transparent; border: 1px solid transparent;
  cursor: pointer; font-variant-numeric: tabular-nums; transition: background 0.15s;
}
.cal__day:hover { background: var(--card-2); }
.cal__day:empty { pointer-events: none; }
.cal__day--out { opacity: 0.25; pointer-events: none; }
.cal__day--today { border-color: rgba(246, 196, 83, 0.55); color: var(--gold); }
.cal__day--ok { background: rgba(111, 227, 165, 0.16); color: var(--mint); font-weight: 600; }
.cal__day--late { background: rgba(255, 138, 122, 0.14); color: var(--coral); }
.cal__day--ok::after, .cal__day--late::after { content: ""; position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.legend { display: flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 12px; color: var(--ink-3); }
.legend .dot { margin-left: 8px; }
.legend .dot:first-child { margin-left: 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--ink-3); }
.dot--ok { background: var(--mint); border-color: var(--mint); }
.dot--late { background: var(--coral); border-color: var(--coral); }

/* ---------- 表单 ---------- */
.group-title { margin: 22px 4px 8px; font-size: 12px; color: var(--ink-3); letter-spacing: 0.12em; }
.group-title:first-child { margin-top: 0; }
.card .row { padding: 14px 0; }
.card .row:first-child { padding-top: 4px; }
.card .row:last-child { padding-bottom: 4px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row__label { font-size: 15px; }
.row__hint { font-size: 12px; color: var(--ink-3); margin-top: 3px; line-height: 1.5; }
.row--stack { flex-direction: column; align-items: stretch; gap: 10px; }

.seg { display: flex; padding: 4px; border-radius: 14px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); gap: 4px; }
.seg button {
  flex: 1; appearance: none; border: 0; background: transparent; color: var(--ink-2);
  font-size: 13px; padding: 8px 4px; border-radius: 10px; cursor: pointer; font-variant-numeric: tabular-nums;
  transition: background 0.15s, color 0.15s;
}
.seg button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.12); color: var(--ink); font-weight: 600; }

.switch {
  position: relative; flex: none; width: 48px; height: 28px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.14); border: 0; cursor: pointer; transition: background 0.2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); transition: transform 0.2s;
}
.switch[aria-checked="true"] { background: var(--gold); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

input[type="time"] {
  appearance: none; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); color: var(--ink);
  font: inherit; font-size: 18px; font-weight: 600; padding: 8px 12px; border-radius: 12px;
  font-variant-numeric: tabular-nums; color-scheme: dark; cursor: pointer;
}
input[type="time"]:focus { outline: 2px solid var(--gold); outline-offset: 2px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card-2); color: var(--ink);
  font-size: 14px; font-weight: 500; padding: 10px 14px; border-radius: 12px; cursor: pointer;
  transition: transform 0.12s, background 0.15s; white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.14); }
.btn:active { transform: scale(0.97); }
.btn--text { background: transparent; border-color: transparent; color: var(--ink-3); padding: 6px 8px; }
.btn--danger { color: var(--coral); }
.btn--primary { background: linear-gradient(180deg, #ffd978, #f0b03a); color: #1b1500; border: 0; font-weight: 600; }
.btn--primary:hover { background: linear-gradient(180deg, #ffe08f, #f5ba46); }
.foot { margin: 22px 8px 0; font-size: 12px; color: var(--ink-3); text-align: center; line-height: 1.7; }

/* ---------- 提示条 ---------- */
.banner {
  display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 14px;
  border-radius: var(--radius); background: rgba(246, 196, 83, 0.08); border: 1px solid rgba(246, 196, 83, 0.25);
}
.banner__text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.banner__text b { font-size: 14px; }
.banner__text span { font-size: 12px; color: var(--ink-3); }

.notice {
  position: absolute; left: 12px; right: 12px; top: calc(10px + env(safe-area-inset-top)); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; border-radius: 18px;
  background: linear-gradient(135deg, #2a2f6a, #1a1f4a); border: 1px solid rgba(246, 196, 83, 0.35);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45); transform: translateY(-120%); opacity: 0;
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.3s;
}
.notice.show { transform: none; opacity: 1; }
.notice__icon { font-size: 28px; }
.notice__text { flex: 1; }
.notice__title { font-size: 15px; font-weight: 600; color: var(--gold-2); }
.notice__body { font-size: 13px; color: var(--ink-2); margin-top: 2px; line-height: 1.5; }
.notice__close { appearance: none; border: 0; background: transparent; color: var(--ink-3); font-size: 24px; line-height: 1; cursor: pointer; padding: 4px; }

/* ---------- 底部弹层 ---------- */
.sheet-backdrop { position: absolute; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.5); animation: fadeIn 0.2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 21;
  padding: 12px 22px calc(24px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0;
  background: #171c44; border: 1px solid var(--line); border-bottom: 0;
  animation: sheetIn 0.3s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.sheet__grip { width: 40px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.18); margin: 0 auto 14px; }
.sheet__head { display: flex; align-items: flex-start; justify-content: space-between; }
.sheet__title { font-size: 18px; font-weight: 600; }
.sheet__sub { font-size: 13px; color: var(--ink-3); margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.sheet__body { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.sheet__body label { font-size: 15px; }
.sheet__hint { margin-top: 12px; font-size: 12px; color: var(--ink-3); line-height: 1.6; }
.sheet__actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet__actions .btn { flex: 1; padding: 14px; font-size: 16px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: var(--card-2); color: var(--ink-2); }
.tag--ok { background: rgba(111, 227, 165, 0.16); color: var(--mint); }
.tag--late { background: rgba(255, 138, 122, 0.16); color: var(--coral); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- 轻提示与撒花 ---------- */
.toast {
  position: absolute; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 31;
  transform: translate(-50%, 16px); padding: 10px 16px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.94); color: #151a3d; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; white-space: nowrap; transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.fx { position: absolute; inset: 0; z-index: 25; pointer-events: none; overflow: hidden; }
.fx i { position: absolute; width: 8px; height: 8px; border-radius: 2px; animation: burst 0.9s ease-out forwards; }
@keyframes burst {
  from { opacity: 1; transform: translate(0, 0) rotate(0) scale(1); }
  to { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(0.4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
