html {
    scrollbar-gutter: stable;
}
:root {
    --bg-color: #ffffff;
    --text-main: #1a1a1a;
    --text-sub: #666666;
    --accent: #ed4d48;
    --border-light: #eeeeee;
    --border-strong: #d1d5db;
    --border-color: rgba(0,0,0,0.08);
}

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

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
}

/* --- Nav --- */
.navbar {
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1000;
    border-bottom: 1px solid var(--border-light);
    padding: 0 5%;
    justify-content: space-between;
}

.navbar-brand {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--text-main);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.btn-login {
    padding: 8px 20px;
    background-color: var(--text-main);
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 700;
}

.user-control-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.profile-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 50px;
    background: #f8f9fa;
}

.user-avatar {
    width: 26px;
    height: 26px;
    background: var(--text-main);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.user-id-text {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
}

/* --- Main Content --- */
.container {
    max-width: 1050px; /* 최대 열 5개를 수용하기 위해 너비 확장 */
    margin: 0 auto;
    /*padding: 50px 5%;*/
}

/* --- Public Header (Instagram Style) --- */
.public-header {
    display: flex;
    justify-content: center;
    margin-bottom: 44px;
    padding: 30px 20px 0 20px;
    border-bottom: none; /* 하단 선 제거 (인스타 스타일) */
    gap: 0;
}

/* 왼쪽 프로필 이미지 영역 */
.profile-left {
    flex: 1;
    display: flex;
    justify-content: end;
    margin-right: 30px;
}

.profile-image-container {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.profile-main-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 오른쪽 정보 영역 */
.profile-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ID 및 버튼 행 */
.profile-id-row {
    display: flex;
    align-items: center;
    gap: 20px;
}

.profile-username {
    font-size: 20px !important;
    font-weight: 700 !important;
    margin-bottom: 0 !important;
}

.btn-profile-edit {
    padding: 5px 16px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--border-strong);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
}

/* 통계 행 (게시물, 팔로워 등) */
.profile-stats-row {
    display: flex;
    gap: 40px;
}

.stat-item {
    font-size: 16px;
    color: var(--text-main);
}

.stat-count {
    font-weight: 600;
}

/* 소개글 행 */
.profile-bio-row {
    font-size: 14px;
    line-height: 1.5;
}

.bio-name {
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
}

.bio-text {
    color: var(--text-main) !important;
    font-size: 14px !important;
}

/* --- 모바일 대응 --- */
@media (max-width: 768px) {
    .public-header {
        padding-top: 20px;
        margin-bottom: 24px;
    }

    .profile-left {
        margin-right: 0;
    }

    .profile-image-container {
        width: 77px;
        height: 77px;
    }

    .profile-right {
        gap: 12px;
    }

    .profile-id-row {
        gap: 8px;
    }

    .profile-stats-row {
        gap: 20px;
    }

    .stat-item {
        font-size: 14px;
    }
}

/* --- Book Grid (핵심 수정 영역) --- */
.book-grid {
    display: grid;
    /* 최대 5개 유지, 화면이 줄어들면 자동으로 조절되지만 미디어쿼리로 최소 3개 보장 */
    grid-template-columns: repeat(4, 1fr);
    gap: 0; /* 책들 사이의 간격 제거 */
}

.book-item {
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s ease;
}
.book-item:hover {
    cursor:pointer;
}

.book-cover-wrapper {
    width: 100%;
    aspect-ratio: 2/3;
    border-radius: 0; /* radius 제거 */
    overflow: hidden;
    background-color: #f5f5f5;
    position: relative;
    border: 0.5px solid var(--border-light); /* 간격이 없을 때 경계 구분을 위해 얇은 선 추가 가능 */
}

.book-cover-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-info {
    text-align: left;
    padding: 10px 5px; /* 사진끼리 붙어있으므로 텍스트 가독성을 위한 패딩 */
}

.book-title {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    font-size: 0.8rem;
    color: var(--text-sub);
}

/* --- Badge --- */
.post-count-badge {
    position: absolute;
    top: 0;
    right: 12px;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.post-count-badge svg {
    color: rgb(255 255 255 / 90%);
    width: 28px;
    height: 32px;
}

.badge-number {
    position: absolute;
    top: 8px;
    color: #1a1a1a;
    font-size: 0.7rem;
    font-weight: 800;
    line-height: 1;
}

/* --- Responsive (그리드 제한) --- */
@media (max-width: 1024px) {
    .book-grid {
        grid-template-columns: repeat(4, 1fr); /* 태블릿 구간에서 4개 */
    }
}

@media (max-width: 768px) {
    .public-header h2 { font-size: 1.5rem; }

    body { background-colo: black;}

    .book-grid {
        grid-template-columns: repeat(3, 1fr); /* 화면이 작아져도 최소 3개 유지 */
    }

    .post-count-badge svg {
        width: 22px;
        height: 26px;
    }
    .badge-number {
        top: 6px;
        font-size: 0.6rem;
    }
}

footer {
    border-top: 1px solid var(--border-light);
    padding: 40px 5%;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-sub);
    margin-top: 80px;
}

/* 모달 전체 오버레이 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(15px); /* 고급스러운 블러 효과 */
    z-index: 2000;
    justify-content: center; align-items: center;
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 800px; /* 목차를 위해 너비 확장 */
    height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-close {
    position: absolute;
    right: 10px;
    z-index:100;
    background: none; border: none;
    color: black; font-size: 40px; cursor: pointer;
    opacity: 0.7; transition: opacity 0.2s;
}
.modal-close:hover { opacity: 1; }

/* 슬라이더 영역 */
.slider-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 4px;
}

