/*
  Lume — estilos do app. Cores, fontes, espaços e raios vêm de theme.css
  (gerado de docs/lume-brand-kit/tokens/tokens.json); aqui só se usa var().

  Mobile-first: o estilo base é o do celular; telas maiores ganham ajustes
  nos @media (min-width) do fim de cada seção. O layout do leitor troca em
  680px, junto com o setupMobileLayout de app.js.
*/

/* ------------------------------------------------------------------ */
/* Base                                                                */
/* ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--type-body-ui-size);
  line-height: var(--type-body-ui-line);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* Logo: a fita na cor da marca, a palavra na cor do texto (muda com o tema). */
  --logo-mark: var(--accent);
  --logo-word: var(--text);
}

button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

.hidden { display: none !important; }
.screen { height: 100%; }
.spacer { flex: 1; }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

.screen-title {
  font-family: var(--font-display);
  font-size: var(--type-display-m-size);
  line-height: var(--type-display-m-line);
  font-weight: var(--type-display-m-weight);
  letter-spacing: var(--type-display-m-tracking);
  font-optical-sizing: auto;
}
.overline {
  font-size: var(--type-overline-size);
  line-height: var(--type-overline-line);
  font-weight: var(--type-overline-weight);
  letter-spacing: var(--type-overline-tracking);
  text-transform: uppercase;
  color: var(--text-muted);
}
.caption {
  font-size: var(--type-caption-size);
  line-height: var(--type-caption-line);
  color: var(--text-muted);
}

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  vertical-align: middle;
}

.logo { display: block; height: 32px; width: calc(32px * 171.333 / 64); }

/* ------------------------------------------------------------------ */
/* Botões                                                              */
/* ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap-target);
  padding: 0 var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  font-size: var(--type-label-size);
  line-height: var(--type-label-line);
  font-weight: var(--type-label-weight);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-block { width: 100%; }
.btn-small { min-height: 36px; padding: 0 var(--space-3); }

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

.btn-ghost { border-color: var(--border-strong); color: var(--text); }

.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger-solid { background: var(--danger); color: var(--bg); }

/* Só ícone: alvo de toque quadrado de 44px. */
.btn-icon {
  min-width: var(--tap-target);
  padding: 0 var(--space-2);
  color: var(--text);
}
.btn-icon.btn-small { min-width: 36px; }

/* Ligado (TTS, foco, seguir a leitura...): fundo e cor da marca, inconfundível. */
.btn.active,
.btn-toggle.active {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn-label { display: none; }

/* ------------------------------------------------------------------ */
/* Campos                                                              */
/* ------------------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field-label {
  font-size: var(--type-label-size);
  line-height: var(--type-label-line);
  font-weight: var(--type-label-weight);
}

input[type="text"], input[type="password"], input[type="number"], input[type="email"], input[type="search"], select, textarea {
  min-height: var(--tap-target);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: 16px; /* abaixo de 16px o iOS dá zoom ao focar */
}
textarea { padding: var(--space-3); line-height: 1.5; resize: vertical; width: 100%; }
select { padding-right: var(--space-8); cursor: pointer; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 0; border-color: var(--accent); }

/* Sliders: trilho em border, preenchimento e alça na cor da marca. */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: var(--tap-target);
  margin: 0;
  background: transparent;
  touch-action: pan-y; /* arrastar na horizontal move o slider; na vertical, rola a folha */
  accent-color: var(--accent);
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: var(--radius-full); background: var(--border); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: var(--radius-full); background: var(--border); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: var(--radius-full); background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
}

.form-error {
  min-height: var(--type-caption-line);
  font-size: var(--type-caption-size);
  line-height: var(--type-caption-line);
  color: var(--danger);
}

/* ------------------------------------------------------------------ */
/* Chips (categorias)                                                  */
/* ------------------------------------------------------------------ */
.chips {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0; /* área de rolagem numa coluna flex: sem isso, encolhia com a lista longa */
  overflow-x: auto;
  scrollbar-width: none;
  padding: var(--space-1) var(--space-4);
  margin: 0 calc(-1 * var(--space-4));
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chips > * { flex-shrink: 0; }
.chips-group { display: contents; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  background: transparent;
  font-size: var(--type-label-size);
  font-weight: var(--type-label-weight);
  white-space: nowrap;
}
.chip.active { background: var(--accent-tint); border-color: var(--accent); color: var(--accent-text); }
.chip .cat-count { font-weight: 400; color: var(--text-muted); }
.chip.active .cat-count { color: inherit; }
.chip-form { display: flex; align-items: center; gap: var(--space-1); }
.chip-form input { min-height: 36px; width: 150px; border-radius: var(--radius-full); padding: 0 var(--space-3); font-size: var(--type-label-size); }

/* ------------------------------------------------------------------ */
/* Diálogos, janelas e avisos                                          */
/* ------------------------------------------------------------------ */
/* <dialog>: folha que sobe de baixo no celular, janela central em telas maiores. */
.dialog {
  width: 100%;
  max-width: 100%;
  margin: auto 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sheet);
}
.dialog::backdrop { background: var(--scrim); }
.dialog[open] { animation: sheet-in 0.2s ease-out; }
.dialog-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-5) calc(var(--space-5) + env(safe-area-inset-bottom));
}
.dialog-title {
  font-size: var(--type-title-l-size);
  line-height: var(--type-title-l-line);
  font-weight: var(--type-title-l-weight);
  overflow-wrap: anywhere;
}
.dialog-text { color: var(--text-muted); font-size: var(--type-body-ui-size); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }
.dialog-actions-split { justify-content: space-between; }

