:root {
    --primary: #f97316;
    --primary-hover: #ea580c;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

header {
    background-color: var(--card-bg);
    padding: 24px 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 32px;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-weight: 700;
    color: var(--primary);
    font-size: 2rem;
}

h2, h3 {
    font-weight: 600;
    margin-bottom: 16px;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
    background: white;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover {
    background: var(--primary-hover);
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.list-toggle-btn {
    background: #4f46e5;
    padding: 10px 18px;
    font-size: 0.95rem;
}

.list-toggle-btn:hover {
    background: #4338ca;
}

.badge-count {
    background: white;
    color: #4f46e5;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 0.75rem;
    margin-left: 6px;
    font-weight: 700;
}

.search-sort-bar {
    display: flex;
    gap: 20px;
    margin-bottom: 32px;
    align-items: center;
}

.search-group {
    flex-grow: 1;
    position: relative;
}

.search-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.sort-group {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.sort-group select {
    padding: 10px 16px;
    width: auto;
}

.loader {
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top: 3px solid white;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

#status-msg {
    margin-top: 12px;
    font-weight: 500;
}

.success { color: #10b981; }
.error { color: #ef4444; }

.bookmarklet-btn {
    display: inline-block;
    background-color: #10b981;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    cursor: grab;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.4);
}
.bookmarklet-btn:hover { transform: scale(1.05); }

.manual-btn {
    background-color: white;
    color: var(--primary);
    border: 2px solid var(--primary);
    margin-top: 12px;
    width: 100%;
}
.manual-btn:hover {
    background-color: var(--primary);
    color: white;
}

.bookmarklet-section { margin-top: 24px; }

.filters {
    margin-bottom: 24px;
    margin-top: 32px;
}

.badge-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.badge {
    background: white;
    border: 1px solid var(--border);
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.badge:hover, .badge.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 64px;
}

.recipe-card {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    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: 0 10px 15px -3px rgba(0,0,0,0.1);
}

.card-fav-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(4px);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    padding: 0;
    font-size: 1.2rem;
    color: var(--text-muted);
}

.card-fav-btn.active {
    color: #ef4444;
}

.recipe-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #f1f5f9;
}

.recipe-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.recipe-theme {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 8px;
}

.recipe-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-main);
}

.recipe-actions {
    margin-top: auto;
    display: flex;
    justify-content: flex-end;
}

.delete-btn {
    background: none;
    color: #ef4444;
    padding: 6px 12px;
    font-size: 0.9rem;
    border: 1px solid #ef4444;
}
.delete-btn:hover {
    background: #ef4444;
    color: white;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    z-index: 50;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 20px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 32px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

.close-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--text-main);
}

.modal-header {
    display: flex;
    gap: 24px;
    margin-bottom: 32px;
}

.modal-header img {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 12px;
}

.modal-title {
    font-size: 2rem;
    margin-bottom: 8px;
}

.source-link {
    display: inline-block;
    margin-top: 12px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.source-link:hover {
    text-decoration: underline;
}

.modal-body-content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 32px;
}

.ingredients-list {
    background: #f8fafc;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.ingredients-list h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ingredients-list ul {
    list-style-type: none;
}

.ingredients-list li {
    padding: 0;
    border-bottom: 1px solid #e2e8f0;
}
.ingredients-list li:last-child {
    border-bottom: none;
}

.ingredient-item {
    display: flex;
    align-items: center;
}

.checkbox-container {
    display: flex;
    align-items: flex-start;
    position: relative;
    padding: 12px 0;
    cursor: pointer;
    font-size: 1rem;
    user-select: none;
    width: 100%;
    gap: 12px;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    height: 22px;
    width: 22px;
    background-color: white;
    border: 2px solid var(--border);
    border-radius: 6px;
    flex-shrink: 0;
    transition: all 0.2s;
    position: relative;
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--primary);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.add-to-list-btn.secondary {
    background: white;
    color: #10b981;
    border: 2px solid #10b981;
    margin-top: 0;
}

.add-to-list-btn.secondary:hover:not(:disabled) {
    background: #10b981;
    color: white;
}

.add-to-list-btn:disabled {
    background: #f1f5f9;
    color: #94a3b8;
    border-color: #e2e8f0;
    cursor: not-allowed;
}

.servings-control {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 15px;
    background: #f1f5f9;
    padding: 8px 16px;
    border-radius: 12px;
    width: fit-content;
}

.servings-control button {
    background: white;
    color: var(--text-main);
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
}

.servings-control span {
    font-weight: 700;
    min-width: 80px;
    text-align: center;
}

.instructions-list ol {
    padding-left: 20px;
}

.instructions-list li {
    margin-bottom: 16px;
    padding-left: 8px;
}

.add-to-list-btn {
    background: #10b981;
    color: white;
    width: 100%;
    margin-top: 15px;
}

.notes-area {
    width: 100%;
    height: 100px;
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    resize: none;
}

/* Drawer */
.drawer {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.4);
    display: flex;
    justify-content: flex-end;
}

