/* ==========================================================================
   QUIZ.CSS - Quiz Card, Choices, Results, Navigation
   ========================================================================== */

/* --- Welcome Screen --- */
#welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 88%, rgba(255, 255, 255, 0.08) 12%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--app-border, rgba(255, 255, 255, 0.14));
    border-radius: 24px;
    padding: 3rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    z-index: 50;
    --welcome-scale: 1.125;
    transform: scale(var(--welcome-scale));
    transform-origin: center;
}

#welcome-screen h2 {
    margin-top: 0;
    font-size: 2.5rem;
    background: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 1rem;
    position: relative;
    display: inline-block;
    isolation: isolate;
}

#welcome-screen h2.welcome-title {
    background-image: linear-gradient(112deg,
            var(--g1, #60a5fa) 0%,
            color-mix(in srgb, var(--g1, #60a5fa) 68%, white 32%) 16%,
            var(--g2, #f472b6) 34%,
            color-mix(in srgb, var(--g2, #f472b6) 72%, white 28%) 50%,
            var(--g1, #60a5fa) 68%,
            color-mix(in srgb, var(--g1, #60a5fa) 64%, var(--g2, #f472b6) 36%) 84%,
            var(--g2, #f472b6) 100%);
    background-size: 320% 100%;
    background-position: 0% 50%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    -webkit-text-stroke: 0.85px color-mix(in srgb, var(--g1, #60a5fa) 22%, rgba(255, 255, 255, 0.78) 78%);
    animation: welcome-gradient-flow 6.2s linear infinite, welcome-gradient-pulse 2.2s ease-in-out infinite;
    will-change: background-position, filter;
}

#welcome-screen h2.welcome-title::before,
#welcome-screen h2.welcome-title::after {
    content: none;
}

@keyframes welcome-gradient-flow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 160% 48%;
    }

    100% {
        background-position: 320% 50%;
    }
}

@media (max-width: 900px) {
    #welcome-screen {
        --welcome-scale: 1.01;
    }
}

@media (max-width: 700px) {
    #welcome-screen {
        --welcome-scale: 0.9;
    }
}

@keyframes welcome-gradient-pulse {
    0%,
    100% {
        filter: saturate(1) brightness(1);
    }

    50% {
        filter: saturate(1.1) brightness(1.08);
    }
}

#welcome-screen p {
    color: #94a3b8;
    margin-bottom: 2rem;
    line-height: 1.5;
    font-size: 1.1rem;
}

.welcome-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    flex-direction: column;
    width: 100%;
    align-items: center;
}

.welcome-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.welcome-btn {
    padding: 1rem 1.5rem;
    font-size: 1rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 200px;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.welcome-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

#welcome-screen .welcome-btn {
    justify-content: flex-start;
    padding-left: 1.35rem;
    gap: 0.8rem;
    width: min(86%, 520px);
    margin-inline: auto;
}

#welcome-screen .welcome-btn::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--g1, #60a5fa), var(--g2, #f472b6));
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.22),
        0 0 14px color-mix(in srgb, var(--g1, #60a5fa) 45%, transparent);
    flex-shrink: 0;
}

#welcome-screen .welcome-btn .welcome-btn-text {
    font-weight: 500;
    letter-spacing: 0.01em;
}

.welcome-btn.primary {
    background: var(--g);
    border: none;
    font-weight: 700;
}

.welcome-btn.secondary {
    border-color: #60a5fa;
    color: #60a5fa;
}

/* --- Standard Quiz Card --- */
#quiz-mode-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#quiz-card {
    display: none;
    --quiz-content-scale: 1;
    width: 800px;
    max-width: none;
    border: 1px solid var(--g1, #60a5fa);
    border: 1px solid color-mix(in srgb, var(--g1, #60a5fa) 52%, var(--g2, #f472b6) 48%);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    padding: 2.5rem;
    position: relative;
    margin-bottom: 2rem;
    /* Scroll enabled for fixed-position drag/resize */
    overflow: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    min-width: 320px;
    min-height: 300px;
    border-radius: 24px;
    background: var(--card-bg);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    transition: box-shadow 1.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 1.2s ease, filter 2s ease;
    z-index: 100;
}

/* Keep quiz card outline theme-synced across render/navigation state changes. */
#quiz-card,
#quiz-card.active,
#quiz-card.quiz-card-expanded,
#quiz-card[style*="block"],
#quiz-card[style*="flex"] {
    border-color: var(--g1, #60a5fa) !important;
    border-color: color-mix(in srgb, var(--g1, #60a5fa) 52%, var(--g2, #f472b6) 48%) !important;
}

#quiz-card:focus,
#quiz-card:focus-visible {
    outline: 2px solid var(--g1, #60a5fa) !important;
    outline-color: color-mix(in srgb, var(--g1, #60a5fa) 56%, var(--g2, #f472b6) 44%) !important;
    border-color: var(--g1, #60a5fa) !important;
    outline: 2px solid color-mix(in srgb, var(--g1, #60a5fa) 56%, var(--g2, #f472b6) 44%) !important;
    outline-offset: 0;
    border-color: color-mix(in srgb, var(--g1, #60a5fa) 52%, var(--g2, #f472b6) 48%) !important;
}

#quiz-card:focus:not(:focus-visible) {
    outline: none !important;
}

#quiz-card.quiz-card-expanded {
    position: fixed !important;
    inset: 10px !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    z-index: 12040 !important;
    overflow: auto !important;
    border-radius: 16px;
    box-shadow: 0 22px 80px rgba(2, 6, 23, 0.78);
}

#quiz-card.quiz-card-expanded #resize-handle {
    opacity: 0;
    pointer-events: none;
}

#quiz-card.save-outline-flash::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 2px solid color-mix(in srgb, var(--g1, #60a5fa) 58%, var(--g2, #f472b6) 42%);
    pointer-events: none;
    z-index: 25;
    opacity: 0;
    animation: quiz-save-outline-flash 1s ease-in-out forwards;
}

@keyframes quiz-save-outline-flash {
    0% {
        opacity: 0;
        box-shadow: 0 0 0 color-mix(in srgb, var(--g1, #60a5fa) 58%, var(--g2, #f472b6) 42%);
    }

    35% {
        opacity: 0.55;
        box-shadow: 0 0 10px color-mix(in srgb, var(--g1, #60a5fa) 58%, var(--g2, #f472b6) 42%);
    }

    70% {
        opacity: 0.95;
        box-shadow: 0 0 20px color-mix(in srgb, var(--g1, #60a5fa) 58%, var(--g2, #f472b6) 42%);
    }

    100% {
        opacity: 0;
        box-shadow: 0 0 0 color-mix(in srgb, var(--g1, #60a5fa) 58%, var(--g2, #f472b6) 42%);
    }
}

#quiz-card::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

#quiz-card.quiz-gen-blurred {
    filter: blur(6px) saturate(0.92);
    opacity: 0.55;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    will-change: filter, opacity;
    transition: filter 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

/* When quiz card is shown (via JS inline style display:block), use flexbox */
#quiz-card[style*="block"],
#quiz-card[style*="flex"] {
    display: flex !important;
    flex-direction: column;
}

/* Show quiz card when it has the active class */
#quiz-card.active {
    display: flex !important;
    flex-direction: column;
}

#work-area.split-view #quiz-card:not(.is-floating) {
    width: 95%;
    max-width: 900px;
    height: auto !important;
    margin: 0 auto 2rem auto;
    left: auto;
    top: auto;
}

/* Resize Handle */
#resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 24px;
    height: 24px;
    cursor: nwse-resize;
    z-index: 100;
    border-right: 3px solid var(--g1, #60a5fa);
    border-bottom: 3px solid var(--g1, #60a5fa);
    border-radius: 0 0 16px 0;
    opacity: 0.35;
    transition: opacity 0.15s;
    user-select: none;
    touch-action: none;
}

#resize-handle:hover {
    opacity: 1;
}

/* Ambient Glow */
#quiz-card.ambient-active {
    animation: shadow-pulse 4s ease-in-out infinite alternate;
}

#quiz-card.ambient-active.is-static {
    animation: none;
    box-shadow: 0 0 var(--amb-max) var(--amb-c2);
}

/* VISUALIZER OVERRIDE: When music is playing, disable CSS transition for instant response */
#quiz-card.visualizer-active {
    transition: box-shadow 0.05s linear, border-color 0.2s ease !important;
    animation: none !important;
}

#quiz-content-wrapper {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#quiz-content-wrapper.quiz-content-scaled {
    overflow: hidden;
}

#quiz-content-wrapper::-webkit-scrollbar {
    display: none;
}

#quiz-scale-shell {
    display: flex;
    flex-direction: column;
    width: calc(100% / var(--quiz-content-scale, 1));
    min-width: calc(100% / var(--quiz-content-scale, 1));
    min-height: 100%;
    transform: scale(var(--quiz-content-scale, 1));
    transform-origin: top left;
    will-change: transform;
}

/* --- AUDIO VISUALIZER STYLES --- */
#audio-visualizer {
    position: relative;
    width: 100%;
    height: 46px;
    margin-bottom: 8px;
    pointer-events: none;
    z-index: 5;
    opacity: 1;
    border-radius: 10px;
    background:
        radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--g1, #60a5fa) 34%, transparent), transparent 45%),
        radial-gradient(circle at 80% 0%, color-mix(in srgb, var(--g2, #f472b6) 36%, transparent), transparent 45%),
        linear-gradient(180deg, rgba(15, 23, 42, 0.22), rgba(15, 23, 42, 0.04));
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: inset 0 0 18px rgba(15, 23, 42, 0.42), 0 4px 16px rgba(2, 6, 23, 0.28);
}

#progress-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin-bottom: 1.5rem;
    overflow: hidden;
    position: relative;
    z-index: 10;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background: var(--g);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.q-image {
    display: none;
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
    border: 1px solid #334155;
    margin: 0 auto 1.5rem auto;
    object-fit: contain;
    background: #000;
    cursor: zoom-in;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* Image Lightbox Overlay */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    cursor: zoom-out;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, background 0.3s ease, visibility 0.3s ease;
}

.image-lightbox.active {
    opacity: 1;
    visibility: visible;
    background: rgba(0, 0, 0, 0.9);
}

.image-lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.image-lightbox.active img {
    transform: scale(1);
}

.question-text {
    font-size: clamp(1.5rem, 1.22rem + 0.78vw, 2.02rem);
    font-weight: 700;
    margin: 0 auto 1.7rem auto;
    color: var(--text-q);
    line-height: 1.56;
    text-align: center;
    max-width: 38ch;
    width: 100%;
}

#quiz-card.quiz-card-expanded .question-text {
    font-size: clamp(1.78rem, 1.36rem + 0.95vw, 2.3rem);
    max-width: 44ch;
    margin-bottom: 2rem;
}

/* --- IPHONE 26 GLASSY BUTTONS --- */
#choices {
    position: relative;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.choice {
    display: block;
    width: 100%;
    margin: 0;
    padding: 1.2rem 1.55rem;
    border-radius: 18px;
    background: var(--bg-opt, rgba(255, 255, 255, 0.03));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    color: var(--text-a);
    cursor: pointer;
    text-align: left;
    font-size: clamp(1.18rem, 1.04rem + 0.32vw, 1.36rem);
    line-height: 1.45;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    user-select: none;
}

.choice:not(.locked):hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.01);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.choice.locked {
    cursor: default;
    transform: none !important;
}

.choice.correct {
    border-color: #22c55e !important;
    background: rgba(34, 197, 94, 0.2) !important;
    color: #f0fdf4 !important;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.2);
}

.choice.incorrect {
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.2) !important;
    color: #fef2f2 !important;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

/* UPDATED ELIMINATED STYLE */
.choice.eliminated {
    text-decoration: line-through;
    color: rgba(226, 232, 240, 0.4);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: none;
    filter: grayscale(1);
}

.choice .label {
    margin-right: 0.5rem;
    font-weight: 700;
    opacity: 0.7;
    font-size: 1em;
}

#quiz-card.quiz-card-expanded .choice {
    font-size: clamp(1.34rem, 1.14rem + 0.42vw, 1.56rem);
    padding: 1.35rem 1.75rem;
    line-height: 1.5;
}

/* --- CHOICE EYEBALLS --- */
.eye-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.2;
    transition: all 0.2s;
    z-index: 10;
    cursor: pointer;
    border-radius: 50%;
}

.choice:hover .eye-toggle {
    opacity: 0.5;
}

.eye-toggle:hover {
    opacity: 1 !important;
    background: rgba(255, 255, 255, 0.1);
}

/* UPDATED EYE STYLE FOR ELIMINATED */
.choice.eliminated .eye-toggle {
    opacity: 1 !important;
    color: #ef4444;
    filter: none;
}

#choices.hard-mode .choice {
    filter: blur(8px);
    opacity: 0.4;
    pointer-events: none;
}

#hard-mode-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    cursor: pointer;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.1);
}

#hard-mode-btn {
    padding: 12px 24px;
    background: var(--g);
    color: white;
    font-weight: bold;
    border-radius: 30px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.2s;
}

#hard-mode-overlay:hover #hard-mode-btn {
    transform: scale(1.05);
}

/* Hard Mode Type-Before-Reveal - Hide choices initially */
#choices.hard-mode-hidden {
    filter: blur(12px);
    opacity: 0.3;
    pointer-events: none;
    user-select: none;
    transition: all 0.3s ease;
}

#choices.hard-mode-hidden .choice {
    transform: scale(0.98);
}

/* --- THEME-SYNCED BACKGROUND FOR EXPLANATION --- */
#explanation {
    margin-top: 1.5rem;
    padding: 1.25rem;
    border-radius: 16px;
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--bd, #334155);
    display: none;
    line-height: 1.6;
    font-size: 1rem;
    color: #cbd5e1;
}

/* When #explanation becomes ai-response-box directly */
#explanation.ai-response-box {
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--bd, #334155);
    border-left: 3px solid var(--g1, #60a5fa);
    padding: 1.25rem;
}

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

.ai-expand-hint {
    font-size: 0.75rem;
    color: #64748b;
    transition: color 0.2s;
}

#explanation.ai-response-box:hover .ai-expand-hint {
    color: #94a3b8;
}