/* Janela "à mão" (div): notas e usuários. */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-dialog);
  display: flex;
  align-items: flex-end;
  background: var(--scrim);
}
.modal-card {
  width: 100%;
  max-height: calc(100dvh - var(--space-8));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-5) calc(var(--space-5) + env(safe-area-inset-bottom));
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-sheet);
  animation: sheet-in 0.2s ease-out;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }

@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.toasts {
  position: fixed;
  left: var(--space-4);
  right: var(--space-4);
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom) + var(--bottom-ui, 0px));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 480px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-popover);
  font-size: var(--type-label-size);
  line-height: var(--type-label-line);
  animation: sheet-in 0.2s ease-out;
  transition: opacity 0.25s;
}
.toast.leaving { opacity: 0; }
.toast-error .icon { color: color-mix(in srgb, var(--danger) 60%, var(--bg)); }

@media (min-width: 681px) {
  .dialog {
    max-width: 480px;
    margin: auto;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
  }
  .dialog-body { padding: var(--space-6); }
  .modal { align-items: center; justify-content: center; padding: var(--space-4); }
  .modal-card {
    max-width: 480px;
    padding: var(--space-6);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
  }
  .toasts { left: auto; right: var(--space-6); bottom: var(--space-6); align-items: flex-end; }
}

/* ------------------------------------------------------------------ */
/* Entrar, cadastro e recuperação                                      */
/* ------------------------------------------------------------------ */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: calc(var(--space-8) + env(safe-area-inset-top)) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
}
.login-card {
  width: 100%;
  max-width: 400px;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}
.logo-link { align-self: center; }
.logo-login { height: 44px; width: calc(44px * 171.333 / 64); }
.auth-view { display: flex; flex-direction: column; gap: var(--space-4); }
.auth-title {
  font-family: var(--font-display);
  font-size: var(--type-display-m-size);
  line-height: var(--type-display-m-line);
  font-weight: var(--type-display-m-weight);
  letter-spacing: var(--type-display-m-tracking);
}
.auth-view .btn-primary { margin-top: var(--space-1); }
.auth-links { text-align: center; color: var(--text-muted); font-size: var(--type-label-size); }
a { color: var(--accent-text); text-underline-offset: 2px; }
.btn { text-decoration: none; }
.field-hint { font-size: var(--type-caption-size); line-height: var(--type-caption-line); color: var(--text-muted); }
.check { display: flex; gap: var(--space-3); align-items: flex-start; font-size: var(--type-label-size); line-height: 1.45; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.notice {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--accent-tint);
  color: var(--text);
  font-size: var(--type-label-size);
}
.divider { display: flex; align-items: center; gap: var(--space-3); color: var(--text-muted); font-size: var(--type-caption-size); }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.google-area { display: flex; flex-direction: column; gap: var(--space-3); }
.google-btn { background: var(--surface); }
.google-g { width: 18px; height: 18px; }
.turnstile-slot { min-height: 65px; display: flex; justify-content: center; }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-5);
  padding: var(--space-8) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
  font-size: var(--type-caption-size);
}
.site-footer a { color: var(--text-muted); }

/* ------------------------------------------------------------------ */
/* Página inicial pública                                              */
/* ------------------------------------------------------------------ */
.landing-screen { overflow-y: auto; }
.landing-bar { position: sticky; top: 0; z-index: var(--z-sticky); }
.landing { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 var(--space-4); }
.hero { padding: var(--space-12) 0 var(--space-10); display: flex; flex-direction: column; gap: var(--space-5); }
.hero-title {
  font-family: var(--font-display);
  font-size: var(--type-display-l-size);
  line-height: var(--type-display-l-line);
  font-weight: var(--type-display-l-weight);
  letter-spacing: var(--type-display-l-tracking);
}
.hero-text { font-size: 18px; line-height: 1.6; color: var(--text-muted); max-width: 36em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.features { display: grid; gap: var(--space-4); padding-bottom: var(--space-12); }
.feature, .plan-card, .card-section, .stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.feature { display: flex; flex-direction: column; gap: var(--space-2); }
.feature h2 { font-size: var(--type-title-m-size); line-height: var(--type-title-m-line); }
.feature p { color: var(--text-muted); }
.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-tint);
  color: var(--accent-text);
  margin-bottom: var(--space-2);
}
.section-title { font-size: var(--type-title-l-size); line-height: var(--type-title-l-line); font-weight: var(--type-title-l-weight); }
.plans { display: flex; flex-direction: column; gap: var(--space-4); padding-bottom: var(--space-8); }
.plan-cards { display: grid; gap: var(--space-4); }
.plan-card h3 { font-size: var(--type-title-l-size); margin-bottom: var(--space-3); display: flex; align-items: center; gap: var(--space-2); }
.plan-card ul { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: var(--space-2); color: var(--text-muted); }
.plan-card-pro { border-color: var(--accent); }
.badge-pro, .badge-plan {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--accent-tint);
  color: var(--accent-text);
  font-size: var(--type-overline-size);
  font-weight: 700;
  letter-spacing: var(--type-overline-tracking);
  text-transform: uppercase;
}
.badge-plan:not(.is-pro) { background: var(--surface-2); color: var(--text-muted); }

