/* ── Design tokens ── */
:root {
    --color-bg: #0f0f0f;
    --color-surface: #1a1a2e;
    --color-surface-2: #16213e;
    --color-primary: #e94560;
    --color-primary-hover: #ff6b81;
    --color-primary-rgb: 233, 69, 96;
    --color-text: #eee;
    --color-text-muted: #888;
    --color-border: #2a2a3e;
    --color-success: #2ecc71;
    --color-error: #e74c3c;
    --color-warning: #f39c12;
    --color-overlay: rgba(0,0,0,0.7);
    --color-shadow: rgba(0,0,0,0.4);
    --radius: 12px;
    --radius-sm: 8px;
    --nav-height: 64px;
    --header-height: 56px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Light theme ── */
[data-theme="light"] {
    --color-bg: #f5f5f7;
    --color-surface: #ffffff;
    --color-surface-2: #eef0f4;
    --color-primary-hover: #d63350;
    --color-text: #1a1a2e;
    --color-text-muted: #6b7280;
    --color-border: #d1d5db;
    --color-success: #16a34a;
    --color-error: #dc2626;
    --color-warning: #d97706;
    --color-overlay: rgba(0,0,0,0.4);
    --color-shadow: rgba(0,0,0,0.1);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --color-bg: #f5f5f7;
        --color-surface: #ffffff;
        --color-surface-2: #eef0f4;
        --color-primary-hover: #d63350;
        --color-text: #1a1a2e;
        --color-text-muted: #6b7280;
        --color-border: #d1d5db;
        --color-success: #16a34a;
        --color-error: #dc2626;
        --color-warning: #d97706;
        --color-overlay: rgba(0,0,0,0.4);
        --color-shadow: rgba(0,0,0,0.1);
    }
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* ── App Header ── */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding-top: var(--safe-top);
}

.app-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 16px;
}

.app-header__logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.app-header__spacer { width: 80px; }

.app-header__actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.header-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s;
    position: relative;
}

.header-btn:hover { background: var(--color-surface-2); }

.header-btn--add {
    background: var(--color-primary);
    color: #fff;
}

.header-btn--add:hover { background: var(--color-primary-hover); }

/* ── Main ── */
.app-main {
    padding-top: calc(var(--header-height) + var(--safe-top) + 8px);
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
    padding-left: 16px;
    padding-right: 16px;
    min-height: 100dvh;
    max-width: 640px;
    margin: 0 auto;
}

/* ── Bottom Nav ── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding-bottom: var(--safe-bottom);
    height: calc(var(--nav-height) + var(--safe-bottom));
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 0.65rem;
    cursor: pointer;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.nav-item.active { color: var(--color-primary); }
.nav-item__icon { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; }
.nav-item__icon svg { width: 24px; height: 24px; }
.nav-item__icon .icon-fill { fill: transparent; transition: fill 0.2s; }
.nav-item.active .nav-item__icon .icon-fill { fill: currentColor; opacity: 0.15; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-hover); }
.btn--primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--loading { position: relative; min-width: 80px; min-height: 40px; }
.btn--loading::after {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn--outline { background: transparent; border: 1px solid var(--color-primary); color: var(--color-primary); }
.btn--ghost { background: transparent; color: var(--color-text-muted); padding: 6px 10px; }
.btn--sm { padding: 6px 12px; font-size: 0.8rem; }

/* ── Inputs ── */
input[type="text"], input[type="url"], input[type="search"], input[type="number"], textarea, select {
    width: 100%;
    padding: 12px 16px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--color-primary);
}

textarea { resize: vertical; }

/* ── Capture View ── */
.capture-input { margin-bottom: 24px; }

.input-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.tab {
    flex: 1;
    padding: 8px 12px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.capture-form { display: none; flex-direction: column; gap: 10px; }
.capture-form.active { display: flex; }

.input-group {
    display: flex;
    gap: 8px;
}

.input-group input { flex: 1; }

.photo-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.2s;
}

.photo-upload:hover { border-color: var(--color-primary); }
.photo-upload__icon { font-size: 2rem; }
.photo-upload__text { color: var(--color-text-muted); font-size: 0.85rem; }

