/* ==========================================================================
   MODALS.CSS - History, Stats, Saved, Theme, AI Modals
   ========================================================================== */

/* --- Modal Base --- */
#history-modal,
#saved-modal,
#stats-modal,
#theme-modal,
#ask-ai-modal,
#api-key-modal,
#quiz-gen-modal,
#notes-modal,
#canvas-settings-modal,
#canvas-browser-modal,
#canvas-help-modal,
#conversion-progress-modal,
#database-modal,
#export-modal,
#theme-confirm-modal,
#srs-rating-modal,
#adaptive-snapshot-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: color-mix(in srgb, var(--card-bg, rgba(15,23,42,0.6)) 45%, rgba(2,6,23,0.9) 55%);
    z-index: 13000;
    display: none;
    justify-content: center;
    align-items: center;
}

/* Hide scrollbar in history list */
#history-list::-webkit-scrollbar {
    display: none;
}

/* Hide modal backdrop when content is in fullscreen */
#saved-modal:has(.modal-content:fullscreen) {
    background: transparent;
}

#history-modal.active,
#saved-modal.active,
#stats-modal.active,
#theme-modal.active,
#ask-ai-modal.active,
#api-key-modal.active,
#quiz-gen-modal.active,
#notes-modal.active,
#canvas-settings-modal.active,
#canvas-browser-modal.active,
#canvas-help-modal.active,
#conversion-progress-modal.active,
#database-modal.active,
#export-modal.active,
#theme-confirm-modal.active,
#srs-rating-modal.active,
#adaptive-snapshot-modal.active {
    display: flex;
}

/* Theme-dynamic select dropdown */
.theme-select {
    width: 100%;
    padding: 10px 35px 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.2s;
    /* Theme-dynamic text color */
    background-image: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 600;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: var(--g), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat, no-repeat;
    background-position: left, right 12px center;
    background-size: 100%, 12px;
}

.theme-select:hover,
.theme-select:focus {
    border-color: var(--g1, #60a5fa);
    outline: none;
}

.theme-select option {
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    color: #e2e8f0;
    font-weight: normal;
}

/* Theme outline button with gradient border and text */
.theme-outline-btn {
    position: relative;
    padding: 12px 20px;
    border-radius: 12px;
    border: 2px solid var(--g1, #60a5fa);
    background: transparent;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    /* Gradient text */
    background-image: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.theme-outline-btn:hover {
    transform: translateY(-1px);
}

.theme-outline-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#quiz-gen-generate-btn {
    width: 100%;
    min-width: 80px;
}

#quiz-gen-generate-btn:focus,
#quiz-gen-generate-btn:focus-visible {
    outline: none;
}

#quiz-gen-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#quiz-gen-save-prefs-btn {
    min-width: 92px;
    border: 1px solid rgba(148, 163, 184, 0.18) !important;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

#quiz-gen-save-prefs-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

#quiz-gen-save-prefs-btn.is-saved {
    border-color: rgba(110, 231, 183, 0.38) !important;
    background: rgba(16, 185, 129, 0.12);
    box-shadow: 0 0 18px rgba(52, 211, 153, 0.18);
}

#quiz-gen-save-prefs-btn:disabled {
    cursor: not-allowed;
}

.modal-content {
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--bd, #334155);
    padding: 2rem;
    border-radius: 16px;
    width: 550px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.modal-content::-webkit-scrollbar {
    display: none;
}

/* --- Theme Confirm Modal --- */
#theme-confirm-modal {
    z-index: 12050;
}

#theme-confirm-modal .theme-confirm-content {
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--app-border, rgba(148, 163, 184, 0.25));
    border-radius: 16px;
    width: min(440px, 92vw);
    padding: 1.4rem 1.4rem 1.1rem;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
}

#theme-confirm-title {
    margin: 0 0 0.65rem;
    font-size: 1.1rem;
    font-weight: 800;
}

#theme-confirm-message {
    margin: 0;
    color: #cbd5e1;
    line-height: 1.45;
    font-size: 0.95rem;
}

.theme-confirm-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.theme-confirm-actions .glass-btn,
.theme-confirm-actions .theme-outline-btn {
    min-width: 92px;
    justify-content: center;
    padding: 9px 14px;
}

/* --- Adaptive Review Rating Modal --- */
#srs-rating-modal {
    z-index: 12060;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
}

#srs-rating-modal .srs-rating-content {
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--app-border, rgba(148, 163, 184, 0.25));
    border-radius: 16px;
    width: min(560px, 94vw);
    padding: 1.35rem;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
    pointer-events: auto;
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    cursor: default;
}

#srs-rating-modal .srs-rating-content.dragging {
    cursor: grabbing;
    user-select: none;
}

#srs-rating-title {
    margin: 0 0 0.45rem;
    font-size: 1.12rem;
    font-weight: 800;
}

#srs-rating-subtitle {
    margin: 0 0 0.95rem;
    color: #cbd5e1;
    font-size: 0.93rem;
}

.srs-rating-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.srs-rate-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    text-align: left;
    padding: 0.8rem 0.85rem;
    border-radius: 12px;
    border: 1px solid var(--bd, rgba(148, 163, 184, 0.35));
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 86%, rgba(255, 255, 255, 0.05) 14%);
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.15s ease;
}

.srs-rate-btn:hover {
    border-color: var(--g1, #60a5fa);
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 80%, var(--g1, #60a5fa) 20%);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
    transform: translateY(-1px);
}

.srs-rate-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.06);
    color: #dbeafe;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
}

.srs-rate-label {
    background: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 0.95rem;
    font-weight: 700;
}

.srs-rate-note {
    font-size: 0.8rem;
    color: #94a3b8;
}

@media (max-width: 620px) {
    .srs-rating-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Export Modal Buttons --- */
.export-option-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.export-option-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateX(4px);
}

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

.export-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.export-title {
    font-size: 1rem;
    font-weight: 600;
    color: #e2e8f0;
}

.export-desc {
    font-size: 0.8rem;
    color: #64748b;
}

/* --- History Items --- */
.hist-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.hist-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--amb-c1, #f59e0b);
}

/* History modal wider */
#history-modal .modal-content {
    width: 650px;
}

.hist-meta {
    display: flex;
    flex-direction: column;
    flex: 1;
    margin-right: 15px;
    min-width: 0;
    overflow: hidden;
}

.hist-date {
    font-size: 0.85rem;
    color: #94a3b8;
}

.hist-name {
    font-size: 1.05rem;
    font-weight: 700;
    background: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.hist-detail {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 3px;
}

.hist-del {
    color: #ef4444;
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
}

.hist-del:hover {
    background: rgba(239, 68, 68, 0.2);
    border-radius: 4px;
}

.hist-rename {
    background: rgba(255, 255, 255, 0.06);
    border: none;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 5px 12px;
    margin-right: 10px;
    border-radius: 20px;
    opacity: 0.85;
    transition: all 0.2s;
}

.hist-rename span {
    background: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hist-rename:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}

/* --- Inline Rename Edit UI --- */
.hist-rename-edit {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: rgba(30, 41, 59, 0.9);
    border-radius: 8px;
    border: 1px solid rgba(96, 165, 250, 0.3);
    animation: renameSlideIn 0.2s ease-out;
}

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

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

.hist-rename-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.95rem;
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 6px;
    color: #f1f5f9;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.hist-rename-input:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.hist-rename-input::placeholder {
    color: #64748b;
}