@media (min-width: 720px) {
  .hero { padding: var(--space-16) 0 var(--space-12); }
  .hero-title { font-size: var(--type-display-xl-size); line-height: var(--type-display-xl-line); letter-spacing: var(--type-display-xl-tracking); }
  .features { grid-template-columns: repeat(3, 1fr); }
  .plan-cards { grid-template-columns: repeat(2, 1fr); }
}

/* ------------------------------------------------------------------ */
/* Telas de página (Conta, Administração)                              */
/* ------------------------------------------------------------------ */
.page-screen { display: flex; flex-direction: column; }
.app-bar-title { font-size: var(--type-title-m-size); line-height: var(--type-title-m-line); font-weight: 600; flex: 1; }
.page {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.page > * { width: 100%; max-width: 720px; margin-left: auto; margin-right: auto; }
.page-wide > * { max-width: 1200px; }
#admin-content { display: flex; flex-direction: column; gap: var(--space-4); }
.card-section { display: flex; flex-direction: column; gap: var(--space-3); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.usage-list { display: flex; flex-direction: column; gap: var(--space-3); }
.usage-row { display: flex; flex-direction: column; gap: var(--space-1); }
.usage-label { display: flex; justify-content: space-between; gap: var(--space-2); font-size: var(--type-label-size); }
.usage-row.near-limit .progress-fill { background: var(--warning); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2) var(--space-4); margin: 0; }
.kv dt { color: var(--text-muted); font-size: var(--type-label-size); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.setting-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
}
.setting-line:first-of-type { border-top: 0; }
.setting-line p { margin-top: 2px; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.plain-list li { padding: var(--space-3) 0; border-top: 1px solid var(--border); font-size: var(--type-label-size); }
.plain-list li:first-child { border-top: 0; }
.session-item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.page-footer-actions { display: flex; justify-content: center; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
.stat-card { display: flex; flex-direction: column; gap: 2px; padding: var(--space-4); }
.stat-value { font-family: var(--font-display); font-size: var(--type-display-m-size); line-height: var(--type-display-m-line); font-weight: 600; }
.stat-label { font-weight: 600; font-size: var(--type-label-size); }
.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--space-5)); padding: 0 var(--space-5); }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--type-label-size); white-space: nowrap; }
.data-table th { text-align: left; font-size: var(--type-overline-size); letter-spacing: var(--type-overline-tracking); text-transform: uppercase; color: var(--text-muted); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); }
.data-table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); }
.table-actions { display: flex; gap: var(--space-1); justify-content: flex-end; }
#admin-search { min-width: 0; flex: 0 1 260px; }

.banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--accent);
  background: var(--accent-tint);
  font-size: var(--type-label-size);
}
.banner p { flex: 1; }
.banner .icon { color: var(--accent-text); }

.qr { display: flex; justify-content: center; padding: var(--space-3); background: #ffffff; border-radius: var(--radius-md); }
.qr svg { width: 200px; height: 200px; }
.mono, .codes { font-family: var(--font-read-mono); overflow-wrap: anywhere; }
.codes { margin: 0; padding: var(--space-3); background: var(--surface-2); border-radius: var(--radius-md); columns: 2; font-size: 15px; line-height: 1.8; }
.choose-options { display: flex; flex-direction: column; gap: var(--space-2); }
.onboarding .dialog-body { text-align: center; align-items: center; }
.onboarding-slide { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.onboarding-dots { display: flex; gap: var(--space-2); }
.onboarding-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.onboarding-dots span.active { background: var(--accent); }
.onboarding .dialog-actions { width: 100%; justify-content: space-between; }

@media (min-width: 720px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .page { padding-top: var(--space-8); }
}

/* ------------------------------------------------------------------ */
/* Biblioteca                                                          */
/* ------------------------------------------------------------------ */
.library-screen { display: flex; flex-direction: column; }

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: calc(var(--space-2) + env(safe-area-inset-top)) var(--space-2) var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.logo-bar { height: 28px; width: calc(28px * 171.333 / 64); }
.app-bar-actions { display: flex; gap: var(--space-1); }

.library {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-4) calc(var(--space-10) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.library > * { width: 100%; max-width: 1120px; margin-left: auto; margin-right: auto; }
.library-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }

.continue-reading { display: flex; flex-direction: column; gap: var(--space-2); }

/* Celular: lista (capa pequena + informações). Telas maiores: grade de cards. */
.library-grid { display: flex; flex-direction: column; gap: var(--space-2); }

.doc-card {
  position: relative;
  display: flex;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}
.doc-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  padding-right: 0;
  background: none;
  border: 0;
  border-radius: var(--radius-lg);
  text-align: left;
}
.doc-menu { align-self: flex-start; margin: var(--space-1); color: var(--text-muted); }

/* Capa tipográfica: inicial do título em Fraunces sobre a cor da marca. */
.doc-cover {
  position: relative;
  flex-shrink: 0;
  width: 56px;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.doc-cover::before { /* lombada */
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
}
.doc-cover-letter {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1;
  font-weight: 600;
}
.doc-cover-format {
  position: absolute;
  bottom: 4px;
  right: 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.8;
}
.doc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.doc-title {
  font-size: var(--type-title-m-size);
  line-height: var(--type-title-m-line);
  font-weight: var(--type-title-m-weight);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.doc-meta, .doc-status {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--type-caption-size);
  line-height: var(--type-caption-line);
  color: var(--text-muted);
}
.doc-status .icon { width: 14px; height: 14px; }
.doc-status.busy .icon { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress { display: block; height: 4px; border-radius: var(--radius-full); background: var(--border); overflow: hidden; }
.progress-fill { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

/* "Continuar lendo": card largo com botão. */
.doc-card-hero .doc-cover { width: 72px; }
.doc-card-hero .doc-open { padding: var(--space-4); padding-right: var(--space-4); }
.doc-card-hero .continue-cta { margin-top: var(--space-2); align-self: flex-start; pointer-events: none; }

.library-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-4);
  color: var(--text-muted);
}
.library-empty .empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-tint);
  color: var(--accent-text);
}
.library-empty .empty-icon .icon { width: 28px; height: 28px; }
.library-empty h2 { color: var(--text); font-size: var(--type-title-l-size); line-height: var(--type-title-l-line); }

