:root {
  --bg: #FFF8F0;
  --surface: #FFFFFF;
  --ink: #3A2E27;
  --ink-soft: #8A7B6F;
  --accent: #E07A4E;
  --accent-dark: #C4602F;
  --accent-soft: #FBE3D3;
  --success: #4C9A6A;
  --success-soft: #E1F3E6;
  --warning: #E0A73B;
  --warning-soft: #FBEFD6;
  --danger: #D65F5F;
  --danger-soft: #FBE3E3;
  --border: #F0E3D6;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 16px rgba(58, 46, 39, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #211A15;
    --surface: #2B231D;
    --ink: #F3E9DF;
    --ink-soft: #B8A99B;
    --accent: #F0925F;
    --accent-dark: #F7B084;
    --accent-soft: #3D2C22;
    --success: #6FBE8C;
    --success-soft: #223228;
    --warning: #E8BB63;
    --warning-soft: #3A311E;
    --danger: #E58484;
    --danger-soft: #3A2323;
    --border: #3A2E26;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg);
}

.hidden { display: none !important; }

/* ---------- generic ---------- */

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.btn {
  font-size: 15px;
  font-weight: 600;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-success { background: var(--success-soft); color: var(--success); border: 1px solid var(--success); }
.big-tap { padding: 16px; font-size: 16px; margin-bottom: 20px; }

.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; }
.hint { color: var(--ink-soft); font-size: 13px; text-align: center; margin-top: 10px; }
.sub { color: var(--ink-soft); font-size: 14px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 14px;
}
input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  font-size: 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; margin: 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.more-options { margin: 4px 0 18px; font-size: 13px; color: var(--ink-soft); }
.more-options summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.more-options[open] summary { margin-bottom: 10px; }

/* ---------- auth ---------- */

.view { min-height: 100vh; }
.auth-wrap { padding: 48px 24px 24px; }
.brand { text-align: center; margin-bottom: 28px; }
.brand-mark { font-size: 48px; }
.brand h1 { margin: 4px 0 2px; font-size: 26px; }
.tagline { color: var(--ink-soft); margin: 0; }

.tabs { display: flex; gap: 6px; background: var(--bg); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 20px; }
.tab-btn { flex: 1; border: none; background: transparent; padding: 10px; border-radius: 8px; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.tab-btn.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.foot-note { text-align: center; color: var(--ink-soft); font-size: 12px; margin-top: 18px; }

/* ---------- onboarding ---------- */

.onboarding-wrap { padding: 40px 20px 24px; }
.onboarding-wrap h1 { margin-bottom: 4px; }

/* ---------- topbar / nav ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.pet-switcher {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px 8px 8px;
  font-weight: 700; font-size: 15px; color: var(--ink);
  cursor: pointer;
}
.pet-switcher span:first-child { font-size: 20px; }
.chev { color: var(--ink-soft); font-size: 12px; }
.icon-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--ink-soft); padding: 6px; }

.tab-panel { padding: 16px 18px 100px; }

.greeting { font-size: 20px; font-weight: 700; margin: 6px 0 16px; }

.section { margin-bottom: 24px; }
.section h2 { font-size: 15px; margin: 0 0 10px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-head h2 { margin: 0; }
.sticky-head { position: sticky; top: 57px; background: var(--bg); z-index: 5; padding: 10px 0 6px; }

.preview-badge { font-size: 11px; background: var(--warning-soft); color: var(--warning); padding: 3px 8px; border-radius: 999px; font-weight: 700; }
.preview-badge-live { font-size: 11px; background: var(--success-soft); color: var(--success); padding: 3px 8px; border-radius: 999px; font-weight: 700; }

/* ---------- banners ---------- */

.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-md); margin-bottom: 14px;
  font-size: 14px; font-weight: 600;
}
.banner-danger { background: var(--danger-soft); color: var(--danger); }
.banner-warning { background: var(--warning-soft); color: var(--warning); }

/* ---------- task list ---------- */

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 12px 14px;
}
.task-item .task-icon { font-size: 20px; }
.task-item .task-body { flex: 1; }
.task-item .task-title { font-weight: 600; font-size: 14px; }
.task-item .task-time { color: var(--ink-soft); font-size: 12px; }
.task-item.done { opacity: 0.5; }
.task-item.overdue .task-title { color: var(--danger); }
.task-check {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--surface);
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.task-check.checked { background: var(--success); border-color: var(--success); color: white; }

/* ---------- quick add grid ---------- */

.quick-add-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.quick-add-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 12px 4px;
  font-size: 11px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.quick-add-btn:active { background: var(--accent-soft); }
.qa-icon { font-size: 22px; }

/* ---------- record list ---------- */

.record-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.record-item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 12px 14px;
}
.record-icon { font-size: 20px; }
.record-body { flex: 1; }
.record-title { font-weight: 600; font-size: 14px; }
.record-meta { color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.record-amount { font-weight: 700; font-size: 14px; color: var(--accent-dark); }

/* ---------- chips ---------- */

.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 6px; }
.chip {
  flex-shrink: 0; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-soft); padding: 7px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--accent); color: white; border-color: var(--accent); }

/* ---------- health tab ---------- */

.fake-chart {
  height: 90px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex; align-items: flex-end; gap: 6px; padding: 12px;
}
.fake-chart .bar { flex: 1; background: var(--accent-soft); border-radius: 4px 4px 0 0; position: relative; }
.fake-chart .bar.peak { background: var(--accent); }

/* ---------- expenses tab ---------- */

.expense-summary { margin-bottom: 20px; }
.expense-total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.expense-total .label { color: var(--ink-soft); font-size: 13px; }
.expense-total .amount { font-size: 24px; font-weight: 800; color: var(--accent-dark); }
.expense-cats { display: flex; flex-direction: column; gap: 8px; }
.expense-cat-row { display: flex; justify-content: space-between; font-size: 13px; }
.expense-cat-row .cat-name { color: var(--ink-soft); }
.expense-cat-row .cat-amount { font-weight: 700; }

/* ---------- profile tab ---------- */

.profile-hero { text-align: center; margin-bottom: 20px; }
.profile-avatar { font-size: 44px; margin-bottom: 6px; }
.profile-hero h2 { margin: 0 0 2px; }

.info-list { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.info-list div { display: flex; justify-content: space-between; padding: 11px 14px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.info-list div:last-child { border-bottom: none; }
.info-list dt { color: var(--ink-soft); }
.info-list dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------- bottom nav ---------- */

.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.nav-btn {
  background: none; border: none; display: flex; flex-direction: column;
  align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600;
  color: var(--ink-soft); cursor: pointer; padding: 4px 10px;
}
.nav-btn span { font-size: 19px; }
.nav-btn.active { color: var(--accent); }

/* ---------- quick-add sheet ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 30;
}
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  z-index: 31; max-height: 85vh; overflow-y: auto;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.15);
}
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 999px; margin: 6px auto 14px; }
.sheet h3 { margin: 0 0 16px; }

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

.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 18px;
  border-radius: 999px; font-size: 13px; font-weight: 600; z-index: 40;
  box-shadow: var(--shadow);
}
