/* ── VARIABLES ── */
:root {
    --rose: #f472b6;
    --rose-light: #fce7f3;
    --rose-dark: #be185d;
    --lilac: #a78bfa;
    --lilac-light: #ede9fe;
    --mint: #6ee7b7;
    --mint-light: #d1fae5;
    --peach: #fb923c;
    --peach-light: #ffedd5;
    --sky: #38bdf8;
    --sky-light: #e0f2fe;
    --cream: #fdf6ef;
    --sand: #f5e6d0;
    --text: #1e1033;
    --text-soft: #6b5a7a;
    --card: #ffffff;
    --border: #f0d9ec;
    --shadow: 0 4px 24px rgba(167, 139, 250, 0.13);
    --shadow-hover: 0 8px 40px rgba(244, 114, 182, 0.2);
    --code-bg: #1e1033;
    --code-fg: #f0d9ec;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--cream);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: -100px;
    right: -100px;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(244, 114, 182, 0.12), transparent 70%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -80px;
    left: -80px;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.12), transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ── TABS ── */
.tabs-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(253, 246, 239, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1.5px solid var(--border);
    display: flex;
    padding: 0 1rem;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    padding: 1rem 1.2rem;
    border: none;
    background: none;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-soft);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab-btn:hover {
    color: var(--rose-dark);
}

.tab-btn.active {
    color: var(--rose-dark);
    border-bottom-color: var(--rose);
    font-weight: 600;
}

.tab-btn .tab-icon {
    font-size: 1rem;
}

/* ── PANELS ── */
.panel {
    display: none;
}

.panel.active {
    display: block;
    animation: fadeUp 0.35s ease;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── HOME ── */
.hero {
    max-width: 820px;
    margin: 0 auto;
    padding: 4rem 1.5rem 2rem;
    text-align: center;
    position: relative;
    z-index: 1;
}

.hero-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--rose-light), var(--lilac-light));
    color: var(--rose-dark);
    padding: 0.35rem 1rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 1.2rem;
}

.hero h1 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    line-height: 1.15;
    background: linear-gradient(135deg, var(--rose-dark), var(--lilac));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.hero p {
    color: var(--text-soft);
    font-size: 1.05rem;
    line-height: 1.7;
    max-width: 520px;
    margin: 0 auto 2.5rem;
}

.hero-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
    text-align: left;
}

.hero-card {
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: 18px;
    padding: 1.3rem 1.2rem;
    box-shadow: var(--shadow);
    transition: all 0.25s;
    cursor: pointer;
}

.hero-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.hero-card .card-icon {
    font-size: 1.8rem;
    margin-bottom: 0.6rem;
}

.hero-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.hero-card p {
    font-size: 0.82rem;
    color: var(--text-soft);
    line-height: 1.5;
}

/* ── BUTTONS ── */
.btn {
    padding: 0.82rem 1.8rem;
    border: none;
    border-radius: 999px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--rose), var(--lilac));
    color: white;
    box-shadow: 0 4px 18px rgba(244, 114, 182, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(244, 114, 182, 0.45);
}

.btn-secondary {
    background: var(--rose-light);
    color: var(--rose-dark);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-outline {
    background: transparent;
    color: var(--rose-dark);
    border: 1.5px solid var(--rose);
}

.btn-outline:hover {
    background: var(--rose-light);
}

.btn-sm {
    padding: 0.5rem 1.2rem;
    font-size: 0.82rem;
}

/* ── FORM ELEMENTS ── */
.form-group {
    margin-bottom: 1.4rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    background: var(--cream);
    color: var(--text);
    transition: border 0.2s;
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--rose);
    background: #fff;
}

/* ── MULTI-SELECT CHIPS ── */
.multi-select-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-height: 160px;
    overflow-y: auto;
    padding: 0.5rem;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--cream);
}

.ms-chip {
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    background: var(--card);
    border: 1.5px solid var(--border);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s;
    color: var(--text-soft);
    user-select: none;
}

.ms-chip:hover {
    border-color: var(--rose);
    color: var(--rose-dark);
}

.ms-chip.selected {
    background: linear-gradient(135deg, var(--rose), var(--lilac));
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(244, 114, 182, 0.3);
}

.select-all-btn {
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    background: var(--sand);
    border: none;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-soft);
    transition: all 0.18s;
}

.select-all-btn:hover {
    background: var(--border);
}

