* { box-sizing: border-box; }

:root {
    --background: #f4f6f8;
    --surface: #ffffff;
    --text: #222222;
    --muted: #68707c;
    --border: #e7e9ed;
    --primary: #2b6ef3;
    --primary-hover: #1f58c7;
    --gold: #f5b301;
    --shadow: 0 10px 28px rgba(20, 30, 50, 0.08);
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell {
    width: min(1100px, calc(100% - 40px));
    margin: 40px auto;
}

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

.logo {
    font-size: 34px;
    font-weight: 750;
    letter-spacing: -0.04em;
}

.subtitle { margin-top: 5px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.search-input {
    width: 310px;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(20, 30, 50, 0.05);
    outline: none;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(43, 110, 243, 0.13);
}

.primary-button, .secondary-button {
    min-height: 44px;
    padding: 10px 17px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 650;
}

.primary-button { background: var(--primary); color: white; }
.primary-button:hover { background: var(--primary-hover); }
.primary-button:disabled { cursor: wait; opacity: 0.7; }
.secondary-button { border-color: var(--border); background: var(--surface); color: var(--text); }
.secondary-button:hover:not(:disabled) { background: #f7f8fa; }

.library-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
    color: var(--muted);
}

.recipe-grid { display: flex; flex-direction: column; gap: 20px; }
.recipe-card-link { color: inherit; text-decoration: none; }

.recipe-card {
    display: flex;
    min-height: 180px;
    overflow: hidden;
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.recipe-card-link:hover .recipe-card {
    transform: translateY(-3px);
    box-shadow: 0 14px 34px rgba(20, 30, 50, 0.12);
}

.recipe-image {
    width: 180px;
    min-width: 180px;
    height: 180px;
    overflow: hidden;
    background: #eceff3;
}

.recipe-image img { width: 100%; height: 100%; display: block; object-fit: cover; }
.image-placeholder { height: 100%; display: grid; place-items: center; font-size: 64px; }

.recipe-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 22px;
}

.recipe-card h2 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }

.recipe-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 13px;
}

.rating { display: inline-flex; gap: 3px; }

.star {
    color: #d3d7dd;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    transition: color 120ms ease, transform 120ms ease;
}

.star:hover { transform: scale(1.08); }
.star.active, .star.hovered { color: var(--gold); }

.make-again-button {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    border-radius: 999px;
    padding: 7px 12px;
    background: #f1f3f6;
    color: #5f6875;
    font-size: 13px;
    font-weight: 650;
}

.make-again-button.active { background: #ffe7ee; color: #c92f64; }

.meta-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 7px 12px;
    background: #f1f3f6;
    color: #5f6875;
    font-size: 13px;
    font-weight: 600;
}

.recipe-description { margin: 14px 0 18px; color: #515a66; line-height: 1.55; }

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

.recipe-source { font-weight: 700; }
.recipe-added-date { margin-top: 3px; color: var(--muted); font-size: 13px; }
.card-arrow { color: #a0a6af; font-size: 25px; }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty-state-icon { font-size: 45px; }

.modal {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(17, 23, 34, 0.52);
    backdrop-filter: blur(4px);
}

.modal.open {
    display: flex !important;
}

.modal-panel {
    width: min(520px, 100%);
    padding: 28px;
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 28px 80px rgba(10, 20, 40, 0.3);
}

.modal-header { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.modal-header h2 { margin: 0; font-size: 26px; }
.modal-header p { margin: 7px 0 0; color: var(--muted); line-height: 1.45; }

.icon-button {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: #f0f2f5;
    color: #555;
    font-size: 25px;
    line-height: 1;
}

.form-group label { display: block; margin-bottom: 8px; font-weight: 700; }
.form-group input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; outline: none; }
.form-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(43, 110, 243, 0.13); }
.field-help { margin-top: 7px; color: var(--muted); font-size: 13px; }

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
    color: #9aa0aa;
    font-size: 12px;
    font-weight: 750;
}

