/* Fanfics — estilo principal (mobile primeiro, sem build) */

:root {
    --bg: #faf9f7; --fg: #1c1917; --muted: #78716c; --card: #ffffff; --line: #e7e5e4;
    --accent: #6d28d9; --accent-soft: #ede9fe; --accent-fg: #ffffff;
    --ok: #15803d; --warn: #b45309; --danger: #dc2626;
    --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
    --tabbar: 64px;
    --reader-size: 19px; --reader-font: Georgia, 'Times New Roman', serif;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="sepia"]) {
        --bg: #161412; --fg: #f5f5f4; --muted: #a8a29e; --card: #221f1c; --line: #3a3532;
        --accent: #a78bfa; --accent-soft: #2e2445; --accent-fg: #1c1240;
        --logo-word: #f5f5f4;
    }
}
:root[data-theme="dark"] {
    --logo-word: #f5f5f4;
    --bg: #161412; --fg: #f5f5f4; --muted: #a8a29e; --card: #221f1c; --line: #3a3532;
    --accent: #a78bfa; --accent-soft: #2e2445; --accent-fg: #1c1240;
}
:root[data-theme="sepia"] {
    --bg: #f4ecd8; --fg: #3b2f20; --muted: #7a6a55; --card: #fbf5e6; --line: #e2d6b8;
    --accent: #8a4b14; --accent-soft: #efdfc0; --accent-fg: #fff;
}
:root[data-reader-font="sans"] { --reader-font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }

* { box-sizing: border-box; }
/* touch-action: manipulation desliga o zoom por toque duplo (o que ampliava a tela sem querer ao ler);
   overflow-x: clip impede que algo mais largo que a tela alargue a página (o que corta o texto e força zoom).
   clip (e não hidden) para não quebrar o position: sticky do topo e da barra do leitor. */
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
body { overflow-x: clip; }
body {
    margin: 0; background: var(--bg); color: var(--fg);
    font: 16px/1.6 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
}
@media (min-width: 768px) { body { padding-bottom: 0; } }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: .6em 0 .4em; }
h2 { font-size: 1.2rem; margin: 1.2em 0 .5em; }
:root { --page-max: 1280px; --gutter: clamp(16px, 3vw, 40px); }
main { margin: 0 auto; padding: 8px var(--gutter) 32px; }
main.narrow { max-width: calc(760px + 2 * var(--gutter)); }  /* leitura, formulários, configurações */
main.wide { max-width: calc(var(--page-max) + 2 * var(--gutter)); } /* listas de histórias */
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); font-size: 14px; }
.text-center { text-align: center; }
summary { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- topo ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: calc(var(--page-max) + 2 * var(--gutter)); margin: 0 auto; padding: 10px var(--gutter); display: flex; align-items: center; gap: 12px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; color: var(--fg); }
.logo svg { height: 32px; width: auto; display: block; }
.logo-word { fill: var(--logo-word, url(#logo-wg)); }
.logo:hover { text-decoration: none; }
.topnav { display: none; align-items: center; gap: 18px; }
.search-link { margin-left: auto; color: var(--fg); display: inline-flex; padding: 6px; }
.topnav a { color: var(--fg); font-weight: 500; }
@media (min-width: 768px) { .topnav { display: flex; } }

.menu { position: relative; }
.menu > summary { list-style: none; display: flex; align-items: center; gap: 6px; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--card);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; z-index: 30;
    /* nunca maior que o espaço entre o topo e a barra de baixo: o que sobrar rola dentro do menu */
    max-height: calc(100dvh - 80px - var(--tabbar) - env(safe-area-inset-bottom));
    overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
@media (min-width: 768px) { .menu-panel { max-height: calc(100dvh - 80px); } }
.menu-panel a, .menu-panel button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px;
    color: var(--fg); background: none; border: 0; font: inherit; cursor: pointer; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--accent-soft); text-decoration: none; }
.menu-panel hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--accent-soft);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent); }
.avatar-lg { width: 80px; height: 80px; font-size: 32px; }

/* ---------- barra inferior (celular) ---------- */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--tabbar) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line);
    display: grid; grid-template-columns: repeat(5, 1fr);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 11px; color: var(--muted); }
.tabbar a.active { color: var(--accent); font-weight: 600; }
.tabbar a:hover { text-decoration: none; }
.tabbar svg { width: 24px; height: 24px; }
@media (min-width: 768px) { .tabbar { display: none; } }

