:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --accent-color: #4facfe;

    /* Default Dark Theme */
    --bg-main: #0a0a0f;
    --bg-card: #1a1a2e;
    --bg-input: #0f0f1e;
    --bg-hover: #16162a;

    --text-primary: #ffffff;
    --text-secondary: #b0b0c0;
    --text-muted: #808090;

    --border-color: #2d2d44;
    --border-hover: #667eea;

    --radius-sm: 6px;
    --radius-md: 10px;

    --transition: all 0.2s ease;

    /* Component Colors */
    --bg-note: #1a2633;
    --bg-correct: #1a3a2e;
    --border-correct: #43e97b;
    --text-correct: #43e97b;
    --code-color: #a8d5ff;
}

[data-theme="light"] {
    --bg-main: #f0f2f5;
    --bg-card: #ffffff;
    --bg-input: #f8f9fa;
    --bg-hover: #e4e6eb;

    --text-primary: #1a1a1a;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;

    --border-color: #e5e7eb;
    --border-hover: #667eea;

    /* Component Colors (Light) */
    --bg-note: #eef2ff;
    --bg-correct: #ecfdf5;
    --border-correct: #34d399;
    --text-correct: #059669;
    --code-color: #2563eb;
}

/* Theme Toggle */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    padding: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    z-index: 100;
}

.theme-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

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

.theme-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* === HERO === */
.hero {
    text-align: center;
    padding: 60px 20px 40px;
}

.hero-content h1 {
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 12px;
}

.subtitle {
    font-size: clamp(1rem, 2vw, 1.2rem);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* === MAIN CONTENT === */
.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: 40px;
}

@media (min-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
    }

    .editor-section {
        grid-column: 1 / 2;
    }

    .preview-section {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
    }

    .instructions-section {
        grid-column: 1 / -1;
    }
}

/* === CARDS === */
.card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-hover);
}

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

.card-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* === TEXTAREA === */
#quizInput {
    width: 100%;
    min-height: 400px;
    padding: 20px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    border-radius: 0;
}

#quizInput:focus {
    outline: none;
    border-color: var(--border-hover);
}

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

/* === BUTTONS === */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    font-size: 1.1rem;
}

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

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

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-outline:hover {
    border-color: var(--border-hover);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.85rem;
}

/* === PREVIEW === */
.preview-section {
    display: none;
}

.preview-section.active {
    display: block;
}

.preview-content {
    padding: 20px;
    max-height: 600px;
    overflow-y: auto;
}

.preview-content::-webkit-scrollbar {
    width: 8px;
}

.preview-content::-webkit-scrollbar-track {
    background: var(--bg-input);
}

.preview-content::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.preview-chapter {
    margin-bottom: 32px;
}

.preview-chapter h3 {
    font-size: 1.4rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
    color: var(--text-primary);
}

.preview-question {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
    transition: var(--transition);
}

.preview-question:hover {
    border-left-color: var(--primary-color);
}

.preview-question .question-text {
    font-weight: 500;
    margin-bottom: 12px;
    font-size: 1rem;
}

.preview-question .options {
    list-style: none;
    padding-left: 0;
}

.preview-question .option {
    padding: 8px 12px;
    margin: 6px 0;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.preview-question .option:hover {
    border-color: var(--border-hover);
}

.preview-question .option.correct {
    background: var(--bg-correct);
    border: 2px solid var(--border-correct);
    font-weight: 500;
}

.preview-question .option.correct::before {
    content: '✓ ';
    color: var(--text-correct);
    font-weight: bold;
}

/* Question type badge */
.question-type-badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 0.75rem;
    background: #667eea;
    color: white;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: 600;
}

/* Essay and file upload notes */
.preview-question .essay-note,
.preview-question .file-note {
    padding: 10px;
    background: var(--bg-note);
    border-left: 3px solid #4facfe;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 10px;
}

/* Short answer styles */
.preview-question .short-answers {
    margin-top: 10px;
}

.preview-question .short-answers p {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* === INSTRUCTIONS === */
.instructions-content {
    padding: 20px;
}

.instruction-step {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.step-number {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
}

.step-content h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.step-content p {
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.step-content pre {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
}

.step-content code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--code-color);
}

.note {
    background: var(--bg-note);
    border-left: 3px solid var(--accent-color);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-top: 12px;
}

/* === FEATURES === */
.feature-card {
    margin-top: 24px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 20px;
}

.feature-item {
    text-align: center;
    padding: 24px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.feature-item:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
}

.feature-icon {
    font-size: 2.8rem;
    margin-bottom: 12px;
}

.feature-item h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.feature-item p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* === FOOTER === */
.footer {
    text-align: center;
    padding: 40px 20px;
    margin-top: 60px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
}

/* === LOADING OVERLAY === */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-overlay p {
    margin-top: 20px;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .hero {
        padding: 40px 20px 30px;
    }

    .card-footer {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .instruction-step {
        flex-direction: column;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }
}