/* Feast — app styles. Warm, simple, mobile-first. Light/dark via prefers-
   color-scheme with an explicit data-theme override set by theme.js. */

:root {
    --accent: #B5451C;          /* terracotta */
    --accent-ink: #ffffff;
    --bg: #FBF7F2;              /* warm paper */
    --surface: #ffffff;
    --surface-2: #F4ECE3;
    --ink: #241C17;
    --muted: #6E6259;
    --line: #E7DCCF;
    --ok: #2E7D4F;
    --warn: #A66A00;
    --err: #B3261E;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(40,25,15,.06), 0 6px 20px rgba(40,25,15,.05);
    --tap: 44px;
}

html[data-theme="dark"], :root.dark {
    --accent: #E0703F;
    --accent-ink: #1a120c;
    --bg: #17120E;
    --surface: #211A15;
    --surface-2: #2B221B;
    --ink: #F2E9E0;
    --muted: #B3A498;
    --line: #382C23;
    --ok: #6FCF97;
    --warn: #E0A85B;
    --err: #F0857D;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] {
        --accent: #E0703F; --accent-ink: #1a120c;
        --bg: #17120E; --surface: #211A15; --surface-2: #2B221B;
        --ink: #F2E9E0; --muted: #B3A498; --line: #382C23;
        --ok: #6FCF97; --warn: #E0A85B; --err: #F0857D;
        --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---- Top bar ---- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: .5rem;
    /* Pad by the safe-area inset so the bar clears the status bar / Dynamic
       Island in a standalone PWA (black-translucent renders under it).
       Inset is 0 off-device, so desktop/tablet are unchanged. */
    padding: calc(env(safe-area-inset-top, 0px) + .55rem) .9rem .55rem;
    background: var(--accent); color: var(--accent-ink);
    box-shadow: var(--shadow);
}
.brand { display: inline-flex; align-items: center; gap: .5rem; color: var(--accent-ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.25rem; line-height: 1; }
.brand-name { letter-spacing: .2px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.userlink { color: var(--accent-ink); opacity: .95; font-size: .9rem; }
.iconbtn {
    display: none; background: transparent; border: 0; color: var(--accent-ink);
    font-size: 1.25rem; width: var(--tap); height: var(--tap); border-radius: 10px; cursor: pointer;
}
.theme-pick select {
    background: rgba(255,255,255,.15); color: var(--accent-ink);
    border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: .2rem .4rem; font-size: .85rem;
}
.inline { display: inline; margin: 0; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: var(--tap); padding: .5rem 1rem;
    border-radius: 10px; border: 1px solid var(--line);
    background: var(--surface); color: var(--ink);
    font-size: .95rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-quiet { background: transparent; border-color: rgba(255,255,255,.4); color: var(--accent-ink); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: .3rem .7rem; font-size: .85rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }

/* ---- Shell / layout ---- */
.shell { display: flex; align-items: flex-start; }
.sidebar {
    flex: 0 0 220px; position: sticky; top: 56px; align-self: flex-start;
    padding: 1rem .8rem; height: calc(100vh - 56px); overflow-y: auto;
}
.side-section { margin-bottom: 1.2rem; }
.side-title { text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; color: var(--muted); margin: 0 .4rem .4rem; }
.side-list { list-style: none; margin: 0; padding: 0; }
.side-list a {
    display: block; padding: .55rem .7rem; border-radius: 10px; color: var(--ink); font-weight: 500;
}
.side-list a:hover { background: var(--surface-2); text-decoration: none; }
.side-list a.active { background: var(--accent); color: var(--accent-ink); }

.main {
    flex: 1 1 auto; min-width: 0; width: 100%;
    max-width: 900px; margin: 0 auto; padding: 1.2rem 1.1rem 4rem;
}
.main-bare { max-width: 420px; padding-top: 3rem; }

.page-head { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* Back link for detail pages (feast#37 — the PWA has no browser back button). */
.backlink {
    display: inline-flex; align-items: center; gap: .35rem;
    margin: 0 0 .8rem; padding: .1rem 0;
    color: var(--muted); font-weight: 600; font-size: .95rem; text-decoration: none;
}
.backlink:hover { color: var(--accent); }
.backlink-ic { font-size: 1.1rem; line-height: 1; }

/* ---- Cards ---- */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.1rem 1.2rem; margin-bottom: 1.1rem;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; margin-bottom: .8rem; }
.card.empty { text-align: center; padding: 2.2rem 1.2rem; }

.kv { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: .4rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

/* ---- Forms ---- */
.stack { display: flex; flex-direction: column; gap: .9rem; }
label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; color: var(--muted); font-weight: 600; }
input, select, textarea {
    font: inherit; color: var(--ink); background: var(--surface);
    border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; min-height: var(--tap);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.auth-card { max-width: 360px; margin: 0 auto; }
.auth-brand { display: flex; align-items: center; gap: .5rem; margin-bottom: .3rem; }
.auth-brand h1 { font-size: 1.4rem; }
.auth-brand .brand-mark { font-size: 1.6rem; }

/* ---- Flashes ---- */
.flash { padding: .7rem .9rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid var(--line); font-size: .92rem; }
.flash-error { background: color-mix(in srgb, var(--err) 12%, var(--surface)); border-color: var(--err); }
.flash-warn  { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border-color: var(--warn); }
.flash-ok    { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); border-color: var(--ok); }
.flash-info  { background: var(--surface-2); }

/* ---- Tables ---- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---- Mobile bottom tab bar ---- */
.tabbar { display: none; }

/* ---- Footer ---- */
.appfooter {
    display: flex; justify-content: space-between; gap: 1rem;
    max-width: 900px; margin: 0 auto; padding: 1rem 1.1rem 2rem; color: var(--muted); font-size: .8rem;
}

/* ---- Responsive: phones ---- */
@media (max-width: 720px) {
    :root { --tabbar-h: 56px; }

    .sidebar {
        /* Drawer: clear the status bar at the top and stop above the fixed
           tab bar (which sits at a higher z-index) at the bottom. */
        position: fixed; top: 0; left: 0; z-index: 40; width: 78%; max-width: 300px;
        bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
        height: auto;
        padding-top: calc(env(safe-area-inset-top, 0px) + 1rem);
        background: var(--surface); border-right: 1px solid var(--line);
        transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open::after {
        content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35;
    }
    .iconbtn { display: inline-flex; }
    .main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 1.5rem); }

    .tabbar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
        /* Explicit height (row + home-indicator inset) so the bar reads as one
           docked surface; padding keeps the tabs above the home indicator. */
        height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
        background: var(--surface); border-top: 1px solid var(--line);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .tab {
        flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
        padding: .4rem 0; min-height: var(--tabbar-h); color: var(--muted); background: transparent; border: 0;
        font: inherit; cursor: pointer; text-decoration: none;
    }
    .tab.active { color: var(--accent); }
    .tab-lb { font-size: .68rem; }
    .appfooter { display: none; }
}

/* ---- Utilities ---- */
.hidden { display: none !important; }
.spacer { flex: 1 1 auto; }
.grow { flex: 1 1 200px; }
.btn-row.center { justify-content: center; }
.btn-danger { color: var(--err); border-color: var(--err); }
.btn-danger:hover { border-color: var(--err); }
.check-row { flex-direction: row; align-items: center; gap: .5rem; }
.check-row input { min-height: auto; }

/* ---- Recipes: toolbar, chips ---- */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: .8rem; }
.search { display: flex; gap: .4rem; flex: 1 1 240px; min-width: 200px; }
.search input { flex: 1 1 auto; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.1rem; }
.chip {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .32rem .7rem; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    font-size: .85rem; font-weight: 600; cursor: pointer;
}
.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.fav.active { background: var(--warn); border-color: var(--warn); color: #fff; }
.chip.tmx.active { background: var(--ok); border-color: var(--ok); color: #fff; }
.chip.tmx-off.active { background: var(--muted); border-color: var(--muted); color: var(--surface); }
.badge.tmx { background: color-mix(in srgb, var(--ok) 18%, var(--surface)); color: var(--ok); text-transform: none; }
.badge.tkw { background: color-mix(in srgb, var(--warn) 18%, var(--surface)); color: var(--warn); text-transform: none; }

/* ---- Recipe cards grid ---- */
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.rcard {
    display: flex; flex-direction: column; overflow: hidden; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.rcard:hover { border-color: var(--accent); text-decoration: none; }
.rcard-img {
    aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
    background: var(--surface-2); font-size: 2.2rem; color: var(--muted); overflow: hidden;
}
.rcard-img img { width: 100%; height: 100%; object-fit: cover; }
.rcard-body { padding: .7rem .8rem; display: flex; flex-direction: column; gap: .35rem; }
.rcard-title { font-weight: 700; line-height: 1.25; }
.rcard-meta { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.badge {
    display: inline-block; padding: .12rem .5rem; border-radius: 999px;
    background: var(--surface-2); color: var(--muted);
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.star { color: var(--warn); }

/* ---- Recipe detail ---- */
.recipe-hero { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.recipe-hero .photo { flex: 0 0 260px; max-width: 100%; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.recipe-hero .photo img { width: 100%; display: block; }
.hero-body { flex: 1 1 240px; min-width: 200px; }
.recipe-facts { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .3rem 0 .6rem; }
.ing-list { list-style: none; margin: 0; padding: 0; }
.ing-list li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.ing-list li:last-child { border-bottom: 0; }
.ing-qty { font-weight: 700; }
.instructions { line-height: 1.7; }
.actions-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: 1rem; }

/* ---- Ingredient editor ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.form-grid .full { grid-column: 1 / -1; }
.ing-editor { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .6rem; }
.ing-row { display: grid; grid-template-columns: 80px 90px 1.4fr 1fr 40px; gap: .4rem; align-items: center; }
.ing-row .del {
    background: transparent; border: 1px solid var(--line); color: var(--err);
    border-radius: 8px; min-height: 40px; cursor: pointer;
}
.ing-row .del:hover { border-color: var(--err); }
.img-field { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.img-preview { width: 120px; height: 90px; object-fit: cover; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }

@media (max-width: 620px) {
    .form-grid { grid-template-columns: 1fr; }
    .ing-row { grid-template-columns: 1fr 1fr; }
    .ing-row .del { grid-column: 2; justify-self: end; }
}

/* ---- Shopping list ---- */
.shop-list { list-style: none; margin: 0; padding: 0; }
.shop-list li { display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid var(--line); }
.shop-list li:last-child { border-bottom: 0; }
.shop-item { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: row; align-items: center; gap: .7rem; padding: .45rem 0; cursor: pointer; font-weight: 400; color: var(--ink); font-size: 1rem; }
.shop-cat-form { flex: 0 0 auto; display: flex; align-items: center; gap: .3rem; margin: 0; }
.shop-cat-form select {
    min-height: 32px; padding: .1rem .3rem; font-size: .78rem;
    color: var(--muted); background: transparent; border-color: transparent;
}
.shop-cat-form select:hover, .shop-cat-form select:focus { border-color: var(--line); color: var(--ink); }
.shop-item input.shop-tick { min-height: auto; width: 1.15rem; height: 1.15rem; flex: 0 0 auto; }
/* Ticked = will be sent to AnyList; unticked (staples, or manually skipped) is
   dimmed/struck as "already have — not buying". */
.shop-item:has(.shop-tick:not(:checked)) .shop-line { text-decoration: line-through; color: var(--muted); }
.shop-staple-form { flex: 0 0 auto; margin: 0; }
.shop-staple { line-height: 1; padding: .2rem .45rem; color: var(--muted); border-color: transparent; background: transparent; }
.shop-staple:hover { color: var(--accent); }
.shop-staple.on { color: var(--accent); }
.shop-hint { margin: -.3rem 0 .6rem; }

/* Grouping toggle (segmented control) + by-day view. */
.seg { display: inline-flex; margin: 0 0 1rem; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg-btn { padding: .4rem .9rem; font-size: .9rem; font-weight: 600; color: var(--muted); text-decoration: none; background: var(--surface); }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn:hover { color: var(--ink); text-decoration: none; }
.seg-btn.seg-on { background: var(--accent); color: var(--accent-ink); }
.shop-day-meal { padding: .2rem 0 .5rem; }
.shop-day-meal + .shop-day-meal { border-top: 1px solid var(--line); padding-top: .6rem; }
.shop-day-title { font-weight: 700; margin-bottom: .2rem; }

/* Cooking log (feast#6). */
.stars { color: var(--accent); letter-spacing: 1px; }
.badge.rate { color: var(--accent); border-color: var(--accent); }
.cook-log { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .3rem; }
.cook-log input[type="date"], .cook-log select { flex: 0 0 auto; }
.cook-history { list-style: none; margin: .6rem 0 0; padding: 0; }
.cook-history li { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; border-top: 1px solid var(--line); font-size: .92rem; }
.pantry-add { display: flex; gap: .5rem; margin-top: .4rem; }
.pantry-add input { flex: 1 1 auto; min-width: 0; }

/* AnyList management page (feast#10). */
.al-add { display: flex; gap: .5rem; }
.al-add input[name="name"] { flex: 1 1 auto; min-width: 0; }
.al-add .al-qty { flex: 0 0 5rem; }
.al-list { list-style: none; margin: 0; padding: 0; }
.al-item { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.al-item:last-child { border-bottom: 0; }
.al-edit { display: flex; align-items: center; gap: .5rem; flex: 1 1 auto; min-width: 0; margin: 0; }
.al-edit input.al-check { width: 1.2rem; height: 1.2rem; flex: 0 0 auto; min-height: auto; }
.al-edit .al-name { flex: 1 1 auto; min-width: 0; }
.al-edit .al-qty { flex: 0 0 4.5rem; }
.al-del { margin: 0; flex: 0 0 auto; }
.al-remove { color: var(--muted); border-color: transparent; background: transparent; }
.al-remove:hover { color: var(--danger, #c0392b); }
.al-item.done .al-name { text-decoration: line-through; color: var(--muted); }
.al-sep { padding: .6rem 0 .2rem; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border: 0; }
.al-empty { padding: .5rem 0; }
@media (max-width: 560px) { .al-edit { flex-wrap: wrap; } .al-edit .al-name { flex: 1 1 100%; order: 3; } }

/* ---- Home Assistant widget (?p=widget) — chrome-less week card ---- */
.widget-body { background: var(--bg); }
.widget { max-width: 420px; margin: 0 auto; padding: .8rem .9rem; }
.widget-head {
    display: flex; align-items: center; gap: .45rem;
    font-weight: 700; font-size: .95rem; margin-bottom: .35rem;
}
.widget-days { list-style: none; margin: 0; padding: 0; }
.widget-day {
    display: flex; align-items: baseline; gap: .8rem;
    padding: .42rem .1rem; border-bottom: 1px solid var(--line);
}
.widget-day:last-child { border-bottom: 0; }
.widget-dow { flex: 0 0 2.6rem; color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.widget-day.today .widget-dow { color: var(--accent); }
.widget-day.today .widget-meal { font-weight: 700; }
.widget-meals { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.widget-meal { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; }
.widget-meal.suggested { color: var(--muted); font-style: italic; }
.widget-meal .none, .widget-meal.none { color: var(--muted); }
.widget-slot { color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

/* ---- Fridge view (?p=widget) — compact "tonight" hero + week, for the Samsung
       Family Hub. Sized so tonight + the whole week fit one portrait screen with
       no scroll. Fixed heights (no aspect-ratio) + grid gap for older Tizen
       WebKit. Forced dark via data-theme="dark" on the widget. ---- */
/* Fill the whole iframe: the page is a 100vh flex column, the tonight hero is a
   bounded band at top, and the week grid grows to fill the rest (photos expand),
   so it looks full regardless of the exact iframe height. */
.fridge-body { background: var(--bg); color: var(--ink); margin: 0; }
.fridge {
    min-height: 100vh; box-sizing: border-box;
    max-width: 1100px; margin: 0 auto; padding: .6rem .7rem .8rem;
    display: flex; flex-direction: column; gap: .55rem;
}
.fridge-tonight {
    flex: 0 0 auto; min-height: 170px; max-height: 34vh;
    display: flex; align-items: stretch;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
}
.ft-photo { flex: 0 0 42%; max-width: 42%; }
.ft-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ft-body { flex: 1 1 auto; padding: .8rem 1.1rem; display: flex; flex-direction: column; justify-content: center; }
.ft-label { color: var(--muted); font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.ft-meal { font-size: 2rem; font-weight: 800; line-height: 1.12; margin-top: .2rem; }
.ft-meal.none { color: var(--muted); font-weight: 600; }
.ft-note { color: var(--warn); margin-top: .3rem; font-size: .9rem; font-weight: 600; }
.fridge-week-title { flex: 0 0 auto; margin: .15rem 0 .05rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: .8rem; }
.fridge-week {
    flex: 1 1 auto; min-height: 0;
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr; gap: .5rem;
}
.fw-day { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.fw-photo { flex: 1 1 auto; min-height: 56px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 1.6rem; color: var(--muted); overflow: hidden; }
.fw-photo img { width: 100%; height: 100%; object-fit: cover; }
.fw-dow { flex: 0 0 auto; font-weight: 800; padding: .3rem .55rem 0; font-size: .92rem; }
.fw-meal { flex: 0 0 auto; padding: .04rem .55rem .45rem; font-size: .92rem; line-height: 1.18; }
.fw-meal.none { color: var(--muted); }
.fw-meal.suggested { font-style: italic; color: var(--muted); }
.fw-day.empty { opacity: .5; border-style: dashed; }

/* Tappable tiles: a photo whose meal is a real recipe links through to the
   recipe — ?p=widget-recipe on the fridge, ?p=recipe in the app (.wk-photo on
   the dashboard). Plain anchors — the widget's CSP serves no scripts — so the
   whole photo box is the touch target, and a corner chip advertises it. */
/* Qualified with `a` so these outrank the global `a:hover { text-decoration:
   underline }` — Samsung Internet applies :hover on tap, which would otherwise
   underline the hero's meal name mid-press. */
/* Only the meal-name link needs a colour override; the photo boxes already set
   their own `color` (the placeholder cutlery glyph), and a class beats bare `a`,
   so leave those alone or tappable tiles get a brighter glyph than inert ones. */
a.ft-meal-link { color: inherit; }
a.ft-photo, a.fw-photo, a.ft-meal-link, a.wk-photo { position: relative; }
a.ft-photo, a.fw-photo, a.ft-meal-link, a.wk-photo,
a.ft-photo:hover, a.fw-photo:hover, a.ft-meal-link:hover, a.wk-photo:hover { text-decoration: none; }
a.ft-photo { display: block; }
a.ft-photo:active, a.fw-photo:active, a.ft-meal-link:active, a.wk-photo:active { opacity: .72; }
a.ft-meal-link { display: block; }
a.fw-photo.tappable::after, a.ft-photo.tappable::after, a.wk-photo.tappable::after {
    content: "\203A";                       /* › */
    position: absolute; right: .3rem; bottom: .3rem;
    width: 1.3rem; height: 1.3rem; line-height: 1.3rem; text-align: center;
    border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff;
    font-size: .95rem; font-weight: 700;
}
a.ft-photo.tappable::after {
    content: "Recipe \203A";
    width: auto; height: auto; line-height: 1.25; border-radius: 999px;
    padding: .12rem .5rem; font-size: .78rem; right: .4rem; bottom: .4rem;
}

/* ---- Fridge recipe view (?p=widget-recipe) — what a tapped photo opens.
       Ordinary document flow (not the widget's 100vh flex column) so a long
       method simply scrolls inside the iframe. ---- */
.fridge-recipe { display: block; padding-bottom: 1.4rem; }
a.fr-back, a.fr-back:hover {
    display: inline-block; margin-bottom: .7rem; padding: .45rem .85rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
    color: var(--ink); text-decoration: none; font-weight: 700; font-size: .95rem;
}
a.fr-back:active { opacity: .72; }
.fr-head { display: flex; gap: .9rem; align-items: flex-start; margin-bottom: .8rem; }
.fr-photo { flex: 0 0 38%; max-width: 38%; border-radius: 12px; overflow: hidden; }
.fr-photo img { width: 100%; display: block; }
.fr-headtext { flex: 1 1 auto; min-width: 0; }
.fr-title { font-size: 1.7rem; font-weight: 800; line-height: 1.15; margin: 0 0 .4rem; }
.fr-facts { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .5rem; }
.fr-facts span {
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
    padding: .12rem .55rem; font-size: .78rem; font-weight: 600; color: var(--muted);
}
.fr-desc { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.35; }
.fr-cols { display: grid; grid-template-columns: 1fr; gap: .7rem; }
.fr-sec { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; }
.fr-sec h2 { margin: 0 0 .45rem; font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.fr-ings { list-style: none; margin: 0; padding: 0; }
.fr-ings li { padding: .32rem 0; border-bottom: 1px solid var(--line); font-size: 1.02rem; line-height: 1.3; }
.fr-ings li:last-child { border-bottom: 0; }
.fr-qty { font-weight: 800; }
.fr-note { color: var(--muted); font-size: .85rem; }
.fr-method { font-size: 1.02rem; line-height: 1.45; }
.fr-missing { color: var(--muted); padding: 1.1rem 0; font-size: 1.05rem; }
/* Side-by-side only where there is genuinely room; the fridge is portrait. */
@media (min-width: 900px) { .fr-cols { grid-template-columns: 1fr 1.4fr; align-items: start; } }

/* Fridge shopping-list widget (feast#10) — live AnyList list. */
.fridge-shop { gap: .5rem; }
.shop-title { flex: 0 0 auto; font-size: 1.5rem; font-weight: 800; display: flex; align-items: baseline; gap: .6rem; }
.shop-count { font-size: .95rem; font-weight: 600; color: var(--muted); }
.shop-empty { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 1.1rem; }
.shop-grid {
    flex: 1 1 auto; min-height: 0; overflow: auto;
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem; align-content: start;
}
.shop-cell {
    background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
    padding: .45rem .6rem; display: flex; flex-direction: column; gap: .1rem;
}
.shop-name { font-weight: 700; font-size: 1.02rem; line-height: 1.2; }
.shop-meta { color: var(--muted); font-size: .85rem; }
.shop-cell.done { opacity: .45; }
.shop-cell.done .shop-name { text-decoration: line-through; }
@media (max-width: 700px) { .shop-grid { grid-template-columns: 1fr; } }

/* Dashboard "What's on this week" grid (mirrors the fridge widget). */
.week-grid {
    list-style: none; margin: .2rem 0 0; padding: 0;
    display: grid; grid-template-columns: repeat(7, 1fr); gap: .5rem;
}
.wk-day {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 10px; overflow: hidden; display: flex; flex-direction: column;
}
.wk-day.empty { opacity: .6; border-style: dashed; }
.wk-day.wk-today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.wk-photo {
    aspect-ratio: 4 / 3; background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; color: var(--muted); overflow: hidden;
}
.wk-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wk-dow { font-weight: 700; padding: .35rem .5rem 0; font-size: .82rem; color: var(--muted); }
.wk-meal { padding: .05rem .5rem .5rem; font-size: .9rem; line-height: 1.2; }
.wk-meal.none { color: var(--muted); }
.wk-meal.suggested { font-style: italic; color: var(--muted); }
@media (max-width: 760px) {
    .week-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
    /* Stacked hero. The photo needs a DEFINITE height here: with `flex: 1 1 auto`
       its img resolves to the full natural height, overflows the band and the
       clipped remainder takes the meal name (and the "Recipe" chip) with it. */
    .fridge-tonight { flex-direction: column; min-height: 0; max-height: none; }
    .ft-photo { flex: 0 0 auto; max-width: 100%; height: 170px; overflow: hidden; }
    .ft-body { flex: 1 1 auto; min-height: 0; }
    .ft-meal { font-size: 1.5rem; }
    .fridge-week { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Weekly planner ---- */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.day-card { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 0; }
.day-card.approved { border-color: var(--ok); }
.day-head { display: flex; align-items: center; gap: .5rem; }
.lockmark { font-size: .95rem; }
.day-meal { min-height: 3.2rem; }
.day-title { font-weight: 700; line-height: 1.3; color: var(--ink); }
a.day-title:hover { color: var(--accent); text-decoration: none; }
.status-chip {
    display: inline-block; padding: .1rem .5rem; border-radius: 999px;
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.st-suggested { background: color-mix(in srgb, var(--warn) 16%, var(--surface)); color: var(--warn); }
.st-approved  { background: color-mix(in srgb, var(--ok) 16%, var(--surface)); color: var(--ok); }
.st-rejected  { background: var(--surface-2); color: var(--muted); }
.badge-ok { background: color-mix(in srgb, var(--ok) 16%, var(--surface)); color: var(--ok); }
.day-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.day-quick { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip-btn {
    font: inherit; font-size: .8rem; cursor: pointer;
    display: inline-flex; align-items: center; gap: .3rem;
    min-height: 34px; padding: .2rem .6rem; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
}
.chip-btn:hover { border-color: var(--accent); color: var(--ink); }
.chip-btn.active {
    background: color-mix(in srgb, var(--accent) 16%, var(--surface));
    border-color: var(--accent); color: var(--accent); font-weight: 700;
}
.chip-btn.tkw.active {
    background: color-mix(in srgb, var(--warn) 18%, var(--surface));
    border-color: var(--warn); color: var(--warn);
}
.day-more summary {
    cursor: pointer; color: var(--muted); font-size: .85rem;
    display: flex; align-items: center; min-height: 40px;
}
.day-more[open] summary { margin-bottom: .5rem; }

/* ---- Profile / members ---- */
.totp-secret { font-size: 1.05rem; letter-spacing: .06em; background: var(--surface-2); padding: .35rem .6rem; border-radius: 8px; display: inline-block; }
.members-actions { margin-top: 0; gap: .5rem; }

/* ---- Import page divider ---- */
hr.soft { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }

/* ---- Takeaways management (?p=takeaways) ---- */
.add-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.add-row input[type="text"] { flex: 1 1 12rem; }
.tk-list { list-style: none; margin: 0; padding: 0; }
.tk-item { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.tk-item:last-child { border-bottom: 0; }
.tk-item.inactive { opacity: .6; }
.tk-link { color: var(--ink); text-decoration: none; font-weight: 600; }
.tk-link:hover { color: var(--accent); text-decoration: underline; }
.tk-ext { color: var(--muted); font-size: .85em; }
.tk-thumb {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 8px; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2); font-size: 1.4rem;
}
.tk-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tk-edit { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.tk-edit input[type="text"] { min-width: 8rem; }
/* Collapsible Cookidoo collection (browse to import) */
.tk-collection { border-bottom: 1px solid var(--line); }
.tk-collection:last-child { border-bottom: 0; }
.tk-collection > summary {
    cursor: pointer; font-weight: 700; padding: .6rem 0;
    display: flex; align-items: center; gap: .4rem; min-height: 44px;
}
.tk-collection[open] > summary { margin-bottom: .3rem; }
/* takeaway photo on a plan day card */
.day-photo { display: block; margin-bottom: .4rem; }
.day-photo img { width: 100%; height: 96px; object-fit: cover; border-radius: 8px; }

/* ---- Offline fallback page (public/offline.html, static, no PHP) ---- */
.offline-brand { display: flex; align-items: center; justify-content: center; gap: .5rem; margin-bottom: .3rem; }
.offline-brand h1 { font-size: 1.4rem; }
.offline-brand .brand-mark { font-size: 1.6rem; }