/* ---------- componentes ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.warning { border-left: 4px solid var(--warn); }
.flash { background: var(--accent-soft); border-color: transparent; }
label { display: block; margin: 14px 0 4px; font-weight: 500; }
input, select, textarea, .textarea {
    font: inherit; font-size: 16px; /* evita zoom no iOS */ padding: 11px 12px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--card); color: var(--fg); max-width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; vertical-align: -3px; accent-color: var(--accent); }
.textarea, textarea { width: 100%; }
button, a.button, summary.button, label.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
    font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
    background: var(--accent); color: var(--accent-fg); cursor: pointer;
}
a.button:hover { text-decoration: none; filter: brightness(1.05); }
button.secondary, a.button.secondary, summary.button.secondary, label.button.secondary { background: transparent; color: var(--fg); border-color: var(--line); }
button.danger { background: var(--danger); color: #fff; }
button.block, a.button.block { width: 100%; }
.actions { display: flex; gap: 12px 16px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; margin: 4px 8px 4px 0; font-weight: 400; }
.tag { display: inline-block; font-size: 13px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); margin: 2px; color: var(--fg); }
.tag-genre { background: var(--accent-soft); border-color: transparent; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); vertical-align: middle; white-space: nowrap; }
.badge-ok { border-color: var(--ok); color: var(--ok); }
.badge-warn { border-color: var(--warn); color: var(--warn); }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* rolagem horizontal de categorias */
.scroller { display: flex; gap: 8px; overflow-x: auto; padding: 4px var(--gutter) 8px; margin: 0 calc(-1 * var(--gutter)); scrollbar-width: none; }
@media (min-width: 1024px) { .scroller { flex-wrap: wrap; overflow: visible; margin: 0; padding: 4px 0 8px; } } /* computador: categorias em várias linhas, sem cortar */
.scroller::-webkit-scrollbar { display: none; }
.pill { flex: none; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--fg); font-size: 14px; white-space: nowrap; }
.pill.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.pill:hover { text-decoration: none; }

/* ---------- cards de história ---------- */
.story-card { display: flex; gap: 14px; padding: 12px; }
.story-card > a:first-child { flex: none; display: block; width: 76px; height: 108px; }
.story-card .cover { width: 76px; height: 108px; }
.story-card h3 { margin: 0 0 4px; font-size: 1.05rem; line-height: 1.3; }
.story-card h3 a { color: var(--fg); }
.story-card .synopsis { margin: 6px 0 0; font-size: 14px; color: var(--muted);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cover { border-radius: 8px; object-fit: cover; background: var(--accent-soft); display: flex; align-items: center; justify-content: center;
    font: 700 28px/1 Georgia, serif; color: #fff; overflow: hidden; }
.cover-lg { flex: none; width: 140px; height: 200px; font-size: 48px; }
img.cover { display: block; object-fit: cover; object-position: center top; }
.story-hero { display: flex; gap: 16px; align-items: flex-start; }
@media (max-width: 480px) { .story-hero { flex-direction: column; } .cover-lg { width: 120px; height: 172px; } }
.story-card > div { flex: 1; min-width: 0; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: 14px; }

.chapter-list a { display: flex; justify-content: space-between; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--fg); }
.chapter-list a:last-child { border-bottom: 0; }
.chapter-list a:hover { text-decoration: none; color: var(--accent); }
.chapter-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.chapter-row:last-child { border-bottom: 0; }
.row-actions { display: flex; gap: 4px; }
.row-actions button { min-height: 36px; padding: 4px 12px; }

/* ---------- leitor ---------- */
.reader { font-family: var(--reader-font); font-size: var(--reader-size); line-height: 1.8; overflow-wrap: break-word; }
.reader p { margin: 0 0 1em; }
/* conteúdo colado/importado (capítulos antigos) nunca passa da largura da tela */
.reader * { max-width: 100%; }
.reader img, .reader video, .reader iframe { height: auto; }
.reader table { display: block; overflow-x: auto; }
.reader pre { white-space: pre-wrap; }
.reader hr, .editor hr { border: 0; text-align: center; margin: 28px 0; }
.reader hr::after, .editor hr::after { content: '* * *'; color: var(--muted); letter-spacing: .3em; }
.progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--accent); z-index: 40; transition: width .1s; }
.reader-bar { position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 8px); display: flex; justify-content: space-between; gap: 8px; margin: 24px 0; }
@media (min-width: 768px) { .reader-bar { bottom: 16px; } }
.reader-bar a, .reader-bar button { flex: 1; }
.reader-settings { display: grid; gap: 12px; }
.reader-settings .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border-radius: 0; background: var(--card); color: var(--fg); min-height: 40px; padding: 6px 14px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }

/* ---------- editor ---------- */
.toolbar { display: flex; gap: 4px; margin: 16px 0 8px; position: sticky; top: 56px; background: var(--bg); padding: 6px 0; z-index: 5; overflow-x: auto; }
.toolbar button { background: var(--card); color: var(--fg); border: 1px solid var(--line); min-width: 44px; padding: 6px 10px; }
.editor { min-height: 60vh; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; outline: none; }
.editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.save-bar { position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); }
@media (min-width: 768px) { .save-bar { bottom: 0; } }

/* ---------- login social, anúncios, avisos ---------- */
/* Entrar / criar conta (cartão central, botões grandes no estilo dos apps) */
.auth { max-width: 420px; margin: 24px auto 32px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); }
.auth-head { text-align: center; margin-bottom: 20px; }
.auth-logo { display: inline-block; }
.auth-logo svg { height: 40px; width: auto; }
.auth-head h1 { font-size: 22px; margin: 14px 0 4px; }
.auth-head .muted { margin: 0; }
.auth-form label { margin-top: 12px; font-size: 14px; }
.auth-form input:not([type="checkbox"]) { width: 100%; }
.auth-form input:disabled { color: var(--muted); }
.auth-form button.block { margin-top: 18px; min-height: 48px; border-radius: 12px; }
.auth-form .hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.auth-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; }
.auth-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
@media (max-width: 420px) { .auth-pair { grid-template-columns: 1fr; } .auth { border: 0; box-shadow: none; padding: 20px 4px; margin-top: 8px; } }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin: 0; }
label.check.terms { margin-top: 16px; font-size: 14px; line-height: 1.45; }
.auth-note { color: var(--muted); font-size: 13px; text-align: center; margin: 20px 0 0; }
.auth-foot { text-align: center; margin: 14px 0 0; font-size: 15px; }
.auth-foot a { font-weight: 600; }

.social { display: flex; flex-direction: column; gap: 10px; }
.social-btn { position: relative; display: flex; align-items: center; justify-content: center; min-height: 50px; padding: 0 48px;
    border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font-weight: 600; cursor: pointer;
    transition: background .15s, border-color .15s; }
.social-btn:hover { text-decoration: none; border-color: color-mix(in srgb, var(--fg) 30%, var(--line)); background: color-mix(in srgb, var(--fg) 4%, var(--bg)); }
.social-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; }
.social-letter { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 4px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-email { margin-top: 10px; }
.auth-email > summary { list-style: none; }
.auth-email > summary::-webkit-details-marker { display: none; }
.auth-email[open] > summary { display: none; }
.ad { margin: 16px 0; min-height: 90px; text-align: center; }
.ad-label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.ad-placeholder { display: flex; flex-direction: column; justify-content: center; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: 14px; padding: 16px; }
.consent, .install-banner {
    position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px);
    max-width: 640px; margin: 0 auto; z-index: 50; box-shadow: 0 8px 30px rgba(0,0,0,.18);
}
@media (min-width: 768px) { .consent, .install-banner { bottom: 16px; } }
.install-banner { display: flex; align-items: center; gap: 12px; }
.install-banner img { width: 44px; height: 44px; border-radius: 10px; }
.install-banner[hidden] { display: none; }
.offline-badge { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--fg); color: var(--bg); padding: 4px 12px; border-radius: 99px; font-size: 13px; }
.offline-badge[hidden] { display: none; }

footer.site { max-width: calc(var(--page-max) + 2 * var(--gutter)); margin: 24px auto 0; padding: 16px var(--gutter); color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 8px 16px; }
footer.site .footer-social { display: inline-flex; gap: 12px; align-items: center; }
footer.site .footer-social a { display: inline-flex; color: var(--muted); }
footer.site .footer-social a:hover { color: var(--fg); }
footer.site .footer-social svg { width: 18px; height: 18px; }

/* paginação padrão do Laravel sem Tailwind */
nav[role="navigation"] { margin: 16px 0; }
nav[role="navigation"] svg { width: 18px; height: 18px; }
nav[role="navigation"] .hidden { display: none; }
nav[role="navigation"] > div:first-child { display: flex; justify-content: space-between; gap: 8px; }
@media (min-width: 640px) {
    nav[role="navigation"] > div:first-child { display: none; }
    nav[role="navigation"] > div:last-child { display: flex !important; justify-content: space-between; align-items: center; }
    nav[role="navigation"] span[aria-current] span, nav[role="navigation"] a { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; margin: 0 2px; }
    nav[role="navigation"] span[aria-current] span { background: var(--accent); color: var(--accent-fg); }
}