/* ── QUIZ ── */
.quiz-wrap {
    max-width: 760px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
    position: relative;
    z-index: 1;
}

.quiz-setup {
    background: var(--card);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: var(--shadow);
    border: 1.5px solid var(--border);
}

.quiz-setup h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    margin-bottom: 0.4rem;
}

.quiz-setup>p {
    color: var(--text-soft);
    margin-bottom: 2rem;
}

/* Progress */
.quiz-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--rose), var(--lilac));
    border-radius: 99px;
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 0.85rem;
    color: var(--text-soft);
    font-weight: 600;
    white-space: nowrap;
}

/* Question card */
.question-card {
    background: var(--card);
    border-radius: 24px;
    padding: 2rem 2rem 1.5rem;
    box-shadow: var(--shadow);
    border: 1.5px solid var(--border);
    margin-bottom: 1.2rem;
}

.q-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.q-tag {
    padding: 0.25rem 0.8rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.q-tag.category {
    background: var(--lilac-light);
    color: #5b21b6;
}

.q-tag.difficulty-fácil {
    background: var(--mint-light);
    color: #047857;
}

.q-tag.difficulty-medio {
    background: var(--peach-light);
    color: #c2410c;
}

.q-tag.difficulty-difícil {
    background: #fce7f3;
    color: #9d174d;
}

.q-tag.topic {
    background: var(--sand);
    color: #7c6045;
}

.q-tag.code {
    background: var(--sky-light);
    color: #0369a1;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.answers-list {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.answer-btn {
    width: 100%;
    padding: 0.85rem 1.2rem;
    border: 1.5px solid var(--border);
    border-radius: 14px;
    background: var(--cream);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.92rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.18s;
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
}

.answer-btn:hover:not(:disabled) {
    border-color: var(--rose);
    background: var(--rose-light);
    transform: translateX(4px);
}

.answer-btn.selected {
    border-color: var(--lilac);
    background: var(--lilac-light);
}

.answer-btn.correct {
    border-color: #10b981;
    background: var(--mint-light);
    color: #065f46;
    font-weight: 600;
}

.answer-btn.wrong {
    border-color: #ef4444;
    background: #fef2f2;
    color: #991b1b;
}

.answer-btn:disabled {
    cursor: default;
}

.answer-letter {
    min-width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.answer-btn.selected .answer-letter {
    background: var(--lilac);
    color: white;
}

.answer-btn.correct .answer-letter {
    background: #10b981;
    color: white;
}

.answer-btn.wrong .answer-letter {
    background: #ef4444;
    color: white;
}

.quiz-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 0.5rem;
}

/* Timer */
.timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--rose-dark);
    background: var(--rose-light);
    padding: 0.4rem 1rem;
    border-radius: 999px;
}

.timer.warning {
    background: #fef3c7;
    color: #b45309;
}

.timer.urgent {
    background: #fef2f2;
    color: #dc2626;
    animation: pulse 0.8s infinite;
}

@keyframes pulse {
    50% {
        opacity: 0.6;
    }
}

/* Feedback */
.feedback-bar {
    padding: 0.8rem 1.2rem;
    border-radius: 14px;
    font-weight: 600;
    font-size: 0.92rem;
    margin-top: 0.8rem;
    display: none;
}

.feedback-bar.correct {
    background: var(--mint-light);
    color: #065f46;
    display: block;
}

.feedback-bar.wrong {
    background: #fef2f2;
    color: #991b1b;
    display: block;
}

/* Results */
.results-card {
    background: var(--card);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: var(--shadow);
    border: 1.5px solid var(--border);
    text-align: center;
}

.score-circle {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rose), var(--lilac));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 1.5rem auto;
    box-shadow: 0 8px 30px rgba(244, 114, 182, 0.3);
}

.score-num {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    color: white;
    line-height: 1;
}

.score-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
}

.result-emoji {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.results-card h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.results-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-box {
    padding: 1rem;
    border-radius: 14px;
    background: var(--cream);
    border: 1.5px solid var(--border);
}

.stat-box .val {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--rose-dark);
}

.stat-box .lbl {
    font-size: 0.78rem;
    color: var(--text-soft);
    font-weight: 500;
}

.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* ── RANKING ── */
.rank-wrap {
    max-width: 760px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
    position: relative;
    z-index: 1;
}

