/* =========================================================
   XR — calm, warm, mobile-first. No framework.
   ========================================================= */

:root {
    color-scheme: light;
    --bg: #f6f3ec;
    --surface: #fffdf8;
    --surface-2: #efeadf;
    --ink: #1b2621;
    --muted: #66706a;
    --line: #e4ddcf;
    --accent: #1f4a3a;
    --accent-hover: #173a2d;
    --accent-soft: #e3ece5;
    --accent-ink: #fbfaf5;
    --danger: #a3372b;
    --danger-soft: #f8e7e3;
    --warn-soft: #fbf1dc;

    --breakfast: #f4e6c4; --breakfast-ink: #7a5a12;
    --snack: #f5e0d3;     --snack-ink: #8a4a2c;
    --lunch: #dfe9d7;     --lunch-ink: #3d6130;
    --dinner: #dde2ec;    --dinner-ink: #3b4c72;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(27, 38, 33, 0.04), 0 8px 24px -12px rgba(27, 38, 33, 0.12);
    --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: "Fraunces", Georgia, "Times New Roman", serif;
    --bottom-nav: 0px;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #121614;
        --surface: #1a1f1c;
        --surface-2: #232a25;
        --ink: #e8ebe5;
        --muted: #9aa39c;
        --line: #2e3631;
        --accent: #8cc5a4;
        --accent-hover: #a6d6ba;
        --accent-soft: #1f2d26;
        --accent-ink: #0f1a14;
        --danger: #e38b7e;
        --danger-soft: #3a211d;
        --warn-soft: #332b1a;

        --breakfast: #352f20; --breakfast-ink: #e9cf8f;
        --snack: #382a23;     --snack-ink: #eab79c;
        --lunch: #243029;     --lunch-ink: #a9d19a;
        --dinner: #242a37;    --dinner-ink: #aebce0;

        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
    }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

html, body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
}

body { min-height: 100vh; padding-bottom: var(--bottom-nav); }

h1, h2, h3 { line-height: 1.2; font-weight: 600; }
h1 { font-family: var(--font-display); font-size: clamp(1.75rem, 5vw, 2.4rem); margin: 0.2rem 0 0.5rem; letter-spacing: -0.01em; font-weight: 500; }
h2 { font-size: 1.15rem; margin: 0 0 0.6rem; }
h3 { font-size: 1rem; margin: 0.6rem 0 0.3rem; }
p { margin: 0 0 0.8rem; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 0.5rem; z-index: 100; background: var(--surface); padding: 0.5rem 1rem; border-radius: var(--radius-sm); }
.skip-link:focus { left: 0.5rem; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; margin: 1.25rem 0; }
.lead { color: var(--muted); font-size: 1.05rem; margin: 0 0 1rem; max-width: 38rem; }
.eyebrow {
    display: block;
    margin: 0;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.print-only { display: none; }

/* ---------- Top bar & navigation ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1rem;
    min-height: 60px;
}
.brand { display: inline-flex; align-items: center; gap: 0.55rem; text-decoration: none; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 11px;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: 0.02em;
}
.brand-mark.small { width: 1.75rem; height: 1.75rem; border-radius: 8px; font-size: 0.8rem; }
.brand-text { font-family: var(--font-display); font-size: 1.05rem; color: var(--muted); }

.appnav, .sitenav { display: flex; gap: 0.25rem; flex: 1; }
.appnav a, .sitenav a, .sitenav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
}
.appnav a:hover, .sitenav a:hover, .sitenav-link:hover { background: var(--surface-2); color: var(--ink); }
.appnav a.active, .sitenav a.active, .sitenav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-icon { display: none; }

.topbar-right { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.nav-login { text-decoration: none; font-weight: 600; padding: 0.4rem 0.6rem; }
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
}
.avatar:hover { border-color: var(--accent); color: var(--ink); }

@media (max-width: 760px) {
    :root { --bottom-nav: calc(64px + env(safe-area-inset-bottom)); }
    .brand-text { display: none; }
    .sitenav-link { display: none; }
    .appnav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 60;
        justify-content: space-around;
        gap: 0;
        padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom));
        background: var(--surface);
        border-top: 1px solid var(--line);
    }
    .appnav a {
        flex: 1;
        flex-direction: column;
        gap: 0.1rem;
        padding: 0.3rem 0.1rem;
        border-radius: 12px;
        font-size: 0.72rem;
        color: var(--muted);
    }
    .appnav a.active { background: transparent; color: var(--accent); }
    .appnav a.active .nav-icon { background: var(--accent-soft); }
    .nav-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.6rem;
        height: 1.75rem;
        border-radius: 999px;
        font-size: 1.05rem;
        line-height: 1;
    }
    .sitenav { flex: 1; }
}

/* ---------- Page shell ---------- */
.content {
    max-width: 1080px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}
.narrow { max-width: 680px; margin: 0 auto; }

.footer { border-top: 1px solid var(--line); margin-top: 2rem; }
.footer-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 0.5rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin: 0 0 0.7rem; flex-wrap: wrap; }
.section-head h2, .section-head .section-title { margin: 0; }
.section-tight { margin: 1.75rem 0; }
.back { display: inline-block; margin-bottom: 1rem; text-decoration: none; font-weight: 500; }

