:root {
  --bg-top: #fff8f1;
  --bg-bottom: #ffe7d9;
  --card: #ffffff;
  --ink: #4a3a32;
  --muted: #a2857a;
  /* 水色（杯子、柱状图） */
  --blue: #7ec8e3;
  --blue-light: #a9ddf0;
  --blue-deep: #5aafd0;
  /* 暖色主色（按钮、进度、强调） */
  --peach: #ff9e7a;
  --peach-light: #ffc4a8;
  --peach-deep: #f4775a;
  --pink: #ffb6c7;
  --honey: #ffd98e;
  --shadow: 0 12px 30px rgba(206, 140, 108, 0.18);
  --shadow-soft: 0 6px 18px rgba(206, 140, 108, 0.12);
  --radius: 24px;
}

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

/* 关键：类里的 display 会盖掉 hidden 属性，这里统一兜住 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei',
    'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

/* ------------------------------- 骨架屏 / 异常态 ------------------------------- */

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
}

.loader-drop {
  font-size: 44px;
  animation: bob 1.4s ease-in-out infinite;
}

.big-emoji {
  font-size: 52px;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* ---------------------------------- 布局 ---------------------------------- */

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 0 calc(env(safe-area-inset-bottom) + 92px);
}

/* ---------------------------------- 封面 ---------------------------------- */

.cover {
  position: relative;
  height: 52vh;
  min-height: 360px;
  max-height: 560px;
  overflow: hidden;
  background: #3a2c24;
}

.cover-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 18%;
}

.cover-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(26, 17, 12, 0.5) 0%,
    rgba(26, 17, 12, 0.04) 32%,
    rgba(26, 17, 12, 0.55) 62%,
    rgba(26, 17, 12, 0.84) 100%
  );
}

.cover .topbar {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: calc(env(safe-area-inset-top) + 14px) 20px 0;
}

