/* --- Vyreleaf Premium Styling System --- */

:root {
    --bg-main: #050505;
    --bg-card: #101010;
    --bg-ad: #0c0c0d;
    --bg-modal: rgba(20, 20, 22, 0.95);
    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    --text-muted: #55555a;
    --color-accent: #ff3b30;
    --color-accent-hover: #e02d22;
    --color-accent-glow: rgba(255, 59, 48, 0.35);
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-serif: 'Lora', 'KoPub Batang', 'Noto Serif KR', Georgia, serif;
    
    --border-color: #161618;
    --border-light: #2c2c2e;
    
    /* Reader options */
    --reader-font-size: 18px;
    --reader-line-height: 1.8;
    --reader-width: 800px;
    --reader-paragraph-margin: 20px;
    --reader-text-align: left;
    --reader-paragraph-indent: 0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    overflow-x: hidden;
    line-height: 1.5;
}

/* Hide helper class */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* --- 1. Reserved Ad Zone Layout --- */
.top-ad-zone {
    width: 100%;
    height: 90px;
    background-color: var(--bg-ad);
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 2px;
    overflow: hidden;
}

.left-ad-zone {
    width: 160px;
    height: 600px;
    background-color: var(--bg-ad);
    position: sticky;
    top: 130px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
    font-size: 11px;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
    overflow: hidden;
}

/* --- 2. Header and Navigation --- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background-color: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(15px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-primary);
    text-decoration: none;
}

.logo span {
    color: var(--color-accent);
    text-shadow: 0 0 10px var(--color-accent-glow);
}

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

.nav-item {
    color: var(--text-secondary);
    text-decoration: none;
    margin-left: 30px;
    font-size: 14px;
    font-weight: 600;
    transition: color 0.25s, text-shadow 0.25s;
}

.nav-item:hover, .nav-item.active {
    color: var(--text-primary);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.nav-item.active {
    border-bottom: 2px solid var(--color-accent);
    padding-bottom: 4px;
}

/* --- 3. Main Container Layout --- */
.main-container {
    display: flex;
    max-width: 1600px;
    margin: 0 auto;
    padding: 40px 20px;
    gap: 40px;
}

.content-zone {
    flex-grow: 1;
    min-width: 0; /* flexbox text wrap fix */
}

.section-title {
    font-family: var(--font-serif);
    font-size: 32px;
    margin-bottom: 24px;
    font-weight: 400;
    letter-spacing: -0.5px;
    border-left: 3px solid var(--color-accent);
    padding-left: 14px;
}

/* --- 4. Library Page CSS --- */
.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.library-header .section-title {
    margin-bottom: 0;
}

.search-box input {
    background-color: #121214;
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 24px;
    font-size: 14px;
    width: 260px;
    outline: none;
    transition: all 0.3s;
}

.search-box input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 8px var(--color-accent-glow);
    width: 320px;
}

.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.filter-btn {
    background: #111113;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-light);
}

.filter-btn.active {
    background: var(--color-accent);
    color: var(--text-primary);
    border-color: var(--color-accent);
    box-shadow: 0 0 10px var(--color-accent-glow);
}

/* Novel Grid & Cards */
.novel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 36px;
}

.novel-card {
    background-color: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow 0.3s, border-color 0.3s;
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.novel-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.8), 0 0 1px var(--color-accent);
    border-color: var(--border-light);
}

.novel-cover {
    width: 100%;
    height: 330px;
    background: linear-gradient(135deg, #18181c, #26262b);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    position: relative;
    box-shadow: inset 0 -30px 60px rgba(0,0,0,0.6);
    flex-shrink: 0;
}

.adult-cover-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 28px;
    padding: 0 8px;
    border: 1px solid rgba(255,255,255,0.82);
    border-radius: 5px;
    background: var(--color-accent);
    box-shadow: 0 6px 14px rgba(0,0,0,0.45);
    color: #ffffff;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0;
    pointer-events: none;
}

