/* ================= Tokens ================= */
:root {
  --bg: #f5f1ea;
  --surface: #fffdf9;
  --surface-2: #eee7dc;
  --text: #1f1a14;
  --muted: #776c5f;
  --line: #e2d9cc;
  --accent: #1e2a4a;
  --accent-ink: #ffffff;
  --gold: #a87a26;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(40, 30, 15, .08), 0 10px 30px -14px rgba(40, 30, 15, .3);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151310; --surface: #1e1b17; --surface-2: #2a2621; --text: #ece6dc; --muted: #a39889;
    --line: #36302a; --accent: #e8c170; --accent-ink: #1a1408; --gold: #e8c170; --danger: #f97066;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -14px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151310; --surface: #1e1b17; --surface-2: #2a2621; --text: #ece6dc; --muted: #a39889;
  --line: #36302a; --accent: #e8c170; --accent-ink: #1a1408; --gold: #e8c170; --danger: #f97066;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body[data-view="reader"] { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }

/* ================= Botões ================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: none; background: transparent;
  display: grid; place-items: center; color: var(--muted); flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ================= Biblioteca ================= */
.lib-top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 12px max(16px, calc((100% - 1200px) / 2));
  padding-top: max(12px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font: 700 24px/1 'Literata', Georgia, serif; letter-spacing: -.01em; }
.brand svg { width: 32px; height: 32px; }
.lib-search {
  flex: 1; max-width: 460px; margin-left: auto; position: relative; display: block;
}
.lib-search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); }
.lib-search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
}
.lib-search input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent); }

.lib-wrap { max-width: 1232px; margin: 0 auto; padding: 24px 16px 96px; }

