:root {
  --bg: #F1F4FB;
  --bg-soft: #E8EEFA;
  --surface: #FFFFFF;
  --surface-2: #EDF2FB;
  --text: #2A2E3E;
  --text-soft: #6B7591;
  --muted: #A4ADC4;
  --line: #DDE3F2;
  --accent: #8C9CE6;
  --accent-soft: #D6DCF5;
  --accent-ink: #465796;
  --lavender: #C9C4F0;
  --sky: #B6D4F2;
  --mint: #B8E0D2;
  --lilac: #D7CDF2;
  --ice: #E2ECF7;
  --danger: #E68A8A;
  --shadow: 0 4px 18px rgba(96, 116, 168, 0.10);
  --radius: 18px;
  --radius-lg: 24px;
  --tabbar: 76px;
  --safe-top: env(safe-area-inset-top);
  --safe-bot: env(safe-area-inset-bottom);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #161A28;
  --bg-soft: #1E2235;
  --surface: #252A3F;
  --surface-2: #2E344A;
  --text: #ECEAF5;
  --text-soft: #B5B9CD;
  --muted: #7A8099;
  --line: #353B52;
  --accent: #A4B2F0;
  --accent-soft: #3B4470;
  --accent-ink: #C8D2F5;
  --lavender: #B0A5E5;
  --sky: #82B5E0;
  --mint: #7DBFA3;
  --lilac: #B8A5E5;
  --ice: #4A5878;
  --danger: #E68A8A;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }

.skip {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  line-height: 1.2;
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 0 0 12px 0; z-index: 999;
}
.skip:focus { left: 0; }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 100%);
  padding-top: var(--safe-top);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(120%) blur(8px);
}
.topbar__inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  max-width: 1100px; margin: 0 auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: 0; cursor: pointer; padding: 6px 4px;
  color: var(--text);
}
.brand__logo {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow);
  font-size: 22px;
}
.brand__name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }

.topbar__actions { display: flex; gap: 6px; }
.iconbtn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
  font-size: 18px;
}
.iconbtn:active { transform: scale(0.96); }

.search {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 16px 12px; max-width: 1100px; margin: 0 auto;
}
.search input {
  flex: 1;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  font-size: 16px;
  outline: none;
}
.search input:focus { border-color: var(--accent); }

/* ===== Main ===== */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar) + 24px + var(--safe-bot));
}
.section { display: none; }
.section.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-title { font-size: 26px; font-weight: 700; margin: 4px 0 14px; letter-spacing: -0.01em; }
.subtitle { color: var(--text-soft); margin: -8px 0 14px; font-size: 15px; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.card__title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; margin: 0 0 8px; }
.card__hint { color: var(--text-soft); font-size: 14px; }

/* ===== Home ===== */
.greet {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 18px;
  background: linear-gradient(135deg, rgba(232,238,250,0.78) 0%, rgba(255,255,255,0.62) 100%), url('generated/6295a5faee865ea1cbea1d7ddbacbc80.jpg') center/cover no-repeat;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}
.greet__avatar {
  width: 64px; height: 64px; border-radius: 50%;
  object-fit: cover; flex: 0 0 auto;
  box-shadow: var(--shadow);
  border: 3px solid var(--surface);
}
.greet__avatar--ph {
  display: grid; place-items: center;
  background: var(--surface); font-size: 32px;
}
.greet__emoji { font-size: 36px; }
.greet__title { font-size: 22px; font-weight: 700; margin: 0; }
.greet__sub { color: var(--text-soft); font-size: 14px; margin-top: 2px; }

.meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 14px;
}
.meta__cell {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
}
.meta__label { font-size: 12px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; }
.meta__value { font-size: 17px; font-weight: 600; margin-top: 2px; }

