/* ─── Tokens ──────────────────────────────────────────────────────────────── */
/* Identidade AnestOpen: azul-marinho + laranja. Cada área do menu tem um tom próprio. */

:root {
  --navy: #0b2545;
  --orange: #f57c20;
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --surface-3: #e9edf3;
  --text: #0b2545;
  --muted: #5b6678;
  --border: #dfe4eb;
  --accent: #0b2545;
  --on-accent: #ffffff;
  --highlight: #f57c20;
  --tag-bg: #fef0e4;
  --tag-text: #b4530a;
  --user-bubble: #0b2545;
  --on-user-bubble: #ffffff;
  --ok: #15803d;
  --ok-soft: #e8f6ec;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  /* Tons das áreas: fundo do ícone / cor do ícone */
  --study-bg: #e7eefb;  --study: #1d4ed8;
  --review-bg: #e3f5ef; --review: #047857;
  --ia-bg: #fef0e4;     --ia: #c2410c;
  --account-bg: #eef0f4; --account: #475569;
  --radius: 16px;
  --shadow-sheet: 0 -10px 40px rgb(11 37 69 / .18);
  --shadow-card: 0 1px 2px rgb(11 37 69 / .06), 0 4px 16px rgb(11 37 69 / .06);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #071120;
    --surface: #0f1f36;
    --surface-2: #132742;
    --surface-3: #1a3253;
    --text: #e9eef5;
    --muted: #97a3b6;
    --border: #1f3350;
    --accent: #f7923f;
    --on-accent: #1a0d02;
    --tag-bg: #33220f;
    --tag-text: #f9a862;
    --user-bubble: #f7923f;
    --on-user-bubble: #1a0d02;
    --ok: #4ade80;
    --ok-soft: #12291a;
    --bad: #f87171;
    --bad-soft: #321616;
    --study-bg: #172a4d;  --study: #93b4ff;
    --review-bg: #10302a; --review: #5fd3a9;
    --ia-bg: #33220f;     --ia: #f9a862;
    --account-bg: #1a2a42; --account: #a9b6c8;
    --shadow-sheet: 0 -10px 40px rgb(0 0 0 / .5);
    --shadow-card: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }

.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface);
  font-weight: 600; padding: 10px 18px; border-radius: 999px; cursor: pointer;
}

.icon-btn {
  display: grid; place-items: center; flex: none;
  width: 42px; height: 42px; border: 0; border-radius: 50%; background: transparent; cursor: pointer; color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }

/* Tons por área (menu, atalhos, tela inicial, login) */
.tone-study { --t-bg: var(--study-bg); --t: var(--study); }
.tone-review { --t-bg: var(--review-bg); --t: var(--review); }
.tone-ia { --t-bg: var(--ia-bg); --t: var(--ia); }
.tone-account { --t-bg: var(--account-bg); --t: var(--account); }

/* ─── Página de entrada ───────────────────────────────────────────────────── */

.landing { min-height: 100dvh; display: flex; flex-direction: column; }
.landing-main {
  flex: 1; width: 100%; max-width: 1080px; margin: 0 auto;
  display: grid; gap: 40px; align-content: center;
  padding: calc(env(safe-area-inset-top) + 48px) 24px 32px;
}
@media (min-width: 900px) {
  .landing-main { grid-template-columns: 1.05fr .95fr; gap: 64px; align-items: center; }
}
.logo { display: inline-grid; grid-template-columns: auto auto; margin: 0; font-weight: 800; letter-spacing: -0.04em; line-height: .92; font-size: clamp(3.2rem, 15vw, 5.2rem); color: var(--text); }
.logo .l1 { display: flex; align-items: flex-start; }
.logo .l2 { grid-column: 1 / -1; display: flex; align-items: flex-end; gap: 14px; }
.logo .rule { flex: 1; height: 3px; background: var(--highlight); border-radius: 2px; margin-bottom: .5em; min-width: 40px; }
.logo .syringe { width: .32em; height: .62em; margin: .02em 0 0 .06em; }
.tagline { margin: 18px 0 10px; font-size: .78rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.landing .lead { max-width: 440px; margin: 0 0 28px; color: var(--muted); font-size: 1.05rem; }
.login-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; min-height: 44px; }
.login-msg { color: var(--muted); font-size: .85rem; margin: 12px 0 0; }

