:root {
    color-scheme: light;
    --bg: #f6f7f4;
    --surface: #ffffff;
    --ink: #1e2a24;
    --muted: #68746d;
    --line: #dfe5dc;
    --primary: #285f48;
    --primary-dark: #163c2c;
    --accent: #d9614c;
    --gold: #e1ad3d;
    --blue: #3e6f91;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(246, 247, 244, 0.3) 18rem),
        var(--bg);
    color: var(--ink);
}

a {
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(2.1rem, 4vw, 4.4rem);
    line-height: 0.98;
    letter-spacing: 0;
    margin-bottom: 1rem;
}

h1:focus {
    outline: none;
}

h2 {
    font-size: clamp(1.45rem, 2vw, 2.1rem);
    margin-bottom: 0.55rem;
}

h3 {
    font-size: 1.15rem;
    margin-bottom: 0.45rem;
}

.app-frame {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 72px;
    padding: 0.85rem clamp(1rem, 4vw, 3.5rem);
    background: rgba(246, 247, 244, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.brand,
.main-nav,
.hero-actions,
.meta-row,
.metric-row,
.tag-row {
    display: flex;
    align-items: center;
}

.brand {
    gap: 0.65rem;
    color: var(--ink);
    font-weight: 800;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--primary);
    color: white;
}

.main-nav {
    gap: 0.25rem;
}

.main-nav a {
    padding: 0.65rem 0.9rem;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
}

.main-nav a.active,
.main-nav a:hover {
    background: #e9efe8;
    color: var(--primary-dark);
}

.recipe-view-switch {
    display: inline-flex;
    gap: 0.25rem;
    margin-bottom: 1.25rem;
    padding: 0.25rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.recipe-view-switch a {
    min-width: 130px;
    padding: 0.65rem 1rem;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 800;
    text-align: center;
    text-decoration: none;
}

.recipe-view-switch a.active {
    background: var(--primary);
    color: white;
}

.guided-catalog-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.1rem;
    border-left: 4px solid var(--gold);
    background: #fffaf0;
}

.guided-catalog-intro h2,
.guided-catalog-intro p {
    margin-bottom: 0.25rem;
}

.guided-catalog-intro > strong {
    color: var(--primary);
    white-space: nowrap;
}

.page-shell {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2rem 0 4rem;
}

.hero-band {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
    gap: 2rem;
    align-items: end;
    min-height: 430px;
    padding: clamp(2rem, 5vw, 4rem);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(22, 60, 44, 0.94), rgba(22, 60, 44, 0.5)),
        url("https://images.unsplash.com/photo-1498837167922-ddd27525d352?auto=format&fit=crop&w=1800&q=80") center/cover;
    color: white;
    box-shadow: 0 22px 70px rgba(22, 60, 44, 0.18);
}

.hero-copy {
    max-width: 720px;
}

.hero-text {
    max-width: 720px;
    color: color-mix(in srgb, currentColor 78%, transparent);
    font-size: 1.08rem;
    line-height: 1.75;
}

