:root {
    /* Colors */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --accent: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #0f172a;
    --light: #f8fafc;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;

    /* Glassmorphism */
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --blur: 12px;

    /* Typography */
    --font-main: 'Inter', 'Noto Sans JP', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-main);
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    color: var(--text-main);
    min-height: 100vh;
    padding-bottom: 2rem;
    overflow-x: hidden;
}

/* Background Ambience */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 50%);
    z-index: -1;
    animation: pulse-bg 15s infinite alternate;
}

@keyframes pulse-bg {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* ========================================
   Global Navigation
   ======================================== */

/* Base styles - Mobile Bottom Nav */
.global-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 900;
    padding: 0 1rem;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    border-radius: 12px;
    min-width: 60px;
}

.nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active .nav-icon {
    transform: scale(1.1);
}

.nav-icon {
    font-size: 1.5rem;
    margin-bottom: 2px;
    transition: transform 0.2s;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 500;
}

/* App container with nav - Mobile */
.app-with-nav {
    padding-bottom: 80px;
    /* Space for bottom nav */
}

/* PC Sidebar - 768px and above */
@media (min-width: 768px) {
    .global-nav {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: auto;
        width: 80px;
        height: 100vh;
        flex-direction: column;
        justify-content: flex-start;
        padding: 1.5rem 0.5rem;
        gap: 0.5rem;
        border-top: none;
        border-right: 1px solid var(--glass-border);
    }

    .nav-item {
        width: 64px;
        height: 64px;
        padding: 0.5rem;
    }

    .nav-icon {
        font-size: 1.4rem;
    }

    .nav-label {
        font-size: 0.65rem;
    }

    .app-with-nav {
        padding-bottom: 0;
        margin-left: 80px;
        /* Space for sidebar */
    }
}

/* Hide nav during quiz */
.quiz-active .global-nav {
    display: none;
}

.quiz-active .app-with-nav {
    padding-bottom: 0;
    margin-left: 0;
}

/* Landing Container (Shared Quiz) */
.landing-container {
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(var(--blur));
    text-align: center;
}

.landing-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.landing-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: bounce 2s infinite;
}

.landing-title {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #fff, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1.2;
}

.landing-description {
    font-size: 1.1rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.landing-stats {
    display: flex;
    gap: 2rem;
    margin: 1.5rem 0;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
}

.landing-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-landing-start {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    padding: 1rem 3rem;
    border-radius: 50px;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
    transition: all 0.3s;
    border: none;
    cursor: pointer;
}

.btn-landing-start:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 15px 35px rgba(99, 102, 241, 0.5);
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-20px);
    }

    60% {
        transform: translateY(-10px);
    }
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

.container.center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

/* Screen Management */
.screen {
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.screen.active {
    display: block;
    opacity: 1;
    animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

/* Common UI Elements */
.logo,
.logo-compact {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #c084fc, #6366f1);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 0.5rem;
}

.header,
.header-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
}

.btn,
button {
    font-family: var(--font-main);
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s;
}

.btn-primary,
.btn-success {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover,
.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 500;
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

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

.btn-text {
    background: transparent;
    color: var(--text-muted);
}

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

/* Icon button (settings etc) */
.btn-icon-text {
    background: transparent;
    border: none;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* --- Result Screen Styles --- */
.result-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: bounce 1s ease;
}

#result-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff, var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

#result-message {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.result-stats {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-bottom: 2rem;
    max-width: 320px;
    /* Match quiz width */
    margin-left: auto;
    margin-right: auto;
}

.result-stat {
    flex: 1;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 16px;
    padding: 1.5rem 1rem;
    text-align: center;
}

.result-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.result-stat-value {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 320px;
    margin: 0 auto;
}


/* Home Screen */
.home-tab-navigation {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 16px;
}

.home-tab-btn {
    flex: 1;
    padding: 0.75rem;
    border-radius: 12px;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
}

.home-tab-btn.active {
    background: var(--glass-bg);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.quiz-image-container {
    max-width: 320px;
    /* Limit size for better quality with 12-grid */
    margin: 0 auto 1.5rem auto;
    /* Center horizontally */
    border-radius: 12px;
    overflow: hidden;
    /* 4:3 aspect ratio for grid panels (most common now) */
    aspect-ratio: 4/3;
    background-color: rgba(0, 0, 0, 0.3);
    background-size: cover;
    background-position: center;
    position: relative;
    display: none;
    /* hidden by default */
}



.quiz-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    /* Hidden when using background-image */
}

.home-tab-content {
    display: none;
}

.home-tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

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

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

/* Quick Start Cards */
.quick-start-section-compact {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(var(--blur));
}

.config-row-compact {
    margin-bottom: 1.5rem;
}

.config-label-compact {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.config-select-compact {
    width: 100%;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
}

.question-count-selector-compact {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.count-btn-compact {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.count-btn-compact.active {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

/* Stats Grid */
.stats-grid-compact {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stat-card-compact {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    border-radius: 16px;
    text-align: center;
}

.stat-value-compact {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.stat-label-compact {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* Quiz Screen */
.question-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--glass-shadow);
    position: relative;
    overflow: hidden;
}

.question-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to right, var(--primary), var(--secondary));
}

.question-text {
    font-size: 1.25rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    font-weight: 600;
}

.choice-wrapper {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    background: transparent;
    /* Remove bg */
    border: none;
    /* Remove border */
    border-radius: 12px;
    transition: all 0.2s;
}

.choice-number {
    width: 40px;
    text-align: center;
    font-weight: 700;
    color: var(--text-muted);
}

.choice-btn {
    flex: 1;
    text-align: left;
    padding: 1rem;
    background: transparent;
    color: white;
    font-size: 1rem;
    border-radius: 0 12px 12px 0;
}

.choice-btn.correct {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.choice-btn.incorrect {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #1e1b4b;
    /* Solid dark for readability */
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Feedback Modal (Bottom Sheet style on Mobile, Center on Desktop) */
.feedback-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    display: flex;
    justify-content: center;
    pointer-events: none;
    /* Let clicks pass through if hidden logic used differently, but here we cover screen usually? original was modal. */
    padding: 1rem;
    margin-bottom: 2rem;
}

.feedback-modal.hidden {
    display: none;
}

.feedback-modal-content {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    width: 100%;
    max-width: 600px;
    pointer-events: auto;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
    border-bottom: 4px solid var(--primary);
    /* Accent line */
}

/* Explanation Carousel (v3 Compact) */
.explanation-carousel {
    position: relative;
    overflow: hidden;
    touch-action: pan-x;
}

.carousel-track {
    position: relative;
    min-height: 60px;
    cursor: grab;
    user-select: none;
}

.explanation-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    pointer-events: none;
}

.explanation-slide.active {
    position: relative;
    opacity: 1;
    pointer-events: auto;
}

/* Compact Header */
.slide-header-compact {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
}

.slide-title-compact {
    flex: 1;
}

.slide-counter-compact {
    font-size: 0.7rem;
    opacity: 0.5;
}

/* Compact Content */
.slide-content-compact {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #e2e8f0;
}

/* Compact Dots */
.carousel-dots-compact {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.carousel-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s;
}

.carousel-dot:hover {
    background: rgba(255, 255, 255, 0.4);
}

.carousel-dot.active {
    background: var(--primary);
    width: 16px;
    border-radius: 3px;
}

/* Mobile */
@media (max-width: 480px) {
    .slide-content-compact {
        font-size: 0.85rem;
    }

    .carousel-track {
        min-height: 50px;
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Progress Grid */
.progress-grid {
    display: flex;
    gap: 4px;
    margin-bottom: 1rem;
}

.progress-cell {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    font-size: 0;
    /* Hide numbers for cleaner look */
}

.progress-cell.current {
    background: white;
    box-shadow: 0 0 10px white;
}

.progress-cell.correct {
    background: var(--success);
}

.progress-cell.incorrect {
    background: var(--danger);
}

/* Difficulty Badge */
.difficulty-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.difficulty-badge.basic {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
}

.difficulty-badge.intermediate {
    background: rgba(255, 152, 0, 0.2);
    color: #FF9800;
}

.difficulty-badge.standard {
    background: rgba(255, 152, 0, 0.2);
    color: #FF9800;
}

.difficulty-badge.advanced {
    background: rgba(244, 67, 54, 0.2);
    color: #F44336;
}

/* v3: Review Reminder Banner */
.review-reminder-banner {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.1));
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    animation: pulse-gold 2s infinite;
}

.review-reminder-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.review-reminder-icon {
    font-size: 1.5rem;
}

.review-reminder-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.review-reminder-text strong {
    color: #fbbf24;
    font-size: 0.95rem;
}

.review-reminder-text span {
    color: #fcd34d;
    font-size: 0.85rem;
}

@keyframes pulse-gold {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(251, 191, 36, 0);
    }
}

@keyframes pulse-green {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
}

/* Upload Section */
.upload-box-compact {
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    margin-bottom: 1.5rem;
    transition: all 0.3s;
    cursor: pointer;
}

.upload-box-compact:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.text-input-area-compact {
    width: 100%;
    height: 150px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    color: white;
    resize: none;
    margin-bottom: 1rem;
}

/* Material Library */
.materials-list {
    display: grid;
    gap: 1rem;
}

.material-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 1rem;
    border-radius: 12px;
    transition: all 0.2s;
    cursor: pointer;
}

.material-list-item:hover {
    transform: translateX(5px);
    background: rgba(255, 255, 255, 0.05);
}

/* Input modes */
.input-mode {
    display: none;
}

.input-mode.active {
    display: block;
    animation: fadeIn 0.3s;
}

.input-mode-tabs-compact {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.mode-tab-compact {
    flex: 1;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-muted);
}

.mode-tab-compact.active {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
    border-color: rgba(99, 102, 241, 0.3);
}

/* Spinner */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

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

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

/* Tag Cloud */
.tag-cloud-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    padding: 1rem;
}

.tag-cloud-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    color: var(--text-main);
    cursor: default;
    transition: all 0.2s;
}

