/* ========================================
   FULL-SCREEN SCRIPTURE LIBRARY
   Buddha Korea - AI Chatbot
   Premium Edition - Matching Main Page
   ======================================== */

/* ===== CSS Variables (Sync with main page) ===== */
.library-overlay {
    /* Colors - Sage Green (matching main site) */
    --primary: #5A9A6E;
    --primary-light: #8CB89C;
    --secondary: #A3C9AE;
    --accent: #B8D4C2;
    --gold: #5A9A6E;
    --bg-dark: #FFFFFF;
    --bg-medium: #F8FAF8;
    --bg-light: #E8F0EB;
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(90, 154, 110, 0.2);
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-muted: #86868b;
}

/* ===== OVERLAY CONTAINER ===== */

.library-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.library-overlay.active {
    display: flex;
    flex-direction: column;
    opacity: 1;
}

/* Backdrop with Ambient Orbs */
.library-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-medium) 100%);
    cursor: pointer;
    z-index: 1;
    overflow: hidden;
}

/* Ambient Orb Effects */
.library-backdrop::before,
.library-backdrop::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    animation: libraryFloat 30s ease-in-out infinite;
}

.library-backdrop::before {
    width: 500px;
    height: 500px;
    background: var(--primary);
    top: -200px;
    right: -100px;
    opacity: 0.12;
}

.library-backdrop::after {
    width: 400px;
    height: 400px;
    background: var(--secondary);
    bottom: -150px;
    left: -100px;
    opacity: 0.1;
    animation-delay: -15s;
}

@keyframes libraryFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -20px) scale(1.05); }
    50% { transform: translate(-20px, 30px) scale(0.95); }
    75% { transform: translate(-30px, -15px) scale(1.02); }
}

/* Main Container */
.library-container {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    pointer-events: none;
}

.library-container > * {
    pointer-events: auto;
}

/* ===== HEADER SECTION ===== */

.library-header {
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.98) 0%,
        rgba(248, 250, 248, 0.95) 100%);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--glass-border);
    padding: 24px 32px;
    animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

/* Subtle gradient glow at header bottom */
.library-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--primary) 30%,
        var(--secondary) 70%,
        transparent 100%);
    opacity: 0.5;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.library-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.library-header h2 {
    font-size: 24px;
    font-weight: 600;
    background: linear-gradient(90deg, #5A9A6E, #8CB89C);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.library-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(90, 154, 110, 0.1);
    border: 1px solid rgba(90, 154, 110, 0.2);
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.library-close:hover {
    background: rgba(90, 154, 110, 0.2);
    transform: rotate(90deg);
}

.library-close:active {
    transform: rotate(90deg) scale(0.95);
}

/* ===== SEARCH BAR ===== */

.library-search-bar {
    margin-bottom: 16px;
    position: relative;
}

.library-search-bar input {
    width: 100%;
    padding: 16px 24px;
    padding-left: 48px;
    font-size: 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Pretendard Variable', -apple-system, BlinkMacSystemFont, sans-serif;
}

.library-search-bar::before {
    content: '🔍';
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    opacity: 0.5;
    pointer-events: none;
    z-index: 1;
}

.library-search-bar input::placeholder {
    color: var(--text-muted);
}

.library-search-bar input:focus {
    border-color: var(--primary);
    background: #FFFFFF;
    box-shadow: 0 0 0 4px rgba(90, 154, 110, 0.12),
                0 4px 20px rgba(90, 154, 110, 0.15);
}

/* ===== FILTERS ROW ===== */

.library-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.library-filters select {
    flex: 1;
    min-width: 200px;
    padding: 12px 18px;
    background: var(--glass-bg);
    border: 1px solid rgba(90, 154, 110, 0.35);
    border-radius: 100px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Pretendard Variable', -apple-system, BlinkMacSystemFont, sans-serif;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235A9A6E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.library-filters select option {
    background: var(--bg-medium);
    color: var(--text-primary);
    padding: 12px;
}

.library-filters select:hover {
    background: rgba(90, 154, 110, 0.08);
    border-color: var(--primary);
}

.library-filters select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(90, 154, 110, 0.12);
}

.filter-reset-btn {
    padding: 12px 24px;
    background: transparent;
    border: 1px solid rgba(218, 165, 32, 0.4);
    border-radius: 100px;
    color: var(--gold);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Pretendard Variable', -apple-system, BlinkMacSystemFont, sans-serif;
}

.filter-reset-btn:hover {
    background: rgba(218, 165, 32, 0.15);
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(218, 165, 32, 0.2);
}

.filter-reset-btn:active {
    transform: translateY(0);
}

/* ===== FILTER BADGES ===== */

.library-filter-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 0;
    margin-bottom: 12px;
}

