/* Homileto Notes. Brand Gold #d4b06a, Blue #3c5c90, Charcoal #1f2937, set in Manrope (bundled).
   Themes: light (default), dark (for dim sanctuaries) and sepia, set on <html data-theme>. */

@font-face { font-family: "Manrope"; src: url("fonts/manrope.woff") format("woff"); font-weight: 200 800; font-style: normal; font-display: swap; }

:root {
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gold: #d4b06a; --blue: #3c5c90; --charcoal: #1f2937;
  --r: 16px; --r-sm: 12px; --kb: 0px; --kbpad: 0px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --tabbar: 64px;
}
:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7; --paper: #ffffff; --ink: #1f2937; --ink-2: #4b5563; --muted: #6b7280; --line: #e2e5ea; --hover: #eef1f5;
  --accent: #3c5c90; --accent-ink: #ffffff; --accent-soft: #e8eef7; --accent-text: #2c4570;
  --verse-bg: #fbf7ee; --verse-line: #ecdcb8; --verse-ink: #7a5a1f; --scripture: #a07a32;
  --hl: #fde68a; --danger: #c62828; --shadow: 0 1px 2px rgba(31,41,55,.06);
  --pop-bg: #1f2937; --pop-ink: #ffffff; --pop-line: #4a5a72;
  --ink-ink: #1f2937; --ink-gold: #b8892e; --ink-blue: #3c5c90; --ink-red: #c0446f;
  --rule: rgba(31,41,55,.06);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1f2937; --paper: #283445; --ink: #f3f4f6; --ink-2: #cbd2dc; --muted: #aab4c3; --line: #3a475a; --hover: #2f3c50;
  --accent: #d4b06a; --accent-ink: #1f2937; --accent-soft: #33405a; --accent-text: #e6c88a;
  --verse-bg: #34403f; --verse-line: #5b5a43; --verse-ink: #e6c88a; --scripture: #d4b06a;
  --hl: rgba(212,176,106,.38); --danger: #f87171; --shadow: 0 1px 2px rgba(0,0,0,.35);
  --pop-bg: #0f1722; --pop-ink: #f3f4f6; --pop-line: #4a5a72;
  --ink-ink: #ece7dc; --ink-gold: #d4b06a; --ink-blue: #8fb0e3; --ink-red: #ef8fb2;
  --rule: rgba(243,244,246,.07);
}
:root[data-theme="sepia"] {
  color-scheme: light;
  --bg: #f4ecd8; --paper: #fbf5e6; --ink: #3b3226; --ink-2: #5a4d3a; --muted: #7a6a52; --line: #e3d6b8; --hover: #efe4c8;
  --accent: #3c5c90; --accent-ink: #ffffff; --accent-soft: #e6e3d6; --accent-text: #2c4570;
  --verse-bg: #f6ecd0; --verse-line: #e0cb98; --verse-ink: #6e5016; --scripture: #8a6526;
  --hl: #f5d97f; --danger: #b3261e; --shadow: 0 1px 2px rgba(59,50,38,.08);
  --pop-bg: #3b3226; --pop-ink: #fbf5e6; --pop-line: #6b5c45;
  --ink-ink: #3b3226; --ink-gold: #a8781f; --ink-blue: #2f4f86; --ink-red: #a83a60;
  --rule: rgba(59,50,38,.08);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme]) { color-scheme: dark; --bg: #1f2937; --paper: #283445; --ink: #f3f4f6; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); scroll-padding-top: 72px; scroll-padding-bottom: calc(150px + var(--kbpad)); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .center { text-align: center; } .pad { padding: 32px 20px; } .pad-x { padding: 0 20px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 8px; }

#app { min-height: 100vh; min-height: 100dvh; }
.view { max-width: 760px; margin: 0 auto; padding: calc(12px + var(--safe-t)) 16px calc(var(--tabbar) + 96px + var(--safe-b)); }
.view-editor { padding-bottom: calc(170px + var(--kbpad) + var(--safe-b)); }
/* While writing by hand, a finger or pen never selects text or opens the press-and-hold menu */
html.inking, html.inking body, html.inking body * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent;
  background: var(--paper); color: var(--ink); font-weight: 700; font-size: 15px; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.gold { background: var(--gold); color: #1f2937; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost-dark { background: transparent; border-color: var(--pop-line); color: var(--pop-ink); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--danger); }
.btn.danger-fill { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .6; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; color: var(--accent); display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; cursor: pointer; text-decoration: none; }
.icon-btn.round { border-radius: 50%; border: 1px solid var(--line); background: var(--paper); }
.icon-btn.on { background: var(--accent-soft); }
.icon-btn .aa { font-weight: 800; font-size: 17px; }

/* ---------- Header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; margin-bottom: 12px; }
.top h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.4px; }
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; }

/* ---------- Library ---------- */
.search { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; color: var(--muted); }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; font-size: 16px; color: var(--ink); }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 14px -16px 4px; padding: 0 16px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--paper); font-size: 14px; font-weight: 650; white-space: nowrap; cursor: pointer; display: inline-flex; align-items: center; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 750; }
.chip.add { width: 36px; padding: 0; justify-content: center; color: var(--accent); }
.list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.section { font-size: 13px; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 14px 2px 0; }
.card { background: var(--paper); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); border: 1px solid transparent; }
a.card { color: inherit; text-decoration: none; display: block; }
.note-card { display: flex; flex-direction: column; gap: 4px; }
.nc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.nc-meta { font-size: 13px; font-weight: 650; color: var(--accent-text); }
.nc-title { font-size: 17px; font-weight: 800; line-height: 1.3; }
.nc-sub { font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.badge { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); white-space: nowrap; }
.muted-ic { color: var(--muted); display: inline-flex; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.pill { font-size: 12.5px; font-weight: 700; padding: 4px 9px; border-radius: 9px; background: var(--verse-bg); color: var(--verse-ink); }
.link-pill { text-decoration: none; font-size: 14px; padding: 7px 12px; }
.link-pill .cnt { font-weight: 600; opacity: .75; }
.scripture-card .sc-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 15px; }
.scripture-card .sc-head span:first-child { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }
.scripture-card .sc-head svg { color: var(--scripture); }
.link { color: var(--accent); font-size: 13px; font-weight: 750; }
.fab { position: fixed; right: max(20px, calc(50vw - 360px)); bottom: calc(var(--tabbar) + 18px + var(--safe-b)); height: 56px; padding: 0 22px 0 18px; border-radius: 28px; border: 0;
  background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; box-shadow: 0 8px 20px rgba(31,41,55,.28); cursor: pointer; z-index: 5; }