.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 27px; }

.import-status {
    margin-top: 20px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #eef4ff;
    color: #234a94;
    line-height: 1.45;
}

.import-status.error { background: #fff0f0; color: #9a2525; }

@media (max-width: 800px) {
    .app-shell { width: min(100% - 28px, 1100px); margin: 22px auto; }
    .topbar { align-items: stretch; flex-direction: column; }
    .topbar-actions { align-items: stretch; flex-direction: column; }
    .search-input { width: 100%; }
    .recipe-card { flex-direction: column; }
    .recipe-image { width: 100%; min-width: 100%; height: 220px; }
    .planner-shell {width: calc(100% - 28px); padding: 16px 0;}
}

/* Recipe detail image */

@media (max-width: 800px) {
    .detail-hero {
        height: 200px;
    }
}

/* Recipe detail page */

.detail-shell {
    width: min(1000px, calc(100% - 40px));
    margin: 32px auto 60px;
}

.back-link {
    display: inline-block;
    margin-bottom: 16px;
    color: #445064;
    text-decoration: none;
    font-weight: 650;
}

.recipe-detail-card {
    overflow: hidden;
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.detail-hero {
    width: 100%;
    aspect-ratio: 16 / 6;
    overflow: hidden;
    background: #eceff3;
}

.detail-hero img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

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

    margin-bottom:40px;

}
.detail-header h1 {
    margin: 0 0 14px;
    font-size: clamp(32px, 5vw, 46px);
    letter-spacing: -0.04em;
}

.detail-header p {
    margin: 0;
    color: #535d69;
    line-height: 1.6;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 18px;
    color: var(--muted);
}

.source-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-top: 26px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fafbfc;
}

.section-label {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.source-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.source-actions a {
    text-align: center;
    text-decoration: none;
}

.detail-section {
    margin-top: 34px;
}

.detail-section h2 {
    margin-bottom: 16px;
    font-size: 25px;
}

.ingredient-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ingredient-list li {
    display: flex;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.45;
}

.ingredient-check {
    width: 19px;
    height: 19px;
    margin-top: 1px;
    flex: 0 0 auto;
    border: 2px solid #c5cad2;
    border-radius: 5px;
}

.instruction-list {
    margin: 0;
    padding-left: 25px;
}

.instruction-list li {
    margin-bottom: 18px;
    padding-left: 8px;
    line-height: 1.65;
}

@media (max-width: 800px) {
    .detail-shell {
        width: min(100% - 24px, 1000px);
        margin-top: 18px;
    }

    .detail-hero {
        height: 180px;
    }

    .detail-content {
        padding: 20px;
    }

    .source-panel {
        align-items: stretch;
        flex-direction: column;
    }

    .source-actions {
        flex-direction: column;
    }

    .source-actions a {
        width: 100%;
    }
}

.notes-textarea{
    width:100%;
    min-height:180px;
    padding:16px;
    border:1px solid var(--border);
    border-radius:12px;
    resize:vertical;
    font:inherit;
    line-height:1.6;
}

.notes-actions{
    margin-top:16px;
    display:flex;
    justify-content:flex-end;
}

.section-header{

    display:flex;

    justify-content:space-between;

    align-items:center;

    gap:20px;

    margin-bottom:18px;

}

.section-header h2{

    margin:0;

}

/* ---------- Shopping List ---------- */

.shopping-list{

    margin-top:30px;

    background:white;

    border-radius:16px;

    box-shadow:var(--shadow);

    overflow:hidden;

}

.shopping-item{

    display:flex;

    align-items:center;

    gap:16px;

    padding:18px 24px;

    border-bottom:1px solid var(--border);

    font-size:18px;

}

.shopping-item:last-child{

    border-bottom:none;

}

.shopping-item input{

    width:22px;

    height:22px;

}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.meal-day-card {
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,.05);
}