.photo-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

/* ── Queue ── */
.queue-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--color-text-muted);
}

.queue-list { display: flex; flex-direction: column; gap: 8px; }

.queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    cursor: pointer;
    transition: border-color 0.2s;
}

.queue-item:hover { border-color: var(--color-primary); }

.queue-item__thumb {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--color-surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.queue-item__thumb img { width: 100%; height: 100%; object-fit: cover; }
.queue-item__icon { font-size: 1.5rem; }

.queue-item__info { flex: 1; min-width: 0; }
.queue-item__title { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item__meta { font-size: 0.75rem; color: var(--color-text-muted); display: flex; align-items: center; gap: 8px; margin-top: 2px; }

.queue-item__actions { display: flex; gap: 4px; flex-shrink: 0; }

.status-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.status--pending { background: var(--color-surface-2); color: var(--color-text-muted); }
.status--loading { background: rgba(243, 156, 18, 0.15); color: var(--color-warning); }
.status--success { background: rgba(46, 204, 113, 0.15); color: var(--color-success); }
.status--error { background: rgba(231, 76, 60, 0.15); color: var(--color-error); }

/* ── Recipe Grid ── */
.recipes-view h1 { font-size: 1.3rem; margin-bottom: 12px; }

.recipes-header { margin-bottom: 16px; }

.recipes-search { margin-bottom: 8px; }

.recipes-filter { display: flex; gap: 4px; }

.filter-btn {
    padding: 6px 14px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

.recipe-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--color-border);
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, border-color 0.2s;
}

.recipe-card:hover { border-color: var(--color-primary); transform: translateY(-2px); }

.recipe-card__image { position: relative; aspect-ratio: 3/2; overflow: hidden; background: var(--color-surface-2); }
.recipe-card__image img { width: 100%; height: 100%; object-fit: cover; }
.recipe-card__placeholder { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 1.5rem; opacity: 0.15; }
.recipe-card__badge { position: absolute; top: 8px; left: 8px; background: var(--color-warning); color: #000; padding: 2px 8px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; }

.recipe-card__fav {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s, color 0.2s, transform 0.15s;
}
.recipe-card__fav:hover { transform: scale(1.08); }
.recipe-card__fav--on { color: var(--color-warning); }
.recipe-card__fav--on svg { fill: var(--color-warning); }

.recipe-detail__fav--on { color: var(--color-warning); }
.recipe-detail__fav--on svg { fill: var(--color-warning); }

.fav-toggle.active { background: var(--color-warning); border-color: var(--color-warning); color: #000; }

.recipe-card__body { padding: 10px; }
.recipe-card__title { font-size: 0.85rem; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.recipe-card__meta { display: flex; gap: 8px; font-size: 0.7rem; color: var(--color-text-muted); margin-top: 4px; }
.recipe-card__tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.tag {
    padding: 2px 8px;
    background: var(--color-surface-2);
    border-radius: 10px;
    font-size: 0.65rem;
    color: var(--color-text-muted);
}

/* ── Empty states ── */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* ── Loading ── */
.loading {
    text-align: center;
    padding: 32px;
    color: var(--color-text-muted);
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + var(--safe-top) + 12px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.toast {
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    text-align: center;
    box-shadow: 0 4px 20px var(--color-shadow);
}

.toast--visible { opacity: 1; transform: translateY(0) scale(1); }
.toast--success { background: var(--color-success); color: #fff; }
.toast--error { background: var(--color-error); color: #fff; }
.toast--info { background: var(--color-surface-2); color: var(--color-text); border: 1px solid var(--color-border); }

/* ── Recipe Detail ── */
.recipe-detail__actions-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.recipe-detail__hero { width: 100%; max-height: 300px; object-fit: cover; border-radius: var(--radius); margin-bottom: 16px; }
.recipe-detail__title { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.recipe-detail__meta { display: flex; gap: 12px; font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 8px; }
.recipe-detail__meta span { display: flex; align-items: center; gap: 4px; }
.recipe-detail__tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; }

.portion-adjuster { display: flex; align-items: center; gap: 8px; padding: 12px 0; font-weight: 600; }
.portion-value { font-size: 1.2rem; min-width: 2ch; text-align: center; color: var(--color-primary); }

.recipe-section { margin-bottom: 24px; }
.recipe-section h2 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.75rem; }

.ingredient-list { list-style: none; }
.ingredient-item { display: flex; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--color-border); font-size: 0.9rem; }
.ingredient-amount { font-weight: 700; min-width: 3ch; text-align: right; }
.ingredient-unit { color: var(--color-text-muted); min-width: 3ch; }
.ingredient-note { color: var(--color-text-muted); font-style: italic; }
.ingredient-note::before { content: '— '; }

.step-list { list-style: none; counter-reset: step; }
.step-item { display: flex; gap: 12px; margin-bottom: 16px; }
.step-number { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; }
.step-item p { line-height: 1.6; }

.recipe-detail__bottom-actions { display: flex; gap: 8px; margin-top: 24px; }

/* ── Recipe Edit ── */
.recipe-edit__header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.recipe-edit__header h1 { font-size: 1.2rem; }
.edit-form { display: flex; flex-direction: column; gap: 12px; }
.edit-form label { font-size: 0.8rem; font-weight: 600; color: var(--color-primary); margin-bottom: -4px; text-transform: uppercase; letter-spacing: 0.03em; }
.edit-row { display: flex; gap: 8px; }
.edit-field { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.edit-field label { font-size: 0.75rem; }
.edit-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ── Meal Plan ── */
.meal-plan-header { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.meal-plan-header h1 { flex: 1; text-align: center; font-size: 1.2rem; }

.week-block { margin-bottom: 20px; }
.week-block__header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--color-border); }
.week-block__label { font-size: 0.85rem; font-weight: 700; color: var(--color-primary); text-transform: uppercase; letter-spacing: 0.04em; }

.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; overflow-x: auto; }

.day-column { background: var(--color-surface); border-radius: var(--radius-sm); padding: 8px; min-width: 100px; border: 1px solid var(--color-border); }
.day-column--today { border-color: var(--color-primary); background: rgba(var(--color-primary-rgb), 0.05); }
.day-column--past { opacity: 0.6; }
.day-header { text-align: center; margin-bottom: 8px; }
.day-name { display: block; font-weight: 700; font-size: 0.8rem; }
.day-date { font-size: 0.7rem; color: var(--color-text-muted); }

.meal-slot { padding: 6px; margin-bottom: 4px; border-radius: 6px; background: var(--color-surface-2); min-height: 48px; min-width: 0; overflow: hidden; }
.meal-slot__label { font-size: 0.6rem; color: var(--color-text-muted); text-transform: uppercase; display: block; margin-bottom: 2px; }
.meal-slot__recipe { display: flex; flex-direction: column; gap: 2px; position: relative; min-width: 0; }
.meal-slot__title { font-size: 0.75rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal-slot__portions-ctrl { display: flex; align-items: center; gap: 2px; }
.portions-btn { background: none; border: 1px solid var(--color-border); border-radius: 4px; color: var(--color-text-muted); cursor: pointer; font-size: 0.7rem; width: 18px; height: 18px; padding: 0; display: flex; align-items: center; justify-content: center; line-height: 1; transition: border-color 0.2s, color 0.2s; }
.portions-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.meal-slot__portions { font-size: 0.65rem; color: var(--color-text-muted); min-width: 18px; text-align: center; font-weight: 600; }
.meal-slot__remove { position: absolute; top: -2px; right: -2px; background: none; border: none; color: var(--color-text-muted); cursor: pointer; font-size: 0.8rem; padding: 2px; }
.meal-slot__add { background: none; border: 1px dashed var(--color-border); border-radius: 4px; color: var(--color-text-muted); width: 100%; padding: 4px; cursor: pointer; font-size: 1rem; transition: border-color 0.2s; }
.meal-slot__add:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* ── Date Picker (shopping list) ── */
.date-picker__hint { font-size: 0.85rem; color: var(--color-text-muted); margin-bottom: 12px; }
.date-picker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 16px; }
.date-picker__day {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 10px 4px; border-radius: var(--radius-sm);
    background: var(--color-surface-2); border: 2px solid transparent;
    color: var(--color-text); cursor: pointer; transition: all 0.15s;
    position: relative;
}
.date-picker__day:disabled { opacity: 0.3; cursor: not-allowed; }
.date-picker__day--has-entries { border-color: var(--color-border); }
.date-picker__day--today { background: rgba(var(--color-primary-rgb), 0.1); }
.date-picker__day--selected { border-color: var(--color-primary); background: rgba(var(--color-primary-rgb), 0.2); }
.date-picker__day-name { font-size: 0.7rem; font-weight: 700; }
.date-picker__day-num { font-size: 0.75rem; }
.date-picker__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--color-success); }
.date-picker__actions { display: flex; gap: 8px; justify-content: space-between; }

/* ── Shopping List ── */
.shop-lists { display: flex; flex-direction: column; gap: 8px; }
.shop-list-card { display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); text-decoration: none; color: inherit; transition: border-color 0.2s; }
.shop-list-card:hover { border-color: var(--color-primary); }
.shop-list-card__info { flex: 1; }
.shop-list-card__info h3 { font-size: 0.95rem; }
.shop-list-card__meta { font-size: 0.75rem; color: var(--color-text-muted); }
.shop-list-card__progress { width: 80px; }

.progress-bar { height: 6px; background: var(--color-surface-2); border-radius: 3px; overflow: hidden; }
.progress-bar--large { height: 8px; margin-bottom: 16px; }
.progress-bar__fill { height: 100%; background: var(--color-success); border-radius: 3px; transition: width 0.3s; }

.shop-detail__header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.shop-detail__header h1 { flex: 1; font-size: 1.2rem; }
.shop-detail__progress { font-size: 0.85rem; color: var(--color-text-muted); font-weight: 600; }

.shop-category { margin-bottom: 16px; }
.shop-category__title { font-size: 0.8rem; font-weight: 700; color: var(--color-primary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--color-border); }

.shop-items { list-style: none; }
.shop-item { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--color-border); transition: opacity 0.2s; }
.shop-item--checked { opacity: 0.4; }
.shop-item--checked .shop-item__name { text-decoration: line-through; }
.shop-item__check { background: none; border: none; font-size: 1.2rem; cursor: pointer; padding: 4px; -webkit-tap-highlight-color: transparent; }
.shop-item__info { flex: 1; min-width: 0; }
.shop-item__name { font-size: 0.9rem; display: block; }
.shop-item__name b { color: var(--color-primary); }
.shop-item__sources { font-size: 0.7rem; color: var(--color-text-muted); display: block; margin-top: 2px; }
.shop-item__manual { font-size: 0.6rem; background: var(--color-surface-2); padding: 1px 6px; border-radius: 8px; color: var(--color-text-muted); }
.shop-item__delete { opacity: 0.3; transition: opacity 0.2s; }
.shop-item:hover .shop-item__delete { opacity: 1; }

