:root {
  --bg: #fbf9f4; --surface: #ffffff; --text: #23211d; --muted: #6b665d; --line: #e4dfd3;
  --accent: #1f3a5f; --accent-text: #ffffff; --accent-soft: #e8eef7; --focus: #2f6fd1;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --surface: #1b1f26; --text: #e8e5de; --muted: #9a958a; --line: #2b313a;
    --accent: #8fb4e8; --accent-text: #0f1722; --accent-soft: #212a38; --focus: #7aa7ee;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171c; --surface: #1b1f26; --text: #e8e5de; --muted: #9a958a; --line: #2b313a;
  --accent: #8fb4e8; --accent-text: #0f1722; --accent-soft: #212a38; --focus: #7aa7ee;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--fs, 100%); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; max-width: 46rem; margin: 0 auto; padding: 1.25rem 1.1rem 3rem; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; }
h1 { font-family: var(--serif); font-size: 1.9rem; margin: .4rem 0 .6rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Cabeçalho */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .brand { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; margin-right: auto; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 2.5rem; height: 2.5rem; padding: 0 .6rem; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: .6rem; font: inherit; cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--accent-soft); }
.burger, .burger::before, .burger::after { display: block; width: 1.2rem; height: 2px; background: currentColor; content: ""; position: relative; border-radius: 2px; }
.burger::before { position: absolute; top: -6px; } .burger::after { position: absolute; top: 6px; }

/* Menu lateral */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); opacity: 0; visibility: hidden; transition: opacity .2s; z-index: 30; }
.drawer { position: fixed; inset: 0 auto 0 0; width: min(20rem, 88vw); background: var(--surface); border-right: 1px solid var(--line); z-index: 40; transform: translateX(-102%); visibility: hidden; transition: transform .22s ease, visibility .22s; padding: 1rem; overflow-y: auto; }
body.menu-open .drawer { transform: none; visibility: visible; }
body.menu-open .scrim { opacity: 1; visibility: visible; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.drawer-head strong { font-family: var(--serif); font-size: 1.1rem; }
.drawer nav a { display: block; padding: .75rem .6rem; border-radius: .5rem; color: var(--text); text-decoration: none; font-weight: 600; }
.drawer nav a:hover, .drawer nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.drawer h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.4rem .6rem .5rem; }

/* Busca por passagem */
.search { display: grid; grid-template-columns: 1fr 5.5rem auto; gap: .5rem; align-items: end; }
.search label { font-size: .8rem; color: var(--muted); display: block; margin-bottom: .2rem; }
.search select, .search input { width: 100%; height: 2.6rem; padding: 0 .6rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--bg); color: var(--text); font: inherit; }
.search button { height: 2.6rem; padding: 0 1rem; border: 0; border-radius: .6rem; background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 700; cursor: pointer; }
.search-error { grid-column: 1 / -1; margin: 0; color: #b3261e; font-size: .9rem; }
:root[data-theme="dark"] .search-error { color: #ff8a80; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .search-error { color: #ff8a80; } }
.drawer .search { grid-template-columns: 1fr 5rem; }
.drawer .search button { grid-column: 1 / -1; }

/* Início */
.hero { padding: 1.2rem 0 1.6rem; }
.hero p { margin: 0 0 1.2rem; color: var(--muted); font-size: 1.05rem; }
.hero .search-card { background: var(--surface); border: 1px solid var(--line); border-radius: .9rem; padding: 1rem; }
.section-title { font-family: var(--serif); font-size: 1.3rem; margin: 2rem 0 .8rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
.books { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: .5rem; }
.books a { display: flex; justify-content: space-between; align-items: baseline; gap: .4rem; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--surface); color: var(--text); text-decoration: none; }
.books a:hover { border-color: var(--accent); }
.books small { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.inter-card { display: block; margin: 1.6rem 0 0; padding: 1rem; border: 1px dashed var(--accent); border-radius: .8rem; text-decoration: none; color: var(--text); background: var(--accent-soft); }
.inter-card strong { display: block; font-family: var(--serif); font-size: 1.1rem; color: var(--accent); }

/* Capítulos */
.crumbs { font-size: .85rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.chapters { list-style: none; margin: 1rem 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(3.2rem, 1fr)); gap: .45rem; }
.chapters a { display: flex; align-items: center; justify-content: center; height: 2.8rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--surface); color: var(--muted); text-decoration: none; font-weight: 600; }
.chapters a.has { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
.legend { font-size: .85rem; color: var(--muted); }
.legend i { display: inline-block; width: .8rem; height: .8rem; border-radius: .2rem; background: var(--accent); vertical-align: -1px; margin-right: .25rem; }

.tools { display: flex; flex-wrap: wrap; gap: .5rem; margin: .6rem 0 1.2rem; }
.btn { display: inline-flex; align-items: center; gap: .4rem; height: 2.5rem; padding: 0 .9rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--accent-soft); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.whatsapp { background: #1f9d55; border-color: #1f9d55; color: #fff; }
.btn[disabled] { opacity: .55; cursor: default; }
.tools .spacer { flex: 1; }
.sharemenu { display: flex; flex-wrap: wrap; gap: .5rem; margin: -.5rem 0 1.2rem; }
.sharemenu[hidden] { display: none; }

/* Comentário (usado também no editor do painel) */
.comment { font-family: var(--serif); font-size: 1.15rem; line-height: 1.8; overflow-wrap: anywhere; }
.comment p { margin: 0 0 1.1em; }
.comment h2 { font-size: 1.5em; margin: 1.6em 0 .5em; } .comment h3 { font-size: 1.25em; margin: 1.4em 0 .4em; } .comment h4 { font-size: 1.05em; margin: 1.2em 0 .3em; }
.comment blockquote { margin: 1.2em 0; padding: .2em 1em; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 .5rem .5rem 0; }
.comment ul, .comment ol { margin: 0 0 1.1em; padding-left: 1.6em; }
.comment hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.comment a { text-underline-offset: 2px; }
.comment font[size="1"] { font-size: .7em; } .comment font[size="2"] { font-size: .85em; }
.comment font[size="4"] { font-size: 1.2em; } .comment font[size="5"] { font-size: 1.45em; }
.comment font[size="6"] { font-size: 1.8em; } .comment font[size="7"] { font-size: 2.3em; }
.soon { padding: 2rem 1rem; text-align: center; border: 1px dashed var(--line); border-radius: .8rem; color: var(--muted); font-family: var(--serif); font-size: 1.1rem; }
.updated { margin-top: 1.6rem; font-size: .85rem; color: var(--muted); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: 2rem; }
.pager a, .pager span { display: block; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: .7rem; background: var(--surface); text-decoration: none; color: var(--text); }
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.pager .next { text-align: right; }
.pager .none { visibility: hidden; }

/* Configurações */
.setting { background: var(--surface); border: 1px solid var(--line); border-radius: .8rem; padding: 1rem; margin-bottom: 1rem; }
.setting h2 { margin: 0 0 .6rem; font-size: 1.05rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: .6rem; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--text); font: inherit; padding: .55rem 1rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.setting input[type=range] { width: 100%; }
.preview { font-family: var(--serif); margin-top: .8rem; }

.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: .6rem; z-index: 60; font-size: .95rem; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 1.5rem 1rem 2rem; border-top: 1px solid var(--line); }
@media (max-width: 30rem) { .search { grid-template-columns: 1fr 5rem; } .search button { grid-column: 1 / -1; } }
@media print { .topbar, .drawer, .scrim, .tools, .sharemenu, .pager, .footer { display: none !important; } body { background: #fff; color: #000; } }
