:root {
    color-scheme: dark;
    --color-primary: #AD7CFF;
}
* { box-sizing: border-box; }

/* The hidden attribute's UA default (display:none) has no specificity advantage over an author
   rule like .header-actions{display:flex} - origin (author beats UA) wins regardless, so an
   element that's both .hidden and e.g. a flex row stays visibly flex. Found via the Foods/Meals
   segmented control: #meals-actions correctly had the hidden attribute set, but still rendered
   (its own .header-actions{display:flex} rule was winning). This restores hidden's actual
   contract - always hidden, full stop - for every element that uses it. */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    /* Belt-and-braces: nothing below should ever need this, but a stray overflow becomes an
       invisible-to-desktop, broken-on-phone bug otherwise. */
    overflow-x: hidden;
    background: #14161a;
    color: #e4e6eb;
    font: 16px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--color-primary); }

/* Splash (Home only, first load of the session - see app.js): full-screen purple gradient, the
   same palette as the gauge's own gradient elsewhere on this page, with the utensils mark
   popping in and the whole thing fading out shortly after. z-index comfortably above every other
   overlay in the app (sheets 95, snackbar 200, pull-refresh 250) so nothing shows through it. */
.kcal-splash {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #D9B8FF 0%, #AD7CFF 45%, #8C4FFF 100%);
    animation: kcal-splash-fade 1.6s ease forwards;
}
.kcal-splash-icon {
    width: 64px;
    height: 64px;
    fill: #fff;
    animation: kcal-splash-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes kcal-splash-pop {
    0% { transform: scale(0.4); opacity: 0; }
    60% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
/* Holds full opacity through the pop-in plus a brief beat (the first 70% of the 1.6s), then
   fades over the rest - visibility:hidden and pointer-events:none at the end so a slow-to-fire
   animationend listener (app.js, which removes the element entirely) can't leave an invisible
   but still-interactive layer sitting over the page in the meantime. */
@keyframes kcal-splash-fade {
    0%, 70% { opacity: 1; visibility: visible; }
    100% { opacity: 0; visibility: hidden; pointer-events: none; }
}

/* Toast for actions that deliberately stay on the page (app.js's showSnackbar) - top-of-screen,
   not bottom, so it doesn't sit over the bottom nav or get confused for a new bottom sheet. */
.snackbar {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translate(-50%, -20px);
    max-width: calc(100vw - 32px);
    background: #1d2127;
    border: 1px solid var(--color-primary);
    color: #e4e6eb;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    z-index: 200;
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
.snackbar.show { opacity: 1; transform: translate(-50%, 0); }

/* Pull-to-refresh indicator (Home page only, see app.js) - pinned to the top edge, hidden (0
   opacity, pulled up behind the edge) until a drag-down-from-the-top gesture reveals it. JS drives
   transform/opacity directly while actively dragging (transition: none, so it tracks the finger
   1:1); this transition is what takes back over on release, whichever way it settles. Higher
   z-index than .snackbar so the two never visually compete if a refresh happens to land right as
   one is showing. */
.pull-refresh {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translate(-50%, -48px);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1d2127;
    border: 1px solid #2a2f37;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    z-index: 250;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.25s ease;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
.pull-refresh svg { width: 16px; height: 16px; fill: var(--color-primary); transition: fill 0.15s ease; }
/* Past the trigger threshold - still just held, not released yet. */
.pull-refresh.ready svg { fill: #5fd98a; }
.pull-refresh.loading svg { animation: pull-refresh-spin 0.7s linear infinite; }
@keyframes pull-refresh-spin { to { transform: rotate(360deg); } }

/* A visible focus state in the brand color, not just whatever default the browser picks. */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
    /* Clears the floating bottom nav so the last bit of page content is never hidden behind it -
       bigger than the nav's own footprint (padding + content + the gap it now floats above the
       bottom edge by) to leave real breathing room, not just the bare minimum. */
    padding-bottom: 120px;
}
.wrap-narrow { max-width: 420px; }

/* Floating pill, not an edge-to-edge bar - margin on all sides (including the bottom, via the
   env() safe-area padding below rather than touching the very edge), a full border instead of
   just border-top, and a small dot under whichever tab is active instead of relying on icon
   colour alone to show it. Applies to every page (shared fragment), not just Home, so the nav
   looks the same wherever you are. */
.bottom-nav {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    z-index: 50;
    display: flex;
    /* #1d2127 at 70% opacity, with the page content blurred behind it through the remaining
       30% - -webkit- prefix needed for Safari/iOS (incl. standalone PWA mode), which doesn't
       support the unprefixed property yet. */
    background: rgba(29, 33, 39, 0.7);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1px solid #2a2f37;
    border-radius: 24px;
    padding: 8px 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 2px;
    border-radius: 16px;
    color: #9aa1ac;
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
}
.bottom-nav a svg { width: 20px; height: 20px; fill: currentColor; }
.bottom-nav a.active { color: var(--color-primary); }
.bottom-nav a::after {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    margin-top: 1px;
    background: transparent;
}
.bottom-nav a.active::after { background: var(--color-primary); }

/* Bottom sheet (e.g. "New meal"): slides up over the page instead of navigating to it. Above
   the bottom nav (z-index 50) so it covers it while open. */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 90;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 95;
    max-height: 85vh;
    overflow-y: auto;
    background: #1d2127;
    border: 1px solid #2a2f37;
    border-bottom: none;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    padding-bottom: env(safe-area-inset-bottom);
}
.sheet.open { transform: translateY(0); }
/* The draggable area is the whole bar's row (full width, 28px tall), not just the visible 4px
   bar itself - that alone is far smaller than a usable touch target. The bar stays the same
   visible size via ::before; touch-action:none stops the browser's own scroll/pull-to-refresh
   gesture from fighting the drag-to-close handling wired up in app.js. */
.sheet-handle {
    width: 100%;
    height: 28px;
    margin: 4px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
}
.sheet-handle::before {
    content: '';
    width: 40px;
    height: 4px;
    background: #3a3f48;
    border-radius: 2px;
}
/* 40px clear of the bottom of the screen below the last button/content, on every bottom sheet
   (Add food, New meal, Set calories burnt, Weigh in, Change target - all share .sheet-content).
   Stacks with .sheet's own env(safe-area-inset-bottom) above, so a notched phone's home-indicator
   area adds to this rather than eating into it. */
.sheet-content { padding: 8px 16px 40px; }

h2 { font-size: 1rem; color: #c3c7cf; margin: 24px 0 10px; }
/* Profile page only so far - a back button beside the title instead of the plain <h2> other
   simple pages use. The row carries the usual h2 margin itself so the h2 inside doesn't double
   it up. */
.page-header { display: flex; align-items: center; gap: 10px; margin: 24px 0 10px; }
.page-header h2 { margin: 0; }
/* Still used by onboarding.html's own header ("Let's set up your goal") - the login page below
   has its own bigger, more "branded" header treatment now (.login-title etc.), not this. */
.auth-title { font-size: 1.4rem; margin: 12px 0 8px; text-align: center; }
.auth-sub { color: #9aa1ac; text-align: center; margin: 0 0 20px; font-size: 0.9rem; }

/* Login page - the big gradient icon badge (same palette as the splash screen and onboarding's
   progress bar - one consistent "brand purple" across the app), brand title/tagline, then a card
   with the actual phone-number form. .form label's own font-size/color (0,1,1 specificity) would
   otherwise beat a plain .login-field-label (0,1,0) regardless of source order - same gotcha as
   .onboard-text-input earlier - hence ".form .login-field-label" below. */
.login-icon {
    width: 110px;
    height: 110px;
    margin: 48px auto 0;
    border-radius: 28px;
    background: linear-gradient(160deg, #D9B8FF 0%, #AD7CFF 45%, #8C4FFF 100%);
    box-shadow: 0 0 40px rgba(173, 124, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-icon svg { width: 48px; height: 48px; fill: #fff; }
.login-title { font-size: 1.9rem; font-weight: 800; color: #fff; text-align: center; margin: 20px 0 6px; }
.login-tagline { color: #9aa1ac; text-align: center; margin: 0 0 32px; font-size: 0.95rem; }

.card.login-card { padding: 24px 20px; }
.login-card-title { font-size: 1.3rem; font-weight: 800; color: #fff; margin: 0 0 8px; }
.login-card-sub { color: #9aa1ac; font-size: 0.9rem; margin: 0 0 20px; line-height: 1.4; }
.form .login-field-label { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.7rem; font-weight: 700; color: #9aa1ac; }

.login-submit-btn {
    width: 100%;
    height: 56px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(90deg, #8C4FFF, #AD7CFF);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(173, 124, 255, 0.45);
}
.login-submit-arrow { margin-left: 4px; }

/* Onboarding progress - one segment per .onboard-step field, filled in as you reach it (not
   grouped into sections - see app.js). Replaces the old plain dot-row; matches the
   segmented-bar-plus-counter pattern this was explicitly modeled on. */
.onboard-progress { margin: 0 0 20px; }
.onboard-progress-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.onboard-progress-step-label { color: var(--color-primary); font-weight: 700; font-size: 0.95rem; }
.onboard-progress-count { font-size: 0.85rem; color: #9aa1ac; }
.onboard-progress-count strong { color: #fff; font-size: 1rem; }
.onboard-progress-bar { display: flex; gap: 6px; }
/* No overflow:hidden here (unlike a typical progress track) - each segment is only ever 0% or
   100% filled now (one per question, not a partial-within-a-section fill), so there's no
   partial-width corner to clip, and clipping would also cut off the fill's own glow below. */
.onboard-segment { flex: 1; height: 6px; border-radius: 3px; background: #2a2f37; }
.onboard-segment-fill {
    height: 100%;
    width: 0;
    border-radius: 3px;
    background: linear-gradient(90deg, #D9B8FF, #8C4FFF);
    /* Soft glow on the lit portion - a plain overflow:hidden fill read as flat against this dark
       a background, the reference's version has a visible bloom around it. */
    box-shadow: 0 0 8px rgba(173, 124, 255, 0.7);
    transition: width 0.25s ease;
}

/* Only one .onboard-step is display:block at a time (app.js); the rest are none. */
.onboard-step { display: none; }
.onboard-question { font-size: 1.6rem; font-weight: 800; color: #fff; margin: 0 0 10px; line-height: 1.25; }
.onboard-subtext { color: #9aa1ac; font-size: 0.95rem; margin: 0 0 8px; }
/* Name is the one onboard-step that's still a plain text field, not a wheel or choice list - an
   ordinary .form input (boxed, same as every other text field in the app), just with some top
   margin to clear the subtext above it. No font/border/background overrides needed here (unlike
   the old big-centered-text treatment this replaced), so no specificity fight with .form input. */
/* Not wrapped in a .form label here (unlike every other .form input in the app) - .form label's
   own flex/column layout is what stretches a plain input to full width elsewhere, so this needs
   its own explicit width now that there's no such wrapper giving it that for free. */
.onboard-name-input { display: block; width: 100%; margin-top: 28px; }

/* Scroll-wheel picker (date of birth, height, weight) - a native-feeling "spin to pick a value"
   control built from plain scroll-snap, since there's no HTML equivalent. Each .wheel-col is a
   fixed-height window (5 rows) onto a taller scrolling list; .wheel-col-scroll's own top/bottom
   padding (2 rows' worth) is what lets the first/last real item still reach the centre. app.js
   tracks whichever item is centred as "selected" and writes it into this step's own hidden
   input - the thing the form actually submits. */
.wheel-picker { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 32px 0 16px; }
.wheel-col { position: relative; width: 64px; height: 200px; }
.wheel-col-wide { width: 100px; }
.wheel-col-month { width: 90px; }
.wheel-col-year { width: 84px; }
.wheel-col-scroll {
    height: 100%;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 80px 0;
}
.wheel-col-scroll::-webkit-scrollbar { display: none; }
.wheel-item {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: center;
    font-size: 1.15rem;
    font-weight: 700;
    color: #4a4f58;
    transition: color 0.15s ease, font-size 0.15s ease;
}
.wheel-item.selected { color: #fff; font-size: 1.4rem; }
/* The centre "slot" the picker always scrolls to - a static highlight, not tied to any one row,
   since it's the row underneath it that changes as you scroll. */
.wheel-col::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 80px;
    height: 40px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    pointer-events: none;
}
/* Fades the rows nearest the top/bottom edge of the window toward the page background, rather
   than clipping them off sharply - reads as "more to scroll to" instead of a hard cut. Above the
   centre-slot highlight (z-index) so it fades that too right at the very edge of the column. */
.wheel-col::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 10px;
    background: linear-gradient(#14161a, transparent 35%, transparent 65%, #14161a);
    pointer-events: none;
}
.wheel-unit { font-size: 1rem; color: #9aa1ac; font-weight: 600; align-self: center; }

/* Tap-to-select rounded options (sex, activity level, goal) - the other half of "no native
   select/radio" alongside the wheel picker above, same rounded-card visual language. .choice-row
   lays two short options side by side (sex) instead of stacking every option full-width (the
   longer activity/goal labels, which stay stacked). Each option is its own text block (title,
   optional "Recommended" badge, optional one-line description) plus a radio-style indicator on
   the right - an outline ring normally, filled with a check once selected. */
.choice-list { display: flex; flex-direction: column; gap: 10px; margin: 28px 0 16px; }
.choice-list.choice-row { flex-direction: row; }
.choice-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-radius: 14px;
    background: #1d2127;
    border: 1px solid #2a2f37;
    color: #e4e6eb;
    text-align: left;
    cursor: pointer;
}
.choice-list.choice-row .choice-option { justify-content: center; }
.choice-option-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.choice-option-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.choice-option-title { font-size: 0.95rem; font-weight: 700; color: #e4e6eb; }
.choice-option-sub { font-size: 0.8rem; color: #9aa1ac; }
.choice-option-badge {
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    background: rgba(173, 124, 255, 0.25);
    border: 1px solid var(--color-primary);
    border-radius: 999px;
    padding: 2px 10px;
    white-space: nowrap;
}
/* The outline-ring-or-filled-check indicator - .choice-row (sex) hides it rather than removing
   it from the markup, so both option types share one JS click handler and one selected-state
   look (the glowing border below) without a sex-specific branch anywhere. */
.choice-option-radio {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #4a4f58;
    display: flex;
    align-items: center;
    justify-content: center;
}
.choice-list.choice-row .choice-option-radio { display: none; }
.choice-option-radio svg { width: 13px; height: 13px; fill: #fff; display: none; }
.choice-option.selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary), 0 0 16px rgba(173, 124, 255, 0.4);
}
.choice-option.selected .choice-option-title { color: #fff; }
.choice-option.selected .choice-option-radio { background: var(--color-primary); border-color: var(--color-primary); }
.choice-option.selected .choice-option-radio svg { display: block; }

/* Goal step only - a final glance back over everything entered, read live from the form's own
   fields (app.js's updateSnapshot). Native <details>/<summary>, same zero-JS-accordion approach
   as Profile's FAQ, just its own look (icon-left/chevron-right summary row) rather than that
   page's +/x text marker. */
.onboard-snapshot {
    margin: 8px 0 4px;
    border: 1px solid #2a2f37;
    border-radius: 14px;
    padding: 14px 16px;
    background: #1d2127;
}
.onboard-snapshot summary {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 600;
    color: var(--color-primary);
    list-style: none;
}
.onboard-snapshot summary::-webkit-details-marker { display: none; }
.onboard-snapshot summary svg { width: 15px; height: 15px; fill: var(--color-primary); flex-shrink: 0; }
.onboard-snapshot summary span { flex: 1; }
.onboard-snapshot-chevron { transition: transform 0.2s ease; }
.onboard-snapshot[open] .onboard-snapshot-chevron { transform: rotate(180deg); }
.onboard-snapshot-body { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid #2a2f37; }
.onboard-snapshot-row { display: flex; justify-content: space-between; gap: 10px; font-size: 0.85rem; }
.onboard-snapshot-row > span:first-child { color: #9aa1ac; }
.onboard-snapshot-row > span:last-child { color: #e4e6eb; font-weight: 600; text-align: right; }

/* Fixed to the bottom of the screen on every step - otherwise its vertical position jumps around
   with how much content each step has above it (the DOB wheel picker vs. a short choice list),
   and on a long step (Activity's 5 options, or Goal with the snapshot expanded) it would scroll
   out of reach entirely. Same "solid bar, border-top" look as the app's own .bottom-nav
   elsewhere, not a floating/transparent overlay - onboarding has no bottom-nav of its own to
   clash with, so this owns the full width of that space. */
.onboard-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    background: #1d2127;
    border-top: 1px solid #2a2f37;
}
/* Clears the fixed nav so the last bit of each step's own content (the Goal step's snapshot
   panel, in particular) never ends up hidden behind it. */
#onboard-form { padding-bottom: 110px; }
/* Circular, icon-only - distinct from the app's everyday .btn-secondary (which keeps its usual
   look everywhere else); this is just for this one flow. */
.onboard-back-btn {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #2a2f37;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.onboard-back-btn svg { width: 16px; height: 16px; fill: #e4e6eb; }
.onboard-next-btn, .onboard-finish-btn {
    flex: 1;
    height: 56px;
    border-radius: 999px;
    border: none;
    background: var(--color-primary);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(173, 124, 255, 0.45);
}
.onboard-finish-arrow { margin-left: 2px; }
/* Back/Next/Finish visibility is also toggled by app.js per step (first step has no Back, only
   the last step shows Finish instead of Next) - these are just the initial/default states so
   there's no flash of the wrong buttons before that JS runs on page load. display:none, not
   visibility:hidden, on step 1's Back button specifically - visibility:hidden still reserves its
   56px+gap of layout space, leaving Next off-centre instead of actually full width. */
#onboard-back { display: none; }
#onboard-finish { display: none; }

.card {
    background: #1d2127;
    border: 1px solid #2a2f37;
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 16px;
}
/* Day-detail page: the weigh-in and/or calories burnt captured on this specific day, if any, sit
   alongside the meal totals rather than only ever showing up on the Home page. */
.day-stat-card { display: flex; align-items: center; gap: 10px; }
.day-stat-card svg { width: 18px; height: 18px; fill: var(--color-primary); flex-shrink: 0; }
.day-badge-emoji { font-size: 18px; line-height: 1; }

/* "Add to today's target" toggle, Home page's Calories burnt card. A hidden checkbox (opacity:0,
   still the real interactive/keyboard-accessible control) sized/positioned over a styled track,
   so the visuals are just CSS - no icon or extra markup needed per state. */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; cursor: pointer; }
.toggle-switch input {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
    cursor: pointer;
}
.toggle-track {
    position: absolute;
    inset: 0;
    background: #2a2f37;
    border-radius: 12px;
    transition: background 0.2s ease;
}
.toggle-track::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #e4e6eb;
    border-radius: 50%;
    transition: transform 0.2s ease;
}
.toggle-switch input:checked ~ .toggle-track { background: var(--color-primary); }
.toggle-switch input:checked ~ .toggle-track::before { transform: translateX(20px); }
/* Calories burnt card, Home page - tighter than the generic .card (less padding). .burnt-top is
   the icon-avatar/eyebrow+value/"Set calories" header row; .burnt-row (below the divider) is the
   eat-back toggle, its own row rather than .row-between, whose big margin is meant for a
   page-section header, not a flex row that already has the card's own padding around it. */
.burnt-card { padding: 16px; }
.burnt-top { display: flex; align-items: center; gap: 12px; }
.burnt-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 154, 60, 0.15);
    border: 1px solid rgba(255, 154, 60, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}
.burnt-avatar svg { width: 16px; height: 16px; fill: #FF9A3C; }
.burnt-top-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.burnt-eyebrow { font-size: 0.65rem; color: #9aa1ac; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.burnt-value { font-size: 0.95rem; font-weight: 700; color: #e4e6eb; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.burnt-divider { height: 1px; background: #2a2f37; margin: 14px 0; }
.burnt-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.burnt-toggle-text { display: flex; flex-direction: column; gap: 2px; }
.burnt-toggle-text span { font-size: 0.9rem; font-weight: 600; color: #e4e6eb; }
.burnt-toggle-text p { margin: 0; font-size: 0.78rem; color: #9aa1ac; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: #9aa1ac; }
.form input, .form select {
    background: #14161a;
    border: 1px solid #2a2f37;
    border-radius: 8px;
    height: 48px;
    padding: 0 12px;
    color: #e4e6eb;
    font-size: 1rem;
}
.form input:read-only { opacity: 0.6; }
/* Profile's "Your name" card: Save sits right next to the input itself instead of under a full
   label+input stack, so the card stays short. Title keeps the same font-size/color as .form
   label's own text, just not a <label> itself since the input isn't nested inside it here.
   .name-card-field wraps title+row in their own tight 6px gap (matching .form label's own
   title-to-input spacing elsewhere) - without this wrapper, .form's own 14px inter-child gap
   would land between them instead, which read as too big a gap under the title. */
.name-card-field { display: flex; flex-direction: column; gap: 6px; }
.name-card-title { display: block; font-size: 0.85rem; color: #9aa1ac; }
.name-card-row { display: flex; align-items: center; gap: 8px; }
/* flex: 1 (not width: 100%) - it shares its row with the Save button now rather than owning the
   whole row to itself. */
.name-card-row .profile-name-input { flex: 1; min-width: 0; }

.btn-primary, .btn-secondary {
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }
/* An icon dropped straight into one of these (e.g. Home's "Log food"/"Weigh in") has no width/
   height/fill of its own otherwise - an <svg> with neither defaults to the browser's own
   fallback size (300x150px, enormous here) and fill:black, regardless of what icons.html's own
   viewBox says. currentColor keeps it matching whichever text colour the button itself has
   (white on .btn-primary, purple on .btn-secondary) rather than needing its own colour rule. */
.btn-primary svg, .btn-secondary svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    vertical-align: -2px;
    margin-right: 2px;
}
/* Same purple-tinted look as .meal-action.secondary (the "Delete meal" button) - one secondary
   style used everywhere instead of two different ones. border-box so the 1px border doesn't
   add to the padding-driven size like .meal-action's border: none sibling would. */
.btn-secondary {
    background: rgba(173, 124, 255, 0.15);
    color: var(--color-primary);
    border: 1px solid rgba(173, 124, 255, 0.3);
    box-sizing: border-box;
}
.btn-small { padding: 8px 12px; font-size: 0.85rem; }

.link-btn {
    background: none;
    border: none;
    color: #9aa1ac;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px;
}
.link-btn:hover { color: #e4e6eb; }
/* Bottom sheet "x" close button only (new-meal / add-food sheets) - a bigger glyph and tap
   target than the plain .link-btn default used elsewhere (row-remove, log-delete). */
.sheet-close { font-size: 32px; line-height: 1; padding: 4px 8px; }
.resend-form, .delete-form, .logout-form { text-align: center; margin-top: 4px; }

/* Profile page: Tips (plain list) and FAQ (native <details>/<summary> - a free, accessible
   accordion with no JS needed, consistent with how little custom interactivity the rest of this
   page already has beyond its two sheets). */
.tips-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; color: #c3c7cf; font-size: 0.9rem; }
.tips-list li { line-height: 1.4; }
.faq-card { padding-top: 6px; padding-bottom: 6px; }
.faq-item { border-bottom: 1px solid #2a2f37; padding: 12px 0; }
.faq-item:last-child { border-bottom: none; }
.faq-item summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: #e4e6eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
/* Hides the default disclosure triangle (Chrome/Safari put it before the summary text by
   default) - ::after below draws our own +/x indicator instead. */
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary { list-style: none; }
.faq-item summary::after {
    content: '+';
    font-size: 1.1rem;
    color: var(--color-primary);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { margin: 10px 0 0; color: #9aa1ac; font-size: 0.85rem; line-height: 1.5; }

.banner {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 0.9rem;
}
.banner-error { background: #3a1f24; color: #ff9b9b; border: 1px solid #5c2b33; }
.banner-info { background: rgba(173, 124, 255, 0.12); color: #d9b8ff; border: 1px solid rgba(173, 124, 255, 0.35); }
/* Foods/Meals page's "logging for a past/future day" banner - text and the "back to day" link
   share one row instead of stacking, so it reads as a single compact status line. */
.log-date-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.log-date-banner .link-btn { white-space: nowrap; }

/* Full-bleed purple glow behind the gauge: negative margin cancels .wrap's own 16px padding so
   the gradient reaches the screen edges, matching the reference's edge-to-edge hero look. */
.gauge-hero {
    background: radial-gradient(ellipse at 50% -10%, #AD7CFF 0%, #6b3fc2 30%, #14161a 72%);
    margin: -16px -16px 16px;
    padding: 20px 16px 14px;
    text-align: center;
}
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 12px; }
.hero-title { text-align: left; font-size: 1.3rem; font-weight: 700; color: #fff; margin: 0; }
.hero-top-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
/* Profile's one entry point now (removed from the bottom nav) - reuses .meal-action-icon's own
   size/shape/tint (same as Foods' Edit/Delete icon buttons) rather than a one-off size, just
   with the icon itself forced white instead of that class's usual purple - two classes to
   reliably outrank .meal-action-icon's own "color: var(--color-primary)" regardless of source
   order (same specificity-tiebreak pattern used elsewhere in this file). */
.hero-profile-btn.meal-action-icon { color: #fff; }
/* Today's live badge preview, top right of the hero - a dark pill like the rest of the app's
   chrome (not yet another bright hero-glow element), tinted per tier so it reads at a glance
   without needing to read the label text. */
.badge-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid #2a2f37;
    background: rgba(29, 33, 39, 0.85);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}
.badge-pill-emoji { font-size: 0.95rem; line-height: 1; }
.badge-pill.badge-three-stars, .badge-pill.badge-two-stars, .badge-pill.badge-one-star {
    border-color: #2e5c3f; color: #5fd98a;
}
.badge-pill.badge-piggy, .badge-pill.badge-elephant { border-color: #5c2b33; color: #ff8a8a; }
.gauge-wrap { position: relative; max-width: 280px; margin: 0 auto; }
.gauge-svg { width: 100%; height: auto; display: block; overflow: visible; }
.gauge-track { fill: none; stroke: rgba(255, 255, 255, 0.18); stroke-width: 16; stroke-linecap: round; }
.gauge-fill {
    fill: none;
    stroke: url(#gaugeGradient);
    stroke-width: 16;
    stroke-linecap: round;
    stroke-dasharray: 282.7; /* pi * 90 - the radius used in home.html's path */
    transition: stroke-dashoffset 0.5s ease;
}
.gauge-fill.over { stroke: #ff6a6a; }
/* Smaller ring nested inside the main one - calories burnt today vs. the daily target. No
   ".over" variant here: burning more than the target isn't a bad outcome the way over-eating is,
   so the fill just caps at a full ring (see HomeController's burnProgress) rather than recoloring. */
.burn-track { fill: none; stroke: rgba(255, 255, 255, 0.12); stroke-width: 12; stroke-linecap: round; }
.burn-fill {
    fill: none;
    stroke: url(#burnGradient);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 204.2; /* pi * 65 - the smaller radius used in home.html's inner path */
    transition: stroke-dashoffset 0.5s ease;
}
/* Badge icons at the start of each ring (see home.html): a small dark pin circle, outlined in
   that ring's own gradient color, with a white icon on top - reads clearly against either the
   ring stroke or the purple hero glow behind it, rather than blending into whichever is there. */
.gauge-pin { fill: #1d2127; stroke-width: 1.5; }
.gauge-pin-target { stroke: #AD7CFF; }
.gauge-pin-burn { stroke: #FF9A3C; }
.gauge-icon-target path, .gauge-icon-burn path { fill: #fff; }
/* "+" badge on the flame pin's corner when "eat back what you burn" is on - solid orange (not
   the dark-pin-with-orange-outline style the other badges use) so it reads as its own small
   marker rather than a third full badge competing with the two it's attached to. */
.gauge-pin-eatback { fill: #FF9A3C; stroke: #14161a; stroke-width: 1.5; }
.gauge-eatback-plus { font-size: 9px; font-weight: 800; fill: #14161a; text-anchor: middle; dominant-baseline: central; }
.gauge-center {
    position: absolute;
    left: 50%;
    bottom: 2px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.gauge-number { font-size: 2.1rem; font-weight: 800; color: #fff; line-height: 1.1; }
.gauge-label { font-size: 0.8rem; color: rgba(255, 255, 255, 0.75); }
.gauge-burn-label { font-size: 0.7rem; color: #FFB37A; margin-top: 2px; }

.tile svg { width: 18px; height: 18px; fill: var(--color-primary); margin-bottom: 2px; }

.row-between {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 24px 0 10px;
}
.row-between h2 { margin: 0; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* "BODY METRIC" above "Weight Trend" - a small label over a section header, for the one section
   that has both (everywhere else just has the h2 on its own). */
.eyebrow { font-size: 0.7rem; color: #9aa1ac; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; margin: 0 0 2px; }
/* "See all" (Smart Recommendations) - plain text link, not a button; the arrow is a literal
   character in the template (same "Finish setup →" / "Send code →" pattern used elsewhere)
   rather than a new icon fetch. */
.section-link { color: var(--color-primary); font-size: 0.85rem; font-weight: 600; text-decoration: none; white-space: nowrap; }

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 12px;
    margin-bottom: 14px;
    background: #1d2127;
    border: 1px solid #2a2f37;
    border-radius: 10px;
}
/* Highlight the whole bar (icon + padding included), not just the input's own box - the input
   has no border/padding of its own, so a focus ring on it alone would hug only the text area. */
.search-bar:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(173, 124, 255, 0.25);
}
.search-bar svg { width: 16px; height: 16px; fill: #9aa1ac; flex-shrink: 0; }
.search-bar input {
    flex: 1;
    width: 100%;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: none;
    background: none;
    color: #e4e6eb;
    font-size: 1rem;
}
/* The bar itself now shows focus (above); suppress the input's own focus-visible outline so it
   doesn't double up as a second, smaller ring inside the bar's. */
.search-bar input:focus-visible { outline: none; }
/* Hides Safari's own round "clear" button on a type=search input - its default light styling
   is hard to see against this dark background, and the search icon already on the left is
   enough of a visual anchor without it. */
.search-bar input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-empty { display: none; }

/* Foods/Meals segmented control (components.html) - switches the two panels below without a
   page navigation (app.js just toggles `hidden`); Foods is the default, set server-side via
   activeTab so there's no flash of the wrong segment before app.js's click handling takes over. */
.segmented-control {
    display: flex;
    background: #14161a;
    border: 1px solid #2a2f37;
    border-radius: 10px;
    padding: 3px;
    gap: 3px;
    margin-bottom: 14px;
}
.segment {
    flex: 1;
    padding: 8px 0;
    border: none;
    border-radius: 8px;
    background: none;
    color: #9aa1ac;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.segment.active { background: var(--color-primary); color: #fff; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.tile {
    background: #1d2127;
    border: 1px solid #2a2f37;
    border-radius: 10px;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.tile-label { font-size: 0.7rem; color: #9aa1ac; text-transform: uppercase; letter-spacing: 0.04em; }
.tile-value { font-size: 1.15rem; font-weight: 700; }
.tile-value.good { color: #5fd98a; }
.tile-value.bad { color: #ff8a8a; }
.tile-sub { font-size: 0.7rem; color: #9aa1ac; }
/* Home page Remaining tile: the eat-back bonus, kept visually tied to "burnt" (same orange as
   the gauge's burn ring/badge) rather than the plain muted .tile-sub color. */
.tile-sub-burn { color: #FF9A3C; font-weight: 600; }

/* Target/Consumed/Left hero cards, Home page only - a dedicated class rather than reusing
   .tiles/.tile above (which Profile and other pages also use for their own, simpler tiles): label
   + a small coloured icon badge on top, the big value underneath. Left's own border/icon tint
   switches good/bad as a whole (not just the value text, like the plain .tiles treatment does). */
.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card {
    background: #1d2127;
    border: 1px solid #2a2f37;
    border-radius: 14px;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.stat-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 4px; }
.stat-card-label { font-size: 0.62rem; color: #9aa1ac; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; margin-top: 2px; }
.stat-card-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(173, 124, 255, 0.12);
    border: 1px solid rgba(173, 124, 255, 0.35);
}
.stat-card-icon svg { width: 11px; height: 11px; fill: var(--color-primary); }
.stat-card-icon-consumed { background: rgba(255, 106, 106, 0.12); border-color: rgba(255, 138, 138, 0.4); }
.stat-card-icon-consumed svg { fill: #ff8a8a; }
.stat-card-icon-left { background: rgba(95, 217, 138, 0.12); border-color: rgba(95, 217, 138, 0.4); }
.stat-card-icon-left svg { fill: #5fd98a; }
.stat-card-value { font-size: 1.1rem; font-weight: 800; color: #fff; }
.stat-card-value.good { color: #5fd98a; }
.stat-card-value.bad { color: #ff8a8a; }
.stat-card-sub { font-size: 0.65rem; color: #FF9A3C; font-weight: 600; margin-top: -4px; }
.stat-card.stat-card-good { border-color: rgba(95, 217, 138, 0.45); }
.stat-card.stat-card-bad { border-color: rgba(255, 138, 138, 0.45); }

/* Same card look as .tile, but a clickable button (icon above label, centered) that opens a
   bottom sheet instead of just displaying a value - used on the Profile page. */
/* auto-fit/minmax instead of a fixed column count - now there's just "Change target" (Weigh in
   moved to the Home page), this fills the full row on its own rather than leaving a blank
   second column; it'd still lay out fine if another action joins it later. */
.profile-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile-btn {
    background: #1d2127;
    border: 1px solid #2a2f37;
    border-radius: 10px;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: #e4e6eb;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.tile-btn svg { width: 20px; height: 20px; fill: var(--color-primary); }
.tile-btn:hover { border-color: rgba(173, 124, 255, 0.4); }

.muted { color: #9aa1ac; font-size: 0.9rem; }

.log-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.log-row {
    background: #1d2127;
    border: 1px solid #2a2f37;
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    text-decoration: none;
    color: #e4e6eb;
}
/* Flex children default to a content-based min-width, which is exactly what let a long meal
   name push this row (and the page) wider than the viewport instead of wrapping. */
.log-row > div, .log-row > span, .log-row > label { min-width: 0; overflow-wrap: anywhere; }
.log-row-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
/* Foods page rows, and Home's Today's meals rows: force both halves to share one line instead of
   the plain .log-row's flex-wrap (which other pages still want, for long meal names that wrap
   rather than truncate). Flex-wrap's own line-breaking is decided by each item's un-shrunk
   content size, not its post-ellipsis rendered size - with wrap still allowed, an oversized
   .food-row-text gets pushed to its own line instead of actually being shrunk+truncated by the
   rules above. nowrap here removes that escape hatch, so shrinking (and therefore the ellipsis)
   is what happens. */
/* .exercise-log-row (workout.html's Exercises segment) shares this and every other rule below
   down to .qty-btn - same row shape, just a different domain (reps/sets instead of kcal), so
   there's no reason for the CSS itself to fork even though the JS wiring is fully separate (see
   app.js's wireExerciseRows). */
.food-log-row, .exercise-log-row { flex-wrap: nowrap; }

/* Name sits above its own kcal/unit (or kcal/serving-count, on Home) line (smaller, muted) rather
   than that figure sitting out on the row's right edge - the right side is reserved for the
   quantity stepper + Log/Edit buttons (Foods) or the delete button (Home) instead. */
.food-row-text, .exercise-row-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
/* Truncated, not wrapped - a long name wrapping onto a second line was pushing the stepper/Log
   button down to a new row entirely (.log-row below is flex-wrap). One line, cut off with an
   ellipsis if it doesn't fit, keeps the row's height fixed regardless of name length. min-width:0
   is needed here too, not just on .food-row-text above - these are themselves flex items of that
   column flex container, and flex items default to min-width:auto, which for nowrap text equals
   its full unwrapped width, overriding the ellipsis/overflow rules below without this. */
.food-row-name, .food-row-cal, .exercise-row-name, .exercise-row-unit { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.food-row-cal, .exercise-row-unit { font-size: 0.75rem; color: #9aa1ac; }
/* Log mode (default) vs Edit mode, toggled by the header's Edit/Done button adding/removing
   .edit-mode on the <ul> itself - one row shows a Log button, the other an Edit button, never
   both. .meal-action-icon supplies the base square shape/sizing both share; Log then overrides
   it to a solid filled look (the row's primary action) while Edit keeps the plain tinted one. */
/* Two classes each (not just .food-edit-btn/.food-log-btn alone) to reliably outrank the plain
   .meal-action-icon rule below - same specificity otherwise, and .meal-action-icon's own
   "display: inline-flex" comes later in this file, so it would win the tie without this. */
.food-edit-btn.meal-action-icon, .exercise-edit-btn.meal-action-icon { display: none; }
.log-list.edit-mode .food-log-btn.meal-action-icon, .log-list.edit-mode .exercise-log-btn.meal-action-icon { display: none; }
.log-list.edit-mode .food-edit-btn.meal-action-icon, .log-list.edit-mode .exercise-edit-btn.meal-action-icon { display: inline-flex; }
.food-log-btn.meal-action-icon, .exercise-log-btn.meal-action-icon { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.food-log-btn.meal-action-icon:hover, .exercise-log-btn.meal-action-icon:hover { background: #9a63f5; }
/* Quantity stepper - always visible (no checkbox to gate it on anymore). The number box itself
   is readonly - +/- are the only way to change it, no on-screen keyboard. */
.food-qty-stepper, .exercise-qty-stepper {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    border: 1px solid #2a2f37;
    border-radius: 6px;
    overflow: hidden;
}
.food-qty, .exercise-qty {
    width: 32px;
    height: 48px;
    padding: 0;
    border: none;
    background: #14161a;
    font-size: 0.85rem;
    text-align: center;
    color: #e4e6eb;
}
/* Firefox/Chrome's native up/down spinner on <input type=number> would duplicate (and conflict
   with, since this field is readonly) the qty-up/qty-down buttons either side of it. */
.food-qty::-webkit-outer-spin-button, .food-qty::-webkit-inner-spin-button,
.exercise-qty::-webkit-outer-spin-button, .exercise-qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.food-qty, .exercise-qty { -moz-appearance: textfield; }
/* Matches .food-qty's new 48px height so the whole -/number/+ pill reads as one consistent
   control, not a short number box flanked by taller buttons. */
.qty-btn {
    width: 28px;
    height: 48px;
    border: none;
    background: #1d2127;
    color: var(--color-primary);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.qty-btn:hover { background: #2a2f37; }
.qty-btn:active { background: rgba(173, 124, 255, 0.2); }
/* "Delete ingredient" inside the food sheet's edit mode - full width to match the Save/Add
   button above it (it isn't a .form child itself, so it doesn't inherit that flex stretch). */
.delete-component-form, .delete-exercise-form { margin-top: 10px; }
.delete-ingredient-btn { width: 100%; }

/* Meal library accordion: tapping a meal expands its ingredients in place instead of navigating
   to a separate page. max-height transition rather than JS-measured height - simpler, and the
   generous cap is well past any real ingredient list, so the animation never gets cut short. */
/* .routine-accordion/.routine-item/... (workout.html's Routines segment) share this and every
   other rule down to .ingredient-list - same accordion shape, different domain, same reasoning
   as the Exercises/Foods CSS sharing above. */
.meal-accordion, .routine-accordion { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.meal-item, .routine-item {
    background: #1d2127;
    border: 1px solid #2a2f37;
    border-radius: 8px;
    overflow: hidden;
}
/* .meal-row is a plain div, not a button: a <button> can't legally contain two other buttons
   (the Log + chevron pair in .meal-row-right), so those and the name/caption toggle are siblings
   here instead - same reasoning as Foods' own .log-row. */
.meal-row, .routine-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 14px;
}
.meal-row-toggle, .routine-row-toggle {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    background: none;
    border: none;
    padding: 0;
    color: #e4e6eb;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
/* Name sits above its own kcal line (smaller, muted) rather than that figure sitting out on the
   row's right edge - the right side is reserved for the Log button + dropdown chevron instead.
   Same truncate-not-wrap treatment as Foods' .food-row-text/.food-row-name/.food-row-cal, for the
   same reason: a long meal name would otherwise push those two buttons down onto their own line.
   Routines' own .routine-row-summary stands in for .meal-row-cal - there's no calorie figure
   here, so the exercise-by-exercise summary text (e.g. "Push-ups x5, Sit-ups x8") fills that same
   caption slot instead. */
.meal-row-text, .routine-row-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.meal-row-name, .meal-row-cal, .routine-row-name, .routine-row-summary { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal-row-cal, .routine-row-summary { font-size: 0.75rem; color: #9aa1ac; }
.meal-row-right, .routine-row-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
/* Solid-filled, same as Foods' own .food-log-btn - the row's one primary action. */
.meal-log-btn.meal-action-icon, .routine-log-btn.meal-action-icon { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.meal-log-btn.meal-action-icon:hover, .routine-log-btn.meal-action-icon:hover { background: #9a63f5; }
/* Second .meal-row-toggle target (see meals.html) - plain icon-only button, not the flex:1/filled
   look the class it shares would otherwise give it; this overrides what it needs to by coming
   later in the file, same specificity either way (one class each). */
.meal-row-chevron-btn, .routine-row-chevron-btn {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    color: #9aa1ac;
}
.meal-row-chevron-btn svg, .routine-row-chevron-btn svg { width: 12px; height: 12px; fill: currentColor; transition: transform 0.25s ease; }
.meal-item.open .meal-row-chevron-btn svg, .routine-item.open .routine-row-chevron-btn svg { transform: rotate(180deg); }

.accordion-panel { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.meal-item.open .accordion-panel, .routine-item.open .accordion-panel { max-height: 600px; }

.ingredient-list {
    list-style: none;
    margin: 0;
    padding: 0 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ingredient-list li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.9rem;
    color: #c3c7cf;
    padding-bottom: 6px;
    border-bottom: 1px solid #2a2f37;
}
.ingredient-list li:last-child { border-bottom: none; }

/* Edit/Delete icon buttons - the only actions left in the accordion panel now (the "Log meal"
   link that used to sit here is gone; the row's own tick-icon Log button above covers that, and
   the kcal total already shows as a caption under the name there too). */
.meal-actions { display: flex; align-items: center; gap: 8px; padding: 10px 14px 14px; }
/* The delete button's form wraps a fixed-size icon button, so the form itself must hug that size
   too instead of stretching to fill. */
.meal-actions form { flex: 0 0 auto; display: flex; }
.meal-action-icon {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(173, 124, 255, 0.15);
    color: var(--color-primary);
    border: 1px solid rgba(173, 124, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
}
.meal-action-icon svg { width: 16px; height: 16px; fill: currentColor; }
.meal-action-icon:hover { background: rgba(173, 124, 255, 0.25); }
.meal-action-icon:disabled { opacity: 0.5; cursor: not-allowed; }

/* One ingredient line in the meal builder. flex-wrap, not a fixed-column grid: a grid track
   can't shrink past its content's natural minimum width, which is exactly what made this row
   wider than the screen on a phone - number/text inputs all have a built-in minimum width.
   The name field is forced onto its own line (flex-basis 100%); quantity/unit/calories/buttons
   share the line(s) below and wrap naturally once they no longer fit. */
.ingredient-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    background: #14161a;
    border: 1px solid #2a2f37;
    border-radius: 8px;
}
.ingredient-row input { height: 48px; padding: 8px; font-size: 0.9rem; min-width: 0; }
/* width:100% on top of flex-basis - iOS Safari doesn't reliably stretch this to its flex basis
   on its own, so without this it renders at its (much narrower) intrinsic content width. */
.ingredient-row .ingredient-picker { position: relative; flex: 1 1 100%; width: 100%; }
.ingredient-row .ingredient-picker .f-ingredient-search, .ingredient-row .ingredient-picker .r-exercise-search { width: 100%; }
.ingredient-row .f-quantity, .ingredient-row .r-quantity { flex: 1 1 80px; }
.ingredient-row .remove-row { flex: 0 0 auto; }

/* Tap-to-select ingredient results, shown under the search box as you type - replaces a plain
   <select>'s filtered options (which give no visible feedback until you open the picker). */
.ingredient-picker-list {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 10;
    margin: 0;
    padding: 4px;
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    background: #22262d;
    border: 1px solid #2a2f37;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
.ingredient-picker-list.open { display: block; }
.ingredient-picker-list li { margin: 0; }
.ingredient-picker-list li button {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-radius: 6px;
    background: none;
    color: #e4e6eb;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
}
.ingredient-picker-list li button:hover,
.ingredient-picker-list li button:active { background: rgba(173, 124, 255, 0.15); }
.lookup-results {
    flex: 1 1 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.lookup-option {
    text-align: left;
    background: #14161a;
    border: 1px solid #2a2f37;
    border-radius: 6px;
    color: #e4e6eb;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.85rem;
}
.lookup-option.lookup-back { color: #9aa1ac; font-style: italic; border-style: dashed; }

.total-preview { font-size: 0.95rem; color: #c3c7cf; margin: 4px 0 8px; }

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 10px;
}
.cal-dow { text-align: center; font-size: 0.7rem; color: #9aa1ac; padding-bottom: 4px; }
.cal-cell {
    position: relative;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #1d2127;
    border: 1px solid #2a2f37;
    border-radius: 8px;
    color: #e4e6eb;
    text-decoration: none;
    font-size: 0.8rem;
}
.cal-cell.out-of-month { opacity: 0.35; }
.cal-cell.good { border-color: #2e5c3f; background: #182420; }
.cal-cell.bad { border-color: #5c2b33; background: #241a1c; }
.cal-cell small { font-size: 0.6rem; color: #9aa1ac; }
/* Small corner marker for "a weigh-in was logged this day" - independent of the cell's own
   good/bad calorie coloring, so both can show on the same day without clashing. */
.cal-weighin-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-primary);
}
/* That day's badge, bottom-left corner - independent of the weigh-in dot (top-right) and the
   cell's own good/bad coloring, so all three can show on the same day without clashing. One
   glyph regardless of star tier (Badge.emoji() is never multiplied) - opacity stands in for the
   1/2/3-star distinction in this little space; piggy/elephant are already distinct glyphs. */
.cal-badge-emoji {
    position: absolute;
    bottom: 3px;
    left: 4px;
    font-size: 8px;
    line-height: 1;
}
.cal-badge-emoji.badge-two-stars { opacity: 0.75; }
.cal-badge-emoji.badge-one-star { opacity: 0.5; }

/* Month bar chart: one bar per day, flex-distributed so it holds up for both 28- and 31-day
   months without a column count baked in. Bars sit in .month-bar-wrap (not directly in the flex
   row) so each slot's own height:100% gives th:style on .month-bar a 0-100% range to size into,
   regardless of the chart's own fixed pixel height. */
.month-chart {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 120px;
    margin: 10px 0 6px;
    padding: 0 1px;
    border-bottom: 1px solid #2a2f37;
}
.month-chart-target {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px dashed #9aa1ac;
    opacity: 0.6;
}
.month-bar-wrap { flex: 1 1 0; display: flex; align-items: flex-end; height: 100%; min-width: 0; }
.month-bar { width: 100%; border-radius: 2px 2px 0 0; }
.month-bar.good { background: #5fd98a; }
.month-bar.bad { background: #ff8a8a; }
.month-bar.empty { background: #2a2f37; }
.chart-legend { margin-top: 0; }

/* Home's "Badges & Streaks" all-time tally - one row per badge type, a horizontal bar scaled
   against whichever badge has the highest count (not a raw calorie-style chart, so plain CSS
   width is enough - see HomeController.BadgeStat for why the % itself is computed server-side).
   .badge-stat-text wraps the label+bar together (stacked) so the row is emoji / label+bar / count
   - three flex children, not four, with the bar able to take up the label's own full width
   underneath it instead of being squeezed into a fixed-width lane beside it. */
.badge-stats { display: flex; flex-direction: column; gap: 14px; margin-bottom: 10px; }
.badge-stat-row { display: flex; align-items: center; gap: 10px; }
.badge-stat-emoji { font-size: 1.2rem; width: 22px; text-align: center; flex-shrink: 0; }
.badge-stat-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.badge-stat-label { font-size: 0.85rem; color: #e4e6eb; font-weight: 600; }
.badge-stat-bar-track {
    height: 6px;
    border-radius: 3px;
    background: #1d2127;
    border: 1px solid #2a2f37;
    overflow: hidden;
}
.badge-stat-bar { height: 100%; border-radius: 3px; background: var(--color-primary); }
.badge-stat-bar.badge-three-stars, .badge-stat-bar.badge-two-stars, .badge-stat-bar.badge-one-star { background: #5fd98a; }
.badge-stat-bar.badge-piggy, .badge-stat-bar.badge-elephant { background: #ff8a8a; }
.badge-stat-count { font-size: 0.9rem; font-weight: 700; width: 24px; text-align: right; flex-shrink: 0; }

/* Friends leaderboard - one row per person, already server-sorted best-badge-first (see
   FriendsController), so this is just a plain ordered list visually, not a sortable table. */
.leaderboard { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.leaderboard-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #1d2127;
    border: 1px solid #2a2f37;
    border-radius: 10px;
    padding: 12px 14px;
}
/* The viewer's own row, picked out so it's easy to find at a glance in a longer list. */
.leaderboard-row.is-you { border-color: var(--color-primary); background: rgba(173, 124, 255, 0.08); }
.leaderboard-row-top { display: flex; align-items: center; gap: 10px; }
.leaderboard-rank { width: 18px; text-align: center; font-weight: 700; color: #9aa1ac; flex-shrink: 0; }
.leaderboard-badge { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; }
.leaderboard-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.leaderboard-name > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-you-tag {
    flex-shrink: 0;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--color-primary);
    background: rgba(173, 124, 255, 0.15);
    border-radius: 999px;
    padding: 2px 8px;
}
.leaderboard-figures { font-size: 0.8rem; color: #9aa1ac; flex-shrink: 0; white-space: nowrap; }
/* Straight version of the Home gauge - same purple gradient as #gaugeGradient there (an SVG
   gradient, redone here as a plain CSS one since this is a div, not an svg) and the same red
   over-target switch as .gauge-fill.over, just linear instead of a semicircle. */
.leaderboard-bar-track { height: 6px; border-radius: 3px; background: #14161a; overflow: hidden; }
.leaderboard-bar { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #D9B8FF, #8C4FFF); }
.leaderboard-bar.over { background: #ff6a6a; }

/* Home page "Recommendation" carousel - a horizontally scrolling row of cards (not a wrapping
   grid), since the whole point is showing several options in a compact strip without pushing
   the rest of the page down. scroll-snap-type/snap-align give it a light "settle on a card"
   feel on a swipe, rather than stopping at an arbitrary half-scrolled position. */
.recommendation-caption { margin-top: -6px; }
.recommend-carousel {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 16px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}
.recommend-card {
    flex: 0 0 auto;
    min-width: 112px;
    scroll-snap-align: start;
    background: #1d2127;
    border: 1px solid #2a2f37;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.recommend-name { font-weight: 600; font-size: 0.9rem; overflow-wrap: anywhere; }
.recommend-cal { font-size: 0.8rem; color: var(--color-primary); }
.recommend-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.recommend-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(173, 124, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1;
}
/* One-tap log straight from a recommendation - same fetch()-based, stay-on-page pattern as the
   Foods page's own per-row Log button (see app.js), just a round icon-only button here instead
   of a full-width one, to fit this card's compact shape. */
.recommend-log-btn {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.recommend-log-btn svg { width: 10px; height: 10px; fill: #fff; }
.recommend-log-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Weight trend card (Home page) - the chart itself (line + filled area + per-point dots/labels)
   wrapped in a card with its own header (latest figure + the week-over-week delta, both already
   formatted by HomeController - see weeklyDeltaDisplay) and a day-of-week axis underneath. */
.weight-card { background: #1d2127; border: 1px solid #2a2f37; border-radius: 16px; padding: 16px; margin-bottom: 16px; }
.weight-chart-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.weight-chart-latest { font-size: 1.5rem; font-weight: 800; color: #fff; }
.weight-chart-latest small { font-size: 0.75rem; font-weight: 600; color: #9aa1ac; margin-left: 4px; }
.weight-chart-delta { font-size: 0.8rem; font-weight: 700; }
.weight-chart-delta.good { color: #5fd98a; }
.weight-chart-delta.bad { color: #ff8a8a; }

/* The chart itself - a single <polyline> plus a filled <path> underneath it, both built from the
   same pre-computed points (min/max scaling, index-based x spacing isn't a good fit for
   Thymeleaf expressions - see HomeController's buildWeightChart). preserveAspectRatio="none" lets
   it stretch to the container's real width/height independently, same non-scaling-stroke
   reasoning as the gauge rings: without it, a 2-unit stroke-width in the 300x100 viewBox would
   render at a different on-screen thickness depending on how much the viewBox got stretched to
   fill the card. */
.weight-chart { height: 120px; margin-bottom: 6px; }
.weight-chart-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.weight-chart-area { fill: url(#weightAreaGradient); stroke: none; }
.weight-chart-line {
    fill: none;
    stroke: var(--color-primary);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}
.weight-chart-dot { fill: #14161a; stroke: var(--color-primary); stroke-width: 2; vector-effect: non-scaling-stroke; }
.weight-chart-dot.today { stroke: #5fd98a; }
/* Weight figure at each point. Unlike stroke-width above, font-size isn't an SVG-only property
   CSS lets go unitless - "9px" is required here, but it still means 9 of the chart's own viewBox
   units (not a literal device pixel), since that's what "px" resolves to inside an SVG's local,
   viewBox-scaled coordinate system. */
.weight-chart-label { font-size: 9px; fill: #c3c7cf; text-anchor: middle; }
.weight-chart-label.today { fill: #5fd98a; font-weight: 700; }
/* Day-of-week ticks under the chart - evenly spaced via flex (same count/order as the chart's
   own points), not positioned from the SVG's own x coordinates, since this row is plain HTML. */
.weight-chart-axis { display: flex; justify-content: space-between; border-top: 1px solid #2a2f37; padding-top: 8px; }
.weight-chart-axis span { font-size: 0.7rem; color: #9aa1ac; flex: 1; text-align: center; }
.weight-chart-axis span.today { color: var(--color-primary); font-weight: 700; }

@media (min-width: 600px) {
    .tiles { grid-template-columns: repeat(3, 1fr); }
}