.ai-response-content {
    margin-top: 0;
}

/* --- RESULTS SCREEN --- */
#results-view {
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: fadeIn 0.5s ease;
    padding-top: 1rem;
    width: 100%;
    height: 100%;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--st-mas);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--st-mas);
    margin-bottom: 1.5rem;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.2);
}

.score-circle.bad {
    border-color: var(--st-new);
    color: var(--st-new);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.score-circle.mid {
    border-color: var(--st-fam);
    color: var(--st-fam);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
}

.results-list {
    width: 100%;
    text-align: left;
    margin-top: 1rem;
    max-height: 300px;
    overflow-y: auto;
    border-top: 1px solid #334155;
    padding-top: 1rem;
}

.result-item {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 6px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    transition: background 0.2s;
}

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

.result-item.correct {
    border-left: 3px solid var(--st-mas);
}

.result-item.wrong {
    border-left: 3px solid var(--st-new);
}

/* Nav Buttons */
#nav-row {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.nav-btn {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(10px);
    background-image: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    cursor: pointer;
    font-weight: 800;
    transition: all 0.2s;
}

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

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

/* --- AI Action Row --- */
.ai-action-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-quick-btn {
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-quick-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--g1, #4ade80);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.ai-quick-btn .gradient-text {
    font-size: 0.85rem;
    font-weight: 600;
}