.meal-day-card h2 {
    margin: 0 0 16px;
    font-size: 1.25rem;
}

.meal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-top: 1px solid #f0f0f0;
}

.meal-row:first-child {
    border-top: none;
}

.meal-row a {
    text-decoration: none;
    font-weight: 600;
    color: #222;
}

.meal-row a:hover {
    color: #2563eb;
}

.empty-day {
    color: #888;
    font-style: italic;
    padding: 12px 0;
}

/* ---------- Meal Cards ---------- */

.meal-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    padding: 12px;
    margin-bottom: 12px;

    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 12px;

    transition: all .2s ease;
}

.meal-card:hover {
    background: white;
    border-color: #d5d5d5;
    box-shadow: 0 4px 10px rgba(0,0,0,.08);
}

.meal-card-link {
    display: flex;
    align-items: center;
    flex: 1;
    text-decoration: none;
    color: inherit;
}

.meal-card-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.meal-card-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}

.meal-title {
    font-size: 1rem;
    font-weight: 700;
    color: #222;
}

.meal-source {
    margin-top: 4px;
    font-size: .9rem;
    color: #777;
}

.delete-meal-btn {
    border: none;
    background: transparent;

    cursor: pointer;

    font-size: 1.2rem;

    opacity: .55;

    transition: .2s;
}

.delete-meal-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}
.meal-thumb {
    width: 72px;
    height: 72px;

    min-width: 72px;
    max-width: 72px;

    object-fit: cover;
    object-position: center;

    border-radius: 10px;

    display: block;
}

/* ---------- Week Header ---------- */

.week-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    background: white;

    border: 1px solid #e8e8e8;
    border-radius: 16px;

    padding: 18px 24px;
    margin-bottom: 24px;

    box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

.week-info {
    text-align: center;
    flex: 1;
}

.week-label {
    font-size: 1.2rem;
    font-weight: 700;
    color: #222;
}

.week-summary {
    margin-top: 4px;
    font-size: .9rem;
    color: #777;
}

.week-nav {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 36px;
    height: 36px;

    border: 1px solid #ddd;
    border-radius: 50%;

    background: white;

    text-decoration: none;
    color: #333;

    font-size: 1.2rem;
    font-weight: 600;

    transition: all .2s ease;
}