.quick {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin: 6px 0 14px;
}
.quick__btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  min-height: 84px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px; font-weight: 600; color: var(--text);
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}
.quick__btn:active { transform: scale(0.97); }
.quick__btn .ic { font-size: 26px; }
.quick__btn--sleep { background: var(--sky); border-color: transparent; color: #1F3A55; }
.quick__btn--feed { background: var(--lavender); border-color: transparent; color: #3E3263; }
.quick__btn--health { background: var(--ice); border-color: transparent; color: #2D4670; }
.quick__btn--dev { background: var(--lilac); border-color: transparent; color: #3E2E63; }
.quick__btn--tasks { background: var(--mint); border-color: transparent; color: #1F4A3E; }
.quick__btn--shop { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }

.plan {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.plan__row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.plan__row h3 { margin: 0; font-size: 17px; }
.plan__list { display: flex; flex-direction: column; gap: 8px; }
.plan__empty { color: var(--text-soft); font-size: 14px; padding: 6px 0 4px; }
.plan__item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border-radius: 14px; padding: 10px 12px;
}
.plan__check {
  width: 44px; height: 44px; border-radius: 10px;
  border: 2px solid var(--accent); background: transparent; cursor: pointer;
  display: grid; place-items: center; color: #fff; font-size: 14px;
}
.plan__check.done { background: var(--accent); }
.plan__text { flex: 1; }
.plan__text.done { text-decoration: line-through; color: var(--text-soft); }

/* ===== Schedule ===== */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line); border-radius: 2px;
}
.tl-item { position: relative; padding: 10px 0 14px; }
.tl-item::before {
  content: ""; position: absolute; left: -22px; top: 16px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.tl-item--feed::before { background: var(--lavender); box-shadow: 0 0 0 4px var(--accent-soft); }
.tl-item--nap::before { background: var(--sky); box-shadow: 0 0 0 4px #D5E8F8; }
.tl-item--night::before { background: #6E5E8B; box-shadow: 0 0 0 4px #D7CFE6; }
.tl-item--walk::before { background: var(--mint); box-shadow: 0 0 0 4px #D6EFE6; }
.tl-item--bath::before { background: var(--lilac); box-shadow: 0 0 0 4px #E7DCF5; }
.tl-item--wake::before { background: var(--ice); box-shadow: 0 0 0 4px #E8EEFA; }

.tl-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tl-time { font-weight: 700; font-size: 15px; }
.tl-tag {
  font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-soft);
}
.tl-note { color: var(--text-soft); font-size: 14px; margin-top: 4px; }
.tl-actions { display: flex; gap: 6px; margin-top: 6px; }
.linkbtn { background: none; border: 0; color: var(--accent-ink); font-size: 14px; cursor: pointer; padding: 12px 14px; min-height: 44px; border-radius: 10px; display: inline-flex; align-items: center; }
[data-theme="dark"] .linkbtn { color: var(--accent); }
.linkbtn.danger { color: var(--danger); }

/* ===== Tasks ===== */
.task {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
}
.task + .task { margin-top: 8px; }
.task__check {
  width: 24px; height: 24px; border-radius: 8px; flex: 0 0 auto;
  border: 2px solid var(--accent); background: transparent; cursor: pointer;
  display: grid; place-items: center; color: #fff; font-size: 13px;
}
.task__check.done { background: var(--accent); }
.task__text { flex: 1; }
.task__text.done { text-decoration: line-through; color: var(--text-soft); }
.task__pri {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}
.pri-high { background: #D6DCF5; color: #465796; }
.pri-med { background: #DCE9F5; color: #2D5A8A; }
.pri-low { background: #D6ECE3; color: #2E6E55; }
.task__more { background: none; border: 0; color: var(--text-soft); cursor: pointer; font-size: 18px; padding: 0 4px; }

.section-actions {
  display: flex; gap: 8px; margin-bottom: 12px; align-items: center;
  flex-wrap: wrap;
}
.chip {
  height: 36px; padding: 0 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text); font-size: 14px; cursor: pointer;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--tabbar) + 14px + var(--safe-bot));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; border: 0;
  font-size: 28px; box-shadow: 0 8px 22px rgba(140,156,230,.5);
  cursor: pointer; z-index: 40;
}
.fab:active { transform: scale(0.96); }
.fab[hidden] { display: none; }

/* ===== Development ===== */
.dev-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.dev-card + .dev-card { margin-top: 10px; }
.dev-card__icon {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center; font-size: 22px; flex: 0 0 auto;
  background: var(--surface-2);
}
.dev-card__title { font-weight: 700; font-size: 15px; }
.dev-card__desc { color: var(--text-soft); font-size: 14px; margin-top: 2px; }
.dev-card__age {
  display: inline-block; margin-top: 6px;
  font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink);
}
[data-theme="dark"] .dev-card__age { color: var(--accent); }

/* ===== More menu ===== */
.more-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.more-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  cursor: pointer; min-height: 76px;
}
.more-card:active { background: var(--surface-2); }
.more-card__icon { font-size: 26px; width: 44px; height: 44px; display: grid; place-items: center; background: var(--surface-2); border-radius: 14px; }
.more-card__title { font-weight: 700; font-size: 15px; }
.more-card__sub { color: var(--text-soft); font-size: 13px; }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--text-soft); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; font-size: 16px; font-family: inherit;
  outline: none;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-soft); }
.checkbox input { width: 18px; height: 18px; }

.btn-primary {
  width: 100%; min-height: 48px;
  background: var(--accent); color: #fff;
  border: 0; border-radius: 14px; font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-secondary {
  width: 100%; min-height: 48px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-ghost {
  background: transparent; border: 0; color: var(--accent-ink); cursor: pointer;
  font-size: 14px; padding: 8px;
}
[data-theme="dark"] .btn-ghost { color: var(--accent); }

/* ===== Stat tiles ===== */
.stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.stat__val { font-size: 24px; font-weight: 700; }
.stat__label { color: var(--text-soft); font-size: 13px; margin-top: 2px; }

/* ===== Tip card ===== */
.tip {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.tip + .tip { margin-top: 10px; }
.tip__icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface-2); display: grid; place-items: center;
  font-size: 20px; flex: 0 0 auto;
}
.tip__title { font-weight: 700; font-size: 15px; }
.tip__text { color: var(--text-soft); font-size: 14px; margin-top: 4px; }

.banner {
  display: flex; gap: 10px; align-items: flex-start;
  background: #EAF2FB; border: 1px solid #BDC2E0; color: #2D4670;
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px;
}
.banner .ic { font-size: 20px; }
[data-theme="dark"] .banner { background: #2A3050; border-color: #4A5070; color: #C8D2F5; }

/* ===== Meal ===== */
.meal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.meal + .meal { margin-top: 8px; }
.meal__head { display: flex; align-items: center; justify-content: space-between; }
.meal__what { font-weight: 700; }
.meal__time { color: var(--text-soft); font-size: 13px; }
.meal__row { display: flex; gap: 10px; flex-wrap: wrap; font-size: 14px; color: var(--text-soft); }
.meal__tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--mint); color: #2E5C3F; font-weight: 600; }
.meal__tag.react { background: var(--accent-soft); color: var(--accent-ink); }
[data-theme="dark"] .meal__tag { color: #14231A; }
[data-theme="dark"] .meal__tag.react { color: #2A1820; }

/* ===== Tabbar ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bot);
  z-index: 30;
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 60px; color: var(--text-soft); font-size: 11px;
}
.tab__icon { font-size: 22px; }
.tab.active { color: var(--accent-ink); }
[data-theme="dark"] .tab.active { color: var(--accent); }
.tab:active { background: var(--surface-2); }

/* ===== Toast / Modal ===== */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar) + 20px + var(--safe-bot));
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; z-index: 100;
  font-size: 14px; box-shadow: var(--shadow);
  max-width: 90%;
}
.modal {
  position: fixed; inset: 0; background: rgba(20, 24, 40, .5);
  display: grid; place-items: end center;
  z-index: 200; padding: 0;
}
.modal__sheet {
  width: 100%; max-width: 560px;
  background: var(--bg); border-radius: 24px 24px 0 0;
  padding: 18px 18px calc(20px + var(--safe-bot));
  max-height: 90vh; overflow: auto;
}
@media (min-width: 700px) {
  .modal { place-items: center; padding: 16px; }
  .modal__sheet { border-radius: 24px; max-height: 80vh; }
}
.modal__handle {
  width: 40px; height: 4px; background: var(--line);
  border-radius: 4px; margin: 0 auto 12px;
}
.modal__title { font-size: 19px; font-weight: 700; margin: 0 0 12px; }

/* ===== Empty state ===== */
.empty {
  text-align: center; padding: 28px 16px; color: var(--text-soft);
}
.empty .ic { font-size: 38px; }

/* ===== Profile card ===== */
.profile-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
  margin-bottom: 14px;
}
.profile-card__avatar {
  width: 56px; height: 56px; border-radius: 50%;
  object-fit: cover; flex: 0 0 auto;
  border: 2px solid var(--accent-soft);
}
.profile-card__name { font-weight: 700; font-size: 16px; }
.profile-card__age { color: var(--text-soft); font-size: 13px; margin-top: 2px; }
.profile-card__edit {
  margin-left: auto;
  background: var(--accent-soft); color: var(--accent-ink);
  border: 0; border-radius: 999px;
  height: 36px; padding: 0 14px; font-size: 13px; font-weight: 600;
  cursor: pointer;
}

/* ===== Wide screens ===== */
@media (min-width: 800px) {
  .quick { grid-template-columns: repeat(6, 1fr); }
  .more-grid { grid-template-columns: repeat(3, 1fr); }
  .meta { grid-template-columns: repeat(4, 1fr); }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .home-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; align-items: start; }
  .greet { grid-column: 1 / -1; }
}