.skeleton {
  height: 90px;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* Usuários (admin) */
.users-card { max-width: 560px; }
.users-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.users-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}
.users-item-info { flex: 1 1 140px; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.users-item-info span { font-size: var(--type-caption-size); color: var(--text-muted); }
.users-item .btn { min-height: 36px; padding: 0 var(--space-3); }
.users-empty { color: var(--text-muted); }
.new-user-form { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.new-user-form input { flex: 1 1 160px; min-width: 0; }
.users-result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--accent);
  background: var(--accent-tint);
  line-height: 1.5;
}
.users-result > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.users-password { font-family: var(--font-read-mono); letter-spacing: 0.04em; }

@media (min-width: 720px) {
  .app-bar { padding: var(--space-3) var(--space-6); }
  .logo-bar { height: 32px; width: calc(32px * 171.333 / 64); }
  .library { padding: var(--space-8) var(--space-6) var(--space-12); gap: var(--space-6); }
  .chips { margin: 0 auto; padding: var(--space-1) 0; flex-wrap: wrap; overflow: visible; }

  .library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-4);
  }
  .library-grid .doc-card { flex-direction: column; }
  .library-grid .doc-open { flex-direction: column; align-items: stretch; padding: var(--space-3); }
  .library-grid .doc-cover { width: 100%; aspect-ratio: 3 / 2; }
  .library-grid .doc-cover-letter { font-size: 56px; }
  .library-grid .doc-cover-format { font-size: 11px; bottom: 8px; right: 10px; }
  .library-grid .doc-menu { position: absolute; top: var(--space-2); right: var(--space-2); margin: 0; background: color-mix(in srgb, var(--surface) 85%, transparent); }
  .doc-card-hero .doc-cover { width: 96px; }
}

/* ------------------------------------------------------------------ */
/* Leitor — barras                                                     */
/* ------------------------------------------------------------------ */
.reader-screen { display: flex; flex-direction: column; position: relative; overflow: hidden; }

.reader-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: calc(var(--space-1) + env(safe-area-inset-top)) var(--space-1) var(--space-1);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  min-width: 0;
}
.reader-toolbar > * { flex-shrink: 0; }

#reader-title {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: var(--type-label-size);
  padding: 0 var(--space-1);
}

.control-group { display: flex; align-items: center; gap: var(--space-1); }
.control-icon { color: var(--text-muted); }
.value-label {
  min-width: 48px;
  font-size: var(--type-caption-size);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.page-form { display: flex; }
.page-input {
  width: 56px;
  min-height: 36px;
  padding: 0 var(--space-1);
  text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.page-input::-webkit-outer-spin-button, .page-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.page-indicator {
  font-size: var(--type-caption-size);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Celular: barra de baixo, ao alcance do polegar (páginas, foco, sumário). */
.reader-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2) calc(var(--space-1) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.mobile-only { display: flex; }

@media (min-width: 681px) {
  .mobile-only { display: none !important; }
  .reader-toolbar { gap: var(--space-2); padding: var(--space-2) var(--space-4); }
  #reader-title { font-size: var(--type-body-ui-size); }
  .reader-toolbar .btn-label { display: inline; }
  .reader-toolbar .btn-icon:has(.btn-label) { padding: 0 var(--space-3); }
  #g-nav { margin: 0 var(--space-4); }
}

/* ------------------------------------------------------------------ */
/* Leitor — documento                                                  */
/* ------------------------------------------------------------------ */
.pdf-container {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  align-items: safe center;
  padding: var(--space-3);
  -webkit-overflow-scrolling: touch;
}
#single-page-view { width: 100%; display: flex; flex-direction: column; align-items: center; align-items: safe center; }
/* Página renderizada no tamanho real do zoom: quando passa da largura da
   tela, rola na horizontal (encolher com max-width distorcia a página).
   Só com canvas (.pdf-wrap): o texto ajustável contínuo também usa
   .continuous-page-block, e max-content nele desfazia a quebra de linha. */
#single-page-view:has(#pdf-page-wrap:not(.hidden)), #continuous-view:has(.pdf-wrap) { min-width: max-content; }
#pdf-page-wrap { position: relative; }
#pdf-canvas { display: block; cursor: pointer; box-shadow: var(--shadow-popover); border-radius: 2px; }
#highlight-canvas { position: absolute; top: 0; left: 0; pointer-events: none; }

#pdf-page-wrap.loading { min-width: 160px; min-height: 220px; }
#pdf-page-wrap.loading::after {
  content: "Carregando página…";
  position: absolute;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  white-space: nowrap;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--type-caption-size);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-popover);
}

