:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Navbar ── */
.navbar {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}
.navbar-brand { font-size: 1.3rem; letter-spacing: -0.3px; }
.nav-link { opacity: 0.85; transition: opacity 0.15s; }
.nav-link:hover, .nav-link.active { opacity: 1; }

/* ── Hero ── */
.hero { padding: 3rem 0 1rem; }
.hero-icon { opacity: 0.9; }

/* ── Feature cards ── */
.feature-card {
    transition: transform 0.2s, box-shadow 0.2s;
    border-radius: 16px;
}
.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1) !important;
}
.feature-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px; height: 60px;
    border-radius: 16px;
    margin: 0 auto;
}
.upload-icon { background: #ede9fe; color: var(--primary); }
.test-icon   { background: #dcfce7; color: var(--success); }
.flash-icon  { background: #fef3c7; color: var(--warning); }

/* ── Format block ── */
.format-block {
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    font-size: 0.8rem;
    white-space: pre-wrap;
    margin: 0;
}

/* ── Upload page ── */
.type-btn {
    border-radius: 12px;
    transition: all 0.15s;
    height: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.btn-check:checked + .type-btn.btn-outline-success {
    background: #dcfce7;
    border-color: var(--success);
    color: var(--success);
}
.btn-check:checked + .type-btn.btn-outline-warning {
    background: #fef3c7;
    border-color: var(--warning);
    color: var(--warning);
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background: #ede9fe30;
}
.drop-zone.has-file { border-color: var(--success); background: #dcfce730; }

/* ── Quiz List ── */
.quiz-card, .flashcard-list-card { border-radius: 14px; }
.quiz-type-badge {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: #f1f5f9;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.score-badge { font-size: 0.75rem; }
.empty-state { opacity: 0.7; }

/* ── Quiz Page ── */
.timer-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--border);
    z-index: 1100;
}
.timer-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #7c3aed);
    transition: width 1s linear;
    border-radius: 0 2px 2px 0;
}
.timer-bar-fill.warning { background: linear-gradient(90deg, var(--warning), #f59e0b); }
.timer-bar-fill.danger  { background: linear-gradient(90deg, var(--danger), #ef4444); }

.timer-display {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    transition: border-color 0.3s;
    min-width: 110px;
    text-align: center;
}
.timer-display.warning { border-color: var(--warning); color: var(--warning); }
.timer-display.danger  { border-color: var(--danger);  color: var(--danger);
    animation: pulse 0.8s ease-in-out infinite; }

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

.quiz-progress { height: 6px; border-radius: 3px; background: var(--border); }

/* Questions */
.question-card { border-radius: 14px; transition: box-shadow 0.2s; }
.question-card.answered { border-left: 4px solid var(--primary) !important; }
.question-number {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 32px; height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: #ede9fe;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.85rem;
}

.options-grid { display: flex; flex-direction: column; gap: 0.5rem; }
.option-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.option-label:hover { border-color: var(--primary); background: #ede9fe20; }
.option-label.selected { border-color: var(--primary); background: #ede9fe50; }
.option-label.correct  { border-color: var(--success); background: #dcfce780; }
.option-label.wrong    { border-color: var(--danger);  background: #fee2e280; }
.option-letter {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 28px; height: 28px;
    min-width: 28px;
    border-radius: 6px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    font-weight: 700;
    font-size: 0.8rem;
    transition: all 0.15s;
}
.option-label.selected .option-letter { background: var(--primary); color: #fff; border-color: var(--primary); }
.option-label.correct  .option-letter { background: var(--success); color: #fff; border-color: var(--success); }
.option-label.wrong    .option-letter { background: var(--danger);  color: #fff; border-color: var(--danger);  }
.option-text { flex: 1; font-size: 0.95rem; }

/* Results modal */
.result-item { border-radius: 10px; padding: 1rem; margin-bottom: 0.75rem; }
.result-item.correct { background: #dcfce7; border-left: 4px solid var(--success); }
.result-item.wrong   { background: #fee2e2; border-left: 4px solid var(--danger);  }
.score-circle {
    width: 120px; height: 120px;
    border-radius: 50%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    font-weight: 700;
    margin: 0 auto 1.5rem;
}
.score-circle.pass { background: #dcfce7; color: var(--success); border: 4px solid var(--success); }
.score-circle.fail { background: #fee2e2; color: var(--danger);  border: 4px solid var(--danger);  }
.score-circle .score-num { font-size: 2rem; line-height: 1; }
.score-circle .score-label { font-size: 0.75rem; opacity: 0.8; }

/* ── Flashcards ── */
.flashcard-progress { height: 6px; border-radius: 3px; background: var(--border); }

.flashcard-progress-range {
    width: 100%;
    height: 10px;
    margin: 0;
    padding: 0;
    appearance: none;
    background: var(--border);
    border-radius: 999px;
}
.flashcard-progress-range:focus {
    outline: none;
    box-shadow: none;
}
.flashcard-progress-range::-webkit-slider-runnable-track {
    height: 10px;
    border-radius: 999px;
    background: transparent;
}
.flashcard-progress-range::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--bs-warning);
    border: 2px solid white;
    margin-top: -4px;
    box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.15);
}
.flashcard-progress-range::-moz-range-track {
    height: 10px;
    border-radius: 999px;
    background: transparent;
}
.flashcard-progress-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--bs-warning);
    border: 2px solid white;
    box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.15);
}

.flashcard-scene {
    perspective: 1200px;
    max-width: 600px;
    margin: 0 auto;
}
.flashcard {
    width: 100%;
    min-height: 280px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.4, 0.2, 0.2, 1);
    cursor: pointer;
    border-radius: 20px;
}
.flashcard.flipped { transform: rotateY(180deg); }

.flashcard-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 20px;
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 280px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.1);
}
.flashcard-front {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
}
.flashcard-back {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: white;
    transform: rotateY(180deg);
}
.card-face-label {
    position: absolute;
    top: 1rem; left: 1.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    opacity: 0.7;
}
.card-face-content {
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.5;
    max-width: 90%;
}
.card-face-hint {
    position: absolute;
    bottom: 1rem;
    font-size: 0.78rem;
    opacity: 0.7;
}

.flashcard-controls .btn { min-width: 90px; }

/* ── Responsive ── */
@media (max-width: 576px) {
    .flashcard-controls { flex-wrap: wrap; }
    .flashcard-controls .btn { flex: 1 1 auto; }
    .card-face-content { font-size: 1.1rem; }
}

/* ── Profiles ── */
.avatar-dot {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.avatar-dot-sm {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 28px; height: 28px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    flex-shrink: 0;
}
.profile-avatar {
    width: 64px; height: 64px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; font-weight: 700; color: #fff;
    margin: 0 auto;
}
.profile-card { border-radius: 16px; transition: transform 0.15s, box-shadow 0.15s; }
.profile-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.1) !important; }
.profile-active { outline: 3px solid var(--primary); }

/* Color picker */
.color-swatch {
    display: block;
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.15s, transform 0.1s;
}
.color-swatch.selected {
    border-color: #fff;
    box-shadow: 0 0 0 2px var(--primary);
    transform: scale(1.15);
}

/* ── Leaderboard ── */
.leaderboard-table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.leaderboard-table td { vertical-align: middle; padding: 0.85rem 1rem; }
.leaderboard-table .table-active { background: #ede9fe40; }

.rank-badge {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 28px; height: 28px;
    border-radius: 50%;
    font-weight: 700; font-size: 0.8rem; color: #fff;
}
.rank-badge.gold   { background: linear-gradient(135deg, #f59e0b, #d97706); }
.rank-badge.silver { background: linear-gradient(135deg, #9ca3af, #6b7280); }
.rank-badge.bronze { background: linear-gradient(135deg, #cd7f32, #a16207); }
.rank-num { color: var(--muted); font-weight: 600; font-size: 0.9rem; }

.score-pill {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-weight: 700; font-size: 0.82rem;
}
.score-pass { background: #dcfce7; color: #15803d; }
.score-mid  { background: #fef3c7; color: #92400e; }
.score-fail { background: #fee2e2; color: #b91c1c; }

/* ── Edit pages ── */
.question-row, .card-row { border-radius: 12px; }
.card-row:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08) !important; }
