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

:root {
    --emerald: #27ae60;
    --emerald-light: #2ecc71;
    --emerald-dark: #1e8449;
    --navy: #2c3e50;
    --navy-light: #34495e;
    --bg: #f9fafb;
    --white: #ffffff;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-400: #9ca3af;
    --gray-600: #6b7280;
    --gray-800: #374151;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.1);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 300px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Outfit', sans-serif;
    font-weight: 400;
    color: var(--navy);
    background: var(--bg);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
}

h1, h2, h3, h4, .playfair {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 600;
}

.menu-toggle {
    display: none;
    position: fixed;
    top: 12px; left: 12px;
    z-index: 1000;
    background: var(--emerald);
    border: none;
    width: 44px; height: 44px;
    border-radius: 50%;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: var(--shadow-lg);
}
.menu-toggle span {
    display: block;
    width: 22px; height: 2px;
    background: white;
    border-radius: 2px;
    transition: .25s;
}
.menu-open .menu-toggle span:nth-child(1) { transform: rotate(45deg) translate(5px,5px); }
.menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
.menu-open .menu-toggle span:nth-child(3) { transform: rotate(-45deg) translate(5px,-5px); }

.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 99; }

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--navy);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform .3s ease;
}

.sidebar-header {
    position: relative;
    padding: 28px 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
    opacity: .9;
}
.logo {
    font-size: 1.75rem;
    font-weight: 700;
    font-style: italic;
    color: var(--emerald-light);
    line-height: 1.2;
}
.tagline {
    font-size: .85rem;
    color: rgba(255,255,255,.55);
    margin-top: 4px;
    font-weight: 300;
}

.search-box { padding: 20px 24px; }
.search-box input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,.08);
    color: white;
    font-family: inherit;
    font-size: .9rem;
    outline: none;
    transition: border-color .2s;
}
.search-box input::placeholder { color: rgba(255,255,255,.35); }
.search-box input:focus { border-color: var(--emerald); }

.groupes-nav {
    flex: 1;
    padding: 0 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.groupe-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.65);
    text-decoration: none;
    font-weight: 400;
    font-size: .95rem;
    transition: .15s;
    position: relative;
}
.groupe-link:hover { color: white; background: rgba(255,255,255,.06); }
.groupe-link.active { color: white; background: var(--emerald); font-weight: 500; }
.groupe-link .badge {
    margin-left: auto;
    background: rgba(0,0,0,.2);
    color: white;
    font-size: .75rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
}
.groupe-link.active .badge { background: rgba(0,0,0,.25); }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 36px 40px;
    min-height: 100vh;
}

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

.recipe-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
    display: flex;
    flex-direction: column;
}
.recipe-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.recipe-card-header {
    background: linear-gradient(135deg, var(--emerald), var(--emerald-dark));
    color: white;
    padding: 28px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.recipe-card-letter {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 700;
    flex-shrink: 0;
}
.recipe-card-title {
    flex: 1;
    font-size: 1.15rem;
}

.recipe-card-body { padding: 16px 20px; flex: 1; }
.recipe-card-resume {
    font-size: .9rem;
    color: var(--gray-600);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.recipe-card-meta {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    font-size: .8rem;
    color: var(--gray-400);
}
.recipe-card-meta span { display: flex; align-items: center; gap: 4px; }

.recipe-detail {
    max-width: 780px;
    margin: 0 auto;
}
.recipe-detail-header {
    margin-bottom: 32px;
}
.recipe-detail-header h2 {
    font-size: 2rem;
    color: var(--navy);
    margin-bottom: 4px;
}
.recipe-detail-header .resume {
    font-size: 1rem;
    color: var(--gray-600);
    margin-bottom: 16px;
    font-style: italic;
}
.recipe-detail-meta {
    display: flex;
    gap: 20px;
    font-size: .9rem;
    color: var(--gray-400);
    margin-bottom: 8px;
}
.recipe-detail-meta span { display: flex; align-items: center; gap: 5px; }
.recipe-detail-groupes {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.recipe-detail-groupes .tag {
    font-size: .75rem;
    padding: 3px 12px;
    border-radius: 20px;
    background: var(--emerald);
    color: white;
    font-weight: 500;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--emerald);
    text-decoration: none;
    font-weight: 500;
    font-size: .9rem;
    margin-bottom: 20px;
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}
.back-btn:hover { color: var(--emerald-dark); }

.recipe-section {
    margin-bottom: 28px;
}
.recipe-section h3 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    color: var(--emerald);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--emerald-light);
    display: inline-block;
}

