/* Book Viewer / Collection Page CSS */

:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --primary-light: #a78bfa;
    --bg-primary: #0f0e13;
    --bg-secondary: #181820;
    --bg-card: #1f1f2b;
    --text-primary: #f8f8f8;
    --text-secondary: #a3a3a3;
    --border-radius: 12px;
    --glass-bg: rgba(22, 22, 30, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
    --item-scale: 1.0;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    /* Prevent horizontal scroll when sidebar off-screen elements exist */
}

/* Sidebar */
.sidebar-trigger {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 20px;
    z-index: 900;
}

.collection-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -280px;
    /* Hidden */
    width: 260px;
    background: transparent;
    border-right: none;
    z-index: 901;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    /* box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5); Removed for cleaner look if fully transparent, or keep subtle */
    display: flex;
    flex-direction: column;
}

.sidebar-trigger:hover~.collection-sidebar,
.collection-sidebar:hover {
    transform: translateX(280px);
}

.sidebar-header {
    padding: 30px 20px;
    /* border-bottom: 1px solid rgba(255, 255, 255, 0.05); Removed border to look cleaner on transparent */
}

.sidebar-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    letter-spacing: 0.05em;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.sidebar-tag-list {
    list-style: none;
    margin-bottom: 20px;
}

.sidebar-tag-item {
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    /* For potential icons later */
    align-items: center;
}

.sidebar-tag-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.sidebar-tag-item.active {
    background: rgba(139, 92, 246, 0.15);
    color: var(--primary-light);
    border-left: 3px solid var(--primary);
}

.sidebar-add-btn {
    margin-top: auto;
    width: 100%;
    padding: 12px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    color: var(--primary-light);
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-add-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--primary);
}

.collection-container {
    padding: 20px 40px 120px;
    /* Bottom padding for "Add Tag" footer */
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Background Effects */
.bg-effects {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}

.bg-gradient {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.1), transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(34, 211, 238, 0.05), transparent 40%);
}

/* Nav */
.collection-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 200;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* ===================================
   レスポンシブ (極小モバイル最適化)
   =================================== */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .collection-container {
        padding: 15px 15px 80px;
    }

    .collection-nav {
        flex-direction: column;
        gap: 15px;
        padding: 15px 0;
    }

    .collection-main {
        padding-right: 0;
        /* 右サイドバー用の余白を削除 */
    }

    .right-sidebar {
        display: none;
        /* スマホでは右サイドバー（目次）を非表示に */
    }

    .tag-title {
        font-size: 1.5rem;
    }

    .image-shelf {
        justify-content: center;
        gap: 12px;
    }

    .shelf-item {
        width: calc(140px * var(--item-scale, 1));
    }

    .add-image-btn {
        width: calc(140px * var(--item-scale, 1));
    }
}

@media (max-width: 480px) {
    html {
        font-size: 12px;
    }

    .collection-title {
        font-size: 1.6rem;
    }

    .shelf-item {
        width: calc(110px * var(--item-scale, 1));
    }

    .add-image-btn {
        width: calc(110px * var(--item-scale, 1));
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
        padding: 20px;
    }
}

/* Tag Sections */
.tag-section {
    animation: fadeIn 0.5s ease;
    scroll-margin-top: 100px;
    /* For smooth scrolling to section */
}

.tag-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 20px 0 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: sticky;
    top: 85px;
    z-index: 100;
}

/* Specific view behavior */
.is-all-view .tag-header {
    position: static;
    /* No sticky in All view */
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.back-btn:hover {
    color: var(--text-primary);
}

.back-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.collection-title {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff, var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Main Content */
.collection-main {
    display: flex;
    flex-direction: column;
    gap: 60px;
    padding-right: 200px;
    /* Space for right sidebar */
}

.is-streamer-view .collection-main {
    padding-right: 0;
}

.shelf-content-wrapper,
.streamer-content-wrapper {
    width: 100%;
    animation: fadeIn 0.4s ease;
}

/* Right Sidebar */
.right-sidebar {
    position: fixed;
    top: 100px;
    right: 40px;
    width: 180px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    z-index: 50;
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s ease;
    pointer-events: none;
    /* Interact only when visible */
}

.right-sidebar.visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.right-sidebar h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--glass-border);
}

.right-sidebar-list {
    list-style: none;
    border-left: 2px solid var(--glass-border);
}

.right-sidebar-item {
    padding: 6px 16px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
    position: relative;
}

.right-sidebar-item:hover {
    color: var(--text-primary);
}

.right-sidebar-item.active {
    color: var(--primary-light);
    font-weight: 500;
}

.right-sidebar-item.active::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--primary);
}

.sidebar-section-add-btn {
    width: 100%;
    margin-top: 20px;
    padding: 8px;
    background: transparent;
    border: 1px dashed var(--text-secondary);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-section-add-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
}