.features { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.feature {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-card);
}
.feature b { font-weight: 800; }
.feature small { display: block; color: var(--muted); font-size: .85rem; margin-top: 2px; line-height: 1.35; }
.feature-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--t-bg); color: var(--t); flex: none; }
.landing-foot { text-align: center; color: var(--muted); font-size: .78rem; padding: 16px 24px calc(env(safe-area-inset-bottom) + 20px); }

/* ─── Chat ────────────────────────────────────────────────────────────────── */

.chat { position: fixed; inset: 0; display: flex; flex-direction: column; }

.topbar {
  position: relative; flex: none; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 10px 8px 10px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.bot-id { display: flex; align-items: center; gap: 10px; min-width: 0; border: 0; background: none; padding: 4px 8px 4px 4px; border-radius: 12px; cursor: pointer; text-align: left; }
.bot-id:hover { background: var(--surface-2); }
.bot-avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; }
.brand { display: block; font-size: 1.05rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.status { display: block; font-size: .78rem; color: var(--muted); }
.status.busy { color: var(--highlight); }
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--tag-bg); color: var(--tag-text); font-weight: 700; overflow: hidden; }
.avatar-sm img { width: 100%; height: 100%; object-fit: cover; }

.popover {
  position: absolute; right: 10px; top: calc(100% - 4px); z-index: 20; min-width: 250px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 6px;
  box-shadow: 0 12px 32px rgb(0 0 0 / .16); animation: pop .16s var(--ease);
}
.popover button { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 9px; cursor: pointer; }
.popover button .ic { width: 19px; height: 19px; color: var(--muted); }
.popover button:hover, .popover-link:hover { background: var(--surface-2); }
.popover-link { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 9px; color: inherit; text-decoration: none; }
.popover-link .ic { width: 19px; height: 19px; color: var(--muted); }
.popover-info { padding: 8px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: .9rem; }
.popover-info b { display: block; }
.popover-info span { color: var(--muted); }

.messages {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 12px 8px; display: flex; flex-direction: column; gap: 6px;
}
.messages > * { max-width: 720px; width: 100%; margin-left: auto; margin-right: auto; }

.msg { display: flex; flex-direction: column; animation: rise .22s var(--ease) both; }
.msg.user { align-items: flex-end; }
.msg.bot { align-items: flex-start; }
.msg + .msg.user, .msg.user + .msg.bot { margin-top: 8px; }

.bubble {
  max-width: min(88%, 620px); padding: 9px 13px; border-radius: var(--radius);
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45;
}
.msg.bot .bubble { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 6px; }
.msg.user .bubble { background: var(--user-bubble); color: var(--on-user-bubble); border-top-right-radius: 6px; }
.msg.bot.question .bubble, .msg.bot.card .bubble { max-width: min(100%, 680px); }
.bubble b { font-weight: 700; }
.bubble a { color: var(--highlight); }
.bubble code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.bubble code.pix { display: block; padding: 8px 10px; word-break: break-all; user-select: all; }
.bubble .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
.bubble .meta, .bubble .qid { color: var(--muted); font-size: .8rem; }
.bubble img.qr { display: block; width: 220px; max-width: 100%; margin: 4px auto 10px; border-radius: 8px; background: #fff; padding: 8px; }
.time { font-size: .7rem; color: var(--muted); margin: 2px 6px 0; }

/* Botões das mensagens */
.kb { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-width: min(88%, 620px); width: 100%; }
.msg.question .kb, .msg.card .kb { max-width: min(100%, 680px); }
.kb-row { display: flex; gap: 6px; }
.kb-btn {
  flex: 1 1 0; min-width: 0; min-height: 40px; padding: 8px 12px; border-radius: 12px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: .9rem;
  text-align: center; overflow-wrap: anywhere; transition: border-color .15s, transform .1s, background .15s;
}
.kb-btn:hover:not(:disabled) { border-color: var(--highlight); }
.kb-btn:active:not(:disabled) { transform: scale(.98); }
.kb-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.kb-btn.liked { color: var(--bad); }
.kb-btn.danger { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.kb-btn:disabled { cursor: default; }
.kb-btn.loading { opacity: .6; }
.msg.question .kb-btn { text-align: left; font-weight: 500; line-height: 1.4; padding: 10px 14px; }
.kb-btn.correct { background: var(--ok-soft); border-color: var(--ok); color: var(--text); }
.kb-btn.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--text); }
.kb-btn.muted { opacity: .55; }