/* ---------- Buttons ---------- */
.button, .secondary, .danger-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.6rem 1.2rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}
.button { background: var(--accent); color: var(--accent-ink); }
.button:hover { background: var(--accent-hover); color: var(--accent-ink); }
.button:active, .secondary:active { transform: translateY(1px); }
.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.secondary:hover { border-color: var(--accent); color: var(--accent); }
.danger-link { background: transparent; color: var(--danger); padding-inline: 0.6rem; }
.danger-link:hover { background: var(--danger-soft); }
.button:disabled, .secondary:disabled, .danger-link:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.button.small, .secondary.small { min-height: 36px; padding: 0.35rem 0.9rem; font-size: 0.9rem; }
.button.big, .secondary.big { min-height: 52px; padding: 0.8rem 1.6rem; font-size: 1.05rem; }

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}
.icon-button:hover { background: var(--surface-2); }
.icon-button:disabled { opacity: 0.35; cursor: not-allowed; background: transparent; }
.icon-button.small { width: 32px; height: 32px; font-size: 1.05rem; }

.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }

/* ---------- Cards & common blocks ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.1rem;
    margin: 0 0 1rem;
    box-shadow: var(--shadow);
}
.card > h2:first-child { margin-top: 0; }
.empty-card { text-align: center; padding: 1.75rem 1.25rem; }
.empty-card .button { margin-top: 0.25rem; }
.quiet-card { background: transparent; box-shadow: none; border-style: dashed; }
.empty { text-align: center; padding: 3rem 1rem; }

.alert {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    background: var(--danger-soft);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    color: var(--ink);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.95rem;
    margin: 0 0 1rem;
}
.notice {
    background: var(--warn-soft);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1rem;
    margin: 0 0 1.25rem;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.4rem 0; }
.chip {
    display: inline-block;
    background: var(--surface-2);
    color: var(--ink);
    border-radius: 999px;
    padding: 0.15rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.loading { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); padding: 1.25rem 0; }
.spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 1.75rem; }
.field { display: flex; flex-direction: column; gap: 0.4rem; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 600; font-size: 0.95rem; padding: 0; }
fieldset.field > legend { font-size: 1.05rem; margin-bottom: 0.6rem; display: flex; align-items: center; gap: 0.5rem; }
.field small { font-weight: 400; color: var(--muted); }
.field-error { color: var(--danger); font-size: 0.875rem; }
.hint { color: var(--muted); font-size: 0.875rem; margin: 0.3rem 0 0; }

input:not([type=checkbox]):not([type=radio]), select, textarea {
    font: inherit;
    padding: 0.6rem 0.8rem;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input::placeholder { color: var(--muted); opacity: 0.8; }

.segmented { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.segmented button {
    flex: 1 1 8rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    min-height: 56px;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.segmented button:hover { border-color: var(--accent); }
.segmented button.selected { border: 2px solid var(--accent); background: var(--accent-soft); padding: calc(0.6rem - 1px) calc(0.9rem - 1px); }

.stepper { display: inline-flex; align-items: center; gap: 0.75rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0.25rem; align-self: flex-start; }
.stepper .icon-button { background: var(--surface-2); }
.stepper .icon-button:disabled { background: transparent; }
.stepper-value { min-width: 7rem; text-align: center; }

.step-no {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: var(--font-display);
    font-weight: 600;
    flex: 0 0 auto;
}
.step-no.small { width: 1.6rem; height: 1.6rem; font-size: 0.85rem; }

.toggle { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0.25rem 0 1rem; cursor: pointer; font-size: 0.95rem; }
.toggle input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }

/* ---------- Landing ---------- */
.landing { display: flex; flex-direction: column; }
.hero { padding: 2.5rem 0 3rem; max-width: 46rem; }
.display {
    font-family: var(--font-display);
    font-size: clamp(2.4rem, 8vw, 4.2rem);
    line-height: 1.05;
    font-weight: 500;
    letter-spacing: -0.02em;
    margin: 0.6rem 0 1.1rem;
}
.display em { font-style: italic; color: var(--accent); font-weight: 400; }
.hero-lead { font-size: 1.15rem; color: var(--muted); max-width: 36rem; }
.hero-points { list-style: none; padding: 0; margin: 1.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; color: var(--muted); font-size: 0.95rem; }
.hero-points li::before { content: "✓"; color: var(--accent); font-weight: 700; margin-right: 0.4rem; }

