/* ══════════════════════════════════════════════════════════════
   RELANCE — leitor RSVP
   Instrumento de precisão. Bone sobre preto quente.
   A única cor do aplicativo inteiro é a letra focal.
   ══════════════════════════════════════════════════════════════ */

/* ─── fontes embutidas ──────────────────────────────────────

   O visual original dependia de Superclarendon, Futura e Menlo, que só
   existem em aparelho da Apple — no Android o app caía em Noto e Roboto e
   virava outro app. Estas quatro são SIL OFL 1.1 (veja fonts/OFL.txt) e
   viajam junto, então a tela é a mesma em todo lugar.

   Atkinson Hyperlegible foi desenhada pelo Braille Institute pra máxima
   distinção entre letras parecidas — exatamente o que o RSVP exige, já que
   você vê cada palavra uma vez só e não tem como reler.                    */

@font-face {
  font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 400;
  font-display: swap; src: url('../fonts/atkinson-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Bitter'; font-style: normal; font-weight: 400;
  font-display: swap; src: url('../fonts/bitter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Jost'; font-style: normal; font-weight: 400;
  font-display: swap; src: url('../fonts/jost-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Jost'; font-style: normal; font-weight: 500;
  font-display: swap; src: url('../fonts/jost-500.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400;
  font-display: swap; src: url('../fonts/plexmono-400.woff2') format('woff2');
}

:root {
  --ink:        #0c0b0a;
  --ink-lift:   #141210;
  --ink-edge:   #1e1b18;
  --bone:       #e9e3d6;
  --bone-soft:  #b3ab9c;
  --bone-dim:   #6d665b;
  --bone-ghost: #3a352e;
  --focal:      #e5502b;

  --font-display: "Jost", "Futura", "Avenir Next", "Gill Sans", sans-serif;
  --font-read-serif: "Bitter", "Superclarendon", "Charter", Georgia, serif;
  --font-read-sans:  "Atkinson Hyperlegible", "Avenir Next", "Helvetica Neue", sans-serif;
  --font-mono: "IBM Plex Mono", "Menlo", ui-monospace, monospace;

  --word-size: 64px;   /* preferência do leitor */
  --word: 64px;        /* o que cabe de fato na tela — calculado em app.js */
  --word-font: var(--font-read-serif);

  --hair: 1px solid rgba(233, 227, 214, 0.11);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --pad: clamp(20px, 5vw, 64px);
}

* { box-sizing: border-box; }

/* Regras de ID abaixo definem `display`, o que venceria o display:none que o
   navegador dá ao atributo [hidden]. Sem isto, tudo aparece de uma vez. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { overflow-x: hidden; }

.mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; }
.dim  { color: var(--bone-dim); }

/* ─── atmosfera ─────────────────────────────────────────── */

.grain {
  position: fixed; inset: 0; z-index: 900; pointer-events: none;
  opacity: 0.07; mix-blend-mode: overlay;
  transition: opacity 0.6s var(--ease);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.vignette {
  position: fixed; inset: 0; z-index: 899; pointer-events: none;
  background: radial-gradient(ellipse 130% 100% at 50% 45%, transparent 58%, rgba(0,0,0,0.26) 100%);
  transition: opacity 0.6s var(--ease);
}

/* Lendo, atmosfera vira distração: a palavra está sempre no mesmo ponto e
   qualquer variação de luz em volta puxa o olho. Some quase por completo. */
body.reading .grain { opacity: 0.03; }
body.reading .vignette { opacity: 0.35; }

/* ══════════════════ BIBLIOTECA ══════════════════ */

.view { min-height: 100%; }

#view-library {
  max-width: 940px;
  margin: 0 auto;
  padding: clamp(28px, 6vh, 72px) var(--pad) 64px;
  animation: rise 0.7s var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.masthead-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
}

.wordmark {
  margin: 0;
  font-size: clamp(34px, 7vw, 58px);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: lowercase;
}
.wordmark-orp { color: var(--focal); }

.masthead-meta { display: flex; align-items: center; gap: 18px; }

.tagline {
  margin: 14px 0 0;
  max-width: 46ch;
  font-size: 15px;
  line-height: 1.5;
  color: var(--bone-soft);
}

.rule {
  height: 1px;
  background: linear-gradient(90deg, rgba(233,227,214,0.30), rgba(233,227,214,0.04) 70%, transparent);
  margin: 26px 0;
}

.ghost-btn {
  background: none; border: none; padding: 6px 2px;
  color: var(--bone-soft);
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.ghost-btn:hover { color: var(--bone); border-bottom-color: var(--focal); }

/* ─── entrada de arquivos ───────────────────────────────── */

.intake {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 12px;
  margin-bottom: 40px;
}
@media (max-width: 620px) { .intake { grid-template-columns: 1fr; } }

.intake-drop, .intake-paste {
  display: flex; flex-direction: column; justify-content: center;
  gap: 4px;
  min-height: 128px;
  padding: 22px;
  background: var(--ink-lift);
  border: 1px dashed rgba(233,227,214,0.16);
  color: var(--bone);
  font-family: inherit; font-size: 15px; text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s var(--ease);
}
.intake-paste { border-style: solid; }

.intake-drop:hover, .intake-paste:hover,
.intake-drop.hot {
  border-color: var(--focal);
  background: var(--ink-edge);
  transform: translateY(-2px);
}

.intake-plus {
  font-family: var(--font-mono); font-size: 20px;
  color: var(--focal); line-height: 1; margin-bottom: 8px;
}
.intake-label b { font-weight: 600; }
.intake-sub { color: var(--bone-dim); margin-top: 2px; }

/* ─── estante ───────────────────────────────────────────── */

.shelf { display: flex; flex-direction: column; }

.book {
  position: relative;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 18px 0 18px 10px;
  border-top: var(--hair);
  cursor: pointer;
  transition: transform 0.25s var(--ease), padding-left 0.25s var(--ease);
}
.shelf .book:last-child { border-bottom: var(--hair); }
.book:hover { padding-left: 20px; }
.book::before {
  content: ""; position: absolute; left: 0; top: 50%;
  width: 3px; height: 0; background: var(--focal);
  transform: translateY(-50%);
  transition: height 0.25s var(--ease);
}
.book:hover::before { height: 62%; }

.book-num {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--bone-ghost); letter-spacing: 0.05em;
}
.book:hover .book-num { color: var(--bone-dim); }

.book-main { min-width: 0; }
.book-title {
  font-family: var(--font-read-serif);
  font-size: clamp(17px, 2.4vw, 21px);
  line-height: 1.25;
  margin: 0 0 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.book-sub {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--bone-dim);
  display: flex; gap: 10px; flex-wrap: wrap;
}
.book-sub .sep { color: var(--bone-ghost); }

.book-right { display: flex; align-items: center; gap: 14px; }

.book-bar {
  width: clamp(48px, 14vw, 120px); height: 2px;
  background: rgba(233,227,214,0.10);
  position: relative; overflow: hidden;
}
.book-bar span {
  position: absolute; inset: 0 auto 0 0;
  background: var(--bone-soft);
  transition: width 0.4s var(--ease);
}
.book:hover .book-bar span { background: var(--focal); }

.book-pct { font-family: var(--font-mono); font-size: 11px; color: var(--bone-dim); min-width: 32px; text-align: right; }

.book-kill {
  background: none; border: none; cursor: pointer; padding: 6px;
  color: var(--bone-ghost); font-family: var(--font-mono); font-size: 13px;
  opacity: 0; transition: opacity 0.2s, color 0.2s;
}
.book:hover .book-kill { opacity: 1; }
.book-kill:hover { color: var(--focal); }

.empty {
  padding: 48px 0; text-align: center; line-height: 1.7;
  color: var(--bone-soft); font-size: 15px;
}
.empty p { margin: 0 0 24px; }
/* .solid-btn nasceu pras folhas laterais, onde ocupa a largura toda;
   aqui precisa encolher, e vem depois no arquivo — daí as duas classes */
.empty .solid-btn { width: auto; padding: 13px 26px; }

.colophon { margin-top: 56px; color: var(--bone-ghost); }
.colophon p { margin: 0; }

/* ══════════════════ LEITOR ══════════════════ */

#view-reader {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--ink);
  z-index: 500;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ─── sumir enquanto lê ─────────────────────────────────────

   Com o texto passando, só a palavra importa. Tudo mais sai de cena —
   inteiro, não desbotado: 6% de opacidade ainda é coisa pra vista tropeçar.
   O ponteiro também é desligado, senão um toque perto da borda de baixo
   acerta um botão invisível.                                              */

.reader-top, .reader-bottom {
  transition: opacity 0.28s var(--ease);
}
#view-reader.immersed .reader-top,
#view-reader.immersed .reader-bottom { opacity: 0; pointer-events: none; }

/* Quem devolve a moldura é MEXER o mouse, não estar com ele em cima: o leitor
   ocupa a tela toda, então :hover está sempre ativo e a moldura nunca sumiria.
   A classe .awake entra no mousemove e sai sozinha depois de parado. */
#view-reader.immersed.awake .reader-top,
#view-reader.immersed.awake .reader-bottom { opacity: 1; pointer-events: auto; }

/* Onde não há mouse, .awake não tem sentido: nada pode "acordar" a moldura
   durante a leitura, e quem a devolve é pausar. Sem esta trava, qualquer
   caminho de código que deixe a classe ligada mantém a moldura na tela —
   que é exatamente o defeito visto no iPhone.

   Repare que o seletor repete .awake: media query não soma especificidade,
   então uma regra mais curta perderia pra de cima e não adiantaria nada.
   Mesma especificidade, mais abaixo no arquivo — esta vence. */
@media (hover: none) {
  #view-reader.immersed.awake .reader-top,
  #view-reader.immersed.awake .reader-bottom { opacity: 0; pointer-events: none; }
}

/* Sem mouse parado no meio da palavra */
#view-reader.immersed .stage { cursor: none; }
#view-reader.immersed.awake .stage { cursor: pointer; }

/* Fio de progresso: a única coisa que sobrevive à leitura. Dá noção de
   avanço sem pedir atenção. */
.ambient {
  position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: rgba(233, 227, 214, 0.06);
  opacity: 0; transition: opacity 0.45s var(--ease);
  pointer-events: none;
}
#view-reader.immersed .ambient { opacity: 1; }
.ambient span {
  display: block; height: 100%; width: 0;
  background: var(--bone-ghost);
}

.reader-top {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 12px;
  padding: 16px var(--pad);
  border-bottom: var(--hair);
}
.reader-chapter {
  color: var(--bone-dim); text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.reader-right { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.reader-wpm { color: var(--bone-dim); }
.btn-rotate { font-size: 15px; line-height: 1; padding: 4px 6px; }

/* ─── paisagem à força ──────────────────────────────────────

   Nenhum navegador de celular deixa travar a orientação de forma
   confiável: o iOS ignora screen.orientation.lock() e o manifesto, e
   quem está com o bloqueio de retrato ligado nunca vê a tela girar.
   Então o app gira o próprio conteúdo. O leitor passa a medir
   100dvh de largura por 100dvw de altura e roda em torno do canto
   superior esquerdo, voltando pro lugar com o translate.            */

#view-reader.rot-90, #view-reader.rot-270 {
  width: 100vh; width: 100dvh;
  height: 100vw; height: 100dvw;
  /* .view impõe min-height:100%, que aqui venceria o height e deixaria o
     leitor com a altura da tela em vez da largura — girado, ele transborda. */
  min-height: 0;
  transform-origin: top left;
}
#view-reader.rot-90  { transform: rotate(90deg) translateY(-100%); }
#view-reader.rot-270 { transform: rotate(-90deg) translateX(-100%); }

/* ─── palco ─────────────────────────────────────────────── */

.stage {
  position: relative;
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  /* o palco é superfície de gesto: o navegador não pode roubar o arrasto
     pra rolar a página nem pro efeito elástico do iOS */
  touch-action: none;
}

.pivot {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  height: calc(var(--word) * 2.1);
  display: flex; flex-direction: column; align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.tick { width: 1px; height: calc(var(--word) * 0.42); background: rgba(233,227,214,0.22); }
.tick-top { box-shadow: 0 0 0 0 transparent; }

.rail-wrap {
  position: relative;
  width: 100%;
  height: calc(var(--word) * 1.5);
  display: flex; align-items: center;
  overflow: hidden;
}

.rail {
  position: absolute; left: 50%; top: 50%;
  display: flex; align-items: baseline;
  white-space: pre;
  font-family: var(--word-font);
  font-size: var(--word);
  line-height: 1.1;
  letter-spacing: -0.005em;
  transform: translate(-50%, -50%);
  will-change: transform;
}
.rail .pre, .rail .post { color: var(--bone); }
.rail .orp { color: var(--focal); }

/* piscada suavíssima na troca de palavra — só perceptível no subconsciente */
.rail.tick-on { animation: blip 0.09s linear; }
@keyframes blip { from { opacity: 0.55; } to { opacity: 1; } }

.peek {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: min(90%, 760px);
  text-align: center;
  color: var(--bone-ghost);
  font-size: 12px;
  line-height: 1.6;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  pointer-events: none;
}
.peek-prev { bottom: calc(50% + var(--word) * 1.5); }
.peek-next { top:    calc(50% + var(--word) * 1.5); }
.stage.paused .peek.on { opacity: 1; }

.paused-badge {
  position: absolute; bottom: 22px; left: 50%;
  transform: translateX(-50%);
  color: var(--bone-ghost);
  opacity: 0; transition: opacity 0.4s var(--ease);
  letter-spacing: 0.12em; text-transform: uppercase;
}
.stage.paused .paused-badge { opacity: 1; }
.stage.picking .paused-badge, .stage.picking .peek { opacity: 0; }

/* No toque a instrução já está na faixa do polegar, escrita na vertical e
   fora do caminho. Repetir no meio do palco só serve pra colidir com a
   palavra quando a tela é baixa — que é o normal do celular deitado. */
@media (pointer: coarse) { .paused-badge { display: none; } }

/* ─── tela baixa ────────────────────────────────────────────

   Celular deitado no Safari sobra pouca altura: a barra de endereço e as
   abas comem quase metade. A classe entra por JS, não por media query,
   porque com o leitor girado a altura dele não é a altura da viewport.   */

#view-reader.compact .reader-top { padding: 7px var(--pad); }
#view-reader.compact .reader-bottom { padding-bottom: 8px; }
#view-reader.compact .readout { padding: 0 0 8px; }
#view-reader.compact .scrub { height: 18px; }
#view-reader.compact .scrub::before,
#view-reader.compact .scrub-fill { top: 8px; }
#view-reader.compact .scrub-head { top: 4px; height: 9px; }
#view-reader.compact .ctl { height: 32px; min-width: 46px; }
#view-reader.compact .ctl-main { height: 34px; min-width: 62px; font-size: 12px; }
#view-reader.compact .controls { gap: 6px; }

/* ─── faixa do polegar ──────────────────────────────────────
   Só existe onde há dedo. No desktop o palco inteiro responde.   */

.thumb-zone {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 42%;
  display: none;
  align-items: center; justify-content: flex-end;
  padding-right: 10px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(233, 227, 214, 0.012));
  transition: background 0.3s var(--ease), opacity 0.3s var(--ease);
}
@media (pointer: coarse) { .thumb-zone { display: flex; } }

.thumb-grip {
  width: 2px; height: 46px;
  background: var(--bone-ghost);
  transition: background 0.25s var(--ease), height 0.25s var(--ease);
}
.thumb-hint {
  position: absolute; right: 20px;
  color: var(--bone-ghost);
  writing-mode: vertical-rl;
  letter-spacing: 0.2em; text-transform: uppercase;
  transition: opacity 0.3s var(--ease);
}
.stage:not(.paused) .thumb-hint { opacity: 0; }

/* Confirmação de que o dedo pegou: fica no fio, não numa mancha de cor
   grande no canto do olho. */
.stage.holding .thumb-zone { background: linear-gradient(90deg, transparent, rgba(229, 80, 43, 0.03)); }
.stage.holding .thumb-grip { background: var(--focal); height: 72px; }
.stage.picking .thumb-zone { opacity: 0; }

/* ─── navegador de palavras ─────────────────────────────────
   Arrastar do polegar pra esquerda abre o texto corrido e escolhe
   onde pousar — a mesma ideia do cursor da barra de espaço do iPhone. */

.picker {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(8, 7, 6, 0.93);
  animation: fade 0.16s var(--ease);
  pointer-events: none;
}

.picker-window {
  position: relative;
  width: min(88%, 720px);
  height: 62%;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
}

.picker-flow {
  position: absolute; left: 0; right: 0; top: 0;
  font-family: var(--font-read-serif);
  font-size: clamp(15px, 2.1vh, 19px);
  line-height: 2.05;
  color: var(--bone-ghost);
  text-align: justify;
  will-change: transform;
}
.picker-flow .here {
  color: var(--ink);
  background: var(--focal);
  padding: 2px 5px;
  margin: 0 -1px;
  border-radius: 2px;
}
/* palavras vizinhas ganham brilho pra dar contexto imediato */
.picker-flow .near { color: var(--bone-soft); }

.picker-band {
  position: absolute; left: 0; right: 0; top: 50%;
  height: 1px; background: rgba(233, 227, 214, 0.10);
  transform: translateY(-50%);
}
/* ─── velocidade ────────────────────────────────────────────
   Sem botões no celular, arrastar o polegar pra cima acelera e pra baixo
   desacelera. O número aparece só durante o arrasto e some junto.        */

.speed-hud {
  position: absolute; z-index: 6;
  right: 8%; top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  pointer-events: none;
  animation: fade 0.14s var(--ease);
}
.speed-hud b {
  font-family: var(--font-mono); font-weight: 400;
  font-size: clamp(26px, 7vh, 44px);
  color: var(--focal); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.speed-hud span {
  color: var(--bone-dim);
  letter-spacing: 0.2em; text-transform: uppercase;
}

.picker-hint {
  position: absolute; bottom: 18px;
  color: var(--bone-dim);
  letter-spacing: 0.14em; text-transform: uppercase;
}

/* ─── rodapé do leitor ──────────────────────────────────── */

.reader-bottom { padding: 0 var(--pad) 18px; border-top: var(--hair); }

/* No celular não há botão nenhum: tudo é gesto no polegar. Some de vez, não
   por opacidade — elemento que não existe não tem como reaparecer. */
@media (pointer: coarse) { .reader-bottom { display: none; } }

.scrub {
  position: relative; height: 26px; margin: 0 calc(var(--pad) * -1);
  cursor: pointer; touch-action: none;
}
.scrub::before {
  content: ""; position: absolute; left: 0; right: 0; top: 12px;
  height: 2px; background: rgba(233,227,214,0.09);
}
.scrub-fill {
  position: absolute; left: 0; top: 12px; height: 2px; width: 0;
  background: var(--bone-soft);
  transition: width 0.15s linear;
}
.scrub-head {
  position: absolute; top: 8px; left: 0; width: 2px; height: 10px;
  background: var(--focal); transform: translateX(-1px);
  transition: left 0.15s linear;
}
.scrub:hover .scrub-head { height: 16px; top: 5px; }

.readout {
  display: flex; justify-content: space-between;
  color: var(--bone-dim); padding: 2px 0 14px;
}

.controls { display: flex; justify-content: center; align-items: center; gap: 8px; }

.ctl {
  min-width: 54px; height: 40px;
  background: none;
  border: var(--hair);
  color: var(--bone-soft);
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s, transform 0.12s;
}
.ctl:hover { color: var(--bone); border-color: rgba(233,227,214,0.32); }
.ctl:active { transform: scale(0.94); }
.ctl-main {
  min-width: 78px; height: 44px;
  color: var(--ink); background: var(--bone);
  border-color: var(--bone); font-size: 14px;
}
.ctl-main:hover { background: var(--focal); border-color: var(--focal); color: var(--ink); }

.hints {
  text-align: center; color: var(--bone-ghost);
  margin: 14px 0 0; font-size: 10px;
}
@media (max-width: 700px) { .hints { display: none; } }
/* girado, o leitor tem ~760px de largura e a dica de teclado voltaria a
   caber — mas continua sendo um aparelho sem teclado */
@media (pointer: coarse) { .hints { display: none; } }

/* ══════════════════ FOLHAS ══════════════════ */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 700;
  background: rgba(6,5,5,0.72);
  backdrop-filter: blur(3px);
  animation: fade 0.3s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 701;
  width: min(430px, 100vw);
  background: var(--ink-lift);
  border-left: var(--hair);
  padding: 28px 28px calc(28px + env(safe-area-inset-bottom));
  overflow-y: auto;
  animation: slide 0.42s var(--ease);
}
.sheet-wide { width: min(680px, 100vw); }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding-bottom: 18px; margin-bottom: 24px;
  border-bottom: var(--hair);
}
.sheet-head h2 {
  margin: 0; font-size: 20px; font-weight: 500;
  letter-spacing: 0.12em; text-transform: lowercase;
}

.field { margin-bottom: 26px; }
.field > label {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; margin-bottom: 10px;
  font-size: 14px; color: var(--bone);
}
.field-hint {
  margin: 8px 0 0; font-size: 12px; line-height: 1.55;
  color: var(--bone-dim);
}

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; background: rgba(233,227,214,0.16);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 3px; height: 18px; margin-top: -8px;
  background: var(--focal); border: none; border-radius: 0;
}
input[type="range"]::-moz-range-track { height: 2px; background: rgba(233,227,214,0.16); }
input[type="range"]::-moz-range-thumb { width: 3px; height: 18px; background: var(--focal); border: none; border-radius: 0; }

.check { display: flex !important; justify-content: flex-start !important; align-items: center; gap: 10px; cursor: pointer; }
.check input { accent-color: var(--focal); width: 15px; height: 15px; }

.segmented { display: flex; border: var(--hair); }
.segmented button {
  flex: 1; padding: 11px; background: none; border: none;
  color: var(--bone-dim); font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; cursor: pointer; transition: all 0.2s;
}
.segmented button + button { border-left: var(--hair); }
.segmented button[aria-checked="true"] { background: var(--bone); color: var(--ink); }

.text-input {
  width: 100%; padding: 12px;
  background: var(--ink); border: var(--hair);
  color: var(--bone); font-family: var(--font-mono); font-size: 13px;
  line-height: 1.6; resize: vertical;
}
.text-input:focus { outline: none; border-color: var(--focal); }

.solid-btn {
  width: 100%; padding: 14px;
  background: var(--bone); border: none; color: var(--ink);
  font-family: var(--font-mono); font-size: 12px;
  letter-spacing: 0.12em; text-transform: uppercase; cursor: pointer;
  transition: background 0.2s;
}
.solid-btn:hover { background: var(--focal); }

.sheet-foot { margin-top: 40px; padding-top: 18px; border-top: var(--hair); line-height: 1.8; }
.sheet-foot p { margin: 0; }

/* ─── aviso ─────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: 30px; z-index: 950;
  transform: translateX(-50%);
  padding: 12px 20px;
  background: var(--bone); color: var(--ink);
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.06em;
  animation: toastin 0.3s var(--ease);
  max-width: 90vw;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

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

/* ─── dentro do app de desktop ───────────────────────────────

   A janela do Electron não tem barra de título, pra o preto não ser cortado
   por uma faixa cinza. Em troca, estas faixas é que arrastam a janela — a
   propriedade é ignorada no navegador, então o arquivo continua servindo
   aos dois. O respiro extra no topo do leitor evita que os semáforos caiam
   por cima do "← estante". */

.em-app .masthead,
.em-app .reader-top { -webkit-app-region: drag; }

.em-app .masthead button,
.em-app .reader-top button,
.em-app .reader-top .mono { -webkit-app-region: no-drag; }

.em-app .reader-top { padding-top: 38px; }

/* ─── convite de instalação ─────────────────────────────────── */

.install-hint {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 940; max-width: 92vw;
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px 13px 20px;
  background: var(--ink-lift); border: 1px solid rgba(233,227,214,0.16);
  border-radius: 14px;
  font-size: 13px; color: var(--bone-soft);
  box-shadow: 0 18px 50px -20px rgba(0,0,0,0.8);
  animation: toastin 0.4s var(--ease);
  cursor: pointer;
}
.install-hint[data-mode="ios"] { cursor: default; }
.install-hint b { color: var(--bone); font-weight: 600; }
.install-x {
  background: none; border: none; color: var(--bone-ghost); cursor: pointer;
  font-size: 13px; padding: 4px; flex: none;
}
.install-x:hover { color: var(--focal); }

.account-msg { margin-top: 16px; }

/* ─── gate: leitura travada sem sessão ──────────────────────── */
body.gated #view-library,
body.gated #view-reader { filter: blur(8px); pointer-events: none; user-select: none; }
body.gated::before {
  content: ''; position: fixed; inset: 0; z-index: 690;
  background: rgba(12,11,10,0.6);
}
