/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #F97316;
    --primary-deep: #C2410C;
    --secondary: #1E3A8A;
    --neutral: rgba(22, 19, 16, 0.10);
    --canvas: #FFFDF8;
    --card: #FFFFFF;
    --text: #161310;
    --text-light: #6F675C;
    --line: rgba(22, 19, 16, 0.08);
    --shadow-card: 0 2px 12px rgba(24, 16, 8, 0.06), 0 0 0 1px var(--line);
    --shadow-lift: 0 20px 50px -16px rgba(24, 16, 8, 0.25), 0 0 0 1px var(--line);
    --glow: rgba(249, 115, 22, 0.16);
    --display: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --serif: 'Instrument Serif', Georgia, serif;
    --radius: 16px;
    --radius-lg: 24px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-deep: #EA580C;
        --neutral: rgba(245, 241, 234, 0.12);
        --canvas: #12100D;
        --card: #1C1915;
        --text: #F5F1EA;
        --text-light: #A39B8F;
        --line: rgba(245, 241, 234, 0.10);
        --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--line);
        --shadow-lift: 0 20px 50px -16px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--line);
        --glow: rgba(249, 115, 22, 0.22);
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--canvas);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* Page Container */
.page-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Top Header — one row, distinct surface */
.top-header {
    background: color-mix(in srgb, var(--card) 86%, transparent);
    -webkit-backdrop-filter: blur(12px) saturate(1.3);
    backdrop-filter: blur(12px) saturate(1.3);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0.75rem clamp(1.25rem, 4vw, 2.5rem);
}

.logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    height: 32px;
    width: auto;
    flex-shrink: 0;
    display: block;
}

/* Header Actions (Mobile: hamburger + avatar) */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.2s;
}

.hamburger:hover {
    background: var(--neutral);
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: all 0.3s;
}

.hamburger.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.open span:nth-child(2) {
    opacity: 0;
}

.hamburger.open span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Dropdown Menu */
.nav-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card);
    border-bottom: 1px solid var(--neutral);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
}

.nav-dropdown.open {
    display: block;
}

.nav-dropdown-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0.85rem clamp(1.25rem, 4vw, 2.5rem);
}

.nav-dropdown a {
    display: block;
    padding: 0.65rem 0;
    color: var(--text);
    font-weight: 500;
    border-bottom: 1px solid var(--neutral);
}

.nav-dropdown a:last-child {
    border-bottom: none;
}

.nav-dropdown a.active {
    color: var(--primary-text);
    font-weight: 700;
}

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.3rem;
    margin-left: 0.35rem;
    background: var(--primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
}

/* User Avatar — neutral chip: gradient disc + caret, pill surface */
.user-avatar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.6rem 0.22rem 0.22rem;
    border-radius: 999px;
    background: rgba(22, 19, 16, 0.06);
    color: var(--text-light);
    cursor: pointer;
    transition: background 0.15s ease;
}

.user-avatar:hover {
    background: rgba(22, 19, 16, 0.10);
}

.user-avatar .avatar-disc {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #ea580c 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

@media (prefers-color-scheme: dark) {
    .user-avatar { background: rgba(245, 241, 234, 0.08); }
    .user-avatar:hover { background: rgba(245, 241, 234, 0.14); }
}

/* Desktop: ONE-ROW header — inline pill nav, avatar menu (900px+) */
.main-nav { display: none; }

.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
    color: var(--text);
    background: rgba(22, 19, 16, 0.06);
}

.nav-link.active {
    color: var(--primary-text);
    background: rgba(249, 115, 22, 0.14);
    font-weight: 700;
}

@media (prefers-color-scheme: dark) {
    .nav-link:hover {
        color: var(--text);
        background: rgba(245, 241, 234, 0.07);
    }
    .nav-link.active {
        color: #FB923C;
    }
}

/* Avatar menu (Settings + Log Out live here) */
.header-actions { position: relative; }

.avatar-caret {
    font-size: 0.7rem;
    opacity: 0.9;
    margin-left: 0.1rem;
    transition: transform 0.2s ease;
}

.user-avatar.menu-open .avatar-caret {
    transform: rotate(180deg);
}

