﻿/* --- GLOBAL & RESET --- */
*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    /* Light Theme Defaults */
    --bg-color: #f7f9f7;     
    --primary: #408067;
    --card-bg: #ffffff;
    --text-main: #2d3436;
    --text-muted: #718096;
    --header-text: #1a202c;
    
    --tag-bg: #e4f0eb;       
    --tag-text: #1d4a38;
    
    --input-bg: #ffffff;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0,0,0,0.05);
    
    --column-bg: #fcfcfc;
    --scaler-bg: #f8f9fa;
    
    /* Generator Specifics */
    --danger-color: #e74c3c;
    --hover-bg: rgba(0,0,0,0.05);
}

[data-theme="dark"] {
    /* Dark Theme Overrides */
    --bg-color: #121212;
    --primary: #469c76; 
    --card-bg: #1e1e1e;
    --text-main: #e0e0e0;
    --text-muted: #a0a0a0;
    --header-text: #ffffff;
    
    --tag-bg: #2c3e36;
    --tag-text: #a8d5c2;
    
    --input-bg: #2d2d2d;
    --border-color: #333333;
    --shadow-color: rgba(0,0,0,0.5);
    
    --column-bg: #181818;
    --scaler-bg: #2d2d2d;
    
    --hover-bg: rgba(255,255,255,0.1);
}

body {
    font-family: 'Rubik', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    width: 100%;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container { 
    max-width: 1100px; 
    margin: 0 auto; 
}

/* --- HEADER & TOGGLE --- */
.site-header { 
    position: relative;
    text-align: center; 
    margin-bottom: 2rem; 
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.3s;
}

/* Dark Mode Toggle Button */
.theme-toggle {
    position: absolute;
    top: 10px;
    left: 0; 
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s, transform 0.2s, color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.theme-toggle:hover {
    background: rgba(128,128,128,0.1);
    transform: rotate(15deg);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
}

.site-header h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--header-text);
    cursor: pointer;
    transition: color 0.3s;
}

.search-container {
    max-width: 500px;
    margin: 0 auto 1.5rem auto;
}

.search-box {
    width: 100%;
    padding: 12px 20px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    font-family: inherit;
    transition: border-color 0.2s, background 0.3s, color 0.3s;
    box-shadow: 0 2px 5px var(--shadow-color);
}

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

.controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.sort-select {
    appearance: none;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 8px 16px 8px 40px; 
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    cursor: pointer;
    box-shadow: 0 2px 4px var(--shadow-color);
    font-weight: 500;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23408067' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 12px center;
    background-size: 16px;
    min-width: 130px; 
    border-radius: 25px;
    transition: background 0.3s, color 0.3s, border-color 0.3s;
}

.tags-scroll-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.tag-btn {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-muted);
    box-shadow: 0 2px 4px var(--shadow-color);
    white-space: nowrap; 
}

@media (hover: hover) {
    .tag-btn:hover { background: rgba(128,128,128,0.1); transform: translateY(-1px); }
}

.tag-btn.active-tag {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 8px rgba(64, 128, 103, 0.2);
}

/* --- RECIPE GRID --- */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    padding-bottom: 40px;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 15px var(--shadow-color);
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, background 0.3s, border-color 0.3s;
    display: flex;
    flex-direction: column;
    position: relative;
}

.card:hover { transform: translateY(-5px); }

.card img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    background: #f1f1f1;
}

.card-content {
    padding: 1.25rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card h2 {
    margin: 0 0 0.25rem 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--header-text);
    line-height: 1.3;
}

.card .author {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 1rem 0;
}

.card-tags-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: auto;
}

.badge { 
    background: var(--tag-bg); 
    color: var(--tag-text); 
    padding: 4px 10px; 
    border-radius: 12px; 
    font-size: 0.8rem; 
    display: inline-block;
}

/* --- RECIPE DETAIL --- */
.recipe-detail {
    background: var(--card-bg);
    border-radius: 20px;
    position: relative;
    padding: 2rem;
    transition: background 0.3s;
}

