/* ============================================================
   小满 · 一隅花园
   ============================================================ */

:root {
  --paper: #F4F1E9;
  --paper-2: #EDE9DF;
  --card: #FFFCF6;
  --ink: #202822;
  --ink-2: #4C574F;
  --muted: #98A096;
  --line: rgba(32, 40, 34, .085);
  --line-2: rgba(32, 40, 34, .14);

  --moss: #4B7A5C;
  --moss-deep: #31543F;
  --moss-soft: #E6EDE2;
  --cream: #F6F2E7;

  --water: #5E8CA6;
  --amber: #C0793F;

  --radius: 22px;
  --shadow: 0 1px 2px rgba(32, 40, 34, .035), 0 10px 30px -18px rgba(32, 40, 34, .4);

  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

html.lock, html.lock body { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 50% -10%, #FBFAF4 0%, rgba(251, 250, 244, 0) 60%),
    linear-gradient(180deg, #F6F3EB 0%, #F1EEE5 55%, #ECE8DE 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  font-size: 16px;
  line-height: 1.5;
}

button, input { font-family: inherit; color: inherit; }
button {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, p { margin: 0; }

[hidden] { display: none !important; }

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) 18px calc(104px + var(--safe-bottom));
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 18px;
}

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

.brand-mark {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--moss);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.brand-text h1 {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .22em;
  line-height: 1.1;
  margin-left: -.04em;
}

.brand-text p {
  font-size: 10px;
  letter-spacing: .32em;
  color: var(--muted);
  margin-top: 4px;
  text-indent: .32em;
}

.today-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  font-family: var(--serif);
  font-size: 14px;
  background: rgba(255, 252, 246, .55);
  transition: transform .16s ease, background .2s ease;
}
.today-btn:active { transform: scale(.92); background: var(--moss-soft); }

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, .7);
}

/* ---------------- 主卡片 ---------------- */

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  padding: 20px 22px 18px;
  color: var(--cream);
  background:
    radial-gradient(130% 110% at 88% -20%, #6B9578 0%, rgba(107, 149, 120, 0) 55%),
    radial-gradient(100% 100% at 0% 120%, #3E6A52 0%, rgba(62, 106, 82, 0) 60%),
    linear-gradient(155deg, #3A6249 0%, #2E4F3B 100%);
  box-shadow: 0 18px 40px -26px rgba(36, 62, 46, .9), inset 0 1px 0 rgba(255, 255, 255, .1);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .07) .5px, transparent .5px);
  background-size: 3px 3px;
  opacity: .5;
  pointer-events: none;
}

.hero-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}

.hero-kicker {
  font-size: 11px;
  letter-spacing: .42em;
  color: rgba(246, 242, 231, .66);
  text-indent: .42em;
}

.hero-range {
  font-size: 11px;
  letter-spacing: .1em;
  color: rgba(246, 242, 231, .52);
  font-variant-numeric: tabular-nums;
}

.hero-mid {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-count {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--serif);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.hero-count > span:first-child {
  font-size: 54px;
  letter-spacing: -.02em;
}

.hero-of {
  font-size: 15px;
  color: rgba(246, 242, 231, .62);
  letter-spacing: .04em;
}
.hero-of b { font-weight: 500; color: rgba(246, 242, 231, .82); }

.hero-status {
  font-size: 13px;
  letter-spacing: .06em;
  color: rgba(246, 242, 231, .82);
  padding-bottom: 6px;
}

.hero.is-full .hero-status { color: #F3C79B; }
.hero.is-full .hero-count > span:first-child { color: #F3C79B; }

.drops {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 6px;
  margin-top: 16px;
}

.drops i {
  flex: 1;
  height: 7px;
  border-radius: 99px;
  background: rgba(246, 242, 231, .18);
  transition: background .3s ease, transform .3s ease;
}

.drops i.on {
  background: linear-gradient(90deg, #F0EAD8, #FFFCF1);
  box-shadow: 0 0 12px rgba(255, 250, 234, .28);
}

.drops i.over {
  background: linear-gradient(90deg, #E8B98D, #F3C79B);
}

.hero-foot {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: .05em;
  color: rgba(246, 242, 231, .52);
}

/* ---------------- 日历 ---------------- */

.calendar {
  margin-top: 14px;
  padding: 16px 14px 14px;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 12px;
}

.cal-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .1em;
  font-variant-numeric: tabular-nums;
}

.nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--ink-2);
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding-bottom: 3px;
  transition: background .18s ease, transform .16s ease;
}
.nav-btn:active { background: var(--moss-soft); transform: scale(.92); }

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 2px 6px;
  border-bottom: 1px solid var(--line);
}

.weekdays span {
  text-align: center;
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding-top: 8px;
}

.cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 46px;
  border-radius: 14px;
  transition: transform .16s ease, background .2s ease;
}
.cell:active { transform: scale(.93); }