.week-nav:hover {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

@media (max-width: 768px) {

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .page-header h1 {
        margin: 0;
    }

    .page-header .primary-button {
        width: 100%;
    }

}

@media (max-width: 768px) {

    .meal-day-card {
        padding: 16px;
    }

}

/* ======================================================
   Monthly Planner
====================================================== */

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

.planner-title {
    text-align: center;
}

.planner-title h1,
.planner-title h2 {
    margin: 0;
}

.planner-title h1 {
    font-size: 2rem;
}

.planner-title h2 {
    font-size: 1.4rem;
}

.planner-title p {
    margin: 6px 0 0;
    color: #777;
}

.month-nav {
    width: 44px;
    height: 44px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 1px solid #ddd;
    border-radius: 50%;

    background: white;

    cursor: pointer;

    font-size: 1.25rem;
    text-decoration: none;

    transition: .2s;
}

.month-nav:hover {
    background: #2563eb;
    color: white;
}

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

.planner-grid {

    display: grid;

    grid-template-columns: repeat(7, minmax(140px, 1fr));

    gap: 14px;

    align-items: start;

}

.planner-day-header {

    text-align: center;

    font-weight: 700;

    color: #666;

    padding-bottom: 10px;

}

.planner-cell {

    min-height: 190px;

    display: flex;
    flex-direction: column;

    gap: 10px;

    padding: 12px;

    background: white;

    border: 1px solid #ececec;
    border-radius: 16px;

    box-shadow: 0 2px 10px rgba(0,0,0,.05);

    transition: .2s;

}

.planner-cell:hover {

    box-shadow: 0 6px 18px rgba(0,0,0,.08);

}

.planner-date {

    font-weight: 700;

}

/* ======================================================
   Planner Meals
====================================================== */

.planner-meals {

    display: flex;
    flex-direction: column;

    gap: 8px;

    flex: 1;

    margin: 8px 0;

}

.planner-meal {

    display: flex;
    align-items: center;

    gap: 10px;

    padding: 8px;

    background: #f8f9fc;

    border: 1px solid #ececec;
    border-radius: 10px;

    color: inherit;
    text-decoration: none;

    transition: .2s;

}

.planner-meal:hover {

    background: white;

    border-color: #2563eb;

    transform: translateY(-1px);

}

.planner-meal-thumb {

    width: 38px;
    height: 38px;

    border-radius: 8px;

    object-fit: cover;

    flex-shrink: 0;

}

.planner-meal-title {

    flex: 1;

    font-size: .78rem;

    font-weight: 600;

    line-height: 1.25;

    color: #1f2937;

    display: -webkit-box;

    -webkit-box-orient: vertical;

    -webkit-line-clamp: 2;
    line-clamp: 2;

    overflow: hidden;

}

.planner-meal-link {

    display:flex;

    align-items:center;

    gap:10px;

    flex:1;

    text-decoration:none;

    color:inherit;

}

/* ======================================================
   Add Meal Button
====================================================== */

.planner-add {

    margin-top: auto;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 8px 10px;

    background: #eef4ff;

    border-radius: 10px;

    color: #2563eb;

    text-decoration: none;

    font-size: .85rem;
    font-weight: 600;

    transition: .2s;

}

.planner-add:hover {

    background: #2563eb;

    color: white;

}

.planner-delete{

    position:absolute;

    top:6px;

    right:6px;

    opacity:0;

    border:none;

    background:white;

    width:24px;

    height:24px;

    border-radius:50%;

    cursor:pointer;

    transition:.2s;

    box-shadow:0 2px 8px rgba(0,0,0,.15);

}

.planner-meal:hover .planner-delete{

    opacity:1;

}

.planner-delete:hover{

    background:#ef4444;

    color:white;

}

/* ======================================================
   Date Picker Mode
====================================================== */

.picker-header {

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 20px;

    margin-bottom: 16px;

}

.picker-header .planner-title {

    flex: 1;

    text-align: center;

}

.picker-header .planner-title h2 {

    margin: 0;

    font-size: 1.4rem;

}

.picker-header .month-nav {

    width: 36px;
    height: 36px;

    display: flex;
    align-items: center;
    justify-content: center;

    text-decoration: none;

    flex-shrink: 0;

}

.planner-grid.picker {

    grid-template-columns: repeat(7, 1fr);

    gap: 6px;

    max-width: 340px;

    margin: 0 auto;

}

.planner-grid.picker .planner-day-header {

    font-size: .72rem;

    font-weight: 600;

    padding-bottom: 4px;

}

.planner-grid.picker .planner-cell {

    min-height: 48px;

    padding: 0;

    border-radius: 12px;

    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    box-shadow: none;

}

.planner-grid.picker .planner-cell:hover {

    background: #eef4ff;

    border-color: #2563eb;

    box-shadow: 0 3px 10px rgba(37,99,235,.15);

}

.planner-grid.picker .planner-date {

    margin: 0;

    font-size: .95rem;

    font-weight: 600;

    text-align: center;

}

.planner-grid.picker .planner-meals,
.planner-grid.picker .planner-add {

    display: none;

}
/* ======================================================
   Today
====================================================== */

.planner-today {

    width: 34px;
    height: 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    margin: auto;

    background: #2563eb;

    color: white;

    border-radius: 50%;

}

/* ======================================================
   Days Outside Current Month
====================================================== */

.planner-other-month {

    opacity: .35;

}

.planner-grid.picker .planner-other-month {

    visibility: hidden;

    pointer-events: none;

}
/* ======================================================
   Mobile Monthly Planner
====================================================== */

@media (max-width: 700px) {

    .planner-shell {
        width: 100% !important;
        max-width: none !important;

        margin: 0 !important;
        padding: 0 !important;
    }

    .planner-header {
        margin-bottom: 20px;
    }

    .planner-title h1 {
        font-size: 1.6rem;
    }

    .planner-title p {
        font-size: .85rem;
    }

    .month-nav {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }

    /*
       Turn the 7-column calendar into
       a vertical agenda.
    */

    .planner-grid:not(.picker) {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    /*
       Sunday / Monday / Tuesday headers
       aren't needed in agenda mode.
    */

    .planner-grid:not(.picker) > .planner-day-header {
        display: none;
    }

    /*
       Hide dates belonging to the
       previous / next month.
    */

    .planner-grid:not(.picker) > .planner-other-month {
        display: none;
    }

    /*
       Each calendar day becomes a card.
    */

    .planner-grid:not(.picker) > .planner-cell {
        min-height: 0;
        width: 100%;

        padding: 14px;

        gap: 8px;

        border-radius: 14px;

        box-shadow: 0 2px 8px rgba(0,0,0,.05);
    }

    /*
       Date moves to the left instead
       of being centered like desktop.
    */

    .planner-grid:not(.picker) .planner-date {
        width: auto;
        height: auto;

        margin: 0;

        display: block;

        background: none;
        color: var(--text);

        font-size: .85rem;
        font-weight: 750;
    }

    /*
       Keep today highlighted.
    */

    .planner-grid:not(.picker) .planner-today {
        width: fit-content;
        height: auto;

        padding: 5px 10px;

        background: var(--primary);
        color: white;

        border-radius: 999px;
    }

    .planner-grid:not(.picker) .planner-meals {
        margin: 2px 0;
        gap: 6px;
    }

    /*
       Meals become larger, touch-friendly rows.
    */

    .planner-grid:not(.picker) .planner-meal {
        position: relative;

        padding: 10px;

        border-radius: 10px;
    }

    .planner-grid:not(.picker) .planner-meal-thumb {
        width: 46px;
        height: 46px;

        border-radius: 8px;
    }

    .planner-grid:not(.picker) .planner-meal-title {
        font-size: .95rem;

        -webkit-line-clamp: 3;
        line-clamp: 3;
    }

    /*
       Delete needs to be visible on touch
       devices because there is no hover.
    */

    .planner-grid:not(.picker) .planner-delete {
        position: static;

        width: 34px;
        height: 34px;

        flex-shrink: 0;

        opacity: .6;

        box-shadow: none;

        background: transparent;
    }

    /*
       Full-width Add Meal button.
    */

    .planner-grid:not(.picker) .planner-add {
        width: 100%;

        margin-top: 2px;

        padding: 10px;

        box-sizing: border-box;
    }

}

/* ======================================================
   Printable Monthly Planner
====================================================== */

@media print {

    @page {
        size: landscape;
        margin: 0.3in;
    }

    body {
        margin: 0;
        padding: 0;
        background: white;
    }

    .planner-shell {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .back-link,
    .month-nav,
    .planner-print-button,
    .planner-add,
    .planner-delete {
        display: none !important;
    }

    .planner-header {
        margin: 0 0 12px 0;
        justify-content: center;
    }

    .planner-title h1 {
        margin: 0;
        font-size: 24px;
    }

    .planner-title p {
        display: none;
    }

    /* Fixed monthly calendar grid */

    .planner-grid,
    .planner-grid:not(.picker) {
        display: grid !important;

        width: 100% !important;
        height: 5.6in !important;

        grid-template-columns: repeat(7, minmax(0, 1fr)) !important;

        /*
        Header + six IDENTICAL calendar rows.
        Content cannot resize the rows.
        */
        grid-template-rows: 0.25in repeat(6, minmax(0, 1fr)) !important;

        gap: 4px !important;
    }


    /* Day-of-week headers */

    .planner-grid:not(.picker) > .planner-day-header {
        display: block !important;

        min-width: 0;
        padding: 3px !important;

        font-size: 10px;
    }


    /* Every date box is exactly the same size */

    .planner-grid:not(.picker) > .planner-cell {
        display: flex !important;
        flex-direction: column !important;

        width: auto !important;
        min-width: 0 !important;
        min-height: 0 !important;
        height: auto !important;

        padding: 5px !important;

        overflow: hidden !important;

        border: 1px solid #999 !important;
        border-radius: 0 !important;

        box-shadow: none !important;
    }


    /* Restore outside-month cells */

    .planner-grid:not(.picker) > .planner-other-month {
        display: flex !important;
        opacity: 0.35 !important;
    }


    /* Date number */

    .planner-grid:not(.picker) .planner-date {
        width: auto !important;
        height: auto !important;

        margin: 0 0 3px 0 !important;
        padding: 0 !important;

        display: block !important;

        background: none !important;
        color: inherit !important;

        font-size: 10px !important;
        line-height: 1 !important;

        flex: 0 0 auto;
    }


    /* Meals must stay INSIDE their day */

    .planner-grid:not(.picker) .planner-meals {
        min-width: 0 !important;
        min-height: 0 !important;

        flex: 1 1 auto !important;

        margin: 0 !important;

        overflow: hidden !important;
    }


    /* Individual meal */

    .planner-grid:not(.picker) .planner-meal {
        min-width: 0 !important;

        padding: 2px 0 !important;
        margin: 0 !important;

        border: 0 !important;
        background: none !important;
    }


    /* No images on paper */

    .planner-grid:not(.picker) .planner-meal-thumb {
        display: none !important;
    }


    /* Recipe text shrinks/wraps inside the fixed box */

    .planner-grid:not(.picker) .planner-meal-link {
        min-width: 0 !important;

        padding: 0 !important;
    }

    .planner-grid:not(.picker) .planner-meal-title {
        display: -webkit-box !important;

        min-width: 0 !important;

        overflow: hidden !important;

        font-size: 9px !important;
        line-height: 1.15 !important;

        white-space: normal !important;

        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;

        line-clamp: 2;
    }


    /* Screen-only controls */

    .planner-add,
    .planner-delete {
        display: none !important;
    }

    .planner-other-month {
        opacity: 0.35;
    }

    .planner-date {
        font-size: 12px;
        margin-bottom: 4px;
    }

    .planner-today {
        background: none;
        color: inherit;
    }

    .planner-meal {
        padding: 3px 0;
        border: 0;
        background: none;
    }

    .planner-meal-thumb {
        display: none;
    }

    .planner-meal-title {
        font-size: 11px;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }

    .planner-meal-link {
        padding: 0;
    }

    #addMealModal {
        display: none !important;
    }

}

/* ======================================================
   Meal History
====================================================== */

.history-header {
    margin-bottom: 24px;
}

.history-header h1 {
    margin: 0;
    font-size: 2rem;
}

.history-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 16px;
    align-items: center;
}

.history-date {
    color: var(--muted);
    font-size: .9rem;
    font-weight: 650;
}

.history-meal {
    display: flex;
    align-items: center;
    gap: 14px;

    min-height: 72px;
    padding: 12px 16px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;

    color: inherit;
    text-decoration: none;

    box-shadow: 0 2px 8px rgba(20, 30, 50, .04);
}

a.history-meal:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(20, 30, 50, .08);
}