.rank-header {
    text-align: center;
    margin-bottom: 2rem;
}

.rank-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    margin-bottom: 0.3rem;
}

.rank-header p {
    color: var(--text-soft);
}

.rank-table {
    background: var(--card);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1.5px solid var(--border);
}

.rank-row {
    display: grid;
    grid-template-columns: 50px 1fr 80px 80px 100px;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    gap: 0.5rem;
    transition: background 0.15s;
}

.rank-row:last-child {
    border-bottom: none;
}

.rank-row:hover {
    background: var(--cream);
}

.rank-row.header {
    background: linear-gradient(135deg, var(--rose-light), var(--lilac-light));
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--text-soft);
    cursor: default;
}

.rank-pos {
    font-weight: 800;
    font-size: 1.1rem;
    text-align: center;
}

.rank-pos.gold {
    color: #f59e0b;
}

.rank-pos.silver {
    color: #94a3b8;
}

.rank-pos.bronze {
    color: #d97706;
}

.rank-name {
    font-weight: 600;
}

.rank-score {
    font-weight: 800;
    color: var(--rose-dark);
    text-align: center;
    font-size: 1.05rem;
}

.rank-time {
    color: var(--text-soft);
    text-align: center;
    font-size: 0.88rem;
}

.rank-date {
    color: var(--text-soft);
    text-align: center;
    font-size: 0.8rem;
}

.rank-empty {
    padding: 3rem;
    text-align: center;
    color: var(--text-soft);
}

.rank-empty .empty-icon {
    font-size: 3rem;
    margin-bottom: 0.8rem;
}

/* ── STUDY ── */
.study-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
    position: relative;
    z-index: 1;
}

.study-header {
    margin-bottom: 1.5rem;
}

.study-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    margin-bottom: 0.3rem;
}

.study-header p {
    color: var(--text-soft);
}

/* Study Search */
.study-search-bar {
    display: flex;
    gap: 0.7rem;
    margin-bottom: 1.2rem;
    align-items: center;
}

.study-search-input {
    flex: 1;
    padding: 0.7rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.92rem;
    background: var(--card);
    color: var(--text);
    outline: none;
    transition: border 0.2s;
}

.study-search-input:focus {
    border-color: var(--rose);
}

/* Filter Controls */
.filter-controls {
    margin-bottom: 1.5rem;
}

.filter-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    display: block;
}

.study-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

.filter-chip {
    padding: 0.4rem 1rem;
    border-radius: 999px;
    background: var(--card);
    border: 1.5px solid var(--border);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-soft);
}

.filter-chip:hover {
    border-color: var(--rose);
    color: var(--rose-dark);
}

.filter-chip.active {
    background: linear-gradient(135deg, var(--rose), var(--lilac));
    color: white;
    border-color: transparent;
    box-shadow: 0 3px 12px rgba(244, 114, 182, 0.3);
}

.filter-clear {
    font-size: 0.78rem;
    color: var(--text-soft);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0.2rem 0.5rem;
    font-family: 'DM Sans', sans-serif;
}

.filter-clear:hover {
    color: var(--rose-dark);
}

/* Study Grid */
.study-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.2rem;
}

.study-card {
    background: var(--card);
    border-radius: 20px;
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s;
}

.study-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.study-card-header {
    padding: 1.2rem 1.4rem 0.8rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.study-card-title {
    font-weight: 700;
    font-size: 0.97rem;
    line-height: 1.4;
}

.study-card-body {
    padding: 1rem 1.4rem;
}

.study-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.7rem;
}

.study-card-tag {
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: var(--sand);
    color: var(--text-soft);
    font-size: 0.72rem;
    font-weight: 500;
}

.study-card-preview {
    font-size: 0.86rem;
    color: var(--text-soft);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.study-card-footer {
    padding: 0.8rem 1.4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--cream);
}

.study-card-footer .cat {
    font-size: 0.78rem;
    color: var(--text-soft);
    font-weight: 500;
}

/* Study Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(30, 16, 51, 0.6);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--card);
    border-radius: 24px;
    max-width: 720px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    padding: 2rem;
    box-shadow: 0 24px 80px rgba(30, 16, 51, 0.25);
    transform: scale(0.95);
    transition: transform 0.25s;
}

.modal-overlay.visible .modal {
    transform: scale(1);
}

.modal-close {
    float: right;
    background: var(--rose-light);
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    color: var(--rose-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--border);
}

.modal h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    margin-bottom: 1.2rem;
    clear: both;
}

/* Modal markdown */
.modal-content h1,
.modal-content h2 {
    font-family: 'Playfair Display', serif;
    color: var(--rose-dark);
    margin: 1rem 0 0.5rem;
}

