/* Family Recipes — design tokens, then base, layout and components. */

:root {
    --bg: #f6f4ef;
    --surface: #ffffff;
    --surface-2: #f1eee7;
    --surface-3: #e8e4d9;
    --text: #1f2421;
    --muted: #5d6964;
    --faint: #8a938f;
    --border: #e3dfd4;
    --accent: #2f6f4f;
    --accent-strong: #245a40;
    --accent-soft: #e3eee7;
    --on-accent: #ffffff;
    --danger: #b3412b;
    --danger-soft: #f8e5e0;
    --warn: #9a5d0c;
    --warn-soft: #faeed6;
    --info: #2f6690;
    --info-soft: #e2edf6;

    --starter: #5b9346;
    --starter-soft: #e6f0dd;
    --main: #c2602b;
    --main-soft: #f8e4d6;
    --dessert: #b04b7a;
    --dessert-soft: #f5e0e9;
    --snack: #a97d22;
    --snack-soft: #f5ebd1;
    --drink: #2b7fa6;
    --drink-soft: #daebf4;

    --shadow-sm: 0 1px 2px rgb(31 36 33 / 6%);
    --shadow: 0 1px 2px rgb(31 36 33 / 5%), 0 8px 24px rgb(31 36 33 / 7%);
    --shadow-lg: 0 18px 50px rgb(31 36 33 / 18%);
    --radius: 16px;
    --radius-sm: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    --page-width: 1140px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121413;
        --surface: #1a1d1b;
        --surface-2: #222624;
        --surface-3: #2b302d;
        --text: #eaedeb;
        --muted: #a2aca7;
        --faint: #7b8580;
        --border: #2d3230;
        --accent: #7cc49b;
        --accent-strong: #98d6b2;
        --accent-soft: #1d3127;
        --on-accent: #0e1a13;
        --danger: #ef8a73;
        --danger-soft: #3a211b;
        --warn: #e8b562;
        --warn-soft: #382b15;
        --info: #82b8de;
        --info-soft: #1a2a37;

        --starter: #93c97c;
        --starter-soft: #1f2b1a;
        --main: #ec9a66;
        --main-soft: #33231a;
        --dessert: #e28bb3;
        --dessert-soft: #33202a;
        --snack: #dcb55d;
        --snack-soft: #302816;
        --drink: #72b9da;
        --drink-soft: #172a35;

        --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
        --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 30%);
        --shadow-lg: 0 18px 50px rgb(0 0 0 / 55%);
        color-scheme: dark;
    }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.55 var(--font);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; margin: 0; }
h1:focus { outline: none; }
p { margin: 0; }
a { color: var(--accent); }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

.display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
.eyebrow { color: var(--muted); font-size: 0.95rem; margin-bottom: 0.25rem; }
.muted { color: var(--muted); }
.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { flex: none; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Boot screen (index.html) & Blazor error bar ---------- */

.boot {
    min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 1rem;
    color: var(--muted);
}
.boot__mark {
    width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center;
    background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow);
    animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(0.94); opacity: 0.8; } }

#blazor-error-ui {
    display: none; position: fixed; inset: auto 1rem 1rem; z-index: 1000;
    padding: 0.8rem 1rem; border-radius: var(--radius-sm);
    background: var(--danger-soft); color: var(--danger); box-shadow: var(--shadow-lg);
}
#blazor-error-ui .reload { margin-left: 0.5rem; font-weight: 600; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
    min-height: 42px; padding: 0.55rem 1.05rem; border-radius: 999px;
    border: 1px solid transparent; background: var(--surface-2); color: var(--text);
    font-weight: 600; font-size: 0.95rem; text-decoration: none; cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-strong); }
.btn--outline { background: transparent; border-color: var(--border); }
.btn--outline:hover { background: var(--surface-2); }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 88%, black); }
.btn--danger-text { color: var(--danger); }
.btn--danger-text:hover { background: var(--danger-soft); }
.btn--sm { min-height: 36px; padding: 0.35rem 0.85rem; font-size: 0.9rem; }
.btn--block { width: 100%; }
.btn--icon { width: 38px; min-height: 38px; padding: 0; border-radius: 50%; }