.hero-panel {
    justify-self: end;
    width: min(100%, 330px);
    padding: 1.2rem;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(12px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.hero-panel strong {
    display: block;
    margin: 0.3rem 0;
    font-size: 2rem;
}

.panel-label,
.eyebrow {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-band .eyebrow,
.hero-band .panel-label {
    color: #ffd783;
}

.hero-actions {
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.primary-link,
.secondary-link,
.text-link,
.primary-button,
.article-row > a,
.recipe-card a {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 800;
    text-decoration: none;
}

.primary-link,
.primary-button {
    border: 0;
    background: var(--primary);
    color: white;
    padding: 0.75rem 1rem;
}

.primary-link:hover,
.primary-button:hover {
    background: var(--primary-dark);
}

.primary-button {
    cursor: pointer;
    font: inherit;
}

.secondary-link {
    border: 1px solid rgba(255, 255, 255, 0.55);
    color: white;
    padding: 0.7rem 1rem;
}

.text-link,
.recipe-card a,
.article-row > a {
    color: var(--primary);
}

.section-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1.5rem;
    margin: 3rem 0 1rem;
}

.section-header.large {
    align-items: start;
    margin-top: 1rem;
}

.section-header p {
    color: var(--muted);
    margin-bottom: 0;
}

.feature-strip,
.catalog-summary,
.planner-promo {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.feature-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.feature-strip article,
.catalog-summary span,
.planner-promo {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 14px 42px rgba(30, 42, 36, 0.06);
}

.feature-strip article {
    padding: 1rem;
}

.feature-strip strong,
.feature-strip span {
    display: block;
}

.feature-strip strong {
    margin-bottom: 0.4rem;
    color: var(--primary-dark);
}

.feature-strip span {
    color: var(--muted);
    line-height: 1.55;
}

.recipe-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.recipe-card,
.content-panel,
.article-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.recipe-card {
    overflow: hidden;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.recipe-card:hover {
    transform: translateY(-3px);
    border-color: #cbd9d0;
    box-shadow: 0 18px 45px rgba(30, 42, 36, 0.1);
}

.recipe-card img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
}

.card-body {
    padding: 1rem;
}

.card-body p,
.article-row p,
.content-panel p,
.markdown-body {
    color: var(--muted);
    line-height: 1.65;
}

.meta-row,
.metric-row {
    flex-wrap: wrap;
    gap: 0.55rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.meta-row {
    justify-content: space-between;
    margin-bottom: 0.8rem;
}

.tag-row {
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0.85rem 0;
}

.tag-row span {
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    background: #edf4f0;
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 800;
}

.macro-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0.85rem 0;
}

.macro-row span {
    padding: 0.4rem 0.55rem;
    border-radius: 8px;
    background: #fff6e0;
    color: #735315;
    font-size: 0.78rem;
    font-weight: 800;
}

.catalog-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0 0 1.5rem;
}

.catalog-summary span {
    padding: 0.9rem 1rem;
    color: var(--muted);
}

.catalog-summary strong {
    display: block;
    color: var(--ink);
    font-size: 1.45rem;
}

.filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.7rem;
    margin: 1.5rem 0;
    padding: 0.8rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.toggle-filter {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 42px;
    padding: 0 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
}

.toggle-filter input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.filter-bar > input,
.filter-bar select {
    min-height: 42px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
    color: var(--ink);
    padding: 0 0.75rem;
    font: inherit;
}

.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.85fr);
    gap: 2rem;
    align-items: center;
    margin-top: 1rem;
}

.detail-media img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 2rem;
}

.content-panel {
    padding: 1.2rem;
}

.content-panel.wide {
    margin-top: 1rem;
}

.ingredient-list {
    display: grid;
    gap: 0.8rem;
    padding: 0;
    list-style: none;
}

.ingredient-list li {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0.3rem 0.8rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--line);
}

.ingredient-list small {
    grid-column: 2;
    color: var(--muted);
}

.nutrition-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.nutrition-grid span {
    padding: 0.85rem;
    border-radius: 8px;
    background: #f2f6f4;
}

.nutrition-grid strong {
    display: block;
    color: var(--primary-dark);
    font-size: 1.45rem;
}

.serving-control {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.5rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.serving-control button {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    font: inherit;
    font-weight: 900;
}

.serving-control strong {
    min-width: 2ch;
    text-align: center;
    font-size: 1.2rem;
}

.serving-control span {
    color: var(--muted);
    font-size: 0.9rem;
}

.smart-tip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-color: #f1d492;
    background: #fffaf0;
}

.planner-promo {
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 1.3rem;
    background:
        linear-gradient(90deg, rgba(255, 250, 240, 0.96), rgba(255, 255, 255, 0.9)),
        var(--surface);
}

.planner-promo p {
    color: var(--muted);
    margin-bottom: 0;
}

.planner-board {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.day-column {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 14px 42px rgba(30, 42, 36, 0.06);
    overflow: hidden;
}

.day-column:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.day-column header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem 1rem;
    border-bottom: 1px solid var(--line);
    background: #f1f6f2;
}