.history-thumb {
    width: 54px;
    height: 54px;
    flex-shrink: 0;

    border-radius: 10px;
    object-fit: cover;
}

.history-custom-icon {
    width: 54px;
    height: 54px;

    display: grid;
    place-items: center;

    flex-shrink: 0;

    border-radius: 10px;
    background: #f1f3f6;

    font-size: 24px;
}

.history-meal-content {
    display: flex;
    flex-direction: column;
    gap: 4px;

    flex: 1;
}

.history-meal-content strong {
    font-size: 1rem;
}

.history-meal-content span {
    color: var(--muted);
    font-size: .85rem;
}

.history-arrow {
    color: #a0a6af;
    font-size: 22px;
}

@media (max-width: 700px) {

    .history-item {
        display: block;
    }

    .history-date {
        margin: 0 0 6px 4px;
    }

    .history-meal {
        width: 100%;
    }

}

/* ======================================================
   Meal Suggestions
====================================================== */

.suggestions-header {
    margin-bottom: 32px;
}

.suggestions-header h1 {
    margin: 0;
    font-size: 2rem;
}

.suggestions-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.suggestion-section {
    margin-bottom: 42px;
}

.suggestion-section-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;

    margin-bottom: 16px;
}

.suggestion-section-header h2 {
    margin: 0;
    font-size: 1.35rem;
}