.tag-cloud-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

/* --- Review List --- */
.review-material-section {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    margin-bottom: 2rem;
    overflow: hidden;
}

.review-material-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.review-count-badge {
    background: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.review-question-items {
    padding: 1rem;
}

.review-question-item {
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.review-question-item:last-child {
    border-bottom: none;
}

.review-question-meta {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.review-overdue {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
}

/* --- Certificate --- */
.certificate-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.certificate-card {
    background: linear-gradient(135deg, #fff, #f0f9ff);
    color: #1e1b4b;
    /* Dark text for certificate look */
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 8px solid #c084fc;
    max-width: 600px;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.certificate-card::before {
    content: '🏆';
    position: absolute;
    top: -20px;
    right: -20px;
    font-size: 15rem;
    opacity: 0.05;
    pointer-events: none;
}

.certificate-header {
    margin-bottom: 2rem;
}

.certificate-badge {
    font-size: 4rem;
    margin-bottom: 0.5rem;
}

.certificate-title {
    font-family: serif;
    font-size: 2.5rem;
    background: linear-gradient(to right, #6366f1, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.certificate-quiz-title {
    font-size: 2rem;
    margin: 1rem 0;
    color: #1e1b4b;
}

.certificate-label {
    color: #64748b;
    font-size: 1.1rem;
}

.certificate-score {
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 16px;
    display: inline-block;
}

.score-value {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    display: block;
}

.score-detail {
    color: #64748b;
}

.certificate-date {
    color: #94a3b8;
    margin-bottom: 2rem;
}

.certificate-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* --- Landing (Share) --- */
.landing-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    text-align: center;
}

.landing-hero {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 3rem;
    border-radius: 24px;
    max-width: 500px;
}

.landing-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
}

.landing-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.landing-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 2rem 0;
}

.landing-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Filter Bar */
.filter-bar-compact {
    background: var(--glass-bg);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.search-input-compact {
    flex: 2;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    color: white;
}

.filter-select-compact {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    padding: 0.5rem;
}

.view-switcher {
    display: flex;
    gap: 0.25rem;
}

.view-btn {
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.view-btn.active {
    background: var(--primary);
    color: white;
}

/* --- Material Detail Questions List --- */
.question-item-mini {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.2s;
}

.question-item-mini:hover {
    background: rgba(255, 255, 255, 0.08);
}

.question-mini-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.question-mini-row:last-child {
    margin-bottom: 0;
}

.question-mini-label {
    font-weight: 700;
    width: 20px;
    color: var(--text-muted);
}

.question-mini-text {
    flex: 1;
    font-weight: 500;
    line-height: 1.5;
}

.question-mini-answer {
    flex: 1;
    color: var(--success);
    font-weight: 500;
}

.btn-icon-mini {
    background: transparent;
    color: var(--text-muted);
    padding: 0.25rem;
    border-radius: 6px;
    font-size: 1rem;
    line-height: 1;
}

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

/* --- Material Content Tab Typography --- */
.material-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    line-height: 1.8;
    color: var(--text-main);
}

.content-heading-h1 {
    font-size: 1.8rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
    color: white;
}

.content-heading-h1:first-child {
    margin-top: 0;
}

.content-heading-h2 {
    font-size: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: white;
}

.content-heading-h3 {
    font-size: 1.2rem;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-main);
}

.content-list-item {
    margin-left: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.material-content p {
    margin-bottom: 1rem;
    color: #cbd5e1;
}

.material-content strong {
    color: white;
    font-weight: 700;
}

/* --- URL Input --- */
.url-input-compact {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    transition: all 0.3s;
}

.url-input-compact:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    background: rgba(0, 0, 0, 0.4);
}

.url-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    margin-left: 0.5rem;
}

/* --- Toggle Switch --- */
.image-gen-option {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.image-gen-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    user-select: none;
}

.image-gen-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 50px;
    height: 26px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 34px;
    transition: .4s;
    margin-right: 1rem;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
}

input:checked+.toggle-slider {
    background-color: var(--primary);
}

input:checked+.toggle-slider:before {
    transform: translateX(24px);
}

.toggle-label {
    font-weight: 600;
    color: var(--text-main);
}

.image-gen-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: calc(50px + 1rem);
    /* Align with text */
}

