/* ─── Variables & Reset ─── */
:root {
    --bg-void: #08080a;
    --bg-base: #0e0e11;
    --bg-surface: #16161a;
    --bg-surface-hover: #1f1f24;
    --bg-elevated: #25252a;
    --border-subtle: rgba(255,255,255,0.06);
    --border-medium: rgba(255,255,255,0.10);
    --border-strong: rgba(255,255,255,0.16);

    --accent: #f5b73d;
    --accent-soft: rgba(245,183,61,0.12);
    --accent-glow: rgba(245,183,61,0.25);
    --accent-hover: #f7c866;

    --success: #34d399;
    --success-soft: rgba(52,211,153,0.08);
    --warning: #f5b73d;
    --error: #f87171;
    --error-soft: rgba(248,113,113,0.08);

    --text-primary: #f2f2f5;
    --text-secondary: #a0a0ab;
    --text-muted: #6e6e78;
    --text-inverse: #08080a;

    --font-display: 'Fraunces', 'Georgia', serif;
    --font-ui: 'Sora', 'Segoe UI', sans-serif;
    --font-body: 'Source Serif 4', 'Georgia', serif;

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow: 0 10px 30px rgba(0,0,0,0.45);
    --shadow-lg: 0 20px 50px rgba(0,0,0,0.55);

    --transition-fast: 0.15s cubic-bezier(0.22,1,0.36,1);
    --transition: 0.35s cubic-bezier(0.22,1,0.36,1);
    --transition-slow: 0.6s cubic-bezier(0.22,1,0.36,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font-ui);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 9999;
    opacity: 0.35;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #333; }
::selection { background: var(--accent-soft); color: var(--accent-hover); }

/* ─── Nav ─── */
.app-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(8,8,10,0.70);
    border-bottom: 1px solid var(--border-subtle);
}
.nav-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #d97706);
    color: var(--text-inverse);
    font-size: 0.95rem;
    line-height: 1;
}
.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border-radius: 99px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}
.pill .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
    0%,100%{opacity:1;transform:scale(1);}
    50%{opacity:.5;transform:scale(.85);}
}

/* ─── Stage ─── */
.stage {
    max-width: 840px;
    margin: 0 auto;
    padding: 2.5rem 1rem 6rem;
}
.stage-panel {
    animation: fadeUp 0.6s var(--transition) both;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
.center-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 45vh;
}