.suggestion-section-header p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: .9rem;
}

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

.suggestion-card {
    min-width: 0;
    overflow: hidden;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;

    box-shadow: 0 3px 12px rgba(20, 30, 50, .06);
}

.suggestion-image {
    display: block;

    width: 100%;
    height: 180px;

    object-fit: cover;
}

.suggestion-content {
    display: flex;
    flex-direction: column;
    gap: 12px;

    padding: 16px;
}

.suggestion-title {
    color: inherit;
    text-decoration: none;

    font-size: 1.05rem;
    font-weight: 750;
    line-height: 1.3;
}

.suggestion-title:hover {
    color: var(--primary);
}

.suggestion-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.suggestion-meta span {
    padding: 5px 8px;

    background: #f1f3f6;
    border-radius: 7px;

    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.suggestion-plan-button {
    align-self: flex-start;
    margin-top: 2px;

    text-decoration: none;
}


/* Mobile */

@media (max-width: 800px) {

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

    .suggestion-section-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .suggestion-image {
        height: 200px;
    }

}

/* ---------- Recipe Editor ---------- */

.recipe-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.recipe-title-row h1 {
    flex: 1;
}

.recipe-edit-panel {
    margin: 28px 0 34px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fafbfc;
}

.edit-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 18px;
}

.edit-field label {
    font-size: 13px;
    font-weight: 750;
    color: var(--muted);
}