.day-column header div {
    display: grid;
    gap: 0.15rem;
}

.day-column header strong {
    font-size: 1.12rem;
}

.day-column header .day-kicker {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 900;
    text-transform: uppercase;
}

.day-column header .day-energy {
    color: var(--primary);
    font-size: 0.86rem;
    font-weight: 800;
    white-space: nowrap;
}

.day-meals {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.meal-slot {
    display: grid;
    align-content: start;
    gap: 0.45rem;
    min-width: 0;
    padding: 0.9rem;
    border-right: 1px solid var(--line);
}

.meal-slot:last-child {
    border-right: 0;
}

.meal-slot label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.meal-slot select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
    color: var(--ink);
    padding: 0 0.65rem;
    font: inherit;
    font-size: 0.92rem;
}

.meal-slot small {
    color: var(--blue);
    font-weight: 800;
}

.planner-dashboard {
    display: grid;
    grid-template-columns: minmax(280px, 0.75fr) minmax(0, 1.25fr);
    gap: 1rem;
    margin-top: 1rem;
}

.shopping-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.shopping-list li {
    display: grid;
    gap: 0.2rem;
    padding: 0.75rem;
    border-radius: 8px;
    background: #f7f8f5;
}

.shopping-list strong {
    color: var(--primary-dark);
}

.article-list {
    display: grid;
    gap: 0.85rem;
}

.article-list.compact {
    margin-bottom: 2rem;
}

.article-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
}

.article-row time,
.article-header time {
    color: var(--blue);
    font-size: 0.86rem;
    font-weight: 800;
}

.article-page {
    width: min(840px, calc(100% - 2rem));
}

.article-header {
    padding: 2rem 0;
    border-bottom: 1px solid var(--line);
}

.markdown-body {
    padding-top: 2rem;
    font-size: 1.05rem;
}

.markdown-body h2 {
    color: var(--ink);
    margin-top: 2rem;
}

.markdown-body blockquote {
    margin: 1.2rem 0;
    padding: 1rem;
    border-left: 4px solid var(--gold);
    background: #fff9e8;
}

.empty-state,
.loading-text {
    padding: 2rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.loading-text {
    color: var(--muted);
}

#blazor-error-ui {
    display: none;
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1000;
    max-width: min(420px, calc(100% - 2rem));
    padding: 1rem;
    border-radius: 8px;
    background: #8f231f;
    color: white;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
}

#blazor-error-ui .reload {
    margin-left: 0.5rem;
    color: white;
    font-weight: 800;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    margin-left: 0.75rem;
}

/* Botones secundarios y fantasma */
.secondary-button,
.ghost-button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.secondary-button {
    border: 1px solid var(--primary);
    background: var(--surface);
    color: var(--primary);
}

.secondary-button:hover:not(:disabled) {
    background: #eef4f0;
}

.secondary-button:disabled {
    opacity: 0.6;
    cursor: default;
}

.ghost-button {
    border: 1px solid var(--line);
    background: #fbfcfa;
    color: var(--muted);
}

.ghost-button:hover {
    border-color: #cbd9d0;
    color: var(--primary-dark);
}

/* Tarjeta con media y boton de favorito */
.card-media {
    position: relative;
}

.card-media img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
}

.favorite-button {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 38px;
    padding: 0 0.7rem;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--accent);
    font-size: 1.15rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(30, 42, 36, 0.18);
    transition: transform 140ms ease, background 140ms ease;
}

.favorite-button:hover {
    transform: scale(1.06);
}

.favorite-button.is-active {
    background: var(--accent);
    color: white;
}

.favorite-label {
    font-size: 0.82rem;
}

/* Cuando el boton se usa inline (detalle) y no flotante */
.detail-eyebrow-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.detail-eyebrow-row .favorite-button {
    position: static;
    box-shadow: none;
    border: 1px solid var(--line);
    background: #fbfcfa;
}

.detail-eyebrow-row .favorite-button.is-active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.nav-favorites {
    font-size: 1.2rem;
    color: var(--accent) !important;
}