/* denúncia e moderação */
.report { margin: 16px 0; } .report summary { list-style: none; display: inline-block; }
.report summary::-webkit-details-marker { display: none; }
.mod-group { border-left: 4px solid var(--line); } .mod-group.auto { border-left-color: var(--warn); }
.mod-reports { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }

/* páginas legais */
.legal { line-height: 1.7; }
.legal h2 { margin-top: 1.6em; }
.legal table { width: 100%; border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; }
.legal th, .legal td { border: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
.legal th { background: var(--accent-soft); }

/* busca */
.search-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.search-form input[type="search"] { flex: 1; min-width: 0; }
.filters { width: 100%; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 4px 12px; }
.filters-grid label { margin: 8px 0 0; font-size: 14px; }
.filters-grid select { width: 100%; margin-top: 4px; }
a.tag:hover { text-decoration: none; border-color: var(--accent); }

/* comunidade */
.comments { margin-top: 32px; }
.comment { padding: 12px 0; border-bottom: 1px solid var(--line); }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.comment-head .avatar { width: 28px; height: 28px; font-size: 13px; }
.comment-body { margin: 6px 0; white-space: pre-line; overflow-wrap: break-word; }
.comment-actions { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; font-size: 14px; }
.comment-actions form { margin: 0; }
.comment-replies { margin-left: 24px; border-left: 2px solid var(--line); padding-left: 12px; }
.comment-replies .comment { border-bottom: 0; }
button.link { background: none; border: 0; padding: 0; min-height: 0; font-weight: 400; cursor: pointer; }
.bell { position: relative; }
.bell .dot { position: absolute; top: 0; right: -2px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; border-radius: 99px; padding: 1px 5px; line-height: 1.4; }
.notification { display: flex; gap: 10px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--fg); }
.notification.unread { font-weight: 600; }
.notification:hover { text-decoration: none; color: var(--accent); }