/* --- Auto Options Dropdown --- */
.refresh-options-wrapper {
    position: relative;
    display: inline-block;
}

.refresh-options-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--bd, #334155);
    border-radius: 10px;
    padding: 8px;
    width: 190px;
    z-index: 120;
    backdrop-filter: blur(15px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.refresh-options-dropdown.active {
    display: block;
}

.refresh-opt-btn {
    display: block;
    width: 100%;
    margin: 2px 0;
    padding: 8px 10px;
    text-align: left;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 7px;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    box-sizing: border-box;
}

.refresh-opt-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--g1, #4ade80);
}

.auto-options-wrapper {
    position: relative;
    display: inline-block;
}

.auto-options-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--bd, #334155);
    border-radius: 10px;
    padding: 8px 12px;
    width: 170px;
    z-index: 100;
    backdrop-filter: blur(15px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    margin-top: 4px;
    overflow: hidden;
}

.auto-options-dropdown.active {
    display: block;
}

.auto-opt-btn {
    display: block;
    width: 100%;
    margin: 2px 0;
    padding: 8px 10px;
    text-align: center;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    box-sizing: border-box;
}

.auto-opt-btn .gradient-text {
    background-image: var(--g) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    color: transparent !important;
}

.auto-opt-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--g1, #4ade80);
}

