/* The same discovery surface is used on Inspiration and in every meal picker. */
/* Keyboard reflow at 1x; recipe actions stay in their normal reading flow. */
html #modal.viewport-managed[open]{position:fixed;inset:var(--dialog-view-top,0px) calc(var(--dialog-layout-width,100vw) - var(--dialog-view-left,0px) - var(--dialog-view-width,100vw)) calc(var(--dialog-layout-height,100dvh) - var(--dialog-view-top,0px) - var(--dialog-view-height,100dvh)) var(--dialog-view-left,0px);margin:auto;box-sizing:border-box;width:min(var(--dialog-max-width,900px),calc(var(--dialog-view-width,100vw) - 16px));max-width:calc(var(--dialog-view-width,100vw) - 16px);max-height:calc(var(--dialog-view-height,100dvh) - 16px)!important;overscroll-behavior:contain;overflow-x:hidden}
html #modal.viewport-managed:is(.settings-dialog,.calculator-dialog,.install-dialog,.intro-dialog,.settings-allergen-dialog){--dialog-max-width:620px}
html #modal.viewport-managed :is(.modal-content,.suggestion-scroll,.settings-body,.install-step-content,.tour-content){overscroll-behavior-y:contain;min-width:0}
html #modal.viewport-managed>.recipe-detail-bottom-action{max-height:35%;overflow-y:auto;flex-shrink:0;padding:8px 0 max(8px,env(safe-area-inset-bottom));box-sizing:border-box}
html #modal.viewport-managed :is(.recipe-detail-bottom-action,.suggestion-footer,.settings-save,.calc-actions,.install-walkthrough-actions,.tour-nav) button{min-width:0;white-space:normal;overflow-wrap:anywhere}
html #modal.viewport-managed[data-short-viewport]{padding:8px}
html #modal.viewport-managed[data-short-viewport]>.modal-head{padding-bottom:6px;margin-bottom:6px;gap:0;grid-template-rows:44px auto}
html #modal.viewport-managed[data-short-viewport]>.modal-head>h2{font-size:calc(var(--app-text-scale, 1) * 18px);line-height:1.2;padding:0 10px;max-height:none;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}
html #modal.viewport-managed[data-short-viewport] :is(.suggestion-footer,.settings-save,.calc-actions,.install-walkthrough-actions,.tour-nav){padding-block:6px;gap:6px}
html #modal.viewport-managed[data-short-viewport] .modal-top-button{display:none!important}
.recipe-meal-filter{grid-column:1/-1;text-align:center}
.recipe-meal-filter h3{margin:0 0 10px;font-size:calc(var(--app-text-scale, 1) * 21px);color:#274559}
.recipe-meal-icons{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
.recipe-meal-icons button{display:grid;justify-items:center;align-content:center;gap:5px;min-width:0;min-height:78px;margin:0;padding:6px 2px;border:1px solid transparent;background:#f8fbfe;border-radius:14px;color:#274559;box-shadow:0 3px 12px #355c780b}
.recipe-meal-icons button[aria-pressed=true]{border-color:#77add0;background:#e2f2fc}
.recipe-meal-art,.recipe-meal-art svg{display:block;width:44px;height:44px}
.recipe-meal-icons small{font-size:12px;white-space:nowrap}
body .compact-discovery{grid-template-columns:repeat(2,minmax(0,1fr))}
body .compact-discovery .discovery-ingredient-filters{display:contents}
body .compact-discovery .discovery-ingredient-filters>details{grid-column:auto}
body .compact-discovery .discovery-ingredient-filters>details[open]{grid-column:1/-1}
body .compact-discovery .discovery-ingredient-filters>details>summary{font-size:calc(var(--app-text-scale, 1) * 12px);gap:6px;min-height:52px;overflow-wrap:normal}
body .recipe-display-tools{display:grid;grid-template-columns:repeat(3,minmax(0,1fr)) 44px 44px;align-items:center;gap:6px;margin:12px 0 16px}
body .recipe-display-tools>[data-action=recipe-view]{min-width:0;min-height:44px;padding:6px 4px;font-size:calc(var(--app-text-scale, 1) * 13px);line-height:1.25}
body .recipe-display-tools>[aria-pressed=true]{border-color:#3489bd;background:#e4f3fc;color:#173f5c}
body .recipe-time-select,body .recipe-display-tools>.recipe-favorite-filter{position:relative;display:grid;place-items:center;box-sizing:border-box;width:44px;height:44px;min-width:44px;min-height:44px;margin:0;padding:0;border:1px solid #c9dfe9;border-radius:14px;background:#fff;color:#315971;font-size:calc(var(--app-text-scale, 1) * 23px);cursor:pointer}
.recipe-time-select select{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer;font-size:calc(var(--app-text-scale, 1) * 16px)}
body .recipe-time-select.is-active{background:#e4f3fc;border-color:#3489bd}
body .recipe-display-tools>.recipe-favorite-filter[aria-pressed=true]{color:#a52f4b}
.recipe-time-select:focus-within,.recipe-meal-icons button:focus-visible{outline:3px solid #1687bd;outline-offset:3px}
:is(#recipeResults,#pickerResults) .recipe-grid.recipe-grid--small{grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}
:is(#recipeResults,#pickerResults) .recipe-grid--small .recipe-tile{display:flex;flex-direction:column;min-width:0;border-radius:14px;background:#fff;box-shadow:0 3px 12px #355c7812}
:is(#recipeResults,#pickerResults) .recipe-grid--small .recipe-card-media{position:relative;aspect-ratio:1;min-width:0;overflow:hidden;border-radius:13px 13px 0 0;background:#e8f1f7}
:is(#recipeResults,#pickerResults) .recipe-grid--small .recipe-card-media>.food-photo,
:is(#recipeResults,#pickerResults) .recipe-grid--small .recipe-card-media>.food-placeholder{width:100%;height:100%;min-height:0;margin:0;aspect-ratio:auto}
:is(#recipeResults,#pickerResults) .recipe-grid--small .food-photo img{width:100%;height:100%;object-fit:cover}
:is(#recipeResults,#pickerResults) .recipe-grid--small .food-photo figcaption{display:none}
.recipe-grid--small .recipe-small-time{position:absolute;left:5px;top:5px;z-index:2;padding:4px 6px;border-radius:8px;background:#fffffff2;color:#173f5c;font-size:calc(var(--app-text-scale, 1) * 12px);font-weight:650;pointer-events:none}
.recipe-grid--small .recipe-small-caption{padding:8px;text-align:center;color:#18374c}
.recipe-grid--small .recipe-small-caption strong{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;overflow-wrap:anywhere;font-size:calc(var(--app-text-scale, 1) * 14px);line-height:1.3;min-height:2.6em;font-weight:750}
.recipe-grid--small .recipe-small-nutrients{display:flex;justify-content:center;flex-wrap:wrap;gap:4px 8px;margin-top:6px;font-size:calc(var(--app-text-scale, 1) * 12px);font-variant-numeric:tabular-nums}
.recipe-grid--small .recipe-small-nutrients>span{white-space:nowrap}
@media(max-width:600px){
 :is(#recipeResults,#pickerResults) .recipe-grid.recipe-grid--small{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
 :is(#recipeResults,#pickerResults) .recipe-grid--small .recipe-card-media{aspect-ratio:4/3}
 body .recipe-display-tools{grid-template-columns:repeat(3,minmax(0,1fr)) 44px 44px;gap:4px}
 body .recipe-display-tools>[data-action=recipe-view]{font-size:calc(var(--app-text-scale, 1) * 12px);padding:6px 2px}
 .recipe-meal-icons small{font-size:11px}
 body .compact-discovery .discovery-ingredient-filters>details>summary{font-size:calc(var(--app-text-scale, 1) * 12px);padding:8px 6px}
}
@media(forced-colors:active){.recipe-time-select select{position:static;opacity:1;min-width:44px}.recipe-time-select>span{display:none}.recipe-time-select{width:auto!important}}

body .compact-discovery .discovery-ingredient-filters>details[data-filter-section=equipment]:not([open]){grid-column:auto}
:is(#recipeResults,#pickerResults) .recipe-grid.large-recipe-grid{grid-template-columns:1fr}

.recipe-picker-register{display:flex;justify-content:center;margin:0 0 12px}
.recipe-grid--small .recipe-small-actions{margin-top:auto;padding:0 6px 6px}
.recipe-grid--small .recipe-small-actions>button{width:100%;min-width:0;min-height:44px;margin:0;padding:6px 2px;font-size:calc(var(--app-text-scale, 1) * 13px)}
@media(max-width:600px){.recipe-grid--small .recipe-small-caption{padding:6px 4px}.recipe-grid--small .recipe-small-caption strong{font-size:calc(var(--app-text-scale, 1) * 13px)}.recipe-grid--small .recipe-small-nutrients{gap:3px;font-size:calc(var(--app-text-scale, 1) * 12px)}.recipe-grid--small .recipe-small-actions{padding:0 4px 4px}}

:is(#recipeResults,#pickerResults) .recipe-card-media>.favorite-icon{left:0!important;right:auto!important;top:0!important}
:is(#recipeResults,#pickerResults) .recipe-card-media>.recipe-time,:is(#recipeResults,#pickerResults) .recipe-card-media>.recipe-small-time{left:auto;right:4px;top:4px}

.recipe-grid--small .recipe-small-time{font-size:calc(var(--app-text-scale, 1) * 11px);padding:2px 3px;min-width:0}

/* Keep the shared picker controls on one row, including narrow phones. */
body .recipe-view-toggle.recipe-display-tools:has([data-view="small"]){display:grid;grid-template-columns:repeat(3,minmax(0,1fr)) 44px 44px;gap:3px;min-width:0;width:100%;box-sizing:border-box}
body .recipe-display-tools>.recipe-time-select,body .recipe-display-tools>.recipe-favorite-filter{font-size:calc(var(--app-text-scale, 1) * 18px);border-radius:50%;width:44px;height:44px;min-width:44px}
body .recipe-display-tools>[data-action=recipe-view]{white-space:normal;overflow-wrap:normal;font-size:calc(var(--app-text-scale, 1) * 12px);padding:5px 1px}
.compact-discovery>.recipe-clear-filters{align-self:stretch;justify-self:stretch;min-width:0;margin:0;border-radius:14px;font-size:calc(var(--app-text-scale, 1) * 13px)}
dialog:has(#pickerResults){overflow-x:hidden;overscroll-behavior-x:none;max-width:min(900px,calc(100vw - 16px));box-sizing:border-box}
dialog:has(#pickerResults) :is(.recipe-filter-wrap,.recipe-display-tools,#pickerResults,.recipe-grid){min-width:0;max-width:100%;box-sizing:border-box}
dialog:has(#pickerResults) .recipe-tile{min-width:0}

/* The day overview is already the meal list; photos open full details. */
.day-dashboard .meal-group-tools{display:block;padding:12px}
.day-dashboard .meal-group-thumbnails{grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.day-dashboard .meal-group-thumbnails[data-meal-count="1"]{grid-template-columns:minmax(0,220px)}
.day-dashboard .day-thumbnail .food-photo,.day-dashboard .day-thumbnail .food-placeholder{height:auto;aspect-ratio:1;min-height:132px}
.day-dashboard .day-thumbnail>.meal-individual-pin{top:auto;left:auto;bottom:5px;right:5px;place-items:center;padding:0}
.day-dashboard .day-thumbnail>.meal-corner-remove{top:3px;right:3px;place-items:center;padding:0}
.day-dashboard .day-thumbnail>.meal-individual-pin>span,.day-dashboard .day-thumbnail>.meal-corner-remove>span{width:34px;height:34px;border-radius:11px;background:#f5fafff5;border:1px solid #b9d0e1;box-shadow:0 2px 6px #173f5c26;font-size:calc(var(--app-text-scale, 1) * 23px);color:#163f5b;backdrop-filter:none}
.day-dashboard .day-thumbnail>.meal-corner-remove>span{font-size:calc(var(--app-text-scale, 1) * 28px)}
.day-dashboard .day-thumbnail>.meal-individual-pin[aria-pressed=true]>span{background:#ccecff;border-color:#287db1;box-shadow:0 0 0 2px #fff}
.day-thumb-time{position:absolute;top:8px;left:6px;z-index:2;display:flex;align-items:center;gap:3px;padding:4px 5px;border-radius:9px;background:#fffffff2;color:#254b64;font-size:calc(var(--app-text-scale, 1) * 12px);pointer-events:none}
.day-thumb-time svg{width:15px;height:15px}
.day-dashboard .day-thumbnail>.meal-individual-pin>span,.day-dashboard .day-thumbnail>.meal-corner-remove>span{width:34px!important;height:34px!important;font-size:calc(var(--app-text-scale, 1) * 23px)!important;background:#f5fafff5!important}.day-dashboard .day-thumbnail>.meal-corner-remove>span{font-size:calc(var(--app-text-scale, 1) * 28px)!important}
@media(max-width:350px){body .recipe-display-tools>[data-action=recipe-view]{font-size:calc(var(--app-text-scale, 1) * 11px);letter-spacing:-.2px}body .compact-discovery .discovery-ingredient-filters>details>summary{font-size:calc(var(--app-text-scale, 1) * 11px);padding:8px 4px;gap:2px}.recipe-meal-icons small{font-size:10px;max-width:100%;overflow:hidden;text-overflow:ellipsis}}

/* Cookbook discovery shares the recipe cards and filters. */
/* Equal nutrition cells keep neighbouring recipe cards aligned. */
.recipe-grid .recipe-info>.recipe-card-nutrition{display:block;width:100%;min-width:0;padding:8px;border:1px solid #e1e8ed;border-radius:14px;background:#f7f9fb;margin:4px 0 0}
.recipe-grid .recipe-card-nutrition .recipe-serving-label{margin:0 0 7px;font-size:calc(var(--app-text-scale, 1) * 12px);font-weight:550;color:#526a7c}
.recipe-grid .recipe-card-nutrition .macro-line.macro-chips{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-rows:minmax(52px,auto);gap:5px;width:100%;margin:0}
.recipe-grid .recipe-card-nutrition .macro-line>.macro-chip{display:flex;justify-content:center;align-items:center;gap:3px;min-width:0;min-height:0;height:100%;padding:4px 2px;font-size:calc(var(--app-text-scale, 1) * 12px);line-height:1.2;white-space:nowrap;font-variant-numeric:tabular-nums}
.recipe-grid .recipe-card-nutrition .macro-chip-icon{width:16px;height:16px;flex:0 0 16px}
.recipe-grid .recipe-card-nutrition .macro-energy-share{display:block;font-size:calc(var(--app-text-scale, 1) * 11px);white-space:normal;overflow-wrap:anywhere}.recipe-grid .recipe-card-nutrition .macro-chip>span:last-child{min-width:0;white-space:normal;overflow-wrap:anywhere}
.recipe-grid .recipe-info .head-actions.recipe-card-actions{grid-template-columns:1fr}
:is(#recipeResults,#pickerResults) .recipe-grid--small .recipe-small-nutrients{display:grid;grid-template-columns:1fr;grid-auto-rows:28px;gap:4px;width:100%;margin:0;padding:4px;border:1px solid #e1e8ed;border-radius:10px;background:#f7f9fb}
:is(#recipeResults,#pickerResults) .recipe-grid--small .recipe-small-nutrients>span{display:flex;align-items:center;justify-content:center;gap:3px;min-width:0;border-radius:7px;background:var(--macro-kcal-bg);color:var(--macro-kcal-text);font-size:calc(var(--app-text-scale, 1) * 12px);font-weight:650}
:is(#recipeResults,#pickerResults) .recipe-grid--small .recipe-small-nutrients>span+span{background:var(--macro-protein-bg);color:var(--macro-protein-text)}
.recipe-grid--small .recipe-small-caption .recipe-serving-label{font-size:calc(var(--app-text-scale, 1) * 11px);margin:5px 0;color:#526a7c}
@media(max-width:350px){.recipe-grid .recipe-card-nutrition{padding:5px}.recipe-grid .recipe-card-nutrition .macro-line.macro-chips{gap:3px}.recipe-grid .recipe-card-nutrition .macro-line>.macro-chip{font-size:calc(var(--app-text-scale, 1) * 11px);gap:2px}.recipe-grid .recipe-card-nutrition .macro-chip-icon{width:14px;height:14px;flex-basis:14px}}
.inspiration-mode{display:flex;width:100%;box-sizing:border-box;margin:0 0 16px;padding:4px;gap:4px;border:1px solid #cfdfeb;border-radius:28px;background:#f0f6fbd9}.inspiration-mode button{flex:1;min-width:0;min-height:44px;border-radius:24px;margin:0;background:transparent;border:1px solid transparent;font-weight:700}.inspiration-mode button[aria-pressed=true]{background:linear-gradient(140deg,#e5f4ff,#c8e8ff);border-color:#7bb8d6;color:#144969;box-shadow:0 3px 10px #3a71951c}.cookbook-search label{display:block;font-weight:750;margin-bottom:12px}.cookbook-search input{width:100%;font-size:calc(var(--app-text-scale, 1) * 16px);box-sizing:border-box;min-height:46px}.cookbook-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px;margin-top:18px}.cookbook-card{display:flex;flex-direction:column;gap:10px;align-items:stretch;padding:12px;border-radius:24px;border:1px solid #d6e5ef;background:linear-gradient(145deg,#fff,#eef7ff);color:#24475d;min-width:0;box-shadow:0 8px 20px #547f9c15;text-align:center}.cookbook-card strong{font-size:calc(var(--app-text-scale, 1) * 19px);overflow-wrap:anywhere}.cookbook-card>span:last-child{font-size:calc(var(--app-text-scale, 1) * 14px)}.cookbook-cover{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-rows:1fr;aspect-ratio:1.25;overflow:hidden;border-radius:16px;background:#e8f2fb;gap:3px}.cookbook-cover>:only-child{grid-column:1/-1}.cookbook-cover .food-photo,.cookbook-cover-fallback{width:100%;height:100%;min-height:0;margin:0;display:grid;place-items:center;overflow:hidden;border-radius:0;aspect-ratio:auto}.cookbook-cover img{width:100%;height:100%;object-fit:cover}.cookbook-cover figcaption{display:none}.cookbook-cover-fallback svg,.cookbook-cover-fallback img{width:60px;height:60px;object-fit:contain}.cookbook-cover--custom{display:block;aspect-ratio:1;gap:0;background:#fbf6ee}.cookbook-cover--custom .cookbook-cover-image{display:grid;width:100%;height:100%;margin:0;aspect-ratio:auto;place-items:center;background:#fbf6ee}.cookbook-cover--custom .cookbook-cover-image img{object-fit:contain}.cookbook-heading h2{text-align:center;border-radius:28px;padding:12px;background:#eef5fa;margin:16px 0}.cookbook-heading p{text-align:center;max-width:55ch;margin:0 auto 20px}.cookbook-empty{text-align:center;padding:32px 16px;color:#526c7d}.cookbook-card:focus-visible,.inspiration-mode button:focus-visible{outline:3px solid #2588b4;outline-offset:3px}@media(max-width:600px){.cookbook-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.cookbook-card{padding:10px;gap:8px}.cookbook-card strong{font-size:calc(var(--app-text-scale, 1) * 16px)}.cookbook-card>span:last-child{font-size:calc(var(--app-text-scale, 1) * 13px)}.inspiration-mode{width:100%}}

/* Recipe titles remain in the reading flow. */
html #modal.recipe-dialog .modal-head h2{min-width:0;white-space:normal;overflow-wrap:anywhere;max-height:none}
html #modal .recipe-shopping .shopping-choice-toggle{display:flex;width:100%;min-width:0;gap:.5em!important}
html #modal .recipe-shopping .shopping-choice-toggle label{flex:1 1 0;min-width:0;max-width:100%}
html #modal .recipe-shopping .shopping-choice-toggle span{width:100%;box-sizing:border-box;min-width:0;min-height:2.75em;height:auto;padding:.65em .5em;font-size:1em;white-space:normal}
html #modal .recipe-shopping .shopping-choice-title{width:100%;min-width:0;overflow-wrap:anywhere;font-size:1rem}

/* Keep return actions outside the scrolling allergen list, including short screens. */
html #modal.viewport-managed.settings-allergen-dialog[open]{display:flex;flex-direction:column;overflow:hidden;padding:0}
html #modal.viewport-managed.settings-allergen-dialog>.modal-head{flex:none;margin:0;padding:12px 16px}
html #modal.viewport-managed.settings-allergen-dialog>.modal-content{flex:1 1 auto;min-height:0;overflow:auto;padding:14px 16px;scroll-padding-bottom:12px}
html #modal.viewport-managed.settings-allergen-dialog>.settings-allergen-actions{flex:none;position:relative;bottom:auto;margin:0;padding:12px 16px max(12px,env(safe-area-inset-bottom));background:#f5faff;border-top:1px solid #d7e4ec;z-index:2}
html #modal.viewport-managed .settings-allergen-actions button{min-width:0;min-height:48px;width:100%;white-space:normal;overflow-wrap:anywhere}
html #modal.viewport-managed.settings-allergen-dialog>.modal-top-button{display:none}

/* Nutrient labels may be intervals: contain them within equal-width cells. */
body .macro-chips>.macro-chip>span:last-child,
body .week-nutrition>.macro-chip>span:last-child{min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere;line-height:1.3;font-variant-numeric:tabular-nums}

.recipe-grid .recipe-card-nutrition .macro-line>.macro-chip{box-sizing:border-box;white-space:normal}
.recipe-grid--small .recipe-small-nutrients>span{max-width:100%;white-space:normal;overflow-wrap:anywhere}
.day-dashboard .day-thumbnail.day-thumbnail--quick{display:flex;flex-direction:column;align-items:stretch;gap:12px;padding:12px;min-width:0;border:1px solid #cbdce7;border-radius:20px;background:#f4f9fc}
.day-dashboard .day-thumbnail--quick>.quick-meal-edit{display:flex;flex-direction:column;align-items:center;gap:8px;width:100%;height:auto;min-height:132px;padding:8px;background:transparent;border:0;box-shadow:none;white-space:normal;text-align:center}
.quick-meal-edit strong{font-size:1rem;line-height:1.35;overflow-wrap:anywhere}
.quick-meal-edit small{font-size:.85rem;line-height:1.4;color:#415d6f}
.quick-edit-label{font-size:.85rem;text-decoration:underline;text-underline-offset:3px}
.day-dashboard .day-thumbnail--quick .quick-meal-actions{display:flex;justify-content:center;gap:12px;margin-top:auto}
.day-dashboard .day-thumbnail--quick .quick-meal-actions>button{position:static!important;display:grid;place-items:center;flex:0 0 44px;width:44px!important;height:44px!important;min-width:44px;min-height:44px;padding:0!important;border:1px solid #bed1df;border-radius:13px;background:#fff;color:#24506a;transform:none}
.day-dashboard .day-thumbnail--quick .quick-meal-actions>button>span{display:grid;place-items:center;font-size:calc(var(--app-text-scale, 1) * 25px)}
.day-dashboard .day-thumbnail--quick .quick-meal-actions>.meal-corner-remove{color:#923c4e;border-color:#ddbcc4}
.quick-form-actions{position:sticky;bottom:0;padding:12px 0;background:var(--surface,#fff);z-index:2}
.quick-form-actions>button{width:100%}
