:root {
    --primary: #6C63A8;
    --primary-dark: #514A86;
    --success: #79A884;
    --accent: #E9A178;
    --water: #71AFC4;
    --danger: #B95F66;

    --bg: #F7F5F2;
    --card: #FFFFFF;
    --text: #29272D;
    --text-muted: #77727D;
    --border: #E8E4E1;

    --radius: 20px;
    --shadow: 0 10px 30px rgba(41, 39, 45, .06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.page-shell {
    width: 100%;
    max-width: 760px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 24px 18px 120px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(27px, 5vw, 34px); letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 17px; }
small, .small { font-size: 12px; }

.muted { color: var(--text-muted); }
.eyebrow { display: block; margin-bottom: 4px; color: var(--text-muted); font-size: 13px; }
.wave { display: inline-block; font-size: .8em; }

.topbar, .simple-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.simple-header { justify-content: flex-start; }

.back-link {
    width: 44px; height: 44px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--border);
    font-size: 22px;
}

.avatar, .mini-avatar {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--primary);
    color: white;
    font-weight: 800;
}

.avatar { width: 48px; height: 48px; border-radius: 50%; }
.avatar.large { width: 62px; height: 62px; }
.mini-avatar { width: 38px; height: 38px; border-radius: 50%; }
.avatar img, .mini-avatar img { width: 100%; height: 100%; object-fit: cover; }

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin: 22px 0 11px;
}

.text-link { color: var(--primary); font-size: 13px; font-weight: 700; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 16px;
}

.meal-list { padding: 8px 18px; }

.meal-item {
    min-height: 51px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #F0EDEA;
}
.meal-item:last-child { border-bottom: 0; }
.meal-info { display: flex; align-items: center; gap: 11px; }

.status-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--border);
}
.status-dot.done { background: var(--success); }
.status-dot.skipped { background: #A5A1AA; }

.optional { color: var(--text-muted); font-size: 12px; }
.meal-state { color: var(--text-muted); font-size: 13px; }
.meal-state.completed { color: var(--success); font-weight: 800; }

.grid-2, .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.metric-card { display: block; }
.metric-label { color: var(--text-muted); font-size: 13px; margin-bottom: 8px; }
.metric-value { font-size: 29px; font-weight: 800; letter-spacing: -.04em; margin-bottom: 12px; }
.metric-foot { margin-top: 8px; color: var(--text-muted); font-size: 12px; }

.progress {
    width: 100%;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #EEEAE7;
}
.progress.big { height: 11px; }
.progress-bar { height: 100%; border-radius: inherit; }
.progress-bar.water { background: var(--water); }
.progress-bar.exercise, .progress-bar.success { background: var(--success); }
.progress-bar.points { background: var(--primary); }

.points-row, .goal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.streak-pill {
    width: fit-content;
    padding: 8px 12px;
    border-radius: 999px;
    background: #FFF2E9;
    color: #8A5837;
    font-size: 13px;
    font-weight: 800;
}

.family-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.family-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px;
    box-shadow: var(--shadow);
}
.family-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.family-stat { font-size: 13px; margin: 7px 0; }

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: max(14px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 500;

    width: calc(100% - 28px);
    max-width: 720px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);

    padding: 10px 8px;
    border: 1px solid var(--border);
    border-radius: 25px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 12px 35px rgba(41,39,45,.13);
    backdrop-filter: blur(14px);
}

.nav-item {
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 11px;
    cursor: pointer;
}
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 16px; }

.add-button {
    width: 50px; height: 50px;
    display: grid; place-items: center;
    margin-top: -28px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 28px;
    box-shadow: 0 8px 20px rgba(108,99,168,.32);
}

.quick-add-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 18px;
    background: rgba(41,39,45,.38);
}
.quick-add-overlay.show { display: flex; }

.quick-add-panel {
    width: 100%;
    max-width: 520px;
    padding: 10px 18px 20px;
    border-radius: 26px;
    background: var(--card);
    box-shadow: 0 25px 80px rgba(41,39,45,.22);
}
.quick-add-handle {
    width: 44px; height: 5px;
    margin: 2px auto 14px;
    border-radius: 999px;
    background: var(--border);
}
.quick-add-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.quick-add-close {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border: 0; border-radius: 50%;
    background: var(--bg); color: var(--text);
    font-size: 24px; cursor: pointer;
}
.quick-add-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.quick-add-option {
    min-height: 88px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: var(--bg);
}
.quick-add-option span { font-size: 26px; }
.quick-add-option strong { font-size: 13px; }

.stack { display: flex; flex-direction: column; gap: 15px; }
label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; font-weight: 700; }
input, textarea, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: #FFFEFD;
    color: var(--text);
    padding: 12px 13px;
    outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,99,168,.10); }
