:root {
    --bg-color: #fcfcfc;
    --card-bg: #ffffff;
    --text-color: #2b2b2b;
    --text-muted: #6e6e73;
    --primary-color: #0071e3;
    --primary-hover: #005bb5;
    --border-color: #e5e5ea;
    --accent-red: #ff3b30;
    --radius: 12px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
    --bg-color: #151517;
    --card-bg: #1c1c1e;
    --text-color: #f5f5f7;
    --text-muted: #86868b;
    --border-color: #2c2c2e;
    --primary-color: #0a84ff;
    --primary-hover: #0066cc;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    touch-action: pan-y;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    padding: 0 16px;
    box-sizing: border-box;
}

main {
    flex: 1 0 auto;
    animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.logo {
    font-weight: 700;
    font-size: 20px;
    text-decoration: none;
    color: var(--text-color);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 15px;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary-color);
}

.theme-toggle-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-color);
    padding: 4px;
    line-height: 1;
}

.home-banner {
    background: linear-gradient(135deg, var(--primary-color) 0%, #5856d6 100%);
    border-radius: var(--radius);
    padding: 40px 24px;
    color: #ffffff;
    margin-top: 20px;
    margin-bottom: 25px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.home-banner h2 {
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 800;
}

.home-banner p {
    margin: 0;
    font-size: 16px;
    opacity: 0.9;
}

.search-bar-container {
    margin: 20px 0;
    display: flex;
    gap: 12px;
}

.search-input-wrap {
    position: relative;
    flex-grow: 1;
}

.search-input {
    width: 100%;
    padding: 12px 20px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    background-color: var(--card-bg);
    color: var(--text-color);
    outline: none;
    box-sizing: border-box;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.filter-select {
    padding: 12px 20px;
    border-radius: 25px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: 14px;
    outline: none;
    cursor: pointer;
}

.categories-bar {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 5px 0 15px 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.categories-bar::-webkit-scrollbar {
    display: none;
}

.category-badge {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.category-badge.active, .category-badge:hover {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.books-grid-2col {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 10px;
    margin-bottom: 40px;
}

.books-slider-row {
    display: flex;
    overflow-x: auto;
    gap: 16px;
    padding-bottom: 15px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.books-slider-row::-webkit-scrollbar {
    display: none;
}

.books-slider-row .book-card {
    min-width: 145px;
    max-width: 145px;
    flex: 0 0 auto;
}

.category-suggestion-block {
    margin-bottom: 40px;
}

.category-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.category-block-header h2 {
    font-size: 20px;
    margin: 0;
    font-weight: 700;
}

.see-more-link {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 14px;
}

.book-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.book-cover-wrap {
    position: relative;
    width: 100%;
    padding-top: 135%;
    background-color: #eaeaea;
}

.book-cover-wrap img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.book-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.book-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: auto;
}

.book-details {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 30px;
    margin-bottom: 40px;
}

@media(min-width: 600px) {
    .book-details {
        flex-direction: row;
    }
}

.details-cover {
    width: 220px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
    margin: 0 auto;
}

.details-cover img {
    width: 100%;
    display: block;
}

.details-content {
    flex-grow: 1;
}

.details-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 10px 0;
}

.details-desc {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 24px;
    white-space: pre-line;
}

.chapters-list {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 40px;
}

.chapter-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    font-size: 15px;
}

.chapter-item:last-child {
    border-bottom: none;
}

.chapter-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: background 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    padding: 25px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    background-color: var(--card-bg);
}

.reader-immersive-body {
    background-color: #0d0d0d;
    color: #ffffff;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    touch-action: pan-y;
}

.reader-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.reader-mode-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    border-radius: 20px;
    padding: 6px 12px;
    display: flex;
    gap: 8px;
    border: 1px solid #3a3a3c;
}

.mode-btn {
    background: none;
    border: none;
    color: #8e8e93;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 12px;
}

.mode-btn.active {
    background-color: #ffffff;
    color: #000000;
}

.webtoon-view {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.webtoon-view img {
    width: 100%;
    display: block;
    height: auto;
    border: none;
}

.slider-view {
    display: none;
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.slider-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.slide-item {
    min-width: 100%;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.slide-ctrl-btn {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 15%;
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.2);
    font-size: 32px;
    transition: color 0.2s, background 0.2s;
}

.slide-ctrl-btn:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.03);
}

.prev-slide { left: 0; }
.next-slide { right: 0; }

.confirm-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.confirm-modal-box {
    background: var(--card-bg);
    color: var(--text-color);
    padding: 24px;
    border-radius: var(--radius);
    max-width: 320px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.confirm-modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
}

.confirm-modal-text {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.confirm-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-btn-yes {
    background: var(--accent-red);
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
}

.confirm-btn-no {
    background: var(--border-color);
    color: var(--text-color);
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
}

.about-wrap {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow-sm);
    margin-top: 30px;
    margin-bottom: 50px;
}

.social-links {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.social-icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 10px 18px;
    border-radius: 24px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}

.social-icon-btn:hover {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

.social-icon-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}