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

:root {
    --color-bg: #faf9f7;
    --color-surface: #ffffff;
    --color-border: #e5e2db;
    --color-text: #2c2c2c;
    --color-text-muted: #6b6b6b;
    --color-primary: #c0392b;
    --color-primary-dark: #96281b;
    --color-success: #27ae60;
    --color-warning: #e67e22;
    --color-info: #2980b9;
    --font-body: system-ui, -apple-system, sans-serif;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    max-width: 900px;
    margin: 0 auto;
}

.site-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
}

/* Hamburger */
.hamburger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--color-text);
    transition: all 0.2s;
}

.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* Nav menu */
.nav-menu {
    display: none;
    border-top: 1px solid var(--color-border);
}

.nav-menu.open {
    display: block;
}

.nav-menu ul {
    list-style: none;
    padding: 0.5rem 0;
}

.nav-menu ul li a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: 1rem;
}

.nav-menu ul li a:hover {
    background: var(--color-bg);
    color: var(--color-primary);
}

/* Main content */
.main-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* Flash messages */
.flash-messages { margin-bottom: 1rem; }

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.flash-success { background: #d5f5e3; color: #1e8449; border: 1px solid #a9dfbf; }
.flash-error   { background: #fadbd8; color: #922b21; border: 1px solid #f1948a; }
.flash-info    { background: #d6eaf8; color: #1a5276; border: 1px solid #85c1e9; }
.flash-warning { background: #fef9e7; color: #7d6608; border: 1px solid #f9e79f; }

/* Page header */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.6rem; margin-bottom: 0.25rem; }

/* Auth page */
.auth-page { max-width: 400px; }
.auth-note { margin-top: 1rem; color: var(--color-text-muted); font-size: 0.9rem; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.35rem; font-size: 0.95rem; }
.form-control {
    display: block;
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(192,57,43,0.15); }
.field-error { display: block; color: var(--color-primary); font-size: 0.85rem; margin-top: 0.25rem; }
.field-hint  { display: block; color: var(--color-text-muted); font-size: 0.82rem; margin-top: 0.25rem; }
.form-actions { margin-top: 1.5rem; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-border); color: var(--color-text); }
.btn-secondary:hover { background: #d5d0c8; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-danger:hover { background: #96281b; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.875rem; }

/* Icon buttons (move up/down, remove in builders) */
.btn-icon {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.25rem 0.4rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    line-height: 1;
}
.btn-icon:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-icon--danger:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* Back link */
.back-link { color: var(--color-text-muted); text-decoration: none; font-size: 0.9rem; display: inline-block; margin-bottom: 0.5rem; }
.back-link:hover { color: var(--color-primary); }

/* Category grid (browse page) */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.category-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.category-card__name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--color-primary);
}

.category-card__children {
    list-style: none;
    margin-bottom: 0.75rem;
}

.category-card__children li { padding: 0.15rem 0; }

.category-card__children a {
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.95rem;
}

.category-card__children a:hover { color: var(--color-primary); text-decoration: underline; }

.category-card__all {
    display: inline-block;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-decoration: none;
    border-top: 1px solid var(--color-border);
    padding-top: 0.5rem;
    width: 100%;
}

.category-card__all:hover { color: var(--color-primary); }

/* List toolbar */
.list-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.list-count { color: var(--color-text-muted); font-size: 0.9rem; }

.sort-links { display: flex; gap: 0.5rem; }

.sort-link {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    border: 1px solid var(--color-border);
}

.sort-link:hover { color: var(--color-primary); border-color: var(--color-primary); }
.sort-link--active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

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

/* Recipe card */
.recipe-card {
    display: block;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--color-text);
    box-shadow: var(--shadow);
    transition: box-shadow 0.15s, transform 0.15s;
}

.recipe-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); transform: translateY(-1px); }

.recipe-card__photo { aspect-ratio: 4/3; background: #f0ede8; overflow: hidden; }

.recipe-card__photo img { width: 100%; height: 100%; object-fit: cover; }

.recipe-card__no-photo {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    opacity: 0.3;
}

.recipe-card__body { padding: 0.85rem; }

.recipe-card__title { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.2rem; }

.recipe-card__attribution { font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 0.4rem; }

.recipe-card__meta { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

.recipe-card__rating { color: var(--color-warning); font-size: 0.85rem; }
.recipe-card__rating-value { color: var(--color-text-muted); margin-left: 0.15rem; }

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

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--color-text-muted); }
.empty-state p { margin-bottom: 1rem; }