.lib-bar { display: flex; align-items: center; gap: 16px; margin: 8px 0 24px; }
.chips { display: flex; gap: 8px; overflow-x: auto; flex: 1; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  height: 34px; padding: 0 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 500;
}
.chip i { width: 12px; height: 12px; border-radius: 50%; }
.chip b { font-weight: 600; color: var(--muted); font-size: 12px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.on b { color: inherit; opacity: .7; }
.sort { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex: none; }
.sort select { height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); padding: 0 8px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 40px 28px; }
.card { min-width: 0; }
.card-cover { display: block; position: relative; transition: transform .2s ease; border-radius: 4px 8px 8px 4px; }
.card-cover:hover { transform: translateY(-4px); }
.card-cover:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.badge-new {
  position: absolute; bottom: 8px; right: 8px; font: 700 10px/1 'Inter', sans-serif; letter-spacing: .06em;
  text-transform: uppercase; padding: 5px 7px; border-radius: 6px; background: #fff; color: #1e2a4a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.card-info { display: flex; align-items: flex-start; gap: 4px; margin-top: 12px; }
.card-text { flex: 1; min-width: 0; }
.card-title {
  margin: 0; font: 600 15px/1.3 'Literata', Georgia, serif;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prog { height: 3px; border-radius: 3px; background: var(--line); margin-top: 8px; overflow: hidden; }
.prog span { display: block; height: 100%; background: var(--gold); border-radius: inherit; }
.prog.lg { height: 5px; max-width: 320px; margin: 14px 0 8px; }
.no-results { text-align: center; color: var(--muted); padding: 40px 0; }

/* Continuar lendo */
.continue { margin-bottom: 32px; }
.continue-card {
  display: flex; gap: 24px; align-items: center; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px;
  box-shadow: var(--shadow); transition: transform .2s;
}
.continue-card:hover { transform: translateY(-2px); }
.continue-cover { width: 96px; flex: none; }
.continue-body { min-width: 0; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.continue-body h2 { margin: 6px 0 4px; font: 600 22px/1.25 'Literata', Georgia, serif; }
.continue-body p { margin: 0; color: var(--muted); font-size: 14px; }

/* Estado vazio */
.empty { max-width: 620px; margin: 6vh auto 0; text-align: center; }
.empty h1 { font: 600 32px/1.2 'Literata', Georgia, serif; margin: 28px 0 12px; letter-spacing: -.01em; }
.empty p { color: var(--muted); font-size: 16px; line-height: 1.6; }
.empty-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 28px 0 20px; }
.empty-art { position: relative; height: 170px; display: flex; justify-content: center; }
.ghost {
  position: absolute; width: 104px; aspect-ratio: 2/3; border-radius: 4px 8px 8px 4px;
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .45);
}
.g1 { background: linear-gradient(160deg, #8a2236, #4a1020); transform: translateX(-80px) rotate(-9deg); top: 18px; }
.g2 { background: linear-gradient(160deg, #3b4f7d, #1e2a4a); z-index: 1; }
.g3 { background: linear-gradient(160deg, #3f7a57, #1f4030); transform: translateX(80px) rotate(9deg); top: 18px; }
.g2::after {
  content: ''; position: absolute; inset: 30% 30% auto; aspect-ratio: 1; border: 2px solid #e8c170; border-radius: 50%; opacity: .8;
}

.drop-overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(4px);
}
.drop-overlay div {
  border: 2px dashed var(--gold); border-radius: 20px; padding: 48px 40px; font-size: 18px;
  background: var(--surface); text-align: center;
}

/* ================= Navegação Sermões / Igrejas ================= */
.lib-nav { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 10px; }
.lib-nav a {
  padding: 7px 14px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none;
}
.lib-nav a.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
body[data-sub="igrejas"] .lib-top > .lib-search,
body[data-sub="igrejas"] #btnUpload,
body[data-sub="igrejas"] #btnPhoto,
body[data-sub="igrejas"] #btnPaste,
body[data-sub="biblioteca"] .lib-top > .lib-search { visibility: hidden; }

/* Biblioteca (sermões prontos) */
.bib-add {
  margin-top: 10px; width: 100%; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13px; font-weight: 600; color: var(--text);
}
.bib-add:hover:not(:disabled) { background: var(--surface-2); }
.bib-add.on { color: var(--gold); border-color: transparent; background: transparent; cursor: default; }
button.card-cover { border: none; padding: 0; background: none; width: 100%; cursor: pointer; text-align: inherit; }
#bibView .ch-head .lib-search { margin: 0; }

/* ================= Igrejas e pregações ================= */
.ch-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.ch-head h1 { margin: 0; font: 600 28px/1.2 'Literata', Georgia, serif; }
.ch-head p { margin: 4px 0 0; font-size: 14px; }
.ch-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ch-years { margin: 0 0 20px; flex: none; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.6fr); gap: 12px; margin-bottom: 20px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.tile-n { font: 600 30px/1.1 'Literata', Georgia, serif; font-variant-numeric: tabular-nums; color: var(--text); }
.tile-l { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.tile-s { font-size: 12px; color: var(--muted); }
.tile-name { font: 600 17px/1.25 'Literata', Georgia, serif; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tiles.sm { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 16px 0 6px; }
.tiles.sm .tile { padding: 10px 12px; }
.tiles.sm .tile-n { font-size: 19px; }

.ch-two { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; margin-bottom: 28px; }
.card-box { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; min-width: 0; }
.card-box h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }

.bars { display: flex; align-items: stretch; gap: 6px; height: 190px; padding-top: 6px; border-bottom: 1px solid var(--line); }
.bar-col { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; outline: none; cursor: default; }
.bar-track { flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.bar { width: min(100%, 34px); background: var(--gold); border-radius: 4px 4px 0 0; min-height: 0; transition: filter .15s; }
.bar-x { text-align: center; font-size: 11px; color: var(--muted); padding: 6px 0 0; position: absolute; bottom: -22px; left: 0; right: 0; }
.bars { margin-bottom: 26px; }
.bar-col:hover .bar, .bar-col:focus .bar { filter: brightness(1.15); }
.bar-col:hover::after, .bar-col:focus::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% - 4px); left: 50%; translate: -50% 0; white-space: nowrap; z-index: 2;
  background: #26231f; color: #f3efe8; font-size: 12px; padding: 6px 9px; border-radius: 8px; box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .5);
}
.bars-max { margin: 0; }

.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.rank-top { display: flex; gap: 10px; align-items: baseline; font-size: 14px; }
.rank-t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-top b { font-variant-numeric: tabular-nums; }
.rank-bar { height: 4px; border-radius: 4px; background: var(--surface-2); margin: 5px 0 3px; overflow: hidden; }
.rank-bar span { display: block; height: 100%; background: var(--gold); border-radius: inherit; }
.rank-s { font-size: 12px; }
.link { border: none; background: none; padding: 0; color: var(--gold); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }

.ch-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 0 14px; }
.ch-sec-head h2 { margin: 0; font: 600 21px/1.2 'Literata', Georgia, serif; }
.ch-sec-head h2 .muted { font: 500 15px 'Inter', sans-serif; margin-left: 4px; }
.ch-tools { display: flex; gap: 8px; align-items: center; }
.lib-search.sm { width: 240px; flex: none; margin: 0; }
.ch-tools select { height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; }

.church-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; margin-bottom: 32px; }
.church {
  text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px; transition: transform .15s, box-shadow .15s; min-width: 0;
}
.church:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.church-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.church-ico {
  width: 38px; height: 38px; flex: none; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(160deg, #3b4f7d, #1e2a4a); color: #e8c170; font: 700 13px/1 'Inter', sans-serif; letter-spacing: .03em;
}
.church-ico.lg { width: 52px; height: 52px; font-size: 17px; border-radius: 14px; }
.church-name { font: 600 15px/1.3 'Literata', Georgia, serif; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.badge { align-self: flex-start; font-size: 11px; font-weight: 600; letter-spacing: .04em; padding: 3px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.church-stats { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.church-stats b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.church-last { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; border-top: 1px solid var(--line); padding-top: 9px; min-width: 0; }
.church-serm { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.hist { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.hist th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.hist td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.hist tr:last-child td { border-bottom: none; }
.hist tbody tr { cursor: pointer; }
.hist tbody tr:hover { background: var(--surface-2); }
.hist .num { text-align: right; font-variant-numeric: tabular-nums; }
.hist .nowrap { white-space: nowrap; }
tr.cancel td, li.cancel { opacity: .55; }
.tag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 6px; border-radius: 5px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.warn { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold); }
.ch-more { margin: 12px auto 0; display: flex; }

.ch-empty { max-width: 600px; margin: 8vh auto 0; text-align: center; }
.ch-empty-ico { font-size: 56px; }
.ch-empty h1 { font: 600 28px/1.2 'Literata', Georgia, serif; margin: 12px 0; }
.ch-empty p { color: var(--muted); line-height: 1.6; }

.church-dlg { width: 640px; }
.church-body { padding: 22px 22px 4px; max-height: 70vh; overflow-y: auto; }
.cd-actions { padding: 12px 22px 18px; margin: 0; border-top: 1px solid var(--line); }
.cd-head { display: flex; gap: 14px; align-items: center; }
.cd-head h2 { margin: 0; font: 600 21px/1.25 'Literata', Georgia, serif; }
.cd-head p { margin: 3px 0 0; font-size: 13px; }
.cd-years { margin: 0 0 14px; }
.church-body h3 { font-size: 14px; margin: 18px 0 8px; }
.cd-serms { list-style: none; margin: 0; padding: 0; }
.cd-serms li { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline { list-style: none; margin: 0 0 12px; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.timeline li { position: relative; display: flex; gap: 12px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.timeline li:hover { background: var(--surface-2); }
.timeline li::before { content: ''; position: absolute; left: -20px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); border: 2px solid var(--surface); }
.tl-date { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; width: 78px; padding-top: 1px; }
.tl-main { display: flex; flex-direction: column; gap: 2px; font-size: 14px; min-width: 0; }

.preg-dlg { width: 560px; }
.preg-form { padding: 22px; }
.preg-form h3 { margin: 0 0 16px; font-size: 18px; }
.pf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.pf-grid .span2 { grid-column: span 2; }
.pf-check { display: flex; align-items: center; gap: 8px; padding-top: 22px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); }
.pf-check input { width: 18px; height: 18px; accent-color: var(--gold); }
.pf-warn { margin: -4px 0 12px; padding: 9px 12px; border-radius: 10px; font-size: 13px; background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--text); }
.details-hist ul { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.details-hist li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.details-hist .field { margin: 14px 0 6px; }

@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile.wide { grid-column: span 2; }
  .ch-two { grid-template-columns: 1fr; }
}

/* ================= Capa gerada ================= */
.cover {
  container-type: inline-size; position: relative; width: 100%; aspect-ratio: 2 / 3;
  border-radius: 4px 8px 8px 4px; overflow: hidden; color: var(--ac);
  background:
    radial-gradient(circle at 50% 34%, rgba(255, 255, 255, .16), transparent 52%),
    repeating-radial-gradient(circle at 50% 34%, rgba(255, 255, 255, .045) 0 1px, transparent 1px 14px),
    linear-gradient(165deg, var(--c2), var(--c1) 72%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 12px 26px -10px rgba(0, 0, 0, .5);
}
.cover::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5%; z-index: 1;
  background: linear-gradient(90deg, rgba(255, 255, 255, .2), rgba(0, 0, 0, .28) 55%, transparent);
}
.cover::after {
  content: ''; position: absolute; inset: 4.5cqw; border: 1px solid currentColor; opacity: .28; border-radius: 2px;
}
.cover-in {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 11cqw 10cqw 9cqw;
}
.cover-top { font: 600 4.6cqw/1 'Inter', sans-serif; letter-spacing: .22em; text-transform: uppercase; opacity: .9; }
.cover-icon {
  width: 28cqw; height: 28cqw; margin: 13cqw 0 10cqw; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .35));
}
.cover-title {
  color: #fff; font: 600 11cqw/1.1 'Literata', Georgia, serif; letter-spacing: -.01em;
  text-wrap: balance; text-shadow: 0 1px 10px rgba(0, 0, 0, .25);
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.cover-title.l { font-size: 9.4cqw; }
.cover-title.m { font-size: 8cqw; }
.cover-title.s { font-size: 6.6cqw; }
.cover-rule { width: 14cqw; height: 1px; background: currentColor; margin: 7cqw 0 5cqw; opacity: .75; flex: none; }
.cover-ref { font: italic 5.4cqw/1.2 'Literata', Georgia, serif; opacity: .95; }
.cover-brand { margin-top: auto; font: 700 3.6cqw/1 'Inter', sans-serif; letter-spacing: .3em; text-transform: uppercase; opacity: .55; }

/* ================= Diálogos ================= */
dialog.dlg {
  border: none; border-radius: 18px; padding: 0; color: var(--text); background: var(--surface);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5); max-width: min(620px, calc(100% - 32px));
}
dialog::backdrop { background: rgba(10, 8, 5, .45); }
.dlg-actions { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.dlg-actions .sp { flex: 1; }

.details { display: flex; gap: 24px; padding: 24px; }
.details-cover { width: 180px; flex: none; }
.details-body { flex: 1; min-width: 0; }
.field { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }
.field input {
  display: block; width: 100%; margin-top: 6px; height: 40px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); font-size: 15px; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text);
}
.theme-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; margin: -6px 0 12px; }
.swatch {
  border: 2px solid transparent; border-radius: 10px; padding: 8px 4px 6px; color: var(--ac);
  background: linear-gradient(165deg, var(--c2), var(--c1)); display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.swatch svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.swatch span { font-size: 9.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }
.details-stats { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }

/* ================= Toast ================= */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 100; translate: -50% 20px; opacity: 0; pointer-events: none;
  background: #26231f; color: #f3efe8; padding: 11px 18px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px);
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .5); transition: opacity .2s, translate .2s;
}
.toast.show { opacity: 1; translate: -50% 0; }

/* ================= Leitor ================= */
#reader {
  --r-bg: #ffffff; --r-fg: #1b1b1b; --r-muted: #8d8d8d; --r-chrome: rgba(250, 250, 250, .97);
  --r-panel: #ffffff; --r-line: rgba(0, 0, 0, .09); --r-accent: #a87a26; --r-hover: rgba(0, 0, 0, .05);
  position: fixed; inset: 0; background: var(--r-bg); color: var(--r-fg); color-scheme: light;
  transition: background .25s, color .25s;
}
#reader[data-theme="sepia"] {
  --r-bg: #f4ecd8; --r-fg: #4f3d2c; --r-muted: #9a8670; --r-chrome: rgba(238, 228, 204, .97);
  --r-panel: #f8f1e1; --r-line: rgba(80, 60, 30, .14); --r-accent: #9a6a1c; --r-hover: rgba(80, 60, 30, .07);
}
#reader[data-theme="green"] {
  --r-bg: #cfe3cb; --r-fg: #1f2e1f; --r-muted: #5d7a5c; --r-chrome: rgba(196, 218, 191, .97);
  --r-panel: #d9ead5; --r-line: rgba(20, 50, 20, .14); --r-accent: #3d6b2f; --r-hover: rgba(20, 50, 20, .07);
}
#reader[data-theme="dark"] {
  --r-bg: #121212; --r-fg: #d8d4cc; --r-muted: #7c776f; --r-chrome: rgba(28, 28, 28, .97);
  --r-panel: #1c1c1c; --r-line: rgba(255, 255, 255, .09); --r-accent: #e8c170; --r-hover: rgba(255, 255, 255, .06);
  color-scheme: dark;
}

