:root{
  --bg:#f6f3ec;
  --surface:#fff;
  --soft:#eee8dc;
  --text:#2e2a25;
  --muted:#756f65;
  --accent:#9a7417;
  --accent-dark:#72530d;
  --border:#ddd5c7;
  --shadow:0 12px 30px rgba(47,39,26,.08);
  --danger:#8b3930;
  --danger-soft:#f6e8e5;

  --bottom-nav-height:76px;
  --reader-header-height:68px;
  --reader-controls-height:118px;

  font-family:Georgia,"Times New Roman",serif;
}

*{
  box-sizing:border-box;
}

html,
body{
  margin:0;
  min-height:100%;
  background:var(--bg);
  color:var(--text);
}

body{
  overflow-x:hidden;
}

button,
input{
  font:inherit;
}

button{
  cursor:pointer;
}

button:focus-visible,
input:focus-visible,
a:focus-visible{
  outline:3px solid rgba(154,116,23,.22);
  outline-offset:2px;
}

.hidden{
  display:none!important;
}

.screen{
  min-height:100dvh;
}

.center-screen{
  display:grid;
  place-items:center;
  padding:24px;
  text-align:center;
}

.brand-mark{
  width:74px;
  height:74px;
  border:1px solid var(--accent);
  border-radius:50%;
  display:grid;
  place-items:center;
  margin:0 auto 18px;
  color:var(--accent);
  font-size:42px;
}

h1{
  margin:0;
  font-size:clamp(2.6rem,8vw,4rem);
  letter-spacing:.12em;
  font-weight:500;
}

.subtitle{
  margin-top:6px;
  color:var(--accent-dark);
  font-style:italic;
}

.loader{
  margin:26px auto 0;
  width:34px;
  height:34px;
  border-radius:50%;
  border:3px solid var(--border);
  border-top-color:var(--accent);
  animation:spin 1s linear infinite;
}

@keyframes spin{
  to{
    transform:rotate(360deg);
  }
}

.panel{
  width:min(100%,460px);
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:18px;
  padding:30px;
  box-shadow:var(--shadow);
}

.tabs{
  display:grid;
  grid-template-columns:1fr 1fr;
  margin:28px 0 20px;
  border-bottom:1px solid var(--border);
}

.tab,
.link-button{
  background:transparent;
  border:0;
  color:var(--muted);
  padding:12px;
}

.tab.active{
  color:var(--accent-dark);
  border-bottom:2px solid var(--accent);
  font-weight:700;
}

.link-button{
  text-decoration:none;
}

.link-button:hover{
  color:var(--accent-dark);
}

.form{
  display:grid;
  gap:16px;
  text-align:left;
}

.form label{
  display:grid;
  gap:7px;
  font-weight:700;
}


/* =========================================================
   MOSTRAR / OCULTAR SENHA
   ========================================================= */

.password-label-row{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:8px;
  width:100%;
}

.password-label-row > span{
  flex:0 0 auto;
}

.password-toggle{
  flex:0 0 auto;
  min-height:28px;
  border:0;
  border-radius:7px;
  padding:3px 5px;
  background:transparent;
  color:var(--accent-dark);
  font-family:inherit;
  font-size:.72rem;
  font-weight:600;
  line-height:1.15;
  text-decoration:none;
  white-space:nowrap;
}

.password-toggle:hover{
  background:rgba(238,232,220,.6);
  color:var(--accent-dark);
}

.password-toggle:active{
  background:var(--soft);
}

.password-toggle:focus-visible{
  outline:2px solid rgba(154,116,23,.25);
  outline-offset:1px;
}


input{
  width:100%;
  border:1px solid var(--border);
  border-radius:12px;
  padding:13px 14px;
  background:#fff;
  min-height:48px;
  color:var(--text);
}

input:focus{
  outline:3px solid rgba(154,116,23,.15);
  border-color:var(--accent);
}

.primary,
.secondary{
  border:0;
  border-radius:12px;
  min-height:48px;
  padding:12px 18px;
  font-weight:700;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

.primary{
  background:var(--accent);
  color:white;
}

.primary:hover{
  background:var(--accent-dark);
}

.secondary{
  background:var(--soft);
  color:var(--text);
}

.secondary:hover{
  background:#e6dece;
}

.small{
  min-height:42px;
  padding:9px 14px;
}

.hint{
  color:var(--muted);
  font-size:.92rem;
  line-height:1.45;
}

.message{
  margin-top:16px;
  padding:12px;
  border-radius:10px;
  background:var(--soft);
  text-align:left;
  line-height:1.4;
}

.topbar{
  position:sticky;
  top:0;
  z-index:10;
  background:rgba(246,243,236,.96);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--border);
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 18px;
}

