:root { 
    --bg: #050505; 
    --primary: #ff0000; 
    --brand-blue: #1e90ff;   /* "SORA" do logo */
    --text: #ffffff; 
    --border: #222;
    --text-dim: #888;
    --transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    /* Áreas do notch e das barras do sistema (app instalado no celular) */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --nav-h: calc(70px + var(--safe-top));
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }
body { background: var(--bg); color: var(--text); overflow-x: hidden; -webkit-tap-highlight-color: rgba(255, 0, 0, 0.15); }
/* Sem atraso nem zoom de duplo toque em elementos clicáveis (a pinça para ampliar continua funcionando) */
button, a, input, .manga-card, .chapter-tile, .reader-stage { touch-action: manipulation; }

/* --- ANIMAÇÕES --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in { animation: fadeIn 0.8s ease; }
.manga-card { animation: fadeInUp 0.6s ease backwards; }

/* Delay para os cards aparecerem um por um */
.manga-card:nth-child(1) { animation-delay: 0.1s; }
.manga-card:nth-child(2) { animation-delay: 0.2s; }
.manga-card:nth-child(3) { animation-delay: 0.3s; }
.manga-card:nth-child(4) { animation-delay: 0.4s; }

/* --- NAVBAR --- */
.navbar { 
    display: flex; justify-content: space-between; align-items: center; 
    height: var(--nav-h); padding: var(--safe-top) max(5%, var(--safe-right)) 0 max(5%, var(--safe-left));
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 1000; 
    border-bottom: 1px solid var(--border); 
}
.logo { font-size: 24px; font-weight: 900; cursor: pointer; transition: var(--transition); flex-shrink: 0; }
.logo:hover { transform: scale(1.05); color: var(--brand-blue); }
.logo span { color: var(--brand-blue); }

.search-box { 
    display: flex; background: #151515; border: 1px solid var(--border); 
    padding: 8px 15px; border-radius: 8px; flex: 0 1 250px; min-width: 0; transition: var(--transition);
}
.search-box { position: relative; }
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 10px rgba(255,0,0,0.2); }

