:root {
  --bg: #fff9f7;
  --card: rgba(255,255,255,.94);
  --text: #3d2f2c;
  --muted: #9b8e89;
  --soft: #b8a8a4;
  --rose: #e9a9a7;
  --rose-dark: #c87e7d;
  --rose-pale: #fde9e8;
  --cream: #fff4d9;
  --cream-dark: #a07020;
  --lilac: #eae8f6;
  --lilac-dark: #6a5fb0;
  --sage-c: #e2f4ea;
  --sage-dark: #3a8060;
  --line: #f0e5e2;
  --shadow: 0 2px 18px rgba(129,91,82,.07);
  --radius: 18px;
  --radius-lg: 22px;
}

* { box-sizing: border-box; }
.page { display: none; }
.page.active { display: block; }
html { background: var(--bg); }
body {
  margin: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", sans-serif;
  min-height: 100vh;
  background:
    radial-gradient(circle at 92% 4%, rgba(253,233,232,.75) 0, transparent 32%),
    radial-gradient(circle at 4% 92%, rgba(226,244,234,.65) 0, transparent 32%),
    radial-gradient(circle at 48% 48%, rgba(255,244,217,.28) 0, transparent 55%),
    var(--bg);
}
button, input, textarea, select { font: inherit; color: inherit; }

/* ── Shell ── */
.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}