.top-brand{
  letter-spacing:.16em;
  font-size:1.35rem;
}

.top-subtitle{
  color:var(--muted);
  font-size:.82rem;
  font-style:italic;
}

.content{
  width:min(1180px,100%);
  margin:auto;
  padding:
    24px
    18px
    calc(var(--bottom-nav-height) + 34px + env(safe-area-inset-bottom));
}

.welcome-section{
  padding:18px 0 2px;
}

.welcome-section h2{
  margin:0 0 8px;
  font-size:1.45rem;
}

.welcome-section p{
  margin:0;
  color:var(--muted);
}

.hero{
  padding:20px 0 18px;
}

.hero h2{
  font-size:clamp(2rem,6vw,3rem);
  margin:0 0 4px;
  font-weight:500;
}

.hero p{
  color:var(--muted);
  margin:0 0 20px;
}

.search-row{
  display:grid;
  grid-template-columns:1fr auto;
  gap:10px;
}


/* =========================================================
   ACESSOS PRINCIPAIS DA TELA INICIAL
   ========================================================= */

.home-actions{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
  margin:4px 0 32px;
}

.home-action-card{
  width:100%;
  min-height:122px;
  border:1px solid var(--border);
  border-radius:16px;
  padding:16px 14px;
  background:var(--surface);
  color:var(--text);
  text-align:left;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  justify-content:flex-start;
  gap:12px;
  box-shadow:0 6px 16px rgba(47,39,26,.05);
  transition:
    transform .16s ease,
    border-color .16s ease,
    box-shadow .16s ease,
    background .16s ease;
}

.home-action-card:hover{
  border-color:rgba(154,116,23,.45);
  box-shadow:0 9px 22px rgba(47,39,26,.08);
}

.home-action-card:active{
  transform:scale(.985);
}

.home-action-icon{
  width:46px;
  height:46px;
  border-radius:13px;
  background:var(--soft);
  color:var(--accent);
  display:grid;
  place-items:center;
  flex:0 0 auto;
}

.home-action-icon svg{
  width:27px;
  height:27px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.7;
  stroke-linecap:round;
  stroke-linejoin:round;
}

.home-action-content{
  display:grid;
  gap:4px;
}

.home-action-content strong{
  color:var(--text);
  font-size:1rem;
  line-height:1.2;
}

.home-action-content small{
  color:var(--muted);
  font-size:.78rem;
  line-height:1.3;
}


/* =========================================================
   CONTEÚDOS
   ========================================================= */

.section{
  margin:0 0 34px;
}

.section-title{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:14px;
  margin-bottom:14px;
}

.section h3,
.view h3{
  font-size:1.35rem;
}

.view > h3,
.section-title h3{
  margin-top:0;
}

.view-intro{
  margin:5px 0 0;
  color:var(--muted);
  line-height:1.5;
}

.cards{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(150px,1fr));
  gap:18px;
}

.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:14px;
  overflow:hidden;
  box-shadow:0 6px 16px rgba(47,39,26,.05);
}

.card-button{
  display:block;
  width:100%;
  border:0;
  background:transparent;
  color:inherit;
  text-align:left;
  padding:0;
}

.cover{
  aspect-ratio:.7;
  background:var(--soft);
  display:grid;
  place-items:center;
  overflow:hidden;
}

.cover img{
  width:100%;
  height:100%;
  object-fit:cover;
}

.cover-fallback{
  color:var(--accent);
  font-size:2rem;
}

.card-body{
  padding:12px;
}

.card-title{
  margin:0;
  font-size:1rem;
  line-height:1.3;
}

.card-meta{
  color:var(--muted);
  font-size:.82rem;
  margin-top:7px;
  line-height:1.35;
}

.empty-state{
  padding:30px;
  border:1px dashed var(--border);
  border-radius:14px;
  color:var(--muted);
  text-align:center;
  background:rgba(255,255,255,.26);
}

.events-list{
  margin-top:18px;
}

.load-more{
  display:block;
  margin:22px auto;
}


/* =========================================================
   CONTINUAR LENDO
   ========================================================= */

#continue-section{
  margin-top:2px;
}

#continue-list{
  grid-template-columns:repeat(2,minmax(0,1fr));
  align-items:stretch;
}

.continue-card{
  position:relative;
  min-width:0;
  min-height:112px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--surface);
  box-shadow:0 6px 16px rgba(47,39,26,.05);
  overflow:hidden;
}

