:root {
  --fundo: #000;
  --fundo-2: #0d0d0d;
  --fundo-3: #161616;
  --linha: #232323;
  --texto: #f2f2f2;
  --texto-2: #a3a3a3;
  --texto-3: #6b6b6b;
  --rojo-claro: #e0333e;
  --rojo: #b3141f;
  --rojo-oscuro: #4d050b;
  --degrade: linear-gradient(135deg, #e0333e 0%, #a3121d 45%, #4d050b 100%);
  --degrade-suave: linear-gradient(180deg, rgba(179, 20, 31, .28) 0%, rgba(77, 5, 11, 0) 100%);
  --raio: 14px;
  --topo: env(safe-area-inset-top, 0px);
  --base: env(safe-area-inset-bottom, 0px);
  --letra-leitura: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--fundo); }
body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.pagina {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--topo) + 20px) 18px calc(var(--base) + 40px);
  animation: entra .25s ease-out;
}
@keyframes entra { from { transform: translateY(6px); } to { transform: none; } }

/* ---------- marca ---------- */
.marca { display: flex; align-items: center; gap: 10px; }
.marca img { width: 34px; height: 34px; }
.marca b { font-weight: 600; letter-spacing: .22em; font-size: 13px; }
.marca b span { color: var(--rojo-claro); }

.hero { padding: 34px 0 22px; position: relative; }
.hero::before {
  content: ''; position: absolute; inset: -60px -18px auto; height: 260px;
  background: radial-gradient(70% 80% at 50% 0%, rgba(179, 20, 31, .35), transparent 70%);
  pointer-events: none; z-index: -1;
}
.hero h1 { font-size: 30px; line-height: 1.15; font-weight: 600; margin: 0 0 10px; letter-spacing: -.01em; }
.hero h1 em { font-style: normal; background: var(--degrade); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 0; color: var(--texto-2); font-size: 14px; max-width: 34ch; }

/* ---------- busca e filtros ---------- */
.busca {
  display: flex; align-items: center; gap: 10px;
  background: var(--fundo-3); border: 1px solid var(--linha); border-radius: 12px;
  padding: 0 14px; height: 48px; margin: 6px 0 14px;
}
.busca svg { flex: none; color: var(--texto-3); }
.busca input {
  flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: 0;
  color: var(--texto); font: inherit; font-size: 15px;
}
.busca input::placeholder { color: var(--texto-3); }
.busca:focus-within { border-color: var(--rojo); }

.filtros { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -18px 22px; padding: 0 18px; }
.filtros::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 99px; font-size: 13px; font-weight: 500;
  background: var(--fundo-3); color: var(--texto-2); border: 1px solid var(--linha);
}
.chip[aria-pressed="true"] { background: var(--degrade); color: #fff; border-color: transparent; }

/* ---------- continuar lendo ---------- */
.continuar {
  display: flex; gap: 14px; align-items: center; padding: 12px; margin-bottom: 26px;
  border-radius: var(--raio); background: var(--fundo-2); border: 1px solid var(--linha);
  position: relative; overflow: hidden;
}
.continuar::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--degrade); }
.continuar img { width: 48px; height: 70px; object-fit: cover; border-radius: 6px; }
.continuar div { flex: 1; min-width: 0; }
.continuar small { display: block; color: var(--rojo-claro); font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.continuar strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.continuar span { color: var(--texto-2); font-size: 13px; }
.continuar .seta { color: var(--texto-3); }

/* ---------- grade de livros ---------- */
.secao-titulo {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--texto-2); margin: 0 0 14px;
}
.secao-titulo span { color: var(--texto-3); font-weight: 400; letter-spacing: 0; text-transform: none; }
.grade { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 34px; }
@media (min-width: 560px) { .grade { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; } }
.livro-card {
  display: flex; flex-direction: column; padding: 10px;
  background: var(--fundo-3); border: 1px solid #2a2a2a; border-radius: var(--raio);
}
.livro-info { display: block; flex: 1; margin-bottom: 12px; }
.card-acoes { display: grid; gap: 8px; }
.card-acoes .btn { height: 42px; border-radius: 10px; font-size: 13px; gap: 7px; box-shadow: none; }
.card-acoes .btn svg { width: 16px; height: 16px; }
.card-acoes .btn-secundario { background: var(--fundo); border-color: #2a2a2a; color: var(--texto-2); }
.livro-card .capa {
  aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden; background: var(--fundo-3);
  border: 1px solid var(--linha); position: relative;
}
.livro-card .capa img { width: 100%; height: 100%; object-fit: cover; }
.livro-card .capa .barra { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.12); }
.livro-card .capa .barra i { display: block; height: 100%; background: var(--degrade); }
.livro-card h3 { font-size: 14px; font-weight: 600; line-height: 1.3; margin: 10px 0 2px; }
.livro-card p { margin: 0; font-size: 12px; color: var(--texto-3); }
.livro-info:active .capa { transform: scale(.98); }
.vazio { color: var(--texto-3); text-align: center; padding: 40px 0; }