/* PDF nos temas escuros: inverte as cores do canvas (fundo escuro, texto
   claro); hue-rotate(180deg) devolve o matiz das imagens coloridas. */
body[data-theme="dark"] #pdf-canvas,
body[data-theme="amoled"] #pdf-canvas,
body[data-theme="midnight"] #pdf-canvas,
body[data-theme="coffee"] #pdf-canvas,
body[data-theme="dark"] .continuous-page-block canvas,
body[data-theme="amoled"] .continuous-page-block canvas,
body[data-theme="midnight"] .continuous-page-block canvas,
body[data-theme="coffee"] .continuous-page-block canvas {
  filter: invert(0.92) hue-rotate(180deg);
}

/* Camada de texto invisível do pdf.js por cima do canvas — dá pra
   selecionar/copiar o texto real do PDF mesmo a página sendo uma imagem
   renderizada. Posicionamento de cada <span> é calculado pelo pdf.js
   (TextLayer); aqui o essencial do pdf_viewer.css do pdf.js 6 pra ficar
   invisível, clicável e alinhado ao canvas (--total-scale-factor vem do JS). */
.textLayer {
  --scale-round-x: 1px;
  --scale-round-y: 1px;
  --min-font-size: 1;
  --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
  --min-font-size-inv: calc(1 / var(--min-font-size));
  position: absolute;
  inset: 0;
  overflow: clip;
  line-height: 1;
  letter-spacing: normal;
  word-spacing: normal;
  text-align: initial;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  caret-color: CanvasText;
  z-index: 0;
}
.textLayer span, .textLayer br {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
  -webkit-user-select: text;
  user-select: text;
}
.textLayer > :not(.markedContent),
.textLayer .markedContent span:not(.markedContent) {
  z-index: 1;
  --font-height: 0;
  font-size: calc(var(--text-scale-factor) * var(--font-height));
  --scale-x: 1;
  --rotate: 0deg;
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}
.textLayer .markedContent { display: contents; }
.textLayer span[role="img"] { -webkit-user-select: none; user-select: none; cursor: default; }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent {
  display: block;
  position: absolute;
  inset: 100% 0 0;
  z-index: 0;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}
.textLayer.selecting .endOfContent { top: 0; }
.textLayer ::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

/* Texto ajustável (reflow): tipografia de leitura do Lume, ajustável pelo leitor. */
.text-view {
  width: 100%;
  max-width: var(--reader-text-width, 720px);
  padding: var(--space-2) var(--space-1) var(--space-10);
  font-family: var(--font-read-serif);
  font-size: calc(var(--type-leitura-serif-size) * var(--reader-font-size, 1));
  line-height: var(--reader-line-spacing, var(--type-leitura-serif-line));
  color: var(--text);
  overflow-wrap: break-word;
  hyphens: auto;
}
.text-view[data-font="sans"] { font-family: var(--font-read-sans); }
.text-view[data-font="mono"] { font-family: var(--font-read-mono); font-size: calc(var(--type-leitura-mono-size) * var(--reader-font-size, 1)); }
.text-view[data-font="dyslexic"] { font-family: var(--font-read-dyslexic); letter-spacing: var(--type-leitura-dislexia-tracking); word-spacing: 0.1em; }
.text-view p {
  margin: 0 0 1em;
  padding: 2px 6px;
  margin-left: -6px;
  margin-right: -6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s;
}
@media (hover: hover) { .text-view p:hover { background: var(--surface-2); } }

/* Trecho que a leitura em voz alta está falando (todos os modos de exibição). */
.text-view p.reading { background: var(--read-sentence); box-shadow: inset 3px 0 0 var(--accent); }
/* Palavra falada pela voz do aparelho (CSS Custom Highlight API). */
::highlight(lume-word) { background-color: var(--read-word); }
.tts-highlight {
  position: absolute;
  background: var(--read-sentence);
  border-radius: 2px;
  pointer-events: none;
}

.continuous-page-divider {
  text-align: center;
  font-size: var(--type-caption-size);
  color: var(--text-muted);
  margin: var(--space-8) 0 var(--space-4);
  border-top: 1px dashed var(--border);
  padding-top: var(--space-2);
}
.continuous-page-block { width: 100%; }
.continuous-page-block:has(.pdf-wrap) { display: flex; flex-direction: column; align-items: center; align-items: safe center; }
.continuous-page-block canvas { display: block; box-shadow: var(--shadow-popover); }
/* .text-view limita a largura do texto ajustável (largura da coluna); com a
   página original os blocos são canvases e não podem ser espremidos por ela. */
#continuous-view:has(.pdf-wrap) { max-width: none; padding: 0; }
#continuous-sentinel, #continuous-top-sentinel { height: 1px; }