.continue-card-button{
  width:100%;
  height:100%;
  min-width:0;
  min-height:112px;
  border:0;
  border-radius:13px;
  background:transparent;
  color:inherit;
  padding:12px;
  text-align:left;
  display:grid;
  grid-template-columns:72px minmax(0,1fr);
  gap:12px;
  align-items:center;
}

.continue-card-button:hover{
  background:rgba(238,232,220,.26);
}

.continue-card-cover{
  width:72px;
  aspect-ratio:.7;
  border-radius:9px;
  overflow:hidden;
  background:var(--soft);
  display:grid;
  place-items:center;
}

.continue-card-cover img{
  width:100%;
  height:100%;
  object-fit:cover;
}

.continue-card-body{
  min-width:0;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:flex-start;
  gap:6px;
}

.continue-card-title{
  margin:0;
  width:100%;
  color:var(--text);
  font-size:.96rem;
  line-height:1.3;
  overflow:hidden;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
}

.continue-card-position{
  margin:0;
  color:var(--accent-dark);
  font-size:.82rem;
  font-weight:700;
}

.continue-card-meta{
  margin:0;
  color:var(--muted);
  font-size:.76rem;
}


/* =========================================================
   MARCADORES — LISTA
   ========================================================= */

#view-marcadores .section-title{
  align-items:flex-start;
}

#bookmarks-message{
  margin-bottom:16px;
}

#bookmarks-list:not(.empty-state){
  display:grid;
  gap:12px;
}

.bookmark-item{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:14px;
  align-items:center;
  padding:15px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--surface);
  box-shadow:0 5px 14px rgba(47,39,26,.045);
}

.bookmark-item-main{
  min-width:0;
}

.bookmark-item-title{
  margin:0 0 5px;
  color:var(--text);
  font-size:1rem;
  line-height:1.3;
  overflow-wrap:anywhere;
}

.bookmark-item-publication{
  margin:0;
  color:var(--muted);
  font-size:.84rem;
  line-height:1.4;
}

.bookmark-item-position{
  display:inline-block;
  margin-top:7px;
  padding:5px 8px;
  border-radius:999px;
  background:var(--soft);
  color:var(--accent-dark);
  font-size:.78rem;
  font-weight:700;
}

.bookmark-item-actions{
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:7px;
}

.bookmark-action-button{
  min-height:38px;
  border:1px solid var(--border);
  border-radius:10px;
  padding:7px 11px;
  background:var(--surface);
  color:var(--text);
  font-weight:700;
  font-size:.8rem;
}

.bookmark-action-button:hover{
  border-color:rgba(154,116,23,.45);
  color:var(--accent-dark);
}

.bookmark-action-button.delete{
  color:var(--danger);
}

.bookmark-action-button.delete:hover{
  border-color:rgba(139,57,48,.4);
  background:var(--danger-soft);
}


/* =========================================================
   JANELAS / DIALOGS
   ========================================================= */

dialog{
  width:min(720px,calc(100% - 24px));
  max-height:calc(100dvh - 30px);
  border:1px solid var(--border);
  border-radius:18px;
  padding:0;
  box-shadow:var(--shadow);
  color:var(--text);
  background:var(--surface);
}

dialog::backdrop{
  background:rgba(30,26,20,.58);
}

.dialog-close{
  position:sticky;
  top:12px;
  float:right;
  margin:12px 12px 0 0;
  width:42px;
  height:42px;
  border-radius:50%;
  border:1px solid var(--border);
  background:white;
  color:var(--text);
  font-size:1.6rem;
  z-index:2;
}

.detail{
  padding:28px;
}

.detail-grid{
  display:grid;
  grid-template-columns:180px 1fr;
  gap:24px;
}

.detail-cover img{
  width:100%;
  border-radius:10px;
}

.detail h2{
  margin-top:0;
}

.detail-description{
  line-height:1.65;
}

.detail-actions{
  display:flex;
  flex-wrap:wrap;
  align-items:flex-start;
  gap:10px;
  margin-top:18px;
}


/* =========================================================
   AÇÕES DE ABERTURA E DOWNLOAD
   ========================================================= */

.detail-format-actions{
  display:flex;
  flex-wrap:wrap;
  gap:7px;
  align-items:center;
}

.detail-format-actions .primary,
.detail-format-actions .secondary{
  min-height:44px;
}

.detail-download-button{
  background:transparent;
  border:1px solid var(--border);
  color:var(--accent-dark);
}

.detail-download-button:hover{
  background:var(--soft);
  border-color:rgba(154,116,23,.45);
  color:var(--accent-dark);
}

.detail-download-button:disabled{
  opacity:.58;
  cursor:wait;
}