.library-filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(90, 154, 110, 0.15);
    border: 1px solid rgba(90, 154, 110, 0.3);
    border-radius: 16px;
    color: #5A9A6E;
    font-size: 12px;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.library-filter-badge button {
    background: none;
    border: none;
    color: inherit;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.library-filter-badge button:hover {
    background: rgba(90, 154, 110, 0.15);
}

/* ===== RESULTS COUNT ===== */

.library-results-count {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
}

.library-results-count span {
    font-weight: 600;
    color: var(--primary);
}

/* ===== LOADING STATE ===== */

.library-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(90, 154, 110, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

/* ===== EMPTY STATE ===== */

.library-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-muted);
    text-align: center;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.library-empty h3 {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.library-empty p {
    font-size: 14px;
    color: var(--text-muted);
}

/* ===== SCRIPTURE CARDS GRID ===== */

.library-grid {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    align-content: start;
    align-items: stretch;
    animation: fadeInUp 0.4s ease-out;
}

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

/* Custom scrollbar for grid */
.library-grid::-webkit-scrollbar {
    width: 8px;
}

.library-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.library-grid::-webkit-scrollbar-thumb {
    background: rgba(90, 154, 110, 0.3);
    border-radius: 4px;
}

.library-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(90, 154, 110, 0.5);
}

/* ===== SCRIPTURE CARD ===== */

.library-card {
    background: #FFFFFF;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(90, 154, 110, 0.15);
    border-radius: 20px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    min-height: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Top gradient line */
.library-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    opacity: 0;
    transition: opacity 0.4s ease;
}

/* Ambient glow effect */
.library-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        ellipse at center,
        rgba(90, 154, 110, 0.08) 0%,
        transparent 60%
    );
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.library-card:hover {
    transform: translateY(-6px);
    border-color: rgba(90, 154, 110, 0.4);
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.1),
        0 0 40px rgba(90, 154, 110, 0.1),
        inset 0 0 20px rgba(90, 154, 110, 0.03);
    background: #F8FAF8;
}

.library-card:hover::before {
    opacity: 1;
}

.library-card:hover::after {
    opacity: 1;
}

.library-card:active {
    transform: translateY(-3px);
}

.library-card:focus {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

/* Card Content */
.library-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
    line-height: 1.4;
    letter-spacing: -0.01em;
    transition: color 0.3s ease;
}

.library-card:hover .library-card-title {
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.library-card-summary {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0 0 16px 0;
    flex: 1;
}

/* Card Footer */
.library-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(90, 154, 110, 0.1);
}

.library-card-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

/* Card Ask Button */
.library-card-ask-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 100px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
    font-family: inherit;
    box-shadow: 0 2px 10px rgba(90, 154, 110, 0.3);
    position: relative;
    z-index: 2;
}

.library-card-ask-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 20px rgba(90, 154, 110, 0.5);
}

.library-card-ask-btn:active {
    transform: translateY(0) scale(0.98);
}

.library-card-ask-btn svg {
    flex-shrink: 0;
}

.library-card-tag {
    padding: 6px 14px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    font-size: 11px;
    color: var(--primary-light);
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.library-card-tag.tradition {
    background: rgba(90, 154, 110, 0.1);
    border-color: rgba(90, 154, 110, 0.25);
    color: #5A9A6E;
}

.library-card-tag.period {
    background: rgba(155, 235, 180, 0.08);
    border-color: rgba(155, 235, 180, 0.2);
    color: var(--accent);
}

.library-card:hover .library-card-tag {
    border-color: rgba(90, 154, 110, 0.35);
}

/* Scroll sentinel for infinite scroll */
#scrollSentinel {
    height: 1px;
    width: 100%;
}

/* Memory warning banner */
.library-memory-warning {
    background: rgba(218, 165, 32, 0.15);
    border: 1px solid rgba(218, 165, 32, 0.3);
    border-radius: 12px;
    padding: 12px 20px;
    margin: 0 32px 16px;
    color: #DAA520;
    font-size: 13px;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

/* ===== SKELETON LOADING ===== */

.library-card.skeleton {
    pointer-events: none;
    cursor: default;
}

.library-card.skeleton::before {
    display: none;
}

.skeleton-title,
.skeleton-text,
.skeleton-tag {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.06) 25%,
        rgba(255, 255, 255, 0.12) 50%,
        rgba(255, 255, 255, 0.06) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

.skeleton-title {
    height: 24px;
    width: 70%;
    margin-bottom: 16px;
}

.skeleton-text {
    height: 14px;
    width: 100%;
    margin-bottom: 8px;
}

.skeleton-text.short {
    width: 60%;
    margin-bottom: 20px;
}

.skeleton-tags {
    display: flex;
    gap: 8px;
}

.skeleton-tag {
    height: 24px;
    width: 60px;
    border-radius: 12px;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ===== HEADER TRIGGER BUTTON ===== */

.library-header-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #5A9A6E, #8CB89C);
    border: none;
    border-radius: 24px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(90, 154, 110, 0.3);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
}

.library-header-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(90, 154, 110, 0.4);
}