/* --- Tabs (Material Detail) --- */
.tab-navigation {
    display: flex;
    gap: 1rem;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 2rem;
    padding-bottom: 1px;
}

.tab-btn {
    background: transparent;
    color: var(--text-muted);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    border-radius: 8px 8px 0 0;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s;
}

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

/* --- Report Stats Details --- */
.stats-detail-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-detail-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    border-radius: 16px;
    text-align: center;
}

.stat-detail-label {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.stat-detail-value {
    font-size: 2rem;
    font-weight: 800;
    color: white;
}

/* --- Material Stats (Overview) --- */
.overview-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
}

.stat-box-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-box-value {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(to right, #fff, #a5b4fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* --- Markdown Extra --- */
.material-content blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: #e2e8f0;
    background: rgba(139, 92, 246, 0.1);
    padding: 1rem;
    border-radius: 0 8px 8px 0;
}

.material-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    color: #e2e8f0;
}

.material-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
}

.material-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 1rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.material-content a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px dashed var(--primary);
}

.material-content a:hover {
    color: var(--accent);
    border-bottom-style: solid;
}

/* --- Mobile Optimization --- */
@media (max-width: 600px) {
    .container {
        padding: 0.5rem;
        min-height: auto;
    }

    .container.center {
        min-height: 90vh;
    }

    .header-compact,
    .header {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }

    .logo-compact,
    .logo {
        font-size: 1.2rem;
    }

    .stats-grid-compact {
        gap: 0.5rem;
    }

    .stat-card-compact {
        padding: 0.75rem;
    }

    .stat-value-compact {
        font-size: 1.4rem;
    }

    .quick-start-section-compact {
        padding: 1.25rem;
    }

    .btn-large-compact {
        width: 100%;
        padding: 1rem;
    }

    .question-card {
        padding: 1.25rem;
        margin-bottom: 5rem;
    }

    .question-text {
        font-size: 1.1rem;
    }
}

/* --- Global Loader --- */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0f172a;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease-out;
}

.global-loader.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loader-content {
    text-align: center;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.loader-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    animation: pulse 2s infinite;
}

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

@keyframes pulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* Ensure no double scrolling on mobile and fit viewport */
html,
body {
    overscroll-behavior-y: none;
}

/* Additional fix for feedback modal position on mobile */
.feedback-modal {
    padding: 0;
    margin: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 1) 20%, transparent);
    /* Enable full modal scrolling if content is long */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.feedback-modal-content {
    border-radius: 24px 24px 0 0;
    max-width: 100%;
    border-bottom: none;
    padding-bottom: 2rem;
    /* Remove max-height to show full content */
    max-height: none;
    display: flex;
    flex-direction: column;
    background: #1e293b;
    /* Ensure background is solid for readability */
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.feedback-modal-explanation {
    flex: 1 0 auto;
    /* Allow growth */
    overflow-y: visible;
    /* Remove inner scroll */
    margin-bottom: 1rem;
    padding: 0 1.5rem;
    /* Add padding for readability */
}

/* Feedback Actions Compact Layout */
.feedback-actions {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem 0;
    /* Adjust padding */
    border-top: 1px solid var(--glass-border);
    position: sticky;
    /* Keep actions visible at bottom relative to content container? No, sticky bottom of screen maybe? */
    /* User wants explanation fully visible. Sticky bottom might cover content. 
       Let's keep it at the bottom of the flow. User scroll down to see buttons. */
    bottom: 0;
    background: #1e293b;
    /* Match content bg */
    z-index: 10;
}

.auto-advance-toggle {
    margin: 0;
    padding: 0.5rem 1rem;
    flex-shrink: 0;
    background: transparent;
}

.feedback-next-area {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    justify-content: flex-end;
}

.btn-modal.btn-next-compact {
    margin-top: 0;
    width: auto;
    padding: 0.8rem 2rem;
    min-width: 120px;
}

.feedback-modal-timer {
    margin-top: 0;
    display: block !important;
    /* Force display in improved layout */
}

.btn-modal:hover {
    background: #f1f5f9;
}

/* --- Quiz Header Improvement --- */
.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
}

.btn-secondary.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
}

.btn-secondary.btn-icon:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    transform: rotate(90deg);
}

.progress-bar-container {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.progress-info-text {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.progress-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.progress-numbers {
    font-family: monospace;
    font-size: 1.25rem;
    font-weight: 700;
}

.progress-divider {
    color: var(--text-muted);
    font-weight: 400;
    margin: 0 2px;
}

/* --- Markdown Content Styling (Marked.js output) --- */
.material-content h1 {
    font-size: 1.6rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: white;
}

.material-content h2 {
    font-size: 1.4rem;
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
    color: #f1f5f9;
}

.material-content h3 {
    font-size: 1.2rem;
    margin-top: 1.2rem;
    margin-bottom: 0.5rem;
    color: #cbd5e1;
}

.material-content ul,
.material-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.material-content li {
    margin-bottom: 0.25rem;
}

.material-content p {
    margin-bottom: 1rem;
    line-height: 1.8;
}

/* --- Share Modal Options --- */
.share-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.share-option-btn {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    width: 100%;
    text-align: left;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.share-option-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.share-icon {
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.1);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.share-option-text {
    flex: 1;
}

.share-option-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    color: white;
}

.share-option-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- SNS Direct Share Buttons --- */
.share-sns-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
}

.share-sns-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.share-sns-btn .sns-icon {
    font-size: 1.2rem;
}

.share-sns-btn.share-x {
    background: #000000;
    color: white;
    border: 1px solid #333;
}

.share-sns-btn.share-x:hover {
    background: #1a1a1a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.share-sns-btn.share-line {
    background: #06C755;
    color: white;
    border: 1px solid #05b64d;
}

.share-sns-btn.share-line:hover {
    background: #05a94c;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(6, 199, 85, 0.4);
}

@media (max-width: 600px) {
    .share-sns-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
}

.share-result {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    text-align: center;
    animation: fadeIn 0.3s;
}

.share-message {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
}

.qr-container {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 1.5rem auto 0;
    width: fit-content;
    max-width: 100%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#qr-code canvas,
#qr-code img {
    max-width: 100%;
    height: auto;
    display: block;
}

.qr-hint {
    margin-top: 1rem;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
}

/* --- Report Dashboard Revamp --- */
.report-section {
    margin-bottom: 2rem;
}

/* Interests Chart */
.chart-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
}