/* Pesquisas recentes (search-history.js) */
.search-history {
    position: absolute; top: calc(100% + 6px); right: -1px; width: max(calc(100% + 2px), 300px); z-index: 1100;
    background: #0d0d0d; border: 1px solid var(--border); border-radius: 10px; padding: 6px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.7); animation: fadeIn 0.15s ease;
}
.search-history[hidden] { display: none; }
.search-history-head {
    display: flex; justify-content: space-between; align-items: center; padding: 6px 8px;
    font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: 1px; font-weight: 700;
}
.search-history-head button { background: none; border: none; color: #888; font-size: 12px; cursor: pointer; text-transform: none; letter-spacing: 0; }
.search-history-head button:hover { color: var(--primary); }
.search-history-item {
    display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 6px; cursor: pointer;
    color: #ddd; font-size: 14px;
}
.search-history-item > i { color: #666; font-size: 12px; }
.search-history-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-history-item button { background: none; border: none; color: #666; cursor: pointer; padding: 4px 6px; border-radius: 4px; }
.search-history-item button:hover { color: #fff; background: #222; }
.search-history-item:hover, .search-history-item.active { background: #1a1a1a; color: #fff; }
.search-history-item.active > i { color: var(--brand-blue); }
.search-box input { background: transparent; border: none; color: #fff; outline: none; width: 100%; min-width: 0; font-size: 14px; }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-box button { background: transparent; border: none; color: #fff; cursor: pointer; }

/* --- USUÁRIO (NAVBAR) --- */
.nav-right { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex: 1; min-width: 0; margin-left: 12px; }
.btn-user {
    display: flex; align-items: center; gap: 8px; background: #151515; color: #fff;
    border: 1px solid var(--border); padding: 9px 14px; border-radius: 8px; cursor: pointer;
    font-weight: 700; font-size: 13px; transition: var(--transition); white-space: nowrap;
}
.btn-user:hover, .btn-user.logged { border-color: var(--primary); }
.btn-user.logged i { color: var(--primary); }

/* --- HERO --- */
.hero { 
    height: 450px; background: url('https://4kwallpapers.com/images/wallpapers/solo-leveling-game-3840x1080-17908.jpeg') center/cover; 
}
.hero-overlay { 
    height: 100%; background: linear-gradient(to right, #000 20%, transparent); 
    display: flex; align-items: center; padding: 0 5%; 
}
.hero-content { animation: fadeInUp 1s ease; }
.hero h1 { font-size: clamp(30px, 8vw, 60px); line-height: 0.9; }
.hero h1 span { color: var(--brand-blue); }

/* --- GÊNEROS E CABEÇALHO DA LISTA (genres.js / script.js) --- */
.genre-bar { padding: 30px 5% 0; }
.genre-bar[hidden] { display: none; }
.genre-bar h2 { font-size: 18px; margin-bottom: 12px; }
.genre-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.genre-chip {
    background: #111; color: #ccc; border: 1px solid var(--border); border-radius: 999px;
    padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: var(--transition);
}
.genre-chip:hover { border-color: #555; color: #fff; }
.genre-chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.list-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; padding: 30px 5% 15px; }
.list-count { color: #888; font-size: 14px; }
.list-head .btn-clear { margin-left: auto; align-self: center; }
.load-more { display: flex; justify-content: center; padding: 28px 5% 0; }
.load-more .btn-small { min-width: 200px; padding: 11px 18px; font-size: 13px; }

/* --- GRID --- */
.manga-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 25px; padding: 0 5%; }
.manga-card { cursor: pointer; transition: var(--transition); position: relative; }

.manga-card img { 
    width: 100%; border-radius: 12px; aspect-ratio: 2/3; object-fit: cover; 
    background: #111; transition: var(--transition);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.manga-card:hover { transform: translateY(-10px); }
.manga-card:hover img { box-shadow: 0 10px 20px rgba(255, 0, 0, 0.2); filter: brightness(1.1); }
.manga-card p { font-size: 12px; margin-top: 10px; text-align: center; color: #bbb; transition: var(--transition); }
.manga-card:hover p { color: #fff; }

/* --- PÁGINA DO MANGÁ --- */
.manga-detail { display: flex; gap: 20px; margin-top: 20px; flex-wrap: wrap; }
.manga-detail-cover { width: 180px; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px; align-self: flex-start; background: #111; }
.manga-detail-info { flex: 1; min-width: 250px; }

/* --- CAPÍTULOS --- */
.chapters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(75px, 1fr)); gap: 8px; margin-top: 20px; }
.chapter-tile {
    background: #111; padding: 10px; text-align: center; cursor: pointer;
    border-radius: 4px; font-weight: bold; border: 1px solid var(--border);
    color: var(--text); text-decoration: none; transition: var(--transition);
}
.chapter-tile:hover { border-color: var(--primary); }
.chapter-tile.external { color: #888; border-style: dashed; }
.chapter-tile.external i { font-size: 10px; }

/* Capítulo já lido */
.chapter-tile.read { color: #666; background: #0a0a0a; position: relative; }
.chapter-tile.read::after {
    content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900;
    position: absolute; top: 3px; right: 5px; font-size: 9px; color: var(--primary);
}

/* Capítulo começado e não terminado: barrinha embaixo com a parte já lida (--progress vem do profile.js) */
.chapter-tile.in-progress { position: relative; overflow: hidden; }
.chapter-tile.in-progress::before {
    content: ""; position: absolute; left: 0; bottom: 0; height: 3px;
    width: var(--progress, 0%); background: var(--primary);
}

/* --- AÇÕES DO MANGÁ (favoritar / bloquear) --- */
.manga-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 15px; }
.btn-action {
    background: #151515; color: #ddd; border: 1px solid var(--border); padding: 8px 16px;
    border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 13px; transition: var(--transition);
}
.btn-action:hover { border-color: var(--primary); color: #fff; }
.btn-action.active { border-color: var(--primary); color: var(--primary); background: rgba(255,0,0,0.08); }
.read-progress { color: #888; font-size: 13px; }
.read-progress i { color: var(--primary); }

/* --- STATUS (carregando / erro / vazio) --- */
.status-msg {
    grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center;
    gap: 15px; padding: 40px 0; color: #888; text-align: center;
}
.status-msg i { font-size: 24px; color: var(--primary); }

/* --- LEITOR --- */
.reader-header {
    padding: 10px max(5%, var(--safe-right)) 10px max(5%, var(--safe-left));
    background: #000; display: flex; align-items: center; gap: 20px;
    position: sticky; top: var(--nav-h); z-index: 900; border-bottom: 1px solid var(--border);
    transition: transform 0.25s ease;
}
/* Some ao rolar para baixo (reader.js) */
.reader-header.hidden { transform: translateY(-110%); }
#chapterTitle { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-back { background: #222; color: #fff; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; transition: 0.3s; }
.btn-back:hover { background: #333; }

.btn-red { 
    background: var(--primary); color: #fff; border: none; padding: 12px 30px; 
    border-radius: 8px; font-weight: 800; cursor: pointer; transition: var(--transition);
    box-shadow: 0 5px 15px rgba(255,0,0,0.3);
}
.btn-red:hover { transform: scale(1.05); filter: brightness(1.2); }

/* --- MODOS DE VISUALIZAÇÃO (reader.js) --- */
/* Altura útil: tela menos navbar (70px) e cabeçalho do leitor (~60px); nos paginados, menos o paginador também */
#pagesContainer { --reader-top: calc(var(--nav-h) + 60px); }

/* Vertical */
.reader-vertical img {
    width: 100%; max-width: 800px; display: block; margin: 0 auto;
    animation: fadeIn 1s ease; scroll-margin-top: var(--reader-top);
}
/* Até carregar, cada página reserva espaço. Sem isso, todas teriam altura zero, ficariam "na tela" ao mesmo
   tempo e o navegador baixaria o capítulo inteiro de uma vez, ignorando o loading="lazy". */
.reader-vertical img:not(.loaded) { min-height: 80vh; background: #0a0a0a; }
.reader-vertical.with-gap img { margin-bottom: 12px; }
/* 100dvh desconta a barra de endereço do navegador no celular; 100vh fica como reserva para navegadores antigos */
.reader-vertical.fit-height img {
    width: auto; max-width: 100%;
    max-height: calc(100vh - var(--reader-top)); max-height: calc(100dvh - var(--reader-top));
}
.reader-vertical.fit-original { overflow-x: auto; }
.reader-vertical.fit-original img { width: auto; max-width: none; }

/* Página por página e dupla */
.reader-stage {
    display: flex; justify-content: center; align-items: flex-start; gap: 4px;
    margin: 0 auto; cursor: pointer; user-select: none; -webkit-user-select: none;
}
.reader-stage img { display: block; min-width: 0; animation: fadeIn 0.3s ease; }
.reader-single .reader-stage img { width: 100%; max-width: 900px; }
.reader-double .reader-stage { max-width: 1400px; }
.reader-double .reader-stage img { width: 50%; }
.reader-single.fit-height .reader-stage img,
.reader-double.fit-height .reader-stage img {
    width: auto;
    max-height: calc(100vh - var(--reader-top) - 60px); max-height: calc(100dvh - var(--reader-top) - 60px);
}
.reader-single.fit-height .reader-stage img { max-width: 100%; }
.reader-double.fit-height .reader-stage img { max-width: 50%; }
.fit-original .reader-stage { overflow-x: auto; justify-content: safe center; }
.fit-original .reader-stage img { width: auto; max-width: none; flex-shrink: 0; }

.reader-pager {
    display: flex; align-items: center; justify-content: center; gap: 20px;
    padding: 12px; color: #bbb; font-size: 14px; font-weight: 600;
}
.btn-small:disabled { opacity: 0.4; cursor: default; }
.reader-end-screen {
    min-height: 50vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}
.reader-chapter-nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 15px; padding: 30px 16px; }

/* Botão e painel de visualização */
.btn-reader-settings {
    display: flex; align-items: center; gap: 8px; background: #151515; color: #ddd;
    border: 1px solid var(--border); padding: 9px 14px; border-radius: 8px; cursor: pointer;
    font-weight: 700; font-size: 13px; white-space: nowrap; transition: var(--transition);
}
.btn-reader-settings:hover, .btn-reader-settings.active { border-color: var(--primary); color: #fff; }
.btn-reader-settings.active i { color: var(--primary); }
.reader-settings {
    position: absolute; top: calc(100% + 8px); right: 5%; z-index: 950; width: min(360px, calc(100vw - 32px));
    flex-direction: column; gap: 16px; padding: 18px; background: #0d0d0d; border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 15px 40px rgba(0,0,0,0.7); animation: fadeIn 0.2s ease;
}
.setting-group { display: flex; flex-direction: column; gap: 8px; }
.setting-label { font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.segmented { display: flex; background: #151515; border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 3px; }
.segmented button {
    flex: 1; background: none; border: none; color: #999; padding: 8px 6px; border-radius: 6px;
    cursor: pointer; font-size: 12px; font-weight: 700; transition: var(--transition);
}
.segmented button:hover { color: #fff; }
.segmented button.active { background: var(--primary); color: #fff; }
.setting-hint { font-size: 12px; color: #888; line-height: 1.6; }
.setting-hint kbd {
    display: inline-block; min-width: 20px; padding: 0 5px; border: 1px solid #444; border-bottom-width: 2px;
    border-radius: 4px; background: #1a1a1a; color: #ddd; font-family: inherit; font-size: 11px; text-align: center;
}
/* Sem teclado (celular/tablet), a dica não faz sentido */
@media (pointer: coarse) { .setting-hint:has(kbd) { display: none; } }

/* Estilo Profissional do Botão LIMPAR */
.btn-clear {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: var(--transition); /* Usa a animação que já criamos */
}

.btn-clear:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(255, 0, 0, 0.05);
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.2);
    transform: translateY(-2px);
}

.btn-clear:active {
    transform: translateY(0);
}

/* --- CRÉDITOS --- */
.chapter-credits { color: #888; font-size: 13px; margin-top: 10px; }
.chapter-credits i { color: var(--primary); margin-right: 4px; }
.chapter-group { color: #888; font-size: 13px; }
.reader-end { max-width: 800px; margin: 30px auto 0; padding: 0 5%; text-align: center; color: #888; font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.reader-end strong { color: var(--text); }
.reader-end a, .footer-credits a { color: var(--primary); text-decoration: none; }
.footer-credits { font-size: 12px; color: #666; line-height: 1.6; margin-bottom: 15px; }

/* --- DOAÇÃO --- */
.btn-donate {
    background: transparent; color: var(--primary); border: 1px solid var(--primary);
    padding: 10px 24px; border-radius: 8px; font-weight: 800; cursor: pointer;
    letter-spacing: 1px; transition: var(--transition); margin-bottom: 25px;
}
.btn-donate:hover { background: var(--primary); color: #fff; box-shadow: 0 5px 15px rgba(255,0,0,0.3); }
.reader-end .btn-donate { margin-bottom: 0; }

.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 2000;
    display: flex; align-items: flex-start; justify-content: center; padding: 16px;
    padding: max(16px, var(--safe-top)) 16px max(16px, var(--safe-bottom));
    overflow-y: auto; overscroll-behavior: contain;   /* rola dentro da janela quando ela não cabe (celular deitado) */
    animation: fadeIn 0.3s ease;
}
.modal-box {
    position: relative; background: #0d0d0d; border: 1px solid var(--border); border-radius: 12px;
    padding: 30px; max-width: 420px; width: 100%; text-align: center; margin: auto 0;
    display: flex; flex-direction: column; gap: 18px; animation: fadeInUp 0.4s ease;
}
.modal-box h2 i { color: var(--primary); }
.modal-box p { color: #bbb; font-size: 14px; line-height: 1.6; }
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: none; color: #888; font-size: 26px; cursor: pointer; }
.modal-close:hover { color: #fff; }
.pix-box { background: #151515; border: 1px dashed #333; border-radius: 8px; padding: 15px; display: flex; flex-direction: column; gap: 6px; }
.pix-label { font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: 1px; }
.pix-box code { font-size: 16px; color: #fff; word-break: break-all; user-select: all; }
.pix-name { font-size: 12px; color: #888; }

/* --- LOGIN / CADASTRO --- */
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-top: 10px; }
.auth-tabs button {
    flex: 1; background: none; border: none; color: #888; padding: 12px; cursor: pointer;
    font-weight: 800; font-size: 14px; border-bottom: 2px solid transparent; transition: var(--transition);
}
.auth-tabs button.active { color: #fff; border-bottom-color: var(--primary); }
.auth-notice:empty, .form-error:empty { display: none; }
.auth-title:empty { display: none; }
.auth-title { font-size: 20px; margin-top: 10px; }
.auth-notice { color: #bbb; font-size: 13px; line-height: 1.5; }
.auth-notice.success { color: #4ade80; }
.link-button { background: none; border: none; color: #888; font-size: 13px; cursor: pointer; text-decoration: underline; }
.link-button:hover { color: #fff; }
.auth-hint { color: #666; font-size: 12px; }
.account-form { display: flex; flex-direction: column; gap: 12px; }
.account-form input {
    background: #151515; border: 1px solid var(--border); color: #fff; padding: 12px 14px;
    border-radius: 8px; font-size: 14px; outline: none; transition: var(--transition);
}
.account-form input:focus { border-color: var(--primary); }
.form-error { color: #ff6b6b; font-size: 13px; text-align: left; }
.form-error.success { color: #4ade80; }

/* --- IMPORTAR HISTÓRICO --- */
.import-list { list-style: none; text-align: left; display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.import-list li { display: flex; justify-content: space-between; gap: 10px; background: #151515; border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; font-size: 13px; }
.import-chapter { color: #888; white-space: nowrap; }

/* --- AVISOS (toast) --- */
.toast {
    position: fixed; bottom: calc(20px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); z-index: 3000;
    max-width: calc(100% - 32px); padding: 12px 20px; border-radius: 8px; font-size: 14px; font-weight: 600;
    background: #111; border: 1px solid #4ade80; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    animation: fadeInUp 0.3s ease;
}
.toast.error { border-color: var(--primary); }
.toast { align-items: center; gap: 14px; }
.toast-action {
    background: none; border: 1px solid #444; color: #fff; padding: 6px 12px; border-radius: 6px;
    font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap; min-height: 32px;
}
.toast-action:hover { border-color: var(--primary); }

/* --- PERFIL --- */
.profile-header { display: flex; align-items: center; gap: 20px; margin: 25px 0; }
.profile-header h1 { font-size: 28px; }
.profile-header p { color: #888; font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }
.profile-header > div:nth-child(2) { min-width: 0; flex: 1; }
.admin-link { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; align-self: center; }
.admin-link i { color: var(--brand-blue); }
.avatar {
    width: 72px; height: 72px; border-radius: 50%; background: var(--primary); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 900;
}
.verify-banner {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; padding: 12px 16px;
    background: rgba(255, 196, 0, 0.08); border: 1px solid rgba(255, 196, 0, 0.4); border-radius: 8px; font-size: 13px; color: #ddd;
}
.verify-banner i { color: #ffc400; }
.verify-banner span { flex: 1; min-width: 200px; line-height: 1.5; }
.profile-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 25px; overflow-x: auto; }
.profile-tabs button {
    background: none; border: none; color: #888; padding: 12px 16px; cursor: pointer; white-space: nowrap;
    font-weight: 700; font-size: 14px; border-bottom: 2px solid transparent; transition: var(--transition);
}
.profile-tabs button:hover { color: #fff; }
.profile-tabs button.active { color: #fff; border-bottom-color: var(--primary); }
.profile-tabs button.active i { color: var(--primary); }
.profile-grid { padding: 0; }

.card-remove {
    position: absolute; top: 8px; right: 8px; z-index: 10; width: 28px; height: 28px; border-radius: 50%;
    background: rgba(0,0,0,0.75); color: #fff; border: 1px solid #444; cursor: pointer; transition: var(--transition);
}
.card-remove:hover { background: var(--primary); border-color: var(--primary); }

.profile-row {
    display: flex; align-items: flex-start; gap: 15px; padding: 15px; margin-bottom: 10px;
    background: #0d0d0d; border: 1px solid var(--border); border-radius: 10px;
}
.profile-row > img { width: 60px; aspect-ratio: 2/3; object-fit: cover; border-radius: 6px; background: #111; flex-shrink: 0; }
.profile-row-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.profile-row-info span { color: #888; font-size: 13px; }
.profile-row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn-small {
    background: #1a1a1a; color: #ddd; border: 1px solid var(--border); padding: 7px 12px; border-radius: 6px;
    cursor: pointer; font-size: 12px; font-weight: 700; white-space: nowrap; transition: var(--transition);
}
.btn-small:hover { border-color: #555; color: #fff; }
.btn-small.danger { color: #ff6b6b; }
.btn-small.danger:hover { border-color: var(--primary); background: rgba(255,0,0,0.1); }
.read-chips { flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; background: #1a1a1a; border: 1px solid var(--border);
    border-radius: 20px; padding: 4px 6px 4px 12px; font-size: 12px;
}
.chip button { background: none; border: none; color: #888; cursor: pointer; font-size: 11px; padding: 2px 4px; }
.chip button:hover { color: var(--primary); }

.account-section { max-width: 480px; padding: 20px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.account-section p { color: #888; font-size: 13px; }
.account-section .btn-small { align-self: flex-start; }
.danger-zone h3 { color: #ff6b6b; }

/* --- FOOTER --- */
.main-footer {
    background: #000;
    border-top: 1px solid var(--border);
    padding: 60px 5% calc(30px + var(--safe-bottom));
    margin-top: 50px;
    text-align: center;
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
}

.footer-logo {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 15px;
}

.footer-logo span { color: var(--brand-blue); }

.footer-desc {
    color: #888;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 25px;
}

.footer-social {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 25px;
}

.footer-social a {
    color: #fff;
    font-size: 20px;
    transition: var(--transition);
}

.footer-social a:hover {
    color: var(--primary);
    transform: translateY(-3px);
}

.footer-links {
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 600;
}

.footer-links a {
    color: #bbb;
    text-decoration: none;
    margin: 0 5px;
    transition: 0.3s;
}

.footer-links a:hover { color: #fff; }

.copyright {
    font-size: 11px;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ===================== CELULAR E TABLET ===================== */

/* Tablet e celular: durante a leitura, a barra do site some e o cabeçalho do leitor vai para o topo */
@media (max-width: 1024px) {
    body.reading .navbar { display: none; }
    body.reading .reader-header { top: 0; padding-top: calc(10px + var(--safe-top)); }
    body.reading #pagesContainer { --reader-top: calc(60px + var(--safe-top)); }
}

/* Celular e tablet em pé */
@media (max-width: 768px) {
    .nav-right { gap: 8px; }
    .btn-user span { display: none; }
    .logo { font-size: 20px; }
    .hero { height: 250px; }
    /* Gêneros numa faixa que rola para o lado, sem quebrar em várias linhas */
    .genre-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -5%; padding: 0 5% 4px; }
    .genre-chips::-webkit-scrollbar { display: none; }
    .genre-chip { padding: 9px 14px; }
    .manga-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 15px; }

    /* Página do mangá: capa pequena ao lado do título e dos botões; capítulos na largura toda, logo abaixo */
    .manga-detail { display: grid; grid-template-columns: 110px 1fr; gap: 6px 16px; align-items: start; }
    .manga-detail-info { display: contents; }
    .manga-detail-cover { width: 110px; grid-row: 1 / span 3; }
    #currTitle { font-size: 22px; overflow-wrap: anywhere; }
    .manga-detail .manga-actions { margin-top: 4px; gap: 8px; }
    .manga-detail .chapter-credits { margin-top: 0; }
    .manga-detail .chapters-grid { grid-column: 1 / -1; margin-top: 14px; }

    .reader-header { gap: 10px; }
    .btn-back { padding: 10px 14px; }
    .btn-reader-settings span { display: none; }
    .reader-pager { gap: 10px; font-size: 13px; flex-wrap: wrap; }
    .reader-chapter-nav .btn-red { flex: 1 1 100%; }

    .profile-header { gap: 14px; }
    .profile-header h1 { font-size: 22px; }
    .avatar { width: 56px; height: 56px; font-size: 24px; }
    .profile-row { flex-wrap: wrap; }
    .profile-row-actions { width: 100%; justify-content: flex-start; }
    .modal-box { padding: 24px 18px; }
}

/* Celular: a lista de pesquisas ocupa a largura da tela, logo abaixo da barra (o campo de busca é estreito) */
@media (max-width: 600px) {
    .search-history { position: fixed; top: calc(var(--nav-h) - 4px); left: 16px; right: 16px; width: auto; }
    .search-history-item { min-height: 44px; }
    .search-history-item button { min-width: 36px; min-height: 36px; }
}

/* Celulares pequenos (até 380px de largura) */
@media (max-width: 380px) {
    .logo { font-size: 18px; }
    .search-box { padding-left: 10px; }
    .chapters-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
}

/* Telas de toque: alvos maiores para o dedo (mínimo ~40px) */
@media (pointer: coarse) {
    /* Campos com menos de 16px fazem o Safari do iPhone dar zoom ao tocar */
    .search-box input, .account-form input { font-size: 16px; }
    .search-box { padding: 0 0 0 14px; align-items: center; }
    .search-box input { padding: 10px 0; }
    .search-box button { min-width: 40px; height: 40px; }
    .btn-small, .btn-action, .segmented button { min-height: 40px; }
    .btn-small { padding: 9px 14px; }
    .chapter-tile { min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 4px; }
    .card-remove { width: 38px; height: 38px; }
    .chip { padding: 2px 2px 2px 12px; }
    .chip button { min-width: 34px; min-height: 32px; font-size: 13px; }
    .profile-tabs button { min-height: 44px; }
    .modal-close { width: 44px; height: 44px; top: 4px; right: 4px; }
    .link-button { padding: 10px; }
    .footer-social { gap: 28px; }
    .footer-social a { padding: 8px; }
}

/* Sem mouse, o efeito de passar o mouse "gruda" depois do toque: troca por um retorno visual no próprio toque */
@media (hover: none) {
    .manga-card:hover, .logo:hover, .btn-red:hover, .btn-clear:hover, .footer-social a:hover { transform: none; }
    .logo:hover { color: inherit; }
    .manga-card:hover img { box-shadow: 0 4px 10px rgba(0,0,0,0.3); filter: none; }
    .manga-card:active { transform: scale(0.97); }
    .btn-red:active, .btn-small:active, .btn-action:active, .chapter-tile:active { filter: brightness(1.3); }
}
