:root {
    --bg: #f5f2eb;
    --surface: #ffffff;
    --surface2: #f9f8f6;
    --text: #2d3436;
    --text2: #5c5b57;
    --border: #e9e5df;
    --primary: #e17055;
    --primary-hover: #d45d40;
    --skeleton: linear-gradient(90deg, #f0ede6 0%, #e8e5de 40%, #f0ede6 80%);
    --shadow: 0 4px 12px rgba(0,0,0,0.04);
    --shadow-hover: 0 12px 28px rgba(0,0,0,0.08);
}
.dark {
    --bg: #1e1e1e;
    --surface: #2d2d2d;
    --surface2: #383838;
    --text: #f5f5f5;
    --text2: #cccccc;
    --border: #4a4a4a;
    --shadow: 0 4px 12px rgba(0,0,0,0.2);
    --shadow-hover: 0 12px 28px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    transition: background 0.3s, color 0.3s;
}
.app {
    width: 100%;
    max-width: 800px;
    background: var(--surface);
    border-radius: 28px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}
.app-header {
    background: linear-gradient(135deg, #1e2b2c 0%, #2d3436 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.app-header h1 { font-size: 1.6rem; font-weight: 700; }
.header-logo { height: 40px; margin-right: 10px; vertical-align: middle; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.header-actions button {
    background: rgba(255,255,255,0.15);
    border: none; color: white; padding: 8px 12px;
    border-radius: 20px; cursor: pointer; font-weight: 600; font-size: 0.85rem;
    transition: background 0.2s;
}
.header-actions button:hover { background: rgba(255,255,255,0.25); }

/* Ad containers */
.ad-container {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    margin: 8px 0;
    text-align: center;
    overflow: hidden;
    position: relative;
}
.ad-label {
    position: absolute;
    top: 2px;
    right: 8px;
    font-size: 0.65rem;
    color: var(--text2);
    opacity: 0.6;
}
.ad-leaderboard { min-height: 90px; }
.ad-banner { min-height: 100px; }
.ad-sidebar { min-height: 250px; max-width: 300px; margin: 16px auto; }
.ad-footer { min-height: 90px; }

.tabs {
    display: flex; background: var(--surface2); padding: 8px 20px; gap: 10px;
    border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.tabs button {
    flex: 1; background: transparent; border: none; color: var(--text2); padding: 10px 16px;
    font-size: 0.95rem; font-weight: 600; border-radius: 30px; cursor: pointer; transition: all 0.2s;
    white-space: nowrap;
}
.tabs button.active { background: var(--primary); color: white; box-shadow: 0 6px 16px rgba(225, 112, 85, 0.3); }
.tabs .badge { background: rgba(0,0,0,0.1); padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; }
.tabs button.active .badge { background: rgba(255,255,255,0.25); }

.view { display: none; padding: 20px; overflow-y: auto; flex: 1; }
.view.active { display: block; }

.search-box { margin-bottom: 16px; position: relative; }
.search-box input {
    width: 100%; padding: 12px 20px 12px 44px; border: 2px solid var(--border); border-radius: 30px;
    font-size: 0.95rem; outline: none; background: var(--surface2); color: var(--text); transition: border 0.2s;
}
.search-box input:focus { border-color: var(--primary); }
.search-box::before { content: "🔍"; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); opacity: 0.5; }

.filter-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    margin-bottom: 16px;
}
.cuisine-dropdown {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    min-width: 180px;
}
.cuisine-dropdown:focus { border-color: var(--primary); }

.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    padding: 6px 16px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface2);
    color: var(--text2); cursor: pointer; font-size: 0.85rem; font-weight: 500; transition: all 0.2s;
}
.chip.active { background: var(--primary); color: white; border-color: var(--primary); }

.gen-btn {
    background: var(--primary); color: white; border: none; padding: 12px 24px; border-radius: 30px;
    font-weight: 600; cursor: pointer; margin-bottom: 12px; width: 100%; transition: background 0.2s; font-size: 0.95rem;
}
.gen-btn:hover { background: var(--primary-hover); }
.gen-btn:disabled { background: #ccc; cursor: not-allowed; }

/* No recipes message */
.no-results {
    text-align: center;
    padding: 2rem;
    color: var(--text2);
    font-style: italic;
}

.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.recipe-card {
    background: var(--surface); border-radius: 18px; overflow: hidden;
    box-shadow: var(--shadow); cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
    display: flex; flex-direction: column; position: relative;
}
.recipe-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.card-img-wrapper { position: relative; width: 100%; height: 140px; background: var(--surface2); overflow: hidden; }
.card-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-emoji-fallback {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: none; align-items: center; justify-content: center; font-size: 3rem;
}
.favourite-btn {
    position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.3); color: white;
    border: none; border-radius: 50%; width: 32px; height: 32px; font-size: 1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: background 0.2s; z-index: 2;
}
.favourite-btn.active { background: #e74c3c; }
.card-body { padding: 12px; text-align: center; }
.card-body strong { font-weight: 600; font-size: 0.95rem; color: var(--text); display: block; margin-bottom: 6px; }
.meta-badges { display: flex; justify-content: center; gap: 8px; font-size: 0.75rem; color: var(--text2); }
.meta-badges span { display: flex; align-items: center; gap: 2px; }

.recipe-detail .back { background: none; border: none; color: var(--primary); cursor: pointer; font-weight: 600; margin-bottom: 12px; font-size: 0.95rem; }
.detail-img-wrapper { position: relative; width: 100%; height: 220px; background: var(--surface2); border-radius: 18px; overflow: hidden; margin-bottom: 16px; }
.detail-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-emoji-fallback { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: none; align-items: center; justify-content: center; font-size: 5rem; }
.detail-meta { display: flex; gap: 16px; margin: 12px 0; color: var(--text2); flex-wrap: wrap; }
.section-title { font-weight: 600; color: var(--primary); margin: 16px 0 8px; font-size: 1.1rem; }
.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.action-btn { background: var(--primary); color: white; border: none; padding: 8px 18px; border-radius: 20px; cursor: pointer; font-weight: 600; font-size: 0.85rem; }
.cooking-mode { display: none; }
.cooking-mode.active { display: block; }
.step-card { background: var(--surface2); padding: 16px; border-radius: 16px; margin: 12px 0; display: flex; align-items: center; gap: 12px; }
.step-card .step-num { background: var(--primary); color: white; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.step-card p { flex: 1; margin: 0; }
.timer { font-size: 2.5rem; font-weight: 700; text-align: center; margin: 20px 0; }
.timer-controls { display: flex; justify-content: center; gap: 8px; }
.timer-controls button { padding: 8px 16px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); cursor: pointer; font-weight: 600; }

.chat-box { display: flex; flex-direction: column; height: 100%; }
.messages { flex: 1; overflow-y: auto; background: var(--surface2); border-radius: 16px; padding: 16px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 85%; padding: 12px 18px; border-radius: 20px; line-height: 1.45; font-size: 0.9rem; word-wrap: break-word; }
.msg.user { background: var(--primary); color: white; align-self: flex-end; border-bottom-right-radius: 6px; }
.msg.bot { background: var(--surface); color: var(--text); align-self: flex-start; border-bottom-left-radius: 6px; box-shadow: var(--shadow); }
.recipe-offer { background: var(--surface2); border: 1px solid var(--border); padding: 14px; border-radius: 16px; margin-top: 8px; font-size: 0.85rem; }
.recipe-offer strong { display: block; font-size: 1rem; margin-bottom: 6px; color: var(--text); }
.recipe-offer button { background: var(--primary); color: white; border: none; padding: 6px 14px; border-radius: 20px; cursor: pointer; font-weight: 600; margin-top: 8px; }

.chat-input-row { display: flex; gap: 10px; }
.chat-input-row input { flex: 1; padding: 14px 20px; border: 2px solid var(--border); border-radius: 30px; outline: none; background: var(--surface2); color: var(--text); font-size: 0.95rem; }
.chat-input-row button { background: var(--primary); color: white; border: none; padding: 14px 24px; border-radius: 30px; font-weight: 600; cursor: pointer; font-size: 0.95rem; transition: background 0.2s; }
.chat-input-row button:hover { background: var(--primary-hover); }

/* Email subscribe form (in recipe detail) */
.subscribe-form {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.subscribe-form input[type="email"] {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: 20px;
    outline: none;
    background: var(--surface2);
    color: var(--text);
}
.subscribe-form button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
}

@keyframes skeleton { 0% { background-position: -200px 0; } 100% { background-position: calc(200px + 100%) 0; } }
.skeleton-card { height: 250px; border-radius: 18px; background: var(--skeleton); background-size: 200px 100%; animation: skeleton 1.5s ease-in-out infinite; }

@media print {
    body * { visibility: hidden; }
    .recipe-detail, .recipe-detail * { visibility: visible; }
    .recipe-detail { position: absolute; left: 0; top: 0; width: 100%; padding: 20px; background: white; color: black; }
    .action-buttons, .back, .favourite-btn, .detail-img-wrapper, .ad-container { display: none !important; }
}

/* Mobile hamburger */
.hamburger-btn {
    display: none !important;
}
@media (max-width: 600px) {
    .hamburger-btn {
        display: inline-block !important;
        background: rgba(255,255,255,0.15);
        color: white;
        border: none;
        font-size: 1.4rem;
        padding: 8px 12px;
        border-radius: 10px;
        cursor: pointer;
    }
    .tabs {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 70px; right: 20px;
        background: var(--surface);
        box-shadow: 0 10px 20px rgba(0,0,0,0.2);
        border-radius: 12px;
        z-index: 100;
        width: 200px;
    }
    .tabs.open {
        display: flex;
    }
    .tabs button {
        padding: 12px;
        border-radius: 0;
    }
}