.link-button {
    background: none; border: 0; padding: 0; color: var(--accent);
    font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- Forms ---------- */

.field { display: grid; gap: 0.35rem; }
.field__label { font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.field__hint { font-size: 0.85rem; color: var(--faint); }
.field__error { font-size: 0.85rem; color: var(--danger); }

.input, .select, .textarea {
    width: 100%; min-height: 44px; padding: 0.6rem 0.8rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.input--invalid { border-color: var(--danger); }

.stack { display: grid; gap: 1rem; }
.grid-3 { display: grid; gap: 1rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.switch { display: inline-flex; align-items: center; gap: 0.75rem; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
    width: 46px; height: 26px; border-radius: 999px; background: var(--surface-3);
    position: relative; transition: background 0.2s; flex: none;
}
.switch__track::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
    border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform 0.2s;
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-size: 0.93rem; white-space: pre-line; }
.alert--danger { background: var(--danger-soft); color: var(--danger); }
.alert--info { background: var(--info-soft); color: var(--info); }

/* ---------- App shell ---------- */

.app-header {
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--border);
}
.app-header__inner {
    max-width: var(--page-width); margin: 0 auto; padding: 0.7rem 1rem;
    display: flex; align-items: center; gap: 1rem;
}
.app-header__actions { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }

.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--text); text-decoration: none; }
.brand__mark {
    width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
    background: var(--accent); color: var(--on-accent);
}
.brand__mark--lg { width: 56px; height: 56px; border-radius: 16px; }
.brand__name { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; }

.page { max-width: var(--page-width); margin: 0 auto; padding: 1.75rem 1rem 6rem; }
.page-loading { display: grid; place-items: center; min-height: 50vh; }

.spinner {
    width: 28px; height: 28px; border-radius: 50%; display: inline-block;
    border: 3px solid var(--surface-3); border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}
.spinner--sm { width: 16px; height: 16px; border-width: 2px; border-color: currentColor; border-top-color: transparent; }

/* Sync status pill */
.sync-pill {
    display: inline-flex; align-items: center; gap: 0.4rem; min-height: 36px; padding: 0.3rem 0.8rem;
    border-radius: 999px; border: 1px solid transparent; background: var(--surface-2);
    color: var(--muted); font-weight: 600; font-size: 0.85rem; cursor: pointer;
}
.sync-pill--ok { color: var(--accent); background: var(--accent-soft); }
.sync-pill--warn { color: var(--warn); background: var(--warn-soft); }
.sync-pill--danger { color: var(--danger); background: var(--danger-soft); }
.sync-pill--info { color: var(--info); background: var(--info-soft); }

/* User menu */
.user-menu { position: relative; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.9rem;
    border: 0; cursor: pointer;
}
.avatar--lg { width: 72px; height: 72px; font-size: 1.5rem; }
.menu-backdrop { position: fixed; inset: 0; z-index: 60; }
.menu {
    position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 61; min-width: 230px;
    padding: 0.4rem; border-radius: var(--radius); background: var(--surface);
    border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.menu__header { padding: 0.6rem 0.75rem 0.7rem; border-bottom: 1px solid var(--border); margin-bottom: 0.3rem; }
.menu__name { font-weight: 700; }
.menu__email { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.menu__item {
    display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 0.6rem 0.75rem;
    border: 0; border-radius: var(--radius-sm); background: none; color: var(--text);
    text-decoration: none; text-align: left; cursor: pointer; font-size: 0.95rem;
}
.menu__item:hover { background: var(--surface-2); }

/* Floating action button (mobile) */
.fab {
    position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 40;
    width: 58px; height: 58px; border-radius: 18px; display: none; place-items: center;
    background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-lg);
}

/* ---------- Home ---------- */

.home-hero { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.home-hero h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); }
.home-hero__count { color: var(--muted); font-size: 0.95rem; }

.toolbar { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.9rem; }

