:root {
    --bg-surface: #14141b;
    --bg-elevated: #1c1c26;
    --bg-hover: #252530;
}

.hidden { display: none !important; }

.top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 64px;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.glass-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--color-text-primary);
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.glass-btn:hover {
    background: var(--bg-hover);
    border-color: var(--color-primary);
    transform: translateY(-1px);
}

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

.chapter-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.nav-arrow {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-arrow:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    transform: scale(1.05);
}

.nav-arrow:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#reader {
    margin-top: 64px;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 64px);
    width: 100%;
}

.manga-container {
    width: 100%;
    max-width: var(--manga-max-width, 1200px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--page-spacing, 16px);
}

.page-img {
    width: 100%;
    max-width: var(--page-max-width, 900px);
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    display: block;
}

.page-img:hover {
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.6);
}

.page-img.zoomed {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: 100vw;
    max-height: calc(100vh - 64px);
    width: auto;
    height: auto;
    margin: auto;
    z-index: 999;
    cursor: zoom-out;
    border-radius: 0;
    object-fit: contain;
}

.zoom-overlay {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 998;
    cursor: zoom-out;
}

.double-container {
    display: flex;
    gap: var(--page-spacing, 16px);
    width: 100%;
    max-width: var(--manga-max-width, 1400px);
    justify-content: center;
}

.double-container img {
    width: 48%;
    max-width: 700px;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.double-container img:hover {
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.6);
}

.ln-content {
    max-width: var(--ln-max-width, 750px);
    width: 100%;
    margin: 0 auto;
    padding: 3rem 2.5rem;
    line-height: var(--ln-line-height, 1.8);
    font-size: var(--ln-font-size, 18px);
    font-family: var(--ln-font-family, 'Georgia', serif);
    color: var(--ln-text-color, #e5e7eb);
    text-align: var(--ln-text-align, left);
}

.ln-content p {
    margin-bottom: 1.5em;
}

.ln-content h1, .ln-content h2, .ln-content h3 {
    margin-top: 2em;
    margin-bottom: 1em;
    font-weight: 700;
}

.settings-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 400px;
    padding: 0;
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-subtle);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.6);
}

.settings-panel.open {
    transform: translateX(0);
}

.panel-header {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    z-index: 10;
    background: #0a0a0f;
    border-bottom: 1px solid var(--border-subtle);
}

.panel-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: none;
    color: var(--color-text-secondary);
}

.close-btn:hover {
    background: var(--color-primary);
    color: var(--color-text-primary);
    transform: rotate(90deg);
}

.panel-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-subtle);
}

.settings-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.settings-section h4 {
    margin: 0 0 1.25rem 0;
    color: var(--color-text-primary);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.control {
    margin-bottom: 1.25rem;
}

.control:last-child {
    margin-bottom: 0;
}

.control label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.625rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.control label span {
    color: var(--color-text-primary);
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
}

input[type="range"] {
    width: 100%;
    border-radius: var(--radius-full);
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    height: 8px;
    background: var(--bg-hover);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
    width: 20px;
    height: 20px;
    background: var(--color-primary);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.6);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

select, input[type="color"], input[type="number"] {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: 0.875rem;
    transition: all 0.2s;
    cursor: pointer;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
}

select:hover, input[type="color"]:hover, input[type="number"]:hover {
    border-color: var(--color-primary);
}

select:focus, input[type="color"]:focus, input[type="number"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
    transform: translateY(-1px);
}

input[type="color"] {
    height: 44px;
    padding: 0.25rem;
    cursor: pointer;
}

.presets {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.presets button {
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    padding: 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.presets button:hover {
    background: var(--color-primary);
    background: var(--color-primary);
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--color-primary-glow);
}

.toggle-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.toggle-btn {
    flex: 1;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8125rem;
    text-align: center;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--color-text-secondary);
    font-weight: 600;
}

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

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

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-elevated);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1rem;
    color: var(--color-text-secondary);
}

.settings-panel::-webkit-scrollbar {
    width: 8px;
}

.settings-panel::-webkit-scrollbar-track {
    background: var(--bg-surface);
}

.settings-panel::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

.settings-panel::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}

@media (max-width: 768px) {
    .settings-panel {
        width: 100%;
        max-width: 100%;
    }

    .top-bar {
        padding: 0 1rem;
    }

    .glass-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8125rem;
    }

    .chapter-info {
        font-size: 0.875rem;
        gap: 0.75rem;
    }

    .double-container {
        flex-direction: column;
    }

    .double-container img {
        width: 100%;
        max-width: 100%;
    }

    .ln-content {
        padding: 2rem 1.5rem;
        font-size: var(--ln-font-size, 16px);
    }
}

.fit-width {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
}

.fit-height {
    height: var(--viewport-height, 85vh) !important;
    width: auto !important;
    max-width: 100% !important;
}

.fit-screen {
    max-height: var(--viewport-height, 85vh) !important;
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
}

.page-img.longstrip-fit {
    width: 50%;
    max-width: 50%;
    margin: 0 auto;
    display: block;
}