@keyframes pulse-t3pv1p {
    from {
        opacity: 1;
        transform: scale(0);
    }

    to {
        opacity: 0;
        transform: scale(1);
    }
}

@keyframes viewerFadeIn {
    from { opacity: 0.8; }
    to { opacity: 1;}
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

/* Loading Overlay */
.viewer-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--loading-bg);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
    box-sizing: initial !important;
}
.viewer-loading-overlay * {
    box-sizing: initial !important;
}
.viewer-loading-overlay.active {
    display: flex;
}

.viewer-loader.pulse {
    --pulse-size: 14px;
    position: relative;
    height: 64px;
    width: 64px;
    margin-bottom: 1.5rem;
}

.viewer-loader.pulse:before,
.viewer-loader.pulse:after {
    border-radius: 50%;
    content: '';
    position: absolute;
}

.viewer-loader.pulse:before {
    background: var(--color-primary);
    height: var(--pulse-size);
    width: var(--pulse-size);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.viewer-loader.pulse:after {
    animation: pulse-t3pv1p 1.5s infinite;
    border: 6.4px solid var(--color-primary);
    margin-left: calc(var(--pulse-size) / 2 * -1);
    margin-top: calc(var(--pulse-size) / 2 * -1);
    height: 100%;
    width: 100%;
}

.viewer-loading-text {
    font-weight: 600;
    color: var(--color-primary);
    font-size: 1.1rem;
}


#viewer {
    padding: 0;
    overflow: hidden;

    /* Theme Variables - Default (Light) */
    --viewer-bg: #f8f9fa;
    --viewer-content-bg: #ffffff;
    --loading-bg: rgba(255, 255, 255, 0.3);
    --header-bg: rgba(255, 255, 255, 0.8);
    --footer-bg: white;
    --sidebar-bg: #ffffff;
    --sidebar-tab-bg: #f1f3f5;
    --text-color: #333;
    --text-secondary: #777;
    --text-muted: #999;
    --border-color: #dee2e6;
    --card-bg: #fafafa;
    --hover-bg: rgba(0, 0, 0, 0.05);
    --color-primary: #8f45e3;
    --color-primary-light: #f5efff;
    --link-color: var(--color-primary);
    --progress-track-bg: #eee;
    --progress-stripe: rgba(255, 255, 255, 0.2);
    --progress: 0%;

    --color-yellow: #fab005;
    --color-pink: #fa5252;
    --color-green: #40c057;
    --color-blue: #228be6;
    --color-purple: #be4bdb;

    --danger-color: #e74c3c;
    --success-color: #2ecc71;
    --warning-color: #f39c12;

    /* Epub Content Specific */
    --epub-body-bg: transparent;
    --epub-text-color: #2c3e50;

    /* Custom Scrollbar */
    --scrollbar-width: 8px;
    --scrollbar-thumb: rgba(0, 0, 0, 0.2);
    --scrollbar-thumb-hover: rgba(0, 0, 0, 0.3);

    --logo-text-color: #bb9444;
}
body[data-theme=dark]#viewer {
    /* Theme Variables - Dark */
    --viewer-bg: #121212;
    --viewer-content-bg: #1e1e1e;
    --loading-bg: rgba(18, 18, 18, 0.3);
    --header-bg: rgba(30, 30, 30, 0.9);
    --footer-bg: #1e1e1e;
    --sidebar-bg: #1e1e1e;
    --sidebar-tab-bg: #252525;
    --text-color: #e0e0e0;
    --text-secondary: #888;
    --text-muted: #666;
    --border-color: #333;
    --card-bg: #2a2a2a;
    --hover-bg: rgba(255, 255, 255, 0.1);
    --color-primary: #ffffff;
    --color-primary-light: #333;
    --color-yellow: #fcc419;
    --color-pink: #f03e3e;
    --color-green: #37b24d;
    --color-blue: #1c7ed6;
    --color-purple: #ae3ec9;
    --link-color: #a362f0;
    --progress-track-bg: #333;
    --progress-stripe: rgba(255, 255, 255, 0.2);
    --scrollbar-thumb: rgba(255, 255, 255, 0.2);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.3);
    --danger-color: #ff6b6b;

    --logo-text-color: #ffffff;

    /* Epub Content Specific */
    --epub-body-bg: transparent;
    --epub-text-color: #e0e0e0;
}

body[data-theme=sepia]#viewer {
    /* Theme Variables - Sepia */
    --viewer-bg: #f4ecd8;
    --viewer-content-bg: #fdf6e3;
    --loading-bg: rgba(244, 236, 216, 0.3);
    --header-bg: rgba(235, 226, 203, 0.9);
    --footer-bg: #ece2c6;
    --sidebar-bg: #f1e7d0;
    --sidebar-tab-bg: #e6dac1;
    --text-color: #5b4636;
    --text-secondary: #8b7355;
    --text-muted: #a68b6a;
    --border-color: #d3c5a3;
    --card-bg: #f9f3e6;
    --hover-bg: rgba(91, 70, 54, 0.05);
    --color-primary: #5b4636;
    --color-primary-light: #f9f3e6;
    --color-yellow: #f59f00;
    --color-pink: #e64980;
    --color-green: #2f9e44;
    --color-blue: #1971c2;
    --color-purple: #9c36b5;
    --link-color: #8b7355;
    --progress-track-bg: #d3c5a3;
    --progress-stripe: rgba(255, 255, 255, 0.2);
    --scrollbar-thumb: rgba(91, 70, 54, 0.2);
    --scrollbar-thumb-hover: rgba(91, 70, 54, 0.3);
    --danger-color: #d9534f;

    --logo-text-color: #a06d00;

    /* Epub Content Specific */
    --epub-body-bg: transparent;
    --epub-text-color: #5b4636;
}

