:root {
    --thumb-width: 220px;
    --thumb-ratio: 141.4%;
    --grid-gap: 20px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    padding: 60px 20px 20px;
    background-color: var(--bs-body-bg, #1a1a2e);
    color: var(--bs-body-color, #eee);
    margin: 0;
    transition: background-color 0.3s, color 0.3s;
}

main {
    margin: 0 auto;
}

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 15px 20px;
    background: var(--bs-card-bg, #16213e);
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s;
}

.nav>div {
    display: flex;
    align-items: center;
}

.nav button.btn {
    color: var(--bs-body-color, #eee);
    border: 1px solid var(--bs-body-color, #eee);
}

.nav button.btn:hover {
    background: var(--bs-primary, #e94560);
    border-color: var(--bs-primary, #e94560);
    color: #fff;
}

.nav a {
    text-decoration: none;
    color: var(--bs-primary, #e94560);
    font-weight: bold;
    font-size: 1.1em;
}

.nav a:hover {
    color: var(--bs-secondary, #ff6b6b);
}

.nav-logo {
    height: 30px;
    width: auto;
}

.nav-title {
    color: var(--bs-body-color, #eee);
    font-weight: bold;
    font-size: 1.2em;
    margin-left: 10px;
}

.hero-full {
    background: var(--bs-card-bg, #16213e);
    margin: -80px 0 30px -20px;
    width: calc(100% + 40px);
    min-height: 70vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.hero-full .hero-header {
    position: absolute;
    top: 90px;
    left: 90px;
    z-index: 10;
    text-align: center;
    background: var(--bs-card-bg, #16213e);
    padding: 30px 40px;
    border-radius: 12px;
    opacity: 0.95;
}

.hero-full .hero-header .hero-logo {
    max-width: 150px;
    margin-bottom: 10px;
}

.hero-full .hero-header h1 {
    font-size: 1.5em;
    margin: 0 0 5px;
    color: var(--bs-primary, #e94560);
}

.hero-full .hero-header .description {
    font-size: 0.9em;
    color: var(--bs-body-color, #eee);
    opacity: 0.8;
}

.hero-full .carousel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.hero-full .carousel-track {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.5s ease;
}

.hero-full .carousel-slide {
    min-width: 100%;
    height: 100%;
}

.hero-full .carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bs-card-bg, #16213e);
    border: none;
    color: var(--bs-primary, #e94560);
    font-size: 2em;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    opacity: 0.8;
    transition: opacity 0.3s;
    z-index: 20;
}

.carousel-nav:hover {
    opacity: 1;
}

.carousel-prev {
    left: 30px;
}

.carousel-next {
    right: 30px;
}

.carousel-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 20;
}

.carousel-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bs-body-color, #eee);
    opacity: 0.4;
    cursor: pointer;
    border: none;
}

.carousel-dot.active {
    opacity: 1;
    background: var(--bs-primary, #e94560);
}

h2 {
    background: var(--bs-body-bg, #16213e);
    padding: 15px 20px;
    border-radius: 8px;
    margin: 30px 0px 20px 0px !important;
    font-size: 1.4em;
    color: var(--bs-primary, #e94560);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: background-color 0.3s;
}

h2:first-of-type {
    margin-top: 0;
}

[data-theme="dark"] h2 {
    box-shadow: 0 2px 10px rgb(255, 255, 255, 0.05);
}

[data-theme="light"] h2 {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--grid-gap);
    align-items: flex-start;
}

.grid-item {
    width: var(--thumb-width);
    flex-shrink: 0;
}

.card {
    background: var(--bs-card-bg, #16213e);
    border-radius: 10px;
    text-align: center;
    word-wrap: break-word;
    overflow: hidden;
    transition: transform 0.3s ease, background-color 0.3s;
}

[data-theme="dark"] .card {
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .card {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.card:hover {
    transform: translateY(-5px);
}

.card a {
    display: block;
    padding: 15px;
    text-decoration: none;
    color: inherit;
}

.card .thumb-container {
    width: 100%;
    padding-bottom: var(--thumb-ratio);
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
    background: #0f1525;
}

.card .thumb-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card .title {
    font-size: 0.9em;
    color: var(--bs-body-color, #eee);
    min-height: 2.5em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reader {
    max-width: 1200px;
    margin: 0 auto;
}

.reader-page {
    margin-bottom: 30px;
    text-align: center;
}

.reader-page img {
    width: auto;
    max-height: calc(100vh - 60px);
    display: block;
    margin: 0 auto;
}

[data-reader="horizontal"] body {
    padding-left: 0px;
    padding-right: 0px;
}

[data-reader="horizontal"] .reader {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 0px;
    max-width: 100%;
    overflow-x: auto;
}

[data-reader="horizontal"] .reader-page {
    margin-bottom: 0;
    flex-shrink: 0;
}

[data-reader="horizontal"] .reader-page img {
    max-height: calc(100vh - 60px);
    width: auto;
}

@media (max-width: 768px) {
    #reader-toggle {
        display: none;
    }

    [data-reader] .reader {
        display: flex !important;
        flex-wrap: wrap !important;
        overflow-x: auto !important;
    }

    [data-reader] .reader-page {
        flex-shrink: inherit;
        margin-bottom: 0;
        margin-right: 5px;
    }

    [data-reader] .reader-page:last-child {
        margin-right: 0;
    }

    [data-reader] .reader-page img {
        width: 100%;
        max-height: none;
    }
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bs-body-bg, #1a1a2e);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--bs-card-bg, #333);
    border-top: 5px solid var(--bs-primary, #e94560);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

#loading-text {
    font-size: 1.2em;
    color: var(--bs-body-color, #ccc);
}

@media (max-width: 768px) {
    .hero-full .hero-header {
        top: 100px;
        left: 50%;
        transform: translateX(-50%);
    }

    .carousel-prev {
        left: 15px;
    }

    .carousel-next {
        right: 15px;
    }
}