.chart-row {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.chart-row:last-child {
    margin-bottom: 0;
}

.chart-label {
    width: 100px;
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}

.chart-bar-container {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
}

.chart-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 6px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-value {
    width: 50px;
    text-align: right;
    font-family: monospace;
    font-weight: 700;
    color: white;
}

/* Weak Points Cards */
.weak-points-grid {
    display: grid;
    gap: 1rem;
}

.weak-point-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 1rem 1.5rem;
    border-radius: 16px;
    transition: transform 0.2s;
}

.weak-point-card:hover {
    transform: translateX(4px);
    background: rgba(239, 68, 68, 0.15);
}

.weak-point-icon {
    font-size: 1.5rem;
}

.weak-point-info {
    flex: 1;
}

.weak-point-title {
    font-weight: 700;
    color: #fca5a5;
    margin-bottom: 0.25rem;
}

.weak-point-desc {
    font-size: 0.85rem;
    color: #fca5a5;
    opacity: 0.8;
}

.weak-point-empty,
.empty-message {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    border: 1px dashed var(--glass-border);
    border-radius: 16px;
}

/* --- Auto-Advance Toggle --- */
.auto-advance-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 1rem 0;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider-small {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider-small:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked+.toggle-slider-small {
    background-color: var(--primary);
}

.toggle-switch input:checked+.toggle-slider-small:before {
    transform: translateX(20px);
}

.toggle-text {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* --- Google Login & User Info --- */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-google-login {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: white;
    color: #333;
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-google-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-google-login svg {
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    font-size: 0.85rem;
    color: white;
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    padding: 0.25rem 0.5rem;
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: none;
    border-radius: 12px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.4);
}

@media (max-width: 600px) {
    .btn-google-login {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
    }

    .user-name {
        display: none;
    }

    .btn-logout {
        font-size: 0.7rem;
    }
}

/* --- Settings Modal Styles --- */
.settings-modal-content {
    max-width: 700px;
    width: 95%;
}

.settings-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.settings-tab-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s;
}

.settings-tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.settings-tab-btn.active {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
}

.settings-tab-content {
    display: none;
    animation: fadeIn 0.3s;
}

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

.setting-group {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.setting-group:last-child {
    border-bottom: none;
}

.setting-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-main);
}

.setting-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.setting-hint {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
}

/* API Key Input */
.api-key-input-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-family: monospace;
}

.input:focus {
    border-color: var(--primary);
    outline: none;
}

.api-key-status {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    min-height: 1.4em;
}

.api-key-status.success {
    color: var(--success);
}

.api-key-status.error {
    color: var(--danger);
}

/* Prompts */
.prompt-textarea {
    width: 100%;
    min-height: 120px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    color: #e2e8f0;
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
}

.prompt-textarea:focus {
    border-color: var(--primary);
    outline: none;
}

.setting-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.setting-actions-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
}

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

/* Danger Zone */
.danger-zone {
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
    padding: 1.5rem;
    border-radius: 12px;
}

.danger-zone h3 {
    color: var(--danger);
    margin-bottom: 0.5rem;
}

.danger-zone p {
    color: #fca5a5;
    margin-bottom: 1.5rem;
}

.alert-box {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.alert-box.info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

/* --- Compact Input Section Styles (Missing) --- */
.input-mode {
    display: none;
    animation: fadeIn 0.3s ease;
}

.input-mode.active {
    display: block;
}

.btn-large-compact {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.text-input-area-compact {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 0.5rem;
}

.text-input-area-compact:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(0, 0, 0, 0.3);
}

.url-input-compact {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.url-input-compact:focus {
    outline: none;
    border-color: var(--primary-color);
}

.url-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.upload-box-compact {
    border: 2px dashed var(--glass-border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s ease;
    margin-bottom: 1rem;
}

.upload-box-compact:hover {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.05);
}

.upload-label-compact {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.upload-icon-compact {
    font-size: 2rem;
}

.upload-text-compact {
    color: var(--text-muted);
    font-weight: 500;
}

.file-name-compact {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--primary-color);
    min-height: 1.2em;
}

/* Input Mode Tabs */
.input-mode-tabs-compact {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.25rem;
    border-radius: 12px;
}

.mode-tab-compact {
    flex: 1;
    padding: 0.6rem 0;
    font-size: 0.9rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-tab-compact.active {
    background: var(--glass-bg);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.mode-tab-compact:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
}

/* --- Quiz Screen Image & Mobile Optimization --- */
.quiz-image-container {
    width: 100%;
    /* Limit height on mobile */
    /* Enforce 16:9 Aspect Ratio */
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    /* Important for Crop */
    /* Important for Safe Margin cropping */
    margin-bottom: 0.75rem;
    position: relative;
    /* Remove static max-height to respect aspect ratio */
    transform: scale(1.05);
    /* Crop 5% border */
    transform-origin: center;
}

.quiz-image {
    width: 100%;
    height: auto;
    max-height: 25vh;
    object-fit: cover;
    border-radius: 12px;
}

/* Grid Mode for 4x3 panel display */
.quiz-image-container.grid-mode {
    aspect-ratio: 4 / 3;
    background-repeat: no-repeat;
}

/* Compact Question Card */
.question-card {
    padding: 1rem;
    background: var(--glass-bg);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    max-width: 320px;
    /* Match image width */
    margin: 0 auto;
    /* Center */
}

.question-text {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

/* Compact Choices */
.choices-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 320px;
    /* Match image width */
    margin: 0 auto;
    /* Center */
}

.choice-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.choice-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.choice-btn {
    flex: 1;
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    text-align: left;
    background: transparent;
    /* No bg, cleaner look */
    border: none;
    /* Remove border - number circle is enough */
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.choice-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    /* No border */
}

.choice-btn.correct {
    background: rgba(16, 185, 129, 0.2);
    /* No border */
}

.choice-btn.incorrect {
    background: rgba(239, 68, 68, 0.2);
    /* No border */
}

/* Compact Feedback Modal */
.feedback-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 1rem;
    border-radius: 20px 20px 0 0;
    z-index: 100;
    max-height: 50vh;
    overflow-y: auto;
}

.feedback-modal.hidden {
    display: none;
}

.feedback-modal-content {
    max-width: 500px;
    margin: 0 auto;
}

.feedback-modal-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

#feedback-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.feedback-modal-explanation {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 0.75rem;
    max-height: 15vh;
    overflow-y: auto;
}

/* Compact Next Button */
.btn-modal {
    width: auto;
    float: right;
    padding: 0.5rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--primary-color);
    border: none;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.feedback-modal::after {
    content: "";
    display: table;
    clear: both;
}


/* Progress Grid Compact */
.progress-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    margin-bottom: 0.5rem;
}