/* Global Scrollbar Styling */
#viewer ::-webkit-scrollbar {
    width: var(--scrollbar-width);
    height: var(--scrollbar-width);
}

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

#viewer ::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
}

#viewer ::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    background-clip: content-box;
}

/* For Firefox */
#viewer {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

body[data-theme=sepia]#viewer #book_info_popup .book-info .th {
    color: var(--text-secondary);
}

body[data-theme=sepia]#viewer #book_info_popup .book-info .th i {
    color: var(--text-muted);
}

body[data-theme=sepia]#viewer .bookmark-item .bookmark-date,
body[data-theme=sepia]#viewer .memo-item .memo-date,
body[data-theme=sepia]#viewer .highlight-item .highlight-date {
    color: var(--text-secondary);
}

body[data-theme=sepia]#viewer .empty-msg::before {
    color: var(--text-muted);
}

/* Empty Message */
.empty-msg {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.empty-msg::before {
    content: "\f431"; /* bi-info-circle */
    font-family: "bootstrap-icons" !important;
    font-size: 2rem;
    opacity: 0.3;
    margin-bottom: 0.5rem;
}

/* Theme Options in Settings */
.theme-options {
    display: flex;
    gap: 12px;
}

.theme-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
}

.theme-option:hover {
    transform: scale(1.1);
}

.theme-option.active {
    border-color: var(--color-primary);
}

.theme-option.active:after {
    content: '\F26E'; /* bootstrap-icons check-lg */
    font-family: 'bootstrap-icons';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    color: var(--color-primary);
}

.theme-option[data-theme-value="light"] { background-color: #f8f9fa; }
.theme-option[data-theme-value="sepia"] { background-color: #f4ecd8; }
.theme-option[data-theme-value="dark"] { background-color: #121212; }
body[data-theme=dark]#viewer .theme-option.active:after {
    color: white;
}

#viewer * {
    box-sizing: border-box;
}
.viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    overflow: hidden;

    --viewer-header-height: 56px;
    --viewer-header-logo-height: 34px;
    --viewer-footer-height: 50px;
    --viewer-sidebar-height: 500px;
}

/* Viewer All */
.viewer * {font-size: inherit; font-family: inherit !important;}
.viewer img {max-height: 100%; display: block;}
.viewer .inner {width: 100%; height: 100%; padding: 0.5rem 1rem;}
.viewer .inner::after {display: none !important;}

/* Viewer Header */
.viewer .viewer-header {
    height: var(--viewer-header-height);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    background-color: var(--header-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.15);
}
.viewer .viewer-header .btn-list button#btn-theme i {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
body[data-theme=dark]#viewer #btn-theme i {
    transform: rotate(360deg);
}

.viewer .viewer-header .viewer-logo {
    height: var(--viewer-header-logo-height);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.viewer .viewer-header .viewer-logo img {
    transition: filter 0.3s ease;
}
body[data-theme=dark]#viewer .viewer-header .viewer-logo img {
    filter: brightness(0) invert(1);
}
.viewer .viewer-header .viewer-logo span {
    font-size: 1.1rem;
    font-family: 'Times New Roman', sans-serif !important;
    font-weight: 600;
    color: var(--logo-text-color);
    letter-spacing: -0.025em;
}
.viewer .viewer-title {
    font-weight: 600;
    color: var(--text-color);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-left: 2rem;
    margin-right: 2rem;
    text-align: center;
}
.viewer .viewer-header .btn-list {
    margin: 0;
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    flex-shrink: 0;
}
.viewer .viewer-header .btn-list button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
    width: 2.5rem;
    height: 2.5rem;
}
.viewer .viewer-header .btn-list button:hover {
    background-color: var(--hover-bg);
    color: var(--color-primary);
}
.viewer .viewer-header .btn-list button.active {
    color: var(--color-primary);
    background-color: var(--color-primary-light);
}
.viewer .viewer-header .btn-list button#btn-bookmark.active {
    color: var(--color-primary);
}
.viewer .viewer-header .btn-list button#btn-bookmark.active i::before {
    content: "\f199"; /* bi-star-fill */
}
.viewer .viewer-header .inner {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;
}
.viewer .viewer-header .inner > * {
    max-height: 100%;
}

/* Viewer Body */
.viewer .viewer-body {
    margin-top: var(--viewer-header-height);
    height: calc(100% - var(--viewer-header-height));
    display: flex;
    overflow: hidden;
    animation: viewerFadeIn 0.8s ease-out;
}

.viewer .viewer-body .viewer-wrapper {
    height: 100%;
    position: relative;
    flex: 1;
}

.viewer .viewer-body .viewer-content {
    background: var(--viewer-bg);
    height: calc(100% - var(--viewer-footer-height));
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    overflow: hidden; /* 스크롤바가 동작하지 않는 문제 해결을 위해 auto에서 hidden으로 변경. EPUB/PDF는 내부에서 제어함 */
    position: relative; /* 화살표 배치를 위해 추가 */
    user-select: none; /* 드래그 방지하여 스크롤 간섭 최소화 */
}