/* Entry method chooser */
.entry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }

.entry-card {
    display: block;
    padding: 1.5rem 1.25rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--color-text);
    box-shadow: var(--shadow);
    position: relative;
    transition: box-shadow 0.15s, transform 0.15s;
}
.entry-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-1px); }
.entry-card--soon { opacity: 0.6; cursor: default; pointer-events: none; }
.entry-card__icon { font-size: 2rem; margin-bottom: 0.5rem; }
.entry-card__title { font-size: 1rem; font-weight: 700; margin-bottom: 0.35rem; }
.entry-card__desc { font-size: 0.85rem; color: var(--color-text-muted); }
.entry-card__badge {
    position: absolute; top: 0.75rem; right: 0.75rem;
    font-size: 0.7rem; background: var(--color-border); border-radius: 20px;
    padding: 0.15rem 0.5rem; color: var(--color-text-muted);
}

/* Page header subtitle */
.page-header__sub { color: var(--color-text-muted); margin-top: 0.25rem; font-size: 0.9rem; }

/* Form layout helpers */
.form-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }
.form-label { display: block; font-weight: 600; margin-bottom: 0.35rem; font-size: 0.95rem; }
.form-label__req { color: var(--color-primary); margin-left: 2px; }
.form-label__opt { color: var(--color-text-muted); font-weight: 400; font-size: 0.85rem; }

/* Ingredient / Step builders */
.builder-section { margin-bottom: 2rem; }
.builder-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.builder-title { font-size: 1.1rem; font-weight: 700; }
.builder-hint { font-size: 0.82rem; color: var(--color-text-muted); margin-bottom: 0.75rem; }
.builder-empty { color: var(--color-text-muted); font-size: 0.9rem; padding: 0.75rem 0; }

.builder-list { display: flex; flex-direction: column; gap: 0.5rem; }

.builder-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: start;
    padding: 0.6rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.ing-fields { display: grid; grid-template-columns: 90px 90px 1fr; gap: 0.4rem; }
@media (max-width: 500px) { .ing-fields { grid-template-columns: 1fr 1fr; } .ing-fields .ing-name { grid-column: 1 / -1; } }

.builder-row--step { grid-template-columns: 28px 1fr auto; align-items: start; }
.step-number { font-weight: 700; color: var(--color-text-muted); padding-top: 0.5rem; text-align: center; font-size: 0.9rem; }

.builder-row-actions { display: flex; gap: 0.25rem; align-items: center; flex-shrink: 0; }

