:root {
    --bg-color: #f0f4fc;
    --card-bg: #dce7f9;
    --text-dark: #1a202c;
    --text-light: #718096;
    --accent: #ff7f50;
    --white: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
    display: flex;
    justify-content: center;
}

/* Core Layout Shell - Fluid Desktop & Mobile Adaptive Integration */
.app-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 40px rgba(0,0,0,0.03);
}

/* Multi-Column Grid Adjustments for Wide Viewports */
@media (min-width: 768px) {
    .recipe-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .recipe-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Fluid Native Edge-to-Edge Experience on Handheld Screens */
@media (max-width: 480px) {
    .app-container {
        max-width: 100%;
        box-shadow: none;
    }
}

h1, h2, h3 { font-family: 'Playfair Display', serif; color: var(--text-dark); }
h1 { font-size: 2.2rem; padding: 2rem 1.5rem 1rem; }

.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem 0;
}

input, button, textarea { font-family: 'Inter', sans-serif; border: none; outline: none; }

.search-bar {
    background: var(--white);
    padding: 1rem;
    border-radius: 12px;
    margin: 0 1.5rem 1.5rem;
    width: calc(100% - 3rem);
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.btn {
    background: var(--accent);
    color: var(--white);
    padding: 0.8rem 1.5rem;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(255, 127, 80, 0.3); }

.btn-icon { 
    background: transparent; 
    color: var(--text-dark); 
    font-size: 1rem; 
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
}

/* View Switching Flex Rules */
.view { display: none; width: 100%; }
.view.active { display: flex; flex-direction: column; flex: 1; }

.tags-container {
    display: flex;
    gap: 10px;
    padding: 0 1.5rem 1.5rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.tags-container::-webkit-scrollbar { display: none; }

.tag {
    background: var(--white);
    color: var(--text-dark);
    padding: 0.5rem 1.2rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.01);
}
.tag.active { background: var(--accent); color: var(--white); }

.recipe-list { padding: 0 1.5rem 2rem; display: grid; gap: 1.5rem; }
.recipe-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 1.5rem;
    cursor: pointer;
    position: relative;
    transition: 0.3s;
}
.recipe-card h3 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.recipe-card p { font-size: 0.9rem; color: #4a5568; line-height: 1.4; }

.recipe-header {
    background: var(--card-bg);
    padding: 2rem 1.5rem 3.5rem;
}
.recipe-header h1 { padding: 1rem 0 0.5rem; font-size: 2.5rem; }
.meta-info { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.5rem; color: #4a5568; font-size: 0.9rem; }

.detail-tags-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Flushed Bottom Sheet Layout */
.content-sheet {
    background: var(--white);
    border-radius: 30px 30px 0 0;
    margin-top: -30px;
    padding: 2rem 1.5rem 3rem;
    flex: 1;
    position: relative;
    z-index: 2;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.02);
}

.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.portions-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-color);
    padding: 0.5rem;
    border-radius: 20px;
}
.portions-control button {
    background: var(--white); width: 30px; height: 30px; border-radius: 50%;
    cursor: pointer; font-weight: bold;
}

.macro-toggle {
    font-size: 0.8rem;
    color: var(--text-light);
    cursor: pointer;
    text-decoration: underline;
}

.macros-box {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    text-align: center;
}
.macro-item span { display: block; font-size: 0.8rem; color: var(--text-light); margin-top: 0.2rem; }
.macro-item strong { color: var(--accent); }

ul.ingredient-list { list-style: none; margin-bottom: 2rem; }
ul.ingredient-list li {
    display: flex; justify-content: space-between;
    padding: 0.8rem 0; border-bottom: 1px solid #edf2f7;
}

ol.steps-list { padding-left: 1.2rem; }
ol.steps-list li { margin-bottom: 1.5rem; line-height: 1.6; color: #4a5568; }
ol.steps-list li::marker { color: var(--accent); font-weight: bold; }

.add-recipe-form { padding: 1.5rem; }
textarea.ai-input {
    width: 100%; height: 200px; background: var(--white);
    border-radius: 15px; padding: 1rem; margin-bottom: 1rem;
    resize: none; box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}
.loader { display: none; text-align: center; color: var(--text-light); margin-top: 1rem; }