.hist-rename-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.hist-rename-save,
.hist-rename-cancel {
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.hist-rename-save {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border: none;
    color: white;
    font-weight: 500;
}

.hist-rename-save:hover {
    background: linear-gradient(135deg, #16a34a, #15803d);
    transform: translateY(-1px);
}

.hist-rename-cancel {
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #94a3b8;
}

.hist-rename-cancel:hover {
    background: rgba(148, 163, 184, 0.1);
    border-color: rgba(148, 163, 184, 0.5);
}

/* --- Saved List Styles --- */
#saved-list {
    max-height: 60vh;
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#saved-list::-webkit-scrollbar {
    display: none;
}

.saved-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.saved-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.saved-q {
    font-weight: bold;
    color: var(--text-q);
    margin-bottom: 5px;
    font-size: 1rem;
}

.saved-a {
    color: #22c55e;
    font-size: 0.95rem;
}

/* Saved question images */
.saved-q-image {
    max-width: 100%;
    max-height: 200px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 12px;
    object-fit: contain;
    background: #000;
    cursor: zoom-in;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.saved-q-image:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.saved-q-image.compact {
    max-height: 100px;
    margin-bottom: 8px;
}

/* --- SAVED MODAL ENHANCED CONTROLS --- */
.saved-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.saved-controls .control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.saved-controls .control-label {
    font-size: 0.8rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.saved-toggle-btn {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.saved-toggle-btn .gradient-text {
    opacity: 0.5;
    filter: grayscale(50%);
    transition: all 0.25s ease;
}

.saved-toggle-btn:hover .gradient-text {
    opacity: 0.8;
    filter: grayscale(20%);
}

.saved-toggle-btn.active {
    border: 1px solid transparent;
    background: linear-gradient(#0f172a, #0f172a) padding-box,
        var(--g) border-box;
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.4), 0 0 24px rgba(167, 139, 250, 0.2);
}

.saved-toggle-btn.active .gradient-text {
    opacity: 1;
    filter: none;
}

.saved-detect-duplicates-btn.detecting,
.saved-detect-duplicates-btn:disabled {
    cursor: wait;
    opacity: 0.72;
}

.saved-detect-duplicates-btn.detecting .gradient-text,
.saved-detect-duplicates-btn:disabled .gradient-text {
    opacity: 0.95;
    filter: none;
}

/* Fullscreen Mode - Browser Fullscreen API */
.modal-content:fullscreen {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0;
    border: none;
    padding: 2rem 3rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
}

.modal-content:fullscreen #saved-list {
    flex: 1;
    max-height: none !important;
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.modal-content:fullscreen #saved-list::-webkit-scrollbar {
    display: none;
}

/* Webkit fallback */
.modal-content:-webkit-full-screen {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0;
    border: none;
    padding: 2rem 3rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
}

.modal-content:-webkit-full-screen #saved-list {
    flex: 1;
    max-height: none !important;
    overflow-y: auto;
}

/* Body class fallback for hiding backdrop */
body.saved-fullscreen-active #saved-modal {
    background: transparent !important;
}

.fullscreen-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #94a3b8;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

/* Source Filter Dropdown */
.source-filter-wrapper {
    position: relative;
}

.source-filter-btn {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.source-filter-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.source-filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 280px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border: 1px solid rgba(96, 165, 250, 0.3);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 20px rgba(96, 165, 250, 0.1);
    z-index: 100;
    display: none;
    margin-top: 4px;
}

.source-filter-dropdown.active {
    display: block;
}

.source-filter-item {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    color: #94a3b8;
    border-left: 3px solid transparent;
}

.source-filter-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
}

.source-filter-item.selected {
    background: linear-gradient(90deg, rgba(96, 165, 250, 0.15), transparent);
    border-left: 3px solid #60a5fa;
    color: #fff;
}

.source-filter-item .check {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.source-filter-item.selected .check {
    background: #60a5fa;
    border-color: #60a5fa;
}

/* Active Source Chips */
.source-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.source-chip {
    padding: 4px 10px;
    background: rgba(96, 165, 250, 0.2);
    border: 1px solid rgba(96, 165, 250, 0.4);
    border-radius: 20px;
    font-size: 0.75rem;
    color: #60a5fa;
    display: flex;
    align-items: center;
    gap: 6px;
}

.source-chip .remove {
    cursor: pointer;
    opacity: 0.7;
}

.source-chip .remove:hover {
    opacity: 1;
}

/* --- EXPANDED VIEW STYLES --- */
.saved-item.expanded {
    padding: 18px;
}

.saved-item.expanded .saved-q {
    margin-bottom: 12px;
    font-size: 1.05rem;
}

.saved-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.saved-choice {
    padding: 10px 14px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    color: #94a3b8;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.saved-choice .choice-label {
    font-weight: 700;
    flex-shrink: 0;
    width: 20px;
}

.saved-choice.correct {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.4);
    color: #22c55e;
}

.saved-choice.wrong {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

.saved-choice.user-picked {
    border-width: 2px;
    position: relative;
}

.saved-choice.user-picked::after {
    content: '← Your Answer';
    position: absolute;
    right: 10px;
    font-size: 0.75rem;
    opacity: 0.8;
}

.saved-source-tag {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.saved-q-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.saved-q-main {
    flex: 1;
    min-width: 0;
}

.saved-item.duplicate-entry.exact {
    border-color: rgba(96, 165, 250, 0.22);
}

.saved-item.duplicate-entry.near {
    border-color: rgba(251, 191, 36, 0.24);
}

.saved-item.no-nav {
    cursor: default;
}

.saved-item.no-nav:hover {
    background: rgba(255, 255, 255, 0.03);
}

.saved-duplicate-inline-note {
    margin-top: 2px;
    font-size: 0.78rem;
    color: #8cb4ff;
}

.saved-duplicate-source-note {
    margin-left: 10px;
    color: #8f9fb8;
}

.saved-duplicate-anchor {
    position: relative;
    flex-shrink: 0;
}

.saved-duplicate-chip {
    border: 1px solid rgba(96, 165, 250, 0.28);
    background: rgba(59, 130, 246, 0.12);
    color: #dbeafe;
    font-size: 0.72rem;
    line-height: 1.2;
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
}

.saved-duplicate-chip.near {
    border-color: rgba(251, 191, 36, 0.35);
    background: rgba(245, 158, 11, 0.12);
    color: #fde68a;
}

.saved-duplicate-preview {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(360px, 72vw);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 140;
    pointer-events: auto;
}

.saved-duplicate-anchor:hover .saved-duplicate-preview,
.saved-duplicate-anchor:focus-within .saved-duplicate-preview {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.saved-duplicate-preview-card {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(96, 165, 250, 0.24);
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.92)) 92%, #0b1120 8%);
    box-shadow: 0 16px 40px rgba(2, 6, 23, 0.5);
}

.saved-duplicate-preview-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #7dd3fc;
    margin-bottom: 8px;
}

.saved-duplicate-preview-question {
    color: #e2e8f0;
    font-size: 0.88rem;
    line-height: 1.45;
    margin-bottom: 8px;
}

.saved-duplicate-preview-answer {
    color: #4ade80;
    font-size: 0.8rem;
    margin-bottom: 6px;
}

.saved-duplicate-preview-source,
.saved-duplicate-preview-empty {
    color: #94a3b8;
    font-size: 0.76rem;
}

.saved-duplicate-empty {
    color: #94a3b8;
    text-align: center;
    padding: 22px 12px;
}

.source-filter-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Adaptive Snapshot Modal --- */
#adaptive-snapshot-modal {
    z-index: 12050;
}

.adaptive-snapshot-content {
    max-width: 920px;
    width: 94%;
}

#adaptive-snapshot-list {
    max-height: 62vh;
    overflow-y: auto;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    padding-top: 10px;
}

#adaptive-snapshot-list::-webkit-scrollbar {
    width: 8px;
}

#adaptive-snapshot-list::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.32);
    border-radius: 8px;
}