.drawer-content {
    background: white;
    width: 100%;
    max-width: 400px;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 25px -5px rgba(0,0,0,0.1);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.drawer-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-drawer {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.list-items {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
}

.list-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.list-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.list-item-text {
    flex-grow: 1;
}

.list-item.checked .list-item-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

.drawer-footer {
    padding: 24px;
    border-top: 1px solid var(--border);
}

/* Edit UI */
.edit-btn {
    background-color: #3b82f6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 10px;
}

.edit-btn:hover {
    background-color: #2563eb;
}

.edit-input {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.edit-textarea {
    width: 100%;
    height: 300px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    resize: vertical;
}

@media (max-width: 768px) {
    .modal-header {
        flex-direction: column;
    }
    .modal-header img {
        width: 100%;
        height: 250px;
    }
    .modal-body-content {
        grid-template-columns: 1fr;
    }
    .search-sort-bar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Star Rating — Card (readonly, small) */
.card-stars {
    display: flex;
    gap: 2px;
    margin-top: 6px;
}

.card-stars .star {
    font-size: 0.85rem;
    color: #e2e8f0;
    line-height: 1;
}

.card-stars .star.filled {
    color: #f59e0b;
}

/* Star Rating — Modal (interactive, large) */
.star-rating-widget {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
}

.star-rating-widget .star-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 6px;
}

.star-rating-widget .star {
    font-size: 1.75rem;
    cursor: pointer;
    color: #e2e8f0;
    transition: color 0.15s, transform 0.1s;
    line-height: 1;
    user-select: none;
}

.star-rating-widget .star.filled {
    color: #f59e0b;
}

.star-rating-widget .star:hover,
.star-rating-widget .star.hover {
    color: #fbbf24;
    transform: scale(1.2);
}

.star-rating-widget .star.active {
    animation: starPop 0.2s ease;
}

@keyframes starPop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.35); }
    100% { transform: scale(1); }
}

/* Auto-badge for suggested theme/title */
.auto-badge {
    display: inline-block;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
    letter-spacing: 0.04em;
    vertical-align: middle;
    margin-left: 8px;
    text-transform: uppercase;
}

/* Preview modal layout */
.preview-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.preview-img {
    width: 160px;
    height: 160px;
    object-fit: cover;
    border-radius: 12px;
    flex-shrink: 0;
}

.preview-fields {
    flex: 1;
}

.preview-fields label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.preview-stats {
    margin-top: 14px;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    gap: 16px;
}

.preview-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

.auto-detect-btn {
    background: none;
    border: 1px dashed #6366f1;
    color: #6366f1;
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
}
.auto-detect-btn:hover { background: #eef2ff; }

@media (max-width: 600px) {
    .preview-layout { flex-direction: column; }
    .preview-img { width: 100%; height: 200px; }
}