.ingredients-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.ingredients-list li {
    background: var(--gray-100);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: .9rem;
    color: var(--navy);
}

.instructions-list {
    list-style: none;
    counter-reset: step;
}
.instructions-list li {
    counter-increment: step;
    padding: 12px 0 12px 44px;
    position: relative;
    border-bottom: 1px solid var(--gray-200);
    font-size: .95rem;
    line-height: 1.7;
}
.instructions-list li::before {
    content: counter(step);
    position: absolute;
    left: 0; top: 14px;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--emerald);
    color: white;
    font-size: .8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
    font-size: 1.1rem;
}

/* ── View Toggle Button ─────────────────────────────── */
.view-toggle {
    position: absolute;
    top: 10px;
    right: 12px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    color: rgba(255,255,255,.55);
    font-family: 'Outfit', sans-serif;
    font-size: .7rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 20px;
    cursor: pointer;
    letter-spacing: .02em;
    transition: background .2s, color .2s, border-color .2s;
    white-space: nowrap;
}
.view-toggle:hover {
    background: rgba(255,255,255,.18);
    color: rgba(255,255,255,.9);
}
.view-toggle .lbl-v1 { display: none; }

/* ── V1 Mode — Sidebar ──────────────────────────────── */
body.mode-v1 .sidebar {
    background: #ffffff;
    border-right: 1px solid #eaeaea;
}
body.mode-v1 .sidebar-header {
    border-bottom-color: #eaeaea;
}
body.mode-v1 .sidebar-icon { display: none; }
body.mode-v1 .logo { color: var(--emerald); }
body.mode-v1 .tagline { color: var(--gray-600); }
body.mode-v1 .search-box input {
    background: #f9fafb;
    border-color: #eaeaea;
    color: var(--navy);
}
body.mode-v1 .search-box input::placeholder { color: var(--gray-400); }
body.mode-v1 .search-box input:focus { border-color: var(--emerald); }
body.mode-v1 .groupes-nav { display: none; }
body.mode-v1 .view-toggle {
    background: rgba(0,0,0,.04);
    border-color: #ddd;
    color: var(--gray-400);
}
body.mode-v1 .view-toggle:hover {
    background: var(--emerald);
    border-color: var(--emerald);
    color: white;
}
body.mode-v1 .view-toggle .lbl-v2 { display: none; }
body.mode-v1 .view-toggle .lbl-v1 { display: inline; }

/* ── V1 Recipe Nav ──────────────────────────────────── */
.recipe-nav-v1 {
    display: none;
    flex: 1;
    padding: 0 16px 24px;
    flex-direction: column;
}
body.mode-v1 .recipe-nav-v1 { display: flex; }

.nav-section-v1 { margin-top: 16px; }
.nav-section-v1 h2 {
    font-family: 'Outfit', sans-serif;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--gray-400);
    margin-bottom: 8px;
    border-bottom: 2px solid #eafaf1;
    padding-bottom: 5px;
}
.nav-section-v1 ul { list-style: none; }

.recipe-item-v1 {
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 500;
    color: var(--navy-light);
    transition: background .12s, color .12s, transform .12s;
    margin-bottom: 2px;
}
.recipe-item-v1:hover {
    background: #eafaf1;
    color: var(--emerald);
    transform: translateX(3px);
}
.recipe-item-v1.active {
    background: var(--emerald);
    color: white;
    transform: none;
}

/* ── V1 Welcome Card ────────────────────────────────── */
.welcome-card-v1 {
    display: none;
    background: var(--white);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow);
    margin-top: 20px;
    max-width: 780px;
}
.welcome-icon-v1 { margin-bottom: 20px; }
.welcome-card-v1 h2 {
    font-size: 1.6rem;
    color: var(--navy);
    margin-bottom: 10px;
}
.welcome-card-v1 p { color: var(--gray-600); font-size: .95rem; }

/* ── V1 Mode — Main content ─────────────────────────── */
body.mode-v1 .recipes-grid { display: none !important; }
body.mode-v1 .empty-state  { display: none !important; }

@media (max-width: 768px) {
    body { flex-direction: column; }
    .menu-toggle { display: flex; }

    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        min-width: 280px;
    }
    .menu-open .sidebar { transform: translateX(0); }
    .menu-open .overlay { display: block; }

    .main-content {
        margin-left: 0;
        padding: 16px 12px;
        padding-top: 68px;
    }

    .recipes-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .recipe-detail-header h2 { font-size: 1.5rem; }
    .recipe-detail { max-width: 100%; }
}