.avatar-menu {
    position: absolute;
    top: calc(100% + 0.6rem);
    right: 0;
    min-width: 210px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(22, 19, 16, 0.14);
    padding: 0.4rem;
    display: none;
    z-index: 210;
}

.avatar-menu.open { display: block; }

.avatar-menu-email {
    font-size: 0.78rem;
    color: var(--text-light);
    padding: 0.55rem 0.7rem 0.5rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 0.35rem;
    word-break: break-all;
}

.avatar-menu a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.7rem;
    border-radius: 9px;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s ease;
}

.avatar-menu a:hover {
    background: rgba(22, 19, 16, 0.05);
}

.avatar-menu a.avatar-menu-danger {
    color: #DC2626;
}

.avatar-menu a.avatar-menu-danger:hover {
    background: rgba(220, 38, 38, 0.08);
}

@media (prefers-color-scheme: dark) {
    .avatar-menu { box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); }
    .avatar-menu a:hover { background: rgba(245, 241, 234, 0.06); }
    .avatar-menu a.avatar-menu-danger { color: #F87171; }
    .avatar-menu a.avatar-menu-danger:hover { background: rgba(248, 113, 113, 0.10); }
}

@media (min-width: 900px) {
    .hamburger { display: none; }
    .nav-dropdown, .nav-dropdown.open { display: none !important; }
    .main-nav {
        display: flex;
        align-items: center;
        gap: 0.15rem;
        margin-left: 1.25rem;
    }
}

/* Content Area */
.content {
    flex: 1;
    max-width: 1120px;
    margin: 0 auto;
    padding: 1rem clamp(1.25rem, 4vw, 2.5rem);
    width: 100%;
}