.section { padding: 2.5rem 0; border-top: 1px solid var(--line); }
.section-title { font-family: var(--font-display); font-weight: 500; font-size: clamp(1.5rem, 4vw, 2rem); margin: 0 0 0.5rem; }
.section-lead { color: var(--muted); margin-bottom: 1.25rem; }

.steps { list-style: none; padding: 0; margin: 1.25rem 0 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.steps h3 { font-size: 1.1rem; margin: 0.8rem 0 0.35rem; }
.steps p { color: var(--muted); margin: 0; font-size: 0.95rem; }

.faq { display: flex; flex-direction: column; gap: 0.5rem; max-width: 46rem; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 1rem; }
.faq summary { cursor: pointer; padding: 0.9rem 0; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-size: 1.2rem; line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq details p { color: var(--muted); margin: 0 0 1rem; }

.cta-band {
    margin: 2rem 0 0;
    padding: 2.5rem 1.5rem;
    border-radius: 24px;
    background: var(--accent);
    color: var(--accent-ink);
    text-align: center;
}
.cta-band h2 { font-family: var(--font-display); font-weight: 500; font-size: clamp(1.8rem, 5vw, 2.4rem); margin: 0 0 0.5rem; }
.cta-band p { opacity: 0.85; }
.cta-band .button { background: var(--accent-ink); color: var(--accent); margin-top: 0.5rem; }
.cta-band .button:hover { background: var(--bg); color: var(--accent-hover); }

/* ---------- Programs ---------- */
.program-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.program-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 1.1rem 1.15rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    text-align: left;
}
.program-card.selectable { cursor: pointer; transition: border-color 0.15s, background-color 0.15s; }
.program-card.selectable:hover { border-color: var(--accent); }
.program-card.selected { border: 2px solid var(--accent); background: var(--accent-soft); padding: calc(1.1rem - 1px) calc(1.15rem - 1px); }
.program-card.quiet { background: transparent; border-style: dashed; justify-content: center; }
.program-card.quiet.selected { border-style: solid; background: var(--accent-soft); }
.program-name { font-family: var(--font-display); font-size: 1.3rem; font-weight: 500; line-height: 1.2; }
.program-desc { color: var(--muted); font-size: 0.93rem; }

/* ---------- Meal types ---------- */
.meal-breakfast { --meal: var(--breakfast); --meal-ink: var(--breakfast-ink); }
.meal-snack     { --meal: var(--snack);     --meal-ink: var(--snack-ink); }
.meal-lunch     { --meal: var(--lunch);     --meal-ink: var(--lunch-ink); }
.meal-dinner    { --meal: var(--dinner);    --meal-ink: var(--dinner-ink); }
.meal-type {
    display: inline-block;
    align-self: flex-start;
    background: var(--meal, var(--surface-2));
    color: var(--meal-ink, var(--muted));
    border-radius: 999px;
    padding: 0.05rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ---------- Recipes ---------- */
.recipe-grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.recipe-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem 1.1rem 1.1rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.recipe-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 5px;
    background: var(--meal);
}
.recipe-card:hover { color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--meal-ink) 35%, var(--line)); }
.recipe-art {
    position: absolute;
    top: 0.85rem;
    right: 0.9rem;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    background: var(--meal);
    color: var(--meal-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
}
.recipe-name { font-family: var(--font-display); font-weight: 500; font-size: 1.2rem; line-height: 1.25; margin-top: 0.2rem; padding-right: 2.2rem; }
.recipe-desc {
    color: var(--muted);
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.recipe-meta { font-size: 0.82rem; color: var(--muted); margin-top: auto; padding-top: 0.3rem; }

.filter { display: flex; gap: 0.4rem; overflow-x: auto; padding: 0.25rem 0 1rem; scrollbar-width: none; }
.filter::-webkit-scrollbar { display: none; }
.pill {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0.35rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}
.pill:hover { border-color: var(--accent); }
.pill.selected { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.recipe-head { margin-bottom: 1.5rem; }
.facts { list-style: none; padding: 0; margin: 1rem 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.facts li {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 0;
    min-width: 3.6rem;
    max-width: 6rem;
    padding: 0.55rem 0.3rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--line);
}
.facts strong { font-size: 1.05rem; }
.facts span { font-size: 0.72rem; color: var(--muted); }
.recipe-cols { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 820px) { .recipe-cols { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: start; } }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients li { display: flex; gap: 0.75rem; padding: 0.45rem 0; border-bottom: 1px dashed var(--line); }
.ingredients li:last-child { border-bottom: 0; }
.ingredients .qty { min-width: 5rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.method { padding-left: 1.25rem; margin: 0; }
.method li { padding: 0.35rem 0 0.35rem 0.3rem; }
.method li::marker { color: var(--accent); font-weight: 700; }

/* ---------- Today ---------- */
.today-head { margin-bottom: 1.25rem; }
.progress-strip { max-width: 28rem; }
.progress-label { font-size: 0.95rem; margin-bottom: 0.35rem; }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.4s ease; }

.cta-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.2rem;
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--accent-ink);
    text-decoration: none;
    margin: 0 0 1rem;
}
.cta-card:hover { background: var(--accent-hover); color: var(--accent-ink); }
.cta-card > span { display: flex; flex-direction: column; }
.cta-card .muted { color: inherit; opacity: 0.8; }
.cta-arrow { font-size: 1.4rem; }

.quicklinks { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 2rem; }
.quicklinks a {
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    text-decoration: none;
    color: var(--ink);
    font-size: 0.9rem;
}
.quicklinks a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Meal rows ---------- */
.meal-list { padding: 0.35rem 0.9rem; }
.meal {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--line);
}
.meal:last-child { border-bottom: 0; }
.meal-body { display: flex; flex-direction: column; gap: 0.1rem; flex: 1; min-width: 0; }
.meal-name { color: var(--ink); text-decoration: none; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.meal-name:hover { color: var(--accent); text-decoration: underline; }
.meal-meta { font-size: 0.8rem; color: var(--muted); }
.meal.eaten .meal-name { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }

.check {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--line);
    background: var(--surface);
    color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    position: relative;
}
.check::after { content: ""; position: absolute; inset: -7px; } /* 44px hit area */
.check:hover { border-color: var(--accent); color: color-mix(in srgb, var(--accent) 40%, transparent); }
.check[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check:disabled { opacity: 0.6; cursor: progress; }
.swap { color: var(--muted); }

/* ---------- Week plan ---------- */
.weeknav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.3rem;
    margin: 0.5rem 0 1.25rem;
    max-width: 30rem;
}
.weeknav-label { display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.3; min-width: 0; }
.weeknav .icon-button { font-size: 1.5rem; }