.recipe-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap; 
    gap: 15px;
    background: transparent;
    border: none;
    position: static;
    padding: 0;
    direction: ltr; 
}

.nav-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-actions .tag-btn {
    min-width: 140px;
    justify-content: center;
}
.nav-actions div .tag-btn {
    min-width: auto; 
}

.recipe-hero {
    position: relative;
    width: 100%;
    margin-bottom: 20px;
    text-align: center;
}

.recipe-hero-image {
    width: 100%;
    height: 400px;
    object-fit: cover;
    border-radius: 12px;
    margin: 0 auto;
    display: block;
}

.recipe-header-content {
    padding: 1rem 0;
    text-align: center;
}

.recipe-header-content h1 {
    font-size: 2.5rem;
    margin: 0.5rem 0;
    color: var(--header-text);
    line-height: 1.1;
}

.recipe-header-content .author {
    font-size: 1rem;
    color: var(--text-muted);
}

.recipe-body-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
    padding-bottom: 4rem;
}

.ingredients-column {
    background: var(--column-bg);
    padding: 0;
    transition: background 0.3s;
    border-radius: 12px;
}

/* --- DESKTOP / TABLET LANDSCAPE --- */
@media (min-width: 850px) {
    .recipe-body-grid {
        grid-template-columns: 320px 1fr; 
        align-items: start;
    }
    .ingredients-column {
        position: sticky;
        top: 20px; 
    }
    .english-content .recipe-body-grid { grid-template-columns: 1fr 320px; }
    .english-content .ingredients-column { order: 2; }
}

.scaler {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--scaler-bg);
    padding: 10px;
    border-radius: 12px;
    transition: background 0.3s;
}

.scale-btn {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    min-width: 45px;
    transition: 0.2s;
}

.scale-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.ingredients-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ingredients-list li {
    padding: 12px 0; 
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: baseline;
    gap: 12px;
    cursor: pointer;
    transition: opacity 0.2s, border-color 0.3s;
}
.ingredients-list li:last-child { border-bottom: none; }

.ingredients-list li::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #dcdcdc;
    border-radius: 4px;
    margin-left: 8px;
    flex-shrink: 0;
    position: relative;
    top: 3px;
    transition: all 0.2s;
}

.ingredients-list li.checked { opacity: 0.5; }
.ingredients-list li.checked .ing-content { 
    text-decoration: line-through; 
    text-decoration-thickness: 1px; 
}
.ingredients-list li.checked::before { 
    background-color: var(--primary); 
    border-color: var(--primary); 
}

.ingredients-list li span {
    font-weight: 400; 
    color: var(--text-main); 
    font-size: 1.05rem; 
}
.ingredients-list li strong {
    font-weight: 400; 
    color: inherit;
}

.ing-section-title {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    display: inline-block;
    margin-top: 1.5rem;
    font-size: 1rem;
    font-weight: 700;
}

.instructions h3 {
    margin-top: 0;
    font-size: 1.5rem;
    color: var(--header-text);
    border-bottom: none;
    margin-bottom: 1rem;
    text-decoration: underline;
    text-decoration-color: var(--primary);
}

.instructions ol {
    padding-right: 1.5rem;
    margin: 0;
}

.instructions ol li {
    padding-right: 0;
    margin-bottom: 1rem;
    font-size: 1.05rem;
    line-height: 1.8;
}
.instructions ol li::before { content: none; }

.english-content { direction: ltr; text-align: left; }
.english-content .ingredients-list li::before { margin-left: 0; margin-right: 8px; }
.english-content .sort-select { background-position: right 12px center; padding: 8px 32px 8px 20px;}

/* --- FOOTER & ADMIN --- */
.footer-section {
    margin-top: 50px;
    padding: 30px;
    background: #2d3436;
    color: white;
    border-radius: 20px;
    text-align: center;
}