/* Full-height pages (triage, etc) */
.full-height-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Bottom nav removed - navigation now in header */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #ea580c 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.btn-secondary {
    background: var(--neutral);
    color: var(--text);
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-danger {
    background: #EF4444;
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-light { color: var(--text-light); }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* Footer */
.footer {
    text-align: center;
    padding: 0.75rem 1rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    background: var(--canvas);
    border-top: 1px solid var(--neutral);
    flex-shrink: 0;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.25rem;
}

.footer-links a {
    color: var(--text-light);
    font-size: 0.7rem;
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-copy {
    color: var(--text-light);
    font-size: 0.65rem;
}

/* ============================================================
   Shared components (modals, cards, forms, empty states)
   Single source of truth - pages only override intentionally.
   ============================================================ */

/* Modals */
.modal {
position: fixed;
        inset: 0;
        z-index: 1000;
        display: none;
        align-items: center;
        justify-content: center;
        padding: 1rem;
}

.modal.show {
display: flex;
}

.modal-overlay {
position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
}

.modal-content {
position: relative;
        background: var(--card);
        border-radius: 20px;
        max-width: 420px;
        width: 100%;
        max-height: 85vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
        animation: modalSlideIn 0.3s ease-out;
}

.modal-title {
font-size: 1.25rem;
        font-weight: 700;
        margin-bottom: 1rem;
}

.modal-body {
padding: 1.25rem;
        overflow-y: auto;
        flex: 1;
}

.modal-close {
position: absolute;
        top: 12px;
        right: 12px;
        background: rgba(0, 0, 0, 0.7);
        color: white;
        border: none;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        font-size: 1rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        backdrop-filter: blur(8px);
        z-index: 10;
}

.modal-actions {
padding: 1rem 1.25rem;
        border-top: 1px solid var(--neutral);
        display: flex;
        gap: 0.75rem;
}

.modal-actions .btn {
flex: 1;
}

.modal-image img {
width: 100%;
        height: 100%;
        object-fit: cover;
}

.modal-remove-btn {
background: transparent;
        color: #dc2626;
        border: 1px solid #fecaca;
        padding: 0.5rem 1rem;
        border-radius: 8px;
        font-size: 0.8rem;
        cursor: pointer;
        margin-top: 0.75rem;
        width: 100%;
        transition: background 0.2s;
}

.modal-remove-btn:hover {
background: #fef2f2;
}

@keyframes modalSlideIn {
from { opacity: 0; transform: translateY(20px) scale(0.95); }
        to { opacity: 1; transform: translateY(0) scale(1); }
}


/* Empty states */
.empty-state {
display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 3rem 1rem;
        text-align: center;
        color: var(--text-light);
}

.empty-state-icon {
font-size: 3rem;
        margin-bottom: 1rem;
        opacity: 0.5;
}

.empty-state h3 {
font-size: 1.1rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
        color: var(--text);
}

.empty-state p {
margin-bottom: 1.5rem;
}


/* Buttons */
.btn-danger {
background: #dc2626;
        color: white;
}

.btn-danger:hover {
background: #b91c1c;
}


/* Cards */
.card-badge {
position: absolute;
        top: 10px;
        right: 10px;
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 5px 10px;
        border-radius: 16px;
        font-size: 0.75rem;
        font-weight: 600;
        backdrop-filter: blur(8px);
}

.card-image-placeholder {
width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 3.5rem;
        background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.card-title {
font-size: 1rem;
        font-weight: 700;
        margin-bottom: 0.5rem;
        line-height: 1.3;
        color: var(--text);
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
}

.card-meta {
display: flex;
        gap: 0.75rem;
        color: var(--text-light);
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
}

.card-content {
padding: 1rem;
}

.card-image img {
width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.3s;
}


/* Forms */
.form-group {
margin-bottom: 1rem;
}

.form-label {
display: block;
        font-size: 0.875rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
        color: var(--text);
}

.form-input, .form-select {
width: 100%;
        padding: 0.875rem 1rem;
        border: 2px solid var(--neutral);
        border-radius: 12px;
        font-size: 1rem;
        background: var(--canvas);
        color: var(--text);
        min-height: 48px;
}

.form-input:focus, .form-select:focus {
outline: none;
        border-color: var(--primary);
}

.form-row {
display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
}

.form-group:last-child {
margin-bottom: 0;
}



/* Small header buttons (guest CTAs) */
.btn-sm {
    display: inline-flex;
    align-items: center;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
}
.btn-sm-primary {
    background: linear-gradient(135deg, #F97316 0%, #EA580C 100%);
    color: #fff;
    box-shadow: 0 6px 16px -6px rgba(249, 115, 22, 0.5);
}
.btn-sm-primary:hover { transform: translateY(-1px); }
.btn-sm-ghost {
    color: var(--text);
    border: 1.5px solid var(--neutral);
}
.btn-sm-ghost:hover { border-color: var(--text); }


/* ================================================================
   APP DESIGN SYSTEM v2 — matches landing page (2026-10)
   Warm cream canvas, Bricolage display type, pill buttons,
   grain overlay, hairline borders, soft shadows.
   ================================================================ */

/* Grain overlay (matches landing texture) */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 999;
    pointer-events: none;
    opacity: 0.028;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--primary); color: #fff; }

/* Display type for all headings */
h1, h2, h3, .display-h {
    font-family: var(--display);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

.serif-i {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 400;
}

/* Orange eyebrow with dash (section labels) */
.eyebrow {
    font-family: var(--display);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.eyebrow::before {
    content: '';
    width: 20px;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
}

/* Buttons — pill form, gradient primary, motion */
.btn {
    font-family: var(--display);
    border-radius: 999px;
    font-weight: 700;
    box-shadow: 0 6px 18px -6px rgba(249, 115, 22, 0.35);
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.22s ease;
}
.btn-primary {
    background: linear-gradient(135deg, #F97316 0%, #EA580C 60%, var(--primary-deep) 100%);
    color: #fff;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 30px -8px rgba(249, 115, 22, 0.5);
}
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-secondary { background: transparent; border: 1.5px solid var(--neutral); color: var(--text); }
.btn-secondary:hover { border-color: var(--text); }

/* Cards & surfaces — hairline + soft shadow, lift on hover */
.card-lift { transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s ease; }
.card-lift:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }

/* Header — cream, hairline, wordmark in display face */
.top-header { background: color-mix(in srgb, var(--canvas) 92%, var(--card)); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.logo { font-family: var(--display); letter-spacing: -0.02em; }

/* Nav badge — pill, orange */
.nav-badge { border-radius: 999px; background: var(--primary); }

/* Modal — softer radius, hairline + deeper shadow */
.modal-content { border-radius: var(--radius-lg); box-shadow: 0 30px 80px -20px rgba(24, 16, 8, 0.45), 0 0 0 1px var(--line); }
.modal-overlay { backdrop-filter: blur(6px); background: rgba(22, 19, 16, 0.45); }

/* Form controls — warm focus ring */
.form-input, .form-select {
    border-radius: 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-input:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
    outline: none;
}

/* Scrollbar — subtle warm */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--neutral); border-radius: 99px; border: 2px solid var(--canvas); }

/* Smooth anchor scrolling + consistent centered layout (short pages reserve scrollbar space like long ones) */
html {
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
}

/* ---- v2 refinements (contrast + alignment) ---- */
:root { --primary-text: #C2410C; }
@media (prefers-color-scheme: dark) { :root { --primary-text: #FB923C; } }

/* Text-level orange must pass AA on cream (display sizes keep --primary) */
a, .nav-dropdown a.active, .eyebrow { color: var(--primary-text); }

/* Desktop nav: a touch more presence */
@media (min-width: 640px) {
    .nav-dropdown a { font-size: 0.92rem; font-weight: 600; }
    .nav-dropdown a.active { font-weight: 800; }
}

/* Component titles in the display face */
.card-title, .section-title, .modal-title, .meal-title, .form-label {
    font-family: var(--display);
    font-weight: 700;
    letter-spacing: -0.015em;
}

/* ================================================================
   APP FRAME — every page's content aligns to the same 1120px grid
   as the header (full-width page wrappers get their children framed).
   ================================================================ */
.calendar-page > *,
.recipe-book-page > *,
.shopping-page > *,
.feedback-page > *,
.triage-page > * {
    max-width: 1120px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}
/* Narrow centered sections keep their own width inside the frame */
.settings-page, .onboarding-content, .triage-content, .triage-empty {
    margin-left: auto;
    margin-right: auto;
}

/* ================================================================
   STATE SURFACES — mode-aware tints (danger/success/info/purple/warn).
   Light: pastel bg + deep text. Dark: translucent tint + bright text.
   Replaces hardcoded pastels that broke dark mode.
   ================================================================ */
:root {
    --surface-danger-bg: #FEE2E2;  --surface-danger-text: #B91C1C;  --surface-danger-border: #FECACA;
    --surface-success-bg: #F0FDF4; --surface-success-text: #15803D; --surface-success-border: #BBF7D0;
    --surface-info-bg: #E0E7FF;    --surface-info-text: #4338CA;    --surface-info-border: #C7D2FE;
    --surface-purple-bg: #F3E8FF;  --surface-purple-text: #7C3AED; --surface-purple-border: #E9D5FF;
    --surface-warn-bg: #FEF3C7;    --surface-warn-text: #A16207;    --surface-warn-border: #FCD34D;
}
@media (prefers-color-scheme: dark) {
    :root {
        --surface-danger-bg: rgba(248,113,113,0.13);  --surface-danger-text: #FCA5A5; --surface-danger-border: rgba(248,113,113,0.32);
        --surface-success-bg: rgba(74,222,128,0.12);  --surface-success-text: #86EFAC; --surface-success-border: rgba(74,222,128,0.30);
        --surface-info-bg: rgba(129,140,248,0.13);     --surface-info-text: #A5B4FC;  --surface-info-border: rgba(129,140,248,0.32);
        --surface-purple-bg: rgba(192,132,252,0.13);  --surface-purple-text: #C4B5FD; --surface-purple-border: rgba(192,132,252,0.32);
        --surface-warn-bg: rgba(251,191,36,0.12);      --surface-warn-text: #FCD34D;  --surface-warn-border: rgba(251,191,36,0.30);
    }
}

@media (prefers-color-scheme: dark) {
    .top-header {
        background: rgba(30, 26, 22, 0.94);
        border-bottom-color: rgba(245, 241, 234, 0.10);
    }
}
