/* ============================================================
   Language Learning Studio — Design System & Styles
   ============================================================ */

:root {
    /* Color palette — dark theme */
    --bg-primary: #0f0f14;
    --bg-secondary: #161620;
    --bg-tertiary: #1c1c2a;
    --bg-card: #1e1e30;
    --bg-hover: #252540;
    --bg-input: #1a1a2e;

    --text-primary: #e8e8f0;
    --text-secondary: #9898b0;
    --text-muted: #6868880;
    --text-inverse: #0f0f14;

    --accent: #7c5cfc;
    --accent-light: #9b82ff;
    --accent-dark: #5a3cd4;
    --accent-glow: rgba(124, 92, 252, 0.2);

    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.12);
    --error: #f87171;
    --error-bg: rgba(248, 113, 113, 0.12);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.12);
    --info: #60a5fa;

    --border-color: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);

    --glass: rgba(30, 30, 48, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px var(--accent-glow);

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    --sidebar-width: 340px;
    --header-height: 60px;
}

/* ============================================================
   Reset & Base
   ============================================================ */

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

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Layout
   ============================================================ */

#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============================================================
   Sidebar
   ============================================================ */

#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition-normal), width var(--transition-normal);
    z-index: 10;
}

#sidebar.collapsed {
    transform: translateX(-100%);
    width: 0;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 24px;
}

.logo h1 {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.system-prompt-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#system-prompt {
    flex: 1;
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.7;
    padding: 12px;
    resize: none;
    transition: border-color var(--transition-fast);
}

#system-prompt:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#model-select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    padding: 10px 12px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239898b0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color var(--transition-fast);
}

#model-select:focus {
    outline: none;
    border-color: var(--accent);
}

#model-select option {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.token-display {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.token-item {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

.token-item strong {
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.sidebar-actions {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ============================================================
   Buttons
   ============================================================ */

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.text-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.text-btn:hover {
    background: var(--accent-glow);
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.action-btn.danger:hover {
    background: var(--error-bg);
    border-color: var(--error);
    color: var(--error);
}

.action-btn.secondary:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent-light);
}

/* ============================================================
   Chat Area
   ============================================================ */

#chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.chat-title h2 {
    font-size: 16px;
    font-weight: 600;
}

.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: var(--accent-glow);
    color: var(--accent-light);
    border: 1px solid rgba(124, 92, 252, 0.2);
}

.badge.subtle {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 3px;
}

/* ============================================================
   Welcome Screen
   ============================================================ */

#welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

#welcome-screen .welcome-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

#welcome-screen h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#welcome-screen p {
    color: var(--text-secondary);
    max-width: 400px;
    margin-bottom: 32px;
}

.quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 600px;
}

.quick-prompt {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.quick-prompt:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

/* ============================================================
   Messages
   ============================================================ */

.message-group {
    margin-bottom: 24px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    position: relative;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.message:hover {
    background: rgba(255, 255, 255, 0.02);
}

.message:hover .message-actions {
    opacity: 1;
    pointer-events: auto;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #34d399, #059669);
}

.message.system .message-avatar {
    background: linear-gradient(135deg, var(--warning), #d97706);
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-role {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message.user .message-role { color: var(--accent-light); }
.message.assistant .message-role { color: var(--success); }
.message.system .message-role { color: var(--warning); }

.message-text {
    color: var(--text-primary);
    line-height: 1.7;
    word-wrap: break-word;
}

.message-text p {
    margin-bottom: 8px;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
}

.message-text strong {
    font-weight: 600;
    color: var(--accent-light);
}

/* ============================================================
   Message Actions (Edit / Delete / Retry)
   ============================================================ */

.message-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 2px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 2px;
    box-shadow: var(--shadow-sm);
}

.msg-action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 14px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: inherit;
    font-size: 11px;
}

.msg-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.msg-action-btn.edit:hover { color: var(--info); }
.msg-action-btn.retry:hover { color: var(--warning); }
.msg-action-btn.delete:hover { color: var(--error); }

/* Edit mode inline */
.message-edit-area {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
    padding: 10px 12px;
    resize: vertical;
    min-height: 60px;
}

.message-edit-area:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.edit-actions button {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
}

.edit-save {
    background: var(--accent);
    color: white;
}

.edit-save:hover {
    background: var(--accent-light);
}

.edit-cancel {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color) !important;
}

.edit-cancel:hover {
    color: var(--text-primary);
}

/* ============================================================
   Chat Input
   ============================================================ */

#chat-input-area {
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

#editing-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: var(--accent-glow);
    border: 1px solid rgba(124, 92, 252, 0.2);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--accent-light);
}

#editing-indicator.hidden {
    display: none;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 8px 8px 8px 16px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#chat-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    max-height: 150px;
    overflow-y: auto;
}

#chat-input:focus {
    outline: none;
}

#chat-input::placeholder {
    color: var(--text-muted);
}

#send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

#send-btn:hover {
    background: var(--accent-light);
    transform: scale(1.05);
}

#send-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* ============================================================
   Loading indicator
   ============================================================ */

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 0 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* ============================================================
   Interactive Components — Shared
   ============================================================ */

