.pantry-wizard {
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 2vh, 22px);
    max-width: 920px;
    margin: 0 auto;
    width: 100%;
    min-height: 0;
    flex: 1;
}

.pantry-phase {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.pantry-select-shell,
.pantry-results-shell {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    flex: 1;
    /* No nested panel — content sits on the page canvas */
    background: transparent;
    border: none;
    border-radius: 0;
    padding: clamp(4px, 0.6vw, 8px) 0;
    box-shadow: none;
}

/* Header + pills + search stay top; cards breathe in the middle; footer anchors bottom */
.pantry-select-shell {
    justify-content: flex-start;
}

.pantry-phase-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.pantry-phase-title {
    font-family: var(--font-heading);
    font-size: clamp(20px, 1.8vw, 24px);
    font-weight: 800;
    margin: 0;
    color: var(--text-primary);
}

.pantry-phase-hint {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.pantry-cat-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pantry-cat-pills.is-searching .pantry-cat-pill.is-active {
    /* while searching, no page is "active" */
}

.pantry-cat-pill {
    position: relative;
    appearance: none;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 6px 10px;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1.2;
    user-select: none;
    transition:
        transform 0.12s cubic-bezier(0.25, 0.8, 0.25, 1),
        border-color 0.12s ease,
        background 0.12s ease,
        color 0.12s ease,
        box-shadow 0.12s ease;
}

.pantry-cat-pill:hover {
    border-color: rgba(255, 126, 103, 0.4);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.pantry-cat-pill:active {
    transform: translateY(2px);
}

.pantry-cat-pill.is-active {
    border-color: rgba(255, 126, 103, 0.5);
    background: rgba(255, 126, 103, 0.12);
    color: var(--primary-color);
}

.pantry-cat-pill.has-picks:not(.is-active) {
    border-color: rgba(255, 126, 103, 0.28);
}

@keyframes pantryBadgeFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.6);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pantryBadgeFadeOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.6);
    }
}

/* Corner badge — absolute, out of flow, pill never resizes */
.pantry-cat-pill-n {
    position: absolute;
    top: -7px;
    right: -7px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    box-sizing: border-box;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 2px 6px rgba(255, 126, 103, 0.4);
    transform-origin: center center;
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}

.pantry-cat-pill-n.is-entering {
    animation: pantryBadgeFadeIn 0.18s cubic-bezier(0.25, 0.8, 0.25, 1) both;
}

.pantry-cat-pill-n.is-shrinking {
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.1s ease-in, transform 0.1s ease-in;
}

.pantry-cat-pill-n.is-leaving {
    animation: pantryBadgeFadeOut 0.15s ease both;
}

/* Compact footer: text prev + short next + optional match link */
.pantry-footer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.pantry-footer-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.pantry-nav-prev,
.pantry-nav-next {
    flex: 0 1 auto;
    min-height: 44px;
    min-width: 8.5em;
    max-width: 12em;
    padding: 0 22px;
    font-weight: 800;
    font-size: 14px;
    /* press uses global .btn-primary / .btn-secondary :active */
}

.pantry-nav-prev:disabled,
.pantry-nav-next:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Match is a secondary action — not a third giant bar */
.pantry-match-link {
    appearance: none;
    align-self: center;
    border: none;
    background: transparent;
    color: var(--primary-color);
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 800;
    padding: 8px 12px;
    cursor: pointer;
    text-decoration: none;
    border-radius: 10px;
    transition:
        transform 0.12s cubic-bezier(0.25, 0.8, 0.25, 1),
        background 0.12s ease,
        opacity 0.12s ease;
}

.pantry-match-link:hover:not(:disabled) {
    background: rgba(255, 126, 103, 0.1);
    transform: translateY(-1px);
}

.pantry-match-link:active:not(:disabled) {
    transform: translateY(2px);
    background: rgba(255, 126, 103, 0.14);
}

.pantry-match-link:disabled {
    color: var(--text-secondary);
    opacity: 0.45;
    cursor: not-allowed;
}

