:root {
  color-scheme: light;
  --paper: #fcf6ee;
  --white: #fffcf8;
  --ink: #543326;
  --soft-ink: #79564a;
  --faint: #d9b7a0;
  --line: #efdad0;
  --peach: #fbe1d8;
  --peach-line: #e8b5a2;
  --butter: #fff0cb;
  --rose: #a6526c;
  --rose-dark: #874357;
  --pink: #f9dbda;
  --warn: #a13f59;
  --font: ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--rose); outline-offset: 3px;
}
button { border: 0; background: transparent; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
.app { width: min(100%, 550px); margin: 0 auto; min-height: 100dvh; }
.page { min-height: 100dvh; padding: max(17px, env(safe-area-inset-top)) 8% max(20px, env(safe-area-inset-bottom)); }
.page-header { position: relative; display: flex; align-items: center; gap: 12px; min-height: 47px; margin-bottom: 12px; }
.page-header h1 { color: #422b21; font-size: clamp(1.37rem, 5vw, 1.8rem); font-weight: 760; line-height: 1.15; }
.back, .arrow { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid #c4987a; background: var(--white); }
.back { background: #fff5dc; }
.chevron { display: block; width: 8px; height: 8px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(-45deg); }
.chevron.left { transform: rotate(135deg); }
.quiet { padding: 8px 10px; min-height: 36px; color: var(--rose-dark); text-decoration: underline; text-underline-offset: 3px; font-size: .83rem; }
.spacer { flex: 1; }
.primary, .secondary { display: inline-grid; place-items: center; text-align: center; padding: 10px 16px; min-height: 46px; border-radius: 14px; font-weight: 680; }
.primary { background: var(--rose); color: #fff; }
.primary:active { background: var(--rose-dark); }
.secondary { background: #fff3df; border: 1px solid var(--faint); }
.block { width: 100%; }
.danger { color: var(--warn); }
.label { font-size: .85rem; color: var(--soft-ink); }
.muted { color: var(--soft-ink); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.home { --home-width: min(100vw, 550px); min-height: 100dvh; display: flex; flex-direction: column; padding: max(calc(var(--home-width) * .075), env(safe-area-inset-top)) 0 max(8px, env(safe-area-inset-bottom)); }
.summary { margin: 0 auto; width: 80%; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8%; }
.stat { display: flex; flex-direction: column; justify-content: center; align-items: center; border: 1px solid #cead75; background: var(--butter); min-height: clamp(47px, 12vw, 67px); border-radius: clamp(15px, 4vw, 25px); padding: 3px 4px; }
.stat.pink { background: var(--pink); border-color: #d39599; }
.stat span { font-size: clamp(.70rem, 2.75vw, .98rem); font-weight: 600; }
.stat strong { margin-top: 1px; font-size: clamp(.94rem, 4vw, 1.45rem); line-height: 1.25; font-weight: 735; font-variant-numeric: tabular-nums; white-space: nowrap; }
.home-greeting { padding: 0; margin: clamp(25px, 8vw, 48px) auto clamp(10px, 3.5vw, 20px); width: 80%; font-size: clamp(1.25rem, 5.1vw, 1.95rem); font-weight: 780; letter-spacing: .02em; }
.studio { width: 85.33%; margin: 0 auto; aspect-ratio: 814 / 1090; object-fit: contain; mix-blend-mode: multiply; }
.home-actions { width: 70%; margin: 3px auto 0; position: relative; }
.home-actions img { width: 100%; aspect-ratio: 665 / 162; mix-blend-mode: multiply; }
.home-actions .targets { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3,1fr); }
.targets button { border-radius: 20px; min-height: 44px; }
.targets button:active { background: #eeb4a12c; }

.month-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 9px 7px 13px; background: var(--peach); border: 1px solid var(--peach-line); border-radius: 13px; }
.month-nav strong { font-size: clamp(1.16rem, 5vw, 1.8rem); font-weight: 750; white-space: nowrap; }
.month-buttons { display: flex; gap: 5px; }
.month-buttons .arrow { width: 40px; height: 40px; background: #fff9ed; }
.day-head, .month-grid { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); }
.day-head { text-align: center; padding: 12px 0 9px; font-size: clamp(.68rem, 2.85vw, .85rem); font-weight: 670; color: var(--soft-ink); }
.calendar-card { background: var(--white); border-radius: 15px; padding: 0 4px 10px; }
.month-grid > * { min-width: 0; min-height: 50px; }
.month-grid .day { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 3px 0; border-radius: 10px; font-weight: 665; font-variant-numeric: tabular-nums; }
.cal-days .month-grid { row-gap: 3px; }
.cal-days .day, .cal-days .blank { border-bottom: 1px solid #f4e4de; }
.cal-days .day:focus-visible { z-index: 1; }
.day.selected { background: var(--pink); }
.day.is-today:not(.selected) .day-number { text-decoration: underline; text-decoration-color: var(--rose); text-underline-offset: .17em; }
.day-number { font-size: .97rem; line-height: 1.12; }
.markers { display: flex; height: 8px; align-items: center; gap: 3px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--rose); flex: none; }
.dot.tentative { border: 1.5px solid var(--rose); background: transparent; }
.dot.confirmed { background: var(--rose); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 10px 8px 2px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 4px; font-size: .73rem; color: var(--soft-ink); }
.cal-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 7px; }
.cal-tools select { width: auto; max-width: 70%; min-height: 35px; border-radius: 9px; border: 1px solid var(--line); background: var(--white); padding: 3px 6px; font-size: .81rem; }
.day-details { margin: 12px 4px 15px; }
.day-details h2, .section-title { font-size: 1.04rem; margin-bottom: 9px; font-weight: 750; }
.appointments { display: grid; gap: 8px; }
.appointment { display: flex; align-items: center; text-align: left; gap: 10px; width: 100%; position: relative; border-radius: 13px; background: var(--peach); padding: 10px 13px; min-height: 58px; }
.appointment::after { content: ''; width: 22px; height: 8px; background: #ffe6ac; border: 1px solid #e2be82; position: absolute; right: 13px; top: -4px; transform: rotate(11deg); }
.appointment.cancelled { background: #eee6e2; }
.appointment strong { display: block; overflow-wrap: anywhere; font-weight: 700; }
.appointment small { display: block; color: var(--soft-ink); margin-top: 3px; line-height: 1.3; font-size: .79rem; }
.appointment .chevron { margin-left: auto; flex: none; }
.empty { padding: 13px 11px; background: #fdf5ee; color: var(--soft-ink); border-radius: 10px; font-size: .88rem; }
.cal-page > .primary, .expenses-page > .primary { margin-top: 8px; }

.expenses-page { padding-left: 5%; padding-right: 5%; }
.expenses-page .page-header { margin-bottom: 11px; }
.expenses-page .page-header h1 { font-size: 1.31rem; }
.total-card { padding: 12px 16px; background: var(--peach); border-radius: 15px; display: flex; align-items: center; justify-content: space-between; }
.total-card p { font-weight: 680; font-size: .95rem; }
.total-card strong { display: block; color: var(--rose); font-weight: 760; margin-top: 2px; font-size: clamp(1.33rem, 5.5vw, 2rem); }
.receipt-symbol { border: 2px solid currentColor; width: 17px; height: 21px; border-radius: 2px 2px 4px 4px; display: inline-block; margin: 2px; position: relative; color: var(--soft-ink); }
.receipt-symbol::before, .receipt-symbol::after { content: ''; left: 3px; right: 3px; height: 1.5px; border-radius: 3px; top: 5px; position: absolute; background: currentColor; }
.receipt-symbol::after { top: 10px; right: 5px; }
.total-card .receipt-symbol { margin-right: 10px; transform: rotate(10deg) scale(1.35); }
.exp-cal { margin-top: 17px; border: 1px solid #ae8b7d; border-radius: 15px; padding: 8px 8px 9px; background: #fffcf94f; }
.exp-cal .month-nav { padding: 3px; background: none; border: 0; }
.exp-cal .month-nav strong { font-size: 1.05rem; background: var(--peach); padding: 6px 11px; border-radius: 13px; }
.exp-cal .day-head { padding: 7px 0 6px; }
.exp-cal .month-grid > * { min-height: 42px; }
.exp-cal .day-number { font-size: .85rem; }
.exp-cal .day .spend { font-size: clamp(.53rem, 2.36vw, .76rem); color: var(--rose-dark); line-height: 1; font-weight: 690; }
.exp-cal .day.has-spend:not(.selected) { background: #fcf1da; }
.exp-cal .month-grid { gap: 2px; }
.expense-details { margin: 19px 3% 11px; }
.receipt { background: var(--white); border: 1px solid #826050; border-bottom: 2px dotted #a68370; border-radius: 12px; margin: 0 0 13px; overflow: hidden; }
.receipt h3 { display: flex; min-height: 32px; align-items: center; justify-content: space-between; gap: 6px; background: #fff1d8; padding: 5px 11px; font-size: .89rem; color: var(--ink); }
.receipt .expense-line { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 7px 9px; min-height: 42px; }
.expense-line + .expense-line { border-top: 1px dashed #e8ccbb; }
.expense-line .kind-icon { width: 25px; text-align: center; font-size: .96rem; flex: none; }
.expense-line .item-label { flex: 1; display: flex; flex-direction: column; font-size: .9rem; }
.item-label small { color: var(--soft-ink); font-size: .72rem; }
.expense-line strong { flex: none; font-size: .83rem; font-variant-numeric: tabular-nums; }

.chat-page { height: 100dvh; min-height: 0; display: flex; flex-direction: column; overflow: hidden; padding: max(14px, env(safe-area-inset-top)) 9% max(19px, env(safe-area-inset-bottom)); }
.chat-page .page-header { flex: none; margin: 0 0 8px; gap: 10px; }
.chat-page .back { margin-left: -4%; margin-right: 5px; }
.avatar { width: 46px; aspect-ratio: 1; border-radius: 50%; flex: none; }
.chat-page .page-header h1 { font-size: 1.28rem; }
.messages { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; display: flex; gap: 13px; flex-direction: column; padding: 13px 1px 8px; scroll-padding-bottom: 10px; }
.message { display: flex; align-items: start; gap: 7px; max-width: 100%; }
.message .avatar { width: 29px; }
.message.user { align-self: end; max-width: 88%; }
.bubble { padding: 6px 10px; border: 1px solid #dfad8b; border-radius: 5px 13px 13px; font-size: .88rem; font-weight: 605; background: #fff5e6; overflow-wrap: anywhere; line-height: 1.4; }
.message.user .bubble { border-radius: 13px 5px 13px 13px; background: var(--pink); border-color: #e3a5a6; }
.bubble.record { background: #fff4dd; }
.bubble.record strong { display: block; font-size: .87rem; }
.bubble.record small { display: block; margin-top: 3px; color: var(--soft-ink); font-size: .78rem; font-weight: 530; }
.bubble.record button { display: block; text-align: left; padding: 0; }
.composer { flex: none; display: flex; gap: 7px; margin-top: 8px; }
.composer input { flex: 1; width: 0; min-width: 0; background: var(--white); border: 1px solid #ad8271; border-radius: 14px; padding: 8px 11px; font-size: 16px; min-height: 46px; }
.composer input::placeholder { color: #8e6e62; }
.composer button { flex: none; padding: 8px 12px; }

.sheet { width: min(92vw, 440px); max-height: 88dvh; border: 1px solid var(--faint); background: var(--paper); color: var(--ink); padding: 18px; border-radius: 19px; }
.sheet::backdrop { background: #2d1b1860; }
.sheet h2 { font-size: 1.21rem; }
.sheet-title { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 10px; }
.icon-close { min-height: 44px; min-width: 44px; font-size: 1.4rem; border-radius: 50%; background: #fbe6da; }
.fields { display: grid; gap: 10px; }
.fields label { display: grid; gap: 4px; font-size: .86rem; font-weight: 640; min-width: 0; }
.fields input:not([type=checkbox]), .fields select, .fields textarea { border: 1px solid var(--faint); background: var(--white); border-radius: 8px; min-height: 42px; padding: 7px 8px; width: 100%; font-size: 16px; }
.fields textarea { resize: vertical; min-height: 54px; }
.fields .row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.fields .check-row { display: flex; gap: 8px; align-items: center; min-height: 36px; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 11px; }
.sheet .muted { font-size: .9rem; line-height: 1.5; }
.form-error { color: var(--warn); font-size: .85rem; }
.backup-actions { display: grid; gap: 9px; margin-top: 12px; }
.toast { z-index: 5; position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 8px 13px; border-radius: 10px; background: #694436; color: #fff; line-height: 1.3; font-size: .89rem; width: max-content; max-width: 88vw; text-align: center; }
[hidden] { display: none !important; }
@media (max-width: 350px) {
  .month-nav { padding-left: 7px; }
  .month-buttons .arrow { width: 34px; min-height: 38px; }
  .page { padding-right: 6.5%; padding-left: 6.5%; }
  .expenses-page { padding-right: 5%; padding-left: 5%; }
  .composer button { padding-inline: 8px; }
}
