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

:root {
    --bg: #faf9f6;
    --card: #ffffff;
    --text: #2d2d2d;
    --muted: #6b7280;
    --accent: #e07a5f;
    --accent-hover: #c96a50;
    --border: #e5e7eb;
    --success: #059669;
    --error: #dc2626;
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

nav {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

main {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Flash messages */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.flash.success { background: #ecfdf5; color: var(--success); border: 1px solid #a7f3d0; }
.flash.error { background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }

/* Extract form */
.extract-form { margin-bottom: 3rem; }
.extract-form h1 { margin-bottom: 0.25rem; }
.extract-form p { color: var(--muted); margin-bottom: 1rem; }

.input-row {
    display: flex;
    gap: 0.5rem;
}

.input-row input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-row input:focus { border-color: var(--accent); }

.input-row button, .btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: background 0.2s;
}

.input-row button, .btn-primary {
    background: var(--accent);
    color: white;
}
.input-row button:hover, .btn-primary:hover { background: var(--accent-hover); }
.input-row button:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-danger { background: var(--error); color: white; }
.btn-danger:hover { background: #b91c1c; }

/* Loading */
.loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    color: var(--muted);
}
.hidden { display: none !important; }

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Recipe list */
.recipe-list h2 { margin-bottom: 0; }

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

.search-box input {
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    outline: none;
    width: 220px;
    transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--accent); }

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

.recipe-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.2s, transform 0.2s;
}
.recipe-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.recipe-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.recipe-card-placeholder {
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    background: #f3f4f6;
}

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

.recipe-card-body h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.recipe-card-meta {
    font-size: 0.8rem;
    color: var(--muted);
}

/* Recipe detail */
.recipe-detail { }

.recipe-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.recipe-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.source-link { color: var(--accent); text-decoration: none; }
.source-link:hover { text-decoration: underline; }

.source-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    transition: background 0.2s;
}
.source-btn:hover { background: var(--accent-hover); }

.recipe-hero {
    margin-bottom: 2rem;
    border-radius: var(--radius);
    overflow: hidden;
}

.recipe-hero img {
    width: 100%;
    max-height: 450px;
    object-fit: cover;
}

.embed-container {
    display: flex;
    justify-content: center;
}

.embed-container .instagram-media,
.embed-container .fb-post {
    margin: 0 !important;
    max-width: 540px !important;
    width: 100% !important;
}

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

@media (max-width: 640px) {
    .recipe-body { grid-template-columns: 1fr; }
}

.ingredients h2, .steps h2, .raw-content h2 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
}

.ingredients ul {
    list-style: none;
}

.ingredients li {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.ingredients li.subheading {
    font-weight: 700;
    border-bottom: none;
    padding-top: 0.8rem;
    color: var(--accent);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.steps ol {
    padding-left: 1.25rem;
}

.steps li {
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.raw-content {
    grid-column: 1 / -1;
}

.raw-text {
    font-size: 0.95rem;
    line-height: 1.8;
}

.recipe-actions {
    display: flex;
    justify-content: space-between;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.recipe-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-delete-small {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.2s, background 0.2s;
}
.btn-delete-small:hover {
    color: var(--error);
    background: #fef2f2;
}

.inline { display: inline; }

/* Quantity toggle */
.steps-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
}

.steps-header h2 {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.qty-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.qty-toggle input { cursor: pointer; }

.qty-hint {
    font-size: 0.8em;
    color: var(--accent);
    opacity: 0.75;
    font-weight: 500;
}