/* Cargar mas */
.load-more {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

/* Planificador: acciones y cabecera de panel */
.planner-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.panel-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.panel-head h2 {
    margin-bottom: 0;
}

.panel-head-actions {
    display: flex;
    gap: 0.5rem;
}

/* Calculadora nutricional */
.calculator-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 1rem;
    margin-top: 1rem;
    align-items: start;
}

.calculator-form .field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.1rem;
}

.calculator-form label {
    display: grid;
    gap: 0.35rem;
}

.calculator-form label > span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.calculator-form input,
.calculator-form select {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
    color: var(--ink);
    padding: 0 0.75rem;
    font: inherit;
}

.calculator-result.placeholder {
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--muted);
}

.calorie-headline {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin: 0.2rem 0 0.3rem;
}

.calorie-headline strong {
    font-size: 3rem;
    color: var(--primary-dark);
    line-height: 1;
}

.calculator-note {
    color: var(--muted);
    font-size: 0.9rem;
}

.macro-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
    margin: 1rem 0;
}

.macro-card {
    display: grid;
    gap: 0.15rem;
    padding: 0.85rem;
    border-radius: 8px;
    background: #f2f6f4;
    border-left: 4px solid var(--primary);
}

.macro-card.protein { border-left-color: var(--accent); }
.macro-card.carbs { border-left-color: var(--gold); }
.macro-card.fat { border-left-color: var(--blue); }
.macro-card.water { border-left-color: var(--primary); }

.macro-card span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.macro-card strong {
    font-size: 1.4rem;
    color: var(--ink);
}

.macro-card small {
    color: var(--muted);
}

/* Impresion: solo la lista de compras */
@media print {
    .topbar,
    .section-header,
    .planner-board,
    .planner-actions,
    .panel-head-actions,
    #blazor-error-ui {
        display: none !important;
    }

    .planner-dashboard {
        grid-template-columns: 1fr;
    }

    .shopping-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .topbar,
    .section-header,
    .article-row {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar {
        position: relative;
        overflow: hidden;
    }

    .topbar-tools {
        position: absolute;
        top: .85rem;
        right: 1rem;
    }

    .main-nav {
        width: 100%;
        max-width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        scrollbar-width: thin;
    }

    .main-nav a {
        flex: 0 0 auto;
        text-align: center;
        white-space: nowrap;
    }

    .topbar-tools {
        align-self: flex-end;
    }

    .guided-catalog-intro {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero-band,
    .detail-layout,
    .content-grid,
    .feature-strip,
    .catalog-summary,
    .planner-dashboard,
    .planner-promo,
    .calculator-layout {
        grid-template-columns: 1fr;
    }

    .hero-panel {
        justify-self: stretch;
    }

    .recipe-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        grid-template-columns: 1fr;
    }

    .article-row {
        grid-template-columns: 1fr;
    }

    .planner-board {
        grid-template-columns: 1fr;
    }

    .day-column:last-child:nth-child(odd) {
        grid-column: auto;
    }
}