.proposal-bar, .toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 0 0 1.25rem;
}
.proposal-bar {
    justify-content: space-between;
    padding: 1rem 1.1rem;
    border-radius: var(--radius);
    background: var(--warn-soft);
}
.proposal-bar > div { display: flex; flex-direction: column; min-width: 0; flex: 1 1 16rem; }
.push { margin-left: auto; }

.week-grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.day-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.85rem 1rem 0.35rem;
}
.day-card.is-today { border: 2px solid var(--accent); padding: calc(0.85rem - 1px) calc(1rem - 1px) calc(0.35rem - 1px); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--line); }
.day-head h2 { font-size: 1rem; margin: 0; }
.day-head h2 .muted { font-weight: 400; }
.is-proposal .day-card { border-style: dashed; }

.choice-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.choice {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.choice:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.choice.current { opacity: 0.7; cursor: default; }
.choice-name { font-weight: 600; }

/* ---------- Shopping ---------- */
.shop-group { margin: 0 0 1.25rem; }
.shop-cat {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 0.4rem;
}
.shop-list {
    list-style: none;
    padding: 0 0.9rem;
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.shop-item { display: flex; align-items: center; gap: 0.5rem; border-bottom: 1px solid var(--line); }
.shop-item:last-child { border-bottom: 0; }
.shop-item label { display: flex; align-items: center; gap: 0.75rem; flex: 1; min-width: 0; padding: 0.7rem 0; cursor: pointer; min-height: 48px; }
.shop-item input[type=checkbox] { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; accent-color: var(--accent); margin: 0; }
.shop-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.1rem 0.6rem; min-width: 0; }
.shop-name { font-weight: 500; overflow-wrap: anywhere; }
.shop-qty { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.93rem; }
.shop-used { flex-basis: 100%; font-size: 0.78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-item.checked .shop-name { text-decoration: line-through; color: var(--muted); }
.shop-item.checked .shop-qty, .shop-item.checked .shop-used { opacity: 0.6; }

.add-item { margin-top: 1.5rem; }
.add-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.add-row .grow { flex: 1 1 12rem; }
.add-row .qty { flex: 0 1 6.5rem; }
.add-row .unit { flex: 0 1 5rem; }
.add-row .button { flex: 1 0 auto; }
@media (min-width: 560px) { .add-row .button { flex: 0 0 auto; } }

/* ---------- Training ---------- */
.session {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.75rem 0.9rem;
    margin: 0 0 0.6rem;
}
.session-head { display: flex; align-items: center; gap: 0.75rem; }
.session-toggle {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.05rem;
    background: none;
    border: 0;
    padding: 0.2rem 0;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.session-kind { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); }
.session-daily .session-kind { color: var(--lunch-ink); }
.session-name { font-weight: 600; font-size: 1.02rem; }
.session.done .session-name { color: var(--muted); }
.chevron { color: var(--muted); transition: transform 0.2s; font-size: 1.1rem; }
.chevron.open { transform: rotate(180deg); }

.exercises { list-style: none; counter-reset: ex; padding: 0.5rem 0 0.2rem; margin: 0.6rem 0 0; border-top: 1px solid var(--line); }
.exercises li { counter-increment: ex; padding: 0.5rem 0 0.5rem 2rem; position: relative; }
.exercises li::before {
    content: counter(ex);
    position: absolute;
    left: 0;
    top: 0.55rem;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background: var(--surface-2);
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.exercise-head { display: flex; justify-content: space-between; gap: 0.75rem; }
.exercise-name { font-weight: 600; }
.exercise-dose { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; color: var(--accent); }

.day-dots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.35rem; margin-bottom: 0.75rem; }
.day-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    min-height: 60px;
}
.day-dot.today { border-color: var(--accent); color: var(--ink); font-weight: 600; }
.day-dot .dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--line);
    color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}