/* Calendar flip count — same language as DIY summary .diy-ing-weight */
.pantry-count-board {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 3.2em;
}

.pantry-count-digit {
    /* extends .diy-ing-weight */
    min-width: 2.4em;
    height: 1.55em;
    padding: 0 8px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.95) 48%, rgba(0, 0, 0, 0.04) 50%, rgba(255, 255, 255, 0.9) 52%, rgba(255, 255, 255, 0.9) 100%);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 2px 6px rgba(0, 0, 0, 0.05);
    font-size: 22px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
    justify-content: center;
    color: var(--primary-color);
}

.theme-dark .pantry-count-digit {
    border-color: rgba(255, 255, 255, 0.12);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.08) 48%, rgba(0, 0, 0, 0.2) 50%, rgba(255, 255, 255, 0.06) 52%, rgba(255, 255, 255, 0.06) 100%);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
    color: var(--primary-color);
}

.pantry-count-digit .diy-flip-face {
    justify-content: center;
    color: var(--primary-color);
}

.pantry-count-caption {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    line-height: 1;
}

.pantry-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pantry-search-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-main, rgba(0, 0, 0, 0.04));
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 0 12px;
    min-height: 42px;
}

.theme-dark .pantry-search-wrap {
    background: rgba(255, 255, 255, 0.04);
}

.pantry-search {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    min-width: 0;
    padding: 10px 0;
    width: 100%;
}

.pantry-search::placeholder {
    color: var(--text-secondary);
    opacity: 0.75;
}

.pantry-clear-btn {
    flex-shrink: 0;
    font-weight: 700;
}

.pantry-selected-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
}

.pantry-selected-bar {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    max-height: 0;
    opacity: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    white-space: nowrap;
    padding: 0;
    margin-bottom: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
    transition: max-height 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), 
                opacity 0.2s ease, 
                padding 0.2s ease, 
                margin-bottom 0.2s ease;
}

