:root {
  color-scheme: light;
  --ink: #453b3a;
  --muted: #9a8985;
  --line: #f1e6e0;
  --paper: #fffdfb;
  --rose: #db8e84;
  --rose-deep: #bd6b66;
  --shadow: 0 14px 36px rgba(119, 80, 71, 0.075);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: #fff8f2;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
.app-shell { max-width: 850px; min-height: 100vh; margin: 0 auto; padding: 20px 28px 28px; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.cloud-login-button, .cloud-logout-button { min-height: 39px; padding: 8px 13px; color: var(--rose-deep); border: 1px solid #f1deda; border-radius: 13px; background: white; font-size: 12px; font-weight: 650; cursor: pointer; }
.cloud-login-button:disabled { color: #aa9c97; background: #f8f4f1; cursor: not-allowed; }
.cloud-status { min-height: 30px; margin: 0 0 15px; padding: 7px 11px; color: #8c7770; background: rgba(255,255,255,.7); border: 1px solid #f1e6e0; border-radius: 12px; font-size: 11px; }
.cloud-status[data-state="connected"] { color: #55764f; background: #f1f7ee; border-color: #dcebd5; }
.cloud-status[data-state="pending"] { color: #936d35; background: #fff8e9; border-color: #f4e7c9; }
.cloud-status[data-state="error"] { color: #a94e4a; background: #fff1ef; border-color: #f4d6d2; }
.cloud-status[data-state="local"] { color: #8c7770; }
.cloud-choice { margin: 0 0 16px; padding: 14px; background: #fff9ee; border: 1px solid #f2e4c9; border-radius: 15px; }
.cloud-choice p { margin: 0 0 10px; color: #79654e; font-size: 12px; line-height: 1.6; }
.cloud-choice-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.auth-help { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.brand { display: inline-flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; color: white; background: #e4a09a; border-radius: 15px; font-size: 24px; }
.brand span:last-child { display: grid; gap: 2px; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.brand strong { font-size: 16px; letter-spacing: .04em; }
.icon-button, .close-button { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: white; color: var(--rose-deep); font-size: 22px; cursor: pointer; }

.weekly-stats-card { margin: 4px 0 20px; padding: 18px; background: linear-gradient(125deg, #f7e9e2, #f3eee2); border: 0; border-radius: 20px; }
.weekly-stats-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 2px 13px; }
.weekly-stats-heading .eyebrow { margin-bottom: 3px; }
.weekly-stats-heading h1 { margin: 0; color: var(--ink); font-size: 17px; font-weight: 650; }
.weekly-stats-controls { display: flex; align-items: center; gap: 8px; }
.weekly-stats-controls select { min-height: 30px; padding: 5px 8px; color: #75635e; background: rgba(255,255,255,.8); border: 1px solid rgba(189,107,102,.18); border-radius: 10px; font-size: 10px; }
.weekly-stats-controls span { color: #8e7a73; font-size: 10px; white-space: nowrap; }
.weekly-stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.weekly-stat { display: flex; align-items: center; min-width: 0; gap: 9px; padding: 12px; background: rgba(255,255,255,.74); border-radius: 14px; }
.weekly-stat-icon { display: grid; flex: 0 0 34px; place-items: center; width: 34px; height: 34px; background: #fff; border-radius: 12px; font-size: 18px; }
.weekly-stat > div { display: grid; min-width: 0; gap: 3px; }
.weekly-stat strong { color: #75635e; font-size: 11px; font-weight: 650; }
.weekly-stat b { overflow: hidden; color: #4d413e; font-size: clamp(11px, 1.4vw, 14px); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.weekly-stat small { overflow: hidden; color: #8c7c76; font-size: clamp(8px, .95vw, 10px); text-overflow: ellipsis; white-space: nowrap; }
.welcome-card { position: relative; display: flex; align-items: center; justify-content: space-between; overflow: hidden; min-height: 170px; padding: 29px 34px; color: #fff; background: linear-gradient(115deg, #d99086, #edb4a5); border-radius: 26px; box-shadow: 0 14px 30px rgba(217, 144, 134, .2); }
.welcome-card::after { position: absolute; right: 75px; bottom: -96px; width: 220px; height: 220px; border: 1px solid rgba(255,255,255,.2); border-radius: 50%; content: ""; }
.eyebrow { margin: 0 0 7px; color: #b6948c; font-size: 10px; font-weight: 700; letter-spacing: .15em; }
.welcome-card .eyebrow { color: rgba(255,255,255,.75); }
.welcome-card h1 { position: relative; z-index: 1; margin: 0; font-size: clamp(21px, 5vw, 29px); font-weight: 600; letter-spacing: .04em; }
.welcome-subtitle { position: relative; z-index: 1; margin: 11px 0 0; color: rgba(255,255,255,.85); font-size: 13px; }
.welcome-flower { position: relative; z-index: 1; margin-right: 18px; font-size: 66px; filter: drop-shadow(0 8px 12px rgba(95,51,43,.15)); }

.section-heading { display: flex; justify-content: space-between; align-items: end; margin: 31px 2px 15px; }
.section-heading h2, .panel-heading h2 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: .03em; }
.count-pill { padding: 6px 11px; color: var(--rose-deep); background: #f9eae6; border-radius: 20px; font-size: 12px; }
.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.overview-card { display: flex; align-items: center; min-width: 0; min-height: 82px; padding: 13px 15px; text-align: left; border: 1px solid transparent; border-radius: 18px; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease; }
.overview-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.feeding-card { background: #fff0e4; border-color: #fbe6d4; }
.sleep-card { background: #f0eefb; border-color: #e8e4f7; }
.outdoor-card { background: #eef5e9; border-color: #e5efdd; }
.vaccine-card { background: #fcecef; border-color: #f8e2e7; }
.other-card { background: #edf3f3; border-color: #e1eceb; }
.firsts-card { background: #fbf1dc; border-color: #f5e9cc; }
.card-icon { display: grid; flex: 0 0 43px; place-items: center; width: 43px; height: 43px; margin-right: 12px; background: rgba(255,255,255,.75); border-radius: 15px; font-size: 22px; }
.card-copy { display: grid; flex: 1; min-width: 0; gap: 5px; }
.card-copy strong { font-size: 15px; }
.card-copy small { overflow: hidden; color: #8b7c78; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.card-arrow { flex: none; margin-left: 8px; color: #bba9a2; font-size: 23px; }

.panel { padding: 20px; background: var(--paper); border: 1px solid rgba(241,230,224,.85); border-radius: 20px; box-shadow: var(--shadow); }
.overview-latest { margin-top: 18px; }
.section-heading.compact { margin: 0 0 10px; }
.latest-list { display: grid; }
.latest-item { display: grid; grid-template-columns: 8px minmax(74px, .9fr) minmax(0, 1.4fr) minmax(45px, .8fr) 12px; align-items: center; gap: 9px; width: 100%; padding: 13px 2px; text-align: left; border: 0; border-bottom: 1px solid #f5eeea; background: transparent; cursor: pointer; }
.latest-item:last-child { border-bottom: 0; }
.latest-item strong { overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.latest-time { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.latest-detail { overflow: hidden; color: #967d77; font-size: 10px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.latest-dot { width: 8px; height: 8px; border-radius: 50%; background: #e6aa86; }
.latest-dot.sleep { background: #aaa0df; }
.latest-dot.outdoor { background: #9dbb84; }
.latest-dot.vaccines { background: #e49ca8; }
.latest-dot.other { background: #9ebdbd; }
.privacy-note { margin: 18px 4px 0; color: var(--muted); font-size: 11px; text-align: center; }

.back-button { display: inline-flex; align-items: center; gap: 7px; padding: 7px 0; color: var(--rose-deep); border: 0; background: transparent; font-size: 14px; cursor: pointer; }
.back-button:first-letter { font-size: 22px; }
.section-title-row { display: flex; justify-content: space-between; align-items: center; margin: 18px 2px 22px; }
.section-title-row h1 { margin: 0; font-size: 28px; }
.section-description { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.section-icon { display: grid; place-items: center; width: 58px; height: 58px; background: #f8e9e5; border-radius: 20px; font-size: 29px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 15px; }
.panel-heading h2 { font-size: 16px; }
.panel-heading .eyebrow { margin-bottom: 5px; }
.two-panels { display: grid; gap: 15px; }
.records-panel { margin-bottom: 15px; padding: 17px; }
.small-add, .primary-button, .secondary-button { min-height: 39px; padding: 9px 14px; border: 0; border-radius: 12px; font-size: 12px; font-weight: 650; cursor: pointer; transition: transform .15s ease, opacity .15s ease; }
.small-add, .primary-button { color: white; background: #d78d83; }
.secondary-button { color: var(--rose-deep); background: #f9eae6; }
.small-add:hover, .primary-button:hover, .secondary-button:hover { transform: translateY(-1px); opacity: .9; }
.add-button { white-space: nowrap; }
.week-group + .week-group { margin-top: 16px; }
.week-heading { display: flex; justify-content: space-between; align-items: center; margin: 0 0 8px; padding-bottom: 8px; color: #887975; border-bottom: 1px solid #f2e9e4; font-size: 12px; font-weight: 600; }
.week-heading small { color: #b2a29c; font-size: 10px; font-weight: 500; }
.record-list { display: grid; }
.record-row { display: grid; grid-template-columns: minmax(82px, .9fr) minmax(0, 2fr) 27px; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid #f5eeea; }
.record-row:last-child { border-bottom: 0; }
.record-time { color: #75635e; font-size: 11px; font-weight: 650; font-variant-numeric: tabular-nums; }
.record-copy { display: grid; min-width: 0; gap: 4px; }
.record-subject { overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.record-detail { overflow-wrap: anywhere; color: #897c77; font-size: 11px; line-height: 1.5; }
.feeding-record { display: grid; grid-template-columns: minmax(78px, .8fr) minmax(0, 1.6fr) auto 27px; align-items: center; gap: 9px; padding: 11px 2px; border-bottom: 1px solid #f5eeea; }
.feeding-record:last-child { border-bottom: 0; }
.feeding-time { color: #75635e; font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.feeding-category { overflow: hidden; color: #8c716b; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.feeding-amount { color: #bd6b66; font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.feeding-amount small { margin-left: 3px; color: #a38c85; font-size: 10px; font-weight: 500; }
.food-actions { display: flex; gap: 7px; }
.food-chips { display: flex; flex-wrap: wrap; gap: 9px; }
.food-chip { display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; color: #596356; background: #f0f1ee; border: 1px solid #e4e7e0; border-radius: 22px; font-size: 12px; }
.food-chip.tolerated { color: #52734b; background: #e8f4e4; border-color: #d1e7ca; }
.food-chip.allergic { color: #a84d4b; background: #fbe8e6; border-color: #f2cfcc; }
.food-allergy { font-size: 12px; }
.food-allergy.tolerated { font-size: 10px; }
.delete-food { display: none; padding: 4px 7px; color: #b46f69; background: #fff; border: 0; border-radius: 12px; font-size: 10px; cursor: pointer; }
.food-editing .delete-food { display: grid; place-items: center; }
.empty-foods { padding: 12px 3px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.delete-record { width: 27px; height: 27px; border: 0; border-radius: 50%; color: #b89089; background: #fbf2ef; font-size: 19px; cursor: pointer; }
.complete-sleep-button { min-height: 32px; padding: 6px 9px; color: var(--rose-deep); background: #f9eae6; border: 0; border-radius: 10px; font-size: 10px; white-space: nowrap; cursor: pointer; }
.sleep-record-actions { display: flex; align-items: center; gap: 5px; }
.sleep-pending-row { grid-template-columns: minmax(0, 1fr) auto; }
.sleep-pending-details { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 5px 9px; min-width: 0; font-size: 11px; }
.sleep-pending-details strong { color: #75635e; font-weight: 650; }
.sleep-pending-details span { color: #897c77; font-variant-numeric: tabular-nums; }
.sleep-edit-button { min-height: 30px; padding: 5px 9px; color: var(--rose-deep); background: #f9eae6; border: 0; border-radius: 10px; font-size: 10px; white-space: nowrap; cursor: pointer; }
.food-plan-table-wrap { width: 100%; overflow: hidden; }
.food-plan-table { width: 100%; table-layout: fixed; border: 0; border-collapse: separate; border-spacing: 0 4px; color: #62534f; font-size: clamp(8px, 2.55vw, 10px); }
.food-plan-table th, .food-plan-table td { overflow: hidden; padding: 7px 3px; border: 0; text-align: center; text-overflow: clip; white-space: nowrap; }
.food-plan-table th { color: #78625b; background: #f2e7df; font-size: clamp(7px, 2.35vw, 10px); font-weight: 700; }
.food-plan-table tbody tr:nth-child(odd) td { background: #fff8f2; }
.food-plan-table tbody tr:nth-child(even) td { background: #edf3e9; }
.food-plan-table tbody td:first-child { width: 24%; color: #725c54; font-weight: 650; }
.food-plan-table th:nth-child(1) { width: 24%; }
.food-plan-table th:nth-child(2) { width: 15%; }
.food-plan-table th:nth-child(3) { width: 36%; }
.food-plan-table th:nth-child(4) { width: 25%; }
.food-plan-table td strong { color: #4d413e; }
.food-plan-table thead th:first-child, .food-plan-table tbody td:first-child { border-radius: 8px 0 0 8px; }
.food-plan-table thead th:last-child, .food-plan-table tbody td:last-child { border-radius: 0 8px 8px 0; }
.empty-state { display: grid; justify-items: center; gap: 7px; padding: 28px 12px; color: var(--muted); text-align: center; }
.empty-state > span { font-size: 25px; }
.empty-state strong { color: #82736f; font-size: 13px; font-weight: 600; }
.empty-state p { margin: 0; font-size: 11px; line-height: 1.6; }
.compact-empty { padding: 22px 8px; }
.next-vaccine { display: flex; align-items: center; gap: 14px; margin-bottom: 15px; padding: 17px; background: linear-gradient(110deg, #fcebe9, #fff6f0); border: 1px solid #f7e2dd; border-radius: 18px; }
.next-icon { display: grid; flex: 0 0 42px; place-items: center; width: 42px; height: 42px; background: rgba(255,255,255,.7); border-radius: 14px; font-size: 20px; }
.next-vaccine div { display: grid; gap: 4px; }
.next-vaccine small, .next-vaccine div span { color: #a38c85; font-size: 11px; }
.next-vaccine strong { font-size: 14px; }
.muted-next { background: #f7f4f2; border-color: #eee8e4; }
.vaccine-actions { display: flex; gap: 9px; margin: 0 0 16px; }
.firsts-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.first-memory { grid-template-columns: minmax(75px, .9fr) minmax(0, 2fr) 42px 27px; }
.first-image, .first-image-placeholder { display: grid; width: 42px; height: 42px; object-fit: cover; background: #fbf3e7; border-radius: 10px; }
.first-image-placeholder { place-items: center; font-size: 20px; }

.record-dialog { width: min(440px, calc(100% - 28px)); max-height: min(88vh, 740px); padding: 23px; color: var(--ink); border: 1px solid var(--line); border-radius: 23px; background: #fffdfb; box-shadow: 0 24px 80px rgba(68,47,40,.2); }
.record-dialog::backdrop { background: rgba(61,45,40,.32); backdrop-filter: blur(3px); }
.record-dialog form { display: grid; gap: 17px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; }
.dialog-heading h2 { margin: 0; font-size: 20px; }
.dialog-heading .eyebrow { margin-bottom: 5px; }
.close-button { border: 0; background: #f8f0ec; font-size: 25px; }
.form-fields { display: grid; gap: 13px; }
.form-field { display: grid; gap: 7px; color: #685b57; font-size: 12px; font-weight: 600; }
.form-field input, .form-field select, .form-field textarea { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--ink); border: 1px solid #eee3dd; border-radius: 12px; outline: none; background: #fff; font-size: 14px; font-weight: 400; }
.form-field input[type="date"], .form-field input[type="time"], .form-field input[type="datetime-local"] { cursor: pointer; }
.form-field input[type="date"]::-webkit-calendar-picker-indicator,
.form-field input[type="time"]::-webkit-calendar-picker-indicator,
.form-field input[type="datetime-local"]::-webkit-calendar-picker-indicator { display: none !important; visibility: hidden !important; opacity: 0 !important; width: 0 !important; height: 0 !important; margin: 0 !important; padding: 0 !important; -webkit-appearance: none; }
.form-field textarea { min-height: 100px; resize: vertical; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: #dfa49b; box-shadow: 0 0 0 3px rgba(217,144,134,.12); }
.form-error { min-height: 0; margin: -9px 0; color: #bd514d; font-size: 12px; }
.save-button { width: 100%; min-height: 48px; font-size: 14px; }
.dialog-actions { display: flex; justify-content: center; gap: 9px; }
.dialog-actions button { min-width: 86px; }
.toast { position: fixed; z-index: 10; right: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); padding: 11px 17px; color: #fff; background: rgba(65,53,49,.92); border-radius: 24px; font-size: 12px; opacity: 0; pointer-events: none; transform: translate(50%, 10px); transition: .2s ease; }
.toast.visible { opacity: 1; transform: translate(50%, 0); }
.hidden { display: none !important; }
footer { padding: 27px 0 4px; color: #b49e96; font-size: 11px; text-align: center; }
footer span { color: #d99287; }

@media (max-width: 600px) {
  .app-shell { padding: 14px 16px calc(22px + env(safe-area-inset-bottom)); }
  .topbar { margin-bottom: 18px; }
  .weekly-stats-card { margin-top: 2px; padding: 13px; }
  .weekly-stats-heading { margin-bottom: 9px; }
  .weekly-stats-heading h1 { font-size: 16px; }
  .weekly-stats-grid { grid-template-columns: 1fr; gap: 6px; }
  .weekly-stat { padding: 8px 10px; }
  .weekly-stat-icon { flex-basis: 30px; width: 30px; height: 30px; font-size: 16px; }
  .weekly-stat > div { gap: 2px; }
  .weekly-stat strong { font-size: 10px; }
  .weekly-stat b { font-size: 12px; }
  .weekly-stat small { font-size: 9px; }
  .section-heading { margin-top: 26px; }
  .overview-grid { gap: 9px; }
  .overview-card { min-height: 76px; padding: 10px; border-radius: 16px; }
  .card-icon { flex-basis: 37px; width: 37px; height: 37px; margin-right: 9px; border-radius: 13px; font-size: 19px; }
  .card-copy strong { font-size: 13px; }
  .card-copy small { font-size: 10px; }
  .other-card { min-height: 69px; }
  .panel { padding: 16px; }
  .latest-item { grid-template-columns: 7px minmax(62px, .9fr) minmax(0, 1.2fr) minmax(36px, .7fr) 10px; gap: 6px; }
  .latest-item strong { font-size: 11px; }
  .latest-time, .latest-detail { font-size: 9px; }
  .section-title-row { margin: 16px 2px 20px; }
  .section-title-row h1 { font-size: 25px; }
  .section-icon { width: 50px; height: 50px; border-radius: 17px; font-size: 25px; }
  .records-panel { padding: 14px; }
  .vaccine-actions { flex-wrap: wrap; }
  .firsts-list { grid-template-columns: 1fr; }
  .feeding-record { grid-template-columns: 78px minmax(0, 1fr) auto 27px; gap: 6px; }
  .feeding-time, .feeding-category { font-size: 11px; }
  .feeding-amount { font-size: 15px; }
  .record-row { grid-template-columns: minmax(74px, .9fr) minmax(0, 2fr) 27px; gap: 7px; }
  .sleep-pending-row { grid-template-columns: minmax(0, 1fr) auto; gap: 5px; }
  .sleep-record-actions { gap: 4px; }
  .sleep-pending-details { gap: 4px 7px; font-size: 10px; }
  .sleep-edit-button { padding: 5px 7px; font-size: 9px; }
  .sleep-record-actions .delete-record { width: 24px; height: 24px; }
  .food-plan-table { font-size: clamp(8px, 2.55vw, 10px); }
  .food-plan-table th { font-size: clamp(8px, 2.4vw, 9px); padding: 6px 2px; }
  .food-plan-table td { padding: 6px 2px; }
  .record-time { font-size: 10px; }
  .first-memory { grid-template-columns: minmax(69px, .9fr) minmax(0, 2fr) 36px 27px; }
  .first-image, .first-image-placeholder { width: 36px; height: 36px; }
}

@media (max-width: 370px) {
  .app-shell { padding-right: 12px; padding-left: 12px; }
  .card-copy small { max-width: 125px; }
  .latest-item time { font-size: 10px; }
}