/* Question Count Display Compact */
.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Difficulty Badge Compact */
.difficulty-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.difficulty-badge.basic {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.difficulty-badge.standard {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.difficulty-badge.advanced {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* --- Selection Mode Styles --- */
.selection-action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    margin-top: 1rem;
    margin-bottom: 1rem;
    animation: slideDown 0.3s ease;
}

.selection-action-bar.hidden {
    display: none;
}

#selected-count-label {
    font-weight: 600;
    color: #fca5a5;
}

.btn-danger-compact {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.5);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-danger-compact:hover {
    background: rgba(239, 68, 68, 0.4);
    color: white;
}

.material-checkbox-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-right: 10px;
}

.material-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Updated List Item Layout for Selection */
.material-list-item.selection-mode {
    border-color: rgba(255, 255, 255, 0.2);
    cursor: pointer;
}

.material-list-item.selected {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary-color);
}

/* Ensure checkbox sits nicely */
.material-list-item {
    display: flex;
    align-items: center;
    /* justify-content: space-between; -- Use existing layout but append checkbox */
}

/* Modifying existing layout slightly */
.material-list-Main-Wrapper {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- Quiz Preview Modal --- */
.preview-modal-content {
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
}

.preview-title {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    text-align: center;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.preview-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

.preview-image-container {
    aspect-ratio: 4 / 3;
    /* Match 4x3 grid panel ratio */
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-image-sliced {
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    /* Remove the scale to prevent cropping issues */
}


.preview-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.preview-question {
    padding: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-light);
    line-height: 1.4;
}

.preview-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.preview-actions .btn {
    flex: 1;
    max-width: 200px;
}

@media (max-width: 600px) {
    .preview-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Generation Settings Modal */
.gen-settings-modal-content {
    max-width: 500px;
    width: 100%;
    padding: 1.5rem;
}

.level-button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.level-btn {
    flex: 1 1 calc(50% - 0.5rem);
    padding: 0.75rem 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.level-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
}

.level-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.gen-textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 1rem;
    resize: vertical;
    min-height: 80px;
    margin-top: 0.5rem;
}

.gen-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.gen-textarea::placeholder {
    color: var(--text-muted);
}


.mini-review-container.hidden {
    display: none;
}

/* Generating screen layout fix */
#generating-screen .container.center {
    justify-content: flex-start;
    padding-top: 15vh;
    min-height: auto;
    overflow-y: auto;
    max-height: 100vh;
}

.mini-review-label {
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 1rem;
    text-align: center;
}

.mini-q-text {
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.mini-choices {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mini-choice-btn {
    padding: 0.75rem 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.mini-choice-btn:hover:not(:disabled) {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
}

.mini-choice-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.mini-choice-btn.correct {
    background: rgba(16, 185, 129, 0.3);
    border-color: var(--success);
}

.mini-choice-btn.incorrect {
    background: rgba(239, 68, 68, 0.3);
    border-color: var(--danger);
}

.mini-feedback {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
}

.mini-feedback.correct {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.mini-feedback.incorrect {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.mini-next-btn {
    margin-top: 1rem;
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.mini-next-btn:hover {
    background: var(--primary-hover);
}

/* Preview List Layout for Image-less Quizzes */
.preview-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.preview-list-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
}

.preview-q-number {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
}

.preview-q-text {
    flex: 1;
    color: var(--text-main);
    line-height: 1.5;
    font-size: 0.95rem;
}

/* ========================================
   MOBILE RESPONSIVE FIXES
   ======================================== */

/* Modal mobile overflow fix */
@media screen and (max-width: 768px) {
    .modal {
        padding: 0.5rem;
    }

    .modal-content,
    .gen-settings-modal-content,
    .preview-modal-content {
        max-height: 90vh;
        overflow-y: auto;
        margin: 1rem;
        width: calc(100% - 2rem);
        max-width: none;
    }

    .preview-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .share-modal .modal-content {
        padding: 1rem;
    }

    .share-options {
        flex-direction: column;
    }

    .qr-container {
        padding: 1rem;
    }

    #qr-code {
        width: 150px;
        height: 150px;
    }
}

/* Quiz answer explanation - move correct answer to top */
.choice-btn.correct-revealed {
    order: -1 !important;
    background: rgba(16, 185, 129, 0.2) !important;
    border-color: #10b981 !important;
    margin-bottom: 0.5rem;
}

.choices-container.show-explanation {
    display: flex;
    flex-direction: column;
}

/* Ensure explanation is visible below correct answer */
.explanation-box {
    order: 0;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--glass-bg);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

/* ========================================
   Delete Modal & Inline Delete Button
   ======================================== */

/* Inline delete button in material list */
.btn-delete-inline {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.2s, transform 0.2s;
    padding: 8px;
    flex-shrink: 0;
}

.btn-delete-inline:hover {
    opacity: 1;
    transform: scale(1.1);
}

.material-list-item:hover .btn-delete-inline {
    opacity: 0.7;
}

/* Delete Modal Content */
.delete-modal-content {
    max-width: 420px;
}

.delete-modal-body {
    padding: 1rem 0;
}

.delete-modal-body>p {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.delete-modal-body #delete-modal-title {
    color: var(--text-main);
    font-weight: 600;
}

/* Delete Options */
.delete-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.delete-option-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.delete-option-btn:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.delete-option-btn.device {
    border-color: rgba(99, 102, 241, 0.3);
}

.delete-option-btn.cloud {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

.delete-option-btn.cloud:hover {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.15);
}

.delete-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.delete-option-text {
    flex: 1;
}

.delete-option-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-main);
}

.delete-option-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Material list wrapper adjustment for delete button */
.material-list-Main-Wrapper {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 1rem;
}

.material-list-main {
    flex: 1;
    min-width: 0;
}

.material-list-stats {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ========================================
   Improved Modal Header & Close Button
   ======================================== */

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

/* Improved close button */
.btn-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: scale(1.05);
}

/* Delete modal specific adjustments */
.delete-modal-content {
    max-width: 420px;
    width: calc(100% - 2rem);
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}

/* Mobile responsive for modals */
@media (max-width: 480px) {
    .modal-content {
        width: calc(100% - 2rem);
        margin: 1rem;
        padding: 1.5rem;
        border-radius: 20px;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }

    .delete-modal-content {
        width: calc(100% - 2rem);
        max-width: none;
    }

    .delete-option-btn {
        padding: 14px;
        gap: 12px;
    }

    .delete-icon {
        font-size: 1.5rem;
    }

    .delete-option-title {
        font-size: 0.95rem;
    }

    .delete-option-desc {
        font-size: 0.8rem;
    }
}

/* Selection action bar improvements */
.selection-action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    margin-bottom: 1rem;
}

.selection-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-compact {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-compact:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-danger-compact {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Compact Stats Grid */
.stats-grid-compact {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 1.5rem;
}

@media (min-width: 480px) {
    .stats-grid-compact {
        grid-template-columns: repeat(4, 1fr);
    }
}

.stat-card-compact {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 0.75rem;
    text-align: center;
    border: 1px solid var(--glass-border);
}

.stat-label-compact {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}


/* Mini Review Floating Container */
#mini-review-floating {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
    max-width: 350px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: left 0.3s ease;
}

@media (min-width: 768px) {

    /* Settings Data Management Cards */
    .data-management-grid {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin-top: 1rem;
    }

    .setting-card {
        display: flex;
        align-items: center;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 1rem;
        gap: 1rem;
    }

    .setting-card.danger-zone {
        border-color: rgba(239, 68, 68, 0.3);
        background: rgba(239, 68, 68, 0.05);
    }

    .setting-card-icon {
        font-size: 1.5rem;
        width: 40px;
        text-align: center;
    }

    .setting-card-content {
        flex: 1;
    }

    .setting-card-title {
        font-weight: 700;
        margin-bottom: 0.25rem;
        color: var(--text-main);
    }

    .setting-card-desc {
        font-size: 0.85rem;
        color: var(--text-secondary);
    }
}

/* --- Quiz Image --- */
/* --- Quiz Image --- */
/* --- Quiz Image --- */
.quiz-image-container {
    width: 80%;
    /* Requested 80% width relative to options (or container) */
    max-width: 400px;
    /* Reasonable max size */
    margin: 0 auto 1.5rem;
    aspect-ratio: 1 / 1 !important;
    /* Square forced */
    border-radius: 16px;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.3);
    background-repeat: no-repeat;
    /* grid-mode will set background-size/position */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.quiz-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Ensure container has height even if img is hidden in grid-mode */
.quiz-image-container.grid-mode {
    display: block !important;
}

/* Certificate Redesign Enhancements */
/* Certificate Redesign Enhancements */
.rank-main-visual-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 1.5rem 0 1rem;
    perspective: 1000px;
}

.rank-main-visual {
    width: 220px;
    height: 220px;
    background-color: #1e293b;
    border-radius: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
    animation: rankPopIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    border: 4px solid transparent;
}

.rank-main-visual.rank-gold {
    border-color: #fbbf24;
    box-shadow: 0 10px 30px rgba(251, 191, 36, 0.5);
}

.rank-main-visual.rank-silver {
    border-color: #94a3b8;
    box-shadow: 0 10px 30px rgba(148, 163, 184, 0.5);
}

.rank-main-visual.rank-bronze {
    border-color: #64748b;
    box-shadow: 0 10px 30px rgba(100, 116, 139, 0.5);
}

.rank-main-image {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: transform 0.5s ease;
}

.rank-main-visual:hover .rank-main-image {
    transform: scale(1.1);
}

.rank-visual-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.4), transparent);
    transform: skewX(-25deg);
    animation: shine 3s infinite;
}