.badges{
  display:flex;
  flex-wrap:wrap;
  gap:7px;
  margin:12px 0;
}

.badge{
  background:var(--soft);
  padding:6px 9px;
  border-radius:999px;
  font-size:.82rem;
  color:var(--muted);
}


/* =========================================================
   DIALOG DE MARCADOR
   ========================================================= */

#bookmark-dialog,
#bookmark-delete-dialog{
  width:min(520px,calc(100% - 24px));
}

.bookmark-dialog-content{
  padding:30px 28px 26px;
}

.bookmark-dialog-content h2{
  margin:0 48px 8px 0;
  font-size:1.45rem;
  font-weight:600;
}

.bookmark-dialog-description{
  margin:0 0 18px;
  color:var(--muted);
  line-height:1.5;
}

.bookmark-position-preview{
  margin:0 0 18px;
  padding:12px 14px;
  border:1px solid var(--border);
  border-radius:11px;
  background:var(--soft);
  color:var(--accent-dark);
  font-weight:700;
  line-height:1.4;
}

.bookmark-title-helper{
  display:flex;
  justify-content:space-between;
  gap:12px;
  margin-top:-8px;
  color:var(--muted);
  font-size:.8rem;
  font-weight:400;
}

#bookmark-title-counter{
  white-space:nowrap;
  font-variant-numeric:tabular-nums;
}

.bookmark-dialog-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-top:4px;
}

#bookmark-delete-confirm{
  background:var(--danger);
}

#bookmark-delete-confirm:hover{
  background:#713029;
}


/* =========================================================
   LEITOR INTERNO — PDF E EPUB
   ========================================================= */

.reader-screen{
  position:fixed;
  inset:0;
  z-index:1000;
  width:100%;
  height:100dvh;
  background:var(--bg);
  color:var(--text);
  display:grid;
  grid-template-rows:auto auto minmax(0,1fr);
  grid-template-areas:
    "header"
    "message"
    "content";
  overflow:hidden;
}

.reader-header{
  grid-area:header;
  min-height:var(--reader-header-height);
  display:grid;
  grid-template-columns:48px minmax(0,1fr) 48px;
  gap:10px;
  align-items:center;
  padding:
    calc(10px + env(safe-area-inset-top))
    14px
    10px;
  background:rgba(246,243,236,.98);
  backdrop-filter:blur(12px);
  border-bottom:1px solid var(--border);
  z-index:3;
}

.reader-heading{
  min-width:0;
  display:grid;
  gap:3px;
  text-align:center;
}

.reader-heading strong{
  display:block;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:1rem;
  font-weight:700;
}

.reader-heading span{
  color:var(--muted);
  font-size:.72rem;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.reader-icon-button{
  width:44px;
  height:44px;
  border:1px solid var(--border);
  border-radius:50%;
  background:var(--surface);
  color:var(--text);
  display:grid;
  place-items:center;
  padding:0;
}

.reader-icon-button:hover{
  border-color:rgba(154,116,23,.45);
  color:var(--accent-dark);
}

.reader-icon-button svg{
  width:23px;
  height:23px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.9;
  stroke-linecap:round;
  stroke-linejoin:round;
}

#reader-bookmark{
  color:var(--accent-dark);
}

#reader-bookmark.is-saved{
  background:var(--accent);
  border-color:var(--accent);
  color:#fff;
}

#reader-bookmark.is-saved svg{
  fill:currentColor;
}

.reader-message{
  grid-area:message;
  position:relative;
  z-index:2;
  margin:10px 14px 0;
  padding:11px 13px;
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--surface);
  color:var(--muted);
  font-size:.9rem;
  line-height:1.4;
  text-align:center;
}

.reader-main{
  grid-area:content;
  position:relative;
  min-width:0;
  min-height:0;
  overflow:hidden;
  background:var(--soft);
  padding-bottom:calc(
    var(--reader-controls-height) +
    env(safe-area-inset-bottom)
  );
}

.reader-loading{
  position:absolute;
  inset:0;
  z-index:2;
  display:grid;
  place-content:center;
  justify-items:center;
  text-align:center;
  padding:24px;
  background:var(--soft);
  color:var(--muted);
}

.reader-loading .loader{
  margin:0 0 16px;
}

.reader-loading p{
  margin:0;
}

.reader-document{
  width:100%;
  height:100%;
  min-width:0;
  min-height:0;
}


/* =========================================================
   LEITOR PDF
   ========================================================= */

#pdf-reader{
  overflow:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  padding-bottom:calc(
    var(--reader-controls-height) +
    20px
  );
}