.novel-cover.has-cover-image,
.detail-cover.has-cover-image,
.update-cover-mini.has-cover-image {
    background-color: #090606;
}

.novel-cover-typography {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    padding: 20px;
    color: #eaeaea;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.novel-info {
    padding: 18px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 236px;
}

.novel-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.novel-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 24px;
    margin-bottom: 12px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
}

.novel-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
    background-color: #151519;
    color: var(--text-secondary);
}

.novel-status-badge svg {
    width: 13px;
    height: 13px;
}

.novel-status-badge path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.novel-status-badge.completed {
    border-color: rgba(201, 155, 85, 0.34);
    color: #d7b775;
}

.novel-status-badge.ongoing {
    border-color: rgba(255, 59, 48, 0.32);
    color: #ff8a83;
}

.chapter-count {
    white-space: nowrap;
}

.novel-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    min-height: 54px;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.novel-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: auto;
}

.tag {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    background: #17171a;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* --- 7. Modals Design (Glassmorphism & Neon) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-box {
    background-color: var(--bg-modal);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    position: relative;
    box-shadow: 0 24px 50px rgba(0,0,0,0.9), 0 0 1px var(--color-accent);
    overflow-y: auto;
}

.modal-box.compact {
    max-width: 500px;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    z-index: 10;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-content {
    padding: 40px;
}

.detail-top {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
}

.detail-cover {
    width: 220px;
    height: 300px;
    background: linear-gradient(135deg, #1c1c22, #2d2d35);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 1px solid var(--border-light);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    flex-shrink: 0;
}

.detail-cover-typography {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    padding: 16px;
    color: #e2e2e2;
}

.detail-meta {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.detail-title {
    font-family: var(--font-serif);
    font-size: 32px;
    font-weight: 400;
    margin-bottom: 12px;
    line-height: 1.2;
}

.detail-tags {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.detail-stats {
    display: flex;
    gap: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.detail-synopsis {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: auto;
}

.detail-action-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.action-btn {
    background-color: #1c1c1f;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    display: inline-block;
}

.action-btn:hover {
    border-color: var(--text-primary);
}

.action-btn.primary {
    background-color: var(--color-accent);
    color: var(--text-primary);
    border-color: var(--color-accent);
}

.action-btn.primary:hover {
    background-color: var(--color-accent-hover);
    box-shadow: 0 0 12px var(--color-accent-glow);
}

.action-btn.danger {
    background-color: #3b0e0c;
    border-color: #a31d1d;
    color: #ff8c8c;
}
.action-btn.danger:hover {
    background-color: #7a1515;
}

.detail-chapters-section {
    border-top: 1px solid var(--border-color);
    padding-top: 30px;
}

.chapters-header-title {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 400;
    margin-bottom: 16px;
}

.chapters-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 6px;
}

.chapter-btn-item {
    background-color: #121214;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 14px 20px;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    width: 100%;
}

.chapter-btn-item:hover {
    background-color: rgba(255, 59, 48, 0.05);
    border-color: var(--color-accent);
    color: var(--text-primary);
}

.chapter-btn-item .chap-number {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-accent);
    text-transform: uppercase;
}

/* --- 8. Immersive Reader View Overlay --- */
.reader-overlay {
    --reader-footer-height: 44px;
    --reader-controls-height: 52px;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #060607;
    z-index: 900;
    display: flex;
    flex-direction: column;
}

.reader-header {
    height: 70px;
    background-color: rgba(10, 10, 10, 0.95);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 910;
    flex-shrink: 0;
}

.reader-back-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s;
}

.reader-back-btn:hover {
    color: var(--text-primary);
}

.reader-back-btn .arrow {
    font-size: 18px;
}

.reader-titles {
    text-align: center;
}

.novel-parent-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
    display: block;
}

.chapter-child-title {
    font-family: var(--font-serif);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.reader-actions {
    display: flex;
    gap: 15px;
}

.reader-icon-btn {
    background: #161619;
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}

.reader-icon-btn:hover {
    border-color: var(--color-accent);
    box-shadow: 0 0 8px var(--color-accent-glow);
}

/* Settings slide-down panel */
.reader-settings-panel {
    background-color: #0d0d0f;
    border-bottom: 1px solid var(--border-light);
    padding: 24px 30px;
    z-index: 905;
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.settings-grid {
    max-width: 800px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.range-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}

.range-row input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--border-light);
    outline: none;
}

.range-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    box-shadow: 0 0 6px var(--color-accent-glow);
}