/* destaques e rankings */
.shelf { margin: 20px 0 8px; }
.shelf .page-head h2 { margin: 0; font-size: 1.15rem; }
.shelf-row { gap: 12px; align-items: flex-start; }
.shelf-item { flex: none; width: 112px; display: flex; flex-direction: column; gap: 4px; color: var(--fg); }
.shelf-item:hover { text-decoration: none; }
.shelf-item .cover { width: 112px; height: 160px; font-size: 2.2rem; }
.shelf-title { font-size: 14px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.shelf-meta { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-row { display: flex; gap: 10px; align-items: center; }
.rank-row > .story-card { flex: 1; min-width: 0; }
.rank-num { flex: none; width: 34px; text-align: center; font-size: 1.3rem; font-weight: 800; color: var(--muted); }
.rank-num.top { color: var(--accent); }
.rank-score { font-weight: 600; }

/* selo Premium */
.premium-badge { width: 1.05em; height: 1.05em; vertical-align: -0.15em; margin-right: .25em; flex: none; filter: drop-shadow(0 1px 1px rgba(120,80,0,.35)); }
h1 .premium-badge { width: .85em; height: .85em; }
.premium-name { white-space: nowrap; }

/* opções de leitura Premium */
@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 400; font-style: normal; font-display: swap; src: url(/fonts/atkinson-hyperlegible-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 400; font-style: italic; font-display: swap; src: url(/fonts/atkinson-hyperlegible-latin-400-italic.woff2) format('woff2'); }
@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 700; font-style: normal; font-display: swap; src: url(/fonts/atkinson-hyperlegible-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 700; font-style: italic; font-display: swap; src: url(/fonts/atkinson-hyperlegible-latin-700-italic.woff2) format('woff2'); }
:root[data-reader-font="legible"] { --reader-font: 'Atkinson Hyperlegible', system-ui, sans-serif; }
.reader { line-height: var(--reader-line, 1.8); }
:root[data-reader-line="relaxed"] { --reader-line: 2.1; }
:root[data-reader-line="loose"] { --reader-line: 2.4; }
:root[data-reader-width="narrow"] .reader { max-width: 34em; margin-left: auto; margin-right: auto; }
:root[data-theme="night"] {
    --bg: #000000; --fg: #d6d3d1; --muted: #8a8580; --card: #0f0f0f; --line: #262321;
    --accent: #a78bfa; --accent-soft: #1f1830; --accent-fg: #1c1240; --logo-word: #d6d3d1;
}
:root[data-theme="paper"] {
    --bg: #ecebe6; --fg: #2b2a27; --muted: #6f6c64; --card: #f6f5f1; --line: #d9d6cd;
    --accent: #5b4bb3; --accent-soft: #e4e0f2; --accent-fg: #fff;
}
.seg button[data-premium-opt]::after { content: '♛'; font-size: 10px; color: #d99a00; margin-left: 3px; vertical-align: super; }
.seg button[data-premium-opt]:disabled { opacity: .45; cursor: not-allowed; }
.seg { flex-wrap: wrap; }
.tts-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0 12px; }
.tts-bar select { min-height: 40px; max-width: 100%; }
.tts-bar select[data-tts-voice] { max-width: min(260px, 100%); }
.reader .tts-current { background: var(--accent-soft); border-radius: 6px; box-shadow: 0 0 0 6px var(--accent-soft); }
.badge-premium { background: #fdf3d0; color: #8a5a00; }
:root[data-theme="dark"] .badge-premium, :root[data-theme="night"] .badge-premium { background: #3a2c08; color: #f5c542; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat-grid .card { margin: 0; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-size: 1.6rem; font-weight: 800; }
.stat-chart { width: 100%; height: auto; display: block; }
.stat-chart .bar { fill: var(--accent); }
.stat-chart .axis { stroke: var(--line); }
.stat-chart .tick { fill: var(--muted); font-size: 11px; }
.stat-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stat-table th, .stat-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.stat-table td:nth-child(2) { white-space: normal; min-width: 140px; }
.meter { display: inline-block; width: 60px; height: 6px; background: var(--line); border-radius: 99px; vertical-align: middle; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); }
.premium-teaser { border: 1px solid #f0d27a; background: linear-gradient(180deg, rgba(253,230,138,.18), transparent); }
.list-card { display: flex; flex-direction: column; gap: 2px; color: var(--fg); }
.list-card:hover { text-decoration: none; border-color: var(--accent); }
.list-row form { margin: -6px 0 12px 4px; }
.add-to-list .menu-panel form { margin: 0; }
.list-toggle { width: 100%; text-align: left; background: none; color: var(--fg); border: 0; padding: 8px 6px; min-height: 0; font-weight: 400; }
.list-toggle:hover { background: var(--accent-soft); }
.new-list { display: flex; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); margin-top: 6px; }
.new-list input { flex: 1; min-width: 0; }
.check { display: flex; gap: 8px; align-items: center; margin: 10px 0; font-weight: 400; }

.premium-list { margin: 0; padding-left: 20px; }
.premium-list li { margin: 2px 0; }

/* "Adicionar a uma lista": painel mais largo e campo de nome em linha própria */
.add-to-list > summary.button { cursor: pointer; }
.add-to-list .menu-panel { left: 0; right: auto; min-width: 280px; max-width: calc(100vw - 32px); }
.add-to-list .new-list { display: grid; grid-template-columns: 1fr; gap: 8px; }
.add-to-list .new-list input[name="name"] { width: 100%; min-width: 0; min-height: 42px; padding: 8px 12px; }
.add-to-list .new-list button { width: 100%; text-align: center; background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.add-to-list .new-list button:hover { background: var(--accent); opacity: .9; }

.search-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.search-head h1 { margin: 0; font-size: 1.3rem; }
.close-search { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; color: var(--fg); border: 1px solid var(--line); background: var(--card); }
.close-search:hover { background: var(--accent-soft); text-decoration: none; }

.notification.announcement { background: linear-gradient(90deg, var(--accent-soft), transparent); border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.announcement-row { margin-bottom: 10px; }

/* recorte de imagem (public/js/image-crop.js): capa 7:10, foto de perfil quadrada e redonda */
.cover-crop { margin: 12px 0; }
.cover-crop-frame { position: relative; width: min(240px, 70vw); aspect-ratio: var(--crop-ratio, 7 / 10); overflow: hidden; border-radius: 8px;
    background: var(--accent-soft); cursor: grab; touch-action: none; user-select: none; box-shadow: 0 0 0 1px var(--line); }
.cover-crop-frame:active { cursor: grabbing; }
.cover-crop-frame img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; pointer-events: none; }
.cover-crop-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.cover-crop-zoom { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; }
.cover-crop-zoom input { width: 140px; }
.cover-crop.round .cover-crop-frame { border-radius: 50%; width: min(200px, 60vw); }
img.avatar { object-fit: cover; }
.avatar-lg { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; flex: none; background: var(--accent-soft); }

/* Página Premium */
.premium-page { max-width: 640px; margin: 0 auto; }
.premium-hero { text-align: center; margin: 16px 0 8px; }
.premium-hero h1 { margin: 6px 0 4px; }
.premium-crown { font-size: 34px; }
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
@media (max-width: 560px) { .plan-grid { grid-template-columns: 1fr; } }
.plan-option { margin: 0; cursor: pointer; }
.plan-option input { position: absolute; opacity: 0; pointer-events: none; }
.plan-box { position: relative; display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 16px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--bg); font-weight: 400; }
.plan-option input:checked + .plan-box { border-color: var(--accent); background: var(--accent-soft); }
.plan-option input:focus-visible + .plan-box { outline: 3px solid var(--accent); outline-offset: 2px; }
.plan-name { font-weight: 600; }
.plan-price { font-size: 24px; font-weight: 700; }
.plan-tag { position: absolute; top: -11px; right: 10px; background: var(--accent); color: var(--accent-fg); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
table.payments { width: 100%; border-collapse: collapse; font-size: 14px; }
table.payments th, table.payments td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
/* celular: cada pagamento vira um bloco de 2 linhas (data | situação / período | valor), sem passar da tela */
@media (max-width: 560px) {
    table.payments thead { display: none; }
    table.payments tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
    table.payments td { border: 0; padding: 0; }
    table.payments td:nth-child(1) { grid-area: 1 / 1; font-weight: 600; }
    table.payments td:nth-child(4) { grid-area: 1 / 2; text-align: right; }
    table.payments td:nth-child(2) { grid-area: 2 / 1; color: var(--muted); }
    table.payments td:nth-child(3) { grid-area: 2 / 2; text-align: right; white-space: nowrap; }
}
.payment-rejected { background: color-mix(in srgb, var(--danger) 12%, var(--card)); }
.premium-crown svg { width: 48px; height: 48px; }

/* Listas de histórias: 1 coluna no celular, 2 a 4 conforme a largura da tela */
.story-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 12px; margin: 12px 0; }
.story-grid > * { min-width: 0; }
.story-grid > .card, .story-grid .story-card { margin: 0; height: 100%; }
.story-grid > .ad, .story-grid > .card:not(.story-card):only-child, .story-grid > p:only-child { grid-column: 1 / -1; }
.story-grid .rank-row, .story-grid .list-row { height: 100%; }
.story-grid .rank-row > div > .story-card { height: auto; margin-bottom: 8px; }
/* Fileiras de destaque um pouco maiores em telas grandes */
@media (min-width: 1200px) {
    .shelf-item { width: 132px; }
    .shelf-item .cover { width: 132px; height: 188px; }
}

/* =====================================================================
   Layout das páginas no computador (18/11/2026)
   Páginas de conta, Premium, notificações, textos legais e página da história
   usam a largura do topo (alinhadas com o logo); só a leitura do capítulo
   e formulários longos ficam na coluna estreita, com o rodapé acompanhando.
   ===================================================================== */
footer.site.narrow { max-width: calc(760px + 2 * var(--gutter)); }
html { scroll-padding-top: 84px; } /* âncoras (#comment-12, #plan) não ficam escondidas atrás do topo fixo */
.card > :first-child, .card > h2:first-of-type { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
label.button { margin: 0; }
[hidden] { display: none !important; } /* botões com display próprio (ex.: "Parar" da leitura em voz alta) também somem */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.page-title { margin: 16px 0 4px; }
.page-sub { margin: 0 0 16px; }

/* menu lateral (Configurações, textos legais): pílulas roláveis no celular, coluna fixa no computador */
.side-layout { display: grid; gap: 4px 40px; align-items: start; }
.side-nav { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 4px var(--gutter) 8px; }
.side-nav::-webkit-scrollbar { display: none; }
.side-nav a { flex: none; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--fg); font-size: 14px; white-space: nowrap; }
.side-nav a:hover { text-decoration: none; }
.side-nav a.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.side-nav .side-nav-title { display: none; }
@media (min-width: 960px) {
    .side-layout { grid-template-columns: 220px minmax(0, 760px); }
    .side-nav { position: sticky; top: 84px; flex-direction: column; overflow: visible; margin: 12px 0 0; padding: 0; gap: 2px; }
    .side-nav a { border: 0; background: none; padding: 8px 12px; border-radius: 10px; color: var(--muted); font-size: 15px; white-space: normal; }
    .side-nav a:hover { background: var(--card); color: var(--fg); }
    .side-nav a.active { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
    .side-nav .side-nav-title { display: block; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 12px 6px; }
}
.side-main > .card:first-child, .side-main > section:first-child > .card:first-child { margin-top: 0; }
.side-main section { scroll-margin-top: 84px; }
.side-main h2 { font-size: 1.15rem; }

/* Configurações: foto com botões do próprio site e dados da conta em lista */
.avatar-edit { display: flex; align-items: center; gap: 16px 20px; flex-wrap: wrap; margin: 6px 0 4px; }
.avatar-edit img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; flex: none; background: var(--accent-soft); transition: opacity .2s; }
.avatar-edit .actions { gap: 8px; }
.avatar-edit:has(input[name="remove_avatar"]:checked) img { opacity: .3; filter: grayscale(1); }
label.button input[type="checkbox"] { margin: 0; }
.field-hint { margin: 4px 0 0; }
.info-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 0; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; overflow-wrap: anywhere; }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 20px; }

/* Premium: página mais larga, benefícios em grade com ícones */
.premium-page { max-width: 1040px; }
.benefits { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.benefit { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--accent-soft) 55%, transparent); line-height: 1.45; }
.benefit-icon { flex: none; width: 28px; font-size: 22px; line-height: 1.1; text-align: center; }
@media (min-width: 960px) { .premium-page .plan-box { padding: 20px; } .premium-page .plan-price { font-size: 1.6rem; } }

