/* Layout: três colunas — livros | leitura | estudo. Número do capítulo em vermelho rubrica, como nas Bíblias impressas. */
:root {
  --paper: #F3F4F6;
  --surface: #FFFFFF;
  --ink: #1A2130;
  --muted: #5B6474;
  --line: #DCE0E7;
  --rubric: #9E1B32;
  --rubric-soft: #F5E2E6;
  --hl-amarelo: #FBEB9C;
  --hl-verde: #CDEDD1;
  --hl-azul: #CBE0F8;
  --hl-rosa: #F6D0DF;
  --shadow: 0 10px 30px rgba(26, 33, 48, .12);

  --font-read: "Literata", Georgia, "Times New Roman", serif;
  --font-ui: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --reading-size: 1.15rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111419; --surface: #191E26; --ink: #E5E8ED; --muted: #98A1AE; --line: #2A313C;
    --rubric: #EC7286; --rubric-soft: #3A1E26;
    --hl-amarelo: #5A4D12; --hl-verde: #1E4829; --hl-azul: #1B3656; --hl-rosa: #552239;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111419; --surface: #191E26; --ink: #E5E8ED; --muted: #98A1AE; --line: #2A313C;
  --rubric: #EC7286; --rubric-soft: #3A1E26;
  --hl-amarelo: #5A4D12; --hl-verde: #1E4829; --hl-azul: #1B3656; --hl-rosa: #552239;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--font-ui);
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--rubric); outline-offset: 2px; }
a { color: var(--rubric); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font: 700 1.25rem var(--font-read); color: var(--ink); text-decoration: none;
  letter-spacing: .01em;
}
.brand-mark {
  width: 14px; height: 20px; border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%;
  background: var(--rubric);
  box-shadow: 0 0 0 3px var(--rubric-soft);
}
.search { flex: 1; display: flex; max-width: 520px; min-width: 0; }
.search input {
  flex: 1; min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--line); border-right: 0;
  border-radius: 8px 0 0 8px;
  background: var(--paper);
}
.search button {
  padding: 8px 14px; border: 1px solid var(--rubric);
  background: var(--rubric); color: #fff; font-weight: 600;
  border-radius: 0 8px 8px 0;
}
.top-actions { display: flex; gap: 4px; margin-left: auto; }
.icon-btn {
  min-width: 36px; height: 36px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; font-weight: 600; color: var(--muted);
}
.icon-btn:hover { background: var(--paper); color: var(--ink); }
.only-narrow { display: none; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 340px;
  height: calc(100% - 57px);
}
.sidebar, .panel { overflow-y: auto; background: var(--surface); }
.sidebar { border-right: 1px solid var(--line); }
.panel { border-left: 1px solid var(--line); padding: 16px; }
.reader { overflow-y: auto; padding: 28px clamp(16px, 5vw, 64px) 48px; }
.reader > * { max-width: 44rem; margin-inline: auto; }

/* ---------- Segmented control ---------- */
.seg { display: inline-flex; background: var(--paper); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 7px;
  font-weight: 600; font-size: .9rem; color: var(--muted);
}
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg.small button { padding: 4px 9px; font-size: .82rem; }

/* ---------- Sidebar ---------- */
.sidebar-head {
  position: sticky; top: 0; background: var(--surface);
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px; border-bottom: 1px solid var(--line);
}
.book-list { list-style: none; margin: 0; padding: 6px 0 24px; }
.book-list button {
  width: 100%; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px;
  padding: 7px 16px; border: 0; background: transparent; text-align: left;
}
.book-list button:hover { background: var(--paper); }
.book-list button.active { background: var(--rubric-soft); color: var(--rubric); font-weight: 600; }
.book-list .mini { width: 34px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.book-list .mini i { display: block; height: 100%; background: var(--rubric); }
.book-group { padding: 12px 16px 4px; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }

/* ---------- Verse of the day ---------- */
.votd {
  margin-bottom: 28px; padding: 18px 20px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.votd blockquote { margin: 6px 0 8px; font: italic 1.08rem/1.6 var(--font-read); }
.votd-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.votd cite { font-style: normal; font-weight: 600; color: var(--muted); }

.eyebrow { font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--rubric); font-weight: 700; }
.link-btn { border: 0; background: none; color: var(--rubric); font-weight: 600; padding: 4px 0; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Chapter header ---------- */
.chapter-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.chapter-head h1 { margin: 2px 0 0; font: 700 clamp(2rem, 5vw, 2.8rem)/1.1 var(--font-read); text-wrap: balance; }
.chapter-tools { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }
.compare { display: flex; align-items: center; gap: 6px; }
.chapter-tools select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); max-width: 190px; }

.chapter-grid { display: flex; flex-wrap: wrap; gap: 4px; margin: 18px auto 26px; }
.chapter-grid button {
  min-width: 34px; height: 32px; padding: 0 6px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--surface);
  font-size: .85rem; font-variant-numeric: tabular-nums; color: var(--muted);
}
.chapter-grid button.read { border-color: transparent; background: var(--rubric-soft); color: var(--rubric); }
.chapter-grid button.active { background: var(--rubric); border-color: var(--rubric); color: #fff; font-weight: 700; }

/* ---------- Text ---------- */
.text { font: var(--reading-size)/1.85 var(--font-read); min-height: 200px; }
.text p { margin: 0; }
.drop {
  float: left; font: 700 calc(var(--reading-size) * 3.6)/.8 var(--font-read);
  color: var(--rubric); margin: 6px 12px 0 0;
  font-variant-numeric: lining-nums;
}
.verse { border-radius: 4px; padding: 1px 1px; cursor: pointer; transition: background .15s; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.verse:hover { background: color-mix(in srgb, var(--rubric-soft) 70%, transparent); }
.verse sup {
  font: 700 .62em var(--font-ui); color: var(--rubric); margin-right: 3px; vertical-align: .5em;
  font-variant-numeric: tabular-nums;
}
.verse.has-note sup::after { content: "•"; margin-left: 1px; }
.verse.hl-amarelo { background: var(--hl-amarelo); }
.verse.hl-verde { background: var(--hl-verde); }
.verse.hl-azul { background: var(--hl-azul); }
.verse.hl-rosa { background: var(--hl-rosa); }
.verse.selected { outline: 2px solid var(--rubric); outline-offset: 1px; }
.verse.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--rubric-soft); } }

