/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #f5f5f5; /* 하얀 계열 배경 */
    color: #222; /* 텍스�?색상 어둡�?*/
    font-family: 'Pretendard', sans-serif;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Dark mode support */
html[data-theme="dark"] {
    background-color: #000;
    color: #fff;
}

/* Header */
.viewer-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    transition: transform 0.3s ease;
    border-bottom: 1px solid #eee;
}

html[data-theme="dark"] .viewer-header {
    background: rgba(0, 0, 0, 0.85);
    border-bottom: none;
}

.viewer-header.hidden {
    transform: translateY(-100%);
}

.vh-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #222;
    text-decoration: none;
    padding: 5px;
}

html[data-theme="dark"] .back-btn {
    color: #fff;
}

.vh-title-info {
    display: flex;
    flex-direction: column;
}

.vh-title-info h1 {
    font-size: 14px;
    font-weight: 500;
    color: #666;
    margin-bottom: 2px;
}

html[data-theme="dark"] .vh-title-info h1 {
    color: #aaa;
}

.vh-title-info p {
    font-size: 16px;
    font-weight: 600;
}

.page-count {
    background: #e0e0e0;
    color: #333;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
    margin-right: 6px;
}

html[data-theme="dark"] .page-count {
    background: #333;
    color: #fff;
}

.vh-right {
    display: flex;
    gap: 15px;
}

.icon-btn {
    background: none;
    border: none;
    color: #222;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

html[data-theme="dark"] .icon-btn {
    color: #fff;
}

/* Episode Dropdown */
.episode-dropdown {
    position: absolute;
    top: 40px;
    right: 0;
    width: 250px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: none;
    flex-direction: column;
    z-index: 1001;
}

.episode-dropdown.show {
    display: flex;
}

html[data-theme="dark"] .episode-dropdown {
    background: #222;
    border-color: #444;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.ed-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

html[data-theme="dark"] .ed-header {
    border-bottom-color: #444;
}

.ed-header h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: #222;
}

html[data-theme="dark"] .ed-header h3 {
    color: #eee;
}

.ed-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
}

.ed-list li {
    border-bottom: 1px solid #f5f5f5;
}

html[data-theme="dark"] .ed-list li {
    border-bottom-color: #333;
}

.ed-list a {
    display: block;
    padding: 12px 15px;
    color: #444;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}

html[data-theme="dark"] .ed-list a {
    color: #ccc;
}

.ed-list a:hover {
    background: #f9f9f9;
}

html[data-theme="dark"] .ed-list a:hover {
    background: #333;
}

.ed-list li.active a {
    color:var(--brand-text);
    font-weight: 700;
}

/* Desktop Navigation Arrows */
.nav-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: #c4c4c4b9; /* 기본적으�?투명하게 */
    border: none;
    color: #fff;
    width: 50px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 900;
    transition: background 0.2s;
}

.nav-arrow svg {
    /* opacity: 0.3; 비활�?시에�?약간 보이�?*/
    transition: opacity 0.2s;
}

.nav-arrow:hover {
    background: rgba(255, 0, 0, 0.4);
}

.nav-arrow:hover svg {
    opacity: 1;
}

.prev-arrow { left: 0; }
.next-arrow { right: 0; }

@media (max-width: 768px) {
    .nav-arrow { display: none; }
}

/* Content */
.viewer-content {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding-top: 60px; /* Header height */
    padding-bottom: 120px; /* Footer height */
}