/* ─── Hero ─── */
.hero {
    text-align: center;
    margin-bottom: 2rem;
}
.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 4.5vw, 3rem);
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}
.hero h1 em {
    font-style: italic;
    color: var(--accent);
}
.subtitle {
    font-size: 0.98rem;
    color: var(--text-secondary);
    max-width: 440px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ─── Upload ─── */
.upload-zone {
    position: relative;
    border-radius: var(--radius-lg);
    padding: 3rem 1.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
}
.upload-zone::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: var(--radius-lg);
    padding: 1px;
    background: conic-gradient(from var(--angle), transparent 0%, rgba(245,183,61,0) 25%, var(--accent) 50%, rgba(245,183,61,0) 75%, transparent 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}
@property --angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
.upload-zone:hover::before, .upload-zone.dragging::before {
    opacity: 1;
    animation: rotate-border 3.5s linear infinite;
}
@keyframes rotate-border { to { --angle: 360deg; } }
.upload-zone.dragging {
    background: var(--bg-elevated);
    transform: scale(1.01);
}
.upload-zone-inner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.upload-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--accent);
    transition: var(--transition-fast);
}
.upload-zone:hover .upload-icon {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(245,183,61,0.15);
}
.upload-title { font-weight: 600; font-size: 1rem; color: var(--text-primary); }
.upload-hint { font-size: 0.78rem; color: var(--text-muted); }
.file-input-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ─── Chips ─── */
.file-chips {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.45rem;
    margin-top: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.55rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(245,183,61,0.45) rgba(255,255,255,0.06);
}
.file-chips::-webkit-scrollbar {
    height: 6px;
}
.file-chips::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 99px;
}
.file-chips::-webkit-scrollbar-thumb {
    background: rgba(245,183,61,0.42);
    border-radius: 99px;
}
.file-chips::-webkit-scrollbar-thumb:hover {
    background: rgba(245,183,61,0.65);
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex: 0 0 auto;
    max-width: min(320px, 78vw);
    padding: 0.35rem 0.65rem;
    border-radius: 99px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    font-size: 0.78rem;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    animation: popIn 0.35s var(--transition) both;
}
@keyframes popIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}
.chip .chip-name { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .chip-status {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.chip .chip-remove {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition-fast);
}
.chip .chip-remove:hover { background: var(--error-soft); color: var(--error); }
.chip.uploading { opacity: 0.55; }
.chip.removing { opacity: 0.45; transform: scale(0.98); }
.chip.error { border-color: rgba(248,113,113,0.35); background: var(--error-soft); color: var(--error); }
.chip.error .chip-status { color: var(--error); }

/* ─── Settings ─── */
.settings-row {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 1rem;
    margin-top: 1.75rem;
}
@media (max-width: 600px) {
    .settings-row { grid-template-columns: 1fr; }
}
.setting-group {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    transition: var(--transition-fast);
}
.setting-group.disabled { opacity: 0.4; pointer-events: none; filter: grayscale(0.6); }
.generation-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.question-count-control {
    transition: var(--transition-fast);
}
.question-count-control.disabled {
    opacity: 0.38;
    pointer-events: none;
    filter: grayscale(0.6);
}
.setting-divider {
    height: 1px;
    background: var(--border-subtle);
}
.setting-label {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.65rem;
}
.count-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 22px; height: 22px; padding: 0 5px;
    border-radius: 99px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 700;
}
.type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    grid-auto-rows: minmax(76px, 1fr);
    gap: 0.65rem;
    align-items: stretch;
}
@media (max-width: 480px) {
    .type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.type-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.7rem;
    padding: 0.85rem 0.9rem;
    min-height: 76px;
    height: 100%;
    min-width: 0;
    border-radius: var(--radius-sm);
    background: var(--bg-void);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: left;
    user-select: none;
}
.type-toggle:hover { border-color: var(--border-medium); }
.type-toggle input {
    position: absolute;
    opacity: 0;
    width: 0; height: 0;
}
.type-toggle .t-icon {
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: var(--transition-fast);
    flex-shrink: 0;
}
.type-toggle .t-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.type-toggle.active {
    background: var(--accent-soft);
    border-color: rgba(245,183,61,0.25);
}
.type-toggle.active .t-icon {
    background: var(--accent);
    color: var(--text-inverse);
}
.type-toggle.active .t-name {
    color: var(--text-primary);
    font-weight: 600;
}
.type-toggle.disabled {
    opacity: 0.35;
    pointer-events: none;
    filter: grayscale(0.6);
}

/* ─── Exam Card ─── */
.exam-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1.1rem 1.25rem;
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(245,183,61,0.08) 0%, rgba(217,119,6,0.04) 100%);
    border: 1px solid rgba(245,183,61,0.18);
    transition: var(--transition-fast);
}
.exam-card:hover {
    border-color: rgba(245,183,61,0.30);
    box-shadow: 0 8px 24px rgba(245,183,61,0.08);
}
.exam-card.active {
    border-color: var(--accent);
    box-shadow: 0 8px 24px rgba(245,183,61,0.15);
    background: linear-gradient(135deg, rgba(245,183,61,0.12) 0%, rgba(217,119,6,0.08) 100%);
}
.exam-card.active .exam-icon {
    background: var(--accent);
    color: var(--text-inverse);
}
.exam-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}
.exam-icon {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.exam-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.2;
}
.exam-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}
.exam-card .btn-primary {
    padding: 0.7rem 1.4rem;
    font-size: 0.85rem;
    flex-shrink: 0;
}
@media (max-width: 520px) {
    .exam-card { flex-direction: column; align-items: flex-start; }
}

