:root {
    --bg: #ffffff;
    --text: #000000;
    --card-bg: #f8f9fa;
    --day-label-color: rgba(0, 0, 0, 0.45);
    --day-num-color: rgba(0, 0, 0, 0.85);
    --day-hover-bg: rgba(0, 0, 0, 0.06);
    --day-dot-color: rgba(0, 0, 0, 0.2);
    --day-scroller-bg: #f0f0f0;
}

[data-theme="dark"] {
    --bg: #121212;
    --text: #ffffff;
    --card-bg: #1e1e1e;
    --day-label-color: rgba(255, 255, 255, 0.45);
    --day-num-color: rgba(255, 255, 255, 0.85);
    --day-hover-bg: rgba(255, 255, 255, 0.08);
    --day-dot-color: rgba(255, 255, 255, 0.3);
    --day-scroller-bg: #1e1e1e;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
    color: var(--text);
}

.day-scroller-wrap {
    background: var(--day-scroller-bg);
    border-radius: 16px;
    padding: 12px 0;
}

.flexContainer {
    padding-bottom: 94px;
}

.day-scroller {
    display: flex; overflow-x: auto; gap: 6px;
    padding: 4px 12px; scrollbar-width: none;
}

.day-scroller::-webkit-scrollbar { display: none; }

.day-item {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; min-width: 52px; height: 72px;
    border-radius: 26px; cursor: pointer; flex-shrink: 0;
    border: 1.5px solid transparent;
    transition: background 0.15s;
}

.day-item:hover { background: var(--day-hover-bg); }

.day-label {
    font-size: 11px;
    color: var(--day-label-color);
    margin-bottom: 4px;
}

.day-num {
    font-size: 17px;
    font-weight: 500;
    color: var(--day-num-color);
}