.cover .brand h1 {
  color: #fff;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}

.cover .today {
  color: rgba(255, 255, 255, 0.8);
}

.cover-bottom {
  position: absolute;
  z-index: 2;
  left: 20px;
  right: 20px;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

.cover-headline {
  font-size: clamp(31px, 9.6vw, 46px);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.42);
}

.cover-headline span {
  display: block;
}

.cover-headline span:nth-child(1) {
  animation: lineUp 0.62s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.cover-headline span:nth-child(2) {
  animation: lineUp 0.62s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.cover-headline span:nth-child(3) {
  animation: lineUp 0.62s cubic-bezier(0.22, 1, 0.36, 1) 0.16s both;
}

@keyframes lineUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.cover-stats {
  display: flex;
  gap: 8px;
}

.cover-stat {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.26);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
}

.cover-stat b {
  font-size: 19px;
  font-weight: 800;
}

.cover-stat span {
  font-size: 11.5px;
  opacity: 0.86;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-drop {
  font-size: 22px;
}

.brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.today {
  font-size: 13px;
  color: var(--muted);
}

.content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px 0;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 16px 0;
  padding: 12px 14px;
  border-radius: 18px;
  background: #fff4e6;
  border: 1px solid #ffdcb8;
  color: #a9682f;
  font-size: 13px;
}

.banner-btn {
  flex: none;
  padding: 7px 12px;
  border-radius: 12px;
  background: var(--peach);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

/* ---------------------------------- 进度环 ---------------------------------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 24px;
  padding-bottom: 22px;
  transition: background 0.8s ease;
}

.hero.morning {
  background: linear-gradient(180deg, #fffdf6, #fff6ea);
}

.hero.evening {
  background: linear-gradient(180deg, #fffaf7, #fdecea);
}

.hero.shimmer {
  position: relative;
  overflow: hidden;
}

.hero.shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 55%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.8), transparent);
  animation: shimmer 0.95s ease;
}

@keyframes shimmer {
  from {
    transform: translateX(-120%);
  }
  to {
    transform: translateX(240%);
  }
}

.ring-wrap {
  position: relative;
  width: 208px;
  height: 208px;
}

.ring {
  width: 208px;
  height: 208px;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: #ffeadf;
  stroke-width: 16;
}

.ring-fill {
  fill: none;
  stroke: url(#ringGradient);
  stroke-width: 16;
  stroke-linecap: round;
  stroke-dasharray: 477.5;
  stroke-dashoffset: 477.5;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.ring-wrap.pop .ring {
  animation: ringPop 0.5s ease;
}

@keyframes ringPop {
  0% {
    transform: rotate(-90deg) scale(1);
  }
  45% {
    transform: rotate(-90deg) scale(1.04);
  }
  100% {
    transform: rotate(-90deg) scale(1);
  }
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.ring-center .big {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-size: 54px;
  font-weight: 800;
  letter-spacing: -2px;
  color: var(--peach-deep);
}

.ring-center .unit {
  font-size: 18px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
}

.ring-center .sub {
  font-size: 13px;
  color: var(--muted);
}

.ring-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe7b8, #ffd98e);
  color: #a9682f;
  font-size: 12px;
  font-weight: 700;
  animation: bob 2s ease-in-out infinite;
}

.line {
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  padding: 0 8px;
}

.evening-note {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.cups-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}

.cup {
  width: 20px;
  height: 24px;
  opacity: 0.35;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.cup.filled {
  opacity: 1;
  transform: translateY(-2px);
}

.cup-water {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.cup .bubble {
  fill: rgba(255, 255, 255, 0.9);
  opacity: 0;
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

.cup.just-filled .bubble {
  animation: bubbleUp 0.9s ease-out;
}

@keyframes bubbleUp {
  0% {
    opacity: 0;
    transform: translateY(3px) scale(0.6);
  }
  35% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translateY(-8px) scale(1);
  }
}

.cups-row.pop .cup {
  animation: cupPop 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cupPop {
  0% {
    transform: translateY(0) scale(1);
  }
  40% {
    transform: translateY(-6px) scale(1.16);
  }
  100% {
    transform: translateY(-2px) scale(1);
  }
}

/* ---------------------------------- 按钮 ---------------------------------- */

.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.actions-sub {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}

.hint-text {
  font-size: 12.5px;
  color: var(--muted);
}

.btn-mini {
  padding: 7px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
  font-size: 13px;
  box-shadow: var(--shadow-soft);
}

.btn-mini:active {
  transform: scale(0.96);
}

.btn-primary {
  width: 100%;
  padding: 18px 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--peach-light), var(--peach-deep));
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(244, 119, 90, 0.32);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 6px 14px rgba(244, 119, 90, 0.26);
}

.btn-primary .plus {
  font-size: 22px;
  margin-right: 6px;
}

.btn-primary.small,
.btn-ghost.small {
  width: auto;
  padding: 11px 18px;
  font-size: 15px;
  border-radius: 14px;
}

.btn-primary.big {
  padding: 20px;
  font-size: 18px;
}

.btn-ghost {
  width: 100%;
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  font-size: 14px;
  box-shadow: var(--shadow-soft);
  text-align: center;
  text-decoration: none;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* ---------------------------------- 统计 ---------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.stat {
  text-align: center;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-emoji {
  font-size: 20px;
}

.stat-value {
  display: inline-block;
  font-size: 24px;
  font-weight: 800;
  color: var(--peach-deep);
}

.stat.bump .stat-value {
  animation: numBump 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes numBump {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.stat-unit {
  font-size: 13px;
  color: var(--muted);
  margin-left: 2px;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
}

/* ---------------------------------- 图表 ---------------------------------- */

.chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  height: 128px;
  padding-top: 6px;
}

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

.bar {
  width: 100%;
  max-width: 26px;
  border-radius: 10px;
  background: #fdeee4;
  min-height: 6px;
  transition: height 0.5s ease;
}

.bar.level-1 {
  background: linear-gradient(180deg, #cdeaf7, #a9ddf0);
}

.bar.level-2 {
  background: linear-gradient(180deg, #a9ddf0, #7ec8e3);
}

.bar.level-3 {
  background: linear-gradient(180deg, #ffcede, #ff9fba);
}

.bar-count {
  font-size: 11px;
  color: var(--muted);
}

.bar-label {
  font-size: 11px;
  color: var(--muted);
}

.chart-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ---------------------------------- 纪念日 ---------------------------------- */

.anniversary {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #fff2f5, #ffe8ef);
  box-shadow: 0 12px 30px rgba(224, 120, 143, 0.16);
}

.anni-heart {
  font-size: 22px;
}

.anni-main {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.anni-main b {
  font-size: 26px;
  font-weight: 800;
  color: #e0788f;
  letter-spacing: -0.5px;
}

.anni-main span {
  font-size: 13px;
  color: var(--muted);
}

.anni-sub {
  margin-left: auto;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

/* ---------------------------------- 入场 ---------------------------------- */

.view.enter > * {
  animation: cardIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------------------------------- 设置项 ---------------------------------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px 7px 14px;
  border-radius: 999px;
  background: #fff1e7;
  color: #c4633f;
  font-size: 14px;
  font-weight: 600;
}

.chip button {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(244, 119, 90, 0.16);
  color: #c4633f;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type='time'],
input[type='date'],
input[type='number'],
input[type='text'] {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #f2ded1;
  background: #fffdfb;
  width: 100%;
  min-width: 0;
}

input[type='time'] {
  max-width: 140px;
}

input[type='date'] {
  max-width: 190px;
}

.preset {
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
}

.preset summary {
  cursor: pointer;
  color: #c4633f;
  font-weight: 600;
}

.preset-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.preset-form label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.preset-form input[type='number'] {
  max-width: 70px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-size: 14px;
  color: var(--muted);
}

.switch input {
  width: 20px;
  height: 20px;
  accent-color: var(--peach);
  flex: none;
}

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 15px;
}

.field > span:first-child {
  flex: none;
  color: var(--muted);
  font-size: 14px;
}

.field > span:last-child {
  flex: none;
  color: var(--muted);
  font-size: 14px;
}

.row {
  margin-bottom: 12px;
}

.row-label {
  font-size: 15px;
  font-weight: 700;
}

.row-hint {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.6;
}

.footer-note {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 12px 0;
}

/* ---------------------------------- 底部导航 ---------------------------------- */

.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  z-index: 20;
}

.tab {
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}

.tab.is-active {
  background: linear-gradient(135deg, var(--peach-light), var(--peach));
  color: #fff;
}

/* ---------------------------------- 弹层 ---------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 58, 50, 0.42);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 40;
}

.sheet {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: 28px;
  padding: 24px 20px calc(env(safe-area-inset-bottom) + 22px);
  box-shadow: 0 20px 40px rgba(74, 58, 50, 0.24);
  text-align: center;
  animation: sheetUp 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes sheetUp {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.sheet-emoji {
  font-size: 40px;
}

.sheet h2 {
  font-size: 19px;
  margin: 8px 0 10px;
}

.sheet .btn-primary {
  margin-top: 18px;
}

.sheet .btn-ghost {
  margin-top: 10px;
}

.ob-body {
  font-size: 14.5px;
  color: var(--muted);
  text-align: left;
  line-height: 1.75;
}

.ob-body ol {
  margin: 0;
  padding-left: 20px;
}

.ob-body li {
  margin-bottom: 6px;
}

.ob-body .kbd {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 7px;
  background: #fff1e7;
  color: #c4633f;
  font-size: 13px;
  font-weight: 700;
}

/* ---------------------------------- 其它 ---------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 92px);
  transform: translateX(-50%);
  padding: 11px 20px;
  border-radius: 999px;
  background: rgba(74, 58, 50, 0.92);
  color: #fff;
  font-size: 14px;
  z-index: 60;
  animation: toastIn 0.25s ease;
  max-width: 86vw;
  text-align: center;
}

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

.confetti {
  position: fixed;
  top: 42%;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  z-index: 50;
  pointer-events: none;
  animation: confettiFall 1s ease-out forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), 220px) rotate(var(--rot));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ring-fill,
  .bar,
  .cup {
    transition: none;
  }
  .confetti {
    display: none;
  }
}
