/* ═══════════════════════════════════════════════════
   NutriBooty v2 — Deep UX Redesign 🍑
   Bento grids · SVG rings · Masonry · FAB nav
   ═══════════════════════════════════════════════════ */

:root {
    /* ─── Core Dark Palette ─── */
    --bg-base: #0B0B11;
    --bg-surface: #111118;
    --bg-card: rgba(255, 255, 255, 0.035);
    --bg-card-hover: rgba(255, 255, 255, 0.06);
    --bg-card-solid: #18181F;
    --bg-input: rgba(255, 255, 255, 0.05);
    --bg-input-focus: rgba(255, 255, 255, 0.08);

    /* ─── Accent: Peach → Magenta ─── */
    --accent: #F472B6;
    --accent-2: #EC4899;
    --accent-3: #F97316;
    --accent-glow: rgba(244, 114, 182, 0.2);
    --accent-soft: rgba(244, 114, 182, 0.1);

    --gradient-main: linear-gradient(135deg, #EC4899 0%, #F97316 100%);
    --gradient-hero: linear-gradient(135deg, #BE185D 0%, #EC4899 50%, #F97316 100%);
    --gradient-subtle: linear-gradient(135deg, rgba(244,114,182,0.06), rgba(249,115,22,0.03));

    /* ─── Status Colors ─── */
    --good: #34D399;
    --good-bg: rgba(52, 211, 153, 0.1);
    --warn: #FBBF24;
    --warn-bg: rgba(251, 191, 36, 0.1);
    --bad: #F87171;
    --bad-bg: rgba(248, 113, 113, 0.1);
    --info: #60A5FA;

    /* ─── Text ─── */
    --text: #F0F0F5;
    --text-2: #9CA3AF;
    --text-3: #6B7280;

    /* ─── Borders ─── */
    --border: rgba(255, 255, 255, 0.06);
    --border-2: rgba(255, 255, 255, 0.12);

    /* ─── Shadows ─── */
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.25);
    --shadow: 0 4px 16px rgba(0,0,0,0.35);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.45);
    --shadow-glow: 0 4px 24px var(--accent-glow);

    /* ─── Spacing ─── */
    --s1: 4px;  --s2: 8px;  --s3: 12px;  --s4: 16px;
    --s5: 20px; --s6: 24px; --s8: 32px;  --s10: 40px;

    /* ─── Radius ─── */
    --r1: 8px;  --r2: 12px;  --r3: 16px;  --r4: 20px;
    --r5: 24px; --r-full: 9999px;

    /* ─── Typography ─── */
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --ts-xs: 0.6875rem; --ts-sm: 0.8125rem; --ts-base: 0.9375rem;
    --ts-lg: 1.0625rem; --ts-xl: 1.25rem; --ts-2xl: 1.5rem;
    --ts-3xl: 2rem; --ts-4xl: 2.5rem;

    /* ─── Transitions ─── */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --t-fast: 0.15s; --t-base: 0.25s; --t-slow: 0.4s;

    /* ─── Nav ─── */
    --nav-h: 64px;
}

/* ═══ Reset ═══ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: calc(var(--nav-h) + 16px);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Ambient glow */
body::before {
    content: '';
    position: fixed; top: -30%; left: -20%;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(236,72,153,0.08), transparent 70%);
    pointer-events: none; z-index: 0;
}

/* ═══ Typography ═══ */
h1, h2, h3 { font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: var(--ts-2xl); }
h2 { font-size: var(--ts-xl); }
h3 { font-size: var(--ts-lg); }
a { color: var(--accent); text-decoration: none; }

/* ═══ Layout ═══ */
.container { max-width: 500px; margin: 0 auto; padding: 0 var(--s4); position: relative; z-index: 1; }