.day-item.selected { background: #1a73e8; }
.day-item.selected .day-label,
.day-item.selected .day-num { color: #fff; }

.day-item.today:not(.selected) { border-color: #1a73e8; }
.day-item.today:not(.selected) .day-num { color: #1a73e8; }

.day-dot {
    width: 4px; height: 4px; border-radius: 50%;
    background: var(--day-dot-color); margin-top: 5px;
}

.day-item.selected .day-dot { background: rgba(255, 255, 255, 0.7); }
.day-item.has-data:not(.selected) .day-dot { background: #1a73e8; }

.day-detail {
    padding: 16px 12px;
}

.day-detail-header {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 14px;
    opacity: 0.7;
}

.meal-card {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 10px;
}

.meal-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.meal-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: #1a73e8;
    flex-shrink: 0;
}

.meal-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
}

.meal-calories {
    font-size: 12px;
    color: var(--text);
    opacity: 0.5;
    margin-top: 1px;
}

.meal-empty {
    font-style: italic;
}

.meal-add-btn {
    margin-left: auto;
    background: none;
    border: 1.5px solid rgba(26, 115, 232, 0.4);
    color: #1a73e8;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    flex-shrink: 0;
}

.meal-add-btn:hover {
    background: rgba(26, 115, 232, 0.1);
}

.dish-name {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 5px;
}

.dish-macros {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.macro {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 500;
}

.progress-bar-container {
    margin-bottom: 20px;
}
.progress-bar-title {
    padding: 5px 10px;
    font-size: 1.5rem;
    color: rgb(40, 40, 40);
}

[data-theme="dark"] {
    .progress-bar-title {
        padding: 5px 10px;
        font-size: 1.5rem;
        color: rgb(140, 140, 140);
    }
}
.progress-bar {
    position: relative;
    overflow: hidden;
    width: 100%;
    background: var(--day-scroller-bg);
    border-radius: 20px;
    height: 12px;
}
.progress-bar div {
    width: 0%;
    background: #34a853;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    transition: 0.5s ease-in-out;
}
.macro-cal { background: rgba(26,  115, 232, 0.12); color: #1a73e8; }
.macro-p   { background: rgba(234, 67,  53,  0.12); color: #ea4335; }
.macro-c   { background: rgba(251, 188, 5,   0.15); color: #b8860b; }
.macro-f   { background: rgba(52,  168, 83,  0.12); color: #34a853; }

[data-theme="dark"] .macro-c { color: #fbbc05; }

.dish-row-wrap {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    margin-top: 10px;
    background: transparent;
}

.dish-row {
    position: relative;
    padding: 10px 0;
    background: var(--card-bg);
    transform: translateX(0);
    transition: transform 0.25s ease;
    z-index: 2;
    cursor: grab;
    user-select: none;
}

.dish-row.dragging {
    transition: none;
    cursor: grabbing;
}

.dish-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 6px;
}

.dish-quantity {
    font-size: 12px;
    color: var(--text);
    opacity: 0.5;
}

.dish-actions {
    padding: 1px;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    width: 80px;
    z-index: 1;
}

.dish-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: filter 0.15s;
}

.dish-action-btn:active { filter: brightness(0.85); }
.dish-action-btn span   { font-size: 11px; }

.dish-edit-btn   { background: #1a73e8; color: white; }
.dish-delete-btn { background: #ea4335; color: white; border-radius: 0 10px 10px 0; }


/* ═══════════════════════════════════════════════════════════════════════════
   CAMERA UI
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Samsung-style camera action buttons ───────────────────────────────────
   Thick rounded pill buttons matching Samsung Camera's action row.
   Used for .afo-action-btn (Scan Barcode / Take Photo) in the sheet footer.
   ───────────────────────────────────────────────────────────────────────── */

.afo-loading {
    text-align: center;
    margin-bottom: 10px;
}
.afo-action-row {
    display: flex;
    gap: 12px;
    padding: 10px 16px 10px;
    justify-content: center;
}

.afo-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;

    height: 54px;
    border-radius: 27px;
    border: none;
    cursor: pointer;

    /* Default: dark pill (works on dark backgrounds like camera overlay) */
    background: #1c1c1e;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.18),
        0 1px 2px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);

    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}

.afo-action-btn i {
    font-size: 17px;
    opacity: 0.9;
}

.afo-action-btn:active {
    transform: scale(0.96);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    background: #2c2c2e;
}

/* Light theme: light pill with dark text */
:root:not([data-theme="dark"]) .afo-action-btn {
    background: #f2f2f7;
    color: #1c1c1e;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.09),
        0 1px 2px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

:root:not([data-theme="dark"]) .afo-action-btn:active {
    background: #e5e5ea;
}

[data-theme="dark"] .afo-action-btn {
    background: #2c2c2e;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.35),
        0 1px 2px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .afo-action-btn:active {
    background: #3a3a3c;
}
.footer-elements {
    z-index: 2;
    display: flex;
    gap: 8px;
    padding: 4px;

    position: fixed;
    left: 20px;
    right: 20px;
    bottom: max(20px, env(safe-area-inset-bottom));
    height: 62px;

    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px) saturate(1.2) brightness(1.8);

    overflow: hidden;
    align-items: center;
}

.footer-selector {
    user-select: none;
    position: absolute;
    top: 4px;
    left: 4px;
    height: calc(100% - 8px);
    width: calc((100% - 16px - 16px) / 3);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    pointer-events: none;
    z-index: 1;
    transition: transform 0.22s cubic-bezier(.2, .8, .2, 1);
    box-sizing: border-box;
}

.footer-elements.dragging .footer-selector {
    transition: none;
}

.footer-elements button {
    position: relative;
    z-index: 2;
    flex: 1;
    height: 100%;
    border: none;
    padding-top: 7px;
    border-radius: 999px;
    background: transparent;
    color: white;
    transition: background 0.2s ease, color 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: rgb(200, 200, 200);
    font-size: 10px;
}
.footer-elements button i {
    color: white;
    font-size: 18px;
}

.footer-elements button:disabled, .footer-elements button:disabled i {
    color: rgb(80, 80, 80);
}

/* ── Samsung-style shutter button ──────────────────────────────────────────
   White ring + white inner disc, presses inward on tap.
   ───────────────────────────────────────────────────────────────────────── */

.afo-shutter {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3.5px solid rgba(255, 255, 255, 0.9);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s ease, border-color 0.1s ease;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.15),
        0 4px 16px rgba(0, 0, 0, 0.3);
}

.afo-shutter-inner {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
    transition: transform 0.1s ease, background 0.1s ease;
}

.afo-shutter:active {
    transform: scale(0.93);
    border-color: rgba(255, 255, 255, 0.7);
}

.afo-shutter:active .afo-shutter-inner {
    background: #d8d8d8;
    transform: scale(0.95);
}


/* ── Photo bottom bar ───────────────────────────────────────────────────── */

.afo-bottom-bar {
    padding: 12px 0 env(safe-area-inset-bottom, 12px);
}

.afo-photo-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    width: 100%;
    box-sizing: border-box;
}

.afo-photo-bar .afo-hint-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    text-align: center;
    flex: 1;
}


/* ── Zoom badge ─────────────────────────────────────────────────────────── */

.afo-zoom-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.85);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.afo-zoom-badge.shift-down {
    top: 48px;
}
.afo-zoom-badge--visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.afo-zoom-badge i {
    font-size: 12px;
    opacity: 0.85;
}


/* ── Barcode overlay hint ─────────────────────────────────────────────── */

.afo-barcode-overlay {
    position: absolute;
    bottom: 100px;
    left: 0; right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 10;
    pointer-events: none;
}

.afo-barcode-overlay .afo-scanning-status,
.afo-barcode-overlay .afo-hint-text {
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #fff;
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 12px;
    white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────────────
   Multi-scan toggle pill  (sits in the header, right side)
───────────────────────────────────────────────────────────────── */
.afo-scan-mode-toggle {
    display: flex;
    align-items: center;
    min-width: 80px;
    justify-content: flex-end;
}

.afo-toggle-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    padding: 5px 10px 5px 6px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
}

.afo-toggle-pill--active {
    background: rgba(52, 199, 89, 0.28);
    border-color: rgba(52, 199, 89, 0.7);
}

/* The sliding toggle track + thumb */
.afo-toggle-track {
    position: relative;
    width: 28px;
    height: 16px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.afo-toggle-pill--active .afo-toggle-track {
    background: #34c759;
}

.afo-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.afo-toggle-pill--active .afo-toggle-thumb {
    transform: translateX(12px);
}

.afo-toggle-label {
    line-height: 1;
}

/* Count badge on the toggle */
.afo-toggle-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #34c759;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    line-height: 1;
    animation: afoBadgePop 0.2s cubic-bezier(.4,0,.2,1);
}

@keyframes afoBadgePop {
    0%   { transform: scale(0.5); opacity: 0; }
    80%  { transform: scale(1.15); }
    100% { transform: scale(1);    opacity: 1; }
}

/* ─────────────────────────────────────────────────────────────────
   Barcode bottom bar (multi-scan)
───────────────────────────────────────────────────────────────── */
.afo-barcode-bar {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 16px 16px;
}

/* Empty state */
.afo-scanned-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.45);
    font-size: 13px;
    padding: 6px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

/* Horizontally scrollable chip tray */
.afo-scanned-tray {
    width: 100%;
    overflow: hidden;
}

.afo-scanned-tray-inner {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;          /* space for scrollbar on desktop */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;        /* Firefox */
}

.afo-scanned-tray-inner::-webkit-scrollbar {
    display: none;
}

/* Individual barcode chip */
.afo-scanned-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.13);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    padding: 5px 6px 5px 10px;
    white-space: nowrap;
    flex-shrink: 0;
    color: #fff;
    font-size: 13px;
    transition: background 0.2s;
}

.afo-scanned-chip--new {
    background: rgba(52, 199, 89, 0.28);
    border-color: rgba(52, 199, 89, 0.65);
    animation: afoChipIn 0.25s cubic-bezier(.4,0,.2,1);
}

@keyframes afoChipIn {
    0%   { transform: scale(0.7) translateY(8px); opacity: 0; }
    100% { transform: scale(1)   translateY(0);   opacity: 1; }
}

.afo-scanned-chip i {
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
}

.afo-scanned-code {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.afo-scanned-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #fff;
    font-size: 10px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.afo-scanned-remove:active {
    background: rgba(255, 59, 48, 0.5);
}

/* ─────────────────────────────────────────────────────────────────
   Done button
───────────────────────────────────────────────────────────────── */
.afo-done-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.45);
    font-size: 16px;
    font-weight: 600;
    cursor: not-allowed;
    transition: background 0.2s, color 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.afo-done-btn--ready {
    background: #34c759;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(52, 199, 89, 0.45);
}

.afo-done-btn--ready:active {
    transform: scale(0.97);
}

.afo-done-count {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.85;
}