.typing .bubble { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

/* ─── Tela inicial (mensagem kind="home") ─────────────────────────────────── */

.msg.home { align-items: stretch; }
.home-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  padding: 20px 18px 16px; box-shadow: var(--shadow-card);
}
.home-head h2 { margin: 0; font-size: 1.45rem; letter-spacing: -0.02em; line-height: 1.2; }
.home-head p { margin: 4px 0 0; color: var(--muted); }
.home-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 18px 0 6px; }
@media (min-width: 560px) { .home-stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface-2); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.stat .ic { width: 18px; height: 18px; color: var(--highlight); margin-bottom: 4px; }
.stat b { font-size: 1.35rem; letter-spacing: -0.02em; line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--muted); }
.home-card h3 { margin: 18px 0 8px; font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.continue { display: grid; gap: 8px; }
.row-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px;
  transition: border-color .15s, transform .1s;
}
.row-btn:hover { border-color: var(--highlight); }
.row-btn:active { transform: scale(.99); }
.row-btn .txt { flex: 1; min-width: 0; }
.row-btn .txt b { display: block; font-size: .95rem; }
.row-btn .txt small { display: block; color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-btn > .ic:last-child { width: 18px; height: 18px; color: var(--muted); }
.tile-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--t-bg, var(--surface-2)); color: var(--t, var(--text)); flex: none; }
.home-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 560px) { .home-tiles { grid-template-columns: repeat(6, 1fr); } }
.home-foot { display: block; margin: 14px auto 0; border: 0; background: none; color: var(--muted); font-size: .82rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* Tile (usado na tela inicial e no menu) */
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px;
  min-width: 0; padding: 12px 6px 10px; border-radius: 16px; cursor: pointer; text-align: center;
  background: var(--surface); border: 1px solid var(--border); transition: border-color .15s, transform .1s, background .15s;
}
.tile:hover { border-color: var(--t, var(--highlight)); }
.tile:active { transform: scale(.97); }
.tile b { font-size: .84rem; font-weight: 700; line-height: 1.2; }
.tile small { font-size: .72rem; color: var(--muted); line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--highlight); color: #fff; font-size: .72rem; font-weight: 800; line-height: 1;
}
.tile .badge { position: absolute; top: 8px; right: 8px; }

/* ─── Barra de atalhos ────────────────────────────────────────────────────── */