/* Floating Navigation Arrows */
.content-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: var(--header-bg); /* 배경색을 테마 헤더 배경과 맞춤 */
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-color);
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.content-nav:hover {
    background: var(--color-primary);
    color: var(--footer-bg);
    border-color: var(--color-primary);
    transform: translateY(-50%) scale(1.1);
}

.content-nav:disabled {
    opacity: 0;
    pointer-events: none;
}

.content-nav-prev {
    left: 20px;
}

.content-nav-next {
    right: 20px;
}

/* EPUB Mode Footer Styling */
.page-controls.epub-mode .page-number {
    display: none;
}

/* Viewer Body - Footer */
.viewer .viewer-footer {
    background: var(--footer-bg);
    width: 100%;
    height: var(--viewer-footer-height);
    display: flex;
    border-top: solid 1px var(--border-color);
}
.viewer .viewer-footer .page-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    min-width: 240px;
}
.page-number {
    color: var(--text-color);
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
    font-size: 1rem;
}
.page-number .page-sub {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 2px;
    font-weight: 400;
}
.viewer .viewer-footer .page-controls.epub-mode {
    min-width: 200px;
}
.viewer .viewer-footer .page-controls.expand {
    min-width: 280px;
}
.viewer .viewer-footer .page-controls button {
    padding: 0.5rem 0.8rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
}
.viewer .viewer-footer .page-controls button:hover {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
}

.viewer .viewer-footer .page-controls button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.viewer .viewer-footer .page-refresh {
    display: flex;
    align-items: center;
}

.viewer .viewer-footer .page-refresh button {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.2rem;
}

.viewer .viewer-footer .page-refresh button:hover {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
    transform: rotate(30deg);
}

/* Viewer Body - Footer - Progress */
.viewer-progress {
    flex: 1; /* 너비를 채우도록 변경 */
    padding: 12px 15px;
}

.viewer-progress-text {
    padding: 0 15px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    min-width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-progress .page-progress {
    width: 100%;
    appearance: none;
    height: 8px;
    background: var(--progress-track-bg);
    background-image: 
        linear-gradient(
            45deg, 
            var(--progress-stripe) 25%, 
            transparent 25%, 
            transparent 50%, 
            var(--progress-stripe) 50%, 
            var(--progress-stripe) 75%, 
            transparent 75%, 
            transparent
        ),
        linear-gradient(to right, var(--color-primary) 0%, var(--color-primary) var(--progress, 0%), transparent var(--progress, 0%), transparent 100%);
    background-size: 30px 30px, 100% 100%;
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.12);
}

/* thumb */
.viewer-progress .page-progress::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: #fff;
    border: 3px solid var(--color-primary); /* 고정 색상으로 변경하여 가독성 유지 */
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: -1px; /* Center it better on 8px track */
}

.viewer-progress .page-progress::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.viewer-progress .page-progress:disabled {
    cursor: not-allowed;
    filter: grayscale(1);
    opacity: 0.6;
}

.viewer-progress .page-progress:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.viewer-progress .page-progress::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #fff;
    border: 3px solid #8f45e3;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Viewer Body - Sidebar */
.viewer .viewer-sidebar {
    position: relative;
    margin-right: calc(var(--viewer-sidebar-height) * -1);
    width: var(--viewer-sidebar-height);
    background: var(--sidebar-bg);
    border-left: solid 1px var(--border-color);
    transition: margin-right 0.3s ease;
    z-index: 1000;
    display: flex; /* Flexbox 추가 */
}


body[data-sidebar="open"] .viewer-sidebar {
    margin-right: 0;
}

/* Sidebar Tabs 수정 */
.viewer .viewer-sidebar .sidebar-tabs {
    display: flex;
    flex-direction: column;
    width: 60px; /* 너비 줄임 */
    height: 100%;
    background-color: var(--sidebar-tab-bg);
    border-right: 1px solid var(--border-color);
    padding-top: 0;
}
.viewer .viewer-sidebar .sidebar-tabs button {
    padding: 1rem 0.5rem;
    border: none;
    border-left: 2px solid transparent;
    background: transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-color);
    opacity: 0.6;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.viewer .viewer-sidebar .sidebar-tabs button:hover {
    background-color: var(--hover-bg);
}
.viewer .viewer-sidebar .sidebar-tabs button.active {
    border-left-color: var(--color-primary);
    background-color: var(--sidebar-bg);
    color: var(--color-primary);
    font-weight: 600;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1;
    opacity: 1;
}

body[data-theme=dark]#viewer .viewer .viewer-sidebar .sidebar-tabs button.active {
    box-shadow: 2px 0 10px rgba(255, 255, 255, 0.1);
}

/* Sidebar Content 수정 */
.viewer .viewer-sidebar .sidebar-content {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    background-color: var(--sidebar-bg);
    scroll-behavior: smooth;
}
.viewer .viewer-sidebar .sidebar-tab {
    display: none;
    animation: slideIn 0.3s ease-out forwards;
}

/* Sidebar Content Header 추가 */
.sidebar-content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-content-header .header-title {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.sidebar-content-header i {
    font-size: 1.25rem;
    color: var(--color-primary);
}

.sidebar-content-header h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-color);
}

.btn-delete-all {
    background: none;
    border: none;
    padding: 4px;
    color: var(--text-color);
    opacity: 0.2;
    cursor: default;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    pointer-events: none;
}