/* Notificações e listas simples: largura confortável, alinhadas com o logo */
.list-page { max-width: 860px; }
.empty-state { text-align: center; padding: 40px 16px 32px; }
.empty-state svg { width: 52px; height: 52px; color: var(--muted); }
.empty-state h2 { margin: 12px 0 6px; }
.empty-state p { color: var(--muted); max-width: 46ch; margin: 0 auto; }
.empty-state .actions { justify-content: center; margin-top: 20px; }
.notification > span:first-child { flex: none; width: 1.6em; text-align: center; }
.notification .muted { white-space: nowrap; }

/* Textos legais: índice da página */
.legal-tabs { margin: 12px 0 4px; }
.toc { margin: 0 0 8px; }
.toc > summary { font-weight: 600; }
.toc ol { list-style: none; margin: 8px 0 0; padding: 0; }
.toc li a { display: block; padding: 6px 0; color: var(--fg); font-size: 15px; line-height: 1.35; }
.toc li a:hover { color: var(--accent); text-decoration: none; }
@media (min-width: 960px) {
    .toc { position: sticky; top: 84px; margin-top: 16px; background: none; border: 0; box-shadow: none; padding: 0; max-height: calc(100vh - 110px); overflow-y: auto; }
    .toc > summary { list-style: none; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); pointer-events: none; }
    .toc > summary::-webkit-details-marker { display: none; }
    .toc li a { padding: 6px 12px; border-radius: 10px; color: var(--muted); }
    .toc li a:hover { background: var(--card); color: var(--fg); }
}
.legal { max-width: 72ch; }
.legal h2 { scroll-margin-top: 84px; }