.adaptive-rank-group {
    margin-bottom: 14px;
}

.adaptive-rank-heading {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 8px 0 10px;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.14), rgba(15, 23, 42, 0.72));
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #e2e8f0;
    cursor: pointer;
    transition: transform 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
}

.adaptive-rank-heading:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.adaptive-rank-heading:focus-visible {
    outline: 2px solid rgba(96, 165, 250, 0.65);
    outline-offset: 2px;
}

.adaptive-rank-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.adaptive-rank-chevron {
    font-size: 0.72rem;
    transition: transform 0.2s ease;
}

.adaptive-rank-count {
    font-size: 0.75rem;
    font-weight: 700;
    color: #dbeafe;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.38);
    padding: 2px 8px;
    background: rgba(2, 6, 23, 0.4);
}

.adaptive-rank-heading.rank-1 {
    border-color: rgba(239, 68, 68, 0.55);
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.24), rgba(127, 29, 29, 0.18) 52%, rgba(2, 6, 23, 0.78));
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.2);
}

.adaptive-rank-heading.rank-2 {
    border-color: rgba(234, 179, 8, 0.55);
    background: linear-gradient(90deg, rgba(234, 179, 8, 0.24), rgba(113, 63, 18, 0.2) 52%, rgba(2, 6, 23, 0.78));
    box-shadow: inset 0 0 0 1px rgba(234, 179, 8, 0.2);
}

.adaptive-rank-heading.rank-3 {
    border-color: rgba(59, 130, 246, 0.55);
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.24), rgba(30, 58, 138, 0.2) 52%, rgba(2, 6, 23, 0.78));
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.2);
}

.adaptive-rank-heading.rank-4 {
    border-color: rgba(34, 197, 94, 0.55);
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.24), rgba(21, 128, 61, 0.2) 52%, rgba(2, 6, 23, 0.78));
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.2);
}

.adaptive-rank-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.adaptive-rank-group.collapsed .adaptive-rank-body {
    display: none;
}

.adaptive-rank-group.collapsed .adaptive-rank-chevron {
    transform: rotate(-90deg);
}

.adaptive-entry {
    position: relative;
    padding-right: 78px;
    cursor: default;
}

.adaptive-rank-pill {
    position: absolute;
    right: 10px;
    top: 10px;
    font-size: 0.74rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 4px 8px;
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.adaptive-rank-pill.rank-1 {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.14);
}

.adaptive-rank-pill.rank-2 {
    color: #facc15;
    border-color: rgba(234, 179, 8, 0.45);
    background: rgba(234, 179, 8, 0.14);
}

.adaptive-rank-pill.rank-3 {
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.45);
    background: rgba(96, 165, 250, 0.14);
}

.adaptive-rank-pill.rank-4 {
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.45);
    background: rgba(74, 222, 128, 0.14);
}

.adaptive-entry .saved-a.adaptive-correct {
    color: #22c55e;
}

.adaptive-entry .saved-a.adaptive-incorrect {
    color: #ef4444;
}
.adaptive-entry-meta {
    margin-top: 8px;
    font-size: 0.75rem;
    color: #94a3b8;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* --- STATS STYLES --- */
.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-title {
    font-size: 0.85rem;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 10px;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12px, 1fr));
    gap: 4px;
    margin-top: 10px;
}

.heatmap-day {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: #334155;
}

.heatmap-day.l1 {
    background: #0e4429;
}

.heatmap-day.l2 {
    background: #006d32;
}

.heatmap-day.l3 {
    background: #26a641;
}

.heatmap-day.l4 {
    background: #39d353;
}

.hard-q-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
}

.hard-q-item:last-child {
    border-bottom: none;
}

.hard-q-score {
    color: #ef4444;
    font-weight: bold;
}

/* --- XP Stats Grid (Enhanced Stats Modal) --- */
.xp-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    font-family: var(--font-family, inherit);
}

.xp-stat-box {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.xp-stat-box.full-width {
    grid-column: 1 / -1;
}

.xp-stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-a, #e2e8f0);
    line-height: 1.2;
}

.xp-stat-label {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    margin-top: 4px;
}

.xp-progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

.xp-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--g1, #4ade80), var(--g2, #22d3ee));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.xp-progress-text {
    font-size: 0.8rem;
    color: #94a3b8;
}

/* --- Power-Ups List in Stats --- */
#active-powerups-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.powerup-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.powerup-count {
    color: var(--g1, #4ade80);
    font-weight: 700;
}

.no-powerups {
    color: #64748b;
    font-size: 0.9rem;
    text-align: center;
    padding: 15px;
}

/* --- Hard Mode Type Input --- */
.hard-mode-input-container {
    margin-bottom: 15px;
    display: none;
}

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

.hard-mode-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: var(--text-a, #e2e8f0);
    font-size: 1rem;
    font-family: var(--font-family, inherit);
    transition: all 0.2s ease;
}

.hard-mode-input::placeholder {
    color: #64748b;
}

