:root {
  --ink: #2d241f;
  --muted: #7c6c63;
  --background: #f5efe6;
  --paper: #fffdf8;
  --coral: #ed855f;
  --coral-dark: #b64b31;
  --peach: #f9ded0;
  --brown: #6f4b37;
  --sage: #91a47c;
  --sage-soft: #e4eadc;
  --line: #eadfd2;
  --shadow: 0 12px 30px rgba(77, 51, 37, 0.09);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", sans-serif;
  color: var(--ink);
  background: var(--background);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 5% 0%, rgba(249, 222, 208, 0.8), transparent 28rem),
    var(--background);
}

button { color: inherit; font: inherit; }

#app {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(104px + env(safe-area-inset-bottom));
}

.page { display: none; }
.page.active { display: block; animation: page-in 180ms ease-out; }

@keyframes page-in {
  from { opacity: 0; transform: translateY(5px); }
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: 35px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.today-badge {
  display: grid;
  min-width: 66px;
  padding: 10px 13px;
  border-radius: 17px;
  background: var(--peach);
  text-align: center;
}

.today-badge strong { font-size: 22px; line-height: 1; }
.today-badge span { margin-top: 3px; color: var(--muted); font-size: 9px; font-weight: 700; }

.record-card {
  position: relative;
  overflow: hidden;
  padding: 24px 20px 29px;
  border-radius: 28px;
  background: var(--brown);
  box-shadow: var(--shadow);
  color: white;
  text-align: center;
}

.record-card::before {
  position: absolute;
  top: -80px;
  left: -40px;
  width: 170px;
  height: 170px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 50%;
  content: "";
}

.record-card > p {
  position: relative;
  margin-bottom: 3px;
  font-size: 18px;
  font-weight: 800;
}

.record-card > span {
  position: relative;
  color: rgba(255,255,255,.66);
  font-size: 11px;
}

#record-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 174px;
  height: 174px;
  margin: 18px auto 0;
  border: 8px solid rgba(255,255,255,.17);
  border-radius: 50%;
  background: linear-gradient(145deg, #ff9c74, var(--coral));
  box-shadow: 0 13px 0 var(--coral-dark), 0 22px 30px rgba(27,12,7,.28);
  color: white;
  cursor: pointer;
  flex-direction: column;
  transition: transform 150ms ease, box-shadow 150ms ease;
  -webkit-tap-highlight-color: transparent;
}

#record-button:active {
  transform: translateY(8px);
  box-shadow: 0 5px 0 var(--coral-dark), 0 10px 16px rgba(27,12,7,.25);
}

#record-button.saved { animation: bounce 520ms ease; }

@keyframes bounce {
  35% { transform: scale(1.08) rotate(-3deg); }
  70% { transform: scale(.98) rotate(2deg); }
}

#record-button b { height: 43px; font-size: 38px; }
#record-button strong { font-size: 25px; font-weight: 900; }
#record-button small { color: rgba(255,255,255,.72); font-size: 10px; font-weight: 700; letter-spacing: .1em; }

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin: 14px 0;
}

.summary-card {
  padding: 17px 18px;
  border-radius: 20px;
}

.summary-card.coral { background: var(--peach); }
.summary-card.sage { background: var(--sage-soft); }
.summary-card span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.summary-card strong { display: inline-block; margin: 4px 3px 0 0; font-size: 33px; font-weight: 900; line-height: 1; }
.summary-card small { color: var(--muted); font-size: 10px; }

.card {
  margin-bottom: 14px;
  padding: 19px;
  border: 1px solid rgba(234, 223, 210, .85);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title p { margin-bottom: 2px; color: var(--muted); font-size: 10px; font-weight: 700; }
.section-title > span { color: var(--muted); font-size: 11px; font-weight: 700; }

.event-list { min-height: 48px; }

.event-row {
  display: grid;
  grid-template-columns: 31px 1fr auto;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  gap: 10px;
}

.event-index {
  display: grid;
  width: 29px;
  height: 29px;
  border-radius: 10px;
  background: var(--peach);
  color: var(--coral-dark);
  font-size: 11px;
  font-weight: 900;
  place-items: center;
}

.event-copy { display: flex; flex-direction: column; }
.event-copy strong { font-size: 15px; }
.event-copy small { color: var(--muted); font-size: 10px; }
.delete-button { padding: 7px; border: 0; background: transparent; color: #a28878; font-size: 10px; font-weight: 700; }

.empty-state {
  padding: 25px 8px 18px;
  color: #a29287;
  text-align: center;
}

.empty-state b { display: block; margin-bottom: 6px; font-size: 28px; }
.empty-state span { font-size: 11px; font-weight: 700; }

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

.month-nav button {
  width: 39px;
  height: 39px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--brown);
  font-size: 26px;
}

.month-nav strong { font-size: 17px; }
.stats-nav { padding: 0 4px; }

.weekday-row, .calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.weekday-row span {
  padding-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  aspect-ratio: .78;
  margin: 2px;
  padding: 7px 3px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  flex-direction: column;
  gap: 4px;
}

.calendar-day > span { font-size: 12px; font-weight: 800; }
.calendar-day > b {
  display: grid;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--coral);
  color: white;
  font-size: 9px;
  place-items: center;
}
.calendar-day.muted { opacity: .24; }
.calendar-day.selected { background: var(--brown); color: white; }
.calendar-day.selected > b { background: var(--peach); color: var(--coral-dark); }
.calendar-day.today::after {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sage);
  content: "";
}

.total-card {
  margin-bottom: 14px;
  padding: 26px 22px;
  border-radius: 25px;
  background: linear-gradient(145deg, var(--brown), #493024);
  box-shadow: var(--shadow);
  color: white;
}
.total-card p { margin-bottom: 9px; color: rgba(255,255,255,.65); font-size: 11px; font-weight: 700; }
.total-card strong { margin-right: 5px; font-size: 52px; font-weight: 900; letter-spacing: -.04em; line-height: 1; }
.total-card span { color: rgba(255,255,255,.7); font-size: 12px; }

.trend-chart {
  display: flex;
  align-items: flex-end;
  height: 178px;
  gap: 9px;
}

.trend-item {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 100%;
  color: var(--muted);
  flex: 1;
  flex-direction: column;
  justify-content: flex-end;
  gap: 5px;
}

.trend-item b { font-size: 9px; }
.trend-bar { width: 100%; min-height: 9px; border-radius: 7px 7px 3px 3px; background: var(--peach); }
.trend-item.current .trend-bar { background: var(--coral); }
.trend-item span { font-size: 9px; }

.stats-note {
  padding: 0 12px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}

.tab-bar {
  position: fixed;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(234,223,210,.8);
  background: rgba(255,253,248,.94);
  box-shadow: 0 -8px 24px rgba(77,51,37,.08);
  backdrop-filter: blur(18px);
}

.tab {
  display: flex;
  align-items: center;
  padding: 7px 4px;
  border: 0;
  background: transparent;
  color: #95857a;
  font-size: 10px;
  font-weight: 700;
  flex-direction: column;
  gap: 2px;
}
.tab span { font-size: 21px; line-height: 1; }
.tab.active { color: var(--coral-dark); }

.toast {
  position: fixed;
  z-index: 20;
  bottom: calc(91px + env(safe-area-inset-bottom));
  left: 50%;
  padding: 10px 16px;
  border-radius: 99px;
  background: rgba(45,36,31,.92);
  color: white;
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 580px) {
  #app {
    min-height: calc(100vh - 30px);
    margin-top: 15px;
    border-radius: 30px;
    background: rgba(255,255,255,.25);
  }
}

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