.pdf-stage{
  width:max-content;
  min-width:100%;
  min-height:100%;
  padding:20px;
  box-sizing:border-box;
}

#pdf-canvas{
  display:block;
  max-width:none;
  height:auto;
  margin-left:auto;
  margin-right:auto;
  background:white;
  box-shadow:0 8px 24px rgba(47,39,26,.14);
}


/* =========================================================
   LEITOR EPUB
   ========================================================= */

#epub-reader{
  overflow:hidden;
  background:var(--surface);
}

.epub-viewer{
  width:100%;
  height:100%;
  min-width:0;
  min-height:0;
  background:var(--surface);
}

.epub-viewer iframe{
  border:0!important;
  width:100%!important;
  height:100%!important;
  background:var(--surface);
}


/* =========================================================
   CONTROLES DO LEITOR
   ========================================================= */

.reader-controls{
  position:fixed;
  left:0;
  right:0;
  bottom:0;
  z-index:1002;
  background:rgba(255,255,255,.98);
  backdrop-filter:blur(12px);
  border-top:1px solid var(--border);
  box-shadow:0 -8px 24px rgba(47,39,26,.08);
  padding:
    8px
    12px
    calc(8px + env(safe-area-inset-bottom));
  display:grid;
  gap:8px;
}

.reader-navigation{
  display:grid;
  grid-template-columns:minmax(88px,1fr) minmax(110px,auto) minmax(88px,1fr);
  gap:8px;
  align-items:center;
}

.reader-control-button{
  min-width:0;
  min-height:42px;
  border:1px solid var(--border);
  border-radius:11px;
  background:var(--soft);
  color:var(--text);
  display:flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  padding:8px 10px;
  font-weight:700;
  font-size:.84rem;
}

.reader-control-button:hover{
  border-color:rgba(154,116,23,.45);
}

.reader-control-button:disabled{
  opacity:.45;
  cursor:default;
}

.reader-control-button svg{
  width:18px;
  height:18px;
  flex:0 0 auto;
  fill:none;
  stroke:currentColor;
  stroke-width:2;
  stroke-linecap:round;
  stroke-linejoin:round;
}


/* =========================================================
   POSIÇÃO TRADICIONAL
   Mantida para compatibilidade durante a transição.
   ========================================================= */

.reader-position{
  min-width:0;
  color:var(--muted);
  text-align:center;
  font-size:.82rem;
  line-height:1.25;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}


/* =========================================================
   NAVEGAÇÃO DIRETA — PDF / EPUB
   ========================================================= */

.reader-position-control{
  min-width:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  color:var(--muted);
}

.reader-position-label{
  font-size:.66rem;
  line-height:1;
  color:var(--muted);
  white-space:nowrap;
}

.reader-position-edit{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:4px;
  min-width:0;
}

.reader-position-input{
  width:58px;
  min-width:0;
  min-height:34px;
  height:34px;
  padding:4px 6px;
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--surface);
  color:var(--text);
  text-align:center;
  font-size:.82rem;
  font-weight:700;
  font-variant-numeric:tabular-nums;
  appearance:textfield;
  -moz-appearance:textfield;
}

.reader-position-input::-webkit-outer-spin-button,
.reader-position-input::-webkit-inner-spin-button{
  -webkit-appearance:none;
  margin:0;
}

.reader-position-input:focus{
  outline:2px solid rgba(154,116,23,.18);
  border-color:var(--accent);
}

.reader-position-total{
  color:var(--muted);
  font-size:.76rem;
  line-height:1;
  white-space:nowrap;
  font-variant-numeric:tabular-nums;
}


/* =========================================================
   FERRAMENTAS DO LEITOR
   ========================================================= */

.reader-tools{
  display:flex;
  justify-content:center;
  align-items:center;
  min-width:0;
}

.reader-tool-group{
  display:flex;
  justify-content:center;
  align-items:center;
  gap:7px;
  min-width:0;
}

.reader-tool-button{
  min-width:40px;
  min-height:38px;
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--surface);
  color:var(--text);
  display:grid;
  place-items:center;
  padding:6px 10px;
  font-weight:700;
}

.reader-tool-button:hover{
  border-color:rgba(154,116,23,.45);
  color:var(--accent-dark);
}

.reader-tool-button:disabled{
  opacity:.45;
  cursor:default;
}

.reader-tool-text{
  min-width:auto;
  padding-left:12px;
  padding-right:12px;
  font-size:.8rem;
}

.reader-zoom-label{
  min-width:50px;
  color:var(--muted);
  text-align:center;
  font-size:.8rem;
  font-variant-numeric:tabular-nums;
}