/* Section Header (in Grid) */
.section-header-item {
    width: 100% !important;
    margin: 20px 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--primary-light);
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: grab;
    position: relative;
    /* Create stacking context for absolute buttons */
}

.section-header-item:hover .item-delete-btn,
.section-header-item:hover .item-edit-btn {
    opacity: 1;
    transform: scale(1);
}

.section-header-item:active {
    cursor: grabbing;
}

/* Tag Sections */
.tag-section {
    animation: fadeIn 0.5s ease;
}


.tag-title {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    /* Larger */
    font-weight: 800;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
    /* Glowing effect */
    background: linear-gradient(90deg, #fff, var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tag-controls {
    display: flex;
    gap: 10px;
    opacity: 0;
    /* Show on hover */
    transition: opacity 0.2s;
}

.tag-section:hover .tag-controls {
    opacity: 1;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Scale Control */
.scale-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.scale-icon {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.scale-icon.large {
    font-size: 1.2rem;
}

input[type=range] {
    -webkit-appearance: none;
    background: transparent;
    width: 100px;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    margin-top: -6px;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Nav Actions */
.nav-actions {
    display: flex;
    align-items: center;
}

/* Image Grid (Shelf) */
.image-shelf {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 10px 0;
}

.shelf-item-link {
    text-decoration: none;
    display: block;
}

.shelf-item {
    position: relative;
    width: calc(200px * var(--item-scale));
    /* Restored Scaling */
    height: auto;
    /* Natural height */
    /* Remove background so it doesn't look like a box if image is transparent-ish */
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    /* align-self: start;  Useful if using flex-start alignment in container */
    margin-bottom: 20px;
    /* Spacing for potential masonry or just flow */
}

.shelf-item:hover .shelf-item-image-container {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
    border-color: rgba(139, 92, 246, 0.5);
}

.shelf-item-image-container {
    width: 100%;
    /* Remove aspect-ratio and fixed height */
    background: transparent;
    /* No black bars */
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    transition: transform 0.3s ease;
    display: block;
    /* Remove flex centering */
}

.shelf-item:hover .shelf-item-image-container {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
    border-color: rgba(139, 92, 246, 0.5);
}

.shelf-item img {
    display: block;
    width: 100%;
    height: auto;
    /* Natural height */
    object-fit: contain;
    /* just in case, but height auto should handle it */
    transition: transform 0.3s ease;
}

.rotate-90 {
    transform: rotate(90deg);
}

.rotate-180 {
    transform: rotate(180deg);
}

.rotate-270 {
    transform: rotate(270deg);
}

.shelf-item-title {
    font-size: calc(0.9rem * var(--item-scale));
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
    transition: color 0.2s;
}

.shelf-item:hover .shelf-item-title {
    color: var(--primary-light);
}

.item-delete-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: 2px solid #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    z-index: 20;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.item-edit-btn {
    position: absolute;
    top: -8px;
    right: 24px;
    /* Left of delete btn */
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: 2px solid #fff;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    z-index: 20;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.item-rotate-btn {
    position: absolute;
    top: -8px;
    right: 56px;
    /* Left of edit btn */
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #10b981;
    /* Greenish for action */
    color: white;
    border: 2px solid #fff;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    z-index: 20;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.shelf-item:hover .item-delete-btn,
.shelf-item:hover .item-edit-btn,
.shelf-item:hover .item-rotate-btn {
    opacity: 1;
    transform: scale(1);
}

.item-delete-btn:hover {
    background: #ef4444;
    color: white;
}

/* Modal Type Switch */
.modal-type-switch {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 8px;
}

.type-btn {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.type-btn.active {
    background: var(--glass-bg);
    color: var(--text-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.add-image-btn {
    width: calc(180px * var(--item-scale));
    aspect-ratio: 2/3;
    /* Match image ratio */
    background: rgba(255, 255, 255, 0.03);
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    font-size: calc(1.5rem * var(--item-scale));
}

.add-image-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    color: var(--primary);
}

/* Footer "Add Tag" */
.add-tag-footer {
    display: flex;
    justify-content: center;
    margin-top: 40px;
    padding-bottom: 40px;
}

.add-tag-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

.add-tag-btn:hover {
    color: var(--primary);
    transform: translateY(-2px);
}

.plus-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    transition: background 0.3s;
}

.add-tag-btn:hover .plus-icon {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

/* ===================================
   Study Memo Styles
   =================================== */

.study-content-wrapper {
    width: 100%;
    animation: fadeIn 0.4s ease;
}

.study-view-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    position: sticky;
    top: 90px;
    z-index: 150;
    padding: 10px;
    background: transparent;
    /* Fix black background issue */
    backdrop-filter: blur(10px);
    /* Add subtle blur instead of solid background */
    border-radius: 12px;
}

.view-switch {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    padding: 5px;
    border-radius: 30px;
    /* More rounded pill shape */
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.view-switch-btn {
    padding: 8px 25px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 25px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.view-switch-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.study-search-container {
    max-width: 600px;
    margin: 0 auto 30px;
    position: relative;
}

.study-search-input {
    width: 100%;
    padding: 12px 20px 12px 45px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

.study-search-input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
}

.study-search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.study-shelf {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.study-tag-section {
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.study-tag-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.study-tag-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-light);
    display: flex;
    align-items: center;
    gap: 10px;
}

.study-tag-drag-handle {
    cursor: grab;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.study-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.study-card {
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 0;
    padding: 12px;
    transition: background 0.2s;
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 15px;
}

.study-card:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: none;
}

.study-card-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    flex: 1;
}

.study-main-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
}

.study-example-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    color: #facc15 !important;
    font-size: 0.95rem;
    /* Increased to match memo size */
    padding-left: 0;
}

.study-example-label,
.study-example-separator,
.study-example-content {
    color: #facc15 !important;
}

.study-example-label {
    font-weight: 700;
}

.study-example-content {
    font-style: normal;
    /* Changed from italic to normal as requested */
    word-break: break-all;
}

.study-word {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-light);
    /* Highlight word color */
    white-space: nowrap;
}

.study-separator {
    color: var(--text-secondary);
    font-weight: 400;
}

.study-memo {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.4;
    white-space: pre-wrap;
    flex: 1;
}

.study-reading {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 5px;
    font-weight: 400;
}

.study-card-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
    margin-left: auto;
}

.study-card:hover .study-card-actions {
    opacity: 1;
}

.study-action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
}

.study-action-btn:hover {
    background: var(--primary);
    color: #fff;
}

.study-add-tag-btn {
    margin-top: 15px;
    width: 100%;
    padding: 12px;
    background: rgba(139, 92, 246, 0.05);
    border: 1px dashed rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    color: var(--primary-light);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Sidebar Tag Add Button Specific */
.sidebar-tag-add-btn {
    width: 100%;
    padding: 10px;
    margin-top: 15px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 6px;
    color: var(--primary-light);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.sidebar-tag-add-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--primary);
}

.study-add-tag-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--primary);
}