.range-row output {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 700;
}

.settings-row-checkboxes {
    display: flex;
    gap: 30px;
    grid-column: span 2;
    margin-top: 10px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.check-row input[type="checkbox"] {
    accent-color: var(--color-accent);
    width: 16px;
    height: 16px;
}

/* Bookmarks Panel Sliding sidebar */
.reader-bookmarks-panel {
    position: absolute;
    top: 70px;
    right: 0;
    bottom: 0;
    width: 380px;
    background-color: #0a0a0c;
    border-left: 1px solid var(--border-light);
    z-index: 908;
    display: flex;
    flex-direction: column;
    animation: slideLeft 0.3s ease-out;
}

@keyframes slideLeft {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.bookmarks-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.bookmarks-panel-header h4 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-primary);
}

.panel-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

.bookmarks-panel-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bm-item-row {
    background-color: #121215;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.bm-item-row:hover {
    border-color: var(--color-accent);
    background-color: rgba(255, 59, 48, 0.02);
}

.bm-meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.bm-meta-row .date {
    color: var(--text-muted);
}

.bm-content-text {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    padding-left: 8px;
}

.bm-content-text.hl-red {
    border-left: 3px solid var(--color-accent);
}

.bm-content-text.hl-dark {
    border-left: 3px solid var(--text-muted);
}

.bm-note-snippet {
    margin-top: 8px;
    font-size: 12px;
    color: #c5a4a4;
    background-color: #1a1515;
    padding: 6px 10px;
    border-radius: 4px;
    border-left: 2px solid var(--color-accent);
}

/* Reader ad zone styles */
.reader-ad-zone {
    width: 100%;
    background-color: var(--bg-ad);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 1px;
    overflow: hidden;
}

.reader-ad-top {
    height: 120px;
    margin-top: 10px;
    margin-bottom: 40px;
}

.reader-ad-bottom {
    height: 120px;
    margin-top: 50px;
    margin-bottom: 20px;
}

/* Scrollable reader core */
.reader-scroll-zone {
    flex-grow: 1;
    overflow-y: auto;
    padding: 60px 20px 100px 20px;
    display: flex;
    justify-content: center;
}

.reader-content {
    width: 100%;
    max-width: var(--reader-width);
}

.reader-body {
    font-family: var(--font-serif);
    font-size: var(--reader-font-size);
    line-height: var(--reader-line-height);
    text-align: var(--reader-text-align);
    color: #d1d1d6;
}

.reader-body p {
    margin-bottom: var(--reader-paragraph-margin);
    text-indent: var(--reader-paragraph-indent);
    position: relative;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
    cursor: text;
}

.reader-body p:hover {
    background-color: rgba(255,255,255,0.015);
}

/* Highlight classes */
.reader-body p.hl-red {
    background-color: rgba(255, 59, 48, 0.15);
    border-left: 3px solid var(--color-accent);
}

.reader-body p.hl-dark {
    background-color: rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--text-secondary);
}

/* Memo marker */
.memo-indicator {
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    margin-left: 6px;
    vertical-align: middle;
    background: #271413;
    padding: 2px 5px;
    border-radius: 4px;
    border: 1px solid var(--color-accent);
    box-shadow: 0 0 6px var(--color-accent-glow);
    user-select: none;
}