.fancy-slider {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 6px;
    background: var(--bg-void);
    border-radius: 99px;
    outline: none;
    cursor: pointer;
}
.fancy-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 0 4px rgba(245,183,61,0.20);
    transition: var(--transition-fast);
}
.fancy-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 0 6px rgba(245,183,61,0.30);
}
.fancy-slider::-moz-range-thumb {
    width: 18px; height: 18px;
    border-radius: 50%; border: none;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 0 4px rgba(245,183,61,0.20);
}
.slider-hint {
    display: flex; justify-content: space-between;
    font-size: 0.7rem; color: var(--text-muted);
    margin-top: 0.3rem;
}

.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
}
.difficulty-toggle {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 42px;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-void);
    cursor: pointer;
    transition: var(--transition-fast);
    user-select: none;
}
.difficulty-toggle:hover { border-color: var(--border-medium); }
.difficulty-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.difficulty-toggle.active {
    background: var(--accent-soft);
    border-color: rgba(245,183,61,0.28);
}
.difficulty-name {
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.1;
}
.custom-instructions-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.custom-instructions-field .setting-label {
    margin-bottom: 0.4rem;
}
.custom-instructions-field textarea {
    width: 100%;
    min-height: 112px;
    resize: vertical;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-void);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.84rem;
    line-height: 1.45;
    padding: 0.85rem 0.9rem;
    outline: none;
    transition: var(--transition-fast);
}
.custom-instructions-field textarea:focus {
    border-color: rgba(245,183,61,0.45);
    box-shadow: 0 0 0 3px rgba(245,183,61,0.10);
}
.custom-instructions-field textarea::placeholder {
    color: var(--text-muted);
}
@media (max-width: 420px) {
    .difficulty-grid { grid-template-columns: 1fr; }
    .difficulty-toggle { min-height: 40px; }
}

/* ─── Buttons ─── */
.btn-primary, .btn-secondary {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.4rem;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    overflow: hidden;
    transition: var(--transition-fast);
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), #d97706);
    color: var(--text-inverse);
    padding: 0.9rem 2rem;
    box-shadow: 0 4px 16px rgba(245,183,61,0.22);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(245,183,61,0.32);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled, .btn-primary.generate-disabled {
    opacity: 0.4; cursor: not-allowed; filter: grayscale(0.6);
    box-shadow: none; transform: none;
}
.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
    padding: 0.8rem 1.5rem;
}
.btn-secondary:hover { background: var(--bg-surface-hover); border-color: var(--border-strong); }
.btn-large { font-size: 0.98rem; padding: 1rem 2.6rem; border-radius: var(--radius-lg); }
.action-row { display: flex; justify-content: center; margin-top: 2rem; }

/* ─── Loading Overlay ─── */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(8,8,10,0.92);
    backdrop-filter: blur(16px);
}
.loading-overlay.active { display: flex; }

.scan-line {
    position: absolute;
    left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--accent) 45%, var(--accent) 55%, transparent 100%);
    opacity: 0.35;
    animation: scanMove 3s ease-in-out infinite;
    box-shadow: 0 0 12px rgba(245,183,61,0.2);
}
@keyframes scanMove {
    0%,100% { top: 15%; opacity: 0; }
    10% { opacity: 0.35; }
    50% { top: 85%; opacity: 0.35; }
    90% { opacity: 0.35; }
    100% { opacity: 0; }
}