.draft-details {
    border: none;
    background: transparent;
    color: white;
}
.draft-details summary {
    background: rgba(255, 255, 255, 0.1); 
    color: #fff;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem; 
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 30px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    transition: all 0.2s ease;
}
.draft-details summary:hover { 
    background: rgba(255, 255, 255, 0.2); 
    border-color: rgba(255,255,255,0.4);
}
.draft-details summary::marker { display: none; }
.draft-details summary::-webkit-details-marker { display: none; }

.footer-section h3 { display: none; }

.draft-form input, .draft-form textarea {
    background: var(--input-bg);
    border: none;
    padding: 12px; 
    width: 90%;
    margin: 10px 0;
    border-radius: 8px;
    font-size: 1rem; 
    color: var(--text-main);
}
.draft-form input::placeholder, .draft-form textarea::placeholder {
    color: #888;
    opacity: 1; 
}

.draft-checkboxes { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 10px; 
    justify-content: center; 
    margin: 10px 0; 
}
.draft-tag-label {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,0.1);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
    cursor: pointer;
    color: white; 
}
.draft-tag-label input {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.tag-btn-action {
    background: var(--primary);
    color: white;
    width: 90%;
    margin: 0 auto;
    justify-content: center;
    font-size: 1rem;
    padding: 10px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: filter 0.2s;
}
.tag-btn-action:hover { filter: brightness(1.1); }

.admin-link {
    color: #888;
    text-decoration: none;
    font-size: 0.8rem;
    margin: 20px 10px 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}
.admin-link:hover { color: white; }

.icon-svg {
    width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* Modal styles */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; }
.modal-content { 
    background: var(--card-bg); 
    padding: 30px; 
    border-radius: 16px; 
    width: 90%; 
    max-width: 700px; 
    max-height: 90vh; 
    overflow-y: auto; 
    position: relative; 
    color: var(--text-main); 
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.close-modal { 
    position: absolute; 
    top: 15px; 
    left: 15px; 
    font-size: 1.5rem; 
    cursor: pointer; 
    background: none; 
    border: none; 
    color: var(--text-muted);
    transition: color 0.2s;
    z-index: 10;
}
.close-modal:hover { color: var(--danger-color); }

.gen-input { 
    width: 100%; 
    padding: 10px 12px; 
    margin-bottom: 12px; 
    border: 1px solid var(--border-color); 
    background: var(--input-bg);
    color: var(--text-main);
    border-radius: 8px; 
    box-sizing: border-box; 
    font-family: inherit;
    transition: border-color 0.2s;
}
.gen-input:focus { outline: none; border-color: var(--primary); }

.ing-row { 
    display: grid; 
    grid-template-columns: 80px 70px 1fr auto; 
    gap: 8px; 
    margin-bottom: 8px; 
    align-items: center;
}

.gen-row-controls {
    display: flex;
    gap: 2px;
}

.gen-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.gen-icon-btn:hover { background: var(--hover-bg); color: var(--text-main); }
.gen-icon-btn.delete-btn:hover { background: #fee2e2; color: var(--danger-color); }

.add-btn-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.add-btn-group button {
    background: var(--tag-bg);
    color: var(--tag-text);
    border: 1px solid var(--border-color);
    padding: 10px;
    cursor: pointer;
    font-weight: 500;
    border-radius: 8px;
    transition: background 0.2s;
}
.add-btn-group button:hover {
    background: var(--primary);
    color: white;
}


/* Bookmark filter button */
#bookmarks-filter-btn.active-tag svg {
    fill: #dc2626;
    stroke: #dc2626;
}

/* --- BOOKMARK BUTTON --- */
.bookmark-btn {
    background: rgba(255, 255, 255, 0.7);
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    border-radius: 50%;
    color: #333;
}

.bookmark-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.9);
}

.bookmark-btn svg {
    width: 22px;
    height: 22px;
    transition: all 0.2s;
}

[data-theme="dark"] .bookmark-btn {
    background: rgba(0, 0, 0, 0.45);
    color: #e0e0e0;
}
[data-theme="dark"] .bookmark-btn:hover {
    background: rgba(0, 0, 0, 0.6);
}