/* =========================================================
   ÁUDIO DO EPUB
   ========================================================= */

#epub-tools{
  max-width:100%;
}

.epub-audio-controls{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  min-width:0;
}

#epub-audio-toggle{
  color:var(--accent-dark);
}

#epub-audio-toggle:not(:disabled){
  border-color:rgba(154,116,23,.34);
}

#epub-audio-toggle:not(:disabled):hover{
  background:var(--soft);
}

#epub-audio-stop{
  color:var(--muted);
}

.epub-audio-status{
  min-width:0;
  max-width:120px;
  color:var(--muted);
  font-size:.7rem;
  line-height:1.15;
  text-align:left;
}


/* =========================================================
   NAVEGAÇÃO INFERIOR
   ========================================================= */

.bottom-nav{
  position:fixed;
  left:0;
  right:0;
  bottom:0;
  z-index:30;
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  align-items:stretch;
  background:rgba(255,255,255,.97);
  backdrop-filter:blur(14px);
  border-top:1px solid var(--border);
  box-shadow:0 -8px 24px rgba(47,39,26,.08);
  padding:
    5px
    6px
    calc(5px + env(safe-area-inset-bottom));
}

.bottom-nav .nav-tab{
  min-width:0;
  min-height:64px;
  border:0;
  border-top:2px solid transparent;
  border-radius:10px;
  background:transparent;
  color:var(--muted);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:4px;
  padding:5px 4px;
  font-size:.73rem;
  line-height:1.1;
  text-align:center;
  transition:
    color .15s ease,
    background .15s ease,
    border-color .15s ease;
}

.bottom-nav .nav-tab:hover{
  background:rgba(238,232,220,.48);
}

.bottom-nav .nav-tab.active{
  color:var(--accent-dark);
  border-top-color:var(--accent);
  font-weight:700;
  background:rgba(238,232,220,.34);
}

.bottom-nav-icon{
  display:grid;
  place-items:center;
  width:25px;
  height:25px;
}

.bottom-nav-icon svg{
  width:24px;
  height:24px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}


/* =========================================================
   TABLETS E COMPUTADORES
   ========================================================= */

@media(min-width:760px){

  .content{
    padding-left:24px;
    padding-right:24px;
    padding-bottom:120px;
  }

  .welcome-section{
    padding-top:26px;
  }

  .home-actions{
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:16px;
    margin-bottom:38px;
  }

  .home-action-card{
    min-height:138px;
    padding:18px;
  }

  .home-action-icon{
    width:50px;
    height:50px;
  }

  .home-action-icon svg{
    width:29px;
    height:29px;
  }

  .home-action-content strong{
    font-size:1.05rem;
  }

  #continue-list{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .bottom-nav{
    left:50%;
    right:auto;
    width:min(720px,calc(100% - 32px));
    transform:translateX(-50%);
    bottom:14px;
    border:1px solid var(--border);
    border-radius:18px;
    padding:6px 8px;
    box-shadow:0 10px 28px rgba(47,39,26,.13);
  }

  .bottom-nav .nav-tab{
    min-height:62px;
  }

  .reader-screen{
    background:var(--soft);
  }

  .reader-header{
    padding-left:22px;
    padding-right:22px;
  }

  .reader-heading strong{
    font-size:1.08rem;
  }

  .reader-main{
    margin:0 auto;
    width:100%;
  }

  .pdf-stage{
    padding:28px;
  }

  .reader-controls{
    padding-left:22px;
    padding-right:22px;
  }

  .reader-navigation{
    width:min(680px,100%);
    margin:0 auto;
  }

  .reader-tools{
    width:min(760px,100%);
    margin:0 auto;
  }

  .reader-position-input{
    width:64px;
  }
}


/* =========================================================
   CELULARES
   ========================================================= */