.page-head { padding: var(--s5) 0 var(--s3); }
.page-title {
    font-size: var(--ts-2xl); font-weight: 800;
    background: var(--gradient-main);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ═══ ANIMATION SYSTEM ═══ */
@keyframes fadeUp   { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn  { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes slideR   { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes ringDraw { from { stroke-dashoffset: var(--ring-circumference); } }
@keyframes countUp  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse    { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes shimmer  { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes fabPop   { 0% { transform: translate(-50%, 35%) scale(0); opacity: 0; } 100% { transform: translate(-50%, 35%) scale(1); opacity: 1; } }

.anim-fade-up  { animation: fadeUp  0.5s var(--ease) both; }
.anim-fade-in  { animation: fadeIn  0.4s var(--ease) both; }
.anim-scale-in { animation: scaleIn 0.4s var(--ease-bounce) both; }
.anim-slide-r  { animation: slideR  0.4s var(--ease) both; }

/* Stagger delays */
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.3s; }
.delay-7 { animation-delay: 0.35s; }
.delay-8 { animation-delay: 0.4s; }

/* ═══ CARDS ═══ */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--r4);
    padding: var(--s5);
    transition: border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}
.card:hover { border-color: var(--border-2); }
.card-sm { padding: var(--s3); border-radius: var(--r2); }
.card-flat { background: var(--bg-card-solid); border: none; backdrop-filter: none; }

/* ═══ BENTO GRID ═══ */
.bento {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s3);
}
.bento-span { grid-column: 1 / -1; }
.bento-cell {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r3);
    padding: var(--s4);
    display: flex; flex-direction: column;
    transition: border-color var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.bento-cell:hover { border-color: var(--border-2); transform: translateY(-1px); }

/* ═══ SVG RING ═══ */
.ring-container { position: relative; display: flex; align-items: center; justify-content: center; }
.ring-svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,0.04); }
.ring-fill { fill: none; stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease); }
.ring-center {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}
.ring-value { font-size: var(--ts-3xl); font-weight: 800; line-height: 1; animation: countUp 0.6s var(--ease) both 0.3s; }
.ring-label { font-size: var(--ts-xs); color: var(--text-2); margin-top: 2px; }

/* Mini arc gauges */
.arc-gauge { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; }
.arc-svg { flex-shrink: 0; }
.arc-info { flex: 1; }
.arc-name { font-size: var(--ts-sm); font-weight: 600; }
.arc-vals { font-size: var(--ts-xs); color: var(--text-3); }