@media (max-width: 520px) {
    .page-shell {
        width: min(100% - 1rem, 1180px);
        padding-top: 1rem;
    }

    .hero-band {
        min-height: 0;
        padding: 1.4rem;
    }

    .hero-actions,
    .hero-actions a {
        width: 100%;
    }

    .recipe-view-switch {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .recipe-view-switch a {
        min-width: 0;
    }

    .ingredient-list li,
    .nutrition-grid,
    .shopping-list,
    .calculator-form .field-grid,
    .macro-cards {
        grid-template-columns: 1fr;
    }

    .ingredient-list small {
        grid-column: auto;
    }

    .day-meals {
        grid-template-columns: 1fr;
    }

    .meal-slot {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .meal-slot:last-child {
        border-bottom: 0;
    }

    .serving-control,
    .smart-tip {
        align-items: stretch;
        flex-direction: column;
    }
}

/* ============================================================
   Tema oscuro
   ============================================================ */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #12150f;
    --surface: #1b211a;
    --ink: #e9ede8;
    --muted: #9faba2;
    --line: #2c352b;
    --primary: #5cba8a;
    --primary-dark: #bfe6d2;
    --accent: #e2715d;
    --gold: #e1ad3d;
    --blue: #84b2d4;
}

:root[data-theme="dark"] body {
    background: var(--bg);
}

:root[data-theme="dark"] .topbar {
    background: rgba(18, 21, 15, 0.92);
}

:root[data-theme="dark"] .main-nav a.active,
:root[data-theme="dark"] .main-nav a:hover {
    background: #243024;
    color: var(--primary-dark);
}

:root[data-theme="dark"] .filter-bar > input,
:root[data-theme="dark"] .filter-bar select,
:root[data-theme="dark"] .calculator-form input,
:root[data-theme="dark"] .calculator-form select,
:root[data-theme="dark"] .meal-slot select,
:root[data-theme="dark"] .toggle-filter,
:root[data-theme="dark"] .ghost-button,
:root[data-theme="dark"] .review-form input,
:root[data-theme="dark"] .review-form textarea,
:root[data-theme="dark"] .language-switcher {
    background: #232b22;
    color: var(--ink);
}

:root[data-theme="dark"] .feature-strip article,
:root[data-theme="dark"] .catalog-summary span,
:root[data-theme="dark"] .planner-promo,
:root[data-theme="dark"] .guided-catalog-intro {
    background: var(--surface);
}

:root[data-theme="dark"] .nutrition-grid span,
:root[data-theme="dark"] .shopping-list li,
:root[data-theme="dark"] .macro-card,
:root[data-theme="dark"] .day-column header {
    background: #232b22;
}

:root[data-theme="dark"] .tag-row span {
    background: #25342b;
    color: #bfe6d2;
}

:root[data-theme="dark"] .macro-row span {
    background: #322a16;
    color: #e8cf94;
}

:root[data-theme="dark"] .smart-tip {
    background: #2a2515;
    border-color: #4a4222;
}

:root[data-theme="dark"] .markdown-body blockquote {
    background: #2a2515;
}

:root[data-theme="dark"] .favorite-button {
    background: rgba(27, 33, 26, 0.92);
}

/* ============================================================
   Barra superior: herramientas (idioma + tema)
   ============================================================ */
.topbar-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-actions {
    display: flex;
    gap: 0.4rem;
}

.theme-toggle,
.app-tool-button {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font-size: 1.1rem;
    cursor: pointer;
}

.theme-toggle:hover,
.app-tool-button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.app-tool-button span {
    font-size: 1.25rem;
    line-height: 1;
}

.app-version {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}

.app-action-toast {
    position: fixed;
    top: 82px;
    right: clamp(1rem, 4vw, 3.5rem);
    z-index: 40;
    max-width: min(320px, calc(100vw - 2rem));
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.18);
    font-size: 0.88rem;
    font-weight: 700;
}