.btn-delete-all.active {
    opacity: 0.5;
    cursor: pointer;
    pointer-events: auto;
}

.btn-delete-all.active:hover {
    opacity: 1;
    color: var(--danger-color);
}



.outline-list, .ol {
    list-style: none;
    padding: 0;
    margin: 0;
}

.outline-list li, .ol li {
    border-bottom: 1px solid var(--border-color);
}

.ol-item-container {
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
}

.ol-item-container:hover {
    background-color: var(--hover-bg);
}

.ol-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-left: 0.8rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    color: var(--text-color);
    opacity: 0.5;
}

.ol-toggle:hover {
    opacity: 1;
}

.ol-toggle i {
    font-size: 0.8rem;
}

.ol-link {
    display: block;
    width: 100%;
    padding: 0.9rem 1rem;
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 400;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    flex: 1;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ol-item-container:has(.ol-toggle) .ol-link {
    padding-left: 0.4rem;
}

/* Active State */
.ol-link.active {
    color: var(--color-primary);
    font-weight: 600;
    background-color: var(--color-primary-light);
}

/* Cover 항목 강조 */
.ol > li:first-child > .ol-item-container .ol-link {
    /* font-weight: 600; */
}

.ol ul {
    list-style: none;
    padding: 0;
    padding-left: 1.2rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    opacity: 0;
    pointer-events: none;
    border-left: 1px solid var(--border-color);
    margin-left: 1.1rem;
}

li.open > ul {
    max-height: 5000px;
    opacity: 1;
    pointer-events: auto;
}

li.open > .ol-item-container .ol-toggle {
    transform: rotate(90deg);
}

li.open > .ol-item-container .ol-toggle i::before {
    /* content: "\f282"; */ /* Chevron down if needed */
}

/* Rendering transition effects */
#pdf-container, #epub-container {
    transition: opacity 0.3s ease-in-out;
}

#pdf-container.rendering, #epub-container.rendering {
    opacity: 0.9;
}

.pdf-canvas {
    max-width: 100%;
    max-height: 100%;
    transition: transform 0.3s ease-out, opacity 0.3s ease-in-out;
}

/* PDF Area */
#pdf-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--viewer-content-bg);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

body[data-sidebar="open"] #pdf-container,
body[data-sidebar="open"] #epub-container {
    width: calc(100vw - var(--viewer-sidebar-height));
}

/* Ensure canvases scale to container height while keeping aspect ratio */
.pdf-canvas {
    height: 100%;
    width: auto;
}

/* EPUB Area */
#epub-container {
    --epub-max-size: 1100px;
    position: relative;
    width: min(90vw, var(--epub-max-size));
    height: 100%;
    background: var(--viewer-content-bg);
    margin: 0 auto;
    overflow: auto; /* hidden에서 auto로 변경하여 스크롤 허용 (scrolled 모드 대응) */
    -webkit-overflow-scrolling: touch;
    transition: opacity 0.4s ease-in-out;
    padding: 0;
}
#epub-container * {
    overflow-x: hidden !important;
}
#epub-container {
    opacity: 1;
}
body[data-sidebar="open"] #epub-container {
    width: calc(100vw - var(--viewer-sidebar-height));
    max-width: var(--epub-max-size);
}

/* 내부 iframe이 container를 벗어나지 못하게 함 */
#epub-container iframe {
    max-width: 100% !important;
    border: none !important;
}

/* epub.js 내부 레이아웃 제약 제거 (라이브러리 자체 계산에 맡김) */
#epub-container .epubjs-view,
#epub-container .epubjs-spread {
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
}

.epubjs-render {
    display: block !important;
}

.epubjs-manager {
    height: 100% !important;
}


.viewer-sidebar .book-info {
    padding: 1rem;
    gap: 1rem;
}

.viewer-sidebar .book-info .book-img img {
    height: 180px;
}

.viewer-sidebar .book-info .th {
    width: 100%;
}

.book-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.2rem;
}

.book-info .book-title-group {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-primary);
    background: var(--color-primary-light);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
}

.book-info .book-img {
    margin-top: 0.5rem;
    perspective: 1000px;
}

.book-info .book-img img {
    display: block;
    height: 220px;
    box-shadow: 0 15px 35px rgba(143, 69, 227, 0.2);
    border-radius: 6px;
    transition: transform 0.3s ease;
}

.book-info .book-img img:hover {
    transform: translateY(-5px) rotateY(-5deg);
}

.book-info .table {
    width: 100%;
    margin-top: 0.5rem;
}

.book-info .tr {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.6rem;
    background: var(--card-bg);
    border-radius: 0.8rem;
    width: 100%;
    transition: background-color 0.2s ease, transform 0.2s ease;
    border: 1px solid transparent;
}

.book-info .tr:hover {
    background: var(--hover-bg);
    transform: translateX(4px);
    border-color: var(--color-primary-light);
}

.book-info .th, .book-info .td {
    width: 100%;
    padding: 0.8rem 1rem;
    text-align: left;
    font-size: 0.95rem;
}

.book-info .th {
    padding-bottom: 0;
    flex-shrink: 0;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.book-info .td {
    flex: 1;
    font-weight: 600;
    color: var(--text-color);
}

.book-info .th i {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.book-info .tr:last-child {
    margin-bottom: 0;
}

.book-info .btn-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-primary);
    color: var(--viewer-content-bg) !important;
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s;
    width: 100%;
}