/* Notas (verde) e grifos (amarelo): no texto e em retângulos sobre o PDF. */
.note-mark {
  background: var(--grifo-verde);
  border-bottom: 2px solid color-mix(in srgb, var(--success) 70%, transparent);
  color: inherit;
  cursor: pointer;
  border-radius: 2px;
}
.note-mark.is-highlight { background: var(--grifo-amarelo); border-bottom-color: transparent; }
.note-layer { position: absolute; inset: 0; pointer-events: none; }
.note-rect {
  position: absolute;
  background: var(--grifo-verde);
  border-bottom: 2px solid color-mix(in srgb, var(--success) 70%, transparent);
  mix-blend-mode: multiply;
}
.note-rect.is-highlight { background: var(--grifo-amarelo); border-bottom-color: transparent; }
body[data-theme="dark"] .note-rect,
body[data-theme="amoled"] .note-rect,
body[data-theme="midnight"] .note-rect,
body[data-theme="coffee"] .note-rect { mix-blend-mode: screen; }
/* Nota criada no texto ajustável vista na página original: barra na margem do parágrafo. */
.note-rect.note-rect-paragraph {
  background: none;
  border-bottom: none;
  border-left: 3px solid var(--success);
  margin-left: -8px;
  mix-blend-mode: normal;
}
.note-rect.note-rect-paragraph.is-highlight { border-left-color: var(--warning); }
.note-badge {
  position: absolute;
  z-index: 3; /* acima da camada de texto, que cobre a página toda */
  transform: translate(-70%, -70%);
  pointer-events: auto;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--success);
  background: var(--surface);
  color: var(--success);
  box-shadow: var(--shadow-popover);
}
.note-badge .icon { width: 16px; height: 16px; }

/* Botões que aparecem sob o texto selecionado. */
.float-btn {
  position: fixed;
  z-index: var(--z-toast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: var(--type-label-size);
  font-weight: var(--type-label-weight);
  box-shadow: var(--shadow-popover);
  white-space: nowrap;
}
.float-btn .icon { width: 18px; height: 18px; }
.float-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Janela de nota */
#note-modal-quote {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--success);
  background: var(--bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-family: var(--font-read-serif);
  font-size: var(--type-caption-size);
  line-height: 1.5;
  max-height: 20vh;
  overflow-y: auto;
  color: var(--text-muted);
}
#note-modal.is-highlight #note-modal-quote { border-left-color: var(--warning); }

/* ------------------------------------------------------------------ */
/* Leitor — painel lateral (sumário, marcadores, notas)                */
/* ------------------------------------------------------------------ */
#side-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 88vw;
  z-index: var(--z-sheet);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-modal);
}
.side-panel-tabs {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-1) 0 var(--space-2);
  border-bottom: 1px solid var(--border);
}
.side-tab {
  flex: 1;
  min-height: var(--tap-target);
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-muted);
  font-size: var(--type-label-size);
  font-weight: var(--type-label-weight);
}
.side-tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.side-tab-content { flex: 1; overflow-y: auto; padding: var(--space-3); }
#add-bookmark-btn, #export-notes-btn { margin-bottom: var(--space-3); }
.book-search { display: flex; gap: var(--space-1); margin-bottom: var(--space-3); }
.book-search input { flex: 1; min-width: 0; }
.search-result { display: block; width: 100%; text-align: left; color: inherit; font: inherit; padding-right: var(--space-3); }
.search-result mark { background: var(--read-word); color: inherit; border-radius: 2px; }

.outline-item {
  padding: var(--space-2) var(--space-2);
  min-height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--type-label-size);
  line-height: 1.4;
}
.outline-empty { color: var(--text-muted); font-size: var(--type-label-size); padding: var(--space-2); }

.bookmark-item {
  position: relative;
  padding: var(--space-3);
  padding-right: var(--space-10);
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border);
  margin-bottom: var(--space-2);
  cursor: pointer;
  font-size: var(--type-label-size);
}
.bookmark-item .bookmark-page { font-weight: 600; }
.bookmark-item .bookmark-note { margin-top: var(--space-1); color: var(--text-muted); white-space: pre-wrap; }
.bookmark-item .bookmark-delete {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.bookmark-item .bookmark-delete .icon { width: 18px; height: 18px; }
.note-item .note-quote {
  font-family: var(--font-read-serif);
  color: var(--text-muted);
  border-left: 3px solid var(--success);
  padding-left: var(--space-2);
  margin: var(--space-1) 0;
}
.note-item.is-highlight .note-quote { border-left-color: var(--warning); }
.note-item .note-text { white-space: pre-wrap; }

/* ------------------------------------------------------------------ */
/* Leitor — modo foco                                                  */
/* ------------------------------------------------------------------ */
#focus-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-dialog);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(68px + env(safe-area-inset-top)) var(--space-6) calc(100px + env(safe-area-inset-bottom));
  background: var(--bg);
  cursor: pointer;
}
#focus-text {
  max-width: var(--measure-media);
  max-height: 100%;
  overflow-y: auto;
  font-family: var(--font-read-serif);
  font-size: calc(22px * var(--reader-font-size, 1));
  line-height: var(--reader-line-spacing, var(--type-leitura-serif-line));
  text-align: left;
  cursor: text;
}
.focus-nav,
.focus-nav:active {
  position: fixed;
  bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  z-index: calc(var(--z-dialog) + 1);
  min-width: 72px;
  min-height: 52px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--surface);
}
.focus-nav .icon { width: 26px; height: 26px; }
#focus-prev { left: 18vw; }
#focus-next { right: 18vw; }
#focus-close {
  position: fixed;
  top: calc(var(--space-3) + env(safe-area-inset-top));
  right: var(--space-3);
  z-index: calc(var(--z-dialog) + 2);
}