.composer { flex: none; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.quickbar {
  display: flex; gap: 8px; overflow-x: auto; max-width: 744px; margin: 0 auto; padding: 8px 12px 0;
  scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent); mask-image: linear-gradient(90deg, #000 92%, transparent);
}
.quickbar::-webkit-scrollbar { display: none; }
.quickbar:empty { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px 0 10px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer;
  font-size: .86rem; font-weight: 600; white-space: nowrap; transition: border-color .15s, background .15s;
}
.chip .ic { width: 18px; height: 18px; color: var(--t, var(--muted)); }
.chip:hover { border-color: var(--t, var(--highlight)); }
.chip .badge { margin-left: 2px; }

.composer-row { display: flex; align-items: flex-end; gap: 6px; max-width: 744px; margin: 0 auto; padding: 8px 10px; }
.menu-btn { color: var(--text); }
#input {
  flex: 1; resize: none; max-height: 140px; min-height: 42px; padding: 10px 16px; border-radius: 21px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; line-height: 1.35;
}
#input:focus { outline: 2px solid color-mix(in srgb, var(--highlight) 50%, transparent); outline-offset: 0; }
.send-btn { width: 42px; height: 42px; flex: none; border: 0; border-radius: 50%; background: var(--highlight); color: #fff; cursor: pointer; display: grid; place-items: center; transition: transform .1s; }
.send-btn:active { transform: scale(.94); }
.send-btn .ic { width: 20px; height: 20px; }

/* Paleta de comandos ("/") */
.palette {
  flex: none; max-height: 40vh; overflow-y: auto; margin: 0 auto; width: 100%; max-width: 744px;
  background: var(--surface); border-top: 1px solid var(--border);
}
.palette button { display: flex; gap: 10px; width: 100%; padding: 9px 16px; border: 0; background: none; text-align: left; cursor: pointer; }
.palette button:hover, .palette button.sel { background: var(--surface-2); }
.palette .c { font-weight: 700; color: var(--highlight); flex: none; }
.palette .d { color: var(--muted); font-size: .9rem; }

/* ─── Menu em painel ──────────────────────────────────────────────────────── */

.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgb(7 17 32 / .45); animation: fade .2s ease both; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; margin: 0 auto; width: 100%; max-width: 640px;
  max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 24px 24px 0 0; box-shadow: var(--shadow-sheet);
  animation: sheet-in .28s var(--ease) both;
}
@media (min-width: 700px) {
  .sheet { bottom: 50%; transform: translateY(50%); border-radius: 24px; max-height: 84dvh; animation: sheet-pop .2s var(--ease) both; }
}
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 8px auto 0; flex: none; }
@media (min-width: 700px) { .sheet-handle { display: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px 2px 20px; flex: none; }
.sheet-head h2 { margin: 0; font-size: 1.15rem; letter-spacing: -0.01em; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px calc(env(safe-area-inset-bottom) + 20px); }

.sheet-filter {
  display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; padding: 10px 12px;
  background: var(--tag-bg); color: var(--tag-text); border-radius: 14px; font-size: .88rem;
}
.sheet-filter .ic { width: 18px; height: 18px; }
.sheet-filter span { flex: 1; min-width: 0; }
.sheet-filter span b { display: block; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.sheet-filter button { border: 0; background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: .8rem; font-weight: 700; cursor: pointer; }

.sheet-section h3 { margin: 18px 4px 8px; font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 460px) { .sheet-grid { grid-template-columns: repeat(4, 1fr); } }

.toggles { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.toggle {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; background: none; text-align: left; cursor: pointer;
}
.toggle + .toggle { border-top: 1px solid var(--border); }
.toggle .txt { flex: 1; }
.toggle .txt b { display: block; font-size: .92rem; font-weight: 600; }
.toggle .txt small { display: block; color: var(--muted); font-size: .8rem; }
.switch { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3); transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .2s var(--ease); }
.toggle[aria-checked="true"] .switch { background: var(--highlight); }
.toggle[aria-checked="true"] .switch::after { transform: translateX(18px); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(120px + env(safe-area-inset-bottom));
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-size: .88rem; font-weight: 600; z-index: 50;
  animation: rise .2s var(--ease) both; box-shadow: 0 8px 24px rgb(0 0 0 / .2);
}

/* ─── Animações ───────────────────────────────────────────────────────────── */

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes sheet-pop { from { opacity: 0; transform: translateY(50%) scale(.97); } to { opacity: 1; transform: translateY(50%); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ─── Leitor do livro ─────────────────────────────────────────────────────── */

.reader { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--surface); }
.reader-bar {
  flex: none; display: flex; align-items: center; gap: 2px;
  padding: calc(env(safe-area-inset-top) + 6px) 6px 6px; border-bottom: 1px solid var(--border);
}
.reader-title { flex: 1; min-width: 0; font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.icon-btn.txt { font-weight: 700; font-size: .85rem; width: 36px; }
.reader-jumps { flex: none; display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.reader-jumps button {
  flex: none; border: 1px solid var(--border); background: var(--surface-2); border-radius: 99px;
  padding: 5px 12px; font-size: .82rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.reader-jumps button.hot { border-color: var(--highlight); color: var(--tag-text); background: var(--tag-bg); }
.reader-jumps select { flex: none; max-width: 46vw; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 99px; padding: 4px 10px; font: inherit; font-size: .82rem; }

.reader-body {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 20px calc(env(safe-area-inset-bottom) + 32px);
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  font-size: var(--reader-size, 18px); line-height: 1.6;
}
.reader-body > * { max-width: 680px; margin-left: auto; margin-right: auto; }
.reader-body .chap-kicker { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: .75em; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--highlight); margin-top: 8px; }
.reader-body h1 { font-size: 1.6em; line-height: 1.2; margin: 6px auto 18px; letter-spacing: -0.01em; }
.reader-body h2 { font-size: 1.2em; margin: 1.6em auto .5em; padding-top: .6em; border-top: 1px solid var(--border); scroll-margin-top: 12px; }
.reader-body h3 { font-size: 1.05em; margin: 1.2em auto .4em; scroll-margin-top: 12px; }
.reader-body p { margin: 0 auto .8em; }
.reader-body p.box { border-left: 3px solid var(--highlight); background: var(--surface-2); padding: 8px 12px; border-radius: 0 8px 8px 0; }
.reader-body ul, .reader-body ol { padding-left: 1.4em; margin: 0 auto .9em; }
.reader-body li { margin: .25em 0; }
.reader-body li > ul, .reader-body li > ol { margin: .3em 0; }
.reader-body .flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--tag-bg); } to { background: transparent; } }
.reader-nav { display: flex; gap: 8px; margin-top: 32px !important; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.reader-nav button { flex: 1; min-width: 0; text-align: left; border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; cursor: pointer; font-size: .85rem; }
.reader-nav button.next { text-align: right; }
.reader-nav small { display: block; color: var(--muted); font-size: .75rem; }

/* Índice */
.book-cover { text-align: left; margin-bottom: 18px !important; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.book-cover h1 { margin: 0; font-size: 1.5em; font-family: "Iowan Old Style", Georgia, serif; }
.book-cover .sub { color: var(--highlight); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; font-size: .78em; margin-top: 4px; }
.book-cover .by { color: var(--muted); font-size: .9em; margin-top: 6px; }
.book-search { display: flex; gap: 6px; margin-bottom: 16px !important; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.book-search input { flex: 1; min-width: 0; padding: 10px 14px; border-radius: 21px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: .95rem; }
.toc { list-style: none; padding: 0 !important; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: .95rem; }
.toc li { margin: 0; }
.toc button { display: flex; gap: 10px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); background: none; padding: 11px 4px; cursor: pointer; align-items: baseline; }
.toc button:hover { background: var(--surface-2); }
.toc .n { flex: none; width: 2.2em; color: var(--highlight); font-weight: 800; }
.toc .continue { background: var(--tag-bg); border-radius: 10px; border: 0; margin-bottom: 8px; padding: 12px; font-weight: 600; }
.search-hit { display: block; width: 100%; text-align: left; border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: .9rem; }
.search-hit small { display: block; color: var(--muted); margin-top: 3px; }

/* ─── Páginas legais (/privacidade, /termos) ──────────────────────────────── */

body.legal-page { height: auto; min-height: 100%; overscroll-behavior: auto; }
.legal-top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 20px 10px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.legal-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.legal-brand img { border-radius: 50%; }
.legal-top nav a { color: var(--muted); font-size: .9rem; text-decoration: none; }
.legal-top nav a:hover { color: var(--text); text-decoration: underline; }
.legal { max-width: 760px; margin: 0 auto; padding: 32px 20px 48px; line-height: 1.65; }
.legal-kicker { margin: 0; font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--highlight); }
.legal h1 { margin: 6px 0 4px; font-size: clamp(1.8rem, 6vw, 2.4rem); letter-spacing: -0.03em; line-height: 1.15; }
.legal-meta { margin: 0 0 20px; color: var(--muted); font-size: .9rem; }
.legal-lead { font-size: 1.05rem; }
.legal h2 { margin: 36px 0 10px; font-size: 1.25rem; letter-spacing: -0.01em; scroll-margin-top: 72px; }
.legal h3 { margin: 20px 0 6px; font-size: 1.02rem; }
.legal section { scroll-margin-top: 72px; }
.legal a { color: var(--study); }
.legal ul { padding-left: 1.3em; }
.legal li { margin: .35em 0; }
.legal-toc { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 18px; margin: 24px 0 8px; }
.legal-toc ol { margin: 8px 0 0; padding-left: 1.4em; columns: 2 220px; column-gap: 24px; }
.legal-toc li { margin: .2em 0; break-inside: avoid; }
.legal-callout { background: var(--tag-bg); border-left: 4px solid var(--highlight); border-radius: 0 12px 12px 0; padding: 12px 16px; }
.legal-table { width: 100%; border-collapse: collapse; font-size: .9rem; margin: 8px 0 12px; display: block; overflow-x: auto; }
.legal-table th, .legal-table td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.legal-table th { background: var(--surface-2); font-weight: 700; white-space: nowrap; }
.legal-foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 20px 20px calc(env(safe-area-inset-bottom) + 28px); border-top: 1px solid var(--border); }
.legal-foot a, .landing-foot a { color: inherit; }
@media (max-width: 600px) {
  .legal-table, .legal-table tbody, .legal-table tr, .legal-table td { display: block; width: 100%; }
  .legal-table thead { display: none; }
  .legal-table tr { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 6px 4px; margin-bottom: 10px; }
  .legal-table td { border: 0; padding: 4px 10px; }
  .legal-table td::before { content: attr(data-label); display: block; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
}