.language-switcher {
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    padding: 0 0.6rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

/* ============================================================
   Valoraciones / estrellas
   ============================================================ */
.star-rating {
    display: inline-flex;
    align-items: center;
    gap: 0.1rem;
    color: var(--line);
    font-size: 1.1rem;
    line-height: 1;
}

.star-rating .star.filled {
    color: var(--gold);
}

.star-rating.editable .star {
    border: 0;
    background: none;
    padding: 0 0.05rem;
    color: var(--line);
    font-size: 1.6rem;
    cursor: pointer;
    transition: transform 120ms ease;
}

.star-rating.editable .star:hover {
    transform: scale(1.15);
}

.star-rating.editable .star.filled {
    color: var(--gold);
}

.rating-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.reviews-section {
    margin-top: 1rem;
}

.reviews-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.reviews-average {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.reviews-average strong {
    font-size: 1.3rem;
    color: var(--primary-dark);
}

.reviews-average span {
    color: var(--muted);
    font-size: 0.9rem;
}

.reviews-list {
    display: grid;
    gap: 0.85rem;
    margin: 1.2rem 0;
    padding: 0;
    list-style: none;
}

.reviews-list li {
    padding: 0.9rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

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

.review-head time {
    color: var(--muted);
    font-size: 0.82rem;
    margin-left: auto;
}

.review-form {
    display: grid;
    gap: 0.7rem;
    margin-top: 1.4rem;
    padding-top: 1.4rem;
    border-top: 1px solid var(--line);
}

.review-form-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.review-form input,
.review-form textarea {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
    color: var(--ink);
    padding: 0.6rem 0.75rem;
    font: inherit;
}

.review-form input {
    flex: 1;
    min-width: 200px;
    min-height: 42px;
}

.review-form .primary-button {
    justify-self: start;
    padding-inline: 1.4rem;
}

@media (max-width: 860px) {
    .topbar-tools {
        justify-content: flex-end;
    }

    .brand {
        padding-right: 190px;
    }

    .app-action-toast {
        top: 70px;
    }
}

@media (max-width: 520px) {
    .topbar-tools {
        gap: 0.3rem;
    }

    .theme-toggle,
    .app-tool-button {
        width: 36px;
        height: 36px;
    }

    .brand {
        padding-right: 170px;
    }
}

/* ============================================================
   Recetas guiadas (checklist + barra de progreso)
   ============================================================ */
.step-badge {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    background: rgba(40, 95, 72, 0.92);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 800;
}

.guided-header {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 2rem;
    align-items: center;
    margin-top: 1rem;
}

.guided-media img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
}

.guided-intro .text-link {
    display: inline-block;
    margin-bottom: 0.6rem;
    font-weight: 800;
}

.progress-bar-sticky {
    position: sticky;
    top: 72px;
    z-index: 15;
    margin: 1.5rem 0 0.5rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 10px 30px rgba(30, 42, 36, 0.08);
}

.progress-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

.progress-meta strong {
    color: var(--primary-dark);
}

.progress-meta span {
    color: var(--muted);
    font-size: 0.9rem;
}

.progress-meta .ghost-button {
    margin-left: auto;
    min-height: 34px;
    padding: 0.3rem 0.8rem;
}

.progress-track {
    height: 12px;
    border-radius: 999px;
    background: #e7ece8;
    overflow: hidden;
}

:root[data-theme="dark"] .progress-track {
    background: #2c352b;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), #4f9e78);
    transition: width 320ms ease;
}

.progress-fill.complete {
    background: linear-gradient(90deg, var(--gold), var(--primary));
}

.guided-done {
    margin: 1rem 0;
    padding: 1rem 1.2rem;
    border: 1px solid #cde7d8;
    border-radius: 8px;
    background: #eafaf1;
    color: var(--primary-dark);
    font-weight: 800;
}

:root[data-theme="dark"] .guided-done {
    background: #1f3a2c;
    border-color: #2f5a44;
    color: #bfe6d2;
}

.guided-grid {
    margin-top: 1rem;
}

.detail-mode-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(520px, 100%);
    margin: 1.25rem auto;
    padding: 0.25rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.detail-mode-switch a {
    padding: 0.7rem 1rem;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 800;
    text-align: center;
    text-decoration: none;
}

.detail-mode-switch a.active {
    background: var(--primary);
    color: white;
}

.cooking-progress {
    position: sticky;
    top: 84px;
    z-index: 15;
    margin-bottom: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: 0 10px 30px rgba(30, 42, 36, 0.1);
    backdrop-filter: blur(12px);
}

.cooking-progress .progress-meta {
    justify-content: space-between;
}

.cooking-progress .eyebrow {
    margin-bottom: 0.2rem;
}

.cooking-progress-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cooking-progress-actions > span {
    color: var(--primary);
    font-size: 1.15rem;
    font-weight: 900;
}

.cooking-grid {
    margin-top: 0;
}

.cooking-grid .panel-head > span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.cooking-note {
    margin-top: 1rem;
}

.recipe-overview-grid {
    margin-top: 1.25rem;
}

.recipe-cooking-section {
    margin-top: 1.25rem;
}

.recipe-timing-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .75rem;
    margin-top: 1rem;
}

.recipe-timing-grid span {
    padding: .85rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--muted);
}

