:root {
    --bg-color: #fdfaf5;
    --text-main: #3d2b1f;
    --text-muted: #8c7b6c;
    --accent-color: #a67b5b;
    --accent-hover: #8b6241;
    --white: #ffffff;
    --font-serif: 'Noto Serif KR', serif;
    --font-sans: 'Noto Sans KR', sans-serif;
    --font-display: 'Playfair Display', serif;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    word-break: keep-all;
    overflow-wrap: break-word;
}

* {
    box-sizing: border-box;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    padding: 40px 0;
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand h1 {
    font-family: var(--font-display);
    font-size: 2.8rem;
    margin: 0;
    color: var(--accent-color);
}

.subtitle {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.auth-box .btn-login-google {
    background: white;
    border: 1px solid #ddd;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.auth-box .btn-login-google:hover {
    background: #f8f8f8;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.user-profile-nav {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-nickname {
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

.btn-logout-small {
    background: none;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

/* Banner */
.banner {
    background: linear-gradient(135deg, #a67b5b 0%, #8b6241 100%);
    color: white;
    padding: 80px 60px;
    border-radius: 32px;
    margin-bottom: 60px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
    position: relative;
    overflow: hidden;
}

.banner::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    z-index: 0;
}

.banner-content {
    flex: 1;
    z-index: 1;
}

.banner-content h1 {
    font-family: var(--font-serif);
    font-size: 3rem;
    margin: 0 0 15px;
    letter-spacing: -1px;
}

.banner-content p {
    font-size: 1.3rem;
    opacity: 0.95;
    margin: 0;
}

.banner-books {
    flex: 1.5;
    display: flex;
    gap: 40px;
    justify-content: flex-end;
    align-items: center;
    position: relative;
    min-height: 250px;
}

.banner-empty-state {
    text-align: center;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    padding: 30px 45px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 100%;
}

.banner-empty-state p {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    margin: 0 0 8px;
    font-weight: 600;
}

.banner-empty-state span {
    font-size: 1rem;
    opacity: 0.85;
}

.banner-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.banner-item:hover {
    transform: translateY(-15px) scale(1.08);
}

.banner-book-img {
    height: 220px;
    width: auto;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 15px 25px 40px rgba(0, 0, 0, 0.4);
}

.banner-book-info {
    margin-top: 15px;
    text-align: center;
}

.banner-book-title {
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0.9;
    display: block;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-badge,
.pick-badge {
    position: absolute;
    top: -10px;
    left: -10px;
    background: var(--banner-bg);
    color: #fff;
    width: auto;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 2;
    font-family: var(--font-serif);
}

.pick-badge {
    background: var(--accent-color);
}

/* Action Section */
.action-section {
    text-align: center;
    margin-bottom: 60px;
}

.btn-register {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(166, 123, 91, 0.3);
    transition: all 0.2s;
}

.btn-register:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

/* Feed Grid */
/* Feed Tabs & Header */
.feed-header {
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.feed-tabs {
    display: flex;
    gap: 15px;
    border-bottom: 2px solid #f0e6d6;
    padding-bottom: 5px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 20px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #a0937d;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.tab-btn:hover {
    color: var(--accent-color);
}

.tab-btn.active {
    color: var(--accent-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--accent-color);
    border-radius: 2px;
}

.library-info {
    background: #fff;
    padding: 20px 25px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-subtle);
    border-left: 5px solid var(--accent-color);
    animation: fadeInDown 0.5s ease-out;
}

.library-info h2 {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    color: var(--text-dark);
    margin: 0;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.feed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 25px;
    padding-bottom: 100px;
}

.book-card {
    background: white;
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.book-card:hover {
    transform: translateY(-5px);
}

.book-cover {
    width: 100%;
    aspect-ratio: 2 / 3;
    margin-bottom: 15px;
}

.book-info h3 {
    font-size: 1.1rem;
    margin: 0 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.book-meta {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.user-name {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-tag {
    background: #f0ebe5;
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--accent-color);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 10px;
    z-index: 1000;
    overflow-y: auto;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 550px;
    padding: 30px;
    border-radius: 20px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    animation: modalSlideUp 0.3s ease-out;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    margin-bottom: 25px;
    position: relative;
}

.detail-comment p.no-comment {
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.7;
    word-break: keep-all;
}

.modal-header h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--text-main);
    margin: 0;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #f5f5f5;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s;
    z-index: 10;
}

.close-modal:hover {
    background: #eee;
    color: var(--text-main);
    transform: rotate(90deg);
}

.search-box {
    display: flex;
    gap: 10px;
    background: #f1f1f1;
    padding: 8px 8px 8px 20px;
    border-radius: 40px;
    margin-bottom: 30px;
    transition: all 0.2s;
}

.search-box:focus-within {
    background: #eee;
    box-shadow: 0 0 0 2px rgba(166, 123, 91, 0.2);
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    font-size: 1rem;
    padding: 10px 0;
    outline: none;
    color: var(--text-main);
}

.btn-search {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-search:hover {
    background: var(--accent-hover);
}

.btn-primary {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(166, 123, 91, 0.3);
}

.btn-secondary {
    background: #f5f5f5;
    color: var(--text-muted);
    border: 1px solid #ddd;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #eee;
    color: var(--text-main);
    border-color: #ccc;
}

#search-results {
    max-height: 350px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid #f5f5f5;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #fdfaf5;
    transform: translateX(5px);
}

.search-result-item img {
    width: 60px;
    height: 90px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.result-info {
    flex: 1;
    min-width: 0;
}

.result-info h4 {
    margin: 0 0 5px;
    font-size: 1.05rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-info p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.search-hint {
    font-size: 0.9rem;
    color: var(--accent-color);
    margin-bottom: 20px;
    text-align: center;
    font-weight: 500;
}

/* Admin Persona Section */
#admin-only-section {
    background: #fdf2e9;
    padding: 15px;
    border-radius: 12px;
    border-left: 4px solid var(--accent-color);
    margin-top: 20px;
}

#admin-author-input {
    transition: border-color 0.2s, box-shadow 0.2s;
}

#admin-author-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(166, 123, 91, 0.1);
}


/* Modal Footer */
.modal-footer {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.modal-footer button {
    flex: 1;
}

#book-comment {
    width: 100%;
    height: 180px;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 16px;
    background: #fafafa;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    transition: all 0.2s;
    margin-top: 15px;
}

#book-comment:focus {
    background: white;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(166, 123, 91, 0.1);
}

.char-counter {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Responsive */
@media (max-width: 1024px) {
    .banner-content h1 {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    header {
        padding: 25px 0;
    }

    .brand h1 {
        font-size: 2.2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    /* Banner Mobile */
    .banner {
        flex-direction: column;
        padding: 40px 20px;
        text-align: center;
        gap: 30px;
        margin-bottom: 40px;
    }

    .banner-content h1 {
        font-size: 1.6rem;
        /* ~24px to 26px */
        margin-bottom: 10px;
    }

    .banner-content p {
        font-size: 1.1rem;
    }

    .banner-books {
        justify-content: flex-start;
        width: calc(100% + 40px);
        margin: 0 -20px;
        padding: 10px 20px;
        gap: 15px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }

    /* Hide scrollbar for banner-books */
    .banner-books::-webkit-scrollbar {
        display: none;
    }

    .banner-books {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .banner-item {
        flex: 0 0 130px;
    }

    .banner-book-img {
        height: 180px;
    }

    .rank-badge {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        top: -10px;
        left: -10px;
    }

    /* Feed Grid Mobile (2 Columns) */
    .feed-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .book-card {
        padding: 10px;
        border-radius: 12px;
    }

    .book-info h3 {
        font-size: 0.95rem;
        margin-bottom: 8px;
    }

    /* Bestseller Section Mobile */
    .bestseller-section {
        padding: 60px 0;
    }

    .bestseller-section .section-header h2 {
        font-size: 1.5rem;
        margin-bottom: 30px;
        padding: 0 10px;
    }

    .bestseller-slider-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 20px;
        margin: 0 -15px;
        /* Offset container padding to allow edge-to-edge scroll */
        padding-left: 15px;
        padding-right: 15px;
    }

    .bestseller-list-wrapper {
        overflow: visible;
        /* Prevent clipping that blocks parent scroll */
    }

    /* Hide nav buttons on mobile */
    .carousel-nav-btn {
        display: none;
    }

    .bestseller-slider {
        gap: 15px;
        transition: none !important;
        /* Disable JS transition for native swipe */
        transform: none !important;
    }
}

/* Load More Button (Global) */
.load-more-container {
    display: flex;
    justify-content: center;
    margin-top: 40px;
    margin-bottom: 60px;
}

.btn-load-more {
    width: 100%;
    max-width: 400px;
    padding: 16px 0;
    background-color: #f0ebe5;
    color: #5d4037;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.btn-load-more:hover {
    background-color: #e5dfd8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-load-more:active {
    transform: translateY(0);
}

.btn-load-more:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #f5f5f5;
}

/* Detail Modal Specifics */
.detail-modal-content {
    padding: 0;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) transparent;
}

/* Custom Scrollbar for Detail Modal */
.detail-modal-content::-webkit-scrollbar {
    width: 6px;
}

.detail-modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.detail-modal-content::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 10px;
    border: 2px solid transparent;
}

.detail-header {
    display: flex;
    gap: 25px;
    padding: 30px;
    background: #fdfaf5;
    border-bottom: 1px solid #eee;
}

.detail-cover {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    background: #f8f8f8;
}

.detail-cover img {
    max-width: 100%;
    max-height: 50vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.detail-meta {
    flex: 1;
    position: relative;
    text-align: left;
}

.detail-meta h2 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    margin: 0 0 10px;
    color: var(--text-main);
    padding-right: 80px;
    /* Space for admin buttons */
    line-height: 1.3;
}

.detail-author {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 15px;
}

.detail-user {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: var(--accent-color);
}

.detail-body-inner {
    padding: 30px;
}

.detail-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.detail-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.detail-comment-body {
    background: #fdfaf5;
    padding: 20px;
    border-radius: 12px;
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-main);
    white-space: pre-wrap;
    word-break: keep-all;
    overflow-wrap: break-word;
}

.detail-comment {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 12px;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--bg-cream);
    word-break: keep-all;
    overflow-wrap: break-word;
}

@media (max-width: 480px) {
    .detail-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 25px 20px;
        gap: 15px;
    }

    .detail-cover {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }

    .detail-meta h2 {
        font-size: 1.3rem;
    }

    .detail-body-inner {
        padding: 20px;
    }

    .detail-comment {
        font-size: 0.95rem;
        padding: 15px;
    }
}



.btn-load-more:hover {
    background-color: #e5dfd8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-load-more:active {
    transform: translateY(0);
}

.btn-load-more:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #f5f5f5;
}

.modal-content {
    padding: 30px 20px;
}

@media (max-width: 480px) {
    .brand h1 {
        font-size: 1.8rem;
    }

    .banner-content h1 {
        font-size: 1.4rem;
    }

    .feed-grid {
        gap: 10px;
    }
}