.empty { text-align: center; padding: 48px 12px; }
.empty h2 { margin: 12px 0 4px; font-size: 20px; }
.empty p { color: var(--ink-2); max-width: 360px; margin: 0 auto 20px; }
.empty-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.book-row h2 { margin: 0 0 6px; font-size: 16px; }
.loading .spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); margin: 40px auto 10px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.big { font-size: 18px; font-weight: 650; margin-bottom: 18px; }

/* Install and backup cards */
.install-card, .backup-card { margin-top: 12px; border: 1px solid var(--line); }
.ic-head { display: flex; gap: 12px; align-items: flex-start; }
.ic-head img { border-radius: 10px; flex: none; }
.ic-head p { margin: 2px 0 0; font-size: 14px; color: var(--ink-2); }
.bk-ic { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.steps { margin: 10px 0 0; padding-left: 22px; font-size: 14.5px; }
.steps li { margin: 4px 0; }
.kbd { display: inline-flex; vertical-align: -3px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--accent); }
.ic-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; justify-content: flex-end; }
.install-card .btn.primary { margin-top: 10px; }

/* ---------- Tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--paper); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 6px 8px calc(6px + var(--safe-b)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; min-height: 52px; justify-content: center; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 650; }
.tabbar a.on { color: var(--accent); font-weight: 800; }
.offline-bar { position: fixed; left: 0; right: 0; top: 0; z-index: 30; padding: calc(4px + var(--safe-t)) 12px 4px; text-align: center; font-size: 13px; font-weight: 650; background: var(--charcoal); color: #fff; }

/* ---------- Editor ---------- */
.edit-top { position: sticky; top: 0; z-index: 8; display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: calc(-12px - var(--safe-t)) -16px 6px; padding: calc(6px + var(--safe-t)) 8px 6px; background: var(--bg); }
.edit-actions { display: flex; align-items: center; gap: 2px; }
.blank-count { flex: 1; text-align: center; font-size: 13px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.nb-select { position: relative; display: inline-flex; align-items: center; height: 34px; border-radius: 17px; border: 1px solid var(--line); background: var(--paper); padding: 0 28px 0 12px; max-width: 46vw; }
.nb-select select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; font-size: 13.5px; font-weight: 700; max-width: 100%; outline: 0; padding: 0; text-overflow: ellipsis; }
.nb-select svg { position: absolute; right: 10px; pointer-events: none; }
.note { padding: 0 6px; }
.title-input { width: 100%; border: 0; background: transparent; resize: none; overflow: hidden; font-size: 26px; font-weight: 800; letter-spacing: -.4px; line-height: 1.25; padding: 4px 0; outline: 0; color: var(--ink); }
.title-input::placeholder { color: var(--muted); opacity: .7; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.mchip { position: relative; display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 4px 10px; border-radius: 10px; background: var(--paper); border: 1px solid var(--line); font-size: 13px; font-weight: 650; color: var(--ink-2); cursor: pointer; }
.mchip.tag { color: var(--accent-text); }
.mchip.dashed { border-style: dashed; background: transparent; color: var(--muted); }
.date-chip input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.details { display: grid; gap: 10px; margin: 10px 0; padding: 14px; background: var(--paper); border-radius: var(--r-sm); }
.details label, .form-card label, .modal-label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.details input, .form-card input, .modal-label input, .paste-form input { height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); padding: 0 12px; font-size: 16px; font-weight: 500; color: var(--ink); }
.details .two { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 10px; }
.details input, .form-card input, .modal-label input { width: 100%; min-width: 0; }
.details label { min-width: 0; }
.shared-head { margin: 12px 0 6px; display: flex; flex-direction: column; gap: 8px; }
.shared-head .from { font-size: 12.5px; font-weight: 700; color: var(--accent-text); }
.ts-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ts-label { font-size: 12px; font-weight: 800; color: var(--scripture); text-transform: uppercase; letter-spacing: .6px; }
.opens { font-size: 12px; font-weight: 650; color: var(--muted); }
.vchips { display: flex; gap: 8px; flex-wrap: wrap; }
.vchip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--verse-line); background: var(--verse-bg); color: var(--verse-ink); font-size: 13.5px; font-weight: 750; cursor: pointer; }
.tip { margin: 0; font-size: 13px; color: var(--ink-2); background: var(--accent-soft); padding: 8px 12px; border-radius: 10px; }