.cell .num {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 13px;
  letter-spacing: .02em;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  transition: background .2s ease, color .2s ease;
}

.cell.has .num {
  background: var(--moss-soft);
  color: var(--moss-deep);
  font-weight: 600;
}

.cell.today .num {
  background: var(--moss-deep);
  color: #FFFCF3;
  font-weight: 600;
  box-shadow: 0 6px 14px -8px rgba(49, 84, 63, .9);
}

.cell.today.has .num { background: var(--moss-deep); }

.cell.future .num { color: #B0B6AE; }

.cell .dots {
  display: flex;
  gap: 3px;
  height: 4px;
  align-items: center;
}

.cell .dots i {
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: var(--moss);
  opacity: .75;
}

.cell.today .dots i { background: var(--moss-deep); }

.cell .dots i.ghost { background: transparent; }

.cell.blank { pointer-events: none; }

.cal-tip {
  margin-top: 10px;
  text-align: center;
  font-size: 10px;
  letter-spacing: .16em;
  color: var(--muted);
  opacity: .8;
}

/* ---------------- 最近 ---------------- */

.recent { margin-top: 22px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4px 10px;
}

.section-head h2 {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .2em;
  color: var(--ink);
}

.muted { font-size: 11px; color: var(--muted); letter-spacing: .06em; }

.recent-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: 16px;
  background: rgba(255, 252, 246, .62);
  border: 1px solid rgba(255, 255, 255, .6);
  margin-bottom: 8px;
  transition: background .2s ease, transform .16s ease;
}
.recent-list li:active { background: var(--moss-soft); transform: scale(.99); }

.r-date {
  font-family: var(--serif);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.r-week { font-size: 11px; color: var(--muted); }

.r-dots { margin-left: auto; display: flex; gap: 4px; }
.r-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--moss); opacity: .7; }

.r-time {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
}

.recent-list li.empty-note {
  display: block;
  background: none;
  border: 1px dashed var(--line-2);
  border-radius: 16px;
}

.empty-note {
  padding: 22px 18px;
  text-align: center;
  font-size: 12px;
  letter-spacing: .12em;
  color: var(--muted);
  background: rgba(255, 252, 246, .5);
  border-radius: 16px;
  border: 1px dashed var(--line-2);
}

/* ---------------- 年轮 ---------------- */

.page-title { padding: 8px 4px 20px; }
.page-title h2 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: .18em;
}
.page-title p {
  margin-top: 8px;
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--muted);
}

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

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

.stat .k {
  font-size: 10px;
  letter-spacing: .2em;
  color: var(--muted);
}

.stat .v {
  margin-top: 8px;
  font-family: var(--serif);
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: .02em;
}
.stat .v small { font-size: 11px; font-family: var(--sans); color: var(--muted); margin-left: 4px; letter-spacing: .06em; }

.chart-card { margin-top: 12px; padding: 18px 16px 14px; }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 132px;
  padding-top: 6px;
}

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