/* ── Topbar ── */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin: 4px 2px 20px; }
.eyebrow { margin: 0 0 3px; color: var(--muted); font-size: 10px; letter-spacing: .15em; text-transform: uppercase; }
h1 { margin: 0; font-family: "Songti SC", "STSong", serif; font-size: 26px; font-weight: 600; letter-spacing: .02em; color: var(--text); }
h1 span { color: var(--rose); }
p { margin: 0; }
.cloud-status { margin: 5px 0 0; color: var(--soft); font-size: 10px; }
.cloud-status::before { content: '●'; margin-right: 4px; color: #d0c0bc; }
.cloud-status[data-state="ok"]::before { color: #8ec8a0; }
.cloud-status[data-state="syncing"]::before { color: #e0b870; }
.cloud-status[data-state="error"]::before { color: #d8a0a0; }
.icon-button {
  height: 36px; padding: 0 13px; border-radius: 12px;
  border: 0.5px solid var(--line); background: rgba(255,255,255,.82);
  color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}

/* ── Summary grid ── */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.summary-card {
  border-radius: var(--radius);
  padding: 15px 14px 13px;
  border: none; cursor: default;
}
.summary-card span { display: block; font-size: 10px; letter-spacing: .09em; margin-bottom: 7px; font-weight: 500; }
.summary-card strong { display: block; font-size: 24px; font-weight: 300; letter-spacing: -.02em; line-height: 1; }
.summary-card.rose { background: linear-gradient(145deg,#fde9e8,#fbdfdd); border: 0.5px solid rgba(233,169,167,.3); }
.summary-card.rose span { color: #c08080; }
.summary-card.rose strong { color: #a86060; }
.summary-card.cream { background: linear-gradient(145deg,#fff4d9,#ffeec4); border: 0.5px solid rgba(240,210,130,.3); cursor: pointer; }
.summary-card.cream span { color: #b08838; }
.summary-card.cream strong { font-size: 17px; font-weight: 500; color: #906820; margin-top: 2px; letter-spacing: -.01em; }
.summary-card.lilac { background: linear-gradient(145deg,#edeafb,#e5e1f6); border: 0.5px solid rgba(180,170,220,.3); }
.summary-card.lilac span { color: #7868b8; }
.summary-card.lilac strong { color: #5848a0; }
.summary-card.sage-summary { background: linear-gradient(145deg,#e2f4ea,#d6eee0); border: 0.5px solid rgba(160,210,180,.3); }
.summary-card.sage-summary span { color: #488860; }
.summary-card.sage-summary strong { color: #286848; }

/* ── Cards ── */
.card { background: var(--card); border: 0.5px solid #ede0dc; border-radius: var(--radius-lg); margin-bottom: 12px; box-shadow: var(--shadow); }
.soft-card { background: rgba(255,255,255,.72); box-shadow: none; border-color: rgba(240,220,216,.6); }
.section-card { padding: 0; overflow: hidden; }
.section-heading {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px; border-bottom: 0.5px solid rgba(240,220,216,.8);
}
h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.section-kicker { margin: 0 0 3px; color: var(--muted); font-size: 10px; letter-spacing: .13em; }
.count-badge { background: var(--rose-pale); color: var(--rose-dark); font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 99px; }
.mini-total { font-size: 15px; font-weight: 600; color: var(--rose-dark); }

/* ── Date row ── */
.date-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.date-row label { font-size: 13px; color: var(--muted); }
.date-row input[type=date] { border: none; background: transparent; font-size: 13px; font-weight: 600; color: var(--text); outline: none; }

/* ── Empty state ── */
.empty-state { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.6; }

/* ── Inline add form ── */
.inline-form { display: flex; gap: 8px; padding: 12px 16px; }
.inline-form input {
  flex: 1; height: 40px; border-radius: 13px;
  border: 0.5px solid #ecddd8; background: rgba(253,233,232,.22);
  padding: 0 13px; font-size: 13.5px; outline: none; color: var(--text);
  transition: border-color .18s, background .18s;
}
.inline-form input:focus { border-color: var(--rose); background: #fff; }
.inline-form button {
  height: 40px; border-radius: 13px; border: none;
  background: var(--rose); color: #fff; padding: 0 16px; font-size: 13.5px; font-weight: 600; cursor: pointer;
}

/* ── Yesterday improve banner ── */
.improve-banner {
  border-radius: var(--radius);
  background: linear-gradient(135deg, #fff4d9, #fde9e8);
  border: 0.5px solid rgba(240,210,130,.4);
  padding: 13px 16px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.improve-label {
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  color: #b08838; text-transform: uppercase; margin: 0 0 7px;
}
.improve-text {
  font-size: 13.5px; color: var(--text); line-height: 1.65;
  margin: 0; white-space: pre-wrap;
}

/* ── Task groups ── */
.task-group { border-bottom: 0.5px solid rgba(240,220,216,.7); }
.task-group:last-child { border-bottom: none; }
.task-group-header {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 16px 9px;
  border-bottom: 0.5px solid rgba(240,220,216,.5);
}
.task-group-icon { font-size: 15px; line-height: 1; }
.task-group-name { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; flex: 1; }
.task-group-count { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 99px; }
.group-mind .task-group-name { color: #6858c0; }
.group-mind .task-group-count { background: #edeafb; color: #6858c0; }
.group-mind { background: rgba(237,234,251,.18); }
.group-body .task-group-name { color: #c07088; }
.group-body .task-group-count { background: var(--rose-pale); color: var(--rose-dark); }
.group-body { background: rgba(253,233,232,.12); }
.group-custom .task-group-name { color: var(--muted); }
.group-custom .task-group-count { background: #f0ebe8; color: var(--muted); }
.task-group .task-list { padding: 0; }

/* ── Task list ── */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 14px 13px 16px;
  border-bottom: 0.5px solid rgba(240,220,216,.7);
  transition: background .15s;
}
.task-item:last-child { border-bottom: none; }
.task-item:active { background: rgba(253,233,232,.28); }
.task-check {
  width: 21px; height: 21px; border-radius: 50%; flex-shrink: 0; margin-top: 1px;
  border: 1.5px solid #ddd0cc; background: #fff; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  transition: all .2s ease; position: relative;
}
.task-check:checked {
  background: var(--rose); border-color: var(--rose);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 14 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='2.5,7 5.5,10 11.5,4' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 13px; background-repeat: no-repeat; background-position: center;
}
.task-item.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-item.done .task-desc { opacity: .6; }
.task-title { display: block; font-size: 14px; color: var(--text); font-weight: 500; margin-bottom: 3px; }
.task-desc { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.48; }
.task-category { display: inline-block; margin-top: 5px; padding: 2px 9px; border-radius: 99px; font-size: 9.5px; font-weight: 600; background: var(--rose-pale); color: var(--rose-dark); }
.task-time { display: block; font-size: 10.5px; color: #c0b0ac; margin-top: 4px; }
.delete-button {
  margin-left: auto; width: 24px; height: 24px; flex-shrink: 0;
  border-radius: 50%; border: none; background: transparent;
  color: #d0c0bc; font-size: 16px; cursor: pointer; line-height: 1;
  transition: background .15s, color .15s;
}
.delete-button:hover { background: var(--rose-pale); color: var(--rose-dark); }

/* ── Payment form ── */
.payment-form { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 11px; }
.field { position: relative; }
.field label { display: block; font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; height: 42px; border-radius: 13px;
  border: 0.5px solid #ecddd8; background: rgba(255,255,255,.85);
  padding: 0 13px; font-size: 14px; color: var(--text); outline: none;
  transition: border-color .18s;
}
.field input:focus, .field select:focus { border-color: var(--rose); background: #fff; }
.field.full { width: 100%; }
.payment-cat-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.payment-cat-chip {
  padding: 7px 11px; border-radius: 99px;
  border: 0.5px solid #ecddd8; background: rgba(255,255,255,.85);
  color: var(--muted); font-size: 12.5px; cursor: pointer;
  transition: all .16s; white-space: nowrap; line-height: 1;
}
.payment-cat-chip.active {
  background: var(--rose-pale); border-color: rgba(233,169,167,.7);
  color: var(--rose-dark); font-weight: 600;
}
.primary-button {
  width: 100%; height: 48px; border-radius: var(--radius); border: none;
  background: linear-gradient(135deg, #eba8a6, #d68080);
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
  letter-spacing: .03em; box-shadow: 0 6px 18px rgba(200,126,125,.22);
  transition: opacity .18s, transform .15s;
}
.primary-button:active { opacity: .88; transform: scale(.99); }

/* ── Payment list ── */
.payment-list { padding: 0 4px 4px; }
.payment-row {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-bottom: 0.5px solid rgba(240,220,216,.7);
}
.payment-row:last-child { border-bottom: none; }
.pay-cat-icon {
  width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  background: var(--rose-pale);
}
.payment-name { display: block; font-size: 13.5px; color: var(--text); font-weight: 500; }
.payment-meta { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.payment-amount { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; margin-left: auto; }

/* ── Review ── */
.page-title { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.simple-title { margin-bottom: 18px; }
.back-button {
  width: 38px; height: 38px; border-radius: 13px; flex-shrink: 0;
  border: 0.5px solid var(--line); background: rgba(255,255,255,.82);
  color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1;
}
.review-form { padding: 16px; }
.review-form .field { margin-bottom: 13px; }
.review-form textarea {
  width: 100%; border-radius: 14px;
  border: 0.5px solid #ecddd8; background: rgba(255,255,255,.85);
  padding: 12px 13px; font-size: 13.5px; color: var(--text);
  outline: none; resize: none; line-height: 1.58; transition: border-color .18s;
}
.review-form textarea:focus { border-color: var(--rose); background: #fff; }
.mood-field { border: none; padding: 0; margin: 0 0 14px; }
.mood-field legend { display: block; font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 9px; }
.moods { display: flex; gap: 7px; justify-content: space-between; }
.moods label { cursor: pointer; flex: 1; }
.moods input { display: none; }
.moods span {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 9px 4px; border-radius: 14px;
  border: 0.5px solid transparent; background: rgba(255,255,255,.7);
  font-size: 22px; transition: all .18s;
}
.moods small { font-size: 9.5px; color: var(--muted); font-weight: 500; }
.moods input:checked + span { background: var(--rose-pale); border-color: rgba(233,169,167,.7); }
.moods input:checked + span small { color: var(--rose-dark); }
.save-hint { text-align: center; font-size: 11px; color: var(--muted); margin: 8px 0 0; }
.review-entry { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 0.5px solid rgba(240,220,216,.7); }
.review-entry:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.review-entry strong { display: block; font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 5px; }
.review-entry p { font-size: 13.5px; color: var(--text); line-height: 1.6; }

/* ── History ── */
.history-card { padding: 14px 16px; margin-bottom: 0; border-radius: 0; box-shadow: none; border: none; border-bottom: 0.5px solid rgba(240,220,216,.8); }
.history-card:last-child { border-bottom: none; }
.history-card h3 { margin: 0 0 11px; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-list li { padding: 7px 0; font-size: 13px; color: var(--text); border-bottom: 0.5px solid rgba(240,220,216,.6); display: flex; align-items: center; gap: 8px; }
.history-list li:last-child { border-bottom: none; }
.history-muted { color: var(--muted); font-size: 12px; }
.history-total { color: var(--rose-dark); font-weight: 600; }

/* ── Guide ── */
.guide-quote {
  margin: 0 0 14px; padding: 22px 18px; border: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(140deg,#fbe5e5 0%,#fff7e8 60%,#f0eafc 100%);
  border: 0.5px solid rgba(233,169,167,.25);
  text-align: center; font-family: "Songti SC", "STSong", serif;
  font-size: 17px; line-height: 1.75; color: #7a6260;
  box-shadow: var(--shadow);
}
.direction-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.direction-grid article {
  padding: 13px 11px; border-radius: 15px;
  background: rgba(253,233,232,.18); border: 0.5px solid rgba(240,220,216,.8);
}
.direction-grid article:last-child { grid-column: 1 / -1; }
.direction-grid b { color: var(--rose-dark); font-size: 12px; display: block; margin-bottom: 6px; }
.direction-grid p { margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.55; }
.schedule-list { display: grid; gap: 9px; }
.schedule-list div { padding: 12px 13px; border-radius: 14px; background: rgba(255,244,217,.35); border: 0.5px solid rgba(240,210,130,.3); }
.schedule-list span { font-size: 13px; font-weight: 600; color: #907030; display: block; margin-bottom: 5px; }
.schedule-list p { color: var(--muted); font-size: 11.5px; line-height: 1.55; }
.avoid-list { margin: 0; padding-left: 18px; }
.avoid-list li { margin: 9px 0; color: #756864; font-size: 13px; line-height: 1.58; }

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(100%, 560px);
  background: rgba(255,249,247,.85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid rgba(240,220,216,.9);
  padding: 7px 6px calc(10px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-around; z-index: 50;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 11px; border-radius: 16px; border: none;
  background: transparent; color: var(--muted); font-size: 9.5px;
  letter-spacing: .04em; font-weight: 600;
  cursor: pointer; transition: all .18s;
}
.nav-item span { font-size: 21px; line-height: 1; }
.nav-item.active { background: var(--rose-pale); color: var(--rose-dark); }

/* ── Toast ── */
.toast {
  position: fixed; z-index: 100; left: 50%; bottom: 90px;
  padding: 10px 20px; transform: translate(-50%, 14px);
  border-radius: 99px; color: #fff;
  background: rgba(55,42,40,.88); opacity: 0; pointer-events: none;
  transition: .24s; font-size: 13px; white-space: nowrap;
  backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Finance ── */
.fin-month-nav { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.fin-nav-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 0.5px solid #ede0dc; background: rgba(255,255,255,.82);
  color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1;
}
#finMonthLabel { font-size: 15px; font-weight: 700; color: var(--text); }
.fin-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.fin-method-row { display: flex; flex-direction: column; gap: 11px; padding: 2px 0; }
.fin-method-item { display: flex; flex-direction: column; gap: 5px; }
.fin-method-top { display: flex; justify-content: space-between; align-items: center; }
.fin-method-name { font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 7px; }
.fin-method-amt { font-size: 13.5px; font-weight: 600; color: var(--text); }
.fin-method-pct { font-size: 10px; color: var(--muted); margin-left: 4px; }
.fin-bar-track { height: 5px; background: rgba(240,220,216,.6); border-radius: 99px; overflow: hidden; }
.fin-bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg,var(--rose),#f5c8c6); transition: width .48s ease; }
.fin-record-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 0.5px solid rgba(240,220,216,.7); }
.fin-record-row:last-child { border-bottom: none; }
.fin-cat-icon { width: 36px; height: 36px; border-radius: 12px; background: var(--rose-pale); display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.fin-record-info { flex: 1; min-width: 0; }
.fin-record-name { font-size: 13.5px; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-record-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.fin-record-amt { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; }
.fin-record-date { font-size: 10px; color: var(--muted); white-space: nowrap; text-align: right; margin-top: 3px; }

/* ── Responsive ── */
@media (min-width: 500px) {
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
  .fin-stats { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 360px) {
  .app-shell { padding-left: 12px; padding-right: 12px; }
  .moods { gap: 4px; }
  .moods span { font-size: 20px; padding: 7px 2px; }
  .payment-cat-chip { font-size: 11.5px; padding: 6px 9px; }
}