.hard-mode-input:focus {
    outline: none;
    border-color: var(--g1, #4ade80);
    box-shadow: 0 0 20px color-mix(in srgb, var(--g1, #4ade80) 20%, transparent);
}

.hard-mode-reveal-btn {
    margin-top: 10px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--g1, #4ade80), var(--g2, #22d3ee));
    border: none;
    border-radius: 8px;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hard-mode-reveal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.hard-mode-feedback {
    margin-top: 10px;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    display: none;
}

.hard-mode-feedback.correct {
    display: block;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #22c55e;
}

.hard-mode-feedback.partial {
    display: block;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.4);
    color: #fbbf24;
}

.hard-mode-feedback.wrong {
    display: block;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

/* ==========================================================================
   QUIZ GENERATION MODAL
   ========================================================================== */

.quiz-gen-options {
    margin: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.quiz-gen-step-card {
    position: relative;
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background:
        linear-gradient(145deg, rgba(15, 23, 42, 0.9), rgba(5, 10, 24, 0.86)),
        radial-gradient(circle at top right, rgba(96, 165, 250, 0.12), transparent 46%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transition: opacity 0.25s ease, filter 0.25s ease, transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.quiz-gen-step-card.is-current {
    border-color: rgba(96, 165, 250, 0.38);
    box-shadow: 0 10px 28px rgba(2, 6, 23, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.quiz-gen-step-card.is-complete {
    border-color: rgba(125, 211, 252, 0.24);
}

.quiz-gen-step-card.is-upcoming {
    opacity: 0.48;
    filter: blur(3px) saturate(0.88);
    transform: scale(0.992);
}

.quiz-gen-step-card.is-upcoming:hover,
.quiz-gen-step-card.is-upcoming:focus-within {
    opacity: 0.72;
    filter: blur(1.4px);
}

.quiz-gen-step-card-compact {
    padding-block: 14px;
}

.quiz-gen-step-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.quiz-gen-step-badge {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: #dbeafe;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.24), rgba(244, 114, 182, 0.24));
    border: 1px solid rgba(148, 163, 184, 0.22);
    flex: 0 0 auto;
}

.quiz-gen-step-title {
    color: #e5eefc;
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.15;
}

.quiz-gen-step-subtitle {
    color: #7f8da3;
    font-size: 0.78rem;
    line-height: 1.5;
    margin-top: 4px;
}

.quiz-gen-field-label {
    color: #d6e2f4;
    font-size: 0.82rem;
    font-weight: 700;
    display: block;
    margin-bottom: 10px;
}

.quiz-gen-field-hint {
    color: #73849b;
    font-size: 0.74rem;
    line-height: 1.45;
    display: block;
    margin-top: 6px;
}

.quiz-gen-field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.quiz-gen-help-popover {
    position: relative;
    flex: 0 0 auto;
}

.quiz-gen-help-trigger {
    width: 32px;
    min-width: 32px;
    height: 28px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.88), rgba(15, 23, 42, 0.92));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.quiz-gen-help-trigger .gradient-text {
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1;
}

.quiz-gen-help-trigger:hover,
.quiz-gen-help-popover:focus-within .quiz-gen-help-trigger,
.quiz-gen-help-popover.is-open .quiz-gen-help-trigger {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--g1, #60a5fa) 44%, rgba(148, 163, 184, 0.22) 56%);
    box-shadow: 0 8px 20px rgba(2, 6, 23, 0.28);
}

.quiz-gen-help-tooltip {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: min(430px, calc(100vw - 112px));
    padding: 14px;
    border-radius: 16px;
    border: 1px solid color-mix(in srgb, var(--g1, #60a5fa) 28%, rgba(148, 163, 184, 0.24) 72%);
    background:
        radial-gradient(circle at top right, color-mix(in srgb, var(--g1, #60a5fa) 18%, transparent) 0, transparent 36%),
        linear-gradient(155deg, rgba(10, 16, 32, 0.98), rgba(5, 10, 24, 0.97));
    box-shadow: 0 18px 40px rgba(2, 6, 23, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.985);
    transform-origin: top right;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
    pointer-events: none;
    z-index: 40;
}

.quiz-gen-help-tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 12px;
    width: 16px;
    height: 16px;
    border-left: 1px solid color-mix(in srgb, var(--g1, #60a5fa) 28%, rgba(148, 163, 184, 0.24) 72%);
    border-top: 1px solid color-mix(in srgb, var(--g1, #60a5fa) 28%, rgba(148, 163, 184, 0.24) 72%);
    background: linear-gradient(135deg, rgba(10, 16, 32, 0.99), rgba(7, 12, 26, 0.98));
    transform: rotate(45deg);
}

.quiz-gen-help-popover.is-open .quiz-gen-help-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.quiz-gen-help-tooltip-title {
    color: #edf5ff;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    margin-bottom: 10px;
}

.quiz-gen-help-tooltip-grid {
    display: grid;
    gap: 8px;
}

.quiz-gen-help-sample {
    border-radius: 12px;
    padding: 10px 11px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(15, 23, 42, 0.5);
}

.quiz-gen-help-sample.is-easy {
    border-color: rgba(34, 197, 94, 0.24);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(15, 23, 42, 0.58));
}

.quiz-gen-help-sample.is-moderate {
    border-color: rgba(245, 158, 11, 0.24);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(15, 23, 42, 0.58));
}

.quiz-gen-help-sample.is-difficult {
    border-color: rgba(239, 68, 68, 0.24);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(15, 23, 42, 0.58));
}

.quiz-gen-help-sample-title {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.quiz-gen-help-sample.is-easy .quiz-gen-help-sample-title {
    color: #4ade80;
}

.quiz-gen-help-sample.is-moderate .quiz-gen-help-sample-title {
    color: #fbbf24;
}

.quiz-gen-help-sample.is-difficult .quiz-gen-help-sample-title {
    color: #f87171;
}

.quiz-gen-help-sample-question {
    color: #e2e8f0;
    font-size: 0.76rem;
    line-height: 1.45;
}

.quiz-gen-help-sample-answer {
    margin-top: 6px;
    color: #d7e3f8;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.4;
}

.quiz-gen-help-sample-note,
.quiz-gen-help-tooltip-note {
    color: #8a99b0;
    font-size: 0.72rem;
    line-height: 1.45;
}

.quiz-gen-help-sample-note {
    margin-top: 4px;
}

.quiz-gen-help-tooltip-note {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.quiz-gen-model-wrap {
    position: relative;
}

.quiz-gen-model-wrap > span:not(.quiz-gen-select-caret) {
    display: none;
}

.quiz-gen-model-select {
    width: 100%;
}

.quiz-gen-select-caret {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #94a3b8;
    font-size: 0.7rem;
}

.quiz-gen-buttons {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.quiz-gen-count-btn {
    flex: 1;
    padding: 12px 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.03);
    color: #94a3b8;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
}

.quiz-gen-count-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    color: #e2e8f0;
}

.quiz-gen-count-btn.selected {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(167, 139, 250, 0.2));
    border: 1px solid transparent;
    background-clip: padding-box;
    position: relative;
    color: #fff;
}

.quiz-gen-count-btn.selected::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 13px;
    background: var(--g, linear-gradient(135deg, #60a5fa, #a78bfa));
    z-index: -1;
}

.quiz-gen-prompt-inline {
    margin-top: 12px;
}

.quiz-gen-prompt-inline .source-filter-btn {
    width: auto;
    min-width: 0;
}

.quiz-gen-prompt-hint {
    margin-top: 8px;
}

.quiz-gen-enhancement-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.quiz-gen-enhancement-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quiz-gen-toggle-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(255, 255, 255, 0.025);
    cursor: pointer;
    transition: border-color 0.22s ease, background 0.22s ease, transform 0.22s ease, box-shadow 0.22s ease;
}

.quiz-gen-toggle-card:hover {
    border-color: rgba(148, 163, 184, 0.3);
    background: rgba(255, 255, 255, 0.045);
}

.quiz-gen-toggle-card.is-enabled,
.quiz-gen-toggle-card:has(input:checked) {
    border-color: rgba(96, 165, 250, 0.42);
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.12), rgba(167, 139, 250, 0.08));
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.2);
}

.quiz-gen-toggle-card input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.quiz-gen-toggle-check {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.66);
    box-shadow: inset 0 0 0 3px rgba(2, 6, 23, 0.85);
    flex: 0 0 auto;
    margin-top: 1px;
    transition: border-color 0.22s ease, background 0.22s ease, box-shadow 0.22s ease;
}

.quiz-gen-toggle-card.is-enabled .quiz-gen-toggle-check,
.quiz-gen-toggle-card:has(input:checked) .quiz-gen-toggle-check {
    border-color: rgba(125, 211, 252, 0.72);
    background: linear-gradient(135deg, #60a5fa, #f472b6);
    box-shadow: inset 0 0 0 4px rgba(9, 14, 32, 0.84);
}

.quiz-gen-toggle-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.quiz-gen-toggle-title {
    color: #e6eefc;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.35;
}

.quiz-gen-toggle-description {
    color: #8191a7;
    font-size: 0.77rem;
    line-height: 1.5;
}

.quiz-gen-inline-options {
    display: none;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(255, 255, 255, 0.03);
}

.quiz-gen-inline-options-lg {
    padding: 16px;
}

.quiz-gen-inline-field-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.quiz-gen-inline-field {
    flex: 1 1 220px;
    min-width: 0;
}

.quiz-gen-inline-label {
    color: #cbd5e1;
    font-size: 0.78rem;
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
}

.quiz-gen-inline-select,
.quiz-gen-inline-field .theme-select,
.quiz-gen-advanced-select {
    width: 100%;
}

.quiz-gen-inline-input,
#quiz-gen-expl-prompt {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    background: rgba(15, 23, 42, 0.82);
    border: 1px solid rgba(71, 85, 105, 0.85);
    border-radius: 10px;
    padding: 10px 12px;
    color: #e2e8f0;
    font-size: 0.84rem;
    line-height: 1.45;
}

.quiz-gen-inline-input::placeholder,
#quiz-gen-expl-prompt::placeholder {
    color: #64748b;
}

.quiz-gen-inline-input:focus,
#quiz-gen-expl-prompt:focus {
    outline: none;
    border-color: rgba(96, 165, 250, 0.5);
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.22);
}

.quiz-gen-inline-scope-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
}

.quiz-gen-scope-toggle {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quiz-gen-scope-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(255, 255, 255, 0.04);
    color: #a9b7cb;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.quiz-gen-scope-chip:hover {
    border-color: rgba(148, 163, 184, 0.4);
    color: #e2e8f0;
}

.quiz-gen-scope-chip.selected,
.quiz-gen-scope-chip:has(input:checked) {
    border-color: rgba(96, 165, 250, 0.46);
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.16), rgba(244, 114, 182, 0.14));
    color: #f8fbff;
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.16);
}

.quiz-gen-scope-chip input {
    position: absolute;
    opacity: 0;
    inset: 0;
    cursor: pointer;
}

.quiz-gen-inline-scope-input {
    display: none;
    width: 100%;
    flex: 1 1 auto;
}

.quiz-gen-scope-custom-wrap {
    display: none;
    gap: 10px;
}

.quiz-gen-scope-count-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.quiz-gen-scope-count-prefix,
.quiz-gen-scope-count-suffix {
    color: #cbd5e1;
    font-size: 0.8rem;
    font-weight: 600;
}

.quiz-gen-inline-scope-number {
    width: 110px;
    min-width: 0;
    text-align: center;
    font-weight: 700;
}

.quiz-gen-inline-action {
    min-width: 126px;
    justify-content: center;
}

.quiz-gen-inline-helper {
    color: #74859b;
    font-size: 0.73rem;
    line-height: 1.5;
    margin-top: 8px;
}

.quiz-gen-advanced-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(255, 255, 255, 0.03);
}

.quiz-gen-advanced-copy {
    min-width: 0;
}

.quiz-gen-advanced-note {
    color: #7c8da5;
    font-size: 0.76rem;
    line-height: 1.45;
}

.quiz-gen-concurrency-warning {
    margin-top: 10px;
    font-size: 0.75rem;
    line-height: 1.45;
    color: #94a3b8;
}

.quiz-gen-concurrency-warning.warn {
    color: #fbbf24;
}

.quiz-gen-concurrency-warning.danger {
    color: #f87171;
}

@media (max-width: 720px) {
    .quiz-gen-step-card {
        padding: 14px;
    }

    .quiz-gen-buttons {
        flex-wrap: wrap;
    }

    .quiz-gen-count-btn {
        min-width: calc(50% - 6px);
    }

    .quiz-gen-field-row,
    .quiz-gen-advanced-card {
        flex-direction: column;
        align-items: stretch;
    }

    .quiz-gen-help-popover {
        align-self: flex-end;
    }

    .quiz-gen-help-tooltip {
        width: min(320px, calc(100vw - 44px));
        right: -4px;
    }

    .quiz-gen-inline-field-row,
    .quiz-gen-inline-scope-row {
        flex-direction: column;
    }

    .quiz-gen-scope-count-row {
        align-items: stretch;
    }

    .quiz-gen-inline-scope-number {
        width: 100%;
    }

    .quiz-gen-inline-action,
    .quiz-gen-prompt-inline .source-filter-btn {
        width: 100%;
    }
}

.quiz-gen-progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.quiz-gen-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--g1, #60a5fa), var(--g2, #a78bfa));
    border-radius: 4px;
    transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: width;
    animation: quiz-gen-pulse 1.5s ease-in-out infinite;
}