.loading-center {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.morph-blob {
    width: 100px; height: 100px;
    background: linear-gradient(135deg, var(--accent), #d97706);
    opacity: 0.85;
    animation: blobMorph 6s ease-in-out infinite;
    filter: blur(1px);
    box-shadow: 0 0 40px rgba(245,183,61,0.25), 0 0 80px rgba(245,183,61,0.10);
}
@keyframes blobMorph {
    0%,100% { border-radius: 60% 40% 55% 45% / 55% 45% 60% 40%; transform: rotate(0deg) scale(1); }
    25% { border-radius: 45% 55% 40% 60% / 50% 60% 40% 50%; transform: rotate(90deg) scale(1.08); }
    50% { border-radius: 55% 45% 50% 50% / 45% 50% 55% 45%; transform: rotate(180deg) scale(0.95); }
    75% { border-radius: 40% 60% 45% 55% / 60% 40% 55% 45%; transform: rotate(270deg) scale(1.05); }
}

.loading-status {
    font-family: var(--font-ui);
    font-size: 0.92rem;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    user-select: none;
}
.status-prefix {
    color: var(--accent);
    margin-right: 0.3rem;
    font-weight: 600;
}
.status-cursor {
    color: var(--accent);
    animation: blink 1s step-end infinite;
}
@keyframes blink {
    0%,100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ─── Eval Spinner (kept for evaluation overlay) ─── */
.spinner-orbit {
    position: relative;
    width: 90px; height: 90px;
}
.spinner-orbit.large { width: 130px; height: 130px; }
.orbit-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--accent);
    border-right-color: var(--accent);
    animation: spin 1.4s linear infinite;
}
.orbit-ring.ring-2 {
    inset: 14px;
    border-top-color: var(--text-muted);
    border-right-color: var(--text-muted);
    animation-direction: reverse;
    animation-duration: 1.8s;
}
.spinner-orbit.large .orbit-ring.ring-2 { inset: 20px; }
.orbit-core {
    position: absolute;
    inset: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #d97706);
    opacity: 0.9;
    animation: pulse-core 2.5s ease-in-out infinite;
}
.spinner-orbit.large .orbit-core { inset: 40px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-core {
    0%,100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.1); opacity: 0.6; }
}

/* ─── Questions ─── */
.questions-list {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    margin-top: 0.25rem;
}
.qa-pair {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.4rem;
    transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
    animation: enterCard 0.45s cubic-bezier(0.22,1,0.36,1) both;
}
.qa-pair:nth-child(1){animation-delay:0.03s}
.qa-pair:nth-child(2){animation-delay:0.06s}
.qa-pair:nth-child(3){animation-delay:0.09s}
.qa-pair:nth-child(4){animation-delay:0.12s}
.qa-pair:nth-child(5){animation-delay:0.15s}
.qa-pair:nth-child(6){animation-delay:0.18s}
.qa-pair:nth-child(7){animation-delay:0.21s}
.qa-pair:nth-child(8){animation-delay:0.24s}
.qa-pair:nth-child(9){animation-delay:0.27s}
.qa-pair:nth-child(10){animation-delay:0.30s}
.qa-pair:nth-child(11){animation-delay:0.33s}
.qa-pair:nth-child(12){animation-delay:0.36s}
.qa-pair:nth-child(13){animation-delay:0.39s}
.qa-pair:nth-child(14){animation-delay:0.42s}
.qa-pair:nth-child(15){animation-delay:0.45s}
.qa-pair:nth-child(16){animation-delay:0.48s}
.qa-pair:nth-child(17){animation-delay:0.51s}
.qa-pair:nth-child(18){animation-delay:0.54s}
.qa-pair:nth-child(19){animation-delay:0.57s}
.qa-pair:nth-child(20){animation-delay:0.60s}
.qa-pair:nth-child(21){animation-delay:0.63s}
@keyframes enterCard {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.qa-pair:hover {
    border-color: var(--border-medium);
    box-shadow: var(--shadow);
}
.question-meta {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}
.question-text {
    font-family: var(--font-body);
    font-size: 1.1rem;
    line-height: 1.5;
    color: var(--text-primary);
    margin-bottom: 0.9rem;
    overflow-x: auto;
}
.question-text mjx-container,
.option-label mjx-container,
.item-txt mjx-container,
.feedback mjx-container {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

/* ─── Textarea ─── */
textarea {
    width: 100%;
    padding: 0.85rem 0.95rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-void);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.92rem;
    line-height: 1.5;
    min-height: 52px;
    resize: vertical;
    transition: var(--transition-fast);
    outline: none;
}
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea::placeholder { color: var(--text-muted); }

/* ─── Multiple Choice ─── */
.options-list { display: flex; flex-direction: column; gap: 0.5rem; }
.option-card {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.8rem 0.95rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-void);
    cursor: pointer;
    transition: var(--transition-fast);
}
.option-card:hover { border-color: var(--border-medium); background: var(--bg-base); }
.option-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.option-indicator {
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    flex-shrink: 0;
}
.option-card.selected .option-indicator {
    background: var(--accent); color: var(--text-inverse); border-color: var(--accent);
}
.option-label { min-width: 0; font-size: 0.88rem; color: var(--text-secondary); transition: var(--transition-fast); }
.option-card.selected .option-label { color: var(--text-primary); }
.option-check { margin-left: auto; font-size: 0.85rem; color: var(--accent); opacity: 0; transform: scale(0.8); transition: var(--transition-fast); }
.option-card.selected .option-check { opacity: 1; transform: scale(1); }
.option-card.disabled, .option-card.disabled:hover {
    opacity: 0.45; cursor: not-allowed; background: var(--bg-void); border-color: var(--border-subtle);
}