.library-header-btn:active {
    transform: translateY(0);
}

/* ===== RESPONSIVE DESIGN ===== */

@media (max-width: 768px) {
    .library-header {
        padding: 20px 16px;
    }

    .library-header h2 {
        font-size: 20px;
    }

    .library-filters {
        flex-direction: column;
    }

    .library-filters select,
    .filter-reset-btn {
        min-width: 100%;
    }

    .library-grid {
        padding: 20px 16px;
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .library-card {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .library-header {
        padding: 16px 12px;
    }

    .library-header h2 {
        font-size: 18px;
    }

    .library-search-bar input {
        font-size: 14px;
        padding: 12px 16px;
    }

    .library-grid {
        padding: 16px 12px;
    }
}

/* ===== ACCESSIBILITY ===== */

/* Focus styles for keyboard navigation */
.library-close:focus-visible,
.library-search-bar input:focus-visible,
.library-filters select:focus-visible,
.filter-reset-btn:focus-visible,
.library-card:focus-visible,
.library-header-btn:focus-visible {
    outline: 3px solid rgba(90, 154, 110, 0.6);
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .library-overlay,
    .library-card,
    .library-close,
    .library-search-bar input,
    .filter-reset-btn,
    .library-header-btn {
        transition-duration: 0.1s;
    }

    @keyframes slideDown,
    @keyframes fadeInUp,
    @keyframes fadeIn {
        from { opacity: 0.5; }
        to { opacity: 1; }
    }

    .loading-spinner {
        animation-duration: 2s;
    }

    .library-card:hover {
        transform: none;
    }

    .library-card::before {
        display: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .library-overlay {
        background: rgba(0, 0, 0, 0.95);
    }

    .library-card {
        border-width: 2px;
    }
}

/* ===== SOURCE DETAIL MODAL ===== */

.source-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.source-modal.active {
    opacity: 1;
    visibility: visible;
}

.source-modal-content {
    position: relative;
    width: 90%;
    max-width: 720px;
    max-height: 85vh;
    background: linear-gradient(145deg,
        rgba(255, 255, 255, 0.98),
        rgba(248, 250, 248, 0.98));
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow:
        0 32px 100px rgba(0, 0, 0, 0.7),
        0 0 60px rgba(90, 154, 110, 0.08),
        inset 0 0 30px rgba(255, 255, 255, 0.02);
    overflow: hidden;
    transform: translateY(30px) scale(0.97);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.source-modal.active .source-modal-content {
    transform: translateY(0) scale(1);
}

/* Modal Navigation Buttons */
.modal-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(90, 154, 110, 0.15);
    border: 1px solid rgba(90, 154, 110, 0.3);
    color: #5A9A6E;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.modal-nav-btn:hover:not(:disabled) {
    background: rgba(90, 154, 110, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.modal-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.modal-nav-btn.prev {
    left: -60px;
}

.modal-nav-btn.next {
    right: -60px;
}

/* Modal Scroll Wrapper */
.modal-scroll-wrapper {
    max-height: 85vh;
    overflow-y: auto;
    padding: 32px;
}

/* Modal Header */
.modal-header {
    position: relative;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 28px;
}

.modal-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, var(--primary), transparent);
    opacity: 0.5;
}

.modal-close-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--primary);
    font-size: 22px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    background: rgba(90, 154, 110, 0.15);
    border-color: var(--primary);
    transform: rotate(90deg);
}

.modal-header h3 {
    font-size: 1.6rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 10px 0;
    padding-right: 52px;
    line-height: 1.3;
}

.modal-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
}

/* Ask about this sutra button */
.modal-ask-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 100px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: inherit;
    box-shadow: 0 4px 20px rgba(90, 154, 110, 0.35);
}

.modal-ask-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 30px rgba(90, 154, 110, 0.5);
}

.modal-ask-btn:active {
    transform: translateY(0) scale(0.98);
}

.modal-ask-btn svg {
    flex-shrink: 0;
}