/* Comparação lado a lado */
.text.parallel .row-v { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.text.parallel .row-v .other { color: var(--muted); font-size: .92em; }
.text.parallel .row-v .other sup { font: 700 .62em var(--font-ui); color: var(--muted); margin-right: 3px; vertical-align: .5em; }
.text.parallel .drop { display: none; }

.loading, .error { color: var(--muted); font-family: var(--font-ui); font-size: 1rem; }
.error { padding: 16px; border: 1px solid var(--rubric); border-radius: 10px; background: var(--rubric-soft); color: var(--ink); }
.skeleton { height: 1em; margin: .6em 0; border-radius: 4px; background: var(--line); animation: pulse 1.2s infinite alternate; }
@keyframes pulse { to { opacity: .45; } }

.chapter-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 36px; flex-wrap: wrap; }
.btn {
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--rubric);
  background: var(--rubric); color: #fff; font-weight: 600;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.done { background: var(--rubric-soft); color: var(--rubric); border-color: transparent; }
.btn:disabled { opacity: .4; cursor: default; }
.credit { margin-top: 28px; font-size: .8rem; color: var(--muted); text-align: center; }

/* ---------- Panel ---------- */
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.empty { color: var(--muted); font-size: .95rem; padding: 12px 0; }
.vd-text { font: 1.02rem/1.65 var(--font-read); margin: 6px 0 10px; }
.vd-compare { font: italic .92rem/1.55 var(--font-read); color: var(--muted); margin: 0 0 10px; padding-left: 10px; border-left: 2px solid var(--line); }
.field-label { display: block; margin: 16px 0 6px; font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.sw {
  height: 46px; border: 1px solid var(--line); border-radius: 9px;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 4px;
  font-size: .7rem; font-weight: 600; color: var(--ink);
}
.sw-amarelo { background: var(--hl-amarelo); }
.sw-verde { background: var(--hl-verde); }
.sw-azul { background: var(--hl-azul); }
.sw-rosa { background: var(--hl-rosa); }
.sw-none { background: var(--surface); color: var(--muted); }
.sw.active { outline: 2px solid var(--rubric); outline-offset: 1px; }
textarea {
  width: 100%; resize: vertical; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--paper);
  font: .98rem/1.55 var(--font-read);
}
.note-status { font-size: .78rem; color: var(--muted); min-height: 1.2em; margin-top: 4px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; margin-top: 0; }

.nb-list { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 8px; }
.nb-list li button {
  width: 100%; text-align: left; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  display: grid; grid-template-columns: 10px 1fr; gap: 4px 10px;
}
.nb-list li button:hover { border-color: var(--muted); }
.nb-list .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--line); }
.nb-list .dot.amarelo { background: #E2C437; } .nb-list .dot.verde { background: #4CAF68; }
.nb-list .dot.azul { background: #4C8FD8; } .nb-list .dot.rosa { background: #D9668F; }
.nb-list .ref { font-weight: 700; }
.nb-list .snip { grid-column: 2; font: .9rem/1.45 var(--font-read); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nb-list .snip.note { color: var(--ink); font-style: italic; }

.stat { padding: 8px 0 14px; }
.stat-num { font: 700 2.6rem/1 var(--font-read); color: var(--rubric); font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); margin-top: 4px; }
.bar-row { display: flex; justify-content: space-between; font-size: .88rem; margin-top: 10px; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 4px; background: var(--paper); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--rubric); border-radius: 4px; transition: width .4s; }
.pg-books { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.pg-books li { display: grid; grid-template-columns: 1fr 60px 52px; align-items: center; gap: 8px; font-size: .86rem; font-variant-numeric: tabular-nums; }
.pg-books li .n { text-align: right; color: var(--muted); }
.pg-books .bar { margin: 0; height: 5px; }

/* ---------- Toast / scrim ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 10px; z-index: 60;
  box-shadow: var(--shadow); font-weight: 600;
}
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); }
  .panel {
    position: fixed; right: 0; top: 0; bottom: 0; width: min(380px, 100%); z-index: 40;
    transform: translateX(100%); transition: transform .25s; box-shadow: var(--shadow);
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
  }
  .panel.open { transform: none; }
  #btnPanel, #btnClosePanel { display: inline-block; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .only-narrow { display: inline-block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86%); z-index: 40;
    transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow);
    padding-top: env(safe-area-inset-top, 0px);
  }
  .sidebar.open { transform: none; }
  .panel {
    top: auto; width: 100%; max-height: 72%; border-left: 0; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0; transform: translateY(100%);
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .layout { height: calc(100% - 103px); }
  .reader { padding-top: 20px; }
  .text.parallel .row-v { grid-template-columns: 1fr; gap: 4px; }
  #btnFontDown, #btnFontUp { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