.memo-indicator:hover {
    transform: scale(1.15);
}

/* Reader navigation fixed below progress */
.reader-chapter-controls {
    height: var(--reader-controls-height);
    background-color: #0b0b0d;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 7px 16px 9px;
}

.nav-btn {
    background-color: #111113;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    width: 42px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.reader-nav-icon svg {
    width: 20px;
    height: 20px;
}

.reader-nav-icon path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chapter-list-btn {
    width: 46px;
    background-color: #17171b;
    border-color: rgba(255, 255, 255, 0.16);
}

.nav-btn:hover:not(:disabled) {
    border-color: var(--color-accent);
    box-shadow: 0 0 12px var(--color-accent-glow);
    background-color: rgba(255, 59, 48, 0.02);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Reader footer progress */
.reader-footer {
    height: var(--reader-footer-height);
    background-color: #0b0b0d;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.progress-bar-container {
    height: 3px;
    background-color: #1a1a1e;
    width: 100%;
}

.reader-progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--color-accent);
    box-shadow: 0 0 8px var(--color-accent);
}

.footer-copy {
    flex-grow: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
}

.reader-chapter-panel {
    position: absolute;
    top: 70px;
    right: 0;
    bottom: calc(var(--reader-footer-height) + var(--reader-controls-height));
    left: 0;
    z-index: 920;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: flex-end;
    justify-content: center;
    padding: 20px;
}

.reader-chapter-panel-box {
    width: min(760px, 100%);
    max-height: min(620px, calc(100vh - 220px));
    background-color: #0d0d10;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 1px var(--color-accent);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.reader-chapter-panel-header {
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
}

.reader-chapter-panel-header h4 {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 600;
}

.reader-chapter-panel-header .panel-close-btn {
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    padding: 7px 10px;
}

.reader-chapter-panel-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 8px;
    overflow-y: auto;
    padding: 12px;
}

.reader-chapter-item {
    background-color: #121216;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 74px;
    padding: 12px;
    text-align: left;
    transition: all 0.2s;
}

.reader-chapter-item:hover {
    border-color: var(--color-accent);
    color: var(--text-primary);
    background-color: rgba(255, 59, 48, 0.05);
}

.reader-chapter-item.active {
    border-color: var(--color-accent);
    background-color: rgba(255, 59, 48, 0.1);
    box-shadow: inset 3px 0 0 var(--color-accent);
    color: var(--text-primary);
}

.reader-chapter-number {
    color: var(--color-accent);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.reader-chapter-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
}

.reader-chapter-empty {
    color: var(--text-muted);
    font-size: 13px;
    padding: 24px;
}

/* --- 9. Selection Toolbar --- */
.selection-toolbar {
    position: absolute;
    background-color: #151518;
    border: 1px solid var(--border-light);
    padding: 5px;
    border-radius: 8px;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.8), 0 0 1px var(--color-accent);
    display: flex;
    gap: 6px;
    transform: translate(-50%, -100%);
    animation: popIn 0.15s ease-out;
}

@keyframes popIn {
    from { transform: translate(-50%, -80%) scale(0.9); opacity: 0; }
    to { transform: translate(-50%, -100%) scale(1); opacity: 1; }
}

.hl-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
    transition: transform 0.15s;
}

.hl-btn:hover {
    transform: scale(1.1);
}

.hl-btn.red {
    background-color: var(--color-accent);
    border: 1px solid rgba(255,255,255,0.2);
}

.hl-btn.dark {
    background-color: #2c2c2e;
    border: 1px solid rgba(255,255,255,0.2);
}

.hl-btn.memo, .hl-btn.copy {
    background-color: #232328;
    width: auto;
    padding: 0 10px;
    font-family: inherit;
    gap: 4px;
}