/* ---------- página do livro ---------- */
.barra-topo {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 6px;
  padding: calc(var(--topo) + 8px) 10px 8px; margin: calc(-1 * (var(--topo) + 20px)) -18px 0;
  background: rgba(0, 0, 0, .82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.barra-topo h2 { flex: 1; min-width: 0; margin: 0; font-size: 14px; font-weight: 500; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icone-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; flex: none; color: var(--texto); }
.icone-btn:active { background: var(--fundo-3); }

.ficha { text-align: center; padding: 18px 0 8px; position: relative; }
.ficha::before {
  content: ''; position: absolute; inset: -40px -18px auto; height: 330px;
  background: var(--degrade-suave); z-index: -1; pointer-events: none;
}
.ficha .capa { width: 168px; margin: 0 auto 20px; border-radius: 10px; overflow: hidden; box-shadow: 0 20px 50px rgba(179, 20, 31, .28), 0 0 0 1px var(--linha); aspect-ratio: 2/3; }
.ficha .capa img { width: 100%; height: 100%; object-fit: cover; }
.ficha .cat { color: var(--rojo-claro); font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.ficha h1 { font-size: 25px; line-height: 1.2; font-weight: 600; margin: 6px 0 4px; }
.ficha .sub { color: var(--texto-2); margin: 0 0 12px; font-size: 14px; }
.ficha .desc { color: var(--texto-2); font-size: 14px; max-width: 40ch; margin: 0 auto 14px; }
.meta { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; color: var(--texto-3); font-size: 12px; margin-bottom: 22px; }
.meta span + span::before { content: '·'; margin-right: 8px; }

.acoes { display: grid; gap: 10px; margin-bottom: 30px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 54px; border-radius: 14px; font-weight: 600; font-size: 15px; width: 100%;
}
.btn-principal { background: var(--degrade); color: #fff; box-shadow: 0 10px 30px rgba(179, 20, 31, .3); }
.btn-principal small { font-weight: 400; opacity: .85; }
.btn-secundario { background: var(--fundo-2); border: 1px solid var(--linha); color: var(--texto); }
.btn:active { transform: scale(.985); }

.indice { border-top: 1px solid var(--linha); }
.indice h4 { margin: 22px 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--rojo-claro); }
.indice a {
  display: flex; align-items: center; gap: 14px; padding: 14px 4px;
  border-bottom: 1px solid var(--linha); font-size: 15px;
}
.indice a .n { width: 30px; flex: none; color: var(--texto-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.indice a .t { flex: 1; min-width: 0; }
.indice a .ok { width: 8px; height: 8px; border-radius: 50%; background: var(--rojo); flex: none; }
.indice a.atual .t { color: var(--rojo-claro); font-weight: 500; }

/* ---------- leitor ---------- */
.leitor .barra-topo { justify-content: space-between; }
.progresso { position: fixed; top: 0; left: 0; height: 2px; background: var(--degrade); z-index: 20; width: 0; transition: width .1s; }
.texto { font-size: var(--letra-leitura); line-height: 1.75; font-weight: 300; padding-top: 10px; }
.texto .cab { text-align: center; margin: 22px 0 28px; }
.texto .cab small { display: block; color: var(--rojo-claro); font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; margin-bottom: 6px; }
.texto .cab h1 { font-size: 1.45em; line-height: 1.25; font-weight: 600; margin: 0; }
.texto .cab::after { content: ''; display: block; width: 44px; height: 3px; border-radius: 3px; background: var(--degrade); margin: 18px auto 0; }
.texto p { margin: 0 0 .9em; }
.texto p .v { color: var(--rojo-claro); font-weight: 600; font-size: .72em; vertical-align: .28em; margin-right: .3em; }
.texto h3 { font-size: 1em; font-weight: 600; margin: 1.6em 0 .7em; color: var(--texto); }
.texto blockquote { white-space: pre-line; margin: 0 0 1.4em; padding: 2px 0 2px 16px; border-left: 3px solid var(--rojo); color: var(--texto-2); font-style: italic; }
.nav-cap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 34px; }
.nav-cap .btn { height: 58px; font-size: 14px; flex-direction: column; gap: 0; line-height: 1.2; }
.nav-cap .btn small { font-weight: 400; color: var(--texto-3); font-size: 11px; }
.nav-cap .btn-principal small { color: rgba(255,255,255,.8); }
.fim { text-align: center; color: var(--texto-2); padding: 26px 0 0; font-size: 14px; }

/* ---------- folha inferior (ajustes / capítulos) ---------- */
.veu { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; animation: aparece .2s; }
@keyframes aparece { from { opacity: 0; } }
.folha {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 78dvh; overflow-y: auto;
  background: var(--fundo-2); border-top: 1px solid var(--linha); border-radius: 20px 20px 0 0;
  padding: 10px 18px calc(var(--base) + 20px); max-width: 720px; margin: 0 auto;
  animation: sobe .25s ease-out;
}
@keyframes sobe { from { transform: translateY(100%); } }
.folha .pega { width: 40px; height: 4px; border-radius: 4px; background: var(--linha); margin: 0 auto 16px; }
.folha h5 { margin: 0 0 14px; font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--texto-2); }
.tamanho { display: flex; align-items: center; gap: 12px; }
.tamanho button { flex: 1; height: 52px; border-radius: 12px; background: var(--fundo-3); border: 1px solid var(--linha); font-weight: 600; }
.tamanho output { min-width: 54px; text-align: center; color: var(--texto-2); font-size: 13px; }
.folha .indice { border-top: 0; }

.aviso {
  position: fixed; left: 50%; bottom: calc(var(--base) + 24px); transform: translateX(-50%); z-index: 60;
  background: var(--fundo-3); border: 1px solid var(--linha); padding: 12px 18px; border-radius: 12px;
  font-size: 14px; max-width: calc(100% - 32px); text-align: center;
}
.carregando { display: grid; place-items: center; min-height: 50dvh; color: var(--texto-3); }
.carregando::before { content: ''; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--linha); border-top-color: var(--rojo); animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

.rodape { color: var(--texto-3); font-size: 12px; text-align: center; padding-top: 10px; border-top: 1px solid var(--linha); }
.rodape p { margin: 16px 0 0; }