.auto-opt-btn.active {
    background: var(--g);
    border-color: var(--g1, #4ade80);
}

.auto-opt-btn.active .gradient-text {
    background: none;
    -webkit-text-fill-color: #fff;
    color: #fff;
}

/* --- AI Response Box --- */
.ai-response-box {
    border-left: 3px solid;
    border-image: var(--g) 1;
    padding-left: 15px;
}

/* --- Inline AI Buttons --- */
.ai-quick-btn-inline {
    position: relative;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: all 0.2s ease;
}

#notes-btn-inline.has-note::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.95), 0 0 8px rgba(34, 197, 94, 0.55);
    pointer-events: none;
}

.ai-quick-btn-inline:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--g1, #4ade80);
    transform: translateY(-1px);
}

.ai-quick-btn-inline .gradient-text {
    font-size: 0.8rem;
    font-weight: 600;
}

#quiz-expand-lock-btn-inline {
    display: none;
}

body.quiz-card-expanded-mode #quiz-expand-lock-btn-inline {
    display: inline-flex !important;
}

#quiz-expand-lock-btn-inline.locked {
    background: color-mix(in srgb, var(--g1, #60a5fa) 22%, rgba(15, 23, 42, 0.92));
    border-color: color-mix(in srgb, var(--g1, #60a5fa) 62%, var(--g2, #f472b6) 38%);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--g1, #60a5fa) 30%, transparent);
}

#quiz-expand-lock-btn-inline.locked .gradient-text {
    background: none;
    -webkit-text-fill-color: #f8fafc;
    color: #f8fafc;
}

/* Pulsation for buttons with active AI generation */
@keyframes ai-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 transparent;
        border-color: rgba(255, 255, 255, 0.12);
    }

    50% {
        box-shadow: 0 0 12px 3px color-mix(in srgb, var(--g1, #4ade80) 50%, transparent);
        border-color: var(--g1, #4ade80);
    }
}

.ai-quick-btn-inline.ai-generating {
    animation: ai-pulse 1.5s ease-in-out infinite;
}

.ai-quick-btn-inline.ai-btn-blocked {
    cursor: not-allowed !important;
}

#save-btn {
    background: var(--g);
    -webkit-background-clip: border-box;
    background-clip: border-box;
    color: #fff;
    -webkit-text-fill-color: #fff;
    border: none;
}

#save-btn.saved {
    background: #16a34a;
    background-image: none;
}

/* --- REFINED POPUP STYLES (THEME-SYNCED) --- */
#wrong-popup {
    position: absolute;
    z-index: 13010;
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--g1, #4ade80);
    color: var(--text-main, #e2e8f0);
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    max-width: 190px;
    width: auto;
    font-size: 0.82rem;
    line-height: 1.4;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: block;
    white-space: normal;
    word-wrap: break-word;
}

#wrong-popup.active {
    opacity: 1;
    pointer-events: auto;
}