/* ═══ MEAL TIMELINE ═══ */
.meal-timeline { display: flex; align-items: stretch; gap: 0; padding: var(--s3) 0; }
.meal-tl-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    position: relative; text-decoration: none; color: var(--text);
    padding: var(--s2) var(--s1);
    transition: transform var(--t-fast) var(--ease);
}
.meal-tl-item:hover { transform: translateY(-2px); }
.meal-tl-dot {
    width: 40px; height: 40px;
    border-radius: var(--r2);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; margin-bottom: var(--s1);
    transition: box-shadow var(--t-base) var(--ease);
}
.meal-tl-dot.filled { box-shadow: 0 2px 12px rgba(0,0,0,0.3); }
.meal-tl-dot.empty { border: 2px dashed var(--border-2); background: transparent; }
.meal-tl-name { font-size: var(--ts-xs); font-weight: 600; color: var(--text-2); text-align: center; line-height: 1.2; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-tl-cal { font-size: 9px; color: var(--text-3); margin-top: 1px; }

/* Connector line */
.meal-tl-item:not(:last-child)::after {
    content: ''; position: absolute;
    top: 20px; right: -2px; width: calc(100% - 40px);
    height: 2px; background: var(--border);
    transform: translateX(50%);
}
.meal-tl-item:not(:last-child).has-meal::after { background: var(--accent-soft); }

/* Color per type */
.dot-breakfast { background: rgba(251,191,36,0.15); }
.dot-lunch    { background: rgba(52,211,153,0.15); }
.dot-dinner   { background: rgba(139,92,246,0.15); }
.dot-snack    { background: rgba(244,114,182,0.15); }

/* ═══ DAY STRIP (Calendar) ═══ */
.day-strip {
    display: flex; gap: var(--s2); padding: var(--s2) 0;
    overflow-x: auto; scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.day-strip::-webkit-scrollbar { display: none; }
.day-pill {
    flex-shrink: 0; scroll-snap-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    width: 48px; padding: var(--s2) 0;
    border-radius: var(--r3);
    cursor: pointer; border: none; background: transparent;
    color: var(--text-3); font-family: var(--font);
    transition: all var(--t-base) var(--ease);
}
.day-pill:hover { background: var(--bg-card); color: var(--text-2); }
.day-pill.active {
    background: var(--gradient-main); color: white;
    box-shadow: var(--shadow-glow);
}
.day-pill.today:not(.active) { border: 2px solid var(--accent); }
.day-pill .dp-name { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.day-pill .dp-num { font-size: var(--ts-lg); font-weight: 700; }
.day-pill .dp-dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: 0; }
.day-pill.has-meals .dp-dot { opacity: 1; }
.day-pill.active .dp-dot { background: white; }

/* Day detail */
.day-detail { animation: fadeUp 0.3s var(--ease) both; }
.day-summary-bar {
    display: flex; gap: var(--s3); padding: var(--s3);
    background: var(--bg-card); border-radius: var(--r2);
    border: 1px solid var(--border); overflow-x: auto;
}
.ds-chip { font-size: var(--ts-xs); font-weight: 600; white-space: nowrap; color: var(--text-2); }
.ds-chip.highlight { color: var(--accent); }

/* ═══ MASONRY GRID ═══ */
.masonry {
    columns: 2; column-gap: var(--s3);
}
.masonry-card {
    break-inside: avoid; margin-bottom: var(--s3);
    background: var(--bg-card-solid);
    border-radius: var(--r3); overflow: hidden;
    border: 1px solid var(--border);
    transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
    display: inline-block; width: 100%;
}
.masonry-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: var(--border-2);
}
.masonry-img {
    width: 100%; aspect-ratio: 4/3;
    object-fit: cover; display: block;
    background: var(--gradient-subtle);
}
.masonry-img-wrap {
    width: 100%; overflow: hidden;
    background: var(--gradient-subtle);
}
.masonry-img-wrap img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
}
.masonry-img-placeholder {
    width: 100%; aspect-ratio: 4/3;
    background: var(--gradient-subtle);
    display: flex; align-items: center; justify-content: center;
    font-size: 2.5rem;
}
.masonry-body { padding: var(--s3); }
.masonry-name { font-size: var(--ts-sm); font-weight: 600; line-height: 1.3; margin-bottom: var(--s1); }
.masonry-meta { font-size: 10px; color: var(--text-3); display: flex; gap: var(--s2); }
.masonry-fav {
    position: absolute; top: var(--s2); right: var(--s2);
    background: rgba(0,0,0,0.5); backdrop-filter: blur(8px);
    border: none; border-radius: 50%;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; cursor: pointer;
    transition: transform var(--t-fast) var(--ease);
}
.masonry-fav:hover { transform: scale(1.15); }

/* Compact macro bar for recipe cards */
.macro-compact { margin-top: var(--s2); }
.macro-compact-bar {
    display: flex; height: 4px; border-radius: 2px; overflow: hidden;
    gap: 1px;
}
.macro-compact-bar > div { min-width: 2px; border-radius: 1px; }
.macro-compact-labels {
    display: flex; justify-content: space-between;
    font-size: 9px; font-weight: 600; margin-top: 3px;
    opacity: 0.85;
}

/* Floating search */
.floating-search {
    position: sticky; top: 0; z-index: 10;
    padding: var(--s2) 0; margin-bottom: var(--s3);
    background: linear-gradient(var(--bg-base), transparent);
}
.search-bar {
    display: flex; align-items: center; gap: var(--s2);
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    padding: var(--s2) var(--s4);
    transition: border-color var(--t-base), box-shadow var(--t-base);
}
.search-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-bar input {
    flex: 1; border: none; background: transparent;
    color: var(--text); font-family: var(--font); font-size: var(--ts-base);
    outline: none;
}
.search-bar input::placeholder { color: var(--text-3); }
.search-icon { color: var(--text-3); flex-shrink: 0; }