@media (min-width: 681px) {
  #focus-overlay { padding: 10vh 10vw; }
  #focus-text { font-size: calc(28px * var(--reader-font-size, 1)); }
  .focus-nav, .focus-nav:active { top: 50%; bottom: auto; transform: translateY(-50%); }
  #focus-prev { left: 3vw; }
  #focus-next { right: 3vw; }
}

/* ------------------------------------------------------------------ */
/* Leitor — folha de ajustes (celular)                                 */
/* ------------------------------------------------------------------ */
#settings-backdrop { position: fixed; inset: 0; z-index: var(--z-sheet); background: var(--scrim); }
#settings-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 82dvh;
  z-index: calc(var(--z-sheet) + 1);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--text);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-sheet);
  animation: sheet-in 0.2s ease-out;
}
.sheet-handle { width: 36px; height: 4px; border-radius: var(--radius-full); background: var(--border-strong); margin: var(--space-2) auto 0; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-2) var(--space-2) var(--space-2) var(--space-5); }
#settings-sheet-body {
  overflow-y: auto;
  padding: 0 var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}
.setting-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  border-top: 1px solid var(--border);
}
.setting-section:first-child { border-top: 0; padding-top: var(--space-1); }
.setting-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--type-label-size);
  line-height: var(--type-label-line);
  font-weight: var(--type-label-weight);
}
.setting-label .value-label { min-width: 0; font-weight: 400; }
/* Rótulo à esquerda, seleção à direita. */
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.setting-row select { flex: 0 1 220px; min-width: 0; }
/* Rótulo em cima, slider largo embaixo. */
.setting-slider { display: flex; flex-direction: column; gap: 0; }
.setting-slider input[type="range"] { width: 100%; }
.setting-inline { display: flex; align-items: center; gap: var(--space-3); }
.setting-inline input[type="range"] { flex: 1; min-width: 0; }
.setting-actions { flex-direction: row; flex-wrap: wrap; }
.setting-actions .btn { flex: 1 1 200px; }

/* Amostras de tema: a cor de fundo e a de destaque de cada um (--sw-* em theme.css). */
.theme-swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--tap-target);
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: none;
  font-size: var(--type-caption-size);
}
.theme-swatch[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--accent-text); font-weight: 600; }
.swatch {
  width: 100%;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: linear-gradient(135deg, var(--sw-bg) 0 60%, var(--sw-accent) 60% 100%);
}

@media (min-width: 681px) {
  /* Computador: painel à direita, sem escurecer o documento. */
  #settings-backdrop { background: transparent; }
  #settings-sheet {
    left: auto;
    right: var(--space-4);
    top: 64px;
    bottom: auto;
    width: 380px;
    max-height: calc(100dvh - 80px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
  }
  .sheet-handle { display: none; }
}

/* ------------------------------------------------------------------ */
/* Tela limpa: só o documento                                          */
/* ------------------------------------------------------------------ */
#reader-screen.chrome-hidden .reader-toolbar,
#reader-screen.chrome-hidden .reader-bottom-bar,
#reader-screen.chrome-hidden .mini-player,
#reader-screen.chrome-hidden #side-panel,
#reader-screen.chrome-hidden #settings-sheet,
#reader-screen.chrome-hidden #settings-backdrop { display: none !important; }
#chrome-show {
  position: fixed;
  top: calc(var(--space-2) + env(safe-area-inset-top));
  right: var(--space-2);
  z-index: var(--z-sticky);
  background: var(--surface);
  border: 1px solid var(--border);
  opacity: 0.45;
  transition: opacity 0.15s;
}
#chrome-show:hover, #chrome-show:focus-visible { opacity: 1; }


/* Efeitos de passar o mouse só onde há mouse: no toque, o :hover "gruda"
   no botão depois do toque e ele parece continuar ligado. */
