/* ───────── Theme ───────── */
:root {
  --bg: #faf7f2; --surface: #ffffff; --surface-2: #f3eee6; --text: #2a2522; --muted: #7a716b;
  --line: #e7dfd4; --shadow: 0 1px 2px rgba(60,40,20,.06), 0 4px 14px rgba(60,40,20,.06);
  --accent: #c8553d; --accent-soft: #f6e3dc; --on-accent: #fff;
  --radius: 14px; --radius-sm: 9px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Serif", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body: var(--sans); --font-head: var(--serif);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-font="sans"] { --font-head: var(--sans); }
:root[data-size="s"] { font-size: 15px; }
:root[data-size="m"] { font-size: 16.5px; }
:root[data-size="l"] { font-size: 18.5px; }

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #1b1917; --surface: #252220; --surface-2: #2e2a27; --text: #efe9e2; --muted: #a59c94;
    --line: #3a3531; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1917; --surface: #252220; --surface-2: #2e2a27; --text: #efe9e2; --muted: #a59c94;
  --line: #3a3531; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25); color-scheme: dark;
}

/* Accent colours (soft tint is mixed from the accent so it works in light and dark) */
:root[data-accent="tomato"]   { --accent: #c8553d; }
:root[data-accent="sage"]     { --accent: #5d7d58; }
:root[data-accent="plum"]     { --accent: #85507a; }
:root[data-accent="ocean"]    { --accent: #2f6f8f; }
:root[data-accent="honey"]    { --accent: #b07d1f; }
:root[data-accent="charcoal"] { --accent: #4a4541; }
:root { --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
:root[data-theme="dark"][data-accent="charcoal"] { --accent: #b9b0a6; --on-accent: #1b1917; }
@media (prefers-color-scheme: dark) { :root[data-theme="system"][data-accent="charcoal"] { --accent: #b9b0a6; --on-accent: #1b1917; } }

/* ───────── Base ───────── */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: var(--font-body); line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
svg.i { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.fill { fill: currentColor; }

/* ───────── Buttons & inputs ───────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45em; border: 1px solid var(--line); background: var(--surface); padding: .6em 1em; border-radius: 999px; font-weight: 600; font-size: .95rem; white-space: nowrap; }
.btn:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: #c0392b; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 0; background: transparent; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.on { color: var(--accent); }
.field { display: grid; gap: .3rem; margin-bottom: 1rem; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: .8rem; }
.input, textarea.input, select.input { width: 100%; padding: .7em .85em; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 6rem; line-height: 1.5; }
.row { display: flex; gap: .6rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }

/* ───────── Layout ───────── */
.shell { min-height: 100vh; display: flex; }
.sidebar { display: none; }
.main { flex: 1; min-width: 0; padding-bottom: calc(6rem + var(--safe-b)); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .25rem; padding: .5rem .6rem; padding-top: max(.5rem, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.topbar .title { flex: 1; min-width: 0; font-family: var(--font-head); font-size: 1.35rem; font-weight: 600; padding-left: .4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { display: flex; align-items: center; gap: .5rem; }
.brand img { width: 1.7rem; height: 1.7rem; border-radius: 7px; }
.narrow { max-width: 760px; margin: 0 auto; padding: 0 1rem; }

@media (min-width: 900px) {
  .sidebar { display: block; width: 250px; flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 1rem .75rem 2rem; border-right: 1px solid var(--line); background: var(--surface); }
  .sidebar .brand { padding: .3rem .5rem 1rem; font-family: var(--font-head); font-size: 1.35rem; font-weight: 600; }
  .chips-row.books { display: none; }
  .hide-wide { display: none !important; }
}
@media (max-width: 899px) { .hide-narrow { display: none !important; } }

.side-head { display: flex; align-items: center; justify-content: space-between; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 1rem .6rem .35rem; }
.side-item { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .6rem; border: 0; border-radius: var(--radius-sm); background: transparent; text-align: left; font-size: .95rem; }
.side-item:hover { background: var(--surface-2); }
.side-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-item .count { margin-left: auto; font-size: .8rem; color: var(--muted); }
.side-item .emoji { width: 1.4em; text-align: center; }

/* ───────── Library ───────── */
.searchbar { display: flex; gap: .5rem; align-items: center; padding: .25rem 1rem .5rem; max-width: 1180px; margin: 0 auto; }
.search { flex: 1; display: flex; align-items: center; gap: .5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 .9rem; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; border: 0; background: transparent; outline: none; padding: .65em 0; min-width: 0; }
.filter-btn { position: relative; }
.badge { position: absolute; top: .15rem; right: .15rem; min-width: 1.1rem; height: 1.1rem; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: .68rem; font-weight: 700; display: grid; place-items: center; padding: 0 .25rem; }
.chips-row { display: flex; gap: .45rem; overflow-x: auto; padding: .25rem 1rem .6rem; scrollbar-width: none; max-width: 1180px; margin: 0 auto; }
.chips-row::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: .35em; padding: .42em .85em; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .88rem; white-space: nowrap; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.chip.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip .x { opacity: .7; margin-left: .1em; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .2rem 1rem .6rem; max-width: 1180px; margin: 0 auto; color: var(--muted); font-size: .88rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .9rem; padding: 0 1rem; max-width: 1180px; margin: 0 auto; }
@media (min-width: 600px) { .cards { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 1.1rem; } }
.card { position: relative; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; transition: transform .12s ease; }
.card:active { transform: scale(.985); }
.card .ph { aspect-ratio: 4 / 3; background: var(--surface-2); position: relative; overflow: hidden; }
.card .ph img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: .6rem .75rem .75rem; display: grid; gap: .25rem; }
.card h3 { font-size: 1.02rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; gap: .7rem; color: var(--muted); font-size: .8rem; align-items: center; flex-wrap: wrap; }
.card .meta span { display: inline-flex; gap: .25em; align-items: center; }
.card .fav { position: absolute; top: .45rem; right: .45rem; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.88); color: #c8553d; border: 0; }
.card .check { position: absolute; top: .45rem; left: .45rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.25); display: grid; place-items: center; color: #fff; }
.card.selected { outline: 3px solid var(--accent); outline-offset: -1px; }
.card.selected .check { background: var(--accent); border-color: var(--accent); }

.placeholder { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-size: 2.6rem; color: rgba(255,255,255,.92); }

/* List layout */
.cards.list { grid-template-columns: 1fr; gap: .55rem; }
.cards.list .card { flex-direction: row; align-items: stretch; }
.cards.list .card .ph { width: 96px; aspect-ratio: auto; flex: none; min-height: 84px; }
.cards.list .card .placeholder { font-size: 1.8rem; }
.cards.list .card .body { align-content: center; }
.cards.list .card .fav { position: static; background: transparent; margin: auto .5rem auto 0; flex: none; }
.cards.list .card .check { top: .4rem; left: .4rem; }

.empty { text-align: center; padding: 3rem 1.5rem; max-width: 460px; margin: 0 auto; }
.empty .big { font-size: 3rem; }
.empty h2 { margin: .5rem 0; }
.empty p { color: var(--muted); }

.fab { position: fixed; right: 1.1rem; bottom: calc(1.1rem + var(--safe-b)); z-index: 30; width: 3.6rem; height: 3.6rem; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,0,0,.22); }
.fab svg { width: 1.6rem; height: 1.6rem; }

.selbar { position: fixed; left: .75rem; right: .75rem; bottom: calc(.75rem + var(--safe-b)); z-index: 31; background: var(--text); color: var(--bg); border-radius: 16px; padding: .5rem .5rem .5rem 1rem; display: flex; align-items: center; gap: .25rem; box-shadow: 0 8px 26px rgba(0,0,0,.3); max-width: 720px; margin: 0 auto; }
.selbar .icon-btn { color: var(--bg); }
.selbar .icon-btn:hover { background: rgba(255,255,255,.12); }
.selbar .count { flex: 1; font-weight: 600; }

/* ───────── Recipe view ───────── */
.hero { max-width: 1000px; margin: 0 auto; }
.hero img { width: 100%; max-height: 420px; object-fit: cover; }
@media (min-width: 760px) { .hero { padding: 0 1rem; } .hero img { border-radius: var(--radius); } }
.recipe { max-width: 1000px; margin: 0 auto; padding: 1rem 1rem 2rem; }
.recipe h1 { font-size: 1.9rem; margin: .2rem 0 .4rem; }
.source { color: var(--muted); font-size: .9rem; }
.source a { color: inherit; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.stars { display: inline-flex; gap: .1rem; }
.stars button { border: 0; background: none; padding: .15rem; color: var(--line); }
.stars button.on { color: #e0a526; }
.stars svg { width: 1.35rem; height: 1.35rem; }
.facts { display: flex; flex-wrap: wrap; gap: .5rem; margin: .9rem 0; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .45rem .75rem; font-size: .85rem; }
.fact b { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.desc { font-size: 1.02rem; color: var(--text); opacity: .9; }
.cols { display: grid; gap: 1.6rem; margin-top: 1.4rem; }
@media (min-width: 760px) { .cols { grid-template-columns: minmax(250px, 2fr) 3fr; gap: 2.4rem; } }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; border-bottom: 2px solid var(--accent); padding-bottom: .35rem; margin-bottom: .6rem; }
.section-head h2 { font-size: 1.3rem; }
.ings { list-style: none; padding: 0; margin: 0; }
.ings li { display: flex; gap: .65rem; align-items: flex-start; padding: .5rem 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.ings li .box { flex: none; width: 1.15rem; height: 1.15rem; margin-top: .2rem; border: 2px solid var(--muted); border-radius: 5px; display: grid; place-items: center; }
.ings li.done { color: var(--muted); text-decoration: line-through; }
.ings li.done .box { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.ings li.group, .steps li.group { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; border: 0; padding: .9rem 0 .2rem; cursor: default; text-decoration: none; color: var(--text); }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps li { position: relative; padding: .55rem .5rem .75rem 2.6rem; border-radius: var(--radius-sm); cursor: pointer; }
.steps li:not(.group)::before { counter-increment: step; content: counter(step); position: absolute; left: .3rem; top: .55rem; width: 1.65rem; height: 1.65rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .85rem; display: grid; place-items: center; }
.steps li.group { padding-left: 0; }
.steps li.current { background: var(--accent-soft); }
.steps li.done { color: var(--muted); }
.scaler { display: inline-flex; align-items: center; gap: .15rem; font-size: .85rem; color: var(--muted); }
.scaler .icon-btn { width: 2rem; height: 2rem; }
.scaler b { color: var(--text); min-width: 1.5rem; text-align: center; }
.scaler .chip { padding: .25em .6em; font-size: .8rem; }
.notes-box { margin-top: 1.8rem; }
.notes-box textarea { min-height: 5rem; background: var(--surface); }
.book-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.cook-banner { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0 .2rem; }
.cooked-line { margin-top: 1.5rem; color: var(--muted); font-size: .86rem; }

body.cooking .recipe { font-size: 1.15rem; }
body.cooking .steps li { padding-top: .8rem; padding-bottom: 1rem; }
body.cooking .hide-cooking { display: none !important; }

/* ───────── Editor ───────── */
.editor { padding: .5rem 1rem 3rem; }
.photo-edit { display: flex; gap: .9rem; align-items: center; margin-bottom: 1rem; }
.photo-edit .thumb { width: 110px; height: 82px; border-radius: var(--radius-sm); background: var(--surface-2) center / cover no-repeat; flex: none; border: 1px solid var(--line); }
.checklist { display: grid; gap: .25rem; }
.checklist label { display: flex; gap: .6rem; align-items: center; padding: .45rem .5rem; border-radius: var(--radius-sm); cursor: pointer; }
.checklist label:hover { background: var(--surface-2); }
.checklist input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }

/* ───────── Sheets ───────── */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(20,14,10,.42); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; background: var(--bg); border-radius: 20px 20px 0 0; padding: .5rem 1.1rem calc(1.2rem + var(--safe-b)); animation: up .2s ease; box-shadow: 0 -6px 30px rgba(0,0,0,.2); }
.sheet .grab { width: 2.6rem; height: .3rem; border-radius: 9px; background: var(--line); margin: .3rem auto .8rem; }
.sheet h2 { font-size: 1.3rem; margin-bottom: .8rem; }
.sheet h3 { font-family: var(--font-body); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1.1rem 0 .5rem; }
.sheet .actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.2rem; }
@media (min-width: 700px) {
  .backdrop { align-items: center; }
  .sheet { border-radius: 20px; padding-bottom: 1.3rem; }
  .sheet .grab { display: none; }
}
.menu { display: grid; gap: .15rem; }
.menu button { display: flex; align-items: center; gap: .8rem; padding: .8rem .6rem; border: 0; background: none; border-radius: var(--radius-sm); text-align: left; font-size: 1rem; }
.menu button:hover { background: var(--surface-2); }
.menu button .sub { display: block; color: var(--muted); font-size: .82rem; }
.menu button svg { color: var(--accent); }
.menu button.danger, .menu button.danger svg { color: #c0392b; }
.options { display: flex; flex-wrap: wrap; gap: .45rem; }
.seg { display: inline-flex; background: var(--surface-2); padding: .2rem; border-radius: 999px; gap: .2rem; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: .45em 1em; border-radius: 999px; font-size: .9rem; }
.seg button.active { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.swatches { display: flex; gap: .6rem; flex-wrap: wrap; }
.swatch { width: 2.3rem; height: 2.3rem; border-radius: 50%; border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--line); }
.swatch.active { box-shadow: 0 0 0 2px var(--text); }
.emoji-grid { display: flex; flex-wrap: wrap; gap: .3rem; }
.emoji-grid button { width: 2.4rem; height: 2.4rem; border: 1px solid transparent; border-radius: 10px; background: var(--surface); font-size: 1.25rem; }
.emoji-grid button.active { border-color: var(--accent); background: var(--accent-soft); }

/* ───────── Settings ───────── */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.panel h2 { font-size: 1.15rem; margin-bottom: .8rem; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem 0; flex-wrap: wrap; }
.setting + .setting { border-top: 1px solid var(--line); }
.setting .label { font-weight: 600; }
.setting .label small { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; }
.bookmarklet { display: inline-block; padding: .5em 1em; border-radius: 999px; background: var(--accent); color: var(--on-accent); text-decoration: none; font-weight: 600; }
.sync-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: var(--muted); margin-right: .35rem; vertical-align: middle; }
.sync-dot.ok { background: #3c9d5d; } .sync-dot.err { background: #d0443a; } .sync-dot.busy { background: #e0a526; }

/* Setup / passcode */
.setup { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.setup .box { max-width: 380px; width: 100%; text-align: center; }
.setup img { width: 76px; height: 76px; border-radius: 18px; margin: 0 auto 1rem; box-shadow: var(--shadow); }
.setup h1 { font-size: 1.8rem; margin-bottom: .4rem; }
.setup p { color: var(--muted); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: calc(5.4rem + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: .65rem 1.1rem; border-radius: 999px; font-size: .92rem; opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 80; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.spinner { width: 1.1em; height: 1.1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }

/* ───────── Print ───────── */
#print-root { display: none; }
@media print {
  @page { margin: .6in; }
  html, body { background: #fff !important; color: #111 !important; }
  #app, #toast, .backdrop { display: none !important; }
  #print-root { display: block; font-family: var(--font-body); font-size: 11pt; line-height: 1.45; color: #111; }
  #print-root h1, #print-root h2, #print-root h3 { font-family: var(--font-head); color: #111; }
  .p-recipe { break-inside: auto; }
  .p-recipe.newpage, .p-break { break-before: page; }
  .p-recipe + .p-recipe:not(.newpage) { margin-top: .45in; padding-top: .3in; border-top: 1px solid #bbb; }
  .p-head { display: flex; gap: .3in; align-items: flex-start; }
  .p-head .p-title { flex: 1; }
  .p-head img { width: 2.3in; height: 1.7in; object-fit: cover; border-radius: 6px; }
  .p-recipe h1 { font-size: 21pt; margin: 0 0 4pt; }
  .p-meta { font-size: 9.5pt; color: #444; margin: 2pt 0; }
  .p-desc { font-size: 10pt; color: #333; margin: 6pt 0 0; }
  .p-cols { display: grid; grid-template-columns: 2.3in 1fr; gap: .3in; margin-top: 12pt; }
  .p-cols h2 { font-size: 12.5pt; border-bottom: 1.5px solid #111; padding-bottom: 2pt; margin: 0 0 6pt; }
  .p-cols ul { list-style: none; padding: 0; margin: 0; }
  .p-cols ul li { padding: 2pt 0; border-bottom: .5px dotted #bbb; break-inside: avoid; }
  .p-cols ol { padding-left: 1.3em; margin: 0; }
  .p-cols ol li { margin-bottom: 6pt; break-inside: avoid; }
  .p-group { font-weight: 700; margin-top: 7pt; list-style: none; border: 0 !important; }
  ol .p-group { margin-left: -1.3em; }
  .p-notes { margin-top: 12pt; padding: 8pt 10pt; border: 1px solid #ccc; border-radius: 6px; font-size: 10pt; white-space: pre-wrap; break-inside: avoid; }
  .p-source { margin-top: 10pt; font-size: 8.5pt; color: #666; word-break: break-all; }
  .p-cover { height: 8.5in; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
  .p-cover .emoji { font-size: 60pt; }
  .p-cover h1 { font-size: 38pt; margin: 12pt 0 6pt; }
  .p-toc h2 { font-size: 20pt; margin-bottom: 12pt; }
  .p-toc ol { columns: 2; font-size: 11pt; padding-left: 1.4em; }
  .p-toc li { margin-bottom: 3pt; break-inside: avoid; }
  .p-compact .p-cols { grid-template-columns: 2in 1fr; }
}
.btn.primary.danger-fill { background: #c0392b; border-color: #c0392b; color: #fff; }
.card .fav, .card .check { z-index: 2; }

/* Photo scanning */
.scan-grid { display: flex; flex-wrap: wrap; gap: .6rem; }
.scan-thumb { position: relative; width: 92px; height: 116px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2) center / cover no-repeat; padding: 0; }
button.scan-thumb { cursor: zoom-in; }
.scan-thumb span { position: absolute; left: .3rem; bottom: .3rem; background: rgba(0,0,0,.55); color: #fff; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 0 .45rem; }
.scan-thumb button { position: absolute; top: .25rem; right: .25rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; }
.scan-thumb button svg { width: 1rem; height: 1rem; }
.btn.disabled { opacity: .5; pointer-events: none; }