/* Filter chips */
.filter-chips {
    display: flex; gap: var(--s2); padding: var(--s1) 0;
    overflow-x: auto; scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.f-chip {
    flex-shrink: 0; padding: 6px 14px;
    border-radius: var(--r-full);
    background: var(--bg-card); border: 1px solid var(--border);
    font-size: var(--ts-sm); font-weight: 500;
    color: var(--text-2); cursor: pointer;
    text-decoration: none; font-family: var(--font);
    transition: all var(--t-base) var(--ease);
}
.f-chip:hover { background: var(--bg-card-hover); border-color: var(--border-2); color: var(--text); }
.f-chip.active {
    background: var(--gradient-main); border-color: transparent;
    color: white; box-shadow: var(--shadow-glow);
}

/* ═══ FULL-BLEED HERO (Recipe Detail) ═══ */
.hero-bleed {
    margin: 0 calc(-1 * var(--s4));
    position: relative; overflow: hidden;
}
.hero-bleed img {
    width: 100%; height: 240px; object-fit: cover; display: block;
}
.hero-bleed-placeholder {
    width: 100%; height: 240px;
    background: var(--gradient-hero);
    display: flex; align-items: center; justify-content: center;
    font-size: 4rem;
}
.hero-bleed-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, var(--bg-base));
    padding: var(--s8) var(--s4) var(--s4);
}
.hero-bleed-nav {
    position: absolute; top: var(--s3); left: var(--s3); right: var(--s3);
    display: flex; justify-content: space-between; align-items: center;
}

/* Pill Tabs */
.pill-tabs {
    display: flex; gap: var(--s2);
    background: var(--bg-card-solid);
    border-radius: var(--r-full);
    padding: 3px;
    border: 1px solid var(--border);
}
.pill-tab {
    flex: 1; padding: 8px 0;
    text-align: center; font-size: var(--ts-sm); font-weight: 600;
    border-radius: var(--r-full); border: none;
    background: transparent; color: var(--text-3);
    cursor: pointer; font-family: var(--font);
    transition: all var(--t-base) var(--ease);
}
.pill-tab.active {
    background: var(--gradient-main);
    color: white; box-shadow: var(--shadow-sm);
}
.tab-content { display: none; animation: fadeUp 0.3s var(--ease) both; }
.tab-content.active { display: block; }

/* ═══ PROGRESS CIRCLE (Shopping) ═══ */
.progress-hero {
    display: flex; flex-direction: column; align-items: center;
    padding: var(--s6) 0 var(--s4);
}
.progress-circle-container { position: relative; width: 120px; height: 120px; }
.progress-circle-svg { transform: rotate(-90deg); }
.progress-circle-bg { fill: none; stroke: rgba(255,255,255,0.04); }
.progress-circle-fill {
    fill: none; stroke-linecap: round;
    stroke: url(#progressGrad);
    transition: stroke-dashoffset 1s var(--ease);
}
.progress-circle-text {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}
.progress-pct { font-size: var(--ts-2xl); font-weight: 800; }
.progress-count { font-size: var(--ts-xs); color: var(--text-3); }

/* Swipeable items */
.swipe-item {
    position: relative; overflow: hidden;
    border-radius: var(--r2); margin-bottom: var(--s2);
}
.swipe-content {
    display: flex; align-items: center; gap: var(--s3);
    padding: var(--s3) var(--s4);
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--r2);
    transition: transform var(--t-base) var(--ease), opacity var(--t-base) var(--ease);
    position: relative; z-index: 1;
    cursor: pointer;
}
.swipe-actions {
    position: absolute; top: 0; right: 0; bottom: 0;
    display: flex; align-items: stretch; z-index: 2;
}
.swipe-action {
    width: 64px; display: flex; align-items: center; justify-content: center;
    border: none; cursor: pointer; font-size: 1.2rem;
    color: white;
}
.swipe-action.action-pantry { background: var(--good); }
.swipe-action.action-delete { background: var(--bad); }
.swipe-item.checked .swipe-content { opacity: 0.4; }
.swipe-item.checked .item-name { text-decoration: line-through; }