@media(max-width:620px){

  :root{
    --reader-header-height:62px;
    --reader-controls-height:112px;
  }

  .center-screen{
    padding:18px;
  }

  .panel{
    padding:24px 18px;
  }

  .password-label-row{
    gap:7px;
  }

  .password-toggle{
    min-height:27px;
    padding:3px 4px;
    font-size:.7rem;
  }

  .topbar{
    padding:12px 16px;
  }

  .top-brand{
    font-size:1.28rem;
  }

  .top-subtitle{
    font-size:.8rem;
  }

  .content{
    padding:
      18px
      14px
      calc(var(--bottom-nav-height) + 30px + env(safe-area-inset-bottom));
  }

  .welcome-section{
    padding:14px 0 0;
  }

  .welcome-section h2{
    font-size:1.32rem;
  }

  .hero{
    padding:18px 0;
  }

  .hero h2{
    font-size:2.25rem;
  }

  .hero p{
    margin-bottom:16px;
  }

  .search-row{
    gap:8px;
  }

  .search-row input{
    min-width:0;
  }

  .home-actions{
    gap:10px;
    margin-top:0;
    margin-bottom:28px;
  }

  .home-action-card{
    min-height:120px;
    padding:14px 12px;
  }

  .section{
    margin-bottom:30px;
  }

  .section-title{
    margin-bottom:12px;
  }

  .section h3,
  .view h3{
    font-size:1.28rem;
  }

  .cards{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:12px;
  }

  /*
   * Continuar lendo permanece deliberadamente com
   * duas colunas também em celulares.
   */
  #continue-list{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:10px;
  }

  .continue-card{
    min-height:0;
  }

  .continue-card-button{
    min-height:0;
    height:100%;
    padding:9px;
    grid-template-columns:1fr;
    align-content:start;
    gap:8px;
  }

  .continue-card-cover{
    width:100%;
    max-width:82px;
    justify-self:center;
  }

  .continue-card-body{
    width:100%;
    justify-content:flex-start;
    align-items:center;
    gap:4px;
    text-align:center;
  }

  .continue-card-title{
    font-size:.86rem;
    line-height:1.25;
    -webkit-line-clamp:3;
  }

  .continue-card-position{
    font-size:.75rem;
  }

  .continue-card-meta{
    font-size:.7rem;
  }

  .card-title{
    font-size:.98rem;
  }

  .card-body{
    padding:11px;
  }

  .bookmark-item{
    grid-template-columns:1fr;
    gap:12px;
  }

  .bookmark-item-actions{
    justify-content:flex-start;
  }

  .detail-grid{
    grid-template-columns:110px 1fr;
    gap:16px;
  }

  .detail{
    padding:20px;
  }

  .detail-actions{
    gap:8px;
  }

  .detail-format-actions{
    gap:6px;
  }

  .detail-actions .primary,
  .detail-actions .secondary{
    min-height:44px;
    padding:10px 12px;
  }

  .detail-download-button{
    font-size:.85rem;
  }

  .bookmark-dialog-content{
    padding:25px 20px 20px;
  }

  .reader-header{
    grid-template-columns:44px minmax(0,1fr) 44px;
    gap:6px;
    padding-left:10px;
    padding-right:10px;
  }

  .reader-icon-button{
    width:40px;
    height:40px;
  }

  .reader-heading strong{
    font-size:.94rem;
  }

  .reader-heading span{
    font-size:.67rem;
  }

  .reader-message{
    margin-left:10px;
    margin-right:10px;
    font-size:.84rem;
  }

  .pdf-stage{
    padding:12px;
  }

  .reader-controls{
    padding-left:8px;
    padding-right:8px;
    gap:7px;
  }

  .reader-navigation{
    grid-template-columns:
      minmax(76px,1fr)
      minmax(96px,auto)
      minmax(76px,1fr);
    gap:5px;
  }

  .reader-control-button{
    min-height:40px;
    padding:7px 6px;
    font-size:.76rem;
  }

  .reader-control-button svg{
    width:16px;
    height:16px;
  }

  .reader-position{
    font-size:.75rem;
  }

  .reader-position-label{
    font-size:.61rem;
  }

  .reader-position-input{
    width:52px;
    min-height:32px;
    height:32px;
    padding:3px 4px;
    font-size:.77rem;
  }

  .reader-position-total{
    font-size:.7rem;
  }

  .reader-tool-group{
    gap:5px;
  }

  .reader-tool-button{
    min-width:38px;
    min-height:36px;
    padding:5px 8px;
  }

  .reader-tool-text{
    padding-left:9px;
    padding-right:9px;
    font-size:.73rem;
  }

  .reader-zoom-label{
    min-width:45px;
    font-size:.75rem;
  }

  #epub-tools{
    width:100%;
    justify-content:center;
    gap:5px;
  }

  .epub-audio-controls{
    gap:5px;
  }

  #epub-audio-toggle,
  #epub-audio-stop{
    min-width:auto;
    padding-left:8px;
    padding-right:8px;
  }

  /*
   * Em celulares, o estado do áudio já é claramente
   * comunicado pelo próprio botão:
   * Ouvir / Pausar / Continuar.
   *
   * Ocultamos apenas o texto auxiliar para não reduzir
   * a área disponível para os controles principais.
   */
  .epub-audio-status{
    display:none;
  }
}


/* =========================================================
   CELULARES PEQUENOS
   ========================================================= */