.shop-detail__toolbar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

.shop-list-card__actions { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; margin-left: auto; }
.shop-list-card__actions .btn { font-size: 1rem; padding: 4px 8px; opacity: 0.4; transition: opacity 0.2s; z-index: 1; }
.shop-list-card__actions .btn:hover { opacity: 1; }
.shop-list-card__actions .btn-delete-list:hover { color: var(--color-error); }
.shop-list-card--done { opacity: 0.6; }
.progress-bar__fill--done { background: var(--color-text-muted); }

.shop-add-form { display: flex; gap: 8px; margin-top: 16px; padding: 12px; background: var(--color-surface); border-radius: var(--radius); border: 1px solid var(--color-border); }
.shop-add-form input { flex: 1; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: var(--color-overlay); z-index: 300; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--color-surface); border-radius: var(--radius) var(--radius) 0 0; width: 100%; max-width: 640px; max-height: 80vh; display: flex; flex-direction: column; }
.modal__header { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--color-border); }
.modal__header h2 { font-size: 1.1rem; }
.modal__body { padding: 16px; overflow-y: auto; flex: 1; }
.modal__search { margin-bottom: 12px; }

.picker-list { display: flex; flex-direction: column; gap: 4px; }
.picker-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-sm); cursor: pointer; text-align: left; color: var(--color-text); transition: border-color 0.2s; width: 100%; }
.picker-item:hover { border-color: var(--color-primary); }
.picker-item__title { font-weight: 600; font-size: 0.9rem; }
.picker-item__meta { font-size: 0.75rem; color: var(--color-text-muted); white-space: nowrap; flex-shrink: 0; }