/* Página da história */
.story-page .story-hero { margin-top: 16px; gap: 16px 28px; }
@media (min-width: 768px) { .story-page .cover-lg { width: 180px; height: 256px; font-size: 64px; } }
.story-byline { margin: 0; color: var(--muted); }
.story-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; }
.story-badges .badge { font-size: 13px; font-weight: 500; padding: 3px 10px; color: var(--fg); }
.story-badges a.badge:hover { text-decoration: none; border-color: var(--accent); }
.story-page .actions { margin-top: 16px; gap: 10px; }
.story-page .actions form { margin: 0; }
.story-layout { display: grid; gap: 8px 40px; align-items: start; margin-top: 20px; }
@media (min-width: 960px) { .story-layout { grid-template-columns: minmax(0, 1fr) 300px; } .story-aside { position: sticky; top: 84px; } }
.story-synopsis { white-space: pre-line; font-size: 17px; line-height: 1.65; margin: 0 0 8px; max-width: 72ch; }
.story-aside .card { margin-top: 0; }
.story-aside h2 { font-size: 1rem; margin: 0 0 10px; }
.story-aside .info-list { font-size: 15px; }
.story-aside .aside-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; }
.story-aside .aside-actions form { margin: 0; }
.chapter-list .chapter-num { display: inline-block; min-width: 2em; color: var(--muted); }
.chapter-list .chapter-words { white-space: nowrap; }

