/* ============================================
   GF Kitchen — Celiac-Safe Recipe Dashboard
   ============================================ */

:root {
    --bg: #faf8f5;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1a2e;
    --bg-sidebar-hover: #252545;
    --bg-sidebar-active: #2d2d52;
    --text: #2c2c2c;
    --text-secondary: #6b6b6b;
    --text-sidebar: #c4c4d4;
    --text-sidebar-active: #ffffff;
    --accent: #d4783c;
    --accent-hover: #c06830;
    --accent-light: #fdf0e8;
    --green: #3a9e6e;
    --green-light: #e8f5ef;
    --red: #d94f4f;
    --red-light: #fce8e8;
    --yellow: #e8a83e;
    --yellow-light: #fef6e6;
    --border: #e8e4df;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.06), 0 0 1px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3 {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    width: 280px;
    min-height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 28px 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 28px;
    line-height: 1;
}

.logo h1 {
    font-size: 1.5rem;
    color: #fff;
    letter-spacing: -0.02em;
}

.tagline {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.4);
    margin-top: 8px;
    line-height: 1.5;
}

.sidebar-nav {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--text-sidebar);
    font-size: 0.875rem;
    font-family: inherit;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    width: 100%;
}

.nav-btn:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.nav-btn.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    font-weight: 500;
}

.nav-btn .count {
    margin-left: auto;
    background: rgba(255,255,255,0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.nav-btn.active .count {
    background: var(--accent);
    color: #fff;
}

.sidebar-section {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-section h3 {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.35);
    margin-bottom: 12px;
}

.category-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.category-tag {
    padding: 4px 10px;
    background: rgba(255,255,255,0.07);
    border: none;
    border-radius: 20px;
    color: var(--text-sidebar);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.category-tag:hover,
.category-tag.active {
    background: var(--accent);
    color: #fff;
}

.source-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.source-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-sidebar);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    width: 100%;
}

.source-item:hover,
.source-item.active {
    background: rgba(255,255,255,0.07);
    color: #fff;
}

.source-item .source-count {
    font-size: 0.7rem;
    opacity: 0.5;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 24px 24px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    gap: 8px;
}

.btn-export, .btn-import {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    background: rgba(255,255,255,0.07);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-sidebar);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-export:hover, .btn-import:hover {
    background: rgba(255,255,255,0.14);
    color: #fff;
}

/* ============================================
   Main Content
   ============================================ */

.main {
    flex: 1;
    margin-left: 280px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    background: rgba(250, 248, 245, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 50;
    border-bottom: 1px solid var(--border);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
}

.search-bar {
    flex: 1;
    max-width: 480px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 40px;
    padding: 10px 18px;
    transition: all var(--transition);
}

.search-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.search-bar svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 0.9rem;
    background: transparent;
    color: var(--text);
}

.search-bar input::placeholder {
    color: #b5b0a8;
}

.btn-add-recipe {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 40px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-add-recipe:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 120, 60, 0.35);
}