.item-check {
    width: 22px; height: 22px; border-radius: 6px;
    border: 2px solid var(--border-2);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
    font-size: 11px; color: transparent;
    transition: all var(--t-fast) var(--ease);
}
.item-check.done {
    background: var(--good); border-color: var(--good); color: white;
}
.item-name { font-weight: 500; font-size: var(--ts-base); }
.item-qty { font-size: var(--ts-sm); color: var(--text-3); }

/* Shopping category */
.shop-cat {
    font-size: var(--ts-xs); font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--accent);
    padding: var(--s3) 0 var(--s1); display: flex; align-items: center; gap: var(--s2);
}

/* ═══ VISUAL PANTRY CARDS ═══ */
.pantry-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.pantry-visual {
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--r3);
    padding: var(--s3); text-align: center;
    transition: all var(--t-base) var(--ease);
    position: relative; overflow: hidden;
    cursor: pointer;
}
.pantry-visual:hover { border-color: var(--border-2); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.pantry-visual:active { transform: scale(0.97); }
.pv-emoji { font-size: 2rem; display: block; margin-bottom: var(--s1); }
.pv-name { font-size: 11px; font-weight: 600; line-height: 1.2; margin-bottom: var(--s1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-qty { font-size: var(--ts-xs); color: var(--text-3); font-weight: 500; }

.pv-stepper {
    display: flex; align-items: center; justify-content: center;
    gap: 2px; margin-top: var(--s2);
}
.pv-step-btn {
    width: 24px; height: 24px; border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card); color: var(--text-2);
    font-size: 14px; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--t-fast) var(--ease);
}
.pv-step-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.pv-step-val {
    font-size: var(--ts-sm); font-weight: 700;
    min-width: 28px; text-align: center;
}

.pv-cart-btn {
    width: 100%; margin-top: var(--s2);
    padding: 5px 0; border: 1px solid var(--border-2);
    border-radius: var(--r-full);
    background: var(--bg-card); color: var(--text-2);
    font-size: 10px; font-weight: 600; font-family: var(--font);
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 3px;
    transition: all var(--t-base) var(--ease);
}
.pv-cart-btn:hover {
    background: var(--accent-soft); border-color: var(--accent);
    color: var(--accent);
}
.pv-cart-btn:active { transform: scale(0.95); }

.pv-badge {
    position: absolute; top: var(--s1); right: var(--s1);
    font-size: 8px; padding: 1px 5px; border-radius: var(--r-full);
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.pv-badge-expired { background: var(--bad-bg); color: var(--bad); }
.pv-badge-expiring { background: var(--warn-bg); color: var(--warn); }

/* ═══ BOTTOM NAV + FAB ═══ */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: rgba(11, 11, 17, 0.92);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 16px;
    color: var(--text-3); text-decoration: none;
    position: relative;
    transition: color var(--t-base) var(--ease);
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item span { font-size: 9px; font-weight: 600; letter-spacing: 0.3px; }
.nav-item:hover { color: var(--text-2); }
.nav-item.active { color: var(--accent); }
.nav-item.active::before {
    content: ''; position: absolute; top: -1px;
    left: 50%; transform: translateX(-50%);
    width: 20px; height: 2px;
    background: var(--gradient-main); border-radius: 0 0 2px 2px;
}

/* FAB */
.fab-wrapper { position: relative; }
.fab-btn {
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--gradient-main);
    border: none; color: white; font-size: 1.5rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px var(--accent-glow);
    margin-top: -20px;
    transition: transform var(--t-base) var(--ease-bounce), box-shadow var(--t-base) var(--ease);
    position: relative; z-index: 2;
}
.fab-btn:hover { transform: scale(1.08) translateY(-2px); box-shadow: 0 6px 28px var(--accent-glow); }
.fab-btn.open { transform: rotate(45deg); }

.fab-menu {
    position: absolute; bottom: 100%; left: 50%;
    transform: translate(-50%, 35%) scale(0);
    opacity: 0; pointer-events: none;
    display: flex; flex-direction: column; gap: var(--s2);
    padding: var(--s3); margin-bottom: var(--s3);
    background: var(--bg-card-solid);
    border: 1px solid var(--border-2);
    border-radius: var(--r3);
    box-shadow: var(--shadow-lg);
    transition: all var(--t-base) var(--ease-bounce);
    min-width: 170px;
}
.fab-menu.open {
    transform: translate(-50%, 0) scale(1);
    opacity: 1; pointer-events: auto;
}
.fab-menu-item {
    display: flex; align-items: center; gap: var(--s3);
    padding: var(--s2) var(--s3);
    border-radius: var(--r2);
    text-decoration: none; color: var(--text);
    font-size: var(--ts-sm); font-weight: 500;
    transition: background var(--t-fast) var(--ease);
}
.fab-menu-item:hover { background: var(--bg-card-hover); color: var(--text); }
.fab-menu-item span:first-child { font-size: 1.2rem; }
.fab-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.4); z-index: 99;
}
.fab-backdrop.open { display: block; }