/* --- 10. Compact Modal Elements (Memo Quotes) --- */
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
    font-size: 16px;
    font-family: var(--font-serif);
    font-weight: 600;
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.memo-quote {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-secondary);
    border-left: 2px solid var(--color-accent);
    padding-left: 12px;
    font-size: 13px;
    line-height: 1.5;
}

.modal-body textarea {
    background-color: #121214;
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    resize: none;
    height: 120px;
    outline: none;
    font-family: inherit;
}

.modal-body textarea:focus {
    border-color: var(--color-accent);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 10px;
}

/* --- 11. Toast System --- */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: rgba(255, 59, 48, 0.95);
    color: #ffffff;
    padding: 12px 28px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 10px 25px rgba(255, 59, 48, 0.3);
    z-index: 2000;
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    letter-spacing: 0.5px;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* --- 12. Responsive Adjustments --- */
@media (max-width: 1100px) {
    .left-ad-zone {
        display: none; /* Hide left ad to give space on tablet sizes */
    }
    .main-container {
        padding: 30px 15px;
        gap: 0;
    }
}

@media (max-width: 768px) {
    header {
        gap: 10px;
        padding: 14px 12px;
    }
    .logo {
        flex-shrink: 0;
        font-size: 15px;
        letter-spacing: 0.6px;
    }
    .nav-links {
        flex: 0 0 auto;
        gap: 14px;
        margin-left: auto;
    }
    .nav-item {
        margin-left: 0;
        font-size: 12px;
        white-space: nowrap;
    }
    .novel-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 20px;
    }
    .novel-cover {
        height: 250px;
    }
    .novel-cover-typography {
        font-size: 16px;
    }
    .detail-top {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .detail-tags {
        justify-content: center;
    }
    .detail-stats {
        justify-content: center;
    }
    .detail-action-buttons {
        justify-content: center;
    }
    .chapters-list {
        grid-template-columns: 1fr;
    }
    .settings-grid {
        grid-template-columns: 1fr;
    }
    .settings-row-checkboxes {
        grid-column: span 1;
    }
    .reader-bookmarks-panel {
        width: 100%; /* Mobile full width panel */
    }
    .reader-overlay {
        --reader-controls-height: 54px;
    }
    .reader-chapter-controls {
        height: var(--reader-controls-height);
        padding: 8px 12px 10px;
    }
    .reader-chapter-panel {
        bottom: calc(var(--reader-footer-height) + var(--reader-controls-height));
        padding: 12px;
    }
    .reader-chapter-panel-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    header {
        gap: 8px;
        padding: 13px 10px;
    }
    .logo {
        font-size: 13px;
        letter-spacing: 0.4px;
    }
    .nav-links {
        gap: 10px;
    }
    .nav-item {
        font-size: 11px;
    }
}

/* --- 13. Global Age Verification Gate CSS --- */
.age-gate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(5, 5, 5, 0.97);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.5s ease-out, filter 0.5s ease-out;
}