#wrong-popup.popup-error {
    background: rgba(31, 18, 18, 0.97);
    border-color: #ef4444;
    color: #fecaca;
}

#wrong-popup.popup-info {
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border-color: var(--g1, #4ade80);
    color: var(--text-main, #e2e8f0);
}

/* Arrows - hidden by default, shown only when positioned next to a button */
#wrong-popup::before {
    content: "";
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
    display: none;
}

#wrong-popup.popup-side-right::before,
#wrong-popup.popup-side-left::before {
    display: block;
}

/* Popup is to the RIGHT of the button, Arrow points LEFT */
#wrong-popup.popup-side-right::before {
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 6px 6px 6px 0;
    border-color: transparent var(--bd) transparent transparent;
}

#wrong-popup.popup-error.popup-side-right::before {
    border-color: transparent #ef4444 transparent transparent;
}

#wrong-popup.popup-info.popup-side-right::before {
    border-color: transparent var(--g1, #4ade80) transparent transparent;
}

/* Popup is to the LEFT of the button, Arrow points RIGHT */
#wrong-popup.popup-side-left::before {
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 6px 0 6px 6px;
    border-color: transparent var(--bd) transparent transparent;
}

#wrong-popup.popup-error.popup-side-left::before {
    border-color: transparent transparent transparent #ef4444;
}

#wrong-popup.popup-info.popup-side-left::before {
    border-color: transparent transparent transparent var(--g1, #4ade80);
}

/* --- LIVE STATS BAR --- */
#stats-outer-wrapper {
    display: flex;
    align-items: center;
    margin-left: 0.5rem;
}

#live-stats-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0 12px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    height: 32px;
    max-width: 600px;
    opacity: 1;
    overflow: hidden;
    transition: max-width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.4s ease,
        padding 0.5s ease,
        border-width 0.3s ease;
}

#live-stats-bar.is-hidden {
    max-width: 0;
    opacity: 0;
    padding: 0;
    border-width: 0;
}

#stats-collapsed-btn {
    display: none;
}

#stats-collapsed-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
}

#stats-collapse-trigger {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0 4px;
    margin-right: 4px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

#stats-collapse-trigger:hover {
    color: #fff;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #94a3b8;
    cursor: default;
}

.stat-icon {
    width: 14px;
    height: 14px;
    fill: currentColor;
    opacity: 0.8;
}

.stat-val {
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    background-image: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}

.stat-divider {
    width: 1px;
    height: 14px;
    background: rgba(255, 255, 255, 0.15);
}

/* --- Quiz Control Buttons (Inline) --- */
.quiz-ctrl-btn {
    padding: 4px 10px;
    font-size: 0.75rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.quiz-ctrl-btn .gradient-text {
    background-image: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}

.quiz-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.25);
}

.quiz-ctrl-btn.active {
    border-color: var(--c1);
    box-shadow: 0 0 8px rgba(var(--c1-rgb, 255, 255, 255), 0.3);
}

/* Hide scrollbar utility */
.hide-scrollbar {
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari/Webkit */
}