/* Study Modal specific */
.tag-input-container select {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    outline: none;
}

.tag-input-container select option {
    background: var(--bg-card);
}

@media (max-width: 768px) {
    .study-grid {
        grid-template-columns: 1fr;
    }

    .study-view-controls {
        top: 70px;
    }
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    background: rgba(22, 22, 30, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 20px;
    padding: 35px;
    z-index: 1001;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.7),
        0 0 20px rgba(139, 92, 246, 0.1);
}

.modal-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
#streamer-comment-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s ease;
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
#streamer-comment-input:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-danger {
    padding: 12px 20px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    cursor: pointer;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

/* Tabs */
.tab-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* File Upload */
.file-upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.file-upload-area:hover {
    border-color: var(--primary);
}

.upload-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 10px;
}

#file-preview {
    position: relative;
    margin-top: 20px;
    text-align: center;
}

#file-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
}

#remove-file-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
}

/* Lightbox */
.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

#lightbox-img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 4px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

.lightbox-actions {
    position: absolute;
    bottom: -50px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
}

.btn-icon-danger {
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: #ef4444;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-icon-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-icon-danger svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* Streamer Specific Styles */
.sidebar-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 10px 20px;
}

.streamer-shelf {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(300px * var(--item-scale))), 1fr));
    gap: 24px;
    padding: 20px 0;
}

.streamer-add-btn {
    width: 100% !important;
    aspect-ratio: 1 / 1 !important;
}

.streamer-card {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.streamer-card:hover {
    transform: translateY(-5px);
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 92, 246, 0.2);
}

.streamer-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.streamer-icon-container {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--primary);
    flex-shrink: 0;
    background: var(--bg-secondary);
}

.streamer-icon-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.streamer-info {
    flex: 1;
    min-width: 0;
}

.streamer-name {
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.streamer-platform {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.platform-youtube {
    color: #ff0000;
}

.platform-twitch {
    color: #9146ff;
}

.streamer-comment {
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.4);
    padding: 12px;
    border-radius: 8px;
    line-height: 1.5;
    position: relative;
}

.streamer-comment::before {
    content: '"';
    position: absolute;
    top: 4px;
    left: 4px;
    font-family: serif;
    font-size: 1.5rem;
    opacity: 0.2;
}

.streamer-card-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 8px;
}