textarea { resize: vertical; }
.field-help { color: var(--text-muted); font-weight: 400; }

.btn {
    min-height: 46px;
    border: 0;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 16px;
    cursor: pointer;
    font-weight: 800;
}
.btn.primary { background: var(--primary); color: white; }
.btn.secondary { background: #EEEAF8; color: var(--primary-dark); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: #F8E8E9; color: var(--danger); }
.btn.wide { width: 100%; }

.alert { margin-bottom: 16px; padding: 12px 14px; border-radius: 13px; font-size: 13px; }
.alert.success { background: #EAF4EC; color: #456B4D; }
.alert.error { background: #F8E8E9; color: #8E4147; }
.alert.info { background: #E9F3F6; color: #426A77; }

.auth-body {
    min-height: 100vh;
    padding: 22px;
    display: grid;
    place-items: center;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: 30px;
}
.brand-mark {
    width: 54px; height: 54px;
    display: grid; place-items: center;
    margin-bottom: 22px;
    border-radius: 18px;
    background: var(--primary);
    color: white; font-weight: 900; font-size: 24px;
}

.water-hero { text-align: center; padding: 30px 20px; }
.water-number { font-size: 48px; font-weight: 900; letter-spacing: -.05em; }
.water-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.water-chip {
    min-height: 50px; border: 1px solid #D5E5EB; border-radius: 14px;
    background: #ECF6F8; color: #467789; font-weight: 800; cursor: pointer;
}
.custom-water { display: grid; grid-template-columns: 1fr auto; gap: 9px; }

.compact-list { display: flex; flex-direction: column; }
.compact-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.compact-row:last-child { border-bottom: 0; }

.feed-list { display: flex; flex-direction: column; gap: 18px; }
.post-card {
    overflow: hidden;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
}
.post-header { display: flex; align-items: center; gap: 10px; padding: 15px 16px; }
.post-meta { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.post-image { display: block; width: 100%; max-height: 680px; object-fit: cover; background: #EEEAE7; }
.post-description { padding: 15px 16px 6px; line-height: 1.5; }
.post-actions { display: flex; align-items: center; gap: 18px; padding: 10px 16px; }
.post-actions form { margin: 0; }
.reaction-btn {
    border: 0; background: transparent; padding: 0;
    color: var(--text); cursor: pointer; font-weight: 800; font-size: 17px;
}
.reaction-btn.liked { color: #C5525A; }
.comment-count { color: var(--text-muted); font-size: 13px; }
.comments { padding: 0 16px 10px; }
.comment { margin: 6px 0; font-size: 13px; }
.comment-form {
    display: grid; grid-template-columns: 1fr auto; gap: 8px;
    padding: 10px 16px 16px;
}
.comment-form input { min-width: 0; }
.comment-form button {
    border: 0; border-radius: 12px; padding: 0 14px;
    background: var(--primary); color: white; font-weight: 800;
}

.empty-state { text-align: center; padding: 40px 20px; }
.empty-state > div { font-size: 42px; margin-bottom: 12px; }

.stats-grid { margin-bottom: 20px; }
.stat-box { text-align: center; margin-bottom: 0; }
.stat-box strong { display: block; font-size: 28px; }
.stat-box small { color: var(--text-muted); }

.reward-list { display: flex; flex-direction: column; gap: 10px; }
.reward-card { display: flex; align-items: center; gap: 14px; margin-bottom: 0; }
.reward-icon { font-size: 28px; }
.reward-card p { margin: 4px 0; font-size: 13px; }
.reward-card.unlocked { border-color: #CFE2D3; background: #FBFFFC; }

.toggle-row { flex-direction: row; justify-content: space-between; align-items: center; }
.toggle-row input { width: 22px; height: 22px; }
.time-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }

.confirm-card { text-align: center; padding: 28px; }
.confirm-emoji { font-size: 42px; margin-bottom: 12px; }

hr { width: 100%; border: 0; border-top: 1px solid var(--border); }

@media (min-width: 700px) {
    .quick-add-overlay { align-items: center; }
    .quick-add-panel { padding: 18px 20px 22px; }
}

@media (max-width: 560px) {
    .page-shell { padding-left: 14px; padding-right: 14px; }
    .family-grid { grid-template-columns: 1fr; }
    .family-card { display: grid; grid-template-columns: 1.5fr repeat(3, .7fr); align-items: center; gap: 6px; }
    .family-head { margin-bottom: 0; }
    .family-stat { text-align: center; }
    .time-grid { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
    .grid-2 { grid-template-columns: 1fr; }
}