.component-container {
    margin: 12px 0;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.component-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.component-header .icon {
    font-size: 16px;
}

/* ============================================================
   Image Grid Component
   ============================================================ */

.image-grid-prompt {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.image-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    user-select: none;
}

.image-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.image-card.selected {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.image-card.correct {
    border-color: var(--success);
    background: var(--success-bg);
    animation: pulse-success 0.5s ease;
}

.image-card.incorrect {
    border-color: var(--error);
    background: var(--error-bg);
    animation: shake 0.5s ease;
}

@keyframes pulse-success {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.image-placeholder {
    width: 80px;
    height: 80px;
    margin: 0 auto 12px;
    background: linear-gradient(135deg, var(--bg-hover), var(--bg-card));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
    padding: 8px;
    border: 1px dashed var(--border-light);
}

.image-card-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

/* ============================================================
   Karaoke Text Component
   ============================================================ */

.karaoke-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.karaoke-lines {
    margin-bottom: 16px;
}

.karaoke-line {
    margin-bottom: 12px;
}

.karaoke-line-text {
    font-size: 18px;
    line-height: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.karaoke-word {
    padding: 2px 6px;
    border-radius: 4px;
    transition: all var(--transition-fast);
    cursor: default;
}

.karaoke-word.active {
    background: var(--accent);
    color: white;
    transform: scale(1.1);
    box-shadow: var(--shadow-glow);
}

.karaoke-word.read {
    color: var(--accent-light);
}

.karaoke-translation {
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 4px;
}

.karaoke-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.karaoke-btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

.karaoke-play {
    background: var(--accent);
    color: white;
}

.karaoke-play:hover {
    background: var(--accent-light);
}

.karaoke-reset {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.karaoke-reset:hover {
    color: var(--text-primary);
}

.karaoke-speed {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: auto;
}

/* ============================================================
   Flashcard Component
   ============================================================ */

.flashcard-deck {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.flashcard-container {
    perspective: 1000px;
    width: 100%;
    max-width: 320px;
    height: 220px;
    margin-bottom: 16px;
}

.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
}

.flashcard-front {
    background: linear-gradient(135deg, #1e1e3a, #2a2a4a);
    border: 1px solid var(--border-light);
}

.flashcard-back {
    background: linear-gradient(135deg, #1a2e1a, #2a3a2a);
    border: 1px solid rgba(52, 211, 153, 0.2);
    transform: rotateY(180deg);
}

.flashcard-image {
    width: 80px;
    height: 60px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding: 6px;
    line-height: 1.3;
}

.flashcard-word {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.flashcard-front .flashcard-word {
    color: var(--accent-light);
}

.flashcard-back .flashcard-word {
    color: var(--success);
}

.flashcard-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.flashcard-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.flashcard-nav-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.flashcard-nav-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.flashcard-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.flashcard-counter {
    font-size: 13px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   MCQ Component
   ============================================================ */

.mcq-question {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.mcq-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.mcq-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.mcq-option:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.mcq-option.selected {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.mcq-option.correct {
    border-color: var(--success);
    background: var(--success-bg);
}

.mcq-option.incorrect {
    border-color: var(--error);
    background: var(--error-bg);
}

.mcq-radio {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-light);
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.mcq-option.selected .mcq-radio {
    border-color: var(--accent);
}

.mcq-option.selected .mcq-radio::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.mcq-option.correct .mcq-radio {
    border-color: var(--success);
    background: var(--success);
}

.mcq-option.correct .mcq-radio::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: 700;
}

.mcq-option.incorrect .mcq-radio {
    border-color: var(--error);
}

.mcq-option.incorrect .mcq-radio::after {
    content: '✗';
    color: var(--error);
    font-size: 12px;
    font-weight: 700;
}

.mcq-option-text {
    font-size: 14px;
    color: var(--text-primary);
}

.mcq-submit {
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: white;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mcq-submit:hover {
    background: var(--accent-light);
}

.mcq-submit:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.mcq-explanation {
    margin-top: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.6;
    animation: fadeIn 0.3s ease;
}

.mcq-explanation.correct {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.mcq-explanation.incorrect {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

/* ============================================================
   Reorder Component
   ============================================================ */

.reorder-instruction {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.reorder-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    min-height: 50px;
}

.reorder-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: grab;
    transition: all var(--transition-fast);
    user-select: none;
}

.reorder-item:active {
    cursor: grabbing;
}

.reorder-item:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.reorder-item.dragging {
    opacity: 0.5;
    border-color: var(--accent);
    background: var(--accent-glow);
}

.reorder-item.drag-over {
    border-top: 2px solid var(--accent);
}

.reorder-item.correct {
    border-color: var(--success);
    background: var(--success-bg);
}

.reorder-item.incorrect {
    border-color: var(--error);
    background: var(--error-bg);
}

.reorder-handle {
    color: var(--text-muted);
    font-size: 16px;
    cursor: grab;
}

.reorder-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.reorder-content {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

.reorder-image-desc {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-color);
}

.reorder-check {
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: white;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.reorder-check:hover {
    background: var(--accent-light);
}

.reorder-result {
    margin-top: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

.reorder-result.correct {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.reorder-result.incorrect {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

/* ============================================================
   Error toast
   ============================================================ */

.error-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: var(--error-bg);
    border: 1px solid var(--error);
    border-radius: var(--radius-md);
    color: var(--error);
    font-size: 13px;
    z-index: 100;
    animation: slideUp 0.3s ease, fadeOut 0.3s ease 3s forwards;
}

@keyframes slideUp {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes fadeOut {
    to { opacity: 0; }
}

/* ============================================================
   Responsive
   ============================================================ */

#mobile-menu-btn {
    display: none;
}

@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        z-index: 100;
        box-shadow: var(--shadow-lg);
    }

    #sidebar.open {
        transform: translateX(0);
    }

    #mobile-menu-btn {
        display: flex;
    }
}
