/* Recipe Box — cookbook-style, responsive, light/dark. No external fonts (works offline). */
:root {
  --paper: #f7f1e6; --card: #fffdf8; --ink: #2b211b; --muted: #6f6257; --line: #e4d8c5;
  --accent: #9e3b26; --accent-ink: #fff; --accent-soft: #f3dfd5; --gold: #c9921f; --ok: #3d7a43; --warn: #a86b00; --bad: #b3261e;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 4px 14px rgba(60, 40, 20, .08);
  --radius: 14px; --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs: 18px; --nav-h: 64px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #1f1a16; --card: #2a231e; --ink: #f1e8dc; --muted: #b5a798; --line: #3e342c;
  --accent: #e07a5f; --accent-ink: #1f1a16; --accent-soft: #46302a; --gold: #e3b450; --ok: #7cc184; --warn: #e0a84a; --bad: #ff8a80;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  color-scheme: dark;
}
:root[data-text="large"] { --fs: 20px; }
:root[data-text="xl"] { --fs: 23px; }

* { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); line-height: 1.5; min-height: 100vh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5rem; font-weight: 700; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
h1 small, h2 small { font-family: var(--sans); font-size: .8rem; color: var(--muted); font-weight: 500; }
a { color: var(--accent); }
p { margin: 0 0 .8rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; justify-content: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; } .skip:focus { left: 1rem; top: 1rem; z-index: 100; background: var(--card); padding: .5rem; }
.ico { width: 1.25em; height: 1.25em; fill: currentColor; flex: none; vertical-align: -.25em; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Top bar + navigation (bottom bar on phones, top on desktop) */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; padding: .55rem 1rem; padding-top: calc(.55rem + env(safe-area-inset-top)); background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); }
:root[data-theme="dark"] .topbar { background: #2c2219; color: var(--ink); }
.brand { display: flex; align-items: center; gap: .55rem; color: inherit; text-decoration: none; font-family: var(--serif); font-size: 1.3rem; font-weight: 700; }
.brand img { border-radius: 9px; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(0,0,0,.06); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 600; }
.nav a .ico { width: 1.55rem; height: 1.55rem; }
.nav a.on { color: var(--accent); }
.offline-pill { display: none; margin-left: auto; font-size: .75rem; font-weight: 700; background: rgba(0,0,0,.25); padding: .15rem .6rem; border-radius: 99px; }
body.offline .offline-pill { display: inline-block; }
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .nav { position: static; height: auto; background: none; border: 0; box-shadow: none; margin-left: auto; gap: .25rem; padding: 0; flex: none; }
  .nav a { flex-direction: row; gap: .4rem; color: inherit; opacity: .85; font-size: .95rem; padding: .45rem .8rem; border-radius: 99px; }
  .nav a.on { color: inherit; opacity: 1; background: rgba(255,255,255,.18); }
  .offline-pill { margin-left: 0; }
}

main { max-width: 1180px; margin: 0 auto; padding: 1rem; outline: none; }
@media (min-width: 900px) { main { padding: 1.5rem 2rem 3rem; } }