/* --- HEART BUTTON (overlay on recipe hero image) --- */
.heart-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    background: rgba(255, 255, 255, 0.75);
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.heart-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.92);
}
.heart-btn svg {
    width: 26px;
    height: 26px;
    stroke: #333;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: all 0.2s;
}
.heart-btn.hearted svg {
    fill: #dc2626;
    stroke: #dc2626;
}
.heart-btn:hover svg {
    stroke: #dc2626;
}

[data-theme="dark"] .heart-btn {
    background: rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .heart-btn svg {
    stroke: #e0e0e0;
}
[data-theme="dark"] .heart-btn.hearted svg {
    fill: #dc2626;
    stroke: #dc2626;
}
[data-theme="dark"] .heart-btn:hover {
    background: rgba(0, 0, 0, 0.65);
}
[data-theme="dark"] .heart-btn:hover svg {
    stroke: #dc2626;
}

/* Larger heart on tablets+ where image is bigger */
@media (min-width: 601px) {
    .heart-btn {
        top: 16px;
        right: 16px;
        padding: 10px;
    }
    .heart-btn svg {
        width: 30px;
        height: 30px;
    }
}

/* --- NOTES EDIT BUTTON --- */
.notes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 8px;
    flex-wrap: wrap;
}
.notes-header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.notes-edit-btn {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 4px 12px;
    border-radius: 16px;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1;
}
.notes-edit-btn:hover {
    background: rgba(128,128,128,0.1);
}
.notes-edit-btn#notes-delete-btn:hover {
    background: rgba(220, 38, 38, 0.1);
}
.notes-edit-btn .icon-svg {
    width: 14px;
    height: 14px;
}

/* Compact add-notes button for empty state */
.notes-add-btn {
    background: transparent;
    border: 1px dashed var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: 0.2s;
}
.notes-add-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.notes-add-btn .icon-svg {
    width: 14px;
    height: 14px;
}

/* --- MOBILE ADJUSTMENTS (< 600px) --- */
@media (max-width: 600px) {
    .theme-toggle { top: 10px; left: 10px; }
    
    .recipe-body-grid { gap: 20px; padding-bottom: 2rem;}
    .english-content .recipe-body-grid { display: block; }

    .ingredients-column { order: -1; } 
    .site-header h1 { font-size: 1.75rem; }
    
    .recipe-nav {
        flex-direction: column; 
        align-items: stretch;
        gap: 12px;
        margin-bottom: 15px;
    }
    
    .recipe-nav > .tag-btn {
        align-self: flex-start;
    }
	    .recipe-nav > .back-btn {
        display: none;
    }
    
    .nav-actions {
        width: 100%;
        justify-content: center;
        gap: 8px;
        flex-wrap: wrap; 
    }

    .nav-actions > * {
        flex: 1 0 auto; 
        display: flex;
        justify-content: center;
        align-items: center;
        text-align: center;
    }
    
    .recipe-nav .tag-btn, 
    .nav-actions .tag-btn {
        min-width: auto; 
        padding: 8px 12px;
        font-size: 0.85rem; 
    }
    
    .nav-actions .tag-btn svg {
        width: 16px; 
        height: 16px;
    }

    .recipe-hero-image {
        height: 220px; 
    }
    
    .scaler {
        justify-content: center;
    }
    
    /* Mobile Generator Adjustments */
    .ing-row { 
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }
    .gen-item { grid-column: 1 / -1; } /* Item name takes full row */
    .gen-row-controls { grid-column: 2 / -1; justify-self: end; }

    /* Bigger touch targets for notes buttons */
    .notes-edit-btn {
        padding: 6px 14px;
        font-size: 0.9rem;
    }
    .notes-add-btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }
}

/* =============================================
   INLINE EDIT MODE
   ============================================= */

