* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #d35400;
    --primary-light: #e67e22;
    --primary-dark: #a04000;
    --primary-bg: rgba(211, 84, 0, 0.08);
    --accent: #27ae60;
    --accent-light: #2ecc71;
    --accent-bg: rgba(39, 174, 96, 0.08);
    --bg: #faf8f5;
    --card-bg: #ffffff;
    --text: #2c1810;
    --text-secondary: #6b5344;
    --text-muted: #9b8a7e;
    --border: #e8e0d8;
    --danger: #c0392b;
    --success: #27ae60;
    --sidebar-bg: #2c1810;
    --sidebar-hover: #3d261a;
    --sidebar-active: #4e3424;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 8px rgba(44, 24, 16, 0.06);
    --shadow-lg: 0 8px 32px rgba(44, 24, 16, 0.12);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { height: 100%; overflow: hidden; }

body {
    font-family: 'Rajdhani', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    height: 100%;
    display: flex;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    font-weight: 500;
}

/* ===== LOGIN GATE ===== */
#login-gate {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s, visibility 0.4s;
    overflow: hidden;
}

#login-gate.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.login-gate-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg, #1a0a00 0%, #3d1a00 30%, #d35400 55%, #27ae60 80%, #1a3d20 100%);
    z-index: 0;
}

.login-gate-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 70%, rgba(211, 84, 0, 0.3) 0%, transparent 60%),
                radial-gradient(circle at 70% 30%, rgba(39, 174, 96, 0.2) 0%, transparent 50%);
}

.login-gate-card {
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    width: min(400px, 90vw);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-gate-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-gate-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.login-gate-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.login-gate-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.gate-input-group {
    margin-bottom: 1rem;
}

.gate-input-group input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
    background: var(--card-bg);
    transition: border-color 0.2s;
}

.gate-input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.gate-btn {
    width: 100%;
    padding: 0.85rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.gate-btn:hover { background: var(--primary-dark); }

.gate-divider {
    display: flex;
    align-items: center;
    margin: 1.2rem 0;
    color: var(--text-muted);
}

.gate-divider::before, .gate-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.gate-divider span { padding: 0 0.8rem; font-size: 0.9rem; }

.gate-switch {
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.gate-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.gate-error {
    margin-top: 1rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    background: rgba(192, 57, 43, 0.1);
    color: var(--danger);
    text-align: center;
    font-size: 0.9rem;
}

.gate-success {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success);
}

/* ===== APP LAYOUT ===== */
#app {
    display: flex;
    width: 100%;
    height: 100%;
}

#app.hidden { display: none; }

/* ===== SIDEBAR (Desktop) ===== */
#sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.2rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-icon { font-size: 1.5rem; }
.sidebar-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.snav-btn {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.snav-btn:hover { background: var(--sidebar-hover); color: rgba(255,255,255,0.85); }
.snav-btn.active { background: var(--sidebar-active); color: white; font-weight: 600; }
.snav-icon { font-size: 1.2rem; width: 1.5rem; text-align: center; }

/* ===== MAIN ===== */
#main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
}

#main-content {
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== BOTTOM NAV (Mobile) ===== */
#bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding: 0.4rem 0 calc(0.4rem + var(--safe-bottom));
    z-index: 100;
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0.3rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-btn.active { color: var(--primary); font-weight: 700; }
.nav-icon { font-size: 1.3rem; }

/* ===== COMMON ===== */
.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.view-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
}

.view-actions { display: flex; gap: 0.5rem; }

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d5cdc5; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #a93226; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-icon { background: none; color: var(--text-muted); font-size: 1.3rem; padding: 0.3rem; }
.btn-icon.active { color: var(--danger); }

.btn-back {
    background: none;
    border: none;
    color: var(--primary);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.3rem 0;
}

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }

.loading { text-align: center; padding: 3rem; color: var(--text-muted); font-size: 1.1rem; }
.error { text-align: center; padding: 2rem; color: var(--danger); }
.empty-state { text-align: center; padding: 3rem; color: var(--text-muted); }
.empty-state .btn { margin-top: 1rem; }

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.search-box { flex: 1; min-width: 200px; }

.search-box input {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    background: var(--card-bg);
}

.search-box input:focus { outline: none; border-color: var(--primary); }

