body {
    background-color: #f8f9fa;
    padding-bottom: 80px; /* Space for bottom nav */
}

@media (min-width: 768px) {
    #app {
        max-width: 600px;
        margin: 0 auto;
        box-shadow: 0 0 15px rgba(0,0,0,0.1);
        min-height: 100vh;
        background-color: white;
        padding: 20px;
    }
    
    body {
        background-color: #e9ecef;
    }

    .fixed-bottom {
        position: sticky;
        bottom: 0;
        max-width: 600px;
        margin: 0 auto;
    }
}

.screen {
    min-height: 80vh;
}

.card {
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border: none;
}

.occasion-item {
    cursor: pointer;
    transition: background-color 0.2s;
}

.occasion-item:hover {
    background-color: #f1f1f1;
}

.meal-item {
    cursor: pointer;
}

.progress-bar-custom {
    height: 8px;
    border-radius: 4px;
    background-color: #e9ecef;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: #0d6efd;
}

#add-meal-fab {
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 1050;
}

.nav-link {
    color: #6c757d;
}

.nav-link.active {
    color: #0d6efd;
}

/* Scanner overlay: fixed full-screen modal-like container so the camera
   preview stays visible regardless of which "screen" is currently active. */
#scanner-container {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

#scanner-container.d-none {
    display: none !important;
}

.scanner-overlay-inner {
    width: 100%;
    max-width: 480px;
    background-color: #000;
    border-radius: 10px;
    overflow: hidden;
    padding: 12px;
}

#reader {
    width: 100%;
    background-color: #000;
    border-radius: 6px;
    overflow: hidden;
}

#reader video {
    width: 100% !important;
    height: auto !important;
    display: block;
}

/* Hide scrollbar for cleaner look */
::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}

#item-ocr-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f8f9fa;
    border-radius: 8px;
}

#item-ocr-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 240px;
    overflow-y: auto;
}

#item-ocr-video {
    display: block;
    width: 100%;
    height: 320px;
    height: clamp(180px, 45svh, 400px);
    object-fit: contain;
    background: #000;
    border-radius: 8px;
}

/* Bound the replaced elements independently of the source photo dimensions. */
#item-ocr-panel,
#item-ocr-panel > *,
#item-recognition-engine {
    min-width: 0;
    max-width: 100%;
}

#item-ocr-preview:not([hidden]) {
    display: grid;
    grid-template-rows: 280px auto;
    grid-template-rows: clamp(180px, 38svh, 320px) auto;
}

#item-ocr-canvas {
    min-width: 0;
    min-height: 0;
}

#item-ocr-panel [hidden] {
    display: none !important;
}

#item-ocr-status {
    overflow-wrap: anywhere;
}

@media (max-width: 575.98px) {
    #item-ocr-panel .item-photo-actions {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr);
    }

    #item-ocr-panel .btn {
        min-height: 44px;
        white-space: normal;
    }

    #item-recognition-engine {
        font-size: 16px;
    }
}
