[x-cloak] {
    display: none !important;
}

html.is-translating {
    visibility: hidden !important;
}

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    background: #f3f4f6;
    color: #1f2937;
    transition: background-color .25s, color .25s;
}

.dark body {
    background: #0a0a0a;
    color: #d1d5db;
}

.reader-image-frame {
    box-sizing: border-box;
    width: 100%;
    min-height: clamp(260px, 48vh, 560px);
    overflow: hidden;
    isolation: isolate;
    border: 1px solid rgba(148, 163, 184, .28);
    background:
        linear-gradient(110deg, rgba(255, 255, 255, .28) 8%, rgba(255, 255, 255, .72) 18%, rgba(255, 255, 255, .28) 33%),
        #e5e7eb;
    background-size: 220% 100%;
    animation: reader-image-skeleton 1.6s linear infinite;
}

#image-container.fixed .reader-image-frame {
    width: min(760px, 86vw);
    min-height: min(72vh, 720px);
}

.reader-image-frame.is-loaded {
    width: 100%;
    min-height: 0;
    overflow: visible;
    border-color: transparent;
    background: transparent;
    animation: none;
}

.reader-image-frame.is-loaded {
    border-width: 0;
}

#image-container.fixed .reader-image-frame.is-loaded {
    width: auto;
}

.reader-image-loading,
.reader-image-error {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 14px;
}

.reader-image-loading {
    flex-direction: row;
    gap: 10px;
}

.reader-image-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(100, 116, 139, .25);
    border-top-color: #3b82f6;
    border-radius: 999px;
    animation: reader-image-spin .75s linear infinite;
}

.reader-image-error {
    display: none;
    flex-direction: column;
    gap: 8px;
    padding: 24px;
    text-align: center;
    background: #f8fafc;
}

.reader-image-error strong {
    color: #334155;
    font-size: 16px;
}

.reader-image-error-icon {
    display: flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #fee2e2;
    color: #dc2626;
    font-size: 24px;
    font-weight: 800;
}

.reader-image-retry {
    margin-top: 4px;
    padding: 8px 18px;
    border: 0;
    border-radius: 999px;
    background: #3b82f6;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
}

.reader-image-retry:hover {
    background: #2563eb;
}

.reader-image-frame.is-error {
    animation: none;
}

.reader-image-frame.is-error .reader-image-loading,
.reader-image-frame.is-loaded .reader-image-loading {
    display: none;
}

.reader-image-frame.is-error .reader-image-error {
    display: flex;
}

.dark .reader-image-frame {
    border-color: rgba(255, 255, 255, .08);
    background:
        linear-gradient(110deg, rgba(255, 255, 255, .015) 8%, rgba(255, 255, 255, .06) 18%, rgba(255, 255, 255, .015) 33%),
        #171717;
    background-size: 220% 100%;
}

.dark .reader-image-frame.is-loaded {
    background: transparent;
}

.dark .reader-image-loading {
    color: #9ca3af;
}

.dark .reader-image-error {
    background: #171717;
    color: #9ca3af;
}

.dark .reader-image-error strong {
    color: #e5e7eb;
}

.manga-image {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto;
    opacity: 0;
}

.reader-image-frame.is-loaded .manga-image {
    opacity: 1;
}

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

@keyframes reader-image-skeleton {
    to { background-position-x: -220%; }
}

.force-hidden {
    display: none !important;
}

.reader-tool-btn {
    display: flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(229, 231, 235, .95);
    background: rgba(255, 255, 255, .92);
    color: #374151;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
    backdrop-filter: blur(12px);
    white-space: nowrap;
}

.reader-top-tools {
    max-width: min(760px, calc(100vw - 3rem));
    align-items: flex-end;
}

.reader-top-tools-main,
.reader-top-actions,
.reader-translate-row {
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
}

.reader-translate-status {
    max-width: min(320px, calc(100vw - 3rem));
    overflow: hidden;
    text-overflow: ellipsis;
}

.reader-tool-btn:hover {
    border-color: #60a5fa;
    background: #dbeafe;
    color: #1d4ed8;
}