body[data-theme=dark]#viewer .book-info .btn-download {
    color: var(--viewer-bg) !important;
}

.book-info .btn-download:hover {
    filter: brightness(0.9);
}



body[data-theme=dark]#viewer .viewer-sidebar .book-info .book-img img {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}
/* Annotation Color Selection */
.annotation-color-tag {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
    display: inline-block;
}

.annotation-color-tag.color-dot-yellow { background-color: var(--color-yellow); }
.annotation-color-tag.color-dot-pink { background-color: var(--color-pink); }
.annotation-color-tag.color-dot-green { background-color: var(--color-green); }
.annotation-color-tag.color-dot-blue { background-color: var(--color-blue); }
.annotation-color-tag.color-dot-purple { background-color: var(--color-purple); }

.annotation-color-tag:hover {
    transform: scale(1.2);
}

.annotation-color-picker {
    display: none;
    position: absolute;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    padding: 4px;
    border-radius: 8px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    margin-top: 20px;
}

/* EPUB Annotation Cursor */
#epub-container .epubjs-annotation {
    cursor: pointer !important;
}

/* Floating Selection Menu */
.selection-menu {
    position: absolute;
    display: none;
    z-index: 10001;
    background: var(--footer-bg);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 0.5rem 1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    align-items: center;
    flex-direction: column;
    animation: fadeIn 0.15s ease;
}

.selection-menu::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--footer-bg);
}

.selection-menu.menu-bottom::after {
    top: -8px;
    bottom: auto;
    border-top: none;
    border-bottom: 8px solid var(--footer-bg);
}

.selection-colors, .memo-color-selection {
    display: flex;
    gap: 8px;
    padding: 0.75rem 0;
    justify-content: center;
}

.memo-color-selection {
    border-bottom: none;
    margin-bottom: 0;
    justify-content: flex-start;
}

.color-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.color-dot::after {
    content: "\f26e"; /* bi-check */
    font-family: "bootstrap-icons" !important;
    font-size: 1.2rem;
    color: white;
    opacity: 0;
    transition: opacity 0.2s;
}

.color-dot.active::after {
    opacity: 1;
}

/* 어두운 색상 도트에서는 체크 표시를 더 잘 보이게, 밝은 색상 도트에서는 그림자 추가 */
.color-dot.color-dot-yellow::after {
    color: rgba(0, 0, 0, 0.5);
}

.color-dot-mini {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.color-dot-mini::after {
    content: "\f26e"; /* bi-check */
    font-family: "bootstrap-icons" !important;
    font-size: 0.8rem;
    color: white;
    opacity: 0;
}

.color-dot-mini.active::after {
    opacity: 1;
}

.color-dot-mini.color-dot-yellow::after {
    color: rgba(0, 0, 0, 0.5);
}

.color-dot-mini:hover {
    transform: scale(1.2);
}

.color-dot.color-dot-yellow, .color-dot-mini.color-dot-yellow { background-color: var(--color-yellow); }
.color-dot.color-dot-pink, .color-dot-mini.color-dot-pink { background-color: var(--color-pink); }
.color-dot.color-dot-green, .color-dot-mini.color-dot-green { background-color: var(--color-green); }
.color-dot.color-dot-blue, .color-dot-mini.color-dot-blue { background-color: var(--color-blue); }
.color-dot.color-dot-purple, .color-dot-mini.color-dot-purple { background-color: var(--color-purple); }

.color-dot:hover {
    transform: scale(1.2);
}

.color-dot.active {
    border-color: var(--text-color);
    transform: scale(1.1);
}

.selection-actions {
    display: flex;
}

.selection-menu.pdf-mode #btn-add-highlight {
    display: none;
}

body[data-theme=dark]#viewer .selection-menu {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.selection-menu button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 4px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.selection-menu button:not(.color-dot):hover {
    background: var(--hover-bg);
    color: var(--color-primary);
}

.selection-menu button i {
    font-size: 1.1rem;
}

/* Viewer Modal System (Simple & Pretty) */
.viewer-modal {
    background: var(--sidebar-bg);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 450px;
    max-width: 90vw;
    display: none; /* Controlled by popup.js */
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.viewer-modal-header {
    padding: 1rem 1rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.viewer-modal-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-color);
}

.viewer-modal-header .btn-close {
    background: none;
    border: none;
    color: var(--text-color);
    opacity: 0.5;
    cursor: pointer;
    padding: 5px;
    font-size: 1.2rem;
    display: flex;
    transition: all 0.2s;
}

.viewer-modal-header .btn-close:hover {
    opacity: 1;
    color: var(--color-primary);
}

.viewer-modal-body {
    padding: 1rem;
}

.viewer-modal-footer {
    padding: 0 1rem 1rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
}

/* Memo Input Specific */
#memo_input_popup {
    width: 500px;
}

.memo-input-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#memo-text {
    width: 100%;
    min-height: 180px;
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--sidebar-bg);
    color: var(--text-color);
    font-family: inherit;
    resize: none;
    outline: none;
    font-size: 1rem;
    transition: border-color 0.2s;
}

#memo-text:focus {
    border-color: var(--color-primary);
}

/* Bookmark Input Specific */
.bookmark-input-container {
    display: flex;
    flex-direction: column;
}

.bookmark-input-container .input-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.bookmark-input-container label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    opacity: 0.7;
}

#bookmark-title {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--sidebar-bg);
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#bookmark-title:focus {
    border-color: var(--color-primary);
}