/* ── Picker filters: two-axis chip rows ── */
.picker-filters { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.picker-filters__row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
    /* Edge mask: fade chips at the right so it's clear there's more to scroll. */
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
            mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
}
.picker-filters__row::-webkit-scrollbar { display: none; }
.picker-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    color: var(--color-text);
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    scroll-snap-align: start;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.picker-chip:hover { border-color: var(--color-primary); }
.picker-chip__icon { font-size: 0.95rem; line-height: 1; }
.picker-chip__count { font-size: 0.7rem; color: var(--color-text-muted); }
.picker-chip--active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
.picker-chip--active .picker-chip__count { color: rgba(255,255,255,0.85); }
.picker-chip--empty { opacity: 0.4; }
.picker-chip--empty.picker-chip--active { opacity: 1; }
.picker-empty {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    padding: 24px 12px;
}

/* Star indicator on picker items + the favorites filter chip */
.picker-item__star { color: var(--color-warning); margin-right: 4px; }
.picker-chip--fav .picker-chip__icon { color: var(--color-warning); }
.picker-chip--fav.picker-chip--active { background: var(--color-warning); border-color: var(--color-warning); color: #000; }
.picker-chip--fav.picker-chip--active .picker-chip__icon { color: #000; }
.picker-chip--fav.picker-chip--active .picker-chip__count { color: rgba(0,0,0,0.7); }

/* ── Capture Modal (bottom sheet) ── */
.capture-modal-overlay {
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.capture-modal-overlay.capture-modal--open {
    opacity: 1;
    pointer-events: auto;
}
.capture-modal-overlay .modal {
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.capture-modal-overlay.capture-modal--open .modal {
    transform: translateY(0);
}

.capture-pipeline { display: flex; flex-direction: column; gap: 8px; }

.capture-option {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 16px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s;
    font-family: inherit;
}
.capture-option:hover { border-color: var(--color-primary); }

.capture-option__icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--color-primary-rgb), 0.12);
    border-radius: var(--radius-sm);
    color: var(--color-primary);
    flex-shrink: 0;
}
.capture-option__icon svg { width: 22px; height: 22px; }

.capture-option__title { font-weight: 600; font-size: 0.95rem; display: block; }
.capture-option__desc { font-size: 0.8rem; color: var(--color-text-muted); display: block; margin-top: 2px; }

.capture-step { display: flex; flex-direction: column; gap: 12px; }
.capture-step[hidden], .capture-pipeline[hidden], .modal__back[hidden], .header-btn[hidden] { display: none !important; }

.capture-modal .modal__back {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}
.capture-modal .modal__back:hover { color: var(--color-text); }

/* ── Theme transition ── */
body, .app-header, .bottom-nav, .modal {
    transition: background-color 0.3s, border-color 0.3s;
}

/* ── Responsive ── */
@media (min-width: 768px) {
    .app-main { max-width: 800px; }
    .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    .modal { border-radius: var(--radius); max-height: 70vh; align-self: center; }
    .modal-overlay { align-items: center; }
}

@media (max-width: 600px) {
    .week-grid { grid-template-columns: 1fr; }
    .day-column { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
    .day-header { margin-bottom: 0; min-width: 50px; text-align: left; }
    .meal-slot { flex: 1; min-height: auto; padding: 4px 8px; margin-bottom: 0; }
    .meal-slot__label { display: none; }
    .date-picker-grid { grid-template-columns: repeat(7, 1fr); gap: 4px; }
    .date-picker__day { padding: 8px 2px; }
    .date-picker__actions { flex-direction: column; }
}