/* ─── True / False ─── */
.tf-toggle { display: flex; gap: 0.7rem; }
.tf-btn { flex: 1; position: relative; cursor: pointer; }
.tf-btn input { position: absolute; opacity: 0; width: 0; height: 0; }
.tf-btn span {
    display: block;
    text-align: center;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-void);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.88rem;
    transition: var(--transition-fast);
}
.tf-btn:hover span { border-color: var(--border-medium); color: var(--text-primary); }
.tf-btn input:checked + span, .tf-btn.selected span {
    border-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); font-weight: 600;
}
.tf-btn input:disabled + span, .tf-btn.disabled span { opacity: 0.45; cursor: not-allowed; }

/* ─── Fill Blank ─── */
.blank-input {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    margin: 0 0.15rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--accent);
    color: var(--accent);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 600;
    min-width: 100px;
    text-align: center;
    outline: none;
    transition: var(--transition-fast);
}
.blank-input:focus { background: var(--accent-soft); border-radius: 4px 4px 0 0; }
.blank-input::placeholder { color: var(--text-muted); font-weight: 400; }
.blank-input:disabled { opacity: 0.45; color: var(--text-muted); border-bottom-color: var(--text-muted); }

/* ─── Matching ─── */
.matching-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.35rem;
    margin-bottom: 1.1rem;
    animation: enterCard 0.5s var(--transition) both;
}
.match-section-heading {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.85rem;
}
.match-content { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.match-col-title {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-subtle);
}
.match-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.6rem 0.7rem;
    border-radius: var(--radius-sm);
    background: var(--bg-void);
    border: 1px solid var(--border-subtle);
    margin-bottom: 0.45rem;
    transition: var(--transition-fast);
}
.match-item.left-item:hover { border-color: var(--border-medium); }
.item-num { font-size: 0.72rem; font-weight: 700; color: var(--accent); min-width: 1.3rem; }
.item-txt { font-size: 0.85rem; color: var(--text-secondary); flex: 1; }
.match-select {
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.78rem;
    outline: none;
    cursor: pointer;
    min-width: 65px;
}
.match-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.match-select:disabled { opacity: 0.45; cursor: not-allowed; color: var(--text-muted); }
.match-item.right-item { background: rgba(52,211,153,0.05); border-color: rgba(52,211,153,0.12); }
.match-item.right-item .item-num { color: var(--success); }
@media (max-width: 640px) { .match-content { grid-template-columns: 1fr; } }

/* ─── Quiz Actions ─── */
.quiz-actions { margin-top: 1.75rem; display: flex; justify-content: center; }