.page { position: relative; margin-top: 10px; }
.ink-layer { position: absolute; left: 0; top: 0; z-index: 3; }
.ink-base { pointer-events: none; }
.ink-live { pointer-events: none; touch-action: none; }
.page.pen-mode { background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 35px, var(--rule) 35px, var(--rule) 36px); border-radius: 12px; }
.page.pen-mode .ink-live { pointer-events: auto; cursor: crosshair; }
.section-label { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 14px 0 4px; }
.rich { outline: 0; font-size: 17px; line-height: 1.6; word-wrap: break-word; overflow-wrap: anywhere; }
.body { min-height: 40vh; padding: 2px 0 24px; }
.rich:empty::before { content: attr(data-ph); color: var(--muted); opacity: .8; pointer-events: none; }
.rich p, .rich div { margin: 0; }
.rich ul, .rich ol { margin: 4px 0; padding-left: 24px; }
.rich span[style*="background-color"] { background-color: var(--hl) !important; border-radius: 3px; padding: 0 1px; }
a.ref { color: var(--accent); font-weight: 750; text-decoration: none; border-bottom: 2px dotted currentColor; cursor: pointer; }
.callout { margin: 14px 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--verse-bg); border: 1px solid var(--verse-line); }
.callout.prayer { background: var(--accent-soft); border-color: transparent; }
.co-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; color: var(--verse-ink); margin-bottom: 4px; }
.prayer .co-label { color: var(--accent-text); }
.co-remove { margin-left: auto; width: 36px; height: 36px; margin-top: -8px; margin-right: -8px; border: 0; background: transparent; color: inherit; opacity: .7; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.co-remove:hover, .co-remove:focus-visible { opacity: 1; background: color-mix(in srgb, currentColor 12%, transparent); }
@media print { .co-remove { display: none; } }
.co-text { min-height: 26px; font-size: 16px; }

/* Fill-in outline */
.outline { display: flex; flex-direction: column; gap: 10px; }
.ol-item { display: flex; flex-direction: column; gap: 6px; }
.ol-head { display: flex; gap: 10px; align-items: baseline; }
.ol-num { flex: none; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; background: var(--blue); color: #fff; font-size: 13px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
:root[data-theme="dark"] .ol-num { background: #5577b3; }
.ol-subpoint .ol-num { background: #6f88b6; }
.ol-num.app { background: #2f855a; }
.ol-label { font-size: 17px; font-weight: 750; line-height: 1.4; }
.ol-para { margin: 0 0 0 36px; font-size: 16.5px; font-weight: 600; line-height: 2; }
.ol-scripture { padding: 0 2px; }
input.blank { height: 30px; border: 0; border-bottom: 2px solid var(--muted); border-radius: 6px 6px 0 0; background: var(--accent-soft); color: var(--accent-text); font-weight: 800; font-size: 16px; text-align: center; padding: 0 4px; margin: 0 2px; max-width: 70vw; }
input.blank:focus { outline: 0; border-bottom-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.ol-notes { margin-left: 36px; border: 0; background: transparent; resize: none; overflow: hidden; font-size: 15px; line-height: 1.5; color: var(--ink); outline: 0; padding: 2px 0; }
.ol-notes::placeholder { color: var(--muted); }

/* Toolbars that ride above the keyboard */
.fmt-bar, .pen-bar, .blank-nav { position: fixed; left: 0; right: 0; z-index: 12; will-change: bottom; display: flex; align-items: center; background: var(--paper); border-top: 1px solid var(--line); }
.fmt-bar { bottom: var(--kb); padding: 4px 6px; padding-bottom: max(4px, calc(var(--safe-b) - var(--kb))); justify-content: space-around; }
.fmt-bar button, .pen-bar button { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 10px; color: var(--ink); font-size: 18px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.fmt-bar button[data-act] { color: var(--scripture); }
.fmt-bar button[data-act="addPrayer"] { color: var(--accent); }
.blank-nav { bottom: var(--kb); padding: 8px 12px; padding-bottom: max(8px, calc(var(--safe-b) - var(--kb))); gap: 10px; }
.blank-nav .btn.ghost { width: 48px; padding: 0; flex: none; }
.blank-nav .btn.primary { flex: none; }
.pen-bar { bottom: calc(10px + var(--safe-b)); left: 50%; right: auto; transform: translateX(-50%); border: 1px solid var(--line); border-radius: 26px; padding: 4px 6px; gap: 0; box-shadow: 0 8px 24px rgba(0,0,0,.18); width: max-content; max-width: calc(100vw - 12px); }
.pen-bar button { width: 36px; height: 40px; flex: none; }
.pen-bar .swatch { width: 24px !important; height: 24px !important; margin: 0 2px; }
.pen-bar .done-i { display: none; }
@media (max-width: 399px) { .pen-bar .sep { display: none; } .pen-bar .done-t { display: none; } .pen-bar .done-i { display: inline-flex; } .pen-bar .done { padding: 0 !important; width: 36px !important; } }
@media (min-width: 420px) { .pen-bar button { width: 44px; height: 44px; } .pen-bar .swatch { width: 30px !important; height: 30px !important; margin: 0 3px; } }
.pen-bar button.on { background: var(--gold); color: #1f2937; border-radius: 22px; }
.pen-bar .sep { width: 1px; height: 24px; background: var(--line); margin: 0 3px; flex: none; }
.pen-bar .swatch { width: 30px; height: 30px; border-radius: 15px; flex: none; margin: 0 3px; border: 2px solid transparent; }
.pen-bar .swatch.on { border-color: var(--gold); background-clip: content-box; padding: 2px; }
.pen-bar .sw-ink { background-color: var(--ink-ink); } .pen-bar .sw-gold { background-color: var(--ink-gold); }
.pen-bar .sw-blue { background-color: var(--ink-blue); } .pen-bar .sw-red { background-color: var(--ink-red); }
.pen-bar .done { width: auto !important; padding: 0 10px; font-size: 14px; font-weight: 800; color: var(--accent); }
.pen-bar [hidden], .fmt-bar[hidden], .pen-bar[hidden], .blank-nav[hidden] { display: none; }

/* Verse popover */
.ref-pop { position: absolute; z-index: 40; background: var(--pop-bg); color: var(--pop-ink); border-radius: 14px; padding: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 10px; }
.rp-title { font-weight: 800; font-size: 15px; }
.rp-row { display: flex; gap: 8px; flex-wrap: wrap; }
.rp-row .btn { min-height: 40px; font-size: 13.5px; padding: 0 12px; }
.rp-remove { align-self: flex-start; border: 0; background: transparent; color: color-mix(in srgb, var(--pop-ink) 70%, transparent); font-size: 13px; font-weight: 650; padding: 2px 0; cursor: pointer; text-decoration: underline; }

/* Scan */
.scan-box { position: relative; width: 100%; max-width: 420px; aspect-ratio: 3 / 4; margin: 0 auto 12px; border-radius: 22px; overflow: hidden; background: #0f1722; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 18% 14%; border: 3px solid var(--gold); border-radius: 20px; box-shadow: 0 0 0 999px rgba(15,23,34,.35); }
.scan-box.off { aspect-ratio: auto; height: 120px; }
.scan-box.off .scan-frame { display: none; }
.paste-form { display: flex; gap: 8px; max-width: 420px; margin: 16px auto 0; padding: 0 4px; }
.paste-form input { flex: 1; min-width: 0; }

/* Settings and forms */
.settings { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.settings h2 { margin: 0; font-size: 16px; }
.settings .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 650; min-height: 44px; }
.settings select { max-width: 60%; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); padding: 0 10px; font-size: 15px; }
.help { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.help.small { font-size: 12.5px; }
.row-actions { display: flex; gap: 8px; }
.row-actions.wrap { flex-wrap: wrap; }
.nb-row { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.add-row { align-self: flex-start; }
.form-card { max-width: 440px; margin: 8px auto 0; }
.form-card form { display: flex; flex-direction: column; gap: 12px; }
.form-error { color: var(--danger); font-size: 14px; margin: 0; min-height: 0; }
.form-error:empty { display: none; }
.form-links { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; font-size: 14.5px; font-weight: 650; }

/* Dialogs, menus, toast */
.modal-wrap, .menu-wrap { position: fixed; inset: 0; z-index: 50; }
.modal-wrap { background: rgba(15,23,34,.45); display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
@media (min-width: 640px) { .modal-wrap { align-items: center; } }
.modal { background: var(--paper); color: var(--ink); width: 100%; max-width: 420px; border-radius: 18px; padding: 18px; padding-bottom: calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
.modal h2 { margin: 0; font-size: 18px; }
.modal p { margin: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-actions.col { flex-direction: column; align-items: stretch; }
.menu { position: fixed; background: var(--paper); border-radius: 14px; padding: 6px; box-shadow: 0 12px 30px rgba(0,0,0,.25); border: 1px solid var(--line); min-width: 230px; display: flex; flex-direction: column; }
.menu button { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 0; background: transparent; border-radius: 10px; font-size: 15px; font-weight: 650; text-align: left; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--hover); }
.menu button.danger { color: var(--danger); }
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + 24px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; transition: .2s; background: var(--charcoal); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 650; z-index: 60; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (hover: hover) {
  .btn:hover { filter: brightness(1.04); }
  .chip:hover:not(.on) { background: var(--hover); }
  a.card:hover { border-color: var(--line); }
}
@media (min-width: 900px) {
  .view { padding-top: 24px; }
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); width: 520px; border: 1px solid var(--line); border-radius: 18px; bottom: 14px; padding-bottom: 6px; }
}

/* Printing a note (Print or save as PDF) */
@media print {
  :root { --bg: #fff; --paper: #fff; --ink: #111; --ink-2: #333; --muted: #555; --verse-bg: #fff; --accent-soft: #fff; }
  html, body { background: #fff; }
  .tabbar, .fmt-bar, .pen-bar, .blank-nav, .edit-top, .fab, #toast, .offline-bar, .details, .mchip.dashed, .ref-pop { display: none !important; }
  .view { padding: 0; max-width: none; }
  .card, .callout { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .rich:empty::before, .ol-notes:placeholder-shown { display: none; }
  a.ref { color: #111; border-bottom: 0; }
  input.blank { background: transparent; border-bottom: 1px solid #333; color: #111; }
  .date-chip input { display: none; }
}
@media (max-width: 340px) { .pen-bar { overflow-x: auto; } .pen-bar button { width: 33px; } .pen-bar .swatch { width: 22px !important; height: 22px !important; margin: 0 1px; } .pen-bar .done { width: 33px !important; } }