.dark .reader-tool-btn {
    border-color: rgba(255, 255, 255, .08);
    background: rgba(30, 30, 30, .92);
    color: #d1d5db;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

.dark .reader-tool-btn:hover {
    background: rgba(45, 45, 45, .98);
    color: #fff;
}

.reader-tool-btn.reader-autoplay-active,
.reader-tool-btn.reader-autoplay-active:hover {
    border-color: #3b82f6;
    background: #dbeafe;
    color: #1d4ed8;
    box-shadow: 0 10px 30px rgba(37, 99, 235, .2);
}

.dark .reader-tool-btn.reader-autoplay-active,
.dark .reader-tool-btn.reader-autoplay-active:hover {
    border-color: rgba(96, 165, 250, .75);
    background: rgba(37, 99, 235, .24);
    color: #60a5fa;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

.reader-tool-icon-btn {
    width: 38px;
    padding: 8px !important;
}

.reader-profile-select {
    min-height: 38px;
    gap: 6px;
    padding: 6px 8px 6px 10px;
}

.reader-profile-combo {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    box-sizing: border-box;
    width: var(--reader-profile-select-width, 40px);
    min-width: var(--reader-profile-select-width, 40px);
    height: 26px;
    border: 1px solid rgba(156, 163, 175, .65);
    border-radius: 4px;
    background-color: rgba(255, 255, 255, .9);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%236b7280' d='M2 3.5h6L5 6.8z'/%3E%3C/svg%3E");
    background-position: right 2px center;
    background-repeat: no-repeat;
    background-size: 8px 8px;
    color: inherit;
    font: inherit;
    padding: 2px 8px 2px 4px;
}

.reader-thread-combo {
    width: 32px;
    min-width: 32px;
    padding-left: 4px;
    padding-right: 8px;
}

.dark .reader-profile-combo {
    border-color: rgba(255, 255, 255, .14);
    background-color: rgba(17, 24, 39, .8);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23d1d5db' d='M2 3.5h6L5 6.8z'/%3E%3C/svg%3E");
}

.sun-icon {
    display: none;
}

.moon-icon {
    display: block;
}

.dark .sun-icon {
    display: block;
}

.dark .moon-icon {
    display: none;
}

.cursor-left {
    cursor: url("../cursor/reader-arrow-left.cur") 24 24, w-resize;
}

.cursor-right {
    cursor: url("../cursor/reader-arrow-right.cur") 24 24, e-resize;
}

.pc-view-page .reader-cursor-up {
    cursor: url("../cursor/reader-arrow-up.cur") 24 24, n-resize;
}

.pc-view-page .reader-cursor-down {
    cursor: url("../cursor/reader-arrow-down.cur") 24 24, s-resize;
}

.reader-modal-card {
    max-height: min(86vh, 820px);
    overflow: auto;
}

.reader-settings-modal-card {
    width: min(720px, calc(100vw - 1.5rem));
    max-width: 720px;
    max-height: calc(100vh - 1rem);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.reader-settings-modal-card::-webkit-scrollbar {
    display: none;
}

.reader-choice {
    min-width: 88px;
}

.reader-choice:focus {
    outline: 2px solid rgba(96, 165, 250, .95);
    outline-offset: 2px;
}

.reader-mode-row {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.reader-mode-options {
    display: grid;
    min-width: 0;
    flex: 1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .75rem;
}

.reader-mode-choice {
    min-width: 0;
    padding-right: .5rem;
    padding-left: .5rem;
    white-space: nowrap;
}

.reader-autoplay-select {
    min-width: 112px;
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 9999px;
    outline: none;
    background-color: rgba(255, 255, 255, .05);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M2.2 4.2h7.6L6 8z'/%3E%3C/svg%3E");
    background-position: right .8rem center;
    background-repeat: no-repeat;
    color: #d1d5db;
    padding: .55rem 2.3rem .55rem 1rem;
    font-weight: 700;
    transition: border-color .2s, background-color .2s, color .2s;
}

.reader-autoplay-layout {
    display: grid;
    grid-template-columns: 80px 288px 160px;
    align-items: center;
    column-gap: .75rem;
    row-gap: .5rem;
}

.reader-autoplay-group-label {
    color: #d1d5db;
    white-space: nowrap;
}

.reader-autoplay-speed-options {
    display: grid;
    grid-template-columns: repeat(3, 88px);
    gap: .75rem;
}

.reader-autoplay-layout .reader-autoplay-speed-options {
    grid-row: 2;
    grid-column: 2;
}

.reader-autoplay-layout > .reader-autoplay-select {
    grid-row: 2;
    grid-column: 3;
    width: 100%;
    min-width: 0;
}

.reader-autoplay-select:hover,
.reader-autoplay-select:focus {
    border-color: #3b82f6;
    background-color: rgba(59, 130, 246, .1);
    color: #60a5fa;
}

.reader-autoplay-select option {
    background: #1c1c1e;
    color: #e5e7eb;
}

.reader-range {
    accent-color: #fff;
}

.reader-chapter-panel {
    direction: ltr;
    min-height: 148px;
}

html.dark .reader-chapter-panel {
    box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

::-webkit-scrollbar {
    width: 15px;
    height: 15px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #b8b8b8;
}

.dark ::-webkit-scrollbar-thumb {
    background: #3d3d3d;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #495060;
}

@media (max-width: 768px) {
    .reader-mode-row {
        align-items: stretch;
        flex-direction: column;
    }

    .reader-mode-options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .reader-breadcrumb {
        max-width: calc(100vw - 1rem) !important;
        font-size: 1rem !important;
        padding-right: 8rem;
    }

    .reader-top-tools {
        top: .75rem !important;
        right: .75rem !important;
        gap: .5rem !important;
        max-width: calc(100vw - 1.5rem) !important;
    }

    .reader-top-tools .reader-tool-btn span {
        font-size: 0;
    }

    .reader-top-tools .reader-tool-btn span::after {
        content: attr(data-short);
        font-size: .75rem;
    }

    .reader-top-tools .reader-profile-select span {
        font-size: .75rem !important;
    }

    .reader-top-tools .reader-profile-select span::after {
        content: none !important;
    }

    .reader-top-tools .reader-translate-status span {
        font-size: .75rem !important;
    }

    .reader-top-tools .reader-translate-status span::after {
        content: none !important;
    }

    .reader-bottom-nav {
        bottom: 1rem !important;
        width: calc(100vw - 1rem) !important;
    }

    .reader-bottom-nav nav button {
        padding-left: .75rem !important;
        padding-right: .75rem !important;
    }
}