/* ═══ CHAT ═══ */
.chat-page { display: flex; flex-direction: column; height: calc(100dvh - var(--nav-h)); margin: calc(-1 * var(--s4)); }
.chat-msgs { flex: 1; overflow-y: auto; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.chat-bubble { max-width: 82%; padding: var(--s3) var(--s4); border-radius: var(--r3); line-height: 1.5; font-size: var(--ts-base); }
.chat-bubble.user { align-self: flex-end; background: var(--gradient-main); color: white; border-bottom-right-radius: var(--r1); }
.chat-bubble.bot { align-self: flex-start; background: var(--bg-card-solid); border: 1px solid var(--border); border-bottom-left-radius: var(--r1); }
.chat-bubble .bot-avatar { font-size: 0.9rem; margin-right: var(--s1); }

.chat-action-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--r2); padding: var(--s3);
    margin-top: var(--s2); display: flex; align-items: center; gap: var(--s2);
    font-size: var(--ts-sm);
}
.chat-action-card a { color: var(--accent); text-decoration: underline; }

.chat-input-area { padding: var(--s3); background: var(--bg-surface); border-top: 1px solid var(--border); }
.chat-glass {
    display: flex; align-items: center;
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    padding: var(--s1) var(--s3);
}
.chat-glass:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-glass input {
    flex: 1; border: none; background: transparent;
    padding: var(--s2); font-size: var(--ts-base);
    outline: none; color: var(--text); font-family: var(--font);
}
.chat-glass input::placeholder { color: var(--text-3); }
.chat-send {
    background: transparent; border: none; font-size: 1.2rem;
    color: var(--accent); cursor: pointer; padding: var(--s2);
    opacity: 0.6; transition: opacity var(--t-fast);
}
.chat-send:hover:not(:disabled) { opacity: 1; }

.chat-welcome {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; text-align: center;
    padding: var(--s8);
}
.cw-avatar { font-size: 3rem; margin-bottom: var(--s4); animation: pulse 3s ease-in-out infinite; }
.cw-title { font-size: var(--ts-xl); font-weight: 700; color: var(--accent); margin-bottom: var(--s1); }
.cw-sub { color: var(--text-3); margin-bottom: var(--s6); }
.cw-chips { display: flex; flex-direction: column; gap: var(--s2); width: 100%; max-width: 280px; }
.cw-chip {
    background: var(--bg-card-solid); border: 1px solid var(--border);
    border-radius: var(--r-full); padding: var(--s2) var(--s4);
    text-align: center; cursor: pointer; color: var(--text);
    font-family: var(--font); font-size: var(--ts-sm);
    transition: all var(--t-base) var(--ease);
}
.cw-chip:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }

.typing-dots { display: flex; gap: 4px; padding: var(--s1); }
.typing-dots span { width: 7px; height: 7px; background: var(--text-3); border-radius: 50%; animation: typing 1.4s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%,60%,100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ═══ IOS-STYLE SETTINGS ═══ */
.settings-group { margin-bottom: var(--s6); }
.settings-group-title {
    font-size: var(--ts-xs); font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-3); padding: 0 var(--s4) var(--s2);
}
.settings-card {
    background: var(--bg-card-solid);
    border-radius: var(--r3); overflow: hidden;
    border: 1px solid var(--border);
}
.settings-row {
    display: flex; align-items: center; gap: var(--s3);
    padding: var(--s3) var(--s4); min-height: 44px;
    border-bottom: 1px solid var(--border);
    transition: background var(--t-fast) var(--ease);
}
.settings-row:last-child { border-bottom: none; }
.settings-row:hover { background: var(--bg-card-hover); }
.sr-icon { font-size: 1.1rem; flex-shrink: 0; width: 28px; text-align: center; }
.sr-label { flex: 1; font-size: var(--ts-base); font-weight: 500; }
.sr-value { font-size: var(--ts-sm); color: var(--text-3); }
.sr-chevron { color: var(--text-3); font-size: 12px; }

/* Toggle switch */
.toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--border-2); border-radius: var(--r-full);
    cursor: pointer;
    transition: background var(--t-base) var(--ease);
}
.toggle-slider::before {
    content: ''; position: absolute;
    left: 2px; top: 2px; width: 20px; height: 20px;
    background: white; border-radius: 50%;
    transition: transform var(--t-base) var(--ease);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Inline edit row */
.sr-input {
    text-align: right; border: none; background: transparent;
    color: var(--text); font-family: var(--font);
    font-size: var(--ts-sm); width: 100px; outline: none;
}

/* ═══ FORMS ═══ */
.form-group { margin-bottom: var(--s4); }
.form-label { display: block; font-size: var(--ts-sm); font-weight: 600; color: var(--text-2); margin-bottom: var(--s1); }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: var(--s3) var(--s4);
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--r2); color: var(--text);
    font-family: var(--font); font-size: var(--ts-base);
    transition: border-color var(--t-base), box-shadow var(--t-base);
    -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-3); }
.form-textarea { min-height: 100px; resize: vertical; }

/* ═══ BUTTONS ═══ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
    padding: 10px 20px; font-size: var(--ts-base); font-weight: 600;
    font-family: var(--font); border-radius: var(--r-full);
    border: none; cursor: pointer; color: var(--text);
    transition: all var(--t-base) var(--ease); text-decoration: none; line-height: 1.3;
}
.btn-p { background: var(--gradient-main); color: white; }
.btn-p:hover { transform: translateY(-1px); box-shadow: var(--shadow-glow); color: white; }
.btn-s { background: var(--bg-card-solid); border: 1px solid var(--border); color: var(--text-2); }
.btn-s:hover { border-color: var(--border-2); color: var(--text); }
.btn-d { background: var(--bad); color: white; }
.btn-ghost { background: transparent; color: var(--text-2); padding: 8px 12px; }
.btn-ghost:hover { color: var(--text); }
.btn-icon {
    width: 40px; height: 40px; padding: 0;
    border-radius: var(--r2); background: var(--bg-card);
    border: 1px solid var(--border); color: var(--text-2);
}
.btn-icon:hover { border-color: var(--border-2); color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: var(--ts-sm); }
.btn-lg { padding: 14px 28px; font-size: var(--ts-lg); }

/* ═══ TAGS ═══ */
.tag {
    display: inline-flex; align-items: center;
    padding: 3px 9px; font-size: var(--ts-xs); font-weight: 600;
    border-radius: var(--r-full);
    background: var(--accent-soft); color: var(--accent);
}
.tag-ok { background: var(--good-bg); color: var(--good); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }

/* ═══ MODALS ═══ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.65); backdrop-filter: blur(4px);
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 200; opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-sheet {
    background: var(--bg-surface);
    border-radius: var(--r5) var(--r5) 0 0;
    width: 100%; max-width: 500px; max-height: 85vh;
    overflow-y: auto;
    border: 1px solid var(--border); border-bottom: none;
    transform: translateY(100%);
    transition: transform 0.35s var(--ease);
}
.modal-overlay.active .modal-sheet { transform: translateY(0); }
.modal-handle {
    width: 36px; height: 4px; background: var(--border-2);
    border-radius: var(--r-full); margin: var(--s3) auto var(--s2);
}
.modal-head { padding: 0 var(--s5) var(--s3); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-size: var(--ts-lg); font-weight: 700; }
.modal-close {
    background: var(--bg-card); border: 1px solid var(--border);
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-3); font-size: 12px;
}
.modal-body { padding: 0 var(--s5) var(--s5); }
.modal-foot { padding: var(--s3) var(--s5) var(--s5); display: flex; gap: var(--s2); }

/* ═══ TOAST ═══ */
.toast-box { position: fixed; top: var(--s4); left: 50%; transform: translateX(-50%); z-index: 500; display: flex; flex-direction: column; gap: var(--s2); max-width: 460px; width: calc(100% - 32px); }
.toast {
    display: flex; align-items: center; gap: var(--s2);
    padding: var(--s3) var(--s5);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r2);
    backdrop-filter: blur(16px);
    font-size: var(--ts-sm); font-weight: 500;
    animation: fadeUp 0.3s var(--ease);
    box-shadow: var(--shadow-lg);
}
.toast.ok { border-color: rgba(52,211,153,0.3); color: var(--good); }
.toast.err { border-color: rgba(248,113,113,0.3); color: var(--bad); }
.toast.wrn { border-color: rgba(251,191,36,0.3); color: var(--warn); }

/* ═══ EMPTY STATE ═══ */
.empty { text-align: center; padding: var(--s10) var(--s5); color: var(--text-3); }
.empty-icon { font-size: 3rem; margin-bottom: var(--s4); }

/* ═══ NUTRITION BARS ═══ */
.nut-row {
    background: var(--bg-card-solid); border: 1px solid var(--border);
    border-radius: var(--r2); padding: var(--s3) var(--s4);
    margin-bottom: var(--s2); transition: border-color var(--t-base);
}
.nut-row:hover { border-color: var(--border-2); }
.nut-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s1); }
.nut-name { font-weight: 500; font-size: var(--ts-sm); }
.nut-val { font-size: var(--ts-xs); color: var(--text-2); }
.nut-bar { height: 6px; background: rgba(255,255,255,0.04); border-radius: var(--r-full); overflow: hidden; }
.nut-fill { height: 100%; border-radius: var(--r-full); transition: width 0.6s var(--ease); min-width: 2px; }
.nut-fill.s-good { background: linear-gradient(90deg, #10B981, #34D399); }
.nut-fill.s-low  { background: linear-gradient(90deg, #F59E0B, #FBBF24); }
.nut-fill.s-bad  { background: linear-gradient(90deg, #EF4444, #F87171); }
.nut-fill.s-over { background: linear-gradient(90deg, #3B82F6, #60A5FA); }

/* Status text */
.st-good { color: var(--good); } .st-low { color: var(--warn); }
.st-bad  { color: var(--bad); }  .st-over { color: var(--info); }

/* ═══ UTILS ═══ */
.text-2 { color: var(--text-2) !important; }
.text-3 { color: var(--text-3) !important; }
.tc { text-align: center; }
.flex { display: flex; } .flex-col { flex-direction: column; }
.items-c { align-items: center; } .jc-sb { justify-content: space-between; }
.gap-1 { gap: var(--s1); } .gap-2 { gap: var(--s2); } .gap-3 { gap: var(--s3); } .gap-4 { gap: var(--s4); }
.mb-2 { margin-bottom: var(--s2); } .mb-3 { margin-bottom: var(--s3); }
.mb-4 { margin-bottom: var(--s4); } .mb-5 { margin-bottom: var(--s5); }
.mb-6 { margin-bottom: var(--s6); } .mt-3 { margin-top: var(--s3); }
.mt-4 { margin-top: var(--s4); } .mt-5 { margin-top: var(--s5); }
.hidden { display: none !important; }
.w-full { width: 100%; }
.fw { flex-wrap: wrap; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: var(--r-full); }
::selection { background: var(--accent-soft); color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 420px) {
    .container { padding: 0 var(--s3); }
    .bento { gap: var(--s2); }
    .pantry-grid { grid-template-columns: repeat(2, 1fr); }
}