/* Unit warning */
.unit-warning { grid-column: 1; font-size: 0.82rem; padding: 0.3rem 0; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.unit-warn-text { color: var(--color-warning); }
.btn-convert { font-size: 0.8rem; padding: 0.2rem 0.6rem; background: var(--color-warning); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; }
.btn-convert:hover { opacity: 0.9; }

/* Tags section */
.tags-container { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; min-height: 2rem; padding: 0.35rem 0; }
.tags-empty { color: var(--color-text-muted); font-size: 0.9rem; }

.tag-pill {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.25rem 0.6rem; border-radius: 20px; font-size: 0.85rem;
    background: var(--color-border); color: var(--color-text);
}
.tag-pill--dietary { background: #d5f5e3; color: #1e8449; }
.tag-pill--occasion { background: #d6eaf8; color: #1a5276; }
.tag-pill--main_ingredient { background: #fef9e7; color: #7d6608; }
.tag-pill__type { font-size: 0.7rem; opacity: 0.7; }
.tag-pill__remove { background: none; border: none; cursor: pointer; font-size: 0.9rem; padding: 0; line-height: 1; color: inherit; opacity: 0.6; }
.tag-pill__remove:hover { opacity: 1; }

.tag-add-row { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.tag-name-input { flex: 1; min-width: 140px; }
.tag-type-select { width: auto; min-width: 140px; }

/* File input */
.form-control-file {
    display: block; width: 100%; margin-top: 0.5rem;
    font-size: 0.9rem; color: var(--color-text);
    padding: 0.4rem 0;
}

/* Current photo preview */
.current-photo { display: flex; align-items: center; gap: 1rem; margin: 0.5rem 0; }
.current-photo__img { width: 80px; height: 60px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--color-border); }
.current-photo__label { font-size: 0.85rem; color: var(--color-text-muted); }

/* Recipe attribution on detail page */
.recipe-attribution { color: var(--color-text-muted); font-style: italic; margin-top: 0.25rem; }

/* ===== Recipe Detail Page ===== */

.recipe-detail { max-width: 680px; }

/* Hero photo */
.recipe-hero { margin: -1.5rem -1rem 0; position: relative; }
.recipe-hero__img { width: 100%; max-height: 420px; object-fit: cover; display: block; }
.recipe-hero__toggle {
    position: absolute; bottom: 0.6rem; right: 0.6rem;
    background: rgba(0,0,0,0.55); color: #fff; border: none; border-radius: var(--radius);
    padding: 0.35rem 0.7rem; font-size: 0.8rem; cursor: pointer;
}
.recipe-hero__toggle:hover { background: rgba(0,0,0,0.75); }

/* Recipe header */
.recipe-header { padding: 1.25rem 0 0; }
.recipe-header__title { font-size: 1.75rem; line-height: 1.2; margin-bottom: 0.2rem; }
.recipe-header__attribution { color: var(--color-text-muted); font-style: italic; margin-bottom: 0.75rem; }

.recipe-meta { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0.5rem 0; font-size: 0.875rem; color: var(--color-text-muted); }
.recipe-meta__link { color: var(--color-primary); text-decoration: none; }
.recipe-meta__link:hover { text-decoration: underline; }
.recipe-meta__rating { color: var(--color-warning); }

.recipe-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0 1rem; }

/* Status badge */
.status-badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; margin-bottom: 0.5rem; }
.status-badge--draft { background: #fef9e7; color: #7d6608; border: 1px solid #f9e79f; }

/* Serving adjuster */
.serving-adjuster {
    display: flex; align-items: center; gap: 0.6rem;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 0.5rem 0.85rem;
    margin: 1.25rem 0; width: fit-content;
}
.serving-adjuster__label { font-size: 0.875rem; color: var(--color-text-muted); }
.serving-adjuster__count { font-size: 1.1rem; font-weight: 700; min-width: 1.5rem; text-align: center; }
.serving-btn {
    background: none; border: 1px solid var(--color-border); border-radius: 50%;
    width: 28px; height: 28px; cursor: pointer; font-size: 1.1rem; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.serving-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.serving-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Recipe sections */
.recipe-section { margin: 1.75rem 0; }
.recipe-section__title { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.75rem; padding-bottom: 0.4rem; border-bottom: 2px solid var(--color-border); }
.recipe-section--minor { margin: 1rem 0; font-size: 0.875rem; color: var(--color-text-muted); }
.recipe-source-label { font-weight: 600; margin-right: 0.3rem; }
.recipe-source-link { color: var(--color-primary); word-break: break-all; }

/* Ingredients */
.ingredient-list { list-style: none; }
.ingredient-list__item { padding: 0.4rem 0; border-bottom: 1px solid var(--color-border); display: flex; gap: 0.4rem; align-items: baseline; }
.ingredient-list__item:last-child { border-bottom: none; }
.ing-amount { font-weight: 600; min-width: 2.5rem; }
.ing-unit { color: var(--color-text-muted); min-width: 3rem; }
.ing-name { }

/* Method */
.method-list { padding-left: 0; counter-reset: step; list-style: none; }
.method-list__step {
    counter-increment: step;
    padding: 0.75rem 0 0.75rem 3rem;
    border-bottom: 1px solid var(--color-border);
    position: relative;
    line-height: 1.6;
}
.method-list__step:last-child { border-bottom: none; }
.method-list__step::before {
    content: counter(step);
    position: absolute; left: 0; top: 0.75rem;
    width: 2rem; height: 2rem;
    background: var(--color-primary); color: #fff;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; font-weight: 700;
}

/* Per-step ingredient list */
.step-ingredients {
    list-style: none;
    margin: 0.5rem 0 0 0;
    padding: 0.4rem 0.75rem;
    border-left: 3px solid var(--color-primary);
    background: var(--color-bg-subtle, #f8f8f6);
    border-radius: 0 4px 4px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
}
.step-ingredients__item { font-size: 0.875rem; color: var(--color-text-muted); display: flex; gap: 0.25rem; }
.step-ing-amount { font-weight: 600; color: var(--color-text); }
.step-ing-unit { color: var(--color-text-muted); }

/* Notes */
.recipe-notes { line-height: 1.7; white-space: pre-line; color: var(--color-text-muted); }

/* Action buttons */
.recipe-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.5rem 0; }
.delete-form { display: inline; }

/* Collapsible sections */
.recipe-section--collapsible { border-top: 1px solid var(--color-border); padding-top: 0; margin-top: 0; }
.collapsible-toggle {
    width: 100%; text-align: left; background: none; border: none; cursor: pointer;
    padding: 1rem 0; font-size: 1rem; font-weight: 600; color: var(--color-text);
    display: flex; align-items: center; justify-content: space-between;
}
.collapsible-toggle:hover { color: var(--color-primary); }
.collapsible-toggle__arrow { font-size: 0.85rem; color: var(--color-text-muted); }
.collapsible-body { padding-bottom: 1rem; }
.collapsible-empty { color: var(--color-text-muted); font-size: 0.9rem; margin-bottom: 0.75rem; }

/* Variants */
.variants-list { display: flex; flex-direction: column; gap: 0.5rem; }
.variant-card { padding: 0.75rem; background: var(--color-bg); border-radius: var(--radius); }
.variant-card__title { font-size: 0.95rem; font-weight: 600; }
.variant-card__title a { color: var(--color-primary); text-decoration: none; }
.variant-card__attr { font-size: 0.82rem; color: var(--color-text-muted); margin-top: 0.15rem; }

/* Social row (ratings / made this placeholders) */
.social-row { display: flex; gap: 1rem; margin: 1.5rem 0; flex-wrap: wrap; }
.social-card { flex: 1; min-width: 140px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1rem; text-align: center; }
.social-card__label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin-bottom: 0.5rem; }
.social-card__stars { font-size: 1.3rem; color: var(--color-border); }
.social-card__stars .star--filled { color: var(--color-warning); }
.social-card__count { font-size: 1.5rem; font-weight: 700; }
.social-card__sub { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.25rem; }

/* ===== Home / What's New Feed ===== */

.home-actions { display: flex; gap: 0.75rem; margin-bottom: 1.75rem; flex-wrap: wrap; }

.feed-heading { font-size: 1.3rem; font-weight: 700; margin-bottom: 1.25rem; }

.welcome-state { text-align: center; padding: 3rem 1rem; }
.welcome-state__message { color: var(--color-text-muted); margin-bottom: 1rem; font-size: 1.05rem; }

.feed-section { margin-bottom: 2rem; }
.feed-section__title { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); margin-bottom: 0.85rem; }

.comment-feed { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.comment-feed__item { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.9rem; }
.comment-feed__author { font-weight: 600; }
.comment-feed__recipe { color: var(--color-primary); text-decoration: none; font-weight: 600; }
.comment-feed__recipe:hover { text-decoration: underline; }
.comment-feed__time { color: var(--color-text-muted); font-size: 0.8rem; margin-left: 0.4rem; }
.comment-feed__preview { color: var(--color-text-muted); margin-top: 0.3rem; font-style: italic; }

.variant-feed { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.variant-feed__item { font-size: 0.9rem; padding: 0.4rem 0; border-bottom: 1px solid var(--color-border); display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: baseline; }
.variant-feed__item:last-child { border-bottom: none; }
.variant-feed__link { font-weight: 600; color: var(--color-primary); text-decoration: none; }
.variant-feed__link:hover { text-decoration: underline; }
.variant-feed__attr { color: var(--color-text-muted); font-size: 0.85rem; }
.variant-feed__parent { color: var(--color-text-muted); font-size: 0.85rem; }
.variant-feed__parent a { color: var(--color-text-muted); text-decoration: underline; }

/* ===== Header controls (search icon + hamburger) ===== */
.header-controls { display: flex; align-items: center; gap: 0.5rem; }
.header-search-btn { font-size: 1.1rem; text-decoration: none; padding: 4px 6px; border-radius: var(--radius); color: var(--color-text); }
.header-search-btn:hover { background: var(--color-bg); }

/* ===== Search page ===== */
.search-form { margin-bottom: 1.5rem; }

.search-bar { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.search-input {
    flex: 1;
    padding: 0.65rem 0.85rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
}
.search-input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(192,57,43,0.15); }

.search-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.filter-select { width: auto; min-width: 160px; }

.search-results-header { margin-bottom: 1rem; font-size: 0.9rem; color: var(--color-text-muted); }
.search-results-query strong { color: var(--color-text); }

.search-prompt { color: var(--color-text-muted); padding: 2rem 0; }

/* ===== URL Scrape page ===== */
.url-scrape-form { margin-bottom: 1.5rem; }
.url-input-row { display: flex; gap: 0.5rem; align-items: stretch; }
.url-input-row .form-control { flex: 1; }
.scrape-fail-actions { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

.scrape-hint-block { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-top: 1.5rem; }
.scrape-hint-block__title { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.5rem; }
.scrape-hint-block__list { padding-left: 1.25rem; font-size: 0.875rem; color: var(--color-text-muted); line-height: 1.7; }

/* ===== OCR / Photo Upload page ===== */
.ocr-phase { margin-top: 0; }

/* Phase 1: drop zone */
.ocr-drop-zone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: var(--color-surface);
}
.ocr-drop-zone:hover,
.ocr-drop-zone:focus,
.ocr-drop-zone--hover { border-color: var(--color-primary); background: rgba(192,57,43,0.04); outline: none; }
.ocr-drop-zone__icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.ocr-drop-zone__text { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.25rem; }
.ocr-drop-zone__hint { font-size: 0.875rem; color: var(--color-text-muted); }
.ocr-file-input { display: none; }

/* Phase 2: image + canvas */
.ocr-select-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.ocr-select-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.15rem; }
.ocr-select-hint { font-size: 0.875rem; color: var(--color-text-muted); }
.ocr-select-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.ocr-canvas-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    cursor: crosshair;
}
.ocr-preview-img {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}
.ocr-canvas {
    position: absolute;
    top: 0; left: 0;
    pointer-events: auto; /* canvas captures events */
    touch-action: none;
}

.ocr-process-row {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.ocr-process-hint { font-size: 0.875rem; color: var(--color-text-muted); }

/* Phase 3: spinner */
.ocr-processing {
    text-align: center;
    padding: 4rem 2rem;
}
.ocr-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: ocr-spin 0.8s linear infinite;
    margin: 0 auto 1.5rem;
}
@keyframes ocr-spin { to { transform: rotate(360deg); } }
.ocr-processing__text { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.25rem; }
.ocr-processing__sub { font-size: 0.875rem; color: var(--color-text-muted); }

/* Phase 4: draft editor */
.ocr-draft-header { margin-bottom: 1.5rem; }
.ocr-draft-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.25rem; }
.ocr-draft-hint { font-size: 0.875rem; color: var(--color-text-muted); margin-bottom: 0.75rem; }

.ocr-marker-pill {
    display: inline-block;
    background: #fee;
    color: #c0392b;
    font-weight: 700;
    font-family: monospace;
    font-size: 0.8em;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    border: 1px solid #f9c4c0;
}

.ocr-marker-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fff8f8;
    border: 1px solid #f9c4c0;
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}
.ocr-marker-count__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.35rem;
    background: var(--color-primary);
    color: #fff;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}