@keyframes rankPopIn {
    0% {
        transform: scale(0.5) rotateX(20deg);
        opacity: 0;
    }

    100% {
        transform: scale(1) rotateX(0);
        opacity: 1;
    }
}

@keyframes shine {
    0% {
        left: -100%;
    }

    20% {
        left: 200%;
    }

    100% {
        left: 200%;
    }
}

/* Adjust existing showcase to be smaller/secondary */
.rank-showcase {
    margin-top: 0.5rem !important;
    gap: 8px !important;
}

.rank-slot {
    width: 60px !important;
    height: 60px !important;
    border-radius: 8px !important;
}

/* Certificate Title Impact */
.certificate-quiz-title {
    font-size: 1.4rem !important;
    background: linear-gradient(45deg, #fbbf24, #f59e0b);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin: 0.5rem 0 !important;
}

/* Action Buttons Restyling */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 2rem;
    width: 100%;
}

.action-buttons button {
    border-radius: 12px;
    font-weight: bold;
    font-size: 0.95rem;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.action-buttons button:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.action-buttons button:active {
    transform: translateY(2px);
}

/* Share Button (Full Width usually, or split) */
#share-result-btn {
    grid-column: span 2;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Retry */
#restart-quiz-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

/* Create Own */
#create-own-quiz-btn {
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

/* --- Public Gallery Styles --- */
.seo-section {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(139, 92, 246, 0.1));
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    text-align: center;
}

.seo-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: 0.5rem;
}

.seo-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.seo-keywords {
    display: inline-block;
    margin-top: 0.5rem;
    color: var(--primary);
    font-size: 0.85rem;
}

/* Public Gallery Button */
.btn-public-gallery {
    width: 100%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border: none;
    border-radius: 16px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
    color: white;
    transition: all 0.2s;
}

.btn-public-gallery:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4);
    filter: brightness(1.1);
}

.gallery-icon {
    font-size: 2rem;
}

.gallery-text {
    flex: 1;
    text-align: left;
    display: flex;
    flex-direction: column;
}

.gallery-title {
    font-weight: bold;
    font-size: 1.1rem;
}

.gallery-desc {
    font-size: 0.85rem;
    opacity: 0.9;
}

.gallery-arrow {
    font-size: 1.2rem;
    font-weight: bold;
    opacity: 0.8;
}

/* Loader */
.loader-spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--primary);
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

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

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

/* --- Quiz Preview Modal Styles --- */
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 4px;
}

.preview-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.preview-image-container {
    width: 100%;
    aspect-ratio: 1 / 1 !important;
    /* Force Square */
    border-radius: 8px;
    overflow: hidden;
    background: #0f172a;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-image-sliced {
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    /* Background size/pos handled inline */
}

.preview-question {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.preview-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
}

.preview-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 50vh;
    overflow-y: auto;
}