.filter-chips {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.chip {
    padding: 0.35rem 0.8rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip-active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== RECIPE GRID ===== */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.2rem;
}

.recipe-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.recipe-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.recipe-card-img {
    height: 180px;
    background: #e8e0d8;
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.recipe-card-placeholder { color: var(--text-muted); font-size: 0.9rem; }

.recipe-fav-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255,255,255,0.85);
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    font-size: 1.1rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.recipe-fav-btn.active { color: var(--danger); }

.recipe-card-body { padding: 0.8rem 1rem; }

.recipe-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recipe-card-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.recipe-cat { color: var(--primary); font-weight: 600; }
.recipe-time { color: var(--accent); }

/* ===== RECIPE DETAIL ===== */
.recipe-detail { max-width: 800px; }

.recipe-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.recipe-detail-actions { display: flex; gap: 0.5rem; }

.recipe-detail-img {
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.2rem;
}

.recipe-detail-img img { width: 100%; max-height: 400px; object-fit: cover; display: block; }

.recipe-detail-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 0.8rem; }

.recipe-detail-meta {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.meta-badge {
    padding: 0.25rem 0.6rem;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.meta-info { font-size: 0.85rem; color: var(--text-muted); display: flex; align-items: center; }

.recipe-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tag {
    padding: 0.2rem 0.5rem;
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.recipe-description { color: var(--text-secondary); margin-bottom: 1.5rem; line-height: 1.6; }

.recipe-sections {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 { font-size: 1.2rem; font-weight: 700; }

.servings-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.servings-control .btn-sm {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border);
    border: none;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
}

#servings-display { font-weight: 600; font-size: 0.95rem; min-width: 90px; text-align: center; }

.ingredient-list { list-style: none; }

.ingredient-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.ingredient-group {
    font-weight: 700;
    color: var(--primary);
    padding: 0.8rem 0 0.3rem;
    font-size: 0.95rem;
}

.ing-amount { font-weight: 700; }
.ing-unit { color: var(--text-secondary); }

.recipe-steps-section h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 1rem; }

.step-list {
    list-style: none;
    counter-reset: step;
}

.step-item {
    position: relative;
    padding: 0.8rem 0 0.8rem 2.5rem;
    border-bottom: 1px solid var(--border);
    counter-increment: step;
}

.step-item::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0.8rem;
    width: 1.8rem;
    height: 1.8rem;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}

.step-text { line-height: 1.6; }
.step-duration { font-size: 0.8rem; color: var(--accent); font-weight: 600; margin-top: 0.3rem; display: block; }

.recipe-notes {
    background: var(--primary-bg);
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.recipe-notes h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.recipe-source a { color: var(--primary); font-weight: 600; }

/* ===== RECIPE FORM ===== */
.recipe-form { max-width: 800px; }

.form-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.2rem;
    box-shadow: var(--shadow);
}

.form-section h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 1rem; }

.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

.form-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header-row h3 { margin-bottom: 0; }

/* Ingredient Groups */
.ing-group {
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.3rem;
    margin-bottom: 0.8rem;
    transition: border-color 0.2s, background 0.2s;
}

.ing-group.drag-over {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.ing-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.3rem;
    margin-bottom: 0.4rem;
    background: var(--bg);
    border-radius: 6px;
    cursor: grab;
}

.ing-group-drag {
    color: var(--text-muted);
    font-size: 1rem;
    cursor: grab;
    user-select: none;
}

.ing-group-title {
    flex: 1;
    padding: 0.3rem 0.5rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
    background: transparent;
}

.ing-group-title:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--card-bg);
}

.ing-drag-handle {
    color: var(--text-muted);
    cursor: grab;
    user-select: none;
    font-size: 0.9rem;
    padding: 0 0.2rem;
    line-height: 1;
}

.ingredient-row.dragging { opacity: 0.4; }

.btn-add-to-group {
    background: none;
    border: 1px dashed var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.6rem;
    font-family: inherit;
    font-size: 0.8rem;
    margin-top: 0.3rem;
    transition: all 0.2s;
}

.btn-add-to-group:hover, .btn-add-group-here:hover { border-color: var(--primary); color: var(--primary); }

.ing-group-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.3rem;
}