.search {
    flex: 1 1 320px; display: flex; align-items: center; gap: 0.6rem; min-height: 48px; padding: 0 1rem;
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
    color: var(--faint); box-shadow: var(--shadow-sm);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.search input { flex: 1; border: 0; background: none; outline: none; color: var(--text); min-width: 0; }

.segmented {
    display: inline-flex; padding: 4px; border-radius: 999px; background: var(--surface-2);
    border: 1px solid var(--border);
}
.segmented__item {
    border: 0; background: none; padding: 0.45rem 0.95rem; border-radius: 999px;
    color: var(--muted); font-weight: 600; cursor: pointer;
}
.segmented__item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.filter-row, .tag-row {
    display: flex; gap: 0.5rem; align-items: center; overflow-x: auto; padding: 0.15rem 0.1rem 0.4rem;
    scrollbar-width: thin;
}
.tag-row { margin-bottom: 1.25rem; }
@media (min-width: 641px) { .filter-row { flex-wrap: wrap; overflow-x: visible; } }

.chip {
    display: inline-flex; align-items: center; gap: 0.35rem; flex: none; padding: 0.4rem 0.85rem;
    border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
    color: var(--text); font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.chip:hover { border-color: var(--faint); }
.chip.is-active { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip-select {
    flex: none; padding: 0.4rem 2rem 0.4rem 0.85rem; border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface); font-size: 0.9rem; font-weight: 600; cursor: pointer;
}

.tag {
    flex: none; padding: 0.25rem 0.65rem; border-radius: 999px; border: 0;
    background: var(--surface-2); color: var(--muted); font-size: 0.85rem; cursor: pointer;
}
.tag.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
span.tag { cursor: default; }

.recipe-grid {
    display: grid; gap: 1.25rem;
    grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
}

/* Type tones used by cards, chips and the detail page */
.tone-starter, .recipe-card--starter, .detail--starter { --tone: var(--starter); --tone-soft: var(--starter-soft); }
.tone-main, .recipe-card--main, .detail--main { --tone: var(--main); --tone-soft: var(--main-soft); }
.tone-dessert, .recipe-card--dessert, .detail--dessert { --tone: var(--dessert); --tone-soft: var(--dessert-soft); }
.tone-snack, .recipe-card--snack, .detail--snack { --tone: var(--snack); --tone-soft: var(--snack-soft); }
.tone-drink, .recipe-card--drink, .detail--drink { --tone: var(--drink); --tone-soft: var(--drink-soft); }

.recipe-card {
    display: flex; flex-direction: column; overflow: hidden; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    color: inherit; text-decoration: none; transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.recipe-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--tone) 35%, var(--border)); }
.recipe-card__cover {
    position: relative; height: 128px; display: grid; place-items: center;
    background:
        radial-gradient(circle at 18% 22%, color-mix(in srgb, var(--tone) 22%, transparent) 0 22%, transparent 23%),
        radial-gradient(circle at 85% 80%, color-mix(in srgb, var(--tone) 16%, transparent) 0 30%, transparent 31%),
        var(--tone-soft);
}
.recipe-card__emoji { font-size: 3.2rem; filter: drop-shadow(0 6px 10px rgb(0 0 0 / 12%)); }
.recipe-card__type {
    position: absolute; left: 0.75rem; top: 0.75rem; padding: 0.15rem 0.6rem; border-radius: 999px;
    background: var(--surface); color: var(--tone); font-size: 0.78rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.recipe-card__badges { position: absolute; right: 0.75rem; top: 0.75rem; display: flex; gap: 0.35rem; }
.badge {
    display: inline-flex; align-items: center; gap: 0.25rem; min-height: 24px; padding: 0.1rem 0.5rem;
    border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 0.75rem; font-weight: 700;
}
.badge--warn { color: var(--warn); }
.badge--danger { color: var(--danger); }
.recipe-card__body { padding: 1rem 1.1rem 1.1rem; display: grid; gap: 0.4rem; flex: 1; align-content: start; }
.recipe-card__title { font-family: var(--font-display); font-size: 1.25rem; }
.recipe-card__desc {
    color: var(--muted); font-size: 0.93rem;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.recipe-card__meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; margin-top: 0.35rem;
    color: var(--muted); font-size: 0.86rem;
}
.recipe-card__meta span { display: inline-flex; align-items: center; gap: 0.3rem; }
.recipe-card__author { margin-left: auto; color: var(--faint); }

.skeleton {
    border-radius: var(--radius); height: 260px; border: 1px solid var(--border);
    background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%) 0 0 / 300% 100%;
    animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { to { background-position: -150% 0; } }

.empty {
    display: grid; justify-items: center; gap: 0.6rem; text-align: center;
    padding: 3.5rem 1rem; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted);
}
.empty__emoji { font-size: 2.6rem; }
.empty h2 { font-family: var(--font-display); color: var(--text); font-size: 1.4rem; }

/* ---------- Recipe detail ---------- */

.back-link {
    display: inline-flex; align-items: center; gap: 0.25rem; margin-bottom: 1rem;
    color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.93rem;
}
.back-link:hover { color: var(--text); }