.preview-list-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.75rem;
    border-radius: 8px;
    display: flex;
    gap: 1rem;
    align-items: center;
    border: 1px solid var(--border-color);
}

.preview-q-number {
    font-weight: bold;
    color: var(--primary);
    min-width: 30px;
}

.preview-q-text {
    font-size: 0.9rem;
    color: var(--text-main);
}

.action-buttons button:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.action-buttons button:active {
    transform: translateY(0);
}

/* Share Button (Full Width usually, or split) */
#share-result-btn {
    grid-column: span 2;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Retry */
#restart-quiz-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

/* Create Own */
#create-own-quiz-btn {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

/* ===== Public Gallery Grid ===== */
#public-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 1rem;
}

.public-quiz-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    aspect-ratio: 1 / 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.public-quiz-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.public-quiz-card:active {
    transform: scale(0.98);
}

.public-card-bg {
    position: absolute;
    inset: 0;
    opacity: 0.9;
}

.public-card-content {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
    text-align: center;
    color: white;
}

.public-card-title {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
    word-break: break-word;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    margin-bottom: 6px;
}

.public-card-summary {
    font-size: 0.7rem;
    font-weight: 400;
    line-height: 1.3;
    opacity: 0.9;
    word-break: break-word;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.public-card-meta {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-top: 6px;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ========================================
   Legal Section Styles
   ======================================== */

.legal-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.legal-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.legal-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.legal-link-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
}

.legal-link-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
}

.legal-icon {
    font-size: 1.2rem;
}

.legal-arrow {
    margin-left: auto;
    color: var(--text-muted);
}

.legal-note {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Content Confirmation Checkbox */
.content-confirm-section {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    padding: 1rem;
    margin: 1rem 0;
}

.content-confirm-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-main);
    line-height: 1.5;
}

.content-confirm-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.content-confirm-text {
    flex: 1;
}

.content-confirm-text a {
    color: var(--primary);
    text-decoration: underline;
}

/* Report Button for Public Gallery */
.report-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.public-card:hover .report-btn {
    opacity: 1;
}

.report-btn:hover {
    background: var(--danger);
}

/* Report Modal */
.report-modal-content {
    max-width: 400px;
}

.report-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}

.report-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.report-option:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.report-option input[type="radio"] {
    accent-color: var(--primary);
}

.report-submit-btn {
    width: 100%;
    margin-top: 1rem;
}

/* --- Fixes for UI Issues --- */

/* 1. Modal Close Button */
.btn-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* 2. Public Quiz Card Updates for Report Button */
.public-quiz-card {
    position: relative;
    /* Ensure absolute children are relative to this */
}

.report-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    font-size: 1rem;
    transition: all 0.2s;
    opacity: 0.8;
}

.report-btn:hover {
    transform: scale(1.1);
    background: rgba(239, 68, 68, 0.4);
    opacity: 1;
}

/* 3. Settings Screen Overflow Fix */
#settings-screen {
    /* Ensure it can scroll independently if needed, or play nice with body scroll */
    min-height: 100vh;
    padding-bottom: 120px !important;
    /* Extra padding for bottom nav/sidebar safety */
}

/* Ensure Settings Content doesn't get hidden */
.settings-tab-content.active {
    padding-bottom: 2rem;
}


/* --- Refinements based on User Feedback --- */

/* 1. Modal Scrolling Fix */
.modal-content,
.privacy-modal-content {
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.privacy-content {
    overflow-y: visible;
    /* Let parent scroll */
    padding-bottom: 2rem;
}

/* 2. Settings Tabs Width Consistency */
.settings-tab-content {
    max-width: 800px;
    /* Constrain width for readability on large screens */
    margin: 0 auto;
    /* Center it */
}

/* 3. Report Button & Description Refinements */
.report-btn {
    top: auto !important;
    /* Override previous top: 10px */
    bottom: 15px !important;
    /* Move to bottom right */
    right: 15px !important;
}

.public-card-summary {
    white-space: normal !important;
    /* Allow wrapping */
    overflow: visible !important;
    text-overflow: clip !important;
    text-align: left !important;
    display: block !important;
    /* Remove any flex constraints if needed */
    margin-right: 40px;
    /* Avoid partial overlap with button if text is long, though button is bottom-right now */
    margin-bottom: 2rem;
    /* Ensure space for the button at bottom */
    font-size: 0.9rem;
    line-height: 1.5;
    opacity: 0.9;
}

.public-quiz-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 180px;
    /* Ensure enough height for expanded text */
    padding-bottom: 3rem;
    /* Space for bottom button */
}

.public-card-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.public-card-title {
    margin-bottom: 0.75rem;
}

/* Adjust Settings Text Areas to fill the new constrained width nicely */
.prompt-textarea {
    width: 100%;
}


/* --- 2:1 Landscape Card Redesign --- */

.public-quiz-card {
    /* Change from square to 2:1 landscape */
    aspect-ratio: 2 / 1;
    min-height: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    /* Align content to bottom */
    position: relative;
    padding: 0;
    overflow: hidden;
    /* Ensure existing padding doesn't break layout */
    padding-bottom: 0 !important;
}

.public-card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.report-btn {
    /* Ensure button is on top of content */
    z-index: 30 !important;
    bottom: 12px !important;
    right: 12px !important;
    top: auto !important;
}

.public-card-content {
    /* Content overlay on top of background */
    position: relative;
    z-index: 10;
    padding: 1rem 1.25rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Center text vertically or keep top? */
    /* Let's use darker gradient overlay for readability */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 60%, rgba(0, 0, 0, 0.1) 100%);
    pointer-events: none;
    /* Let clicks pass through to card */
}

/* Adjust Text Balance */
.public-card-title {
    font-size: 1.2rem;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    /* Limit lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    /* Allow selecting text if needed */
}

.public-card-summary {
    font-size: 0.85rem;
    line-height: 1.4;
    opacity: 0.9;
    margin-bottom: 0 !important;
    /* Remove bottom margin as button is absolute */
    /* Limit lines */
    display: -webkit-box !important;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    /* Ensure it doesn't overlap the button visually if text is long */
    padding-right: 40px;
    pointer-events: auto;
}

.public-card-meta {
    font-size: 0.75rem;
    margin-top: auto;
    /* Push to bottom if content is short? */
    /* Actually with 2:1, space is tight. Maybe hide meta or put same line? */
    display: none;
    /* Hide question count for cleaner look? Or minimal? */
}

/* Specific overrides for the appended styles from previous steps */
.public-quiz-card {
    padding-bottom: 0 !important;
}


/* --- Public Library Grid Layout 2-Column Fix --- */
#public-list.materials-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* Mobile: 1 column */
    gap: 1.5rem;
    width: 100%;
}