/* ─── Timer ─── */
.timer-container {
    display: flex; align-items: center; gap: 0.45rem;
    padding: 0.4rem 0.8rem;
    border-radius: 99px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    animation: pulse-dot 2s infinite;
}
.timer-container.timer-warning { border-color: var(--warning); color: var(--warning); background: rgba(245,183,61,0.08); }
.timer-container.timer-critical { border-color: var(--error); color: var(--error); background: var(--error-soft); animation: shake 0.5s infinite; }
@keyframes shake {
    0%,100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

/* ─── Score Circle ─── */
.score-circle {
    position: relative;
    width: 170px; height: 170px;
    margin-bottom: 1.5rem;
}
.score-circle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-track { fill: none; stroke: var(--bg-elevated); stroke-width: 8; }
.score-fill {
    fill: none;
    stroke: url(#scoreGradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 327;
    stroke-dashoffset: 327;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.22,1,0.36,1);
}
.score-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.score-percent {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1;
}
.score-fraction { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ─── Results Header (shown above questions after submit) ─── */
.results-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
    animation: fadeUp 0.5s var(--transition) both;
}
.results-header .score-circle {
    margin-bottom: 1rem;
}

/* ─── Result States ─── */
.correct { border-left: 4px solid var(--success); background: linear-gradient(90deg, rgba(52,211,153,0.05) 0%, transparent 20%); }
.partially-correct { border-left: 4px solid var(--warning); background: linear-gradient(90deg, rgba(245,183,61,0.05) 0%, transparent 20%); }
.incorrect { border-left: 4px solid var(--error); background: linear-gradient(90deg, rgba(248,113,113,0.05) 0%, transparent 20%); }
.result-status {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.65rem;
}
.correct .result-status { background: var(--success-soft); color: var(--success); }
.partially-correct .result-status { background: rgba(245,183,61,0.10); color: var(--warning); }
.incorrect .result-status { background: var(--error-soft); color: var(--error); }

/* ─── Feedback ─── */
.feedback {
    margin-top: 0.85rem;
    padding: 0.9rem;
    border-radius: var(--radius-sm);
    background: var(--bg-void);
    border: 1px solid var(--border-subtle);
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.55;
}
.feedback strong { color: var(--text-primary); font-weight: 600; }
.feedback ul { margin: 0.35rem 0 0.35rem 1.1rem; }
.feedback li { margin-bottom: 0.15rem; }

.fb-block {
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.6rem;
    border-left: 3px solid var(--border-medium);
    background: rgba(255,255,255,0.03);
}
.fb-block:last-child { margin-bottom: 0; }
.fb-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.3rem;
    color: var(--text-muted);
}
.fb-user { border-left-color: var(--text-muted); background: rgba(255,255,255,0.025); }
.fb-correct { border-left-color: var(--success); background: var(--success-soft); }
.fb-correct .fb-label { color: var(--success); }
.fb-explanation { border-left-color: var(--accent); background: var(--accent-soft); }
.fb-explanation .fb-label { color: var(--accent); }

/* ─── Overlays ─── */
.overlay {
    display: none;
    position: fixed; inset: 0;
    z-index: 200;
    align-items: center; justify-content: center;
    background: rgba(8,8,10,0.72);
    backdrop-filter: blur(8px);
}
.overlay-text { margin-top: 1.25rem; font-size: 0.95rem; color: var(--text-secondary); }

/* Dialog */
.dialog-overlay { padding: 1rem; }
.dialog {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    max-width: 440px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: popIn 0.35s var(--transition) both;
}
.dialog-icon {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    margin: 0 auto 0.85rem;
}
.dialog-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}
.dialog-body {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1.1rem;
}
.unanswered-banner {
    background: var(--error-soft);
    border: 1px solid rgba(248,113,113,0.18);
    color: var(--error);
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    margin-bottom: 1.1rem;
    text-align: left;
}
.dialog-actions { display: flex; gap: 0.7rem; justify-content: center; }

/* ─── Warning Banner ─── */
.warning-banner {
    display: none;
    margin-bottom: 1.1rem;
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-sm);
    background: var(--error-soft);
    border: 1px solid rgba(248,113,113,0.18);
    color: var(--error);
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
}

/* ─── Footer ─── */
.app-footer {
    text-align: center;
    padding: 1.75rem 1rem;
    font-size: 0.74rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
}

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