.bar-val {
  font-size: 11px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.bar {
  width: 100%;
  max-width: 30px;
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, #C6DBBE, #AFCBA6);
  min-height: 4px;
  transition: height .5s cubic-bezier(.2, .8, .2, 1);
}

.bar.full {
  background: linear-gradient(180deg, #5C8A6B, #3F6950);
}

.bar-col.now .bar-val { color: var(--moss-deep); font-weight: 600; }

.bar-label {
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  white-space: nowrap;
}

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

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.field:last-child { border-bottom: 0; }

.f-label {
  font-size: 13px;
  letter-spacing: .1em;
  color: var(--ink-2);
  flex: none;
}

.field input {
  flex: 1;
  min-width: 0;
  text-align: right;
  border: 0;
  outline: none;
  background: none;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: .04em;
  padding: 2px 0;
  -webkit-appearance: none;
  appearance: none;
}

.field input[type="date"] { text-align: right; color: var(--ink-2); }
.field input::placeholder { color: var(--muted); opacity: .7; }
.field input:focus { color: var(--moss-deep); }

.settings-note {
  margin: 10px 6px 18px;
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--muted);
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.btn-soft {
  flex: 1;
  padding: 13px 10px;
  border-radius: 14px;
  background: rgba(255, 252, 246, .78);
  border: 1px solid var(--line);
  font-size: 13px;
  letter-spacing: .06em;
  color: var(--ink-2);
  transition: background .18s ease, transform .16s ease;
}
.btn-soft:active { transform: scale(.97); background: var(--moss-soft); }
.btn-soft.danger { color: #9C5B3B; }

.footnote {
  margin-top: 20px;
  text-align: center;
  font-size: 10.5px;
  letter-spacing: .08em;
  color: var(--muted);
  opacity: .85;
}

/* ---------------- 底部标签 ---------------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 6px 10px calc(4px + var(--safe-bottom));
  background: rgba(246, 243, 236, .96);
  border-top: 1px solid rgba(32, 40, 34, .07);
}

.tabbar-inner {
  max-width: 520px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 6px;
  color: #9BA39A;
  font-size: 9.5px;
  letter-spacing: .22em;
  text-indent: .22em;
  transition: color .2s ease;
}

.tab svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab.active { color: var(--moss-deep); }
.tab.active svg { stroke-width: 1.7; }

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

.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 32, 27, .36);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .28s ease;
}

.sheet.open .sheet-backdrop { opacity: 1; }

.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, #FFFCF6 0%, #FAF6EE 100%);
  border-radius: 26px 26px 0 0;
  padding: 8px 20px calc(22px + var(--safe-bottom));
  box-shadow: 0 -20px 50px -30px rgba(20, 30, 24, .6);
  transform: translateY(102%);
  transition: transform .34s cubic-bezier(.22, .86, .24, 1);
}

.sheet.open .sheet-panel { transform: translateY(0); }

.grab {
  width: 36px;
  height: 4px;
  border-radius: 99px;
  background: rgba(32, 40, 34, .14);
  margin: 6px auto 16px;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.sheet-title {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: .08em;
}

.sheet-sub {
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--muted);
}

.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(32, 40, 34, .045);
  font-size: 12px;
  flex: none;
}
.close-btn:active { background: var(--moss-soft); }

.entry-list { margin: 16px 0 4px; }

.entry-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 7px;
  border-radius: 14px;
  background: rgba(75, 122, 92, .07);
  font-variant-numeric: tabular-nums;
}

.entry-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--moss);
  flex: none;
}

.entry-time { font-size: 14px; letter-spacing: .08em; }
.entry-time.none { color: var(--muted); font-size: 12px; letter-spacing: .14em; }

.entry-tag {
  margin-left: auto;
  font-size: 10px;
  letter-spacing: .18em;
  color: var(--muted);
}

.entry-del {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  background: rgba(255, 255, 255, .7);
}
.entry-del:active { background: #F3DCD1; color: #9C5B3B; }

.sheet-empty {
  margin: 18px 0 6px;
  padding: 18px;
  text-align: center;
  font-size: 12px;
  letter-spacing: .12em;
  color: var(--muted);
  border: 1px dashed var(--line-2);
  border-radius: 14px;
}

.btn-primary {
  width: 100%;
  margin-top: 14px;
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, #3F6950, #2F523D);
  color: var(--cream);
  font-size: 15px;
  letter-spacing: .24em;
  text-indent: .24em;
  box-shadow: 0 12px 24px -16px rgba(47, 82, 61, .9);
  transition: transform .16s ease, filter .2s ease;
}
.btn-primary:active { transform: scale(.985); filter: brightness(1.12); }

.sheet-hint {
  margin-top: 12px;
  text-align: center;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--muted);
  min-height: 16px;
}
.sheet-hint.warn { color: var(--amber); }

/* ---------------- 初次设置 ---------------- */

.kicker {
  font-size: 10px;
  letter-spacing: .38em;
  color: var(--moss);
  text-indent: .38em;
  margin-bottom: 10px;
}

.onboard-title {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: .1em;
}

.onboard-text {
  margin: 10px 0 20px;
  font-size: 12.5px;
  line-height: 1.9;
  letter-spacing: .05em;
  color: var(--ink-2);
}

#onboardSheet .field,
#lockSheet .field {
  background: rgba(255, 255, 255, .6);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 10px;
  padding: 13px 16px;
}

.preview {
  margin: 4px 0 2px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--moss-soft);
  color: var(--moss-deep);
  font-size: 12.5px;
  letter-spacing: .12em;
  text-align: center;
}

.link-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  font-size: 11.5px;
  letter-spacing: .14em;
  color: var(--muted);
}

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translate(-50%, 8px);
  z-index: 80;
  padding: 11px 20px;
  border-radius: 99px;
  background: rgba(36, 50, 41, .93);
  color: #F7F3E8;
  font-size: 12px;
  letter-spacing: .1em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  white-space: nowrap;
  max-width: 88vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 细节 ---------------- */

@media (min-width: 480px) {
  .hero-count > span:first-child { font-size: 60px; }
  .cell { min-height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
