:root {
    --primary: #FF7AA2;
    --primary-dark: #F05A88;
    --primary-light: #FFE8F0;
    --secondary: #6BB5FF;
    --secondary-light: #E8F3FF;
    --bg: #FFF5F8;
    --card: #FFFFFF;
    --text: #3A3A3A;
    --text2: #999999;
    --radius: 16px;
    --shadow: 0 2px 12px rgba(255, 122, 162, 0.12);
    --nav-height: 62px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
input, textarea { font-size: 16px; }

.app { max-width: 520px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--nav-height) + 20px); }
.page { display: none; padding: 16px; padding-top: 12px; }
.page.active { display: block; animation: fadeIn 0.25s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============ 登录/注册 ============ */
.auth-wrap {
    max-width: 520px; margin: 0 auto;
    min-height: 100vh;
    display: flex; flex-direction: column; align-items: center;
    padding: 60px 28px 40px;
    background: linear-gradient(180deg, #FFE8F0 0%, #FFF5F8 40%);
}
.auth-logo { font-size: 64px; animation: bounce 2s infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.auth-title { font-size: 26px; font-weight: 700; color: var(--primary-dark); margin-top: 12px; letter-spacing: 2px; }
.auth-sub { font-size: 13px; color: var(--text2); margin-top: 6px; }
.auth-tabs {
    display: flex; background: #fff; border-radius: 24px;
    padding: 4px; margin: 28px 0 20px; width: 100%; box-shadow: var(--shadow);
}
.auth-tab {
    flex: 1; text-align: center; padding: 10px; border-radius: 20px;
    font-size: 15px; color: var(--text2); cursor: pointer; transition: all 0.2s;
}
.auth-tab.active { background: var(--primary); color: #fff; font-weight: 600; }
.auth-form { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
    width: 100%; padding: 14px 16px; border: 1.5px solid #F3DCE6; border-radius: 14px;
    background: #fff; outline: none; transition: border 0.2s;
}
.auth-form input:focus { border-color: var(--primary); }
.gender-row { display: flex; gap: 16px; }
.gender-row label { font-size: 15px; color: #555; display: flex; align-items: center; gap: 6px; }
.gender-row input[type="radio"] { accent-color: var(--primary); }

.btn-primary {
    width: 100%; padding: 14px; font-size: 16px; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, #FF8FB3, #FF6B98); border: none; border-radius: 14px;
    cursor: pointer; letter-spacing: 1px; box-shadow: 0 4px 14px rgba(255, 107, 152, 0.3);
    transition: transform 0.15s;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { background: #e0d6dc; box-shadow: none; }

/* ============ 顶部栏 ============ */
.header {
    background: linear-gradient(135deg, #FF8FB3, #FF6B98);
    padding: 18px 16px; color: #fff;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
}
.header-left { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.baby-avatar {
    width: 44px; height: 44px; background: rgba(255,255,255,0.25);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 24px;
}
.baby-name { font-size: 17px; font-weight: 700; }
.baby-age { font-size: 12px; opacity: 0.92; margin-top: 2px; }
.header-right { font-size: 13px; background: rgba(255,255,255,0.22); padding: 6px 14px; border-radius: 16px; cursor: pointer; }

/* ============ 页面标题 ============ */
.page-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.page-title { font-size: 19px; font-weight: 700; }
.timeline-count { font-size: 12px; color: var(--text2); }
.btn-mini {
    background: var(--primary-light); color: var(--primary-dark); border: none;
    font-size: 13px; padding: 8px 14px; border-radius: 18px; cursor: pointer; font-weight: 600;
}

/* ============ 底部导航 ============ */
.bottom-nav {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 520px; height: var(--nav-height);
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    display: flex; align-items: center; justify-content: space-around;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
    border-radius: 20px 20px 0 0;
    z-index: 100;
}
.nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 11px; color: var(--text2); cursor: pointer; padding: 6px 0;
}
.nav-item .nav-icon { font-size: 22px; }
.nav-item.active { color: var(--primary); }
.nav-add { position: relative; }
.nav-add-btn {
    width: 52px; height: 52px; border-radius: 50%;
    background: linear-gradient(135deg, #FF8FB3, #FF6B98);
    color: #fff; font-size: 30px; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 16px rgba(255, 107, 152, 0.4);
    margin-top: -26px; border: 4px solid #fff;
}

/* ============ 时间线 ============ */
.tl-item { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.tl-item-head { display: flex; align-items: flex-start; gap: 10px; }
.tl-icon {
    width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.tl-icon.event { background: var(--primary-light); }
.tl-icon.growth { background: var(--secondary-light); }
.tl-icon.photo { background: #FFF3D6; }
.tl-item-body { flex: 1; min-width: 0; }
.tl-item-title { font-size: 15px; font-weight: 700; line-height: 1.4; }
.tl-item-meta { font-size: 12px; color: var(--text2); margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-cat { background: var(--primary-light); color: var(--primary-dark); font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.tl-note { font-size: 13px; color: #666; line-height: 1.6; margin-top: 8px; background: #FAFAFA; border-radius: 10px; padding: 8px 10px; }
.tl-photo { width: 100%; border-radius: 12px; margin-top: 10px; max-height: 260px; object-fit: cover; }
.tl-growth-grid { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.tl-growth-item { background: var(--secondary-light); border-radius: 10px; padding: 8px 14px; text-align: center; }
.tl-growth-item .k { font-size: 11px; color: #5b8fc0; display: block; }
.tl-growth-item .v { font-size: 15px; font-weight: 700; color: #3a7ab5; display: block; margin-top: 2px; }
.tl-item-actions { display: flex; gap: 12px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed #f0f0f0; }
.tl-action { font-size: 12px; color: var(--text2); cursor: pointer; }
.tl-action.danger { color: #e05555; }

/* ============ 生长曲线 ============ */
.chart-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.chart-tab {
    flex: 1; text-align: center; padding: 9px; border-radius: 12px;
    background: #fff; color: var(--text2); font-size: 14px; cursor: pointer; box-shadow: var(--shadow);
}
.chart-tab.active { background: var(--secondary); color: #fff; font-weight: 600; }
.chart-box { background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 14px; }
.chart-box canvas { max-height: 260px; }
#growthTable { display: flex; flex-direction: column; gap: 10px; }
.growth-row {
    background: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: space-between;
}
.growth-row .g-date { font-size: 14px; font-weight: 600; }
.growth-row .g-vals { font-size: 13px; color: #555; display: flex; gap: 12px; }
.growth-row .g-vals span { white-space: nowrap; }
.growth-row .g-del { color: #e05555; font-size: 13px; cursor: pointer; }

/* ============ 照片墙 ============ */
.photos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-cell { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; cursor: pointer; }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-cell .photo-cap { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(transparent, rgba(0,0,0,0.55)); color: #fff; font-size: 11px; padding: 16px 8px 6px; }
.photo-cell .photo-del { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,0.5); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; }

/* ============ 底部面板 sheet ============ */
.sheet-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200;
    display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
    width: 100%; max-width: 520px; background: #fff;
    border-radius: 24px 24px 0 0; padding: 12px 20px 30px;
    animation: slideUp 0.25s;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-handle { width: 40px; height: 4px; background: #e0e0e0; border-radius: 2px; margin: 0 auto 16px; }
.sheet-title { font-size: 16px; font-weight: 700; text-align: center; margin-bottom: 16px; }
.sheet-options { display: flex; flex-direction: column; gap: 6px; }
.sheet-option {
    display: flex; align-items: center; gap: 14px; padding: 15px 14px;
    border-radius: 14px; cursor: pointer; font-size: 16px;
}
.sheet-option:active { background: var(--bg); }
.so-icon { font-size: 26px; }
.so-text { font-weight: 600; }

/* ============ 弹窗 modal ============ */
.modal-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 300;
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
    width: 100%; max-width: 440px; background: #fff; border-radius: 20px;
    padding: 20px; max-height: 88vh; overflow-y: auto;
    animation: popIn 0.2s;
}
.modal-small { max-width: 320px; text-align: center; }
@keyframes popIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { font-size: 17px; font-weight: 700; }
.modal-close { font-size: 18px; color: var(--text2); cursor: pointer; padding: 4px; }

.form-item { margin-bottom: 14px; }
.form-item label { font-size: 13px; color: #666; display: block; margin-bottom: 6px; font-weight: 600; }
.form-item input, .form-item textarea, .form-item select {
    width: 100%; padding: 12px 14px; border: 1.5px solid #F3DCE6; border-radius: 12px;
    outline: none; background: #fff; font-family: inherit;
}
.form-item input:focus, .form-item textarea:focus { border-color: var(--primary); }
.form-row { display: flex; gap: 10px; }
.form-row .form-item { flex: 1; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    padding: 7px 14px; border-radius: 18px; background: #f5f5f5; color: #666;
    font-size: 13px; cursor: pointer; border: 1.5px solid transparent;
}
.chip.active { background: var(--primary-light); color: var(--primary-dark); border-color: var(--primary); font-weight: 600; }

/* 上传框 */
.upload-box { display: block; cursor: pointer; }
.upload-placeholder {
    border: 2px dashed #F3DCE6; border-radius: 14px; padding: 30px 16px;
    text-align: center; color: var(--text2);
}
.upload-icon { font-size: 40px; }
.upload-placeholder p { font-size: 15px; color: #666; margin-top: 8px; }
.upload-placeholder small { font-size: 12px; color: #bbb; }
.upload-preview { width: 100%; max-height: 220px; object-fit: contain; border-radius: 14px; background: #fafafa; }

/* 详情 */
.detail-title { font-size: 18px; font-weight: 700; }
.detail-cat { display: inline-block; background: var(--primary-light); color: var(--primary-dark); font-size: 12px; padding: 3px 10px; border-radius: 12px; margin: 8px 0; }
.detail-time { font-size: 13px; color: var(--text2); margin-bottom: 10px; }
.detail-note { font-size: 14px; color: #555; line-height: 1.7; background: #FAFAFA; border-radius: 10px; padding: 10px; }
.detail-photo { width: 100%; border-radius: 12px; margin-top: 10px; }
.detail-actions { display: flex; gap: 12px; margin-top: 16px; }
.detail-actions button { flex: 1; }

/* 确认弹窗 */
.confirm-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.confirm-text { font-size: 14px; color: #888; margin-bottom: 20px; }
.confirm-btns { display: flex; gap: 10px; }
.btn-ghost { flex: 1; padding: 12px; border: 1.5px solid #e0e0e0; background: #fff; border-radius: 12px; font-size: 15px; cursor: pointer; color: #666; }
.btn-danger { flex: 1; padding: 12px; border: none; background: #E05555; color: #fff; border-radius: 12px; font-size: 15px; cursor: pointer; font-weight: 600; }

/* ============ 空状态 & loading ============ */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text2); }
.empty-icon { font-size: 44px; margin-bottom: 8px; }
.empty-state p { font-size: 14px; }
.spinner {
    width: 28px; height: 28px; border: 3px solid #f0dce4; border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.8s linear infinite; margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Toast ============ */
.toast {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.75); color: #fff; padding: 12px 22px; border-radius: 12px;
    font-size: 14px; z-index: 999; opacity: 0; pointer-events: none; transition: opacity 0.25s;
    max-width: 80%; text-align: center;
}
.toast.show { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
    .bottom-nav { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

@media (min-width: 520px) {
    .app, .auth-wrap { box-shadow: 0 0 30px rgba(0,0,0,0.05); }
}

/* ============ 辅食页 ============ */
.food-stage-list { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.food-stage-list::-webkit-scrollbar { display: none; }
.food-stage-card {
    flex: 0 0 auto; min-width: 108px; background: #fff; border: 2px solid transparent;
    border-radius: 14px; padding: 12px 10px; text-align: center; box-shadow: var(--shadow);
    cursor: pointer; transition: all 0.2s;
}
.food-stage-card .f-age { font-size: 16px; font-weight: 700; color: var(--text); }
.food-stage-card .f-sub { font-size: 11px; color: var(--text2); margin-top: 3px; line-height: 1.3; }
.food-stage-card.active { border-color: var(--secondary); background: var(--secondary-light); transform: translateY(-2px); }
.food-stage-card.active .f-age { color: #3a7ab5; }

.food-stage-desc { margin-top: 12px; background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.food-desc-head { display: flex; align-items: baseline; gap: 8px; }
.food-desc-name { font-size: 17px; font-weight: 700; color: #3a7ab5; }
.food-desc-sub { font-size: 12px; color: var(--text2); }
.food-desc-text { font-size: 13px; line-height: 1.7; color: #555; margin-top: 6px; }
.food-focus { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.food-focus .focus-tag { background: var(--secondary-light); color: #3a7ab5; font-size: 11px; padding: 3px 10px; border-radius: 20px; }

.food-generate { margin-top: 14px; }

.food-result { margin-top: 16px; }
.food-meal { margin-bottom: 16px; }
.food-meal-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.food-dish { background: #fff; border-radius: 14px; padding: 14px; box-shadow: var(--shadow); margin-bottom: 10px; }
.food-dish-name { font-size: 15px; font-weight: 700; }
.food-dish-label { font-size: 12px; font-weight: 600; color: var(--primary-dark); margin: 10px 0 5px; }
.food-ing-list { display: flex; flex-wrap: wrap; gap: 5px; }
.food-ing { background: #FFF8F2; border: 1px solid #FFE8DC; border-radius: 8px; padding: 3px 8px; font-size: 12px; color: #555; }
.food-ing b { color: var(--text); font-weight: 600; }
.food-steps { padding-left: 16px; }
.food-steps li { font-size: 12px; line-height: 1.6; color: #555; margin-bottom: 2px; }
.food-nut-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.food-nut { background: var(--secondary-light); border-radius: 8px; padding: 5px 4px; text-align: center; }
.food-nut .k { font-size: 10px; color: #5b8fc0; display: block; }
.food-nut .v { font-size: 12px; font-weight: 700; color: #3a7ab5; display: block; margin-top: 1px; }
.food-dish-tip { font-size: 11px; line-height: 1.5; color: #b0764a; background: #FFF6EA; border-radius: 8px; padding: 6px 8px; margin-top: 8px; }

/* ============ 手机端兼容优化 ============ */
.bottom-nav { padding-bottom: env(safe-area-inset-bottom); }
@supports (padding: max(0px)) {
    .bottom-nav { padding-bottom: max(env(safe-area-inset-bottom), 0px); }
}
.page { padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 20px); }