.manga-image-container {
    max-width: 800px; /* PC에서 너무 넓지 않게 */
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.manga-page {
    width: 100%;
    height: auto;
    display: block;
}

.cs-input[hidden] { display: none; }
.bottom-menu a[aria-disabled="true"] { opacity: .4; cursor: not-allowed; }

/* Right Controls */
.right-controls {
    position: fixed;
    bottom: 90px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.right-controls.hidden {
    transform: translateX(150%);
}

.rc-btn {
    width: 56px;
    min-height: 60px;
    padding: 9px 4px;
    border-radius: 8px; /* 정방�?약간�?라운�? */
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    color: #222;
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.rc-btn svg {
    width: 20px; /* 아이�?사이�?축소 */
    height: 20px;
}
.rc-label { font-size: 14px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }

html[data-theme="dark"] .rc-btn {
    background: rgba(30, 30, 30, 0.8);
    border-color: #444;
    color: #fff;
}

.view-mode-toggles {
    display: flex;
    background: rgba(30, 30, 30, 0.8);
    border: 1px solid #444;
    border-radius: 20px;
    overflow: hidden;
    backdrop-filter: blur(5px);
}

.vm-btn {
    background: none;
    border: none;
    color: #888;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
}

.vm-btn.active {
    background: var(--brand-action);
    color: #fff;
}

.vm-btn.icon-only {
    padding: 8px;
    display: flex;
    align-items: center;
}
.vm-btn.icon-only svg {
    width: 16px;
    height: 16px;
}

/* Footer & Progress */
.viewer-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.viewer-footer.hidden {
    transform: translateY(100%);
}

.bottom-menu {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #eee;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 10px 20px;
    border-radius: 12px 12px;
    width: fit-content;
    margin: 0 auto;
    margin-bottom: 20px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

html[data-theme="dark"] .bottom-menu {
    background: #111;
    border: none;
    box-shadow: none;
}

.bm-btn {
    background: none;
    border: none;
    color: #666;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

html[data-theme="dark"] .bm-btn {
    color: #aaa;
}

.bm-btn:hover {
    background: #f0f0f0;
    color: #222;
}

html[data-theme="dark"] .bm-btn:hover {
    background: #222;
    color: #fff;
}

.bm-btn svg {
    width: 20px;
    height: 20px;
}

.progress-bar-container {
    width: 100%;
    height: 20px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    padding: 0 10px;
}

html[data-theme="dark"] .progress-bar-container {
    background: #000;
    border-top: none;
}

.progress-bar-wrap {
    flex: 1;
    height: 2px;
    background: #e0e0e0;
    position: relative;
}

html[data-theme="dark"] .progress-bar-wrap {
    background: #333;
}

.progress-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--brand-action);
}

.progress-text {
    font-size: 14px;
    color: #666;
    margin-left: 10px;
    width: 30px;
    text-align: right;
}

/* Comments Sidebar */
.comments-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 350px;
    height: 100vh;
    background: #fff;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    z-index: 2000;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

html[data-theme="dark"] .comments-sidebar {
    background: #1e1e1e;
    box-shadow: -2px 0 10px rgba(0,0,0,0.5);
}

.comments-sidebar.open {
    transform: translateX(0);
}

.cs-header {
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
}

html[data-theme="dark"] .cs-header {
    border-bottom-color: #333;
}

.cs-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #222;
}

html[data-theme="dark"] .cs-header h3 {
    color: #fff;
}

.cs-close {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

html[data-theme="dark"] .cs-close {
    color: #aaa;
}

.cs-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px;
}

.comment-item {
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

html[data-theme="dark"] .comment-item {
    border-bottom-color: #333;
}

.c-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.c-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.c-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: #f5f5f5;
}

.c-user {
    font-size: 14px;
    font-weight: 700;
    color: #222;
}

html[data-theme="dark"] .c-user {
    color: #ccc;
}

.c-time {
    font-size: 14px;
    color: #999;
}

.c-report-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color:var(--brand-text);
    font-size: 14px;
    cursor: pointer;
}

.c-text {
    font-size: 14px;
    color: #222;
    line-height: 1.5;
    margin-bottom: 12px;
    word-break: break-all;
}

html[data-theme="dark"] .c-text {
    color: #eee;
}

.c-footer {
    display: flex;
    align-items: center;
    gap: 15px;
}

.c-like-btn, .c-reply-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: #666;
    font-size: 14px;
    cursor: pointer;
}

html[data-theme="dark"] .c-like-btn, 
html[data-theme="dark"] .c-reply-btn {
    color: #999;
}

.c-reply-form {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-left: 10px;
    border-left: 2px solid #eee;
}

html[data-theme="dark"] .c-reply-form {
    border-left-color: #444;
}

.c-reply-form input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fafafa;
}

html[data-theme="dark"] .c-reply-form input {
    background: #2a2a2a;
    border-color: #444;
    color: #fff;
}

.c-reply-submit {
    background: #666;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0 12px;
    font-size: 14px;
    cursor: pointer;
}

html[data-theme="dark"] .c-reply-submit {
    background: #555;
}

.cs-input {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

html[data-theme="dark"] .cs-input {
    border-top-color: #333;
}

.cs-input input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    background: #f9f9f9;
}

html[data-theme="dark"] .cs-input input {
    background: #2a2a2a;
    border-color: #444;
    color: #fff;
}

.cs-input button {
    background: var(--brand-action);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 0 15px;
    font-weight: 600;
    cursor: pointer;
}

@media (max-width: 768px) {
    .comments-sidebar {
        width: 100%;
    }
}

/* Android viewer controls: larger targets, short feedback, safe-area spacing. */
html {
    -webkit-text-size-adjust: 100%;
}

html.motion-paused *,
html.motion-paused *::before,
html.motion-paused *::after {
    animation-play-state: paused !important;
}

@media (max-width: 768px), (hover: none), (pointer: coarse) {
    a[href],
    button,
    input,
    select,
    textarea,
    [role="button"],
    [role="tab"] {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    button,
    [role="button"],
    [role="tab"],
    .icon-btn,
    .bm-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .bottom-menu {
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
        transition-duration: 220ms !important;
    }

    .comments-sidebar,
    .episode-menu {
        transition-duration: 220ms !important;
    }

    .android-pressing {
        filter: brightness(0.96);
        transform: scale(0.98) !important;
        transition-duration: 80ms !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto !important;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
@media (max-width: 768px) {
    .viewer-header {
        padding: 0 10px;
        height: 50px;
    }
    .vh-title-info h1 {
        font-size: 14px;
    }
    .vh-title-info p {
        font-size: 14px;
    }
    .icon-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .right-controls {
        bottom: 100px;
        right: 10px;
    }
    
    .bottom-menu {
        width: 100%;
        border-radius: 0;
        margin-bottom: 0;
        justify-content: space-between;
        padding: 10px;
    }
    .bm-btn {
        flex-direction: column;
        gap: 4px;
        font-size: 14px;
        padding: 4px;
    }
    .bm-btn span {
        margin: 0;
    }
}