@keyframes quiz-gen-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* --- PDF Batch List --- */
.quiz-gen-pdf-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    /* Hide scrollbar but keep scroll functionality */
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.quiz-gen-pdf-list::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

.quiz-gen-pdf-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.15s ease;
}

.quiz-gen-pdf-item:last-child {
    border-bottom: none;
}

.quiz-gen-pdf-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.quiz-gen-pdf-item.selected {
    background: rgba(96, 165, 250, 0.1);
}

.quiz-gen-pdf-list.locked .quiz-gen-pdf-item {
    cursor: not-allowed;
    pointer-events: none;
}

.quiz-gen-pdf-list.locked .quiz-gen-pdf-item input[type="checkbox"] {
    pointer-events: none;
}

.quiz-gen-pdf-item.processing {
    animation: pdf-pulse 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes pdf-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 transparent;
        background: rgba(96, 165, 250, 0.1);
    }

    50% {
        box-shadow: 0 0 12px 2px var(--g1, rgba(96, 165, 250, 0.4));
        background: rgba(96, 165, 250, 0.2);
    }
}

/* Generate button pulsating during generation */
#quiz-gen-generate-btn.generating {
    animation: btn-pulse 1.5s ease-in-out infinite;
}

@keyframes btn-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 transparent;
    }

    50% {
        box-shadow: 0 0 15px 3px var(--g1, rgba(96, 165, 250, 0.5));
    }
}

/* Successfully generated PDF - neon green outline */
.quiz-gen-pdf-item.completed {
    border: 2px solid #22c55e;
    background: rgba(34, 197, 94, 0.1);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.3);
}

.quiz-gen-pdf-item.completed .pdf-name {
    color: #4ade80;
}

/* Failed generation - red outline */
.quiz-gen-pdf-item.failed {
    border: 2px solid #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.quiz-gen-pdf-item.failed .pdf-name {
    color: #f87171;
}

.quiz-gen-pdf-item.cancelled {
    border: 2px solid rgba(148, 163, 184, 0.45);
    background: rgba(51, 65, 85, 0.16);
}

.quiz-gen-pdf-item.cancelled .pdf-name {
    color: #cbd5e1;
}