.r-viewport {
  position: absolute; inset: 0; padding-top: 52px; padding-bottom: 44px;
  overflow: hidden; overflow: clip; touch-action: manipulation;
}
#reader[data-layout="scroll"] .r-viewport { overflow-y: auto; padding-bottom: 0; scrollbar-width: thin; }
.r-content {
  height: 100%; column-fill: auto;
  font-family: var(--r-font); font-size: var(--r-size); line-height: var(--r-lh);
  text-align: var(--r-align); hyphens: auto; -webkit-hyphens: auto;
  orphans: 2; widows: 2; overflow-wrap: break-word;
  will-change: transform;
}
#reader[data-layout="scroll"] .r-content { height: auto; padding-bottom: 40vh; will-change: auto; max-width: 720px; margin: 0 auto; }
.r-content > :first-child { margin-top: 0; }
.r-content h1, .r-content h2, .r-content h3 { text-align: left; break-after: avoid; hyphens: manual; line-height: 1.25; }
.r-content h1 { font-size: 1.45em; margin: 1.6em 0 .6em; font-weight: 700; }
.r-content h1.sermon-title { font-size: 1.9em; text-align: center; margin: 1.4em 0 .4em; text-wrap: balance; }
.r-content h2 { font-size: 1.2em; margin: 1.4em 0 .5em; font-weight: 700; }
.r-content h3 { font-size: 1.05em; margin: 1.2em 0 .4em; font-weight: 700; }
.r-content p { margin: 0 0 .85em; }
.r-content p.sermon-subtitle { text-align: center; font-style: italic; color: var(--r-muted); margin-bottom: 2em; }
.r-content blockquote {
  margin: 1.1em 0; padding: .1em 0 .1em 1em; border-left: 3px solid var(--r-accent); font-style: italic;
}
.r-content blockquote p:last-child { margin-bottom: 0; }
.r-content blockquote.intense { font-size: 1.08em; }
.r-content ul, .r-content ol { padding-left: 1.4em; margin: 0 0 .85em; }
.r-content li { margin-bottom: .3em; text-align: left; }
.r-content img { max-width: 100%; max-height: 70vh; height: auto; display: block; margin: 1em auto; break-inside: avoid; border-radius: 4px; }
.r-content table { border-collapse: collapse; margin: 1em 0; font-size: .9em; break-inside: avoid; }
.r-content td, .r-content th { border: 1px solid var(--r-line); padding: .3em .5em; }
.r-content a { color: var(--r-accent); }