/* Modal Body */
.modal-body {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.modal-section {
    padding: 0;
}

.modal-section h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0 0 14px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-section p {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    margin: 0;
    white-space: pre-wrap;
}

/* Modal Theme Tags */
.modal-themes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.modal-theme-tag {
    display: inline-block;
    padding: 8px 18px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    font-size: 0.85rem;
    color: var(--primary-light);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: default;
}

.modal-theme-tag:hover {
    background: rgba(90, 154, 110, 0.12);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(90, 154, 110, 0.15);
}

.modal-no-themes {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

/* Modal Mobile Responsive */
@media (max-width: 900px) {
    .modal-nav-btn.prev {
        left: 10px;
    }

    .modal-nav-btn.next {
        right: 10px;
    }

    .source-modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-scroll-wrapper {
        padding: 20px;
    }
}

@media (max-width: 600px) {
    .source-modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .modal-nav-btn {
        width: 40px;
        height: 40px;
        top: auto;
        bottom: 20px;
        transform: none;
    }

    .modal-nav-btn.prev {
        left: 20px;
    }

    .modal-nav-btn.next {
        right: 20px;
    }

    .modal-header h3 {
        font-size: 1.2rem;
    }

    .modal-scroll-wrapper {
        padding: 16px;
        padding-bottom: 80px;
    }
}

/* ===== MOBILE FILTER BUTTON ===== */

.mobile-filter-btn {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(90, 154, 110, 0.15);
    border: 1px solid rgba(90, 154, 110, 0.3);
    border-radius: 20px;
    color: #5A9A6E;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
}

.mobile-filter-btn:hover {
    background: rgba(90, 154, 110, 0.25);
}

.mobile-filter-btn .filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    background: #DAA520;
    color: #1A1E3F;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9px;
}

/* ===== MOBILE FILTER BOTTOM DRAWER ===== */

.mobile-filter-drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-filter-drawer.active {
    display: block;
    opacity: 1;
}

.drawer-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
}

.drawer-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, var(--bg-light) 0%, var(--bg-medium) 100%);
    border-radius: 28px 28px 0 0;
    padding: 16px 24px 32px;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 70vh;
    overflow-y: auto;
    border-top: 1px solid var(--glass-border);
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
}

.mobile-filter-drawer.active .drawer-content {
    transform: translateY(0);
}

.drawer-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    margin: 0 auto 16px;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.drawer-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: white;
    margin: 0;
}

.drawer-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 18px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.drawer-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.drawer-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.drawer-filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drawer-filter-group label {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
}

.drawer-filter-group select {
    width: 100%;
    padding: 14px 18px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    outline: none;
    font-family: 'Pretendard Variable', -apple-system, BlinkMacSystemFont, sans-serif;
    transition: all 0.3s ease;
}

.drawer-filter-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(90, 154, 110, 0.12);
}

.drawer-filter-group select option {
    background: var(--bg-medium);
    color: var(--text-primary);
}

.drawer-footer {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--glass-border);
}

.drawer-reset-btn {
    flex: 1;
    padding: 16px 20px;
    background: transparent;
    border: 1px solid rgba(218, 165, 32, 0.4);
    border-radius: 100px;
    color: var(--gold);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Pretendard Variable', -apple-system, BlinkMacSystemFont, sans-serif;
}

.drawer-reset-btn:hover {
    background: rgba(218, 165, 32, 0.1);
    border-color: var(--gold);
}

.drawer-apply-btn {
    flex: 2;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 100px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Pretendard Variable', -apple-system, BlinkMacSystemFont, sans-serif;
    box-shadow: 0 4px 20px rgba(90, 154, 110, 0.35);
}

.drawer-apply-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(90, 154, 110, 0.5);
}

.drawer-apply-btn:active {
    transform: translateY(0);
}

/* ===== MOBILE RESPONSIVE OVERRIDES ===== */

@media (max-width: 768px) {
    /* Hide desktop filters, show mobile button */
    .library-filters-desktop {
        display: none !important;
    }

    .mobile-filter-btn {
        display: flex;
        margin-bottom: 12px;
    }

    /* Adjust header padding */
    .library-header {
        padding: 16px 20px;
    }

    .library-header h2 {
        font-size: 20px;
    }

    /* Adjust grid */
    .library-grid {
        padding: 16px;
        gap: 16px;
        grid-template-columns: 1fr;
    }

    /* Adjust cards */
    .library-card {
        padding: 16px;
        border-radius: 16px;
    }

    .library-card-title {
        font-size: 16px;
    }

    .library-card-summary {
        font-size: 13px;
    }

    /* Adjust search bar */
    .library-search-bar input {
        padding: 12px 16px;
        font-size: 15px;
    }
}