.ocr-marker-count__label { color: var(--color-text); }

/* Fields containing ### get a highlight ring */
.ocr-field--marker {
    border-color: #e74c3c !important;
    background: #fff8f8 !important;
    box-shadow: 0 0 0 2px rgba(231,76,60,0.15) !important;
}

.ocr-save-blocked {
    font-size: 0.875rem;
    color: var(--color-primary);
    font-weight: 600;
}

/* ===== Comments ===== */
.comment-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.comment {
    border-left: 3px solid var(--color-border);
    padding: 0.6rem 0.75rem;
    background: var(--color-surface);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.comment__header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.35rem;
    flex-wrap: wrap;
}

.comment__author {
    font-weight: 600;
    font-size: 0.875rem;
}

.comment__time {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    flex: 1;
}

.comment__delete-form { margin: 0; }
.comment__delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    padding: 0.1rem 0.25rem;
    border-radius: 3px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.comment__delete-btn:hover { color: var(--color-primary); background: #fee; }

.comment__body {
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
    white-space: pre-wrap;
}

.comment-form { margin-top: 1rem; border-top: 1px solid var(--color-border); padding-top: 1rem; }
.comment-form__input { resize: vertical; }
.comment-form__actions { margin-top: 0.5rem; display: flex; justify-content: flex-end; }

.recipe-card__comments {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

/* ===== Star rating widget ===== */
.star-widget {
    display: flex;
    gap: 0.15rem;
    align-items: center;
    margin: 0.25rem 0;
}

.star-btn {
    background: none;
    border: none;
    padding: 0.1rem 0.05rem;
    cursor: pointer;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--color-border);
    transition: color 0.1s, transform 0.1s;
}
.star-btn:hover,
.star-btn.star--hover  { color: #f39c12; transform: scale(1.15); }
.star-btn.star--filled { color: #f39c12; }
.star-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 3px;
}

/* Dimmed state while a request is in flight */
.star-widget[style*="opacity"] .star-btn { cursor: wait; }

/* ===== Made This ===== */
.made-btn { margin-top: 0.4rem; width: 100%; }

.made-section { margin-top: 0.5rem; }

.made-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.made-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--color-border);
    gap: 1rem;
}
.made-entry:last-child { border-bottom: none; }
.made-entry__name { font-weight: 600; }
.made-entry__date { color: var(--color-text-muted); white-space: nowrap; }