.streamer-action-btn {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.streamer-action-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* --- Dynamic Streamer Background Effects --- */
.collection-container.is-streamer-view .bg-effects {
    background: radial-gradient(ellipse at bottom, #1B2735 0%, #090A0F 100%);
    overflow: hidden;
}

.collection-container.is-streamer-view .bg-glow {
    display: none;
    /* Hide default glow */
}

.collection-container.is-streamer-view .bg-effects::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 20% 30%, rgba(34, 211, 238, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(244, 114, 182, 0.1) 0%, transparent 40%);
    animation: rotateBg 30s linear infinite;
    z-index: -1;
}

@keyframes rotateBg {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Moving Particles effect */
.collection-container.is-streamer-view .bg-effects::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(2px 2px at 20px 30px, #eee, rgba(0, 0, 0, 0)),
        radial-gradient(2px 2px at 40px 70px, #fff, rgba(0, 0, 0, 0)),
        radial-gradient(2px 2px at 50px 160px, #ddd, rgba(0, 0, 0, 0)),
        radial-gradient(2px 2px at 90px 40px, #fff, rgba(0, 0, 0, 0)),
        radial-gradient(2px 2px at 130px 80px, #fff, rgba(0, 0, 0, 0)),
        radial-gradient(2px 2px at 160px 120px, #ddd, rgba(0, 0, 0, 0));
    background-repeat: repeat;
    background-size: 200px 200px;
    opacity: 0.3;
    animation: drift 60s linear infinite;
}

@keyframes drift {
    from {
        background-position: 0 0;
    }

    to {
        background-position: 500px 1000px;
    }
}

/* --- Streamer Card Platform Links --- */
.streamer-platforms {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.platform-link {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    transition: all 0.2s ease;
    cursor: pointer;
}

.platform-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.3);
}

.platform-link.platform-youtube:hover {
    color: #ff0000;
    border-color: #ff0000;
    background: rgba(255, 0, 0, 0.1);
}

.platform-link.platform-twitch:hover {
    color: #9146ff;
    border-color: #9146ff;
    background: rgba(145, 70, 255, 0.1);
}

.platform-link.platform-twitter:hover {
    color: #1DA1F2;
    border-color: #1DA1F2;
    background: rgba(29, 161, 242, 0.1);
}

.platform-link.platform-instagram:hover {
    color: #E1306C;
    border-color: #E1306C;
    background: rgba(225, 48, 108, 0.1);
}

.platform-link.platform-tiktok:hover {
    color: #ff0050;
    border-color: #ff0050;
    background: rgba(255, 0, 80, 0.1);
}

.streamer-link-item {
    margin-bottom: 8px;
}

.streamer-link-item .input-with-action {
    display: flex;
    gap: 8px;
}

.remove-link-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 4px;
    color: #ef4444;
    cursor: pointer;
    font-size: 1.2rem;
}

.remove-link-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

.remove-link-btn.hidden {
    display: none;
}

/* Link Drag & Drop */
.link-drag-handle {
    cursor: grab;
    padding: 0 8px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: color 0.2s;
}

.link-drag-handle:hover {
    color: var(--text-primary);
}

.link-drag-handle:active {
    cursor: grabbing;
}

.sortable-ghost {
    opacity: 0.4;
    background: rgba(139, 92, 246, 0.1) !important;
    border: 1px dashed var(--primary) !important;
}

/* --- Study Memo Picture Mode --- */
.study-picture-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    padding: 20px 0;
}

.study-card.is-picture-mode {
    flex-direction: column;
    height: 100%;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

.study-card.is-picture-mode:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), 0 0 15px rgba(139, 92, 246, 0.2);
    border-color: var(--primary-light);
}

.study-card-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #000;
    cursor: zoom-in;
    border-bottom: 1px solid var(--glass-border);
}

.study-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.5s ease;
}

.study-card.is-picture-mode:hover .study-card-image img {
    transform: scale(1.05);
}

.study-card.is-picture-mode .study-card-content {
    padding: 16px;
    flex: 1;
}

.study-card.is-picture-mode .study-word {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--primary-light);
}

.study-card.is-picture-mode .study-separator {
    display: none;
}

.study-card.is-picture-mode .study-memo {
    display: block;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
}

/* --- Image Upload UI in Modal --- */
.study-image-upload-area {
    width: 100%;
    padding: 24px;
    border: 2px dashed var(--glass-border);
    border-radius: 12px;
    text-align: center;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: all 0.2s;
}

.study-image-upload-area:hover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.05);
}

.study-image-upload-area .upload-icon {
    font-size: 2rem;
    margin-bottom: 12px;
    display: block;
}

#study-image-preview {
    position: relative;
    margin-top: 16px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    max-height: 250px;
    background: #000;
}

#study-preview-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

#study-remove-image-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#study-remove-image-btn:hover {
    background: #ef4444;
}

/* --- Responsive fixes --- */
@media (max-width: 768px) {
    .study-picture-grid {
        grid-template-columns: 1fr;
    }
}