.quiz-gen-pdf-item input[type="radio"] {
    accent-color: var(--g1, #60a5fa);
    width: 16px;
    height: 16px;
}

.quiz-gen-pdf-item .pdf-name {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-main, #e2e8f0);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quiz-gen-existing-badges {
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.quiz-gen-existing-badge {
    margin-left: 0;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.45);
    pointer-events: none;
}

.quiz-gen-existing-badge.quiz-gen-quiz-badge {
    width: auto;
    min-width: 34px;
    padding: 0 6px;
    font-size: 0.56rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.quiz-gen-existing-badge.quiz-gen-expl-badge {
    width: auto;
    min-width: 30px;
    padding: 0 6px;
    font-size: 0.58rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.45);
}

.quiz-gen-pdf-item.has-live-progress .quiz-gen-existing-badges {
    display: none;
}

.quiz-gen-live-badges {
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.quiz-gen-live-badge {
    min-width: 58px;
    height: 22px;
    padding: 0 9px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(226, 232, 240, 0.9);
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.38);
    opacity: 0.6;
    transition: opacity 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, color 0.25s ease, background 0.25s ease;
}

.quiz-gen-live-badge-label,
.quiz-gen-live-badge-progress {
    display: inline-flex;
    align-items: center;
}

.quiz-gen-live-badge-progress {
    font-size: 0.56rem;
    color: rgba(226, 232, 240, 0.72);
}

.quiz-gen-live-badge-quiz {
    border-color: rgba(34, 197, 94, 0.32);
}

.quiz-gen-live-badge-pdf {
    border-color: rgba(56, 189, 248, 0.32);
}

.quiz-gen-live-badge.is-queued {
    opacity: 0.5;
}

.quiz-gen-live-badge.is-active {
    opacity: 0.88;
    transform: translateY(-1px);
}

.quiz-gen-live-badge.is-complete {
    opacity: 1;
    color: #ecfccb;
    background: rgba(22, 101, 52, 0.24);
    border-color: rgba(74, 222, 128, 0.78);
    box-shadow: 0 0 14px rgba(74, 222, 128, 0.24), inset 0 0 10px rgba(74, 222, 128, 0.08);
}

.quiz-gen-live-badge.is-complete .quiz-gen-live-badge-progress {
    color: rgba(220, 252, 231, 0.92);
}

.quiz-gen-live-badge.is-failed,
.quiz-gen-live-badge.is-cancelled {
    opacity: 0.58;
    color: rgba(248, 250, 252, 0.72);
    border-color: rgba(239, 68, 68, 0.36);
    background: rgba(127, 29, 29, 0.14);
}

/* --- AI Response Popup Modal --- */
.ai-popup-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent;
    /* No overlay - content stays visible */
    pointer-events: none;
    z-index: 13020;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.ai-popup-content {
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--bd, #334155);
    border-radius: 16px;
    width: 600px;
    max-width: 100vw;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 30px rgba(56, 189, 248, 0.1);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto;
    position: relative;
}

.ai-popup-modal.active .ai-popup-content {
    transform: scale(1);
}

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

.ai-popup-body {
    padding: 1.5rem;
    overflow-y: auto;
    font-size: 1.05rem;
    line-height: 1.6;
    color: #e2e8f0;
    /* Hide scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.ai-popup-body::-webkit-scrollbar {
    display: none;
}

.ai-popup-body strong {
    color: #38bdf8;
    font-weight: 600;
}

.ai-popup-body em {
    color: #fbbf24;
    font-style: normal;
}

/* Model Selection Cards */
.model-select-label input[type="radio"] {
    display: none;
}

.model-card {
    border: 1px solid #334155;
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border-radius: 8px;
    padding: 10px;
    transition: all 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.model-select-label:hover .model-card {
    border-color: #475569;
    background: rgba(30, 41, 59, 0.8);
}

.model-select-label input:checked+.model-card {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

/* ==========================================================================
   IMPORT MODAL (NEW REVAMPED DESIGN)
   ========================================================================== */

#import-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: color-mix(in srgb, var(--card-bg, rgba(15,23,42,0.6)) 45%, rgba(2,6,23,0.92) 55%);
    z-index: 6000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

#import-modal.active {
    display: flex;
}

.import-modal-content {
    max-width: 800px;
    width: 95%;
    padding: 1.5rem;
    max-height: 90vh;
    overflow-y: auto;
    /* Hide scrollbar but keep scroll functionality */
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.import-modal-content::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

/* Manual mode for paste panel (AI opens in separate window) */
.import-modal-content.manual-mode {
    position: fixed;
    left: 0;
    top: 0;
    width: 50vw;
    max-width: 50vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

.manual-split-layout {
    display: none;
    flex-direction: column;
    flex: 1;
}

/* Hide the header and make textarea grow in manual mode */
.import-modal-content.manual-mode .import-header {
    display: none;
}

/* Hide all content above Paste Quiz JSON in manual mode */
.import-modal-content.manual-mode .import-options-grid {
    display: none !important;
}

.import-modal-content.manual-mode .import-drop-zone {
    display: none !important;
}

.import-modal-content.manual-mode .manual-split-layout {
    height: auto;
}

.paste-instructions {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.paste-instructions p {
    margin: 6px 0;
    font-size: 0.9rem;
    color: #94a3b8;
}

.manual-json-textarea-full {
    flex: 1;
    width: 100%;
    min-height: 200px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    color: #e2e8f0;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    resize: none;
}

.paste-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.paste-actions .welcome-btn {
    flex: 1;
}

.import-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* --- Drag & Drop Zone --- */
.import-drop-zone {
    display: block;
    border: 2px dashed var(--g1, #60a5fa);
    border-radius: 12px;
    padding: 2rem 1.5rem;
    text-align: center;
    margin-bottom: 1.25rem;
    transition: all 0.3s ease;
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    cursor: pointer;
    position: relative;
}

.import-drop-zone:hover {
    border-color: var(--g1, #60a5fa);
    box-shadow: 0 0 20px rgba(96, 165, 250, 0.2);
    background: rgba(30, 41, 59, 0.7);
}

.import-drop-zone.drag-over {
    border-color: var(--g1, #60a5fa);
    background: rgba(30, 41, 59, 0.8);
    box-shadow: 0 0 30px rgba(96, 165, 250, 0.3);
    transform: scale(1.01);
}

.drop-zone-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
    transition: transform 0.3s ease;
}

.import-drop-zone.drag-over .drop-zone-icon {
    transform: scale(1.2);
}

.drop-zone-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main, #e2e8f0);
    margin: 0 0 0.25rem;
}

.drop-zone-subtext {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0;
}

/* --- Two-Column Options Grid --- */
.import-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 700px) {
    .import-options-grid {
        grid-template-columns: 1fr;
    }
}

.import-option-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.75rem;
    min-height: 280px;
    transition: all 0.2s ease;
}

.import-option-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
}

.option-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.option-icon {
    font-size: 1.3rem;
}

.option-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-main, #e2e8f0);
}

.option-badge {
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.option-badge.recommended {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--g1, rgba(96, 165, 250, 0.5));
    /* Gradient text */
    background-image: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.option-badge.free {
    background: rgba(255, 255, 255, 0.05);
    color: #64748b;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.option-desc {
    font-size: 0.85rem;
    color: #94a3b8;
    line-height: 1.5;
    margin: 0 0 3rem;
}

.help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid;
    border-image: var(--g) 1;
    background: rgba(255, 255, 255, 0.05);
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
    transition: all 0.2s;
    /* Override gradient-text's transparent color with visible fallback */
    color: #60a5fa;
}

.help-btn.gradient-text {
    background: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    border: 1.5px solid rgba(96, 165, 250, 0.5);
}

.help-btn:hover {
    box-shadow: 0 0 8px rgba(96, 165, 250, 0.6);
    transform: scale(1.15);
}

/* --- API Key Section --- */
.api-key-section {
    margin-bottom: 1rem;
}

.api-key-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 6px;
    font-weight: 600;
}

.api-key-status {
    font-size: 0.75rem;
}

.api-key-status.saved {
    color: #22c55e;
}

.api-key-status.missing {
    color: #fbbf24;
}

.api-key-input-row {
    display: flex;
    gap: 8px;
}

.api-key-input-row .glass-input {
    flex: 1;
    padding: 10px 14px;
    font-size: 0.9rem;
}

.api-key-input-row .glass-btn {
    padding: 8px 12px;
}

.api-help-text {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 8px;
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.4;
}

.help-icon {
    flex-shrink: 0;
}

.help-link {
    color: var(--g1, #60a5fa);
    text-decoration: none;
    font-weight: 600;
}

.help-link:hover {
    text-decoration: underline;
}

/* --- Import File Section --- */
.import-file-section {
    margin-top: 1rem;
}

.import-file-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: linear-gradient(#0f172a, #0f172a) padding-box,
        var(--g, linear-gradient(135deg, #60a5fa, #a78bfa)) border-box;
    cursor: pointer;
    transition: all 0.2s ease;
}

.import-file-btn:hover {
    box-shadow: 0 0 20px rgba(96, 165, 250, 0.3);
    transform: translateY(-1px);
}

/* --- Manual Route Steps --- */
.manual-step {
    margin-top: 0.75rem;
}

.step-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #cbd5e1;
    margin-bottom: 10px;
    font-weight: 600;
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--g, linear-gradient(135deg, #60a5fa, #a78bfa));
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.manual-ai-buttons {
    display: flex;
    gap: 8px;
}

.manual-ai-btn {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: all 0.2s ease;
}

.manual-ai-btn:hover {
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.manual-tip {
    font-size: 0.75rem;
    color: #64748b;
    margin: 10px 0 0;
    text-align: center;
}

.manual-textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

.manual-textarea::placeholder {
    color: #64748b;
}

.manual-actions {
    display: flex;
    gap: 8px;
}

.manual-actions .welcome-btn {
    flex: 1;
    padding: 10px;
    font-size: 0.9rem;
}

.manual-error {
    color: #ef4444;
    font-size: 0.8rem;
    margin-top: 8px;
    display: none;
}

.manual-error.visible {
    display: block;
}

/* --- Divider --- */
.import-divider {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 1rem 0;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 600;
}

.import-divider::before,
.import-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
}

/* --- Direct Upload Fallback --- */
.import-direct-upload {
    text-align: center;
}

.import-direct-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: all 0.2s ease;
}

.import-direct-btn:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.06);
}

/* ============================================================
   CANVAS LMS STYLES
   ============================================================ */

.canvas-crumb {
    cursor: pointer;
    color: #60a5fa;
    transition: color 0.2s;
}

.canvas-crumb:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.canvas-crumb-sep {
    margin: 0 8px;
    color: #475569;
}

.canvas-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.canvas-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--amb-c1, #f59e0b);
}

.canvas-item-icon {
    font-size: 1.5rem;
    margin-right: 12px;
}

.canvas-item-info {
    flex: 1;
}

.canvas-item-name {
    color: #fff;
    font-weight: 500;
    margin-bottom: 2px;
}

.canvas-item-meta {
    color: #64748b;
    font-size: 0.8rem;
}

.canvas-item-action {
    padding: 6px 12px;
    background: var(--g);
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.canvas-item:hover .canvas-item-action {
    opacity: 1;
}

.canvas-empty {
    text-align: center;
    color: #64748b;
    padding: 3rem;
}

.canvas-loading {
    text-align: center;
    color: #64748b;
    padding: 3rem;
}

.canvas-error {
    text-align: center;
    color: #ef4444;
    padding: 2rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
}

/* ==========================================================================
   CONVERSION PROGRESS MODAL (Theme-Synced)
   ========================================================================== */

.conversion-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.conversion-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--amb-c1, #f59e0b), var(--amb-c2, #ef4444));
    border-radius: 4px;
    transition: width 0.3s ease;
    animation: progressPulse 1.5s ease-in-out infinite;
}

@keyframes progressPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Flash animation for newly imported files */
@keyframes evidenceFlash {

    0%,
    100% {
        box-shadow: 0 0 0 0 transparent;
    }

    25%,
    75% {
        box-shadow: 0 0 20px 5px var(--amb-c1, #f59e0b);
    }
}

.evidence-flash {
    animation: evidenceFlash 1.5s ease-out;
}

/* ==========================================================================
   DATABASE MODAL
   ========================================================================== */

.database-modal-content {
    max-width: 900px !important;
    width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.db-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.db-header-info {
    display: flex;
    gap: 16px;
    align-items: center;
}

.db-header-info span {
    font-size: 0.85rem;
    color: #94a3b8;
}

.db-storage-info {
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 6px;
}

.db-stat-card {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px 24px;
    text-align: center;
}

.db-stat-num {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1.1;
}

.db-stat-label {
    font-size: 0.7rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 4px;
}

.db-content-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.db-content-list::-webkit-scrollbar {
    display: none;
}

.db-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
}

.db-section-header {
    font-size: 0.9rem;
    font-weight: 700;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background 0.2s;
}

.db-section-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.db-section-header span {
    background: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.db-section-header .toggle-icon {
    color: #64748b;
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.db-section.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.db-section-content {
    padding: 12px 16px 16px;
}

.db-section.collapsed .db-section-content {
    display: none;
}

.db-item-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.db-item-list::-webkit-scrollbar {
    display: none;
}

.db-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.db-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.db-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #e2e8f0;
}

.db-item-meta {
    color: #64748b;
    font-size: 0.75rem;
    margin-left: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
}

.db-item-del {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 6px 10px;
    margin-left: 8px;
    transition: all 0.2s;
    font-size: 1rem;
    border-radius: 4px;
}

.db-item-del:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.db-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #334155;
    display: flex;
    gap: 12px;
}

.db-danger-btn {
    border-color: #ef4444 !important;
}

.db-danger-btn span {
    color: #ef4444;
}

/* Session Card Layout */
.db-session-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
}

.db-session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.db-session-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.db-session-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.db-session-name {
    font-weight: 600;
    font-size: 0.95rem;
    background: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.db-session-meta {
    font-size: 0.75rem;
    color: #64748b;
}

.db-session-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.db-session-content {
    padding: 0 16px 16px;
}

.db-session-card.collapsed .db-session-content {
    display: none;
}

.db-session-card.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.db-session-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.db-col {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 12px;
    min-width: 0;
    overflow: hidden;
}

.db-col-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.db-col-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.db-col-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #cbd5e1;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    overflow: hidden;
}

.db-col-item .db-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.db-item-dl {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    font-size: 0.65rem;
    transition: all 0.2s;
    border-radius: 4px;
    flex-shrink: 0;
    position: relative;
    /* Theme gradient text */
    background: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.db-item-dl::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    z-index: -1;
}

.db-item-dl:hover {
    filter: brightness(1.3);
}

.db-item-dl:hover::before {
    background: rgba(0, 0, 0, 0.35);
}

.db-download-all-btn,
.db-session-dup-btn {
    background: rgba(15, 23, 42, 0.68);
    border: 1px solid rgba(148, 163, 184, 0.26);
    cursor: pointer;
    padding: 4px 10px;
    font-size: 0.75rem;
    transition: all 0.2s;
    border-radius: 6px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.db-session-action-label,
.db-session-action-icon {
    background: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.db-session-action-icon {
    display: inline-block;
    font-size: 0.72rem;
    line-height: 1;
}

.db-download-all-btn:hover,
.db-session-dup-btn:hover {
    border-color: rgba(148, 163, 184, 0.42);
    background: rgba(30, 41, 59, 0.82);
    box-shadow: 0 10px 22px rgba(2, 6, 23, 0.28);
    transform: translateY(-1px);
}

.db-session-dup-btn.disabled,
.db-session-dup-btn[aria-disabled="true"] {
    cursor: default;
    opacity: 0.5;
    box-shadow: none;
    transform: none;
}

.db-session-dup-btn.disabled:hover,
.db-session-dup-btn[aria-disabled="true"]:hover {
    box-shadow: none;
    transform: none;
}

.db-session-dup-btn.disabled .db-session-action-label,
.db-session-dup-btn.disabled .db-session-action-icon,
.db-session-dup-btn[aria-disabled="true"] .db-session-action-label,
.db-session-dup-btn[aria-disabled="true"] .db-session-action-icon {
    background: none;
    -webkit-text-fill-color: rgba(148, 163, 184, 0.75);
    color: rgba(148, 163, 184, 0.75);
}

.db-generate-btn {
    background: linear-gradient(var(--card-bg, #0f172a), var(--card-bg, #0f172a)) padding-box,
        var(--g) border-box;
    border: 1px solid transparent;
    cursor: pointer;
    padding: 4px 10px;
    font-size: 0.75rem;
    transition: all 0.2s;
    border-radius: 6px;
    font-weight: 600;
}

.db-generate-btn {
    background: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.db-generate-btn:hover {
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.3);
    transform: translateY(-1px);
}

.db-col-empty {
    font-size: 0.8rem;
    color: #475569;
    font-style: italic;
}

/* Difficulty Selection Options */
.difficulty-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    color: #94a3b8;
}

.difficulty-option input {
    display: none;
}

.difficulty-option:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
}

.difficulty-option.selected {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid color-mix(in srgb, var(--g1, #60a5fa) 58%, var(--g2, #f472b6) 42%) !important;
    box-shadow: none;
    color: #94a3b8;
}

.difficulty-option.selected span {
    background: none;
    -webkit-background-clip: border-box;
    background-clip: border-box;
    -webkit-text-fill-color: currentColor;
    color: inherit;
    font-weight: inherit;
}

/* Quiz Generation Pulsing Animation - for minimized background generation */
.quiz-gen-pulsing {
    animation: quizGenPulse 1.5s ease-in-out infinite;
    position: relative;
}

.quiz-gen-pulsing::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 16px;
    background: var(--g);
    opacity: 0.3;
    filter: blur(8px);
    animation: quizGenPulseGlow 1.5s ease-in-out infinite;
    z-index: -1;
}

@keyframes quizGenPulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(96, 165, 250, 0.3);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 0 25px rgba(167, 139, 250, 0.5), 0 0 40px rgba(96, 165, 250, 0.3);
    }
}

@keyframes quizGenPulseGlow {

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

    50% {
        opacity: 0.5;
        transform: scale(1.05);
    }
}

/* Generated Quizzes Panel Items */
.generated-quizzes-panel {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.generated-quizzes-panel::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.generated-quiz-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.82)) 92%, rgba(255, 255, 255, 0.04) 8%);
    border: 1px solid color-mix(in srgb, var(--bd, #334155) 88%, rgba(255, 255, 255, 0.12) 12%);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.generated-quiz-item:hover {
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.82)) 84%, rgba(255, 255, 255, 0.08) 16%);
    border-color: color-mix(in srgb, var(--bd, #334155) 78%, rgba(255, 255, 255, 0.18) 22%);
    transform: translateX(4px);
}

.generated-quiz-item .quiz-name {
    font-weight: 600;
    background: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 10px;
}

.generated-quiz-item .quiz-count {
    color: #4ade80;
    font-size: 0.85rem;
    font-weight: 500;
    background: rgba(34, 197, 94, 0.15);
    padding: 4px 10px;
    border-radius: 20px;
}

.batch-save-quiz-list {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.batch-save-quiz-list::-webkit-scrollbar {
    display: none;
}

#quiz-gen-modal {
    z-index: 14000;
}

#quiz-gen-modal .modal-content {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#quiz-gen-modal .modal-content::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

#quiz-gen-expl-prompt {
    resize: vertical;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#quiz-gen-expl-prompt::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

#quiz-gen-generate-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    min-width: 240px;
    width: min(280px, 84vw);
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 88%, #10151d 12%);
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    z-index: 50;
}