.review-slider {
    display: flex;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    will-change: transform;
    cursor: grab; /* 잡기 커서 추가 */
    user-select: none; /* 드래그 중 텍스트 선택 방지 */
}

.review-slider:active {
    cursor: grabbing; /* 드래그 중 커서 변경 */
}

.slide-page {
    flex-shrink: 0;
    height: 100%;
    display: flex;
    justify-content: center;
    padding: 0; /* 여백 제거하여 종이가 꽉 차게 */
}

.a4-paper {
    background: white;
    width: 100%;
    height: 100%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    padding: 60px 80px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 첫 페이지 (표지 + 목차) */
.cover-page {
    flex-direction: row !important; /* 가로 배치 */
    align-items: stretch !important;
    padding: 0 !important;
}

.cover-left {
    flex: 4;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    border-right: 1px solid #eee;
}

.cover-left img {
    max-width: 100%;
    max-height: 80%;
    box-shadow: 10px 10px 30px rgba(0,0,0,0.2);
    border-radius: 2px;
}

.cover-right {
    flex: 6;
    padding: 60px 50px;
    display: flex;
    flex-direction: column;
}

.index-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px;
}

.review-index-list {
    list-style: none;
    margin-top: 10px;
}

.index-item {
    padding: 15px 0;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.index-number {
    font-size: 0.8rem;
    font-weight: 700;
    color: #ccc;
    font-family: serif;
}

.index-title {
    font-size: 1.05rem;
    font-weight: 600;
}

/* 독후감 본문 페이지 */
.review-page h2 {
    font-size: 1.2rem;
    font-weight: 900;
    letter-spacing: -1px;
    color: var(--text-main);
}
.title-container {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.1rem;
    padding-bottom: 1.1rem;
}
.title-char {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    color: var(--accent);
    opacity: 0.8;
    margin-bottom: -4px;
}

.review-text {
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
    color: #2c2c2c;
    text-align: justify;
    word-break: break-all;
}

/* 슬라이드 버튼 (가시성 대폭 강화) */
.slide-prev, .slide-next {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.3); /* 배경을 살짝 투명하게 */
    backdrop-filter: blur(5px);
    color: white; border: none;
    width: 50px; height: 50px; border-radius: 50%;
    cursor: pointer; font-size: 20px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2100;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.slide-prev:hover, .slide-next:hover { 
    background: var(--text-main);
    transform: translateY(-50%) scale(1.1);
}

.slide-prev { left: 20px; } /* 안쪽으로 이동 */
.slide-next { right: 20px; }

.slide-prev { left: 10px; }
.slide-next { right: 10px; }
.slide-prev, .slide-next { background: rgba(0,0,0,0.2); width: 40px; height: 40px; }

/* 페이지 표시 (숫자) */
.slide-pagination {
    position: absolute;
    bottom: -40px; left: 50%; transform: translateX(-50%);
    color: rgba(255,255,255,0.6); font-size: 13px; font-weight: 700;
}

/* 도트 인디케이터 추가 */
.slide-dots {
    position: absolute;
    bottom: 25px; left: 50%; transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 2100;
    pointer-events: none; /* 클릭은 안 되게 */
}

.dot {
    width: 6px;
    height: 6px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.dot.active {
    background: var(--accent);
    transform: scale(1.3);
}

@media (max-width: 768px) {
    .modal-content { width: 95%; height: 85vh; }
    .cover-page { flex-direction: column !important; overflow-y: auto; }
    .cover-left { flex: none; height: 40%; padding: 20px; border-right: none; border-bottom: 1px solid #eee; }
    .cover-right { flex: none; padding: 30px 25px; }
    .a4-paper { padding: 40px 30px; }

}
    /* 배경색 효과를 위해 relative와 overflow hidden 설정 */
        .cover-left {
            position: relative;
            overflow: hidden;
            z-index: 1;
        }

        /* 책 표지 기반 블러 배경 생성 */
        .cover-left::before {
            content: "";
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            background-image: var(--book-cover-url); /* JS에서 넣어줄 변수 */
            background-size: cover;
            background-position: center;
            filter: blur(30px) brightness(0.8); /* 블러와 밝기 조절 */
            transform: scale(1.2);
            opacity: 0.6;
            z-index: -1; /* 이미지 뒤로 보냄 */
        }

        /* --- 모달 내 유저 프로필 디자인 --- */
        .user-profile-info {
            display: flex;
            flex-direction: column;
            margin-bottom: 20px;
        }

        .profile-display-name {
            font-size: 1.4rem;
            font-weight: 900;
            color: var(--text-main);
            letter-spacing: -0.5px;
            line-height: 1.2;
        }

        .profile-display-id {
            font-size: 0.95rem;
            font-weight: 500;
            color: var(--text-sub);
            margin-top: 4px;
            opacity: 0.8;
        }

        /* 유저 정보와 목차 사이의 얇은 구분선 */
        .index-divider {
            width: 40px;
            height: 3px;
            background-color: var(--text-main);
            margin-bottom: 25px;
            border-radius: 2px;
        }

        /* 목차 리스트 정렬 조절 */
        .review-index-list {
            margin-top: 0;
        }

        .index-item {
            padding: 12px 0; /* 조금 더 촘촘하게 조절 */
        }