/* ===== Favourite button ===== */
.fav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.fav-btn__icon { font-size: 1.1em; line-height: 1; }
.fav-btn--active { color: var(--color-primary); border-color: var(--color-primary); }

/* Favourites page card wrapper — positions the remove button */
.fav-card-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
}
.fav-card-remove {
    margin-top: 0.4rem;
    width: 100%;
    justify-content: center;
}

/* ===== Variants ===== */
.collapsible-header-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.collapsible-header-row .collapsible-toggle {
    flex: 1;
}

.variants-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.variant-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.variant-card__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    text-decoration: none;
    color: var(--color-text);
    transition: background 0.15s;
}
.variant-card__link:hover { background: var(--color-surface); }

.variant-card__body { flex: 1; min-width: 0; }
.variant-card__title { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.15rem; }
.variant-card__attr  { font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 0.25rem; }
.variant-card__notes { font-size: 0.8rem; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.variant-card__thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: calc(var(--radius) - 2px);
    flex-shrink: 0;
}

.variant-origin-note {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}
.variant-origin-note a { color: var(--color-primary); font-weight: 600; }

/* ===== Cook Mode overlay ===== */
.cook-mode {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #1a1a1a;
    color: #f0f0f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cook-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: #111;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}
.cook-header__title {
    font-size: 1rem;
    font-weight: 700;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 1rem;
}
.cook-exit-btn {
    background: none;
    border: 1px solid #555;
    color: #ccc;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    white-space: nowrap;
    flex-shrink: 0;
}
.cook-exit-btn:hover { border-color: #aaa; color: #fff; }

.cook-tabs {
    display: flex;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}
.cook-tab {
    flex: 1;
    background: none;
    border: none;
    color: #888;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.65rem 1rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.cook-tab:hover { color: #ddd; }
.cook-tab--active { color: #fff; border-bottom-color: var(--color-primary); }

.cook-panel {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
}

/* Method panel */
.cook-step-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 1.5rem 1rem;
    text-align: center;
}
.cook-step-counter {
    font-size: 0.875rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1.5rem;
}
.cook-step-text {
    font-size: clamp(1.4rem, 4vw, 2rem);
    line-height: 1.5;
    color: #f0f0f0;
    margin: 0;
}

.cook-nav {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem 1.25rem;
    flex-shrink: 0;
}
.cook-nav-btn {
    flex: 1;
    padding: 0.85rem;
    font-size: 1rem;
    font-weight: 600;
    background: #2a2a2a;
    color: #f0f0f0;
    border: 1px solid #444;
    border-radius: var(--radius);
}
.cook-nav-btn:hover:not(:disabled) { background: #333; border-color: #666; color: #fff; }
.cook-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.cook-wakelock-tip {
    text-align: center;
    font-size: 0.8rem;
    color: #666;
    padding: 0 1.25rem 0.75rem;
    flex-shrink: 0;
}

/* Ingredients panel */
.cook-ing-list {
    list-style: none;
    padding: 1rem 1.25rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.cook-ing-item {
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
    font-size: 1.1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #2a2a2a;
}
.cook-ing-item:last-child { border-bottom: none; }
.cook-ing-amount {
    font-weight: 700;
    color: #f0f0f0;
    white-space: nowrap;
    min-width: 4rem;
}
.cook-ing-name { color: #ccc; }

/* ===== Admin panel ===== */
.admin-nav {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 0;
}
.admin-nav__link {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s;
}
.admin-nav__link:hover { color: var(--color-text); }
.admin-nav__link--active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.admin-layout { display: flex; flex-direction: column; gap: 1.5rem; }

.admin-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.admin-card__title { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }

.admin-inline-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: flex-end;
}
.admin-inline-form .form-control { flex: 1; min-width: 160px; }

.admin-search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.admin-search-form .form-control { flex: 1; min-width: 200px; }
.admin-result-count { font-size: 0.875rem; color: var(--color-text-muted); margin-bottom: 0.75rem; }

.admin-table-wrap { overflow-x: auto; }
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.admin-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--color-border);
    font-weight: 700;
    color: var(--color-text-muted);
    white-space: nowrap;
}
.admin-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: var(--color-bg); }
.admin-table__row--self td { background: #fffbf0; }
.admin-table__actions { display: flex; gap: 0.35rem; align-items: center; }

/* Category rows */
.cat-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}
.cat-row:last-child { border-bottom: none; }
.cat-row--sub { padding-left: 1.5rem; background: var(--color-bg); }
.cat-row__name { flex: 1; }
.cat-row__actions { display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0; }
.cat-row__count { font-size: 0.75rem; color: var(--color-text-muted); white-space: nowrap; }
.cat-edit-form { display: flex; gap: 0.4rem; align-items: center; }
.cat-move-form { display: flex; gap: 0.2rem; }

.form-control--inline { width: auto; padding: 0.3rem 0.5rem; font-size: 0.875rem; }

.btn-xs { padding: 0.25rem 0.6rem; font-size: 0.8rem; }

/* Status / role badges */
.status-badge, .role-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: capitalize;
}
.status-badge--published, .role-badge--admin { background: #d5f5e3; color: #1a7a4a; }
.status-badge--draft { background: #fef9e7; color: #9a7d0a; }
.status-badge--used  { background: #eaecee; color: #555; }
.status-badge--pending { background: #d6eaf8; color: #1a5e8a; }
.role-badge--member { background: #d6eaf8; color: #1a5e8a; }
.role-badge--viewer { background: #eaecee; color: #555; }

.role-change-form select { font-size: 0.8rem; padding: 0.25rem 0.4rem; }

/* ===== My Recipes ===== */
.my-section { margin-bottom: 2rem; }
.my-section__title { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); padding-bottom: 0.4rem; }
.my-recipe-wrap { display: flex; flex-direction: column; }
.my-recipe-actions { display: flex; gap: 0.4rem; margin-top: 0.4rem; }
.my-recipe-actions .btn { flex: 1; justify-content: center; }

/* ===== Profile ===== */
.profile-layout { display: flex; flex-direction: column; gap: 1.5rem; max-width: 640px; }
.profile-password-form { display: flex; flex-direction: column; gap: 0.75rem; }

.activity-grid {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.activity-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    min-width: 80px;
    flex: 1;
}
.activity-stat__num { font-size: 1.75rem; font-weight: 700; color: var(--color-primary); line-height: 1; }
.activity-stat__label { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.25rem; text-align: center; }

.profile-dl { display: grid; grid-template-columns: 120px 1fr; gap: 0.5rem 1rem; font-size: 0.9rem; }
.profile-dl dt { font-weight: 600; color: var(--color-text-muted); }
