* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #151515;
    color: #ffffff;
}

header {
    background: #222222;
    padding: 12px 18px;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid #444444;
}

header h1 {
    display: inline-block;
    margin: 0;
    font-size: 24px;
}

button {
    background: #444444;
    color: white;
    border: 0;
    border-radius: 5px;
    padding: 9px 14px;
    font-size: 16px;
    margin-left: 15px;
}

main {
    padding: 15px;
}

#status {
    padding: 10px 0;
    color: #cccccc;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.card {
    background: #242424;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid #333333;
}

.card img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
    background: #333333;
}

.card-title {
    padding: 10px;
    font-size: 15px;
}

.book {
    padding: 15px;
    margin-bottom: 10px;
    background: #242424;
    border-radius: 6px;
}

.book-title {
    font-size: 18px;
    margin-bottom: 6px;
}

.book-info {
    color: #bbbbbb;
    font-size: 14px;
}

@media (max-width: 600px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card img {
        height: 230px;
    }
}

#loadMore {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 25px auto;
    padding: 14px;
    background: #444444;
    color: #ffffff;
    border: 1px solid #666666;
    border-radius: 6px;
    font-size: 18px;
}

#loadMore:disabled {
    opacity: 0.6;
}


/* =========================
   LEITOR DE QUADRINHOS
   ========================= */

#reader {
    margin: 0;
    padding: 0;
    width: 100%;
    background: #000000;
}

#readerHeader {
    position: sticky;
    top: 0;
    z-index: 100;

    display: flex;
    align-items: center;
    justify-content: space-between;

    width: 100%;

    padding: 8px 10px;

    background: rgba(20, 20, 20, 0.96);

    color: #ffffff;

    font-size: 15px;
}

#readerHeader button {
    margin: 0;
}

#readerPages {
    width: 100%;
    margin: 0;
    padding: 0;

    background: #000000;
}

.comicPage {
    display: block;

    width: 100%;
    height: auto;

    max-width: 100vw;
    max-height: 100vh;

    object-fit: contain;

    margin: 0 auto;
    padding: 0;

    border: 0;

    background: #000000;
}

#readerLoading {
    padding: 30px 10px;

    text-align: center;

    color: #ffffff;

    font-size: 16px;
}


/* iPad / tela touch */

@media (min-width: 601px) {

    #readerPages {
        width: 100%;
    }

    .comicPage {
        width: 100%;
        max-width: 100%;
    }
}


/* Remove margens quando estiver no leitor */

body.reader-mode {
    background: #000000;
}

body.reader-mode main {
    padding: 0;
}

/* =========================
   LEITOR - UMA PÁGINA
   POR VEZ
   ========================= */

#reader {
    position: fixed;
    inset: 0;

    z-index: 1000;

    margin: 0;
    padding: 0;

    background: #000000;

    display: flex;
    flex-direction: column;
}

#readerHeader {
    flex: 0 0 auto;

    height: 48px;

    display: flex;
    align-items: center;

    justify-content: space-between;

    padding: 6px 10px;

    background: rgba(20, 20, 20, 0.96);

    color: #ffffff;

    font-size: 14px;

    z-index: 10;
}

#readerHeader button {
    margin: 0;
    padding: 7px 10px;
}

.readerTitle {
    flex: 1;

    overflow: hidden;

    white-space: nowrap;

    text-overflow: ellipsis;

    margin: 0 10px;

    text-align: center;
}

#readerViewer {
    position: relative;

    flex: 1;

    width: 100%;

    overflow: hidden;

    display: flex;

    align-items: center;

    justify-content: center;

    background: #000000;

    touch-action: pan-y;

    user-select: none;

    -webkit-user-select: none;
}

#currentPage {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: contain;

    margin: 0;
    padding: 0;

    transition: opacity 0.12s ease;

    user-select: none;

    -webkit-user-select: none;

    -webkit-user-drag: none;
}

#readerLoading {
    position: absolute;

    left: 0;
    right: 0;

    bottom: 15px;

    text-align: center;

    color: #ffffff;

    font-size: 14px;

    pointer-events: none;
}


/*
 * No iPad em portrait:
 * a página usa toda a área disponível.
 */

@media (orientation: portrait) {

    #readerViewer {
        width: 100vw;
    }

    #currentPage {
        width: 100vw;
        height: 100%;
    }
}


/*
 * Remove completamente o comportamento
 * antigo de página empilhada.
 */

#readerPages {
    display: none !important;
}

.opdsNextButton {
    display: block;
    width: calc(100% - 32px);
    margin: 20px auto 30px auto;
    padding: 16px 20px;

    font-size: 18px;
    font-weight: bold;

    border: 0;
    border-radius: 10px;

    cursor: pointer;
}

.opdsNextButton:disabled {
    opacity: 0.6;
    cursor: default;
}