/* Buttons + form controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 46px; padding: .5rem 1rem; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: .95rem; font-weight: 600; text-decoration: none; cursor: pointer; transition: background .15s, transform .05s; -webkit-tap-highlight-color: transparent; }
.btn:hover { background: var(--accent-soft); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--bad); border-color: currentColor; }
.btn-text { border-color: transparent; background: transparent; padding-inline: .5rem; }
.btn-lg { min-height: 54px; font-size: 1.05rem; padding-inline: 1.3rem; }
.btn-sm { min-height: 38px; font-size: .85rem; padding: .3rem .7rem; }
.btn-icon span { display: none; } @media (min-width: 700px) { .btn-icon span { display: inline; } }
.btn-round { width: 46px; padding: 0; border-radius: 50%; font-size: 1.4rem; }
.btn-link { background: none; border: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }
.row-btns { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: .6rem 0; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1.5px solid var(--line); border-radius: 10px; padding: .6rem .75rem; width: 100%; min-height: 46px; }
textarea { line-height: 1.5; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: block; margin: 0 0 .9rem; border: 0; padding: 0; }
.field > span, .field > legend { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field small { font-weight: 400; color: var(--muted); }
.pick { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; min-height: 40px; }
.pick input { width: 1.3rem; height: 1.3rem; min-height: 0; accent-color: var(--accent); flex: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; } .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.panel h2 { display: flex; align-items: center; gap: .5rem; }
.notice { background: var(--accent-soft); border-radius: var(--radius); padding: .9rem 1.1rem; margin: 1rem 0; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: .1rem .45rem; border-radius: 6px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }

/* List view */
.search { position: relative; margin-bottom: .8rem; }
.search .ico { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 2.6rem; min-height: 52px; border-radius: 99px; font-size: 1.02rem; }
.chips { display: flex; gap: .45rem; overflow-x: auto; padding: .1rem .1rem .6rem; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
@media (min-width: 900px) { .chips { flex-wrap: wrap; overflow: visible; } }
.chip { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; padding: .45rem .9rem; min-height: 40px; border-radius: 99px; background: var(--card); border: 1.5px solid var(--line); color: var(--ink); text-decoration: none; font-size: .9rem; font-weight: 600; }
.chip small { color: var(--muted); font-weight: 500; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.on small { color: inherit; opacity: .8; }
.chip .ico { color: var(--gold); } .chip.on .ico { color: inherit; }
.chip-edit { color: var(--muted); border-style: dashed; }
.list-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: .4rem 0 .9rem; }
.list-title h1 { margin: 0; font-size: 1.45rem; }
.sort select { width: auto; min-height: 42px; font-size: .9rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .9rem; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1.2rem; } }
.card { position: relative; display: flex; flex-direction: column; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); color: inherit; text-decoration: none; border: 1px solid var(--line); transition: transform .12s, box-shadow .12s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(60,40,20,.15); }
.card-img { aspect-ratio: 4 / 3; background: var(--accent-soft); overflow: hidden; }
.card-img { position: relative; }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-img img.loading { position: absolute; inset: 0; opacity: 0; }
.ph { width: 100%; height: 100%; display: grid; place-items: center; background: repeating-linear-gradient(0deg, transparent 0 22px, rgba(158,59,38,.08) 22px 23px), var(--accent-soft); }
.ph span { font-family: var(--serif); font-size: 2.6rem; color: var(--accent); opacity: .55; }
.card-body { padding: .65rem .8rem .8rem; }
.card h3 { font-size: 1rem; margin: 0 0 .3rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; margin: 0; font-size: .8rem; color: var(--muted); }
.fav-toggle { position: absolute; top: .45rem; right: .45rem; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.85); color: #8a7a6a; display: grid; place-items: center; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.fav-toggle.on { color: var(--gold); }
.empty { text-align: center; padding: 3rem 1rem; max-width: 560px; margin: 0 auto; }
.empty-art .ico { width: 4rem; height: 4rem; color: var(--accent); opacity: .6; }
.empty .row-btns { justify-content: center; }
.spinner { width: 42px; height: 42px; margin: 1rem auto; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Recipe detail */
.recipe-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.recipe-top h1 { margin: 0; font-size: 1.25rem; text-align: center; flex: 1; }
.recipe-top .row-btns { margin: 0; }
.recipe-head { display: grid; gap: 1.2rem; margin-bottom: 1.3rem; }
@media (min-width: 800px) { .recipe-head:has(.hero:not([hidden])) { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; } }
.hero { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--accent-soft); }
.hero img { width: 100%; display: block; aspect-ratio: 4 / 3; object-fit: cover; }
.recipe-title h1 { font-size: 2rem; margin-bottom: .3rem; }
.credit { color: var(--muted); font-style: italic; font-family: var(--serif); margin-bottom: .5rem; }
.desc { font-size: 1rem; }
.meta-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0; }
.meta { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .4rem .8rem; min-width: 84px; }
.meta small { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.meta strong { font-size: .98rem; }
.tagline { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.tag { font-size: .85rem; color: var(--muted); text-decoration: none; }
.actions { margin-top: 1rem; }
.recipe-body { display: grid; gap: 1.2rem; }
@media (min-width: 860px) { .recipe-body { grid-template-columns: minmax(280px, 1fr) minmax(0, 1.6fr); align-items: start; } .col-ing { position: sticky; top: 5rem; } }
.col-ing, .col-steps, .notes { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.notes { margin-top: 1.2rem; }
.sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.sec-head h2 { margin: 0; }
.scaler { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.scaler-val { min-width: 4rem; text-align: center; font-size: .9rem; }
.scaler-val small { display: block; color: var(--muted); }
.ingredients, .steps { list-style: none; margin: 0; padding: 0; }
.ingredients li { display: flex; gap: .7rem; padding: .5rem 0; border-bottom: 1px dashed var(--line); }
.ingredients li:last-child { border-bottom: 0; }
.ingredients .box { width: .55rem; height: .55rem; margin-top: .55rem; border-radius: 50%; background: var(--accent); flex: none; opacity: .7; }
.sub { font-family: var(--serif); font-weight: 700; color: var(--accent); padding-top: .9rem !important; border-bottom: 0 !important; }
.steps li { display: flex; gap: .9rem; padding: .7rem 0; }
.steps .num { flex: none; width: 2rem; height: 2rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: .95rem; margin-top: .05rem; }
.steps p { margin: 0; font-size: 1.02rem; }
.recipe-foot { margin-top: 1.5rem; font-size: .85rem; text-align: center; }

/* Cook mode */
body.cooking .topbar, body.cooking .nav { display: none; }
body.cooking { padding-bottom: 0; }
body.cooking main { max-width: 1300px; }
.cook { font-size: 1.25rem; }
.cook-head { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .8rem; padding: .6rem 0; background: var(--paper); border-bottom: 2px solid var(--line); margin-bottom: 1rem; }
.cook-head h1 { flex: 1; margin: 0; font-size: 1.35rem; }
.wake { font-size: .75rem; color: var(--muted); text-align: right; max-width: 9rem; }
.wake.on { color: var(--ok); font-weight: 700; }
.cook-body { display: grid; gap: 1.5rem; }
@media (min-width: 900px) { .cook-body { grid-template-columns: 1fr 1.5fr; } }
.checklist li[data-n] { cursor: pointer; border-radius: 12px; padding: .75rem .6rem; user-select: none; }
.checklist li[data-n]:hover { background: var(--accent-soft); }
.checklist.ingredients .box { width: 1.5rem; height: 1.5rem; margin-top: .1rem; border-radius: 6px; background: transparent; border: 2.5px solid var(--accent); opacity: 1; }
.checklist li.done { opacity: .45; }
.checklist li.done > span:last-child, .checklist li.done p { text-decoration: line-through; }
.checklist.ingredients li.done .box { background: var(--accent); box-shadow: inset 0 0 0 3px var(--card); }
.checklist.steps li.current { background: var(--accent-soft); outline: 2px solid var(--accent); }
.checklist.steps .num { width: 2.4rem; height: 2.4rem; }
.cook .steps p { font-size: 1.3rem; line-height: 1.55; }
.cook-tip { text-align: center; font-size: .9rem; margin-top: 1.5rem; }

/* Editor */
.ed-grid { display: grid; gap: 1.2rem; }
@media (min-width: 900px) { .ed-grid { grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); } }
.ed-main textarea[name=ingredients], .ed-main textarea[name=steps] { min-height: 14rem; }
.cat-picks { display: flex; flex-wrap: wrap; gap: .3rem .9rem; }
.photo-prev { aspect-ratio: 4 / 3; background: var(--accent-soft); border-radius: 12px; overflow: hidden; display: grid; place-items: center; }
.photo-prev img { width: 100%; height: 100%; object-fit: cover; }
.ed-foot { margin-top: 1rem; justify-content: space-between; }
.fav-pick .ico { color: var(--gold); }

/* Add + import */
.add-grid { display: grid; gap: 1rem; }
@media (min-width: 800px) { .add-grid { grid-template-columns: 1fr 1fr; } }
.add-grid .panel { margin: 0; }
.status { min-height: 1.5em; margin: .3rem 0 0; }
.tabs { display: flex; gap: .3rem; margin-bottom: .8rem; overflow-x: auto; }
.tab { flex: none; min-height: 44px; padding: .4rem 1rem; border-radius: 99px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; }
.tab.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.help { margin: .5rem 0 1rem; } .help summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.link-list { max-height: 260px; overflow: auto; font-size: .85rem; padding-left: 1.2rem; word-break: break-all; }
.link-list .dup { color: var(--muted); }
.folders { display: grid; gap: .5rem; margin: .5rem 0; }
.folder { border: 1px solid var(--line); border-radius: 12px; padding: .3rem .7rem; background: var(--paper); }
.folder summary { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; cursor: pointer; list-style: none; }
.folder summary::-webkit-details-marker { display: none; }
.folder summary .pick { flex: 1; min-width: 12rem; }
.folder .fcat { width: auto; max-width: 14rem; min-height: 40px; font-size: .85rem; }
.link-picks { list-style: none; padding: 0 0 0 1.5rem; margin: .3rem 0; max-height: 320px; overflow: auto; font-size: .9rem; }
.sticky-foot { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); background: var(--card); padding: .5rem 0; margin-bottom: 0; }
@media (min-width: 900px) { .sticky-foot { bottom: 0; } }
.progress { margin: .5rem 0 1rem; }
.bar { height: 14px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.progress p { margin: .35rem 0 0; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: .6rem; margin-bottom: .6rem; }
.sum { background: var(--paper); border-radius: 12px; padding: .6rem; text-align: center; border: 1px solid var(--line); }
.sum strong { display: block; font-size: 1.6rem; font-family: var(--serif); }
.sum span { font-size: .85rem; color: var(--muted); }
.sum.ok strong { color: var(--ok); } .sum.lo strong { color: var(--warn); } .sum.bad strong { color: var(--bad); }
.results { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.results li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; padding: .45rem .7rem; background: var(--card); border-radius: 10px; border: 1px solid var(--line); font-size: .9rem; word-break: break-word; }
.results small { flex-basis: 100%; }
.st-imported .badge { background: #dcefdc; color: #24602b; } .st-failed .badge { background: #f9dcd9; color: var(--bad); } .st-link-only .badge { background: #f8ecd2; color: #8a5a00; }
.st-working .badge { animation: pulse 1s ease-in-out infinite; } @keyframes pulse { 50% { opacity: .4; } }
.card-stage { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; margin: .6rem 0; display: grid; place-items: center; }
.card-stage canvas { max-width: 100%; max-height: 60vh; height: auto; border-radius: 8px; }

/* Settings + categories */
.settings { max-width: 780px; margin: 0 auto; }
.sync-box { border-top: 1px solid var(--line); padding-top: .8rem; margin-top: .8rem; }
.danger-zone { border-color: var(--bad); }
.cats { max-width: 640px; margin: 0 auto; }
.cat-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.cat-list li { display: flex; align-items: center; gap: .4rem; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .4rem .5rem; }
.cat-list .cat-name { flex: 1; border-color: transparent; background: transparent; font-weight: 600; }
.cat-list .cat-name:focus { border-color: var(--accent); background: var(--card); }
.cat-list small { min-width: 1.6rem; text-align: center; }
#addCatForm input { flex: 1; min-width: 10rem; }

/* Dialogs + toasts */
.dialog { border: 0; border-radius: 18px; padding: 1.3rem; width: min(440px, 92vw); background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.dialog::backdrop { background: rgba(30, 20, 10, .5); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom)); z-index: 50; display: grid; gap: .5rem; width: min(520px, 92vw); }
@media (min-width: 900px) { #toasts { bottom: 1.5rem; } }
.toast { display: flex; align-items: center; justify-content: space-between; gap: .8rem; background: #2b211b; color: #fff8ef; padding: .8rem 1rem; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.3); font-size: .95rem; animation: toastIn .2s ease-out; transition: opacity .35s, transform .35s; }
.toast .btn { color: #ffcf8a; min-height: 36px; }
.toast.out { opacity: 0; transform: translateY(10px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

@media print {
  .topbar, .nav, .recipe-top, .actions, .scaler, .recipe-foot, #toasts, .notice { display: none !important; }
  body { background: #fff; padding: 0; } .col-ing, .col-steps { box-shadow: none; border: 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 600px) {
  .cook-head { flex-wrap: wrap; }
  .cook-head h1 { font-size: 1.1rem; }
  .wake { max-width: none; flex-basis: 100%; text-align: left; order: 3; }
}

/* cloud sync indicator */
.sync-pill { display: inline-flex; align-items: center; gap: .3rem; margin-left: auto; padding: .25rem .6rem; border-radius: 99px; font-size: .8rem; font-weight: 600; color: inherit; text-decoration: none; background: rgba(255,255,255,.16); white-space: nowrap; }
.sync-pill[hidden] { display: none; }
.sync-pill .ico { width: 1.05rem; height: 1.05rem; }
.sync-pill[data-state="syncing"] .ico { animation: rb-pulse 1s ease-in-out infinite; }
.sync-pill[data-state="error"], .sync-pill[data-state="needs-signin"] { background: #fff3cd; color: #6b4a00; }
@keyframes rb-pulse { 50% { opacity: .35; } }
@media (min-width: 760px) { .sync-pill { margin-left: .5rem; } }
.sync-state { display: grid; gap: .25rem; margin: .5rem 0 .75rem; }
.sync-state .err { color: var(--danger, #b3261e); }
details.advanced { margin-top: .75rem; }
details.advanced summary { cursor: pointer; color: var(--muted); }
.err-detail { display: grid; grid-template-columns: max-content 1fr; gap: .1rem .6rem; margin: .25rem 0 0; font-size: .82rem; }
.err-detail dt { color: var(--muted); }
.err-detail dd { margin: 0; word-break: break-all; font-family: ui-monospace, Consolas, monospace; }
.sync-log { max-height: 16rem; overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: .78rem; background: var(--bg, #f6f1ea); padding: .6rem; border-radius: 8px; }
.sync-state .warn { color: #8a5a00; }

/* "OneDrive needs you to sign in again" banner */
.signin-banner { display: flex; align-items: center; gap: .75rem; justify-content: space-between; flex-wrap: wrap; margin: .6rem auto 0; max-width: 1100px; width: calc(100% - 1.5rem); padding: .7rem .9rem; border-radius: 12px; background: #fff3cd; color: #4d3600; border: 1px solid #f0d58a; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.signin-banner[hidden] { display: none; }
.signin-banner .signin-msg { display: flex; flex-direction: column; gap: .15rem; flex: 1 1 16rem; }
.signin-banner small { font-size: .85rem; opacity: .85; }
.signin-banner .btn { min-height: 44px; padding-inline: 1.2rem; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .signin-banner { background: #3a2f12; color: #ffe9a8; border-color: #6b5520; } }
[data-theme="dark"] .signin-banner { background: #3a2f12; color: #ffe9a8; border-color: #6b5520; }

/* Installed desktop app. 1.0.6 dropped "window-controls-overlay" from the manifest, so Windows draws a normal
   title bar above the app. Until an installed copy picks up the new manifest (or if the user switches the
   overlay on), the header moves into the title bar but keeps clear of the Windows/Chrome controls:
   the titlebar-area env() variables reserve their space, html.wco is set by app.js (windowControlsOverlay
   .visible + geometrychange), the bar can be dragged, and its links/buttons stay clickable. */
:root { --tb-x: 0px; --tb-w: 100vw; --tb-h: 40px; }
@media (display-mode: window-controls-overlay) {
  :root { --tb-x: env(titlebar-area-x, 0px); --tb-w: env(titlebar-area-width, calc(100vw - 160px)); --tb-h: env(titlebar-area-height, 40px); }
}
html.wco .topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--tb-h); min-height: 0;
  padding: 0 calc(100vw - var(--tb-x) - var(--tb-w) + .5rem) 0 calc(var(--tb-x) + .6rem);
  gap: .5rem; box-shadow: none; overflow: hidden;
  app-region: drag; -webkit-app-region: drag; user-select: none;
}
html.wco .topbar a, html.wco .topbar button, html.wco .topbar .sync-pill { app-region: no-drag; -webkit-app-region: no-drag; }
html.wco body { padding-top: var(--tb-h); }
html.wco .brand { font-size: 1rem; gap: .4rem; }
html.wco .brand img { width: 22px; height: 22px; border-radius: 6px; }
html.wco .sync-pill { padding: .1rem .5rem; font-size: .75rem; }
@media (min-width: 900px) {
  html.wco .nav a { padding: .15rem .6rem; font-size: .85rem; }
  html.wco .nav a .ico { width: 1.1rem; height: 1.1rem; }
}

/* Header never overflows: the sync pill shrinks (ellipsis) before anything is pushed off the edge. */
.topbar { min-width: 0; }
.brand, .nav { flex-shrink: 0; }
.sync-pill { min-width: 0; flex-shrink: 1; overflow: hidden; }
.sync-pill .sync-text { overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 900px) and (max-width: 1080px) {
  .topbar { gap: .5rem; }
  .nav a { padding: .45rem .6rem; }
}

/* 1.0.7: several-recipes picker and paste-the-recipe-text fallback */
.pick-list { display: grid; gap: .5rem; max-height: 50vh; overflow: auto; margin: .4rem 0; }
.pick-list .check { display: flex; gap: .6rem; align-items: flex-start; font-size: 1.05rem; }
.pick-list input { width: 1.3rem; height: 1.3rem; margin-top: .15rem; flex: none; }
.paste-text { margin-top: 1rem; }
.paste-text summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: .3rem 0; }
.paste-text textarea { width: 100%; }

/* 1.0.8: sticky toolbars under the header (recipe Back/Favorite/Edit/Delete, editor Cancel/Save, list search + categories).
   --topbar-h is the header's measured height (set in app.js); the paper-coloured band is widened to the window edges. */
:root { --topbar-h: 60px; }
.recipe > .recipe-top, .editor > .recipe-top, .list-bar {
  position: sticky; top: var(--topbar-h); z-index: 15; background: var(--paper);
  box-shadow: 0 0 0 100vmax var(--paper); clip-path: inset(0 -100vmax);
  padding: .35rem 0; margin-top: -.35rem;
}
.recipe > .recipe-top, .editor > .recipe-top { border-bottom: 1px solid var(--line); }
.list-bar .chips { padding-bottom: .35rem; }
.list-bar .search { margin-bottom: .5rem; }
@media (min-width: 860px) { .col-ing { top: calc(var(--topbar-h) + 4.2rem); } }
body.cooking .recipe-top { position: static; }
@media print { .recipe > .recipe-top, .editor > .recipe-top, .list-bar { position: static; box-shadow: none; } }

/* 1.0.8: client ID help (?) and popover, help page */
.help-tip { display: inline-grid; place-items: center; width: 1.35rem; height: 1.35rem; margin: 0 .2rem; padding: 0; border-radius: 50%; border: 1.5px solid var(--accent); background: var(--card); color: var(--accent); font: 700 .8rem/1 var(--sans); cursor: help; vertical-align: .05em; }
.help-pop { max-width: min(26rem, calc(100vw - 2rem)); padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); box-shadow: var(--shadow); font-size: .92rem; line-height: 1.45; font-weight: 400; }
.help-pop::backdrop { background: rgba(0,0,0,.15); }
.help-page h1 { margin-top: .4rem; }
.help-steps li { margin-bottom: .55rem; }
.help-page code { background: var(--accent-soft); padding: .05rem .35rem; border-radius: 6px; word-break: break-all; }

/* 1.0.8: pan-size converter */
.pan-conv { display: grid; gap: .35rem; font-size: .95rem; width: 100%; }
.pan-conv p { margin: 0; }
.pan-pick { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.pan-pick select { flex: 1; min-width: 12rem; }
.pan-custom { display: grid; grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr)); gap: .4rem; align-items: end; }
.pan-custom[hidden] { display: none; }
.pan-custom label span { display: block; font-size: .8rem; color: var(--muted); }
.pan-result strong { color: var(--accent); font-size: 1.1rem; }
.pan-field .row2 { display: grid; grid-template-columns: 1fr auto; gap: .5rem; }
/* the list's sticky bar needs <main> (not the short header section) as its scroll container */
.list-head { display: contents; }

/* 1.0.9: rounded amounts. A line rounded by more than ~15% gets a quiet dotted underline (hover/long-press shows the exact amount). */
.ingredients li.approx > span:last-child { text-decoration: underline dotted color-mix(in srgb, var(--muted) 60%, transparent); text-underline-offset: .25em; }
.rounded-note { color: var(--muted); font-size: .8em; white-space: nowrap; }

/* ---- 1.1.0 ---- */
/* Sync details log: high-contrast text in both themes (was muted grey on beige), larger on phones. */
.sync-log { color: #111; background: #fff; border: 1px solid #8a8178; font-size: .82rem; line-height: 1.45; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
[data-theme="dark"] .sync-log { color: #f4f1ec; background: #0d0b09; border-color: #6d645b; }
@media (max-width: 600px) { .sync-log { font-size: .92rem; max-height: 22rem; } }
/* One status badge per cloud service */
.sync-box h3 { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.conn-badge { font-size: .75rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px; background: var(--accent-soft); color: var(--ink); border: 1px solid var(--line); }
.conn-badge[data-state="ok"] { background: #dff3e4; color: #14532d; border-color: #9fd4ad; }
.conn-badge[data-state="error"], .conn-badge[data-state="needs-signin"] { background: #fde2e0; color: #7f1d1d; border-color: #f1a7a1; }
[data-theme="dark"] .conn-badge[data-state="ok"] { background: #12351f; color: #c9f2d5; border-color: #2f6b43; }
[data-theme="dark"] .conn-badge[data-state="error"], [data-theme="dark"] .conn-badge[data-state="needs-signin"] { background: #3d1513; color: #ffd6d2; border-color: #7a2c27; }
#box-gdrive { margin-top: 1rem; }
/* Back from a recipe: the card you were on flashes briefly */
.card.returned { animation: rb-returned 2s ease-out; }
@keyframes rb-returned { 0%, 35% { box-shadow: 0 0 0 4px var(--accent, #9e3b26); } 100% { box-shadow: var(--shadow); } }
@media (prefers-reduced-motion: reduce) { .card.returned { animation: none; outline: 3px solid var(--accent, #9e3b26); } }

/* 1.2.0: recipe-card reader review (photo next to what was read, numbers highlighted) */
.card-review { display: grid; grid-template-columns: 1fr; gap: .8rem; margin: .6rem 0 1rem; }
@media (min-width: 760px) { .card-review { grid-template-columns: 1fr 1fr; align-items: start; } .card-photo { position: sticky; top: calc(var(--topbar-h, 56px) + .5rem); } }
.card-photo { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem; }
.card-photo img { display: block; width: 100%; max-height: 80vh; object-fit: contain; border-radius: 8px; }
.card-check { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem; }
.card-check h2 { font-size: 1.05rem; margin: .2rem 0 .4rem; }
.card-check h3 { font-size: .95rem; margin: .7rem 0 .2rem; }
.card-check .card-title { font-weight: 700; font-size: 1.1rem; margin: .2rem 0; }
.card-check ul, .card-check ol { margin: 0; padding-left: 1.3rem; }
.card-check mark { background: #ffe58a; color: #222; border-radius: 3px; padding: 0 .12em; font-weight: 700; }
.progress .bar.indeterminate span { width: 35% !important; animation: rb-indet 1.4s ease-in-out infinite; }
@keyframes rb-indet { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

/* ---------- 1.3.0 ---------- */
.app-version { margin: -.4rem 0 1rem; font-size: .9rem; }
.help-new li { margin-bottom: .6rem; }
.btn-xs { min-height: 0; padding: .05rem .4rem; font-size: .78rem; font-weight: 600; margin-left: .3rem; vertical-align: baseline; }
/* Two-sided cards */
.card-sides { display: grid; gap: 1rem; }
@media (min-width: 760px) { .card-sides { grid-template-columns: 1fr 1fr; align-items: start; } }
.card-side h2 { margin: .3rem 0 0; font-size: 1.1rem; }
.back-add { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1rem; margin: .6rem 0; text-align: center; }
.card-photo img + img { margin-top: .4rem; }
/* AI dish photo */
.ai-photo { border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem; margin-top: .6rem; background: var(--card); }
.ai-photo h3 { margin: 0 0 .3rem; font-size: 1rem; }
.ai-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin: .4rem 0; }
.ai-choice { padding: 0; border: 3px solid transparent; border-radius: 10px; background: var(--accent-soft); aspect-ratio: 1; overflow: hidden; cursor: pointer; }
.ai-choice:hover, .ai-choice:focus-visible { border-color: var(--accent); }
.ai-choice img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ai-wait span { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent); background-size: 200% 100%; animation: aiwait 1.2s linear infinite; }
@keyframes aiwait { from { background-position: 200% 0; } to { background-position: -200% 0; } }
/* Bake timers */
.timer-btn { display: inline-flex; align-items: center; gap: .2rem; margin: 0 .15rem; padding: .1rem .55rem; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent); font: inherit; font-size: .85em; font-weight: 700; cursor: pointer; white-space: nowrap; }
.timer-btn:hover { background: var(--accent); color: var(--accent-ink); }
.timers.open .timer-full { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); background: #111; color: #fff; text-align: center; cursor: zoom-out; }
.timer-title { margin: 0; font-size: clamp(1.2rem, 4vw, 2.2rem); font-weight: 700; opacity: .85; }
.timer-label { margin: 0; font-size: clamp(1rem, 3vw, 1.6rem); opacity: .75; }
.timer-digits { margin: 0; font-size: min(30vw, 42vh); line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.timer-acts { display: flex; gap: 1rem; }
.timer-stop { min-height: 72px; min-width: 220px; font-size: 1.8rem; font-weight: 800; border-radius: 999px; background: #e53935; color: #fff; border: 0; }
.timer-more { min-height: 72px; font-size: 1.3rem; border-radius: 999px; }
.timer-others { list-style: none; padding: 0; margin: .5rem 0 0; width: min(100%, 560px); }
.timer-others li { display: flex; align-items: center; gap: .8rem; justify-content: space-between; padding: .4rem .8rem; border-top: 1px solid rgba(255,255,255,.2); font-size: 1.2rem; }
.timer-others b { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.timer-hint { margin: .3rem 0 0; opacity: .55; font-size: .9rem; }
.timers.ringing.open .timer-full { animation: timerflash 1s steps(1) infinite; }
@keyframes timerflash { 0% { background: #c62828; } 50% { background: #111; } }
.timers.bar .timer-bar { position: fixed; left: .5rem; right: .5rem; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + .5rem); z-index: 90; display: flex; flex-wrap: wrap; gap: .4rem .9rem; align-items: center; justify-content: center; padding: .5rem .8rem; border-radius: 14px; background: #111; color: #fff; box-shadow: var(--shadow); cursor: zoom-in; }
@media (min-width: 760px) { .timers.bar .timer-bar { bottom: 1rem; left: auto; right: 1rem; } }
body.cooking .timers.bar .timer-bar { bottom: 1rem; }
.tb-item { display: inline-flex; align-items: center; gap: .4rem; }
.tb-item b { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.tb-item.ringing { animation: timerflash 1s steps(1) infinite; border-radius: 8px; padding: 0 .3rem; }
body.timer-open { overflow: hidden; }