.recipe-timing-grid strong {
    display: block;
    color: var(--ink);
    font-size: 1.25rem;
}

.planner-status {
    margin-bottom: 1.25rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.planner-status-copy,
.planner-status-metrics,
.day-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.planner-status-copy > span {
    font-weight: 800;
    color: var(--accent);
}

.planner-status .progress-track {
    margin: .75rem 0;
}

.planner-status-metrics {
    justify-content: flex-start;
    flex-wrap: wrap;
    color: var(--muted);
}

.planner-status-metrics span + span::before {
    content: "·";
    margin-right: 1rem;
}

.day-summary {
    align-items: flex-end;
    flex-direction: column;
    gap: .2rem;
}

.day-state {
    color: var(--accent);
    font-size: .75rem;
    font-weight: 700;
}

.checklist {
    display: grid;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.checklist li {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    transition: background 140ms ease, border-color 140ms ease;
}

.checklist li.checked {
    background: #f1f8f4;
    border-color: #cde6d9;
}

:root[data-theme="dark"] .checklist li.checked {
    background: #1f2c24;
    border-color: #325040;
}

.checklist label {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.75rem 0.85rem;
    cursor: pointer;
    line-height: 1.5;
}

.checklist input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 0.1rem;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.checklist li.checked label > span:last-child {
    color: var(--muted);
    text-decoration: line-through;
}

.checklist.steps .step-number {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
}

.checklist li.checked .step-number {
    background: var(--muted);
}

@media (max-width: 860px) {
    .guided-header,
    .guided-grid {
        grid-template-columns: 1fr;
    }

    .progress-bar-sticky,
    .cooking-progress {
        position: static;
    }
}

@media (max-width: 560px) {
    .recipe-timing-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   Cuenta / autenticacion
   ============================================================ */
.account-layout {
    display: grid;
    place-items: start center;
    margin-top: 1rem;
}

/* ============================================================
   Contacto
   ============================================================ */
.contact-heading {
    max-width: 760px;
}

.contact-layout {
    display: grid;
    grid-template-columns: minmax(240px, .7fr) minmax(0, 1.3fr);
    gap: 1.25rem;
    align-items: start;
}

.contact-options {
    display: grid;
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--line);
}

.contact-options article {
    display: grid;
    gap: .35rem;
    padding: 1rem;
    background: var(--surface);
}

.contact-options strong {
    color: var(--primary-dark);
}

.contact-options span {
    color: var(--muted);
    line-height: 1.5;
}

.contact-form-panel {
    padding: 1.4rem;
}

.contact-form,
.contact-form label {
    display: grid;
    gap: .4rem;
}

.contact-form {
    gap: 1rem;
}

.contact-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.contact-form label > span {
    color: var(--muted);
    font-size: .82rem;
    font-weight: 800;
}

.contact-form input,
.contact-form select,
.contact-form textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
    color: var(--ink);
    padding: .7rem .75rem;
    font: inherit;
}

.contact-form textarea {
    min-height: 170px;
    resize: vertical;
}

.contact-form .validation-message {
    color: #8f231f;
    font-size: .82rem;
}

.contact-form .primary-button {
    justify-self: start;
    min-width: 160px;
}

.contact-success {
    padding: .5rem;
}

:root[data-theme="dark"] .contact-form input,
:root[data-theme="dark"] .contact-form select,
:root[data-theme="dark"] .contact-form textarea {
    background: #232b22;
}

@media (max-width: 760px) {
    .contact-layout,
    .contact-field-grid {
        grid-template-columns: 1fr;
    }
}

.account-card {
    width: min(440px, 100%);
    padding: 1.6rem;
}

.account-form {
    display: grid;
    gap: 0.9rem;
    margin-top: 0.5rem;
}

.account-form label {
    display: grid;
    gap: 0.35rem;
}

.account-form label > span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.account-form input {
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
    color: var(--ink);
    padding: 0 0.75rem;
    font: inherit;
}

:root[data-theme="dark"] .account-form input {
    background: #232b22;
}

.account-toggle {
    margin-top: 1rem;
    background: none;
    border: 0;
    cursor: pointer;
    font: inherit;
}

.form-message {
    margin: 0;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
}

.form-message.error {
    background: #fdecea;
    color: #8f231f;
}

.form-message.success {
    background: #eafaf1;
    color: var(--primary-dark);
}

:root[data-theme="dark"] .form-message.error {
    background: #3a1f1d;
    color: #f1b0ab;
}

:root[data-theme="dark"] .form-message.success {
    background: #1f3a2c;
    color: #bfe6d2;
}

/* Reconexion de Blazor */
#components-reconnect-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10001;
    place-items: center;
    padding: 1rem;
    background: rgb(21 31 26 / 64%);
    backdrop-filter: blur(5px);
    transition: visibility 0s linear 600ms;
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: grid;
}