.edit-mode-badge {
    background: var(--primary);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.edit-mode-active {
    border: 2px dashed var(--primary);
    border-radius: 20px;
}

/* Field groups */
.edit-field-group {
    margin-bottom: 18px;
}

.edit-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.edit-input {
    width: 100%;
    font-family: 'Rubik', sans-serif;
    font-size: 0.95rem;
    padding: 10px 14px;
    background: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.edit-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(64,128,103,0.12);
}

.edit-input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

.edit-title-input {
    width: 100%;
    font-family: 'Rubik', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    padding: 12px 14px;
    background: transparent;
    color: var(--header-text);
    border: 1px solid transparent;
    border-bottom: 2px solid var(--border-color);
    border-radius: 0;
    transition: border-color 0.2s;
    text-align: center;
    margin-bottom: 20px;
}

.edit-title-input:focus {
    outline: none;
    border-bottom-color: var(--primary);
}

.edit-title-input::placeholder {
    color: var(--text-muted);
    opacity: 0.4;
}

.edit-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 18px;
}

@media (max-width: 500px) {
    .edit-row-2 { grid-template-columns: 1fr; }
    .edit-title-input { font-size: 1.5rem; }
}

/* Tags */
.edit-tags-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.edit-tag-chip {
    font-family: 'Rubik', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.edit-tag-chip:hover { border-color: var(--primary); color: var(--primary); }

.edit-tag-chip.selected {
    background: var(--tag-bg);
    color: var(--tag-text);
    border-color: var(--primary);
}

/* Image upload section */
.edit-image-section {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.edit-image-inputs {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.edit-image-upload-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.edit-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--tag-bg);
    color: var(--tag-text);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Rubik', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.edit-upload-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.edit-image-filename {
    font-size: 0.8rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.edit-image-or {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.edit-img-preview-box {
    flex-shrink: 0;
}

.edit-img-thumb {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.edit-image-status {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 6px;
    min-height: 1.2em;
}

@media (max-width: 500px) {
    .edit-image-section { flex-direction: column; }
    .edit-img-preview-box { align-self: center; }
}

/* Divider */
.edit-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 24px 0;
}

/* Ingredient sections */
.edit-section-block {
    background: var(--column-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    transition: background-color 0.3s, border-color 0.3s;
}

.edit-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.edit-section-name {
    flex: 1;
    font-family: 'Rubik', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 6px 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--primary);
    transition: border-color 0.2s;
}

.edit-section-name:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--input-bg);
}

.edit-section-name::placeholder { color: var(--primary); opacity: 0.5; }

.edit-ing-row {
    display: grid;
    grid-template-columns: 72px 90px 1fr auto;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}

.edit-ing-row input {
    font-family: 'Rubik', sans-serif;
    font-size: 0.88rem;
    padding: 8px 10px;
    background: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: border-color 0.2s;
}

.edit-ing-row input:focus {
    outline: none;
    border-color: var(--primary);
}

.edit-ing-row input::placeholder { color: var(--text-muted); opacity: 0.45; }

.edit-ing-controls {
    display: flex;
    gap: 2px;
}

.edit-icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: var(--text-muted);
    opacity: 0.5;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-icon-btn:hover { opacity: 1; background: var(--hover-bg); }
.edit-icon-btn.delete:hover { opacity: 1; color: var(--danger-color); background: rgba(231,76,60,0.08); }

.edit-icon-btn .icon-svg {
    width: 16px;
    height: 16px;
}

.edit-add-ing-btn {
    font-family: 'Rubik', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 5px 12px;
    border: 1px dashed var(--border-color);
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 4px;
}
.edit-add-ing-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--tag-bg);
}

.edit-add-section-btn {
    width: 100%;
    font-family: 'Rubik', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 10px;
    border: 1px dashed var(--border-color);
    background: transparent;
    color: var(--primary);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px;
}
.edit-add-section-btn:hover {
    background: var(--column-bg);
    border-color: var(--primary);
}

/* Quill RTL overrides */
.edit-mode-active .ql-toolbar.ql-snow {
    border: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
    background: var(--input-bg);
    direction: ltr;
}