/* Ensure no max-width constraints on the container itself restricted it */
#public-library-screen .container {
    max-width: 1000px;
    /* Allow wider container for 2 columns */
}

@media (min-width: 768px) {
    #public-list.materials-grid {
        grid-template-columns: 1fr 1fr;
        /* Desktop: 2 columns */
        gap: 2rem;
    }

    /* Ensure cards take full width of the grid cell */
    .public-quiz-card {
        width: 100%;
        margin: 0;
    }
}

/* Enhancing Readability as requested */
.public-card-title {
    font-size: 1.4rem;
    /* Larger title */
    font-weight: 800;
    margin-bottom: 0.75rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    /* Stronger shadow */
}

.public-card-summary {
    font-size: 1rem;
    /* Larger text */
    line-height: 1.6;
    background: rgba(0, 0, 0, 0.4);
    /* Semi-transparent bg for just text if needed, or rely on gradient */
    padding: 0.5rem;
    border-radius: 8px;
    margin-right: 0;
    /* Align full width */
    max-width: 90%;
    /* Avoid hitting the button if it's there */
}


/* --- Simple Public Card Revert --- */
.public-quiz-card {
    aspect-ratio: auto;
    /* Remove fixed ratio */
    min-height: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.5rem;
    background: var(--glass-bg);
    /* Revert to glass */
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.public-quiz-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    background: rgba(255, 255, 255, 0.08);
    /* Lighten */
}

/* Remove Image/Gradient Overlay feeling, make it clean */
.public-card-bg {
    display: none;
    /* Hide the gradient background div */
}

.public-card-content {
    background: transparent;
    padding: 0;
    pointer-events: auto;
    height: auto;
    display: block;
}

.public-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    color: white;
    text-shadow: none;
    -webkit-line-clamp: 2;
}

.public-card-summary {
    display: none !important;
    /* Hide summary for cleaner look? User said title, count, author, views */
    /* Or keep it simple? User said 'Title, Question Count, Author Name, View Count'. So hide summary is safe or make it very subtle. */
    /* Let's hiding summary to match 'Simple' request and focus on metadata */
}

.public-card-info {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.info-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Hide report button on card */
.public-quiz-card .report-btn {
    display: none !important;
}

/* --- Report Button in Quiz Header --- */
#report-quiz-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    margin-right: 0.5rem;
    transition: all 0.2s;
    color: var(--text-muted);
}

#report-quiz-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

#report-quiz-btn.hidden {
    display: none;
}


/* --- Richer Public Card Metadata --- */
.public-card-meta-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    /* Ensure no overflow on small screens */
}

.meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    /* Pill shape */
    backdrop-filter: blur(4px);
    transition: all 0.2s;
}

.meta-badge:hover {
    transform: translateY(-1px);
}

/* Align Mini Review Container */
#mini-review-floating {
    width: 90%;
    max-width: 600px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border-radius: 16px;
    padding: 1.5rem;
    position: fixed;
    bottom: 2rem;
    z-index: 9000;
}

#progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    width: 0%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

/* Ensure progress container is visible when generating (controlled by JS typically, or checking ancestors) */
.loading-overlay #progress-container {
    display: block;
}

/* Revert public badge styles to keep it simple but working */
/* ... (Existing code) ... */

/* Specific Badge Styles for Richness */
.badge-q {
    background: rgba(99, 102, 241, 0.15);
    /* Indigo tint */
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge-views {
    background: rgba(16, 185, 129, 0.15);
    /* Emerald tint */
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-author {
    background: rgba(255, 255, 255, 0.05);
    /* Subtle */
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-left: auto;
    /* Push author to the right? Or keep left? */
    /* User said: 'QCount -> Views -> Author' in order. */
    /* If 'margin-left: auto' is removed, they stack left. */
    /* Let's keep them all left for scanning. */
    margin-left: 0;
}


/* --- Simple Metadata Revert (No Badges) --- */
.meta-badge {
    background: transparent !important;
    border: none !important;
    color: var(--text-muted) !important;
    padding: 0 !important;
    backdrop-filter: none !important;
    font-weight: 500;
}

.meta-badge:hover {
    transform: none !important;
    color: white !important;
    /* Slight highlight on hover */
}

/* Force Clickability Safety */
.public-quiz-card,
.public-card-content,
.public-card-title,
.public-card-meta-row,
.public-card-info,
.meta-badge {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Ensure no z-index overlap blocking */
.public-card-bg {
    display: none !important;
    pointer-events: none !important;
}

.public-card-content {
    z-index: 100 !important;
    /* Force on top */
}


/* --- Fix Margin and Text Balance --- */
.public-card-title {
    margin-bottom: 1.5rem !important;
    /* Increase margin significantly */
    line-height: 1.5 !important;
}

.public-card-meta-row {
    margin-top: 0 !important;
    /* Reset margin-top since title pushes it */
}


/* --- Fix Margin and Alignment (User Request) --- */
.public-card-content {
    align-items: center;
    /* Center horizontally in flex column */
    text-align: center;
    /* Center text */
}

.public-card-title {
    margin-bottom: 0.5rem !important;
    /* Reset margin on title */
}

.public-card-meta-row {
    margin-top: 0;
    margin-bottom: 1.5rem !important;
    /* Margin BELOW metadata (10 questions etc) */
    justify-content: center;
    /* Center the row items */
    width: 100%;
}


/* --- FORCE QUIZ SCREEN VISIBILITY --- */
#quiz-screen.active-screen {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 9999 !important;
    /* Ensure it's on top */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-color);
    /* Ensure background is opaque */
    overflow-y: auto;
}

/* Ensure container within quiz screen is visible */
#quiz-screen .container {
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
}


/* --- Fix Quiz Screen Position (scroll reset, no extra margin) --- */
#quiz-screen.active {
    top: 0 !important;
    padding-top: 0 !important;
    margin-top: 0 !important;
}

#quiz-screen .container {
    padding-top: 1rem !important;
    /* Minimal top padding */
    margin-top: 0 !important;
}


/* --- CORRECT Fix Quiz Screen Position (using correct .active class) --- */
#quiz-screen.active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 9999 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: var(--bg-color) !important;
    overflow-y: auto !important;
    padding-top: 0 !important;
    margin-top: 0 !important;
}


/* --- Fix Quiz Screen Container Positioning --- */
#quiz-screen .container.center {
    justify-content: flex-start !important;
    /* Align content to TOP, not center */
    min-height: auto !important;
    padding-top: 1rem !important;
}
/* Quiz Content Wrapper for Desktop Alignment */
.quiz-content-wrapper {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    /* Ensure content inside doesn't overflow weirdly */
}