/* Leitura do capítulo: voltar, ouvir e "Aa" numa barra só */
.reader-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-top: 12px; }
.reader-head .back { color: var(--muted); font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.reader-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.reader-tools .tts-bar { margin: 0; }
.reader-tools .button, .reader-tools summary.button { min-height: 40px; padding: 8px 14px; }
.chapter-heading { margin: 18px 0 20px; }
.chapter-heading .muted { margin: 0; }
.chapter-heading h1 { margin: 2px 0 0; }

/* Comentário recém-publicado: aviso junto do comentário, com destaque que some sozinho */
.comment.just-posted { border-radius: 12px; margin: 4px -12px; padding: 12px; animation: just-posted 6s ease-out forwards; }
@keyframes just-posted { 0%, 50% { background: var(--accent-soft); } 100% { background: transparent; } }
.comment-notice { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--accent); }
.comments-flash { margin: 0 0 12px; }

/* Barra Anterior/Próximo do leitor: fica por cima do texto ao rolar, então os botões têm fundo próprio
   (antes o "Anterior" era transparente e o texto aparecia através dele) */
.reader-bar .button.secondary { background: var(--card); }
.reader-bar .button { box-shadow: 0 4px 14px rgba(0,0,0,.18); }

/* Leitura do capítulo em três colunas no computador (18/11/2026):
   capítulos à esquerda, texto no meio (linhas confortáveis) e Ouvir/Aa à direita,
   ocupando a mesma largura do topo. No celular e em telas menores, uma coluna só. */
.reading-toc { display: none; }
.reading-layout { max-width: 760px; margin: 0 auto; } /* tablet e notebook pequeno: coluna única de leitura */
@media (min-width: 1240px) {
    .reading-layout { max-width: none; display: grid; grid-template-columns: 240px minmax(0, 720px) 220px; justify-content: space-between; column-gap: 40px; align-items: start; }
    .reading-toc { display: flex; flex-direction: column; grid-column: 1; grid-row: 1; position: sticky; top: 84px; max-height: calc(100vh - 104px); margin-top: 16px; }
    .reading-main { grid-column: 2; grid-row: 1; min-width: 0; }
    .reader-head { grid-column: 3; grid-row: 1; position: sticky; top: 84px; margin-top: 16px; flex-direction: column; align-items: stretch; }
    .reader-head .back { display: none; }
    .reader-tools { flex-direction: column; align-items: stretch; margin-left: 0; }
    .reader-tools .tts-bar { flex-direction: column; align-items: stretch; }
    .reader-tools .button, .reader-tools button, .reader-tools summary.button, .reader-tools select { width: 100%; justify-content: center; }
    .reader-tools .menu-panel { right: 0; }
    .reader-tools .button, .reader-tools button { white-space: nowrap; padding-left: 10px; padding-right: 10px; }
    .reading-main .chapter-heading { margin-top: 16px; }
    .reading-main .reader-bar a, .reading-main .reader-bar button { max-width: none; }
}
.reading-story { display: flex; gap: 12px; align-items: center; color: var(--fg); margin-bottom: 18px; }
.reading-story:hover { text-decoration: none; }
.reading-story:hover strong { color: var(--accent); }
.reading-story .cover-sm { flex: none; width: 46px; height: 66px; font-size: 20px; border-radius: 6px; }
.reading-story > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; line-height: 1.3; }
.reading-story strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reading-toc .side-nav-title { display: block; margin: 0 0 6px; padding: 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.reading-chapters { list-style: none; margin: 0; padding: 0 4px 0 0; overflow-y: auto; min-height: 0; flex: 1; scrollbar-width: thin; }
.reading-chapters a { display: block; padding: 6px 10px; border-radius: 8px; color: var(--muted); font-size: 14px; line-height: 1.35; }
.reading-chapters a:hover { background: var(--card); color: var(--fg); text-decoration: none; }
.reading-chapters a.active { background: var(--accent-soft); color: var(--fg); font-weight: 600; }

/* app da Google Play: sem compra do Premium */
.only-in-app { display: none; }
html.in-app .only-in-app { display: block; }
html.in-app .hide-in-app { display: none !important; }

/* painel do administrador */
.admin-table td:nth-child(2) { min-width: 0; }
.admin-table th:not(:first-child), .admin-table td:not(:first-child) { text-align: right; }
.admin-table th.left, .admin-table td.left { text-align: left; }
.admin-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