.reconnect-dialog {
    width: min(430px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 24px 70px rgb(9 24 17 / 32%);
    padding: 1.75rem;
    text-align: center;
}

.reconnect-brand {
    display: grid;
    width: 42px;
    height: 42px;
    margin: 0 auto 1.25rem;
    place-items: center;
    border-radius: 7px;
    background: var(--primary);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 900;
}

.reconnect-state {
    display: none;
    justify-items: center;
}

.components-reconnect-show .reconnecting-state,
.components-reconnect-retrying .reconnecting-state,
.components-reconnect-failed .failed-state,
.components-reconnect-rejected .rejected-state {
    display: grid;
}

.reconnect-state .eyebrow {
    margin: 0 0 .45rem;
}

.reconnect-state h2 {
    margin: 0;
    color: var(--ink);
    font-size: 1.45rem;
    line-height: 1.2;
}

.reconnect-state > p:not(.eyebrow):not(.reconnect-attempt) {
    max-width: 34ch;
    margin: .8rem 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.reconnect-spinner {
    width: 34px;
    height: 34px;
    margin-bottom: 1rem;
    border: 3px solid var(--line);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: reconnect-spin .85s linear infinite;
}

.reconnect-attempt {
    margin: 1rem 0 0;
    padding: .5rem .7rem;
    border-radius: 6px;
    background: #edf5f0;
    color: var(--primary-dark);
    font-size: .86rem;
}

.reconnect-status-icon {
    display: grid;
    width: 38px;
    height: 38px;
    margin-bottom: 1rem;
    place-items: center;
    border: 2px solid #b4423d;
    border-radius: 50%;
    color: #9c302b;
    font-size: 1.15rem;
    font-weight: 900;
}

.reconnect-actions {
    display: flex;
    justify-content: center;
    gap: .65rem;
    margin-top: 1.25rem;
}

.reconnect-primary,
.reconnect-secondary {
    min-height: 44px;
    border-radius: 7px;
    padding: .7rem 1rem;
    cursor: pointer;
    font: inherit;
    font-weight: 850;
}

.reconnect-primary {
    margin-top: 1.25rem;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
}

.reconnect-actions .reconnect-primary {
    margin-top: 0;
}

.reconnect-secondary {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink);
}

.reconnect-primary:hover {
    background: var(--primary-dark);
}

.reconnect-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.reconnect-primary:focus-visible,
.reconnect-secondary:focus-visible {
    outline: 3px solid rgb(40 95 72 / 28%);
    outline-offset: 2px;
}

:root[data-theme="dark"] #components-reconnect-modal {
    background: rgb(5 10 7 / 74%);
}

:root[data-theme="dark"] .reconnect-status-icon {
    border-color: #e1847f;
    color: #f2aaa5;
}

:root[data-theme="dark"] .reconnect-attempt {
    background: #25352d;
    color: #c2dfd0;
}

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

@media (prefers-reduced-motion: reduce) {
    .reconnect-spinner {
        animation: none;
    }
}

@media (max-width: 480px) {
    .reconnect-dialog {
        padding: 1.4rem 1rem;
    }

    .reconnect-actions {
        display: grid;
        width: 100%;
    }

    .reconnect-primary,
    .reconnect-secondary {
        width: 100%;
    }
}