.edit-field input,
.edit-field textarea,
.edit-ingredient-row input,
.edit-instruction-row textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: white;
    font: inherit;
    box-sizing: border-box;
}

.edit-field textarea,
.edit-instruction-row textarea {
    resize: vertical;
    line-height: 1.5;
}

.recipe-edit-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.recipe-edit-section {
    margin-top: 28px;
}

.recipe-edit-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
}

.recipe-edit-section-header h2 {
    margin: 0;
    font-size: 20px;
}

.edit-ingredient-row {
    display: grid;
    grid-template-columns: 90px 110px minmax(180px, 1fr) auto 38px;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.edit-optional {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-size: 13px;
    color: var(--muted);
}

.edit-optional input {
    width: auto;
}

.edit-instruction-row {
    display: grid;
    grid-template-columns: 30px 1fr 38px;
    align-items: start;
    gap: 10px;
    margin-bottom: 12px;
}

.edit-step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-top: 7px;
    border-radius: 50%;
    background: #eceff3;
    font-size: 13px;
    font-weight: 750;
}

.recipe-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

@media (max-width: 800px) {

    .recipe-title-row {
        flex-direction: column;
    }

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

    .edit-ingredient-row {
        grid-template-columns: 80px 1fr 38px;
    }

    .edit-ingredient-name {
        grid-column: 1 / 3;
    }

    .edit-optional {
        grid-column: 1 / 3;
    }

    .recipe-edit-actions {
        flex-direction: column-reverse;
    }

    .recipe-edit-actions button {
        width: 100%;
    }
}