@media (hover: hover) {
  .btn-primary:hover { background: var(--accent-hover); }
  .btn-ghost:hover { background: var(--surface-2); }
  .btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
  .btn-icon:hover { background: var(--surface-2); }
  .chip:hover { background: var(--surface-2); }
  .doc-card:hover { border-color: var(--border-strong); }
  .outline-item:hover { background: var(--surface-2); }
  .bookmark-item:hover { border-color: var(--border-strong); }
  .bookmark-item .bookmark-delete:hover { color: var(--danger); background: var(--surface-2); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------------------------ */
/* Páginas legais (privacidade, termos, excluir conta)                 */
/* ------------------------------------------------------------------ */
body.legal-page { height: auto; min-height: 100vh; overflow: auto; }
.legal { max-width: 68ch; margin: 0 auto; padding: var(--space-8) var(--space-4) var(--space-6); line-height: 1.65; }
.legal h1 { font-family: var(--font-display); font-size: var(--type-display-m-size); line-height: var(--type-display-m-line); margin-bottom: var(--space-2); }
.legal h2 { font-size: var(--type-title-m-size); line-height: var(--type-title-m-line); margin: var(--space-8) 0 var(--space-2); }
.legal p, .legal ul, .legal ol { margin: 0 0 var(--space-3); }
.legal li { margin-bottom: var(--space-2); }

/* Aviso de sem conexão (fixo no topo, acima de tudo). */
.offline-banner {
  position: fixed;
  top: env(safe-area-inset-top);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: calc(100% - 2 * var(--space-4));
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-popover);
  font-size: var(--type-caption-size);
}

/* Capa gerada no servidor, por cima da letra. */
.doc-cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* Busca e ordenação da biblioteca. */
.library-tools { flex-shrink: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-3); }
.library-search, .library-sort {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap-target);
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-muted);
}
.library-search { flex: 1 1 100%; min-width: 0; }
@media (min-width: 681px) { .library-search { flex: 1 1 12rem; } }
.library-sort { flex: 1 1 auto; }
.library-search input, .library-sort select {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  padding: 0;
  min-height: 0;
}
.library-search input:focus, .library-sort select:focus { outline: none; box-shadow: none; }
.library-search:focus-within, .library-sort:focus-within { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.library-sort select { max-width: none; }
.library-no-results { grid-column: 1 / -1; color: var(--text-muted); padding: var(--space-4) 0; }
#add-doc-quota.quota-full { color: var(--danger); }

/* Botão dentro do aviso (ex.: Desfazer). */
.toast-action {
  pointer-events: auto;
  margin-left: var(--space-2);
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  min-height: 32px;
  cursor: pointer;
}

/* Onde guardar (nuvem x aparelho). */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
  padding: var(--space-1);
  margin-bottom: var(--space-2);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.segmented .segment {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap-target);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.segmented .segment[aria-checked="true"] { background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow-popover); }

/* Selo "No aparelho" / "Na nuvem" no card. */
.doc-where {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--type-caption-size);
  color: var(--text-muted);
}
.doc-where .icon { width: 14px; height: 14px; }
.doc-where.is-local { color: var(--accent-text); }

/* Documento no aparelho: recursos que dependem do texto extraído ficam apagados. */
#reader-screen.is-local #audio-toggle,
#reader-screen.is-local #focus-toggle { opacity: 0.45; }

/* Abas do painel lateral (o botão de fechar fica fora da lista de abas). */
.side-tablist { display: flex; flex: 1; min-width: 0; gap: var(--space-1); }
/* Área do documento: recebe foco para rolar pelo teclado, sem contorno ao tocar. */
#pdf-container:focus:not(:focus-visible) { outline: none; }
#pdf-container:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }

/* Medidor de força da senha. */
.strength { display: flex; flex-direction: column; gap: var(--space-1); margin-top: var(--space-1); }
.strength-bar { display: block; height: 6px; border-radius: var(--radius-full); background: var(--surface-2); overflow: hidden; }
.strength-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--text-muted); transition: width 0.2s, background-color 0.2s; }
.strength[data-tone="weak"] .strength-fill { background: var(--danger); }
.strength[data-tone="fair"] .strength-fill { background: var(--warning); }
.strength[data-tone="good"] .strength-fill, .strength[data-tone="strong"] .strength-fill { background: var(--success); }
/* No diálogo genérico, só quando o campo é de senha nova. */
#prompt-strength:not([data-enabled="1"]) { display: none; }

/* Mini-player da leitura em voz alta (entre o documento e a barra de baixo). */
.mini-player {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.mini-progress { height: 3px; background: var(--surface-2); }
#mini-progress-fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.mini-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
}
.mini-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.mini-status { font-size: var(--type-label-size); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-info .caption { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-controls { display: flex; align-items: center; gap: var(--space-1); }
.mini-play { background: var(--accent); color: var(--on-accent); border-radius: var(--radius-full); }
@media (hover: hover) { .mini-play:hover { background: color-mix(in srgb, var(--accent) 88%, black); } }
.mini-chip { min-width: 44px; padding: 0 var(--space-2); font-variant-numeric: tabular-nums; gap: 4px; }
.mini-chip.active { color: var(--accent-text); border-color: var(--accent); }
/* Celular estreito: a informação vai para cima e os botões ocupam a linha. */
@media (max-width: 420px) {
  .mini-row { flex-wrap: wrap; row-gap: 0; }
  .mini-info { flex-basis: 100%; flex-direction: row; gap: var(--space-2); align-items: baseline; }
  .mini-controls { flex: 1; justify-content: space-between; }
}

/* Arrastar e soltar na biblioteca. */
#library-screen { position: relative; }
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-dialog);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  pointer-events: none;
}
.drop-target {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: min(520px, 100%);
  padding: var(--space-10) var(--space-6);
  border: 3px dashed var(--accent);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--accent-text);
  text-align: center;
}
.drop-target .icon { width: 40px; height: 40px; }
.add-doc-files {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Impressão: só as páginas do documento, uma por folha (print.js). */
#print-root { display: none; }
@media print {
  @page { margin: 6mm; }
  body.printing { background: #fff; height: auto; overflow: visible; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }
  #print-root img {
    display: block;
    width: 100%;
    height: calc(100vh - 1px);
    object-fit: contain;
    break-after: page;
  }
  #print-root img:last-child { break-after: auto; }
}