.content {
    padding: 28px 32px 48px;
    flex: 1;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.content-header h2 {
    font-size: 1.75rem;
    color: var(--text);
}

.view-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.view-toggle {
    display: flex;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 34px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.view-btn:first-child {
    border-right: 1px solid var(--border);
}

.view-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.view-btn.active {
    background: var(--accent);
    color: #fff;
}

.view-controls select {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    font-family: inherit;
    font-size: 0.825rem;
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
    transition: all var(--transition);
}

.view-controls select:focus {
    border-color: var(--accent);
}

/* ============================================
   List View
   ============================================ */

.recipe-list {
    display: none;
    flex-direction: column;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.recipe-list.active {
    display: flex;
}

.recipe-grid.hidden {
    display: none;
}

.list-header {
    display: grid;
    grid-template-columns: minmax(200px, 2fr) 100px 120px 90px 70px 100px 90px;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    align-items: center;
}

.list-row {
    display: grid;
    grid-template-columns: minmax(200px, 2fr) 100px 120px 90px 70px 100px 90px;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
    align-items: center;
    font-size: 0.85rem;
}

.list-row:last-child {
    border-bottom: none;
}

.list-row:hover {
    background: var(--accent-light);
}

.list-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--text);
    min-width: 0;
}

.list-name span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-name .list-fav {
    color: var(--red);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.list-status {
    font-size: 0.7rem;
}

.list-source {
    color: var(--text-secondary);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-rating {
    color: var(--yellow);
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.list-category {
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-date {
    color: #bbb;
    font-size: 0.75rem;
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
    text-align: center;
    padding: 80px 20px;
    display: none;
}

.empty-state.visible {
    display: block;
}

.empty-illustration {
    font-size: 64px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 28px;
}

/* ============================================
   Recipe Grid
   ============================================ */

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

.recipe-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
}

.recipe-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: transparent;
}

.card-accent {
    height: 4px;
    width: 100%;
}

.card-accent.tested { background: linear-gradient(90deg, var(--green), #5bc88a); }
.card-accent.to-try { background: linear-gradient(90deg, var(--yellow), #f0c060); }
.card-accent.avoid { background: linear-gradient(90deg, var(--red), #e87070); }

.card-body {
    padding: 20px;
}

.card-top-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.card-title {
    font-family: 'DM Serif Display', serif;
    font-size: 1.15rem;
    font-weight: 400;
    color: var(--text);
    line-height: 1.3;
}

.card-fav {
    color: var(--red);
    font-size: 1rem;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity var(--transition);
}

.recipe-card.is-favourite .card-fav {
    opacity: 1;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge.tested { background: var(--green-light); color: var(--green); }
.badge.to-try { background: var(--yellow-light); color: #b8860b; }
.badge.avoid { background: var(--red-light); color: var(--red); }

.card-source {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.card-stars {
    color: var(--yellow);
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.card-notes {
    font-size: 0.835rem;
    color: var(--text-secondary);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.card-tag {
    padding: 2px 8px;
    background: var(--bg);
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

.card-category {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
}

.card-date {
    font-size: 0.7rem;
    color: #bbb;
}

/* ============================================
   Modal
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    padding: 20px;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.25s ease;
}

.modal-overlay.open .modal {
    transform: translateY(0) scale(1);
}

.modal-detail {
    max-width: 640px;
}

.modal-confirm {
    max-width: 420px;
    padding-bottom: 24px;
}

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

.modal-header h2 {
    font-size: 1.35rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

.confirm-text {
    padding: 16px 28px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ============================================
   Form
   ============================================ */

#recipe-form {
    padding: 20px 28px 28px;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-row.two-col > .form-group {
    flex: 1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 4px;
}

.form-group.flex-1 { flex: 1; }

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

.hint {
    font-weight: 400;
    color: var(--text-secondary);
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: all var(--transition);
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #c0bab2;
}

/* Star Rating */
.star-rating {
    display: flex;
    gap: 2px;
}

.star {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #ddd;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s;
}

.star.active {
    color: var(--yellow);
}

.star:hover {
    color: var(--yellow);
}

/* Checkbox */
.checkbox-group {
    margin-top: 4px;
    margin-bottom: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text);
    user-select: none;
}

.checkbox-label input {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.checkbox-label input:checked + .checkmark {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-label input:checked + .checkmark::after {
    content: '\\2713';
    color: #fff;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
}

.btn-cancel {
    padding: 10px 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-cancel:hover {
    background: #eee;
}

.btn-save {
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-save:hover {
    background: var(--accent-hover);
}

.btn-delete {
    padding: 10px 24px;
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-delete:hover {
    background: #c04040;
}

/* ============================================
   Fetch Button & Image Preview
   ============================================ */

.url-input-row {
    display: flex;
    gap: 8px;
}

.url-input-row input {
    flex: 1;
    min-width: 0;
}

.btn-fetch {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #2d2d52;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.825rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-fetch:hover {
    background: #3a3a65;
}

.btn-fetch:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-fetch .fetch-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-fetch .fetch-spinner[hidden] {
    display: none;
}

.btn-fetch.loading .fetch-icon {
    display: none;
}

.btn-fetch.loading .fetch-spinner {
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.fetch-status {
    font-size: 0.78rem;
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    line-height: 1.4;
}

.fetch-status[hidden] {
    display: none;
}

.fetch-status.success {
    background: var(--green-light);
    color: var(--green);
}

.fetch-status.error {
    background: var(--red-light);
    color: var(--red);
}

.image-preview-row {
    position: relative;
    margin-bottom: 16px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    max-height: 180px;
}

.image-preview-row[hidden] {
    display: none;
}

.image-preview-row img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
    border-radius: var(--radius-sm);
}

.btn-remove-image {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}

.btn-remove-image:hover {
    background: rgba(0,0,0,0.7);
}

.form-row.three-col {
    display: flex;
    gap: 12px;
}

.form-row.three-col > .form-group {
    flex: 1;
}

/* Card image */
.card-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

/* ============================================
   Detail Modal
   ============================================ */

.detail-content {
    padding: 24px 28px 28px;
}

.detail-status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.detail-stars {
    color: var(--yellow);
    font-size: 1.1rem;
    letter-spacing: 2px;
}

.detail-fav {
    color: var(--red);
    font-size: 0.9rem;
}

.detail-section {
    margin-bottom: 20px;
}

.detail-section h4 {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.detail-section p,
.detail-section a {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text);
}

.detail-section a {
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}

.detail-section a:hover {
    text-decoration: underline;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.detail-tag {
    padding: 4px 12px;
    background: var(--bg);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.detail-actions button {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-detail-edit {
    background: var(--accent);
    color: #fff;
    border: none;
}

.btn-detail-edit:hover {
    background: var(--accent-hover);
}

.btn-detail-link {
    background: #fff;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn-detail-link:hover {
    background: var(--accent-light);
}

.btn-detail-delete {
    background: #fff;
    color: var(--red);
    border: 1px solid var(--red);
}

.btn-detail-delete:hover {
    background: var(--red-light);
}

/* ============================================
   Price Per Serve Badge
   ============================================ */

.card-price {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    background: #f0faf4;
    color: #2d8659;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.card-price.no-data {
    background: var(--bg);
    color: #bbb;
}

.list-price {
    font-size: 0.8rem;
    font-weight: 600;
    color: #2d8659;
}

.list-price.no-data {
    color: #ccc;
}

/* ============================================
   Nav Divider
   ============================================ */

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 8px 14px;
}

/* ============================================
   My Week Planner
   ============================================ */

.week-planner {
    display: none;
}

.week-planner.active {
    display: block;
}

.week-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.week-selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-week-nav {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.btn-week-nav:hover {
    background: var(--bg);
    color: var(--text);
}

.week-label {
    font-family: 'DM Serif Display', serif;
    font-size: 1.1rem;
    color: var(--text);
    min-width: 160px;
    text-align: center;
}

.week-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.week-cost {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2d8659;
    padding: 6px 14px;
    background: #f0faf4;
    border-radius: 20px;
}

.week-cost:empty {
    display: none;
}

.btn-shopping-list,
.btn-add-to-week {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.825rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-shopping-list {
    background: #fff;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn-shopping-list:hover {
    background: var(--accent-light);
}

.btn-add-to-week {
    background: var(--accent);
    color: #fff;
    border: none;
}

.btn-add-to-week:hover {
    background: var(--accent-hover);
}

/* ============================================
   Calendar Grid
   ============================================ */

.cal-grid {
    display: grid;
    grid-template-columns: 70px repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.cal-corner {
    background: var(--bg);
    padding: 12px 8px;
}

.cal-day-header {
    background: var(--bg);
    padding: 12px 8px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.cal-row-label {
    background: var(--bg);
    padding: 12px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

.cal-slot {
    background: var(--bg-card);
    min-height: 90px;
    padding: 6px;
    position: relative;
    transition: background 0.15s ease;
    cursor: pointer;
}

.cal-slot:hover {
    background: #fdf8f4;
}

.cal-slot.drag-over {
    background: var(--accent-light);
    box-shadow: inset 0 0 0 2px var(--accent);
}

/* Empty slot — show + on hover */
.cal-slot.empty::after {
    content: '+';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #ddd;
    opacity: 0;
    transition: opacity 0.15s;
}

.cal-slot.empty:hover::after {
    opacity: 1;
}

/* Filled slot — meal card */
.cal-meal {
    height: 100%;
    border-radius: 6px;
    padding: 8px;
    cursor: grab;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.cal-meal:active {
    cursor: grabbing;
}

.cal-meal.cook {
    background: linear-gradient(135deg, #e8f5ef 0%, #d4eddf 100%);
    border-left: 3px solid var(--green);
}

.cal-meal.leftover {
    background: linear-gradient(135deg, #fef6e6 0%, #fdefd4 100%);
    border-left: 3px solid var(--yellow);
}

.cal-meal-indicator {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.cal-meal.cook .cal-meal-indicator {
    color: var(--green);
}

.cal-meal.leftover .cal-meal-indicator {
    color: #b8860b;
}

.cal-meal-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cal-meal-price {
    font-size: 0.62rem;
    color: #2d8659;
    font-weight: 600;
    margin-top: auto;
}

.cal-meal-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: rgba(255,255,255,0.7);
    border: none;
    color: #bbb;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--transition);
}

.cal-meal:hover .cal-meal-remove {
    opacity: 1;
}

.cal-meal-remove:hover {
    background: var(--red-light);
    color: var(--red);
}

/* Dragging state */
.cal-meal.dragging {
    opacity: 0.4;
}

/* ============================================
   Week Picker Modal
   ============================================ */

.modal-week-picker {
    max-width: 520px;
}

.week-picker-body {
    padding: 0 28px;
}

.week-picker-search {
    margin: 16px 0 12px;
}

.week-picker-search input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    transition: all var(--transition);
}

.week-picker-search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.week-picker-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.week-picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.week-picker-item:hover {
    background: var(--bg);
}

.week-picker-item.selected {
    background: var(--accent-light);
}

.week-picker-check {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
    font-size: 0.7rem;
    color: transparent;
}

.week-picker-item.selected .week-picker-check {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.week-picker-item-info {
    flex: 1;
    min-width: 0;
}

.week-picker-item-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.week-picker-item-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ============================================
   Shopping List Modal
   ============================================ */

.modal-shopping {
    max-width: 540px;
}

.shopping-body {
    padding: 20px 28px;
    max-height: 60vh;
    overflow-y: auto;
}

.shopping-section {
    margin-bottom: 20px;
}

.shopping-section h4 {
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.shopping-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 0.875rem;
    color: var(--text);
}

.shopping-item input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.shopping-item.checked {
    text-decoration: line-through;
    color: #bbb;
}

.shopping-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    margin-top: 8px;
    border-top: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.95rem;
}

.shopping-total-amount {
    color: #2d8659;
    font-size: 1.1rem;
}

/* ============================================
   Responsive
   ============================================ */

/* Sidebar overlay for mobile — closes sidebar on tap */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

.sidebar-backdrop.visible {
    display: block;
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    }

    .main {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .topbar {
        padding: 12px 12px;
        gap: 8px;
    }

    /* Hide "Add Recipe" text, keep icon */
    .btn-add-recipe {
        padding: 10px 14px;
        font-size: 0;
        gap: 0;
    }

    .btn-add-recipe svg {
        width: 22px;
        height: 22px;
    }

    .search-bar {
        padding: 8px 14px;
        gap: 8px;
    }

    .search-bar input {
        font-size: 0.85rem;
    }

    .content {
        padding: 16px 12px 48px;
    }

    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 16px;
    }

    .content-header h2 {
        font-size: 1.4rem;
    }

    /* Grid: single column, tighter cards */
    .recipe-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .card-body {
        padding: 14px 16px;
    }

    .card-title {
        font-size: 1.05rem;
    }

    .card-footer {
        padding: 10px 16px;
    }

    .card-notes {
        -webkit-line-clamp: 2;
        font-size: 0.8rem;
    }

    /* List: compact 3-col on mobile */
    .list-header,
    .list-row {
        grid-template-columns: 1fr 70px 70px;
        gap: 6px;
        padding: 10px 12px;
    }

    .list-header {
        padding: 8px 12px;
    }

    .list-row {
        font-size: 0.8rem;
    }

    /* Hide source, price, category, date in list */
    .list-header > :nth-child(3),
    .list-header > :nth-child(5),
    .list-header > :nth-child(6),
    .list-header > :nth-child(7),
    .list-row > :nth-child(3),
    .list-row > :nth-child(5),
    .list-row > :nth-child(6),
    .list-row > :nth-child(7) {
        display: none;
    }

    .list-name {
        font-size: 0.82rem;
    }

    /* Week view */
    .week-header-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .week-selector {
        justify-content: center;
    }

    .week-label {
        font-size: 0.95rem;
        min-width: unset;
    }

    .week-actions {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .week-cost {
        font-size: 0.78rem;
        padding: 5px 12px;
    }

    .btn-shopping-list {
        padding: 8px 14px;
        font-size: 0.78rem;
    }

    /* Calendar: scroll horizontally on mobile */
    .cal-grid {
        overflow-x: auto;
        min-width: 600px;
    }

    .cal-slot {
        min-height: 70px;
    }

    .cal-meal-name {
        font-size: 0.65rem;
    }

    .cal-meal-remove {
        opacity: 0.7;
    }

    #week-planner {
        overflow-x: auto;
    }

    /* Form */
    .form-row.two-col,
    .form-row.three-col {
        flex-direction: column;
        gap: 8px;
    }

    /* Modals */
    .modal {
        max-height: 95vh;
        border-radius: 12px;
    }

    .modal-overlay {
        padding: 10px;
    }

    .modal-header {
        padding: 18px 18px 14px;
    }

    .modal-header h2 {
        font-size: 1.15rem;
    }

    #recipe-form {
        padding: 14px 18px 22px;
    }

    /* Detail modal */
    .detail-content {
        padding: 18px 18px 22px;
    }

    .detail-actions {
        flex-direction: column;
        gap: 8px;
    }

    .detail-actions button {
        flex: unset;
        width: 100%;
    }

    /* Shopping list */
    .shopping-body {
        padding: 16px 18px;
    }

    .shopping-item {
        font-size: 0.82rem;
    }

    /* Week picker */
    .week-picker-body {
        padding: 0 18px;
    }

    .week-picker-list {
        max-height: 50vh;
    }

    .week-picker-item {
        padding: 10px 8px;
        gap: 10px;
    }

    .week-picker-item-name {
        font-size: 0.85rem;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .topbar {
        padding: 10px 8px;
    }

    .content {
        padding: 12px 8px 48px;
    }

    .week-label {
        font-size: 0.85rem;
    }

    .btn-week-nav {
        width: 30px;
        height: 30px;
    }
}

/* ============================================
   Scrollbar
   ============================================ */

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

.modal::-webkit-scrollbar {
    width: 6px;
}

.modal::-webkit-scrollbar-track {
    background: transparent;
}

.modal::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 6px;
}

/* ============================================
   Animations
   ============================================ */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.recipe-card {
    animation: fadeInUp 0.35s ease both;
}

.recipe-grid .recipe-card:nth-child(1) { animation-delay: 0.03s; }
.recipe-grid .recipe-card:nth-child(2) { animation-delay: 0.06s; }
.recipe-grid .recipe-card:nth-child(3) { animation-delay: 0.09s; }
.recipe-grid .recipe-card:nth-child(4) { animation-delay: 0.12s; }
.recipe-grid .recipe-card:nth-child(5) { animation-delay: 0.15s; }
.recipe-grid .recipe-card:nth-child(6) { animation-delay: 0.18s; }
.recipe-grid .recipe-card:nth-child(7) { animation-delay: 0.21s; }
.recipe-grid .recipe-card:nth-child(8) { animation-delay: 0.24s; }
.recipe-grid .recipe-card:nth-child(9) { animation-delay: 0.27s; }