.age-gate-box {
    background-color: #0c0c0e;
    border: 1px solid #1a1a1e;
    border-radius: 16px;
    width: 100%;
    max-width: 640px;
    padding: 45px 40px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.95), 0 0 40px rgba(255, 59, 48, 0.12);
    display: flex;
    flex-direction: column;
    gap: 25px;
    animation: ageGatePop 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ageGatePop {
    from {
        transform: scale(0.96);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.age-gate-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 18px;
}

.age-gate-logo {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 3px;
    color: var(--text-primary);
}

.age-gate-logo span {
    color: var(--color-accent);
    text-shadow: 0 0 10px var(--color-accent-glow);
}

.age-gate-badge {
    background-color: #ff3b30;
    color: #ffffff;
    font-size: 14px;
    font-weight: 800;
    padding: 5px 12px;
    border-radius: 6px;
    letter-spacing: 1px;
    box-shadow: 0 0 15px rgba(255, 59, 48, 0.6);
}

.age-gate-content {
    display: flex;
    flex-direction: column;
    gap: 22px;
    text-align: left;
}

.age-gate-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.age-gate-title {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 500;
    line-height: 1.45;
    color: var(--text-primary);
}

.age-gate-warning {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.age-gate-buttons {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 16px;
    margin-top: 8px;
}

.age-gate-btn {
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1.2;
    outline: none;
    font-family: var(--font-sans);
}

.age-gate-btn span {
    display: block;
}

.age-gate-btn .btn-en {
    font-size: 13px;
    font-weight: 700;
}

.btn-exit {
    background-color: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.btn-exit:hover {
    background-color: rgba(255, 255, 255, 0.04);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.btn-enter {
    background-color: var(--color-accent);
    border: 1px solid var(--color-accent);
    color: #ffffff;
    box-shadow: 0 4px 15px var(--color-accent-glow);
}

.btn-enter:hover {
    background-color: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 59, 48, 0.5);
}

.btn-enter:active {
    transform: translateY(0);
}

.age-gate-footer {
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid var(--border-color);
    padding-top: 18px;
}

.age-gate-footer a,
.site-footer a,
.legal-container a {
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 59, 48, 0.45);
}

.age-gate-footer a:hover,
.site-footer a:hover,
.legal-container a:hover {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.site-footer {
    max-width: 1120px;
    margin: 40px auto 60px;
    padding: 24px 20px 0;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.6;
    text-align: center;
}

.site-footer-links {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-bottom: 10px;
}

.legal-page {
    min-height: 100vh;
}

.legal-container {
    width: min(860px, calc(100% - 40px));
    margin: 54px auto 80px;
    color: var(--text-secondary);
}

.legal-kicker {
    color: var(--color-accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.legal-container h1 {
    font-family: var(--font-serif);
    color: var(--text-primary);
    font-size: 42px;
    font-weight: 600;
    line-height: 1.15;
    margin-bottom: 18px;
}

.legal-container > p,
.legal-section p,
.legal-section li {
    font-size: 15px;
    line-height: 1.8;
}

.legal-section {
    border-top: 1px solid var(--border-color);
    padding-top: 28px;
    margin-top: 28px;
}

.legal-section h2 {
    color: var(--text-primary);
    font-size: 17px;
    margin-bottom: 12px;
}

.legal-section p + p {
    margin-top: 12px;
}

.legal-section ul {
    margin: 10px 0 0 22px;
}

.legal-section li + li {
    margin-top: 6px;
}

.seo-novel-container {
    display: block;
}

.seo-tagline {
    color: var(--color-accent);
    font-size: 13px;
    font-weight: 700;
    margin-top: 14px;
}

.seo-cover-frame {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.35);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 28px;
    max-width: 280px;
    min-height: 420px;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.seo-cover-frame.has-cover-image {
    background: #090606;
}

.seo-cover {
    display: block;
    height: 100%;
    object-fit: cover;
    width: 100%;
}

.seo-cover-typography {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 600;
    padding: 22px;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.seo-chapter-list {
    columns: 2;
    column-gap: 44px;
    margin: 0;
    padding-left: 20px;
}

.seo-chapter-list li {
    break-inside: avoid;
    margin-bottom: 8px;
}

.seo-read-link {
    display: inline-flex;
    margin-top: 12px;
    text-decoration: none;
}

@media (max-width: 600px) {
    .age-gate-box {
        padding: 30px 20px;
        gap: 20px;
    }
    .age-gate-buttons {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .age-gate-title {
        font-size: 16px;
    }
    .age-gate-warning {
        font-size: 12px;
    }
    .site-footer-links {
        flex-direction: column;
        gap: 8px;
    }
    .legal-container {
        width: min(100% - 28px, 860px);
        margin-top: 36px;
    }
    .legal-container h1 {
        font-size: 32px;
    }
    .seo-chapter-list {
        columns: 1;
    }
}