.day-dot.done .dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.day-dot:disabled { opacity: 0.6; }

.inline-details summary { cursor: pointer; font-weight: 600; padding: 0.3rem 0; }
.inline-details[open] summary { margin-bottom: 0.25rem; }
.card .inline-details { border-top: 1px solid var(--line); padding-top: 0.5rem; margin-top: 0.5rem; }

/* ---------- Progress ---------- */
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; margin-bottom: 0.5rem; }
.stat { display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; padding: 0.9rem; margin: 0; }
.stat-value { font-family: var(--font-display); font-size: clamp(1.3rem, 5vw, 1.9rem); font-weight: 500; color: var(--accent); line-height: 1.1; }
.stat-label { font-size: 0.85rem; font-weight: 600; }
@media (max-width: 440px) {
    .stat-row { grid-template-columns: 1fr; }
    .stat { flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: 0.2rem 0.6rem; }
}

.chart { margin: 0 0 1rem; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.chart-axis { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart-area { fill: var(--accent); opacity: 0.08; }
.chart-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }

.weight-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.6rem; align-items: end; }
@media (max-width: 480px) { .weight-form { grid-template-columns: 1fr 1fr; } .weight-form .button { grid-column: 1 / -1; } }

.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { display: flex; justify-content: space-between; padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: 0; }