/* Confirm Modal Specific */
#viewer_confirm_popup {
    width: 360px;
}

.confirm-msg {
    font-size: 1.1rem;
    text-align: center;
    padding: 0.5rem 0;
    line-height: 1.5;
    color: var(--text-color);
    opacity: 0.9;
}

/* Button Refinement */
.btn-primary, .btn-secondary {
    padding: 0.6rem 1.5rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    border: none;
}

.btn-primary {
    background: var(--color-primary);
    color: white !important;
}

body[data-theme=dark]#viewer .btn-primary {
    color: #121212 !important;
}

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

.btn-primary:active, .btn-secondary:active {
    transform: scale(0.97);
}

.btn-primary:hover, .btn-secondary:hover {
    opacity: 0.9;
}

/* Override existing styles if any */
#memo_input_popup, #bookmark_input_popup, #viewer_confirm_popup {
    height: auto !important;
    max-height: 90vh !important;
}

.selected-text-preview {
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 10px;
    border-left: 4px solid var(--color-primary);
    font-style: italic;
    color: var(--text-color);
    opacity: 0.8;
    max-height: 120px;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Background overlay by popup.js styling */
.popup_visible .popup_wrapper {
    background: rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(4px);
}

/* Memo List Styling */
.memo-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.memo-item:hover {
    background-color: var(--hover-bg);
}

.memo-item .memo-header, .highlight-item .highlight-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #888;
}

.memo-item .memo-header .header-left, .highlight-item .highlight-header .header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.memo-item .memo-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.memo-item .memo-quote, .memo-item .memo-text, .highlight-item .highlight-text {
    border-left: 3px solid transparent;
    padding-left: 0.8rem;
}

.memo-item.color-yellow .memo-quote, .memo-item.color-yellow .memo-text, .highlight-item.color-yellow .highlight-text { border-left-color: var(--color-yellow); }
.memo-item.color-pink .memo-quote, .memo-item.color-pink .memo-text, .highlight-item.color-pink .highlight-text { border-left-color: var(--color-pink); }
.memo-item.color-green .memo-quote, .memo-item.color-green .memo-text, .highlight-item.color-green .highlight-text { border-left-color: var(--color-green); }
.memo-item.color-blue .memo-quote, .memo-item.color-blue .memo-text, .highlight-item.color-blue .highlight-text { border-left-color: var(--color-blue); }
.memo-item.color-purple .memo-quote, .memo-item.color-purple .memo-text, .highlight-item.color-purple .highlight-text { border-left-color: var(--color-purple); }

.memo-item .memo-text {
    font-weight: 400;
    color: var(--text-color);
    white-space: pre-wrap;
    line-height: 1.5;
    font-size: 0.95rem;
    padding: 0;
    border: none;
}

.memo-item .memo-quote {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    opacity: 0.7;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.memo-item .btn-delete-memo, .highlight-item .btn-delete-highlight {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
    font-size: 1.1rem;
}

.memo-item .btn-delete-memo:hover, .highlight-item .btn-delete-highlight:hover {
    opacity: 1;
}

/* Highlight List Styling */
.highlight-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.highlight-item:hover {
    background-color: var(--hover-bg);
}

.highlight-item .highlight-text {
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

/* Bookmark List Styling */
.bookmark-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.bookmark-item:hover {
    background-color: var(--hover-bg);
}

.bookmark-item .bookmark-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.bookmark-item .bookmark-title {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
}

.bookmark-item .bookmark-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.bookmark-item .btn-delete-bookmark {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 8px;
    opacity: 0.6;
    transition: all 0.2s;
    border-radius: 50%;
}

.bookmark-item .btn-delete-bookmark:hover {
    opacity: 1;
    background-color: rgba(231, 76, 60, 0.1);
}





/* Viewer Alert (Toast) */
.viewer-alert {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 110002;
    background: var(--header-bg);
    color: var(--text-color);
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    font-weight: 500;
}

.viewer-alert.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.viewer-alert i {
    color: var(--color-primary);
    font-size: 1.2rem;
}
.viewer-alert .alert-msg {
    font-size: 1rem;
}

.viewer-alert.success i { color: var(--success-color); }
.viewer-alert.error i { color: var(--danger-color); }
.viewer-alert.warning i { color: var(--warning-color); }
.viewer-alert.info i { color: var(--color-primary); }

body[data-theme=dark]#viewer .viewer-alert {
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
}

/* Sync Tab Styling */
.sync-info {
    padding: 1.5rem;
}

.sync-status-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background-color: var(--hover-bg);
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.sync-status-card .status-icon i {
    font-size: 2.5rem;
    color: var(--text-color);
    opacity: 0.5;
}

.sync-status-card .status-icon i.bi-person-check-fill {
    color: var(--color-primary);
    opacity: 1;
}

.sync-status-card .status-details {
    flex: 1;
}

.sync-status-card .status-label {
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.6;
    margin-bottom: 2px;
}

.sync-status-card .status-value {
    font-size: 1.1rem;
    font-weight: 600;
}

.sync-status-card .status-value.logged-in {
    color: var(--color-primary);
}

.sync-status-card .status-value.guest {
    color: var(--text-color);
}

.sync-actions {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sync-actions .last-sync {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    padding: 0 0.25rem;
}

.sync-actions .last-sync .label {
    opacity: 0.6;
}

.sync-actions .last-sync .value {
    font-weight: 500;
}

.sync-actions button {
    width: 100%;
    padding: 0.85rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
    transition: all 0.2s;
}

.sync-description {
    background-color: var(--hover-bg);
    padding: 1rem;
    border-radius: 8px;
    border-left: 3px solid var(--color-primary);
}

.sync-description p {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
    opacity: 0.8;
    color: var(--text-color);
}

/* Common Components for Sync Tab */
.btn-primary-outline {
    background: transparent;
    border: 1.5px solid var(--color-primary);
    color: var(--color-primary);
    cursor: pointer;
}

.btn-primary-outline:hover:not(:disabled) {
    background-color: var(--color-primary);
    color: #fff;
}

.btn-primary-outline:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: var(--text-color);
    color: var(--text-color);
}



.bi-spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}