.modal-content h3 {
    font-weight: 700;
    margin: 0.8rem 0 0.4rem;
}

.modal-content p {
    line-height: 1.75;
    margin-bottom: 0.8rem;
}

.modal-content strong {
    color: var(--rose-dark);
}

.modal-content ul,
.modal-content ol {
    padding-left: 1.4rem;
    margin-bottom: 0.8rem;
}

.modal-content li {
    margin-bottom: 0.4rem;
    line-height: 1.6;
}

.modal-content code,
.modal-content pre {
    background: var(--code-bg);
    color: var(--code-fg);
    border-radius: 10px;
    padding: 0.15rem 0.5rem;
    font-size: 0.87rem;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
}

.modal-content pre {
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1rem;
    display: block;
    line-height: 1.6;
}

.modal-content pre code {
    padding: 0;
    background: none;
}

.modal-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.modal-content th {
    background: var(--lilac-light);
    color: #5b21b6;
    padding: 0.5rem 0.8rem;
    font-weight: 700;
    text-align: left;
}

.modal-content td {
    padding: 0.5rem 0.8rem;
    border-top: 1px solid var(--border);
}

.modal-content tr:hover td {
    background: var(--cream);
}

/* ── SEARCH PANEL ── */
.search-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
    position: relative;
    z-index: 1;
}

.search-header {
    margin-bottom: 2rem;
}

.search-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    margin-bottom: 0.3rem;
}

.search-header p {
    color: var(--text-soft);
}

.search-box {
    position: relative;
    margin-bottom: 1.2rem;
}

.search-input {
    width: 100%;
    padding: 1rem 1.2rem 1rem 3rem;
    border: 2px solid var(--border);
    border-radius: 16px;
    font-family: 'DM Sans', sans-serif;
    font-size: 1rem;
    background: var(--card);
    color: var(--text);
    outline: none;
    transition: border 0.2s;
    box-shadow: var(--shadow);
}

.search-input:focus {
    border-color: var(--rose);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    pointer-events: none;
}

.search-count {
    font-size: 0.85rem;
    color: var(--text-soft);
    margin-bottom: 1rem;
}

.search-type-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.search-result {
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: 1.2rem 1.4rem;
    margin-bottom: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.search-result:hover {
    border-color: var(--rose);
    box-shadow: var(--shadow-hover);
    transform: translateX(4px);
}

.search-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.search-result-title {
    font-weight: 700;
    font-size: 0.97rem;
}

.search-result-type {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
}

.type-study {
    background: var(--lilac-light);
    color: #5b21b6;
}

.type-quiz {
    background: var(--rose-light);
    color: var(--rose-dark);
}

.type-code {
    background: var(--sky-light);
    color: #0369a1;
}

.search-result-excerpt {
    font-size: 0.86rem;
    color: var(--text-soft);
    line-height: 1.5;
}

.search-result-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.search-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-soft);
}

.search-empty .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

highlight {
    background: rgba(244, 114, 182, 0.25);
    border-radius: 3px;
    font-weight: 700;
    padding: 0 2px;
}

/* ── CODE LAB ── */
.code-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
    position: relative;
    z-index: 1;
}

.code-header {
    margin-bottom: 2rem;
}

.code-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    margin-bottom: 0.3rem;
}

.code-header p {
    color: var(--text-soft);
}