.banner {
    display: flex; align-items: center; gap: 0.6rem; padding: 0.75rem 1rem; margin-bottom: 1rem;
    border-radius: var(--radius-sm); font-size: 0.93rem;
}
.banner--warn { background: var(--warn-soft); color: var(--warn); }
.banner--danger { background: var(--danger-soft); color: var(--danger); }
.banner a { color: inherit; font-weight: 700; }

.detail-hero {
    display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: center;
    padding: 1.75rem; border-radius: calc(var(--radius) + 4px);
    background:
        radial-gradient(circle at 92% 12%, color-mix(in srgb, var(--tone) 18%, transparent) 0 18%, transparent 19%),
        var(--tone-soft);
}
.detail-hero__emoji {
    width: 108px; height: 108px; border-radius: 28px; display: grid; place-items: center;
    background: var(--surface); font-size: 3.6rem; box-shadow: var(--shadow);
}
.detail-hero h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); margin: 0.45rem 0 0.4rem; }
.detail-hero .lead { color: var(--muted); font-size: 1.05rem; max-width: 62ch; }
.byline { color: var(--muted); font-size: 0.9rem; margin-top: 0.6rem; }
.source-link { display: inline-flex; align-items: center; gap: 0.2rem; color: inherit; font-weight: 600; text-underline-offset: 3px; }
.source-link:hover { color: var(--text); }
.bookmarklet { cursor: grab; border-style: dashed; }
.pills { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pill {
    display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.65rem; border-radius: 999px;
    background: var(--surface); color: var(--muted); font-size: 0.8rem; font-weight: 700;
}
.pill--tone { color: var(--tone); text-transform: uppercase; letter-spacing: 0.05em; }

.detail-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.1rem 0 1.25rem; }

.stats {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin: 0 0 1.5rem;
}
.stat {
    padding: 0.85rem 1rem; border-radius: var(--radius); background: var(--surface);
    border: 1px solid var(--border);
}
.stat dt { color: var(--muted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.stat dd { margin: 0.2rem 0 0; font-size: 1.15rem; font-weight: 700; }
.stepper { display: flex; align-items: center; gap: 0.6rem; }
.stepper button {
    width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--surface-2); display: grid; place-items: center; cursor: pointer; color: var(--text);
}
.stepper button:hover { background: var(--surface-3); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr); gap: 1.25rem; align-items: start; }