@media(max-width:420px){

  .topbar{
    padding-left:14px;
    padding-right:14px;
  }

  .top-brand{
    font-size:1.18rem;
  }

  .top-subtitle{
    font-size:.76rem;
  }

  .content{
    padding-left:12px;
    padding-right:12px;
  }

  .password-label-row{
    gap:6px;
  }

  .password-toggle{
    min-height:26px;
    padding:2px 4px;
    font-size:.68rem;
  }

  .hero h2{
    font-size:2.05rem;
  }

  .search-row{
    grid-template-columns:minmax(0,1fr) auto;
  }

  .search-row .primary{
    padding-left:13px;
    padding-right:13px;
  }

  .home-actions{
    gap:9px;
  }

  .home-action-card{
    min-height:116px;
    padding:12px 10px;
    gap:10px;
  }

  .home-action-icon{
    width:42px;
    height:42px;
    border-radius:12px;
  }

  .home-action-icon svg{
    width:24px;
    height:24px;
  }

  .home-action-content strong{
    font-size:.94rem;
  }

  .home-action-content small{
    font-size:.72rem;
  }

  .cards{
    gap:10px;
  }

  #continue-list{
    gap:8px;
  }

  .continue-card-button{
    padding:8px 7px;
    gap:7px;
  }

  .continue-card-cover{
    max-width:72px;
  }

  .continue-card-title{
    font-size:.8rem;
  }

  .continue-card-position{
    font-size:.7rem;
  }

  .continue-card-meta{
    font-size:.66rem;
  }

  .card-body{
    padding:10px;
  }

  .card-title{
    font-size:.93rem;
  }

  .card-meta{
    font-size:.77rem;
  }

  .bookmark-dialog-actions{
    grid-template-columns:1fr;
  }

  .bottom-nav{
    padding-left:3px;
    padding-right:3px;
  }

  .bottom-nav .nav-tab{
    min-height:61px;
    padding-left:2px;
    padding-right:2px;
    font-size:.68rem;
  }

  .bottom-nav-icon{
    width:23px;
    height:23px;
  }

  .bottom-nav-icon svg{
    width:22px;
    height:22px;
  }

  dialog{
    width:calc(100% - 16px);
  }

  .detail{
    padding:18px 16px;
  }

  .detail-grid{
    grid-template-columns:96px 1fr;
    gap:14px;
  }

  .detail h2{
    font-size:1.35rem;
  }

  .detail-format-actions{
    flex-direction:column;
    align-items:stretch;
    width:100%;
  }

  .detail-format-actions .primary,
  .detail-format-actions .secondary{
    width:100%;
    min-height:42px;
    padding:9px 10px;
  }

  .bookmark-dialog-content{
    padding:22px 16px 17px;
  }

  .bookmark-dialog-content h2{
    font-size:1.3rem;
  }

  .reader-header{
    grid-template-columns:40px minmax(0,1fr) 40px;
    padding-left:7px;
    padding-right:7px;
  }

  .reader-icon-button{
    width:38px;
    height:38px;
  }

  .reader-icon-button svg{
    width:21px;
    height:21px;
  }

  .reader-heading strong{
    font-size:.87rem;
  }

  .reader-heading span{
    font-size:.62rem;
  }

  .pdf-stage{
    padding:8px;
  }

  .reader-controls{
    padding-left:5px;
    padding-right:5px;
  }

  .reader-navigation{
    grid-template-columns:
      minmax(70px,1fr)
      minmax(84px,auto)
      minmax(70px,1fr);
    gap:4px;
  }

  .reader-control-button{
    min-height:38px;
    padding:6px 4px;
    font-size:.7rem;
  }

  .reader-control-button svg{
    width:15px;
    height:15px;
  }

  .reader-position{
    font-size:.69rem;
  }

  .reader-position-label{
    font-size:.57rem;
  }

  .reader-position-input{
    width:45px;
    min-height:30px;
    height:30px;
    border-radius:7px;
    padding:2px 3px;
    font-size:.72rem;
  }

  .reader-position-total{
    font-size:.64rem;
  }

  .reader-tool-button{
    min-width:35px;
    min-height:34px;
    padding:4px 6px;
    font-size:.74rem;
  }

  .reader-tool-text{
    padding-left:7px;
    padding-right:7px;
    font-size:.67rem;
  }

  .reader-zoom-label{
    min-width:40px;
    font-size:.7rem;
  }

  #epub-tools{
    gap:4px;
  }

  .epub-audio-controls{
    gap:4px;
  }

  #epub-audio-toggle,
  #epub-audio-stop{
    padding-left:6px;
    padding-right:6px;
    font-size:.65rem;
  }
}