.code-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.code-progress-bar {
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 1rem 1.4rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.code-prog-text {
    font-size: 0.88rem;
    color: var(--text-soft);
}

.code-prog-nums {
    font-weight: 700;
    color: var(--rose-dark);
}

.challenge-card {
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    margin-bottom: 1.2rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.challenge-card.expanded {
    box-shadow: var(--shadow-hover);
}

.challenge-header {
    padding: 1.2rem 1.4rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.8rem;
    transition: background 0.15s;
}

.challenge-header:hover {
    background: var(--cream);
}

.challenge-title-row {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    flex: 1;
}

.challenge-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.challenge-title {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.4;
}

.challenge-subtitle {
    font-size: 0.82rem;
    color: var(--text-soft);
    margin-top: 0.2rem;
}

.challenge-tags {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-shrink: 0;
}

.challenge-expand {
    font-size: 1.2rem;
    color: var(--text-soft);
    transition: transform 0.25s;
}

.challenge-card.expanded .challenge-expand {
    transform: rotate(180deg);
}

.challenge-body {
    display: none;
    padding: 0 1.4rem 1.4rem;
    border-top: 1px solid var(--border);
}

.challenge-card.expanded .challenge-body {
    display: block;
}

.challenge-desc {
    font-size: 0.92rem;
    color: var(--text-soft);
    line-height: 1.6;
    margin: 1rem 0;
}

/* Code block inside challenge */
.code-block {
    background: var(--code-bg);
    color: var(--code-fg);
    border-radius: 14px;
    padding: 1.2rem;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.83rem;
    line-height: 1.7;
    overflow-x: auto;
    margin-bottom: 1.2rem;
    position: relative;
}

.code-block-lang {
    position: absolute;
    top: 0.6rem;
    right: 0.8rem;
    font-size: 0.7rem;
    color: rgba(240, 217, 236, 0.5);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.challenge-options {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.ch-option {
    padding: 0.8rem 1.1rem;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--cream);
    cursor: pointer;
    font-size: 0.9rem;
    text-align: left;
    color: var(--text);
    transition: all 0.18s;
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    font-family: 'DM Sans', sans-serif;
}

.ch-option:hover:not(:disabled) {
    border-color: var(--lilac);
    background: var(--lilac-light);
}

.ch-option.selected {
    border-color: var(--lilac);
    background: var(--lilac-light);
}

.ch-option.correct {
    border-color: #10b981;
    background: var(--mint-light);
    color: #065f46;
    font-weight: 600;
}

.ch-option.wrong {
    border-color: #ef4444;
    background: #fef2f2;
    color: #991b1b;
}

.ch-option:disabled {
    cursor: default;
}

.ch-option-letter {
    min-width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
}

.ch-option.selected .ch-option-letter {
    background: var(--lilac);
    color: white;
}

.ch-option.correct .ch-option-letter {
    background: #10b981;
    color: white;
}

.ch-option.wrong .ch-option-letter {
    background: #ef4444;
    color: white;
}

.challenge-explanation {
    background: #f0f9ff;
    border: 1.5px solid #bae6fd;
    border-radius: 14px;
    padding: 1rem 1.2rem;
    font-size: 0.88rem;
    line-height: 1.65;
    color: #0c4a6e;
    display: none;
    margin-top: 0.8rem;
}

.challenge-explanation.visible {
    display: block;
}

.challenge-explanation strong {
    color: #075985;
}

.challenge-explanation pre {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 0.7rem;
    margin: 0.5rem 0;
    font-size: 0.82rem;
    overflow-x: auto;
    white-space: pre-wrap;
}

.challenge-actions {
    display: flex;
    gap: 0.8rem;
    margin-top: 0.8rem;
    flex-wrap: wrap;
}

.badge-completed {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #047857;
    background: var(--mint-light);
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
}

/* ── TOAST ── */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 1.5rem;
    z-index: 999;
    background: var(--text);
    color: white;
    padding: 0.8rem 1.4rem;
    border-radius: 14px;
    font-size: 0.9rem;
    font-weight: 500;
    transform: translateY(80px);
    opacity: 0;
    transition: all 0.3s;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    max-width: 320px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* ── LOADING ── */
.loading {
    text-align: center;
    padding: 4rem;
    color: var(--text-soft);
}

.spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--rose);
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── MOBILE ── */
@media (max-width: 640px) {
    .tabs-nav {
        padding: 0 0.5rem;
    }

    .tab-btn {
        padding: 0.85rem 0.9rem;
        font-size: 0.8rem;
    }

    .hero {
        padding: 2.5rem 1rem 1.5rem;
    }

    .quiz-setup,
    .question-card,
    .results-card {
        padding: 1.5rem;
    }

    .results-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.6rem;
    }

    .rank-row {
        grid-template-columns: 40px 1fr 65px 65px;
        font-size: 0.88rem;
    }

    .rank-date {
        display: none;
    }

    .modal {
        padding: 1.4rem;
    }

    .code-block {
        font-size: 0.76rem;
    }
}