.panel {
    padding: 1.4rem; border-radius: var(--radius); background: var(--surface);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.panel > h2 { font-family: var(--font-display); font-size: 1.4rem; margin-bottom: 0.9rem; }
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.panel__head h2 { font-family: var(--font-display); font-size: 1.4rem; }
.hint { color: var(--muted); font-size: 0.86rem; margin: -0.4rem 0 0.8rem; }

.ingredients-panel { position: sticky; top: 84px; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; }
.checklist li + li { border-top: 1px solid var(--border); }
.check { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.65rem 0; cursor: pointer; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check__box {
    flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 7px;
    border: 2px solid var(--border); display: grid; place-items: center; color: transparent;
    transition: background 0.15s, border-color 0.15s;
}
.check input:checked + .check__box { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.check input:focus-visible + .check__box { outline: 2px solid var(--accent); outline-offset: 2px; }
.check input:checked ~ .check__text { color: var(--faint); text-decoration: line-through; }
.check__qty { font-weight: 700; }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; gap: 1.1rem; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 2.2rem 1fr; gap: 0.85rem; }
.steps li::before {
    content: counter(step); width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center;
    background: var(--tone-soft, var(--accent-soft)); color: var(--tone, var(--accent)); font-weight: 800;
}
.steps p { padding-top: 0.3rem; }

.tips {
    margin-top: 1.5rem; padding: 1rem 1.15rem; border-radius: var(--radius-sm);
    background: var(--surface-2); border-left: 4px solid var(--tone, var(--accent));
}
.tips h3 { display: flex; align-items: center; gap: 0.4rem; font-size: 1rem; margin-bottom: 0.4rem; }
.tips ul { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.3rem; }

.detail-tags { margin-top: 1.25rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* ---------- Allergens ---------- */

.allergens {
    display: grid; gap: 0.65rem; margin-bottom: 1.25rem; padding: 1rem 1.25rem; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.allergens__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
.allergens__head h2 { font-family: var(--font-display); font-size: 1.25rem; }
.allergens__status { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--warn); font-size: 0.88rem; font-weight: 600; }
.allergens__status--ok { color: var(--accent); }
.allergens__row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.allergens__label {
    min-width: 7.5rem; color: var(--muted); font-size: 0.78rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.allergens__note { color: var(--faint); font-size: 0.85rem; }

.allergen {
    display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.7rem; border-radius: 999px;
    background: var(--warn-soft); color: var(--warn); font-size: 0.88rem; font-weight: 700;
}
.allergen--possible { background: transparent; color: var(--text); border: 1px dashed var(--faint); font-weight: 600; }
.allergen__why { color: var(--muted); font-weight: 400; }
.allergen--avoid { background: var(--danger); color: var(--surface); border: 1px solid var(--danger); }
.allergen--possible.allergen--avoid { background: var(--danger-soft); color: var(--danger); border-style: dashed; }
.allergen--possible.allergen--avoid .allergen__why { color: inherit; }

.allergen-tag {
    display: inline-block; margin-left: 0.3rem; padding: 0 0.45rem; border-radius: 999px; vertical-align: 1px;
    background: var(--warn-soft); color: var(--warn); font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.allergen-tag--avoid { background: var(--danger); color: var(--surface); }
.banner--allergen { font-size: 1rem; }

.allergen-picker { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fill, minmax(195px, 1fr)); }
.allergen-option {
    display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.6rem 0.75rem; text-align: left;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.allergen-option:hover { border-color: var(--faint); }
.allergen-option strong { display: block; font-size: 0.93rem; }
.allergen-option small { display: block; color: var(--muted); font-size: 0.8rem; line-height: 1.35; }
.allergen-option__box {
    flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 6px;
    border: 2px solid var(--border); display: grid; place-items: center;
}
.allergen-option.is-active { border-color: var(--danger); background: var(--danger-soft); }
.allergen-option.is-active .allergen-option__box { background: var(--danger); border-color: var(--danger); color: var(--surface); }

.allergen-hints {
    display: grid; gap: 0.6rem; padding: 0.8rem 1rem; border-radius: var(--radius-sm);
    background: var(--warn-soft); color: var(--warn); font-size: 0.93rem;
}
.allergen-hints p { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; }
.allergen-hints ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.allergen-hints li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.6rem; }
.allergen-hints li > span { color: var(--muted); }

/* ---------- Editor ---------- */

.editor { display: grid; gap: 1.25rem; max-width: 860px; margin: 0 auto; }
.editor__title { font-size: clamp(1.8rem, 4vw, 2.4rem); }
.type-picker { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.type-option {
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.9rem; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface); font-weight: 600; cursor: pointer;
}
.type-option.is-active { border-color: var(--tone); background: var(--tone-soft); color: var(--tone); }

.row-list { display: grid; gap: 0.6rem; }
.ingredient-row { display: grid; grid-template-columns: 5.5rem 6.5rem minmax(0, 1fr) auto; gap: 0.5rem; align-items: center; }
.text-row { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; gap: 0.6rem; align-items: start; }
.text-row__num {
    width: 2rem; height: 2rem; margin-top: 0.4rem; border-radius: 50%; display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 0.85rem;
}
.row-actions { display: flex; gap: 0.15rem; }
.row-actions .btn--icon { width: 34px; min-height: 34px; color: var(--muted); }
.list-labels { display: grid; grid-template-columns: 5.5rem 6.5rem 1fr; gap: 0.5rem; font-size: 0.8rem; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; }

.tag-editor { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.tag-chip {
    display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.25rem 0.35rem 0.25rem 0.7rem;
    border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 0.9rem;
}
.tag-chip button { border: 0; background: none; color: inherit; cursor: pointer; display: grid; place-items: center; padding: 2px; border-radius: 50%; }
.tag-chip button:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.tag-input { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

.editor-actions {
    position: sticky; bottom: 0; z-index: 30; display: flex; align-items: center; justify-content: flex-end; gap: 0.6rem;
    padding: 0.85rem 1rem; margin: 0 -1rem; background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--border);
}
.editor-actions__status { margin-right: auto; color: var(--danger); font-size: 0.9rem; font-weight: 600; }

/* ---------- Auth ---------- */

.auth-shell {
    min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem;
    background:
        radial-gradient(circle at 12% 18%, var(--main-soft) 0 14%, transparent 15%),
        radial-gradient(circle at 88% 82%, var(--starter-soft) 0 18%, transparent 19%),
        radial-gradient(circle at 80% 12%, var(--dessert-soft) 0 9%, transparent 10%),
        var(--bg);
}
.auth-card {
    width: min(100%, 420px); padding: 2.25rem 2rem; border-radius: calc(var(--radius) + 6px);
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; justify-content: center; margin-bottom: 1rem; }
.auth-title { text-align: center; font-size: 1.9rem; }
.auth-sub { text-align: center; color: var(--muted); margin: 0.35rem 0 1.5rem; }
.auth-foot { text-align: center; color: var(--muted); font-size: 0.93rem; margin-top: 1.25rem; }

/* ---------- Profile & conflicts ---------- */

.narrow { max-width: 640px; margin: 0 auto; display: grid; gap: 1.25rem; }
.profile-head { display: flex; align-items: center; gap: 1rem; }
.profile-head h1 { font-size: 1.9rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1.25rem; color: var(--muted); font-size: 0.95rem; }
.kv strong { color: var(--text); }

.conflict { display: grid; gap: 0.85rem; }
.conflict__versions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.version { padding: 0.85rem 1rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.version h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.3rem; }

/* ---------- Toasts & modal ---------- */

.toasts {
    position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 200;
    display: grid; gap: 0.5rem; width: min(92vw, 420px);
}
.toast {
    display: flex; align-items: center; gap: 0.6rem; padding: 0.8rem 1rem; border-radius: var(--radius-sm);
    background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-weight: 600; font-size: 0.93rem;
    animation: toast-in 0.2s ease-out;
}
.toast--success .icon { color: var(--accent-soft); }
.toast--error { background: var(--danger); color: #fff; }
.toast button { margin-left: auto; border: 0; background: none; color: inherit; opacity: 0.7; cursor: pointer; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgb(15 20 17 / 45%); animation: fade-in 0.15s; }
.modal {
    position: fixed; z-index: 101; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(92vw, 440px); padding: 1.5rem; border-radius: calc(var(--radius) + 4px);
    background: var(--surface); box-shadow: var(--shadow-lg); display: grid; gap: 0.75rem;
}
.modal h2 { font-family: var(--font-display); font-size: 1.4rem; }
.modal__body { color: var(--muted); }
.modal__actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }
@keyframes fade-in { from { opacity: 0; } }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
    .detail-grid { grid-template-columns: 1fr; }
    .ingredients-panel { position: static; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .hide-mobile { display: none !important; }
    .fab { display: grid; }
    .brand__name { font-size: 1.05rem; }
    .sync-pill span { display: none; }
    .sync-pill { padding: 0.3rem 0.6rem; }
    .home-hero { flex-direction: column; align-items: start; }
    .segmented { width: 100%; }
    .segmented__item { flex: 1; }
    .detail-hero { grid-template-columns: 1fr; padding: 1.25rem; }
    .detail-hero__emoji { width: 76px; height: 76px; font-size: 2.6rem; border-radius: 22px; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .grid-2, .conflict__versions { grid-template-columns: 1fr; }
    .ingredient-row { grid-template-columns: 4.5rem 5rem minmax(0, 1fr); }
    .ingredient-row .row-actions { grid-column: 1 / -1; justify-content: flex-end; margin-top: -0.3rem; }
    .list-labels { grid-template-columns: 4.5rem 5rem 1fr; }
    .auth-card { padding: 1.75rem 1.25rem; }
    .allergen-picker { grid-template-columns: 1fr 1fr; }
    .allergens__label { min-width: 0; width: 100%; }
}

/* ---------- Print: just the recipe ---------- */

@media print {
    :root { color-scheme: light; --bg: #fff; --surface: #fff; --text: #000; --muted: #333; --border: #ccc; }
    .app-header, .detail-actions, .back-link, .banner, .fab, .toasts, .stepper button, .no-print { display: none !important; }
    .page { padding: 0; max-width: none; }
    .detail-hero { background: none; padding: 0 0 1rem; border-bottom: 2px solid #000; border-radius: 0; }
    .detail-hero__emoji { box-shadow: none; border: 1px solid #ccc; }
    .detail-grid { grid-template-columns: 1fr 1.6fr; }
    .panel, .stat, .allergens { box-shadow: none; break-inside: avoid; }
    .allergen, .allergen-tag { border: 1px solid #000; background: none !important; color: #000 !important; }
    .ingredients-panel { position: static; }
}