/* Help Overlay (Coach Marks) */
.help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    z-index: 200000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: hidden;
    pointer-events: auto;
}

.help-overlay.show {
    display: block;
    opacity: 1;
}

.coach-mark-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.coach-mark-spot {
    position: absolute;
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
    z-index: 200001;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.coach-mark-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--footer-bg);
    color: var(--text-color);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 200002;
    width: 400px;
    max-width: 90%;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
}

.coach-mark-body .cm-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.coach-mark-body .cm-text {
    font-size: 0.9rem;
    line-height: 1.5;
    opacity: 0.9;
    margin: 0;
}

.coach-mark-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.cm-actions {
    display: flex;
    gap: 0.5rem;
}

.cm-steps {
    font-size: 0.8rem;
    opacity: 0.7;
}

#btn-cm-prev, #btn-cm-next {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

.coach-mark-content .btn-close-help {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-color);
    opacity: 0.5;
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
}

.coach-mark-content .btn-close-help:hover {
    opacity: 1;
}

/* Settings Tab Styles */
.settings-group {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.settings-group:last-child {
    border-bottom: none;
}

.settings-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-primary);
    text-transform: uppercase;
    margin-bottom: 1.2rem;
    letter-spacing: 0.05em;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    font-size: 0.95rem;
    color: var(--text-color);
    font-weight: 500;
}

.setting-item-vertical {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.setting-item-vertical:last-child {
    margin-bottom: 0;
}

.setting-item-vertical .label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.setting-item-vertical label {
    font-size: 0.95rem;
    color: var(--text-color);
    font-weight: 500;
}

.setting-item-vertical span {
    font-size: 0.85rem;
    color: var(--color-primary);
    font-weight: 600;
}

/* Adjustment Controls (+/- buttons with slider) */
.adjustment-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.adjustment-controls button {
    background: var(--sidebar-tab-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.adjustment-controls button:hover {
    background: var(--hover-bg);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.adjustment-controls input[type="range"] {
    flex: 1;
}

/* Button Group (View Mode, Text Align) */
.btn-group-sm {
    display: flex;
    background: var(--sidebar-tab-bg);
    padding: 2px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.btn-group-sm button {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-color);
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-group-sm button.active {
    background: var(--color-primary);
    color: white !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
body[data-theme=dark] .btn-group-sm button.active {
    color: #121212!important;
}
.btn-group-sm button i {
    font-size: 1.1rem;
}

/* Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--footer-bg);
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--color-primary);
}

body[data-theme=dark]#viewer input:checked + .slider {
    background-color: #8f45e3; /* 다크모드에서 체크 시 보라색 유지 */
}

body[data-theme=dark]#viewer input:checked + .slider:before {
    background-color: white;
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--color-primary);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Select & Range Styles */
#settings-font-family {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
}

#settings-font-size {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--progress-track-bg);
    border-radius: 5px;
    outline: none;
}

#settings-font-size::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

#settings-font-size::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: none;
}
.settings-action {
    margin-top: 2rem;
    padding: 0 0.5rem;
}

.settings-action button {
    padding: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(143, 69, 227, 0.2);
}

.w-100 {
    width: 100%;
}

@media (max-width: 1400px) {
    .viewer {
        --viewer-sidebar-height: 450px;
    }
}
@media (max-width: 1024px) {
    .viewer .viewer-header .viewer-title {
        display: none;
    }

    .viewer .viewer-sidebar {
        position: absolute;
        top: var(--viewer-header-height);
        right: 0;
        height: calc(100% - var(--viewer-header-height));
        width: 80%;
        max-width: 400px;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        transform: translateX(100%);
        margin-right: 0;
        transition: transform 0.3s ease;
    }

    body[data-sidebar="open"] .viewer .viewer-sidebar {
        transform: translateX(0) !important;
    }

    body[data-sidebar="open"] #epub-container {
        width: 90vw;
    }

    /* floating 시 배경 어둡게 처리 */
    .viewer-sidebar-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.3);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    body[data-sidebar="open"] .viewer-sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }

    /* EPUB-container custom padding */
    #epub-container {
        padding: 5vw;
        width: 90vw;
        height: 100%;
        box-shadow: none;
    }
}