/* Edge fades follow scroll position: only fade where more content exists */
.pantry-selected-bar.fade-right {
    -webkit-mask-image: linear-gradient(to right, #000 88%, transparent 100%);
    mask-image: linear-gradient(to right, #000 88%, transparent 100%);
}

.pantry-selected-bar.fade-left {
    -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 12%);
    mask-image: linear-gradient(to right, transparent 0%, #000 12%);
}

.pantry-selected-bar.fade-left.fade-right {
    -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 12%, #000 88%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, #000 12%, #000 88%, transparent 100%);
}

.pantry-selected-bar::-webkit-scrollbar {
    display: none;
}

.pantry-selected-bar.is-visible {
    max-height: 44px;
    opacity: 1;
    padding: 4px 0;
    margin-bottom: 12px;
}

.pantry-scroll-arrow {
    appearance: none;
    flex-shrink: 0;
    z-index: 8;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    /* Permanent slot: only fades/slides, never pushes the chip bar */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1), background 0.15s ease, border-color 0.15s ease;
}

.pantry-scroll-arrow.left {
    margin-right: 8px;
    transform: translateX(4px);
}

.pantry-scroll-arrow.right {
    margin-left: 8px;
    transform: translateX(-4px);
}

.theme-dark .pantry-scroll-arrow {
    background: rgba(35, 35, 45, 0.95);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.pantry-scroll-arrow.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

/* No selections: collapse the arrow slots along with the bar */
.pantry-selected-wrapper:has(.pantry-selected-bar:not(.is-visible)) .pantry-scroll-arrow {
    width: 0;
    height: 0;
    margin: 0;
    border-width: 0;
}

.pantry-scroll-arrow:hover {
    background: #ffffff;
    border-color: rgba(255, 126, 103, 0.5);
    color: var(--primary-color);
    transform: scale(1.1);
}

@keyframes chipSlideFadeIn {
    0% { opacity: 0; transform: translateX(-6px) scale(0.95); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes chipSlideFadeOut {
    0% { opacity: 1; transform: scale(1); max-width: 140px; margin-right: 0; }
    100% { opacity: 0; transform: scale(0.75); max-width: 0; margin-right: -6px; padding-left: 0; padding-right: 0; }
}

.pantry-selected-pill {
    flex-shrink: 0;
    appearance: none;
    border: 1px solid rgba(255, 126, 103, 0.35);
    background: rgba(255, 126, 103, 0.1);
    color: var(--text-primary);
    border-radius: 999px;
    padding: 4px 8px 4px 10px;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-family: var(--font-heading);
    transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.pantry-selected-pill.is-entering {
    animation: chipSlideFadeIn 0.22s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.pantry-selected-pill.is-leaving {
    animation: chipSlideFadeOut 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
    overflow: hidden;
    white-space: nowrap;
}

.pantry-selected-pill:hover {
    border-color: rgba(255, 126, 103, 0.55);
    transform: translateY(-1px);
}

.pantry-selected-pill:active {
    transform: translateY(1px);
}

.pantry-selected-pill .pill-x {
    opacity: 0.55;
    font-weight: 800;
    margin-left: 2px;
}

/* Ingredient cards — even grid, taller tiles, vertically centered in shell */
.pantry-card-scroll {
    flex: 1 1 auto;
    min-height: 160px;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 2px 12px;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center; /* lift content off the top */
}

@keyframes pantryGridSlideNext {
    0% { opacity: 0; transform: translateX(28px) scale(0.97); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes pantryGridSlidePrev {
    0% { opacity: 0; transform: translateX(-28px) scale(0.97); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes pantryTabPulse {
    0% { transform: scale(1); }
    40% { transform: scale(0.92) translateY(1px); }
    80% { transform: scale(1.06) translateY(-1px); }
    100% { transform: scale(1); }
}

@keyframes pantryGridSamePulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.985); opacity: 0.85; }
    100% { transform: scale(1); opacity: 1; }
}

.pantry-cat-pill.is-pulse {
    animation: pantryTabPulse 0.25s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

.pantry-card-grid.is-same-pulse {
    animation: pantryGridSamePulse 0.22s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

.pantry-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    align-content: center;
}

.pantry-card-grid.pantry-slide-next .pantry-ing-card {
    animation: pantryGridSlideNext 0.28s cubic-bezier(0.25, 1, 0.5, 1) both;
}

.pantry-card-grid.pantry-slide-prev .pantry-ing-card {
    animation: pantryGridSlidePrev 0.28s cubic-bezier(0.25, 1, 0.5, 1) both;
}

.pantry-ing-card {
    appearance: none;
    width: 100%;
    min-height: 64px;
    max-width: none;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    /* Tactile key: darker thick bottom edge, press travels 2px */
    border-bottom: 4px solid rgba(0, 0, 0, 0.14);
    background: #ffffff;
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
    box-shadow: none;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    transition:
        transform 0.12s cubic-bezier(0.25, 0.8, 0.25, 1),
        border-color 0.15s ease,
        border-bottom-width 0.08s ease,
        background 0.15s ease,
        color 0.15s ease;
}

.theme-dark .pantry-ing-card {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.pantry-ing-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 126, 103, 0.03);
    border-color: rgba(255, 126, 103, 0.55);
    border-bottom-color: rgba(255, 126, 103, 0.45);
    box-shadow: 0 4px 12px rgba(255, 126, 103, 0.08);
}

.theme-dark .pantry-ing-card:hover {
    background: rgba(255, 126, 103, 0.06);
    border-color: var(--primary-color);
    border-bottom-color: rgba(255, 126, 103, 0.55);
    box-shadow: 0 4px 12px rgba(255, 126, 103, 0.12);
}

.pantry-ing-card:active,
.pantry-ing-card.is-press {
    transform: translateY(2px);
    border-bottom-width: 1px;
}

/* Selected — flat coral tint + selection ring, no layout shift */
.pantry-ing-card.is-selected {
    background: rgba(255, 126, 103, 0.08) !important;
    border-color: rgba(255, 126, 103, 0.55) !important;
    border-bottom-color: rgba(255, 126, 103, 0.45) !important;
    box-shadow: 0 0 0 1px rgba(255, 126, 103, 0.35) !important;
    color: var(--text-primary);
}

.pantry-ing-card.is-selected .pantry-ing-label {
    color: var(--primary-color);
    font-weight: 700;
}

.theme-dark .pantry-ing-card.is-selected {
    background: rgba(255, 126, 103, 0.14) !important;
    border-color: var(--primary-color) !important;
    border-bottom-color: rgba(255, 126, 103, 0.55) !important;
    box-shadow: 0 0 0 1px rgba(255, 126, 103, 0.45) !important;
}

.pantry-ing-card.is-selected:active,
.pantry-ing-card.is-selected.is-press {
    transform: translateY(2px) !important;
    border-bottom-width: 1px !important;
    box-shadow: 0 0 0 1px rgba(255, 126, 103, 0.35) !important;
}

.pantry-ing-emoji {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
    width: 1.5em;
    text-align: center;
}

.pantry-ing-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.2px;
}

@media (min-width: 900px) {
    .pantry-card-grid {
        max-width: 640px;
        gap: 14px;
    }

    .pantry-ing-card {
        min-height: 72px;
        padding: 16px 18px;
        font-size: 15px;
    }
}

@media (max-width: 420px) {
    .pantry-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-width: none;
        gap: 10px;
    }

    .pantry-ing-card {
        min-height: 48px;
        padding: 10px 12px;
        font-size: 13px;
        border-radius: 12px;
    }
}



/* Results phase */
.pantry-results-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.pantry-results-summary {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.pantry-result-tabs {
    display: flex;
    gap: 6px;
    padding: 4px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
}

.theme-dark .pantry-result-tabs {
    background: rgba(255, 255, 255, 0.04);
}

.pantry-tab {
    flex: 1;
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 11px;
    padding: 10px 8px;
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.22s cubic-bezier(0.25, 0.8, 0.25, 1), color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.pantry-tab.is-active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.theme-dark .pantry-tab.is-active {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.pantry-tab-count {
    min-width: 1.4em;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    background: rgba(255, 126, 103, 0.12);
    color: var(--primary-color);
}

@keyframes pantryPanelSlideNext {
    0% { opacity: 0; transform: translateX(30px) scale(0.97); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes pantryPanelSlidePrev {
    0% { opacity: 0; transform: translateX(-30px) scale(0.97); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes pantryPanelSamePulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.985); opacity: 0.85; }
    100% { transform: scale(1); opacity: 1; }
}

.pantry-tab-panels {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.pantry-tab-panel {
    flex: 1;
    min-height: 160px;
    max-height: min(56vh, 520px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 2px;
}

.pantry-tab-panel.pantry-panel-slide-next > * {
    animation: pantryPanelSlideNext 0.32s cubic-bezier(0.25, 0.8, 0.25, 1) both;
}

.pantry-tab-panel.pantry-panel-slide-prev > * {
    animation: pantryPanelSlidePrev 0.32s cubic-bezier(0.25, 0.8, 0.25, 1) both;
}

.pantry-tab-panel.is-same-pulse {
    animation: pantryPanelSamePulse 0.22s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

.pantry-tab-panel.hidden {
    display: none;
}

.match-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.match-item {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color 0.15s ease, background 0.15s ease;
    cursor: default;
}

.match-item:hover {
    border-color: rgba(255, 126, 103, 0.35);
    background: rgba(255, 126, 103, 0.04);
}

.match-item-thumb {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--border-color);
}

.match-item-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.match-item-title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 15px;
    color: var(--text-primary);
}

.match-item-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.match-tips,
.match-missing {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 8px;
    display: inline-block;
    width: fit-content;
    max-width: 100%;
}

.match-tips {
    color: #c47b00;
    background: rgba(255, 165, 2, 0.12);
}

.theme-dark .match-tips {
    color: var(--warning-color);
}

.match-missing {
    color: #c0392b;
    background: rgba(255, 71, 87, 0.1);
}

.theme-dark .match-missing {
    color: var(--danger-color, #ff6b7a);
}

.match-item .btn {
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 800;
}

.match-empty {
    text-align: center;
    padding: 36px 16px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

@media (max-width: 640px) {
    .pantry-result-tabs {
        flex-direction: column;
    }

    .match-item {
        flex-wrap: wrap;
    }

    .match-item .btn {
        width: 100%;
    }
}

/* Saved Recipes Page */
.saved-intro {
    margin-bottom: 24px;
}

.saved-intro h3 {
    font-family: var(--font-heading);
    font-size: 24px;
    margin-bottom: 6px;
}

.saved-intro p {
    font-size: 13px;
    color: var(--text-secondary);
}

.saved-recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.saved-recipe-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.saved-recipe-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.saved-recipe-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.saved-recipe-header h4 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.saved-recipe-header span {
    font-size: 11px;
    color: var(--text-secondary);
}

.saved-recipe-body {
    flex-grow: 1;
}

.saved-recipe-body p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.saved-recipe-preview {
    font-size: 11px;
    background-color: rgba(0, 0, 0, 0.15);
    padding: 10px;
    border-radius: 8px;
    font-family: monospace;
    color: #dcdce5;
    margin-top: 10px;
    white-space: pre-wrap;
}

.saved-recipe-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
}

.btn-delete {
    color: var(--danger-color);
    font-size: 13px;
    background: none;
    border: none;
    cursor: pointer;
}

.btn-delete:hover {
    text-decoration: underline;
}

/* 5-Level Indicators styling */
.level-blocks {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    width: 100%;
}

.level-blocks .block {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background-color: rgba(255, 255, 255, 0.08); /* Default empty block (dark mode) */
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

/* Light mode overrides for empty blocks */
@media (prefers-color-scheme: light) {
    .level-blocks .block {
        background-color: rgba(0, 0, 0, 0.06);
    }
}

/* Active blocks colors with glowing glow */
.level-blocks.level-1 .block:nth-child(1) { background-color: #2ed573; box-shadow: 0 0 8px rgba(46, 213, 115, 0.4); }

.level-blocks.level-2 .block:nth-child(-n+2) { background-color: #2ed573; box-shadow: 0 0 8px rgba(46, 213, 115, 0.4); }

.level-blocks.level-3 .block:nth-child(-n+3) { background-color: #2ed573; box-shadow: 0 0 8px rgba(46, 213, 115, 0.4); }

.level-blocks.level-4 .block:nth-child(-n+4) { background-color: #ffa502; box-shadow: 0 0 8px rgba(255, 165, 2, 0.4); }

.level-blocks.level-5 .block:nth-child(-n+5) { background-color: #ff7e67; box-shadow: 0 0 8px rgba(255, 126, 103, 0.4); }

/* Settings Popover Styling */
.settings-popover {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    width: 240px; /* Widened to fit the select boxes and labels without overflowing */
    box-sizing: border-box;
    background-color: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-popover.hidden {
    display: none !important;
}

.settings-popover-header h4 {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.settings-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    flex: 1;
}

.settings-select {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    box-sizing: border-box;
    background-color: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.settings-select:hover {
    border-color: var(--primary-color);
}


/* Light mode overrides for settings popover */
:root:not(.theme-dark) .settings-popover {
    background-color: #ffffff;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
    .settings-popover {
        bottom: calc(100% + 16px);
        left: auto;
        right: -8px; /* Anchor to right since Settings is the 4th tab on mobile */
        transform-origin: bottom right;
    }
}

:root:not(.theme-dark) .settings-select {
    background-color: #f5f5f7;
    color: #1d1d1f;
    border-color: #e5e5ea;
}