.edit-mode-active .ql-container.ql-snow {
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    background: var(--input-bg);
    font-family: 'Rubik', sans-serif;
    font-size: 1.05rem;
    min-height: 200px;
}

.edit-mode-active .ql-editor {
    direction: rtl;
    text-align: right;
    line-height: 1.8;
    min-height: 200px;
    color: var(--text-main);
}

.edit-mode-active .ql-editor.ql-blank::before {
    right: 15px;
    left: auto;
    font-style: normal;
    color: var(--text-muted);
    opacity: 0.5;
}

/* Fix RTL list positioning — override Quill's LTR defaults.
   Quill uses li:not(.ql-direction-rtl) which beats generic li selectors,
   so we must target those exact selectors to flip the positioning. */
.edit-mode-active .ql-editor ol,
.edit-mode-active .ql-editor ul {
    padding-right: 1.5em !important;
    padding-left: 0 !important;
}

/* Override Quill's LTR list item padding */
.edit-mode-active .ql-editor li,
.edit-mode-active .ql-editor li:not(.ql-direction-rtl),
.edit-mode-active .ql-editor li.ql-direction-rtl {
    padding-right: 1.5em !important;
    padding-left: 0 !important;
}

/* Override Quill's LTR marker positioning */
.edit-mode-active .ql-editor li::before,
.edit-mode-active .ql-editor li:not(.ql-direction-rtl)::before,
.edit-mode-active .ql-editor li.ql-direction-rtl::before {
    margin-right: -1.5em !important;
    margin-left: 0.3em !important;
    text-align: left !important;
}

/* Nested list indentation for RTL */
.edit-mode-active .ql-editor .ql-indent-1:not(.ql-direction-rtl) {
    padding-right: 3em !important;
    padding-left: 0 !important;
}

.edit-mode-active .ql-snow .ql-stroke { stroke: var(--text-muted); }
.edit-mode-active .ql-snow .ql-fill { fill: var(--text-muted); }
.edit-mode-active .ql-snow .ql-picker { color: var(--text-muted); }
.edit-mode-active .ql-snow button:hover .ql-stroke { stroke: var(--primary); }
.edit-mode-active .ql-snow button:hover .ql-fill { fill: var(--primary); }
.edit-mode-active .ql-snow button.ql-active .ql-stroke { stroke: var(--primary); }
.edit-mode-active .ql-snow button.ql-active .ql-fill { fill: var(--primary); }

/* Floating action bar */
.edit-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    justify-content: center;
    gap: 10px;
    z-index: 100;
    box-shadow: 0 -4px 20px var(--shadow-color);
    transition: background-color 0.3s, border-color 0.3s;
}

.edit-action-btn {
    font-family: 'Rubik', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 10px 24px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.edit-action-btn .icon-svg {
    width: 16px;
    height: 16px;
}

.edit-action-btn.primary {
    background: var(--primary);
    color: white;
}
.edit-action-btn.primary:hover { filter: brightness(1.1); }

.edit-action-btn.secondary {
    background: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.edit-action-btn.secondary:hover { background: var(--hover-bg); }

/* Toast */
.edit-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    font-family: 'Rubik', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
    z-index: 200;
    direction: rtl;
}
.edit-toast.show { transform: translateX(-50%) translateY(0); }

/* Mobile ingredient rows */
@media (max-width: 600px) {
    .edit-ing-row {
        grid-template-columns: 1fr 1fr;
    }
    .edit-ing-row .edit-ing-name { grid-column: 1 / -1; }
    .edit-ing-row .edit-ing-controls { grid-column: 2 / -1; justify-self: end; }
    
    .edit-action-bar { padding: 10px 16px; gap: 8px; }
    .edit-action-btn { padding: 10px 16px; font-size: 0.85rem; }
}

@media print {
    .theme-toggle { display: none; }
    .recipe-nav, .scaler, .site-header, .footer-section { display: none; }
    .recipe-body-grid { display: block; }
    .ingredients-column { border: 1px solid #ddd; margin-bottom: 20px; page-break-inside: avoid; }
    .card { break-inside: avoid; }
}