@media (max-width: 767px) {
    .viewer .viewer-header .btn-list button {
        font-size: 1.25rem;
        width: 1.8rem;
        height: 1.8rem;
    }

    .ol-link {
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
        letter-spacing: -0.02em;
    }

    /* 전체 화면 보기 */
    #epub-container {
        padding: 0;
        width: 100vw;
    }

    /* Hide navigation arrows on mobile */
    .content-nav {
        display: none !important;
    }

    /* Book Info Popup */
    #book_info_popup {
        max-height: 80vh;
    }
    .book-info {
        gap: 1rem;
    }

    /* Hide navigation arrows on mobile */
    .content-nav {
        display: none !important;
    }

    body[data-sidebar="open"] #epub-container {
        width: 100vw;
    }

    .viewer-alert {
        width: fit-content;
        max-width: 90%;
        min-width: 200px;
    }

    .viewer-modal {
        width: 95vw !important;
        margin: 0 auto;
    }

    .viewer .viewer-footer .page-controls button {
        padding: 0.3rem 0.5rem;
    }
    .viewer .viewer-footer .page-controls {
        min-width: 160px !important;
        justify-content: flex-start;
    }
    .viewer .viewer-footer .page-controls .page-number {
        display: none;
    }

    .coach-mark-content {
        width: calc(100% - 40px);
        max-width: 320px;
    }

    /* Sync Info*/
    .sync-info {
        padding: 1rem;
    }

    .sync-status-card .status-icon i {
        font-size: 2rem;
    }

    .sync-actions .last-sync {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    #pdf-container {
        height: 100%;
        width: 100vw;
    }

    .pdf-canvas { height: auto}

    .viewer .viewer-header .viewer-logo span {
        display: none;
    }

    .viewer .viewer-sidebar .sidebar-tabs {
        width: 50px;
    }

    .viewer .viewer-sidebar .sidebar-tabs button {
        font-size: 0.7rem;
        padding: 0.8rem 0.2rem;
    }
    .viewer .viewer-sidebar .sidebar-tabs button i {
        font-size: 1.2rem;
    }

    /* Book Info Popup */
    #book_info_popup .modal-header h2 {
        font-size: 1.2rem;
    }
    .book-info .tr {
        flex-direction: column;
    }
    .book-info .book-img img {
        height: 180px;
    }
    .book-info .th, .book-info .td {
        padding: 0.6rem 0.8rem;
    }
    .book-info .th {
        width: 100%;
        padding-bottom: 0;
    }

    .viewer-alert .alert-msg {
        font-size: 0.9rem;
    }
}

/* RTL Support */
body.align_right {
    direction: rtl;
    text-align: right;
}

body.align_right .viewer .viewer-sidebar {
    margin-left: calc(var(--viewer-sidebar-height) * -1);
    margin-right: 0;
    border-left: none;
    border-right: solid 1px var(--border-color);
    transition: margin-left 0.3s ease;
}

body.align_right[data-sidebar="open"] .viewer-sidebar {
    margin-left: 0;
}

body.align_right .viewer .viewer-sidebar .sidebar-tabs {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

body.align_right .viewer .viewer-sidebar .sidebar-tabs button {
    border-left: none;
    border-right: 2px solid transparent;
}

body.align_right .viewer .viewer-sidebar .sidebar-tabs button.active {
    border-right-color: var(--color-primary);
    border-left-color: transparent;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
}

body.align_right[data-theme=dark]#viewer .viewer .viewer-sidebar .sidebar-tabs button.active {
    box-shadow: -2px 0 10px rgba(255, 255, 255, 0.1);
}

body.align_right .viewer .viewer-header .btn-list {
    margin-right: 2rem;
    margin-left: 0;
}

body.align_right .viewer-header .viewer-logo {
    margin-left: 2rem;
    margin-right: 0;
}

body.align_right .viewer-header .viewer-controls {
    left: auto;
    right: 20px;
}

body.align_right .viewer-header .btn-list {
    right: auto;
    left: 20px;
}

@media (max-width: 1024px) {
    body.align_right .viewer .viewer-sidebar {
        right: auto;
        left: 0;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        transform: translateX(-100%);
        margin-left: 0;
    }

    body.align_right[data-sidebar="open"] .viewer .viewer-sidebar {
        transform: translateX(0) !important;
    }
}

body.align_right .viewer-progress .page-progress {
    background-image: 
        linear-gradient(
            -45deg, 
            var(--progress-stripe) 25%, 
            transparent 25%, 
            transparent 50%, 
            var(--progress-stripe) 50%, 
            var(--progress-stripe) 75%, 
            transparent 75%, 
            transparent
        ),
        linear-gradient(to left, var(--color-primary) 0%, var(--color-primary) var(--progress, 0%), transparent var(--progress, 0%), transparent 100%);
}

body.align_right #settings-font-size {
    background: var(--progress-track-bg);
}

body.align_right .ol-link {
    text-align: right;
}

body.align_right .ol-item-container:has(.ol-toggle) .ol-link {
    padding-left: 1rem;
    padding-right: 0.4rem;
}

body.align_right .ol ul {
    padding-left: 0;
    padding-right: 1.2rem;
    border-left: none;
    border-right: 1px solid var(--border-color);
    margin-left: 0;
    margin-right: 1.1rem;
}

body.align_right .page-controls button i {
    transform: scaleX(-1);
}

body.align_right .viewer-footer {
    flex-direction: row-reverse;
}

body.align_right .content-nav-prev {
    left: auto;
    right: 20px;
}

body.align_right .content-nav-next {
    right: auto;
    left: 20px;
}

body.align_right .content-nav i {
    transform: scaleX(-1);
}

body.align_right .selection-menu {
    direction: rtl;
}

body.align_right .selection-menu button {
    flex-direction: row-reverse;
}

body.align_right .selection-colors {
    flex-direction: row-reverse;
}