/* ---- Formato padrão Pregar ---- */
.r-content p.s-texto, .r-content p.s-tema { text-align: center; margin: 0 0 .7em; hyphens: manual; }
.r-content p.s-texto { font-style: italic; }
.r-content .s-k {
  display: block; font: 600 .6em/1.6 'Inter', sans-serif; font-style: normal; letter-spacing: .14em; text-transform: uppercase; color: var(--r-accent);
}
.r-content p.s-tema + h2, .r-content p.s-texto + h2, .r-content p.s-tema + h3, .r-content p.s-texto + h3 { margin-top: 2em; }
.r-content h2.s-point {
  font-size: 1.22em; margin: 1.8em 0 .6em; padding-top: .9em; border-top: 1px solid var(--r-line);
  display: flex; gap: .55em; align-items: baseline;
}
.r-content h2.s-point[data-n]::before {
  content: attr(data-n); flex: none; display: inline-grid; place-items: center; width: 1.65em; height: 1.65em; border-radius: 50%;
  background: var(--r-accent); color: var(--r-bg); font: 700 .7em/1 'Inter', sans-serif; transform: translateY(-.12em);
}
.r-content h2.s-intro { border-top: none; padding-top: 0; }
.r-content h3.s-label {
  font: 700 .7em/1.3 'Inter', sans-serif; letter-spacing: .1em; text-transform: uppercase; color: var(--lc, var(--r-muted));
  margin: 1.5em 0 .55em; display: flex; align-items: center; gap: .5em;
}
.r-content h3.s-label::before { font-size: 1.35em; letter-spacing: 0; }
.r-content h3.s-label::after { content: ''; flex: 1; height: 1px; background: currentColor; opacity: .25; }
.s-exp { --lc: #2563eb; } .s-exp::before { content: '📖'; }
.s-apl { --lc: #15803d; } .s-apl::before { content: '🔥'; }
.s-ctx { --lc: #8a6a3b; } .s-ctx::before { content: '🏛'; }
.s-ilu { --lc: #7c3aed; } .s-ilu::before { content: '💡'; }
.s-ref { --lc: #c2410c; } h3.s-ref::before { content: '🙏'; }
.s-sec::before { content: '◆'; color: var(--r-accent); font-size: .9em !important; }
#reader[data-theme="dark"] .s-exp { --lc: #7ab0ff; }
#reader[data-theme="dark"] .s-apl { --lc: #5fd38a; }
#reader[data-theme="dark"] .s-ctx { --lc: #d1b07a; }
#reader[data-theme="dark"] .s-ilu { --lc: #b89bff; }
#reader[data-theme="dark"] h3.s-ref { --lc: #ffa36b; }
.r-content blockquote.s-verse {
  font-style: italic; border-left: 3px solid var(--r-accent); padding: .65em .9em; border-radius: 0 .5em .5em 0;
  background: color-mix(in srgb, var(--r-accent) 9%, transparent); text-align: left;
}
.r-content blockquote.s-verse p.s-cite {
  font: 600 .72em/1.4 'Inter', sans-serif; font-style: normal; color: var(--r-accent); margin-top: .5em; letter-spacing: .02em;
}
.r-content p.s-ref { font-size: .92em; color: var(--r-accent); text-align: left; }
.r-content p.s-ref::before { content: '📖 '; }
.r-content p.s-key {
  font-weight: 600; text-align: left; padding: .15em 0 .15em .8em; border-left: 3px solid var(--r-accent);
}
.r-content p.s-lead { font-weight: 700; margin-bottom: .35em; text-align: left; }
.r-content ul.s-check { list-style: none; padding-left: .2em; }
.r-content ul.s-check li { padding-left: 1.4em; position: relative; }
.r-content ul.s-check li::before { content: '✓'; position: absolute; left: 0; color: var(--r-accent); font-weight: 700; }
.r-content ol.s-steps { padding-left: 1.6em; }
.r-content ol.s-steps li::marker { color: var(--r-accent); font-weight: 700; }
.toc-n {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 50%; margin-right: 8px;
  background: var(--r-accent); color: var(--r-bg); font-size: 11px; vertical-align: 1px;
}
.r-content ::selection { background: rgba(120, 160, 255, .35); }

/* Marcações */
.ann { cursor: pointer; border-radius: 2px; transition: background .2s, box-shadow .2s; }
.ann-highlight {
  background: var(--hl); -webkit-box-decoration-break: clone; box-decoration-break: clone;
  padding: .05em 0;
}
#reader:not([data-theme="dark"]) .ann-highlight { mix-blend-mode: multiply; }
.ann-underline {
  text-decoration: underline; text-decoration-color: var(--ul); text-decoration-thickness: .13em;
  text-underline-offset: .2em; text-decoration-skip-ink: none;
}
/* Esboço = caixinha colorida em volta do trecho */
.ann-box {
  border-top: .12em solid var(--ul); border-bottom: .12em solid var(--ul);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  padding: .02em 0;
}
.ann-box.ann-first { border-left: .12em solid var(--ul); padding-left: .12em; border-top-left-radius: .2em; border-bottom-left-radius: .2em; }
.ann-box.ann-last { border-right: .12em solid var(--ul); padding-right: .12em; border-top-right-radius: .2em; border-bottom-right-radius: .2em; }
.ann.has-note.ann-last::after {
  content: ''; display: inline-block; width: .62em; height: .62em; margin-left: .18em; vertical-align: .45em;
  background: var(--ul); border-radius: 50% 50% 50% 0; opacity: .9;
}
.ann.in-outline.ann-first::before {
  content: attr(data-n); display: inline-block; font: 700 .58em/1 'Inter', sans-serif; color: #fff;
  background: var(--ul); border-radius: 4px; padding: .28em .42em; margin-right: .35em; vertical-align: .2em;
  font-style: normal; letter-spacing: .02em;
}
.ann.flash { box-shadow: 0 0 0 3px var(--ul); }

.c-yellow { --hl: #fde68a; --ul: #ca8a04; --sw: #facc15; }
.c-green  { --hl: #bbf7d0; --ul: #16a34a; --sw: #4ade80; }
.c-blue   { --hl: #bfdbfe; --ul: #2563eb; --sw: #60a5fa; }
.c-pink   { --hl: #fbcfe8; --ul: #db2777; --sw: #f472b6; }
.c-orange { --hl: #fed7aa; --ul: #ea580c; --sw: #fb923c; }
.c-purple { --hl: #ddd6fe; --ul: #7c3aed; --sw: #a78bfa; }
#reader[data-theme="dark"] .c-yellow { --hl: rgba(250, 204, 21, .3); --ul: #facc15; }
#reader[data-theme="dark"] .c-green  { --hl: rgba(74, 222, 128, .26); --ul: #4ade80; }
#reader[data-theme="dark"] .c-blue   { --hl: rgba(96, 165, 250, .3); --ul: #60a5fa; }
#reader[data-theme="dark"] .c-pink   { --hl: rgba(244, 114, 182, .3); --ul: #f472b6; }
#reader[data-theme="dark"] .c-orange { --hl: rgba(251, 146, 60, .3); --ul: #fb923c; }
#reader[data-theme="dark"] .c-purple { --hl: rgba(167, 139, 250, .32); --ul: #a78bfa; }

/* Barras do leitor */
.r-runhead {
  position: absolute; top: 0; left: 0; right: 0; height: 52px; padding: 0 72px;
  display: flex; align-items: center; justify-content: center;
  font: 500 12px/1 'Inter', sans-serif; color: var(--r-muted); letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.r-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20; height: 52px;
  display: flex; align-items: center; gap: 2px; padding: 0 8px;
  background: var(--r-chrome); border-bottom: 1px solid var(--r-line);
  font-family: 'Inter', sans-serif;
  transform: translateY(-100%); transition: transform .22s ease;
}
.r-title { flex: 1; min-width: 0; text-align: center; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px; }
.r-btn {
  height: 40px; min-width: 40px; padding: 0 8px; border: none; border-radius: 10px; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; color: var(--r-fg); font-size: 14px; font-weight: 500;
}
.r-btn:hover { background: var(--r-hover); }
.r-btn svg { width: 21px; height: 21px; }
.r-aa { font: 600 17px/1 'Literata', Georgia, serif; }
.r-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 14px var(--mx, 24px) 50px; background: var(--r-chrome); border-top: 1px solid var(--r-line);
  font-family: 'Inter', sans-serif; transform: translateY(100%); transition: transform .22s ease;
}
#reader.chrome-on .r-top, #reader.chrome-on .r-bottom { transform: none; }
.r-binfo { font-size: 12px; color: var(--r-muted); text-align: center; margin-top: 6px; }
#scrub { width: 100%; accent-color: var(--r-accent); }
.r-status {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 21; height: 44px;
  display: flex; justify-content: space-between; align-items: center; padding: 0 var(--mx, 24px);
  padding-bottom: env(safe-area-inset-bottom);
  font: 12px/1 'Inter', sans-serif; color: var(--r-muted); pointer-events: none; font-variant-numeric: tabular-nums;
}
#reader[data-layout="scroll"] .r-status { background: linear-gradient(transparent, var(--r-bg) 40%); }

/* Barra de marcação (seleção) */
.sel-pop {
  position: fixed; z-index: 50; background: #26231f; color: #f3efe8; border-radius: 14px; padding: 10px;
  box-shadow: 0 16px 40px -10px rgba(0, 0, 0, .55); font-family: 'Inter', sans-serif;
  display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 16px);
  animation: pop .14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.pop-note {
  font-size: 13px; line-height: 1.45; padding: 8px 10px; background: rgba(255, 255, 255, .07); border-radius: 8px;
  max-width: 340px; max-height: 120px; overflow: auto; white-space: pre-wrap;
}
.pop-colors { display: flex; gap: 10px; justify-content: center; }
.dot {
  width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--sw); padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); transition: transform .12s;
}
.dot:hover { transform: scale(1.1); }
.dot.on { box-shadow: 0 0 0 2px #26231f, 0 0 0 4px #f3efe8; }
.dot.sm { width: 22px; height: 22px; }
.pop-tools { display: flex; gap: 2px; align-items: stretch; flex-wrap: wrap; justify-content: center; }
.pop-tools > button, .pop-tools .seg button {
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 48px; padding: 6px 3px;
  border: none; border-radius: 9px; background: transparent; color: inherit; font-size: 10.5px; font-weight: 500;
}
.pop-tools svg { width: 19px; height: 19px; }
.pop-tools button:hover { background: rgba(255, 255, 255, .09); }
.pop-tools button.on { background: rgba(255, 255, 255, .16); }
.pop-tools .seg { display: flex; gap: 2px; padding-right: 4px; margin-right: 2px; border-right: 1px solid rgba(255, 255, 255, .14); }
.pop-tools .danger { color: #fca5a5; }

/* Painel lateral */
.panel {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 40; width: min(400px, 100%);
  display: flex; flex-direction: column; background: var(--r-panel); color: var(--r-fg);
  border-left: 1px solid var(--r-line); box-shadow: -20px 0 50px -24px rgba(0, 0, 0, .4);
  font-family: 'Inter', sans-serif; animation: slide .2s ease-out;
}
@keyframes slide { from { transform: translateX(24px); } }
.panel-head { display: flex; align-items: center; padding: 6px 6px 0 12px; border-bottom: 1px solid var(--r-line); }
.tabs { display: flex; flex: 1; }
.tabs button {
  border: none; background: none; padding: 12px 10px 11px; font-size: 14px; font-weight: 600; color: var(--r-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.on { color: var(--r-fg); border-bottom-color: var(--r-accent); }
.panel-body { flex: 1; overflow-y: auto; padding: 14px 16px 24px; }
.panel-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--r-line); }
.panel-foot:empty { display: none; }
.pbtn {
  flex: 1; height: 38px; border-radius: 10px; border: 1px solid var(--r-line); background: transparent;
  font-size: 13px; font-weight: 600; color: var(--r-fg);
}
.pbtn:hover { background: var(--r-hover); }
.p-empty { text-align: center; padding: 40px 12px; color: var(--r-muted); font-size: 14px; line-height: 1.55; }
.p-empty strong { display: block; color: var(--r-fg); font-size: 15px; margin-bottom: 6px; }

.toc { list-style: none; margin: 0; padding: 0; }
.toc-item {
  width: 100%; display: flex; gap: 12px; align-items: baseline; text-align: left; border: none; background: none;
  padding: 10px 8px; border-radius: 8px; font-size: 14.5px; color: var(--r-fg);
}
.toc-item:hover { background: var(--r-hover); }
.toc-item span { flex: 1; }
.toc-item em { font-style: normal; font-size: 12px; color: var(--r-muted); font-variant-numeric: tabular-nums; }
.toc-item.lv1 { font-weight: 600; }
.toc-item.lv2 { padding-left: 24px; }
.toc-item.lv3 { padding-left: 40px; font-size: 13.5px; }
.toc-item.cur { color: var(--r-accent); }

.nb-filters { position: sticky; top: -14px; background: var(--r-panel); padding: 2px 0 12px; margin-top: -2px; z-index: 1; }
.pchips { display: flex; gap: 6px; flex-wrap: wrap; }
.pchip {
  height: 30px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--r-line); background: transparent;
  font-size: 12.5px; font-weight: 500; color: var(--r-fg);
}
.pchip b { color: var(--r-muted); font-weight: 600; }
.pchip.on { background: var(--r-fg); color: var(--r-bg); border-color: var(--r-fg); }
.pchip.on b { color: inherit; opacity: .7; }
.nb-dots { display: flex; gap: 10px; margin-top: 12px; }
.nb-dots .dot.on { box-shadow: 0 0 0 2px var(--r-panel), 0 0 0 4px var(--r-fg); }
.nb-item {
  display: flex; gap: 12px; width: 100%; text-align: left; border: none; background: none; padding: 12px 8px;
  border-radius: 10px; color: var(--r-fg); border-bottom: 1px solid var(--r-line);
}
.nb-item:hover { background: var(--r-hover); }
.nb-bar { width: 4px; border-radius: 4px; background: var(--sw); flex: none; }
.nb-main { flex: 1; min-width: 0; display: block; }
.nb-meta { display: block; font-size: 11.5px; color: var(--r-muted); margin-bottom: 4px; }
.nb-quote { display: block; font-family: var(--r-font); font-size: 15px; line-height: 1.5; }
.nb-note {
  display: flex; gap: 6px; margin-top: 8px; font-size: 13.5px; line-height: 1.45; padding: 8px 10px;
  background: var(--r-hover); border-radius: 8px; white-space: pre-wrap;
}
.nb-note svg { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--r-accent); }

.ol-head { text-align: center; padding: 6px 0 16px; border-bottom: 1px solid var(--r-line); margin-bottom: 8px; }
.ol-title { font: 700 18px/1.3 'Literata', Georgia, serif; }
.ol-ref { font: italic 14px 'Literata', Georgia, serif; color: var(--r-muted); margin-top: 4px; }
.outline { list-style: none; margin: 0; padding: 0; }
.ol-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--r-line); }
.ol-item.lv1 { padding-left: 22px; }
.ol-item.lv2 { padding-left: 44px; }
.ol-n {
  flex: none; min-width: 28px; height: 24px; padding: 0 6px; border-radius: 6px; background: var(--ul); color: #fff;
  font-size: 12px; font-weight: 700; display: grid; place-items: center; margin-top: 1px;
}
.ol-main { flex: 1; min-width: 0; }
.ol-text {
  font-family: var(--r-font); font-size: 15px; line-height: 1.45; outline: none; border-radius: 6px; padding: 1px 4px; margin: -1px -4px;
}
.ol-item.lv0 .ol-text { font-weight: 600; }
.ol-text:focus { background: var(--r-hover); box-shadow: 0 0 0 1px var(--r-accent); }
.ol-go { border: none; background: none; padding: 4px 0 0; font-size: 12px; color: var(--r-accent); font-weight: 500; }
.ol-ctrl { display: flex; gap: 2px; flex: none; }
.ol-ctrl button {
  width: 28px; height: 28px; border: none; border-radius: 7px; background: transparent; color: var(--r-muted);
  font-size: 17px; line-height: 1;
}
.ol-ctrl button:hover:not(:disabled) { background: var(--r-hover); color: var(--r-fg); }
.ol-ctrl button:disabled { opacity: .3; cursor: default; }

/* Aparência (Aa) */
#reader dialog.dlg { background: var(--r-panel); color: var(--r-fg); font-family: 'Inter', sans-serif; }
.set-dlg { width: 440px; padding: 0 !important; margin: 58px 12px auto auto; overflow: hidden; }
.set-dlg::backdrop { background: transparent; }
.set-grip { display: none; width: 36px; height: 4px; border-radius: 4px; background: var(--r-line); margin: 8px auto 0; }
.set-tabs { display: flex; gap: 4px; padding: 6px 14px 0; border-bottom: 1px solid var(--r-line); }
.set-tabs button {
  border: none; background: none; padding: 12px 10px 10px; font-size: 15px; font-weight: 500; color: var(--r-muted);
  border-bottom: 2.5px solid transparent; margin-bottom: -1px;
}
.set-tabs button.on { color: var(--r-accent); border-bottom-color: var(--r-accent); font-weight: 600; }
.set-pane { padding: 16px 18px 6px; min-height: 236px; }
.font-row {
  display: flex; gap: 4px; overflow-x: auto; margin: 0 -18px 14px; padding: 2px 14px 12px;
  border-bottom: 1px solid var(--r-line); scrollbar-width: none; scroll-snap-type: x proximity;
}
.font-row::-webkit-scrollbar { display: none; }
.font-row button {
  flex: none; width: 82px; border: none; background: none; border-radius: 10px; padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--r-fg); scroll-snap-align: center;
}
.font-row .aa { font-size: 34px; line-height: 1.1; }
.font-row .fn { font-size: 11.5px; color: var(--r-muted); white-space: nowrap; }
.font-row button:hover { background: var(--r-hover); }
.font-row button.on .aa, .font-row button.on .fn { color: var(--r-accent); }
.font-row button.on .fn { font-weight: 600; }
.set-hint { margin: 2px 0 14px; text-align: center; font-size: 12px; color: var(--r-muted); }
.set-desc { display: block; font-size: 12.5px; color: var(--r-muted); margin: -4px 0 8px; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--r-line); cursor: pointer; }
.toggle span { flex: 1; }
.toggle b { display: block; font-size: 14.5px; font-weight: 600; }
.toggle small { display: block; font-size: 12.5px; color: var(--r-muted); margin-top: 2px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--r-accent); }
.bright { display: flex; align-items: center; gap: 12px; padding: 14px 18px 18px; border-top: 1px solid var(--r-line); }
.bright svg { width: 20px; height: 20px; flex: none; color: var(--r-muted); }
.bright svg.big { width: 26px; height: 26px; }
.bright input[type=range] { flex: 1; accent-color: var(--r-accent); }
.bright .auto { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--r-muted); cursor: pointer; }
.bright .auto input { width: 18px; height: 18px; accent-color: var(--r-accent); margin: 0; }
.r-dim { position: absolute; inset: 0; z-index: 45; background: #000; opacity: 0; pointer-events: none; transition: opacity .15s; }
.r-clock {
  position: absolute; top: 0; left: var(--mx, 24px); height: 52px; display: flex; align-items: center;
  font: 500 12px/1 'Inter', sans-serif; color: var(--r-muted); pointer-events: none; font-variant-numeric: tabular-nums;
}
#reader.no-clock .r-clock { display: none; }
#reader.no-time #stTime { visibility: hidden; }
.set-row { margin-bottom: 16px; }
.set-row:last-child { margin-bottom: 0; }
.set-label { display: block; font-size: 12px; font-weight: 600; color: var(--r-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.set-label em { font-style: normal; text-transform: none; letter-spacing: 0; margin-left: 4px; }
.seg.wide { display: flex; background: var(--r-hover); border-radius: 10px; padding: 3px; gap: 3px; }
.seg.wide button {
  flex: 1; height: 34px; border: none; border-radius: 8px; background: transparent; font-size: 13px; font-weight: 500; color: var(--r-fg);
}
.seg.wide button.on { background: var(--r-bg); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); font-weight: 600; }
.size { display: flex; align-items: center; gap: 10px; }
.size input { flex: 1; accent-color: var(--r-accent); }
.size button { border: 1px solid var(--r-line); background: transparent; border-radius: 8px; width: 38px; height: 34px; font-family: 'Literata', serif; color: var(--r-fg); }
.a-sm { font-size: 13px; }
.a-lg { font-size: 20px; }
.themes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.themes button {
  height: 96px; border-radius: 12px; border: 2px solid rgba(0, 0, 0, .1); font-size: 12.5px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.themes .aa { font: 600 28px/1 'Literata', Georgia, serif; }
.themes button.on { border-color: var(--r-accent); }
.th-white { background: #fff; color: #1b1b1b; }
.th-sepia { background: #f4ecd8; color: #4f3d2c; }
.th-green { background: #cfe3cb; color: #1f2e1f; }
.th-dark { background: #121212; color: #d8d4cc; }

.note-dlg { width: 520px; }
.note-dlg form { padding: 22px; }
.note-dlg h3 { margin: 0 0 12px; font-size: 17px; }
.note-dlg blockquote {
  margin: 0 0 14px; padding: 4px 0 4px 12px; border-left: 3px solid var(--r-accent); font-family: var(--r-font);
  font-style: italic; font-size: 14.5px; max-height: 110px; overflow: auto; color: var(--r-muted);
}
.note-dlg textarea {
  width: 100%; border-radius: 10px; border: 1px solid var(--r-line); background: var(--r-bg); padding: 12px;
  font-size: 15px; line-height: 1.5; resize: vertical; outline: none; color: var(--r-fg);
}
.note-dlg textarea:focus { border-color: var(--r-accent); }
#reader .btn { background: transparent; border-color: var(--r-line); color: var(--r-fg); }
#reader .btn:hover { background: var(--r-hover); }
#reader .btn.primary { background: var(--r-fg); color: var(--r-bg); border-color: transparent; }
#reader .btn.danger { color: #dc2626; border-color: transparent; }

/* ================= Foto do esboço ================= */
.photo-dlg { width: 640px; display: flex; flex-direction: column; max-height: min(88vh, 900px); }
.photo-dlg[open] { display: flex; }
.ph-body { padding: 22px 22px 8px; overflow-y: auto; min-height: 0; }
.ph-body h3 { margin: 0 0 4px; font-size: 19px; }
.ph-intro { margin: 0 0 16px; font-size: 14px; line-height: 1.5; }
.ph-btns { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ph-btns label.btn { cursor: pointer; }
.ph-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin: 14px 0; }
.ph-thumbs:empty { display: none; }
.ph-thumb { position: relative; margin: 0; aspect-ratio: 3 / 4; max-width: 100%; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.ph-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-thumb figcaption { position: absolute; left: 6px; bottom: 6px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.ph-x { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border-radius: 50%; border: none; background: rgba(0, 0, 0, .6); color: #fff; font-size: 16px; line-height: 1; }
.ph-opts { margin-top: 6px; }
.ph-opts .toggle { border-bottom-color: var(--line); }
.ph-opts .toggle small { color: var(--muted); }
.ph-opts .toggle input { accent-color: var(--gold); }
.ph-status { margin: 12px 0 4px; padding: 11px 14px; border-radius: 10px; font-size: 14px; background: var(--surface-2); }
.ph-status[data-kind="error"] { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.ph-status[data-kind="warn"] { background: color-mix(in srgb, var(--gold) 16%, transparent); }
.photo-dlg[data-stage="busy"] .ph-status::before {
  content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 9px; vertical-align: -1px;
  border: 2px solid var(--gold); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ph-notes { font-size: 13px; color: var(--muted); margin: -4px 0 12px; }
.ph-notes p { margin: 0 0 4px; }
.ph-notes .warn { color: var(--gold); font-weight: 600; }
.ph-notes summary { cursor: pointer; font-weight: 600; color: var(--text); }
.ph-notes ul { margin: 6px 0 0; padding-left: 18px; }
.ph-preview {
  --r-bg: var(--bg); --r-fg: var(--text); --r-muted: var(--muted); --r-line: var(--line); --r-accent: var(--gold); --r-hover: var(--surface-2);
  --r-font: 'Literata', Georgia, serif; --r-size: 16px; --r-lh: 1.6; --r-align: left;
  height: auto; border: 1px solid var(--line); border-radius: 12px; padding: 4px 18px 10px; background: var(--bg); color: var(--text);
}
.ph-actions { padding: 12px 22px 18px; margin: 0; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ================= Tipo (Sermões / Estudos / Infantil) e baixar meus sermões ================= */
.lib-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 12px; }
.lib-tools:not(:has(> :not([hidden]))) { display: none; }
.cat-seg { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 10px; overflow-x: auto; scrollbar-width: none; }
.cat-seg button { border: none; background: transparent; padding: 7px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.cat-seg button b { font-weight: 600; opacity: .7; margin-left: 2px; }
.cat-seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; }
#btnMeus { margin-left: auto; }
#meusInfo[data-kind="ok"] { background: color-mix(in srgb, #16a34a 14%, transparent); }
#meusInfo[data-kind="error"] { background: color-mix(in srgb, var(--danger) 14%, transparent); }

/* ================= Colar texto ================= */
.paste-dlg { width: 600px; }
.paste-form { padding: 22px; }
.paste-form h3 { margin: 0 0 4px; font-size: 19px; }
.paste-form textarea {
  display: block; width: 100%; margin-top: 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  padding: 12px; font: 15px/1.5 'Inter', sans-serif; text-transform: none; letter-spacing: 0; color: var(--text); resize: vertical;
}
.paste-form .opt { text-transform: none; letter-spacing: 0; font-weight: 400; }
#pasteInfo { margin: -6px 0 10px; min-height: 1em; }

/* ================= Confirmação ================= */
.confirm-dlg { width: 420px; }
.confirm-dlg form { padding: 22px; }
.confirm-dlg p { margin: 0; font-size: 15px; line-height: 1.5; }
.btn.danger-fill { background: var(--danger); color: #fff; }

/* ================= Áreas seguras do celular (notch / barra de gestos) ================= */
.lib-top { top: env(safe-area-inset-top, 0px); }
body[data-view="library"]::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg);
}
.r-top { height: calc(52px + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px); }
.r-runhead, .r-clock { top: env(safe-area-inset-top, 0px); }
.r-viewport { padding-top: calc(52px + env(safe-area-inset-top, 0px)); padding-bottom: calc(44px + env(safe-area-inset-bottom, 0px)); }
#reader[data-layout="scroll"] .r-viewport { padding-bottom: 0; }
.r-status { height: calc(44px + env(safe-area-inset-bottom, 0px)); }
.r-bottom { padding-bottom: calc(50px + env(safe-area-inset-bottom, 0px)); }
.panel { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }

/* ================= Responsivo ================= */
@media (max-width: 640px) {
  .lib-top { flex-wrap: wrap; gap: 10px 12px; }
  .brand { font-size: 22px; }
  .lib-top > .lib-search { order: 3; flex-basis: 100%; max-width: none; }
  body[data-sub="igrejas"] .lib-top > .lib-search,
  body[data-sub="biblioteca"] .lib-top > .lib-search { display: none; }
  .lib-nav a { padding: 7px 6px; font-size: 13.5px; }
  .lib-nav { order: 4; flex-basis: 100%; }
  .lib-nav a { flex: 1; text-align: center; }
  .ch-head h1 { font-size: 23px; }
  .ch-tools { width: 100%; }
  .lib-search.sm { flex: 1; width: auto; }
  .tiles.sm { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pf-grid { grid-template-columns: 1fr; }
  .pf-grid .span2 { grid-column: auto; }
  .pf-check { padding-top: 0; margin-bottom: 14px; }
  .hist th:nth-child(3), .hist td:nth-child(3) { display: none; }
  #btnUpload { height: 38px; padding: 0 12px; }
  #btnPaste { margin-left: auto; height: 38px; padding: 0 10px; }
  #btnPhoto { height: 38px; padding: 0 10px; }
  #btnPhoto span, #btnPaste span { display: none; }
  .paste-dlg { width: 100%; }
  .paste-form { padding: 18px 16px; }
  .photo-dlg { width: 100%; max-height: 92vh; }
  .ph-body { padding: 18px 16px 8px; }
  .ph-actions { padding: 12px 16px 16px; }
  .ph-actions .sp { display: none; }
  .ph-actions .btn { flex: 1 1 0; padding: 0 10px; }
  .lib-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .chips { margin: 0 -16px; padding: 2px 16px; }
  .sort { justify-content: flex-end; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 16px; }
  .continue-card { padding: 14px; gap: 16px; }
  .continue-cover { width: 76px; }
  .continue-body h2 { font-size: 18px; }
  .empty h1 { font-size: 26px; }
  .details { flex-direction: column; padding: 20px; }
  .details-cover { width: 130px; margin: 0 auto; }
  .hide-sm { display: none; }
  .set-dlg { width: 100%; max-width: 100% !important; margin: auto 0 0; border-radius: 18px 18px 0 0 !important; padding-bottom: env(safe-area-inset-bottom) !important; }
  .set-grip { display: block; }
  .themes button { height: 80px; }
  .note-dlg { width: 100%; }
  .r-runhead { padding: 0 84px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