#quiz-gen-generate-menu.active {
    display: flex;
}

#quiz-gen-generate-menu button {
    width: 100%;
    text-align: left;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: #dbeafe;
    font-size: 0.82rem;
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

#quiz-gen-generate-menu button:hover {
    background: rgba(96, 165, 250, 0.14);
    border-color: rgba(96, 165, 250, 0.48);
}

#quiz-gen-prompt-panel {
    display: none;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    margin-top: 10px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(2, 6, 23, 0.44);
}

#quiz-gen-prompt-panel.active {
    display: flex;
}

.quiz-gen-prompt-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.quiz-gen-prompt-panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.quiz-gen-prompt-panel-title {
    color: #dbeafe;
    font-size: 0.82rem;
    font-weight: 700;
}

.quiz-gen-prompt-header-btn {
    width: auto;
    min-width: 78px;
    justify-content: center;
    text-align: center;
    padding-inline: 12px;
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 84%, white 16%);
    border-color: var(--app-border, rgba(148, 163, 184, 0.28));
    color: #dbeafe;
}

.quiz-gen-prompt-header-btn:hover {
    border-color: rgba(96, 165, 250, 0.42);
    background: rgba(96, 165, 250, 0.12);
}

.quiz-gen-prompt-panel-note {
    color: #94a3b8;
    font-size: 0.72rem;
    line-height: 1.45;
}