.btn-add-group-here {
    background: none;
    border: 1px dashed var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.6rem;
    font-family: inherit;
    font-size: 0.8rem;
    transition: all 0.2s;
}

/* Ingredient & Step rows */
.ingredient-row, .step-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.ingredient-row input, .step-row textarea, .step-row input {
    padding: 0.5rem 0.6rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    background: var(--bg);
}

.input-xs { width: 60px; flex-shrink: 0; }
.input-sm { width: 90px; flex-shrink: 0; }
.input-md { flex: 1; }

.step-row textarea { flex: 1; resize: vertical; }
.step-num {
    font-weight: 700;
    color: var(--primary);
    padding-top: 0.5rem;
    min-width: 1.5rem;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.3rem;
    line-height: 1;
    flex-shrink: 0;
}

.btn-remove:hover { color: var(--danger); }

/* Image upload */
.image-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-upload-area:hover, .image-upload-area.drag-over { border-color: var(--primary); }
.image-placeholder { color: var(--text-muted); }
.image-preview { max-width: 100%; max-height: 200px; border-radius: 8px; }

.checkbox-group { display: flex; flex-wrap: wrap; gap: 1rem; }
.checkbox-group label { display: flex; align-items: center; gap: 0.3rem; font-size: 0.95rem; cursor: pointer; }

/* ===== MEAL PLAN GRID ===== */
.week-nav {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

#week-label { font-weight: 700; font-size: 1.05rem; min-width: 130px; text-align: center; }

.meal-plan-grid { overflow-x: auto; }

.mp-header-row, .mp-row {
    display: grid;
    grid-template-columns: 100px repeat(7, minmax(0, 1fr));
    gap: 2px;
    min-width: 700px;
}

.mp-corner { background: var(--bg); }

.mp-day-header {
    background: var(--primary);
    color: white;
    padding: 0.5rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 6px 6px 0 0;
}

.mp-day-header small { font-weight: 400; opacity: 0.8; }

.mp-meal-label {
    background: var(--card-bg);
    padding: 0.5rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: flex-start;
    border-right: 2px solid var(--border);
}

.mp-cell {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 0.3rem;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    overflow: hidden;
}

.mp-item {
    background: var(--primary-bg);
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.3rem;
}

.mp-item-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.mp-item-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.mp-item-remove:hover { color: var(--danger); }

.mp-cell-actions {
    display: flex;
    gap: 2px;
    margin-top: auto;
}

.mp-add-btn, .mp-add-dessert-btn {
    background: none;
    border: 1px dashed var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.15rem;
    font-size: 0.85rem;
    transition: all 0.2s;
    line-height: 1;
}

.mp-add-btn { flex: 1; }
.mp-add-dessert-btn { flex: 0 0 auto; font-size: 0.75rem; }

.mp-add-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.mp-add-dessert-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }

.mp-item-link {
    color: var(--text);
    text-decoration: none;
}

.mp-item-link:hover { color: var(--primary); text-decoration: underline; }

/* ===== AI PLAN ===== */
.ai-plan-container { max-width: 900px; }

.ai-preferences {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.ai-preferences h3 { margin-bottom: 1rem; }

.ai-result {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.ai-result h3 { margin-bottom: 1rem; }

.ai-preview-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.ai-day {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 0.8rem;
}

.ai-day h4 { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--primary); }

.ai-meal {
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
}

.ai-meal-type { color: var(--text-muted); display: block; font-size: 0.7rem; }
.ai-meal-title { font-weight: 600; }
.ai-new-badge {
    display: inline-block;
    background: var(--accent);
    color: white;
    font-size: 0.65rem;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-weight: 700;
    margin-left: 0.3rem;
}

.ai-result-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: flex-end;
}

/* ===== SHOPPING LIST ===== */
.shopping-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
    min-height: 400px;
}