/* ---------- Profile ---------- */
.inline-form { display: flex; gap: 0.5rem; align-items: flex-start; flex-wrap: wrap; }
.inline-form .grow { flex: 1 1 12rem; }
.facts-list { margin: 0; display: grid; gap: 0.1rem; }
.facts-list > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.facts-list > div:last-child { border-bottom: 0; }
.facts-list dt { color: var(--muted); }
.facts-list dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 20, 17, 0.45); z-index: 90; animation: fade 0.15s ease; }
.modal {
    position: fixed;
    z-index: 100;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(520px, calc(100vw - 2rem));
    max-height: min(80vh, 720px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: 20px;
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.4);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1rem 0.5rem 1.25rem; }
.modal-head h2 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 1.35rem; }
.modal-body { padding: 0 1.25rem 1.25rem; overflow-y: auto; }
@media (max-width: 560px) {
    .modal {
        left: 0;
        right: 0;
        top: auto;
        bottom: 0;
        transform: none;
        width: 100%;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
        animation: slide-up 0.2s ease;
    }
}
@keyframes fade { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(40px); opacity: 0; } }

/* ---------- Toasts ---------- */
.toasts {
    position: fixed;
    left: 50%;
    bottom: calc(1rem + var(--bottom-nav));
    transform: translateX(-50%);
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: min(440px, calc(100vw - 2rem));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.6rem 0.7rem 1rem;
    border-radius: 14px;
    background: var(--ink);
    color: var(--bg);
    box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.45);
    animation: slide-up 0.2s ease;
}
.toast a { color: var(--bg); font-weight: 600; }
.toast-close { background: none; border: 0; color: inherit; opacity: 0.7; font-size: 1.2rem; cursor: pointer; width: 32px; height: 32px; border-radius: 50%; }
.toast-close:hover { opacity: 1; }

/* ---------- Boot / Blazor chrome ---------- */
.boot { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.5rem; }
.loading-progress { width: 3.5rem; height: 3.5rem; }
.loading-progress circle { fill: none; stroke: var(--line); stroke-width: 0.35rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

#blazor-error-ui {
    background: var(--warn-soft);
    color: var(--ink);
    bottom: var(--bottom-nav);
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.blazor-error-boundary { background: var(--danger); padding: 1rem; color: #fff; border-radius: var(--radius-sm); }
.blazor-error-boundary::after { content: "Ett fel inträffade."; }

/* ---------- Small screens ---------- */
@media (max-width: 520px) {
    .content { padding: 1rem 1rem 2.5rem; }
    .hero { padding: 1.5rem 0 2rem; }
    .section { padding: 2rem 0; }
    .card { padding: 1rem; }
    .toolbar .push { margin-left: 0; }
    .week-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Print (shopping list) ---------- */
@media print {
    :root { --bottom-nav: 0px; }
    html, body { background: #fff; color: #000; }
    .topbar, .footer, .toasts, .no-print, .alert, .skip-link { display: none !important; }
    .print-only { display: block; }
    .content { padding: 0; max-width: none; }
    .eyebrow { color: #000; }
    h1 { font-size: 20pt; }
    .shop-group { break-inside: avoid; margin-bottom: 10pt; }
    .shop-cat { color: #000; }
    .shop-list { border: 0; padding: 0; background: none; columns: 2; column-gap: 24pt; }
    .shop-item { border: 0; break-inside: avoid; }
    .shop-item label { padding: 2pt 0; min-height: 0; }
    .shop-item input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 10pt; height: 10pt; border: 1px solid #000; border-radius: 2px; }
    .shop-item.checked .shop-name { color: #666; }
}