#quiz-gen-prompt-editor-input {
    width: 100%;
    min-height: 170px;
    resize: vertical;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(15, 23, 42, 0.78);
    color: #e2e8f0;
    font-size: 0.8rem;
    line-height: 1.5;
    font-family: inherit;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#quiz-gen-prompt-editor-input:focus {
    outline: none;
    border-color: rgba(96, 165, 250, 0.55);
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.22);
}

#quiz-gen-prompt-editor-input::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

#quiz-gen-prompt-expanded-modal {
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 45%, rgba(2, 6, 23, 0.94) 55%);
    z-index: 16080;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 18px;
}

.quiz-gen-prompt-expanded-content {
    width: min(920px, 94vw);
    min-width: min(640px, 94vw);
    max-width: min(1120px, 96vw);
    min-height: 340px;
    max-height: min(90vh, 960px);
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 1.25rem 1.25rem 1rem;
    position: relative;
    resize: both;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--g1, #60a5fa) 20%, var(--bd, #334155) 80%);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.66), 0 0 24px rgba(96, 165, 250, 0.08);
}

.quiz-gen-prompt-expanded-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-right: 42px;
}

.quiz-gen-prompt-expanded-title {
    color: #e6eefc;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.2;
}

.quiz-gen-prompt-expanded-note {
    color: #94a3b8;
    font-size: 0.78rem;
    line-height: 1.5;
    margin-top: 6px;
}

.quiz-gen-prompt-expanded-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.quiz-gen-prompt-expanded-actions .quiz-gen-prompt-header-btn {
    min-height: 38px;
    padding: 0 14px;
    border-radius: 11px;
    border: 1px solid color-mix(in srgb, var(--g1, #60a5fa) 28%, rgba(148, 163, 184, 0.18) 72%);
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.1), rgba(244, 114, 182, 0.08));
    color: #e2e8f0;
    box-shadow: 0 10px 24px rgba(2, 6, 23, 0.28);
}

.quiz-gen-prompt-expanded-actions .quiz-gen-prompt-header-btn:hover {
    border-color: color-mix(in srgb, var(--g1, #60a5fa) 56%, var(--g2, #f472b6) 44%);
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.16), rgba(244, 114, 182, 0.12));
    color: #f8fbff;
}

.quiz-gen-prompt-expanded-close {
    position: absolute;
    top: 14px;
    right: 14px;
    border-color: color-mix(in srgb, var(--g1, #60a5fa) 22%, rgba(148, 163, 184, 0.2) 78%) !important;
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 82%, rgba(96, 165, 250, 0.12) 18%) !important;
    box-shadow: 0 10px 28px rgba(2, 6, 23, 0.32);
}

#quiz-gen-prompt-expanded-input {
    flex: 1;
    min-height: 0;
    width: 100%;
    resize: none;
    overflow-y: auto;
    padding: 16px 18px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(15, 23, 42, 0.82);
    color: #e2e8f0;
    font-size: 1rem;
    line-height: 1.7;
    font-family: inherit;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#quiz-gen-prompt-expanded-input:focus {
    outline: none;
    border-color: rgba(96, 165, 250, 0.55);
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.22);
}

#quiz-gen-prompt-expanded-input::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

@media (max-width: 720px) {
    .quiz-gen-prompt-panel-header,
    .quiz-gen-prompt-expanded-header {
        flex-direction: column;
        align-items: stretch;
    }

    .quiz-gen-prompt-expanded-content {
        width: min(100%, 94vw);
        min-width: 0;
        min-height: 280px;
        max-height: 92vh;
        padding-top: 2.75rem;
        resize: vertical;
    }

    .quiz-gen-prompt-expanded-actions {
        width: 100%;
    }

    .quiz-gen-prompt-expanded-actions .quiz-gen-prompt-header-btn,
    .quiz-gen-prompt-panel-actions .quiz-gen-prompt-header-btn {
        flex: 1 1 auto;
    }
}

#temp-popup-overlay .modal-content {
    overflow-y: hidden;
}