.shopping-sidebar {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.shopping-list-item {
    padding: 0.7rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem;
    transition: background 0.2s;
    margin-bottom: 0.3rem;
}

.shopping-list-item:hover { background: var(--bg); }
.shopping-list-item.active { background: var(--primary-bg); }
.shopping-list-item span { font-weight: 600; font-size: 0.95rem; flex: 1; }
.shopping-list-item small { font-size: 0.8rem; color: var(--text-muted); }

.shopping-main {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.shopping-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.shopping-progress { color: var(--text-muted); font-weight: 600; }

.shopping-items { list-style: none; }

.shopping-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    transition: opacity 0.2s;
}

.shopping-item.checked { opacity: 0.4; }
.shopping-item.checked .shopping-item-text { text-decoration: line-through; }

.shopping-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.shopping-item-text { flex: 1; font-size: 0.95rem; }
.shopping-item-cat { color: var(--text-muted); font-size: 0.8rem; }

/* ===== SETTINGS ===== */
.settings-container { max-width: 600px; }

.settings-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.settings-section h3 { margin-bottom: 0.8rem; font-size: 1.1rem; }
.settings-info p { margin-bottom: 0.5rem; color: var(--text-secondary); }
.settings-section a { color: var(--primary); font-weight: 600; }
.settings-hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.8rem; }

.allowed-users { list-style: none; }

.allowed-user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.add-user-form .form-row { display: flex; gap: 0.5rem; align-items: flex-end; }

.add-user-form input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    background: var(--bg);
}

.add-user-form input:focus { outline: none; border-color: var(--primary); }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    opacity: 0;
    transition: opacity 0.2s;
}

.modal-overlay.active { opacity: 1; }

.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    width: min(500px, 90vw);
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 1.1rem; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.modal-body { padding: 1.2rem; }
.modal-actions { display: flex; gap: 0.8rem; justify-content: flex-end; padding: 1rem 1.2rem; border-top: 1px solid var(--border); }

.modal-picker { width: min(600px, 90vw); }

.modal-search {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    background: var(--bg);
    margin-bottom: 0.8rem;
}

.modal-search:focus { outline: none; border-color: var(--primary); }

.picker-results { max-height: 300px; overflow-y: auto; }

.picker-item {
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
}

.picker-item:hover { background: var(--primary-bg); }
.picker-item span { font-weight: 600; }
.picker-item small { color: var(--text-muted); }
.picker-empty { text-align: center; color: var(--text-muted); padding: 1rem; }

.picker-divider {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0.8rem 0;
}

.picker-custom {
    display: flex;
    gap: 0.5rem;
}

.picker-custom input {
    flex: 1;
    padding: 0.5rem 0.8rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ===== IMPORT MODAL ===== */
.modal-import { width: min(550px, 90vw); }

.import-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.import-tab {
    flex: 1;
    padding: 0.6rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.import-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.import-tab:hover { color: var(--text); }

.import-hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.8rem; }

.import-tab-content input[type="url"],
.import-tab-content textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    background: var(--bg);
    margin-bottom: 0.8rem;
}

.import-tab-content input:focus,
.import-tab-content textarea:focus { outline: none; border-color: var(--primary); }

.import-tab-content textarea { resize: vertical; min-height: 200px; }

.import-status {
    margin-top: 0.8rem;
    padding: 0.6rem;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
    color: var(--primary);
    background: var(--primary-bg);
}

.import-error { color: var(--danger); background: rgba(192, 57, 43, 0.1); }

/* ===== TOAST ===== */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.7rem 1.2rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    background: var(--text);
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    transition: transform 0.3s ease;
}

.toast.show { transform: translateX(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    #sidebar { display: none; }
    #bottom-nav { display: flex; }
    #main { padding: 1rem; padding-bottom: calc(4rem + var(--safe-bottom)); }

    .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.8rem; }
    .recipe-card-img { height: 130px; }

    .recipe-sections { grid-template-columns: 1fr; gap: 1.5rem; }

    .form-row { flex-direction: column; gap: 0; }

    .mp-header-row, .mp-row { min-width: 600px; }

    .ai-preview-grid { grid-template-columns: repeat(3, 1fr); }

    .shopping-container { grid-template-columns: 1fr; }

    .view-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .recipe-grid { grid-template-columns: 1fr 1fr; }
    .ai-preview-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== PRINT ===== */
@media print {
    #sidebar, #bottom-nav, .recipe-detail-actions, .servings-control, .btn, .filter-bar { display: none !important; }
    #main { padding: 0; }
    .recipe-detail { max-width: none; }
    .recipe-sections { grid-template-columns: 1fr 1.5fr; }
}
