/* ── Modern Admin Content Selector Enhancements ───────────────────────────── */
.card-header-modern {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    background: linear-gradient(90deg, #f4f6fb 60%, #e8ecf8 100%);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 2px 12px rgba(79, 99, 210, 0.07);
    padding: 1.5rem 2rem 1.2rem 2rem;
    border-bottom: 1.5px solid #e5e7eb;
}

.icon-circle {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #4f63d2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #fff;
    box-shadow: 0 2px 8px rgba(79, 99, 210, 0.10);
}

.modern-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: #232b4d;
    margin-bottom: .15rem;
}

.modern-subtitle {
    color: #6b7280;
    font-size: 1.01rem;
    margin-bottom: 0;
}

.card-body-modern {
    background: #f8fafc;
    border-radius: 0 0 18px 18px;
    box-shadow: 0 2px 12px rgba(79, 99, 210, 0.04);
    padding: 2rem 2.5rem 2.2rem 2.5rem;
}

.modern-row {
    display: flex;
    gap: 2.2rem;
    align-items: flex-end;
    margin-bottom: 1.1rem;
    flex-wrap: wrap;
}

.modern-group {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 6px rgba(79, 99, 210, 0.06);
    padding: 1.1rem 1.2rem .7rem 1.2rem;
    margin-bottom: 0;
    min-width: 180px;
    max-width: 260px;
    flex: 1 1 0;
}

.modern-label {
    font-weight: 700;
    color: #4f63d2;
    margin-bottom: .35rem;
    font-size: .98rem;
    letter-spacing: .01em;
}

.modern-dropdown-wrap {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.modern-select {
    border: 1.5px solid #c7d2fe;
    background: #f4f6fb;
    color: #232b4d;
    font-weight: 600;
    border-radius: 7px;
    transition: border-color .18s, box-shadow .18s;
    box-shadow: 0 1px 4px rgba(79, 99, 210, 0.04);
}

.modern-select:focus {
    border-color: #4f63d2;
    box-shadow: 0 0 0 3px rgba(79, 99, 210, 0.13);
}

.modern-btn {
    background: #e8ecf8;
    color: #4f63d2;
    border: 1.5px solid #c7d2fe;
    font-size: 1.35rem;
    font-weight: 700;
    border-radius: 8px;
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
    box-shadow: 0 1px 4px rgba(79, 99, 210, 0.07);
    margin-left: 0.2rem;
}

.modern-btn:hover {
    background: #4f63d2;
    color: #fff;
    border-color: #4f63d2;
    box-shadow: 0 2px 8px rgba(79, 99, 210, 0.13);
}

.modern-status {
    font-size: 1.05rem;
    color: #374151;
    background: #f4f6fb;
    border-radius: 7px;
    padding: .5rem 1.2rem;
    box-shadow: 0 1px 4px rgba(79, 99, 210, 0.04);
    margin-bottom: 0.5rem;
    min-height: 1.7em;
}

/* ── Admin Content Page Custom Layout ─────────────────────────────── */
.admin-content-row-1 {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.admin-content-row-2 {
    margin-bottom: 1rem;
}

.admin-content-row-3 {
    margin-bottom: 1.5rem;
}

.compact-group {
    flex: 1 1 0;
    min-width: 180px;
    max-width: 260px;
}

.dropdown-btn-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.compact-select {
    width: 60%;
    min-width: 100px;
    max-width: 180px;
    margin-bottom: 0;
}

.wide-btn {
    min-width: 48px;
    width: 48px;
    height: 38px;
    font-size: 1.4rem;
    margin-left: 0.2rem;
}

.status-message-line {
    font-weight: 600;
    margin: 0.5rem 0 0.5rem 0.1rem;
    min-height: 1.5em;
}

.chapter-group {
    max-width: 420px;
    width: 100%;
}

.chapter-select {
    width: 100%;
    min-width: 220px;
    max-width: 420px;
    margin-bottom: 0;
}

/* ── Form fields ───────────────────────────────────────────────────────── */
input[type="text"],
input[type="tel"],
input[type="email"],
input[type="url"],
textarea {
    width: 100%;
    padding: 0.7rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    margin-bottom: 0.7rem;
    background: #fff;
    transition: border-color .15s;
}

input[type="text"]:focus,
input[type="tel"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.result-box.error {
    margin-bottom: 1.2rem;
    font-size: 1rem;
}

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --primary: #4f63d2;
    --primary-h: #3a4fb8;
    --success: #22c55e;
    --success-h: #16a34a;
    --danger: #ef4444;
    --muted: #6b7280;
    --border: #e5e7eb;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0, 0, 0, .08);
    --font: 'Segoe UI', system-ui, sans-serif;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: #1f2937;
    min-height: 100vh;
}

/* ── Navbar ──────────────────────────────────────────────────────────────── */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

.brand {
    font-weight: 700;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
    color: inherit;
    letter-spacing: 0.01em;
}

.brand img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    gap: 1.25rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--muted);
    font-weight: 500;
    padding: .25rem .5rem;
    border-radius: 6px;
    transition: background .15s, color .15s;
}

.nav-links a:hover {
    background: var(--bg);
    color: var(--primary);
}

.nav-links a.active {
    color: var(--primary);
    font-weight: 600;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.container {
    max-width: 860px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.75rem 2rem;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

/* ── Typography ──────────────────────────────────────────────────────────── */
h1 {
    font-size: 1.5rem;
    margin-bottom: .4rem;
}

h2 {
    font-size: 1.2rem;
    margin-bottom: .4rem;
}

h3 {
    font-size: 1rem;
    margin-bottom: .3rem;
}

.subtitle {
    color: var(--muted);
    font-size: .95rem;
    margin-bottom: 1rem;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: .85rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: .55rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: var(--border);
    color: #374151;
    transition: background .15s, transform .1s;
}

.btn:hover {
    background: #d1d5db;
}

.btn:active {
    transform: scale(.97);
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-h);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: var(--success-h);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: .35rem .85rem;
    font-size: .82rem;
}

/* ── Drop zone ───────────────────────────────────────────────────────────── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    margin-bottom: 1rem;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: #f0f3ff;
}

.drop-icon {
    font-size: 2.5rem;
    margin-bottom: .5rem;
}

.drop-zone p {
    color: var(--muted);
    margin-bottom: .75rem;
}

.file-name {
    font-weight: 600;
    color: var(--primary);
    margin-top: .5rem;
    min-height: 1.2rem;
}

/* ── Result box ──────────────────────────────────────────────────────────── */
.result-box {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    font-size: .9rem;
    line-height: 1.5;
}

.result-box.success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.result-box.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* ── Chapters list (upload page) ─────────────────────────────────────────── */
.chapters-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.chapter-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .65rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: background .15s;
}

.chapter-row:hover {
    background: var(--bg);
}

.chapter-row .chapter-info {
    display: flex;
    flex-direction: column;
}

.chapter-row .chapter-info strong {
    font-size: .95rem;
}

.chapter-row .chapter-info small {
    color: var(--muted);
    font-size: .8rem;
}

.chapter-row .actions {
    display: flex;
    gap: .5rem;
}

/* ── Chapter grid (viewer page) ─────────────────────────────────────────── */
.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.chapter-tile {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    cursor: pointer;
    transition: box-shadow .15s, border-color .15s;
}

.chapter-tile:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(79, 99, 210, .15);
}

.chapter-tile .tile-subject {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--primary);
    margin-bottom: .35rem;
}

.chapter-tile h3 {
    font-size: .95rem;
}

.chapter-tile small {
    color: var(--muted);
    font-size: .8rem;
}

/* ── Subsection tabs ─────────────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin: 1rem 0;
    border-bottom: 2px solid var(--border);
    padding-bottom: .5rem;
}

.tab-btn {
    padding: .35rem .85rem;
    border-radius: 6px 6px 0 0;
    border: 1px solid transparent;
    background: none;
    cursor: pointer;
    font-size: .85rem;
    color: var(--muted);
    transition: background .15s, color .15s;
}

.tab-btn:hover {
    background: var(--bg);
    color: #374151;
}

.tab-btn.active {
    background: var(--surface);
    border-color: var(--border);
    border-bottom-color: var(--surface);
    color: var(--primary);
    font-weight: 600;
    margin-bottom: -2px;
}

/* ── Accordion (subsections) ─────────────────────────────────────────────── */
.accordion-hint {
    color: var(--muted);
    font-size: .88rem;
    margin: .75rem 0 1rem;
    text-align: center;
    padding: .5rem;
    background: #fffbeb;
    border: 1px dashed #fde68a;
    border-radius: 8px;
}

.accordion-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .6rem;
    /* overflow must NOT be hidden — it breaks position:sticky on child headers */
    overflow: visible;
}

.accordion-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .85rem 1.25rem;
    background: var(--bg);
    border: none;
    cursor: pointer;
    font-size: .95rem;
    font-weight: 600;
    color: #374151;
    text-align: left;
    transition: background .15s;
}

.accordion-header:hover {
    background: #e8ecf8;
}

.accordion-header.active {
    background: #eef1fc;
    color: var(--primary);
}

.accordion-chevron {
    font-size: .7rem;
    color: var(--muted);
    transition: transform .25s ease;
    flex-shrink: 0;
}

.accordion-header.active .accordion-chevron {
    transform: rotate(180deg);
    /* chevron flips up when open */
}

.accordion-body {
    max-height: 0;
    /* collapsed by default */
    overflow: hidden;
    transition: max-height .35s ease;
}

.accordion-body.open {
    max-height: none;
    /* large enough for any content */
}

.accordion-body-inner {
    padding: 1rem 1.25rem 1.25rem;
}

/* ── Subsection viewer ───────────────────────────────────────────────────── */
.subsection-block {
    animation: fadeIn .2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
    }
}

.concept-box,
.curiosity-box {
    background: var(--bg);
    border-left: 4px solid var(--primary);
    padding: 1rem 1.25rem;
    border-radius: 0 8px 8px 0;
    margin-bottom: 1rem;
}

.curiosity-box {
    border-left-color: #f59e0b;
}

.curiosity-box h4 {
    color: #92400e;
}

.fact-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1rem;
}

.fact-chip {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    border-radius: 20px;
    padding: .25rem .75rem;
    font-size: .82rem;
}

.formula-list {
    list-style: none;
    margin-bottom: 1rem;
}

.formula-list li {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .4rem .75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-bottom: .4rem;
    font-size: .88rem;
}

.formula-name {
    font-weight: 600;
    min-width: 160px;
    color: var(--muted);
}

.formula-val {
    font-family: 'Courier New', monospace;
    color: #1f2937;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: .88rem;
}

.comparison-table th {
    background: var(--primary);
    color: #fff;
    padding: .5rem .75rem;
    text-align: left;
}

.comparison-table td {
    padding: .45rem .75rem;
    border-bottom: 1px solid var(--border);
}

.comparison-table tr:nth-child(even) td {
    background: var(--bg);
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 1.25rem 0 .5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: .3rem;
}

.quiz-cta {
    margin-top: 1.5rem;
    text-align: center;
}

/* ── Quiz screen ─────────────────────────────────────────────────────────── */
.form-row {
    margin-bottom: 1.25rem;
}

.form-row label {
    display: block;
    font-weight: 600;
    margin-bottom: .4rem;
}

.radio-group,
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: .25rem;
}

.radio-group label,
.checkbox-group label {
    font-weight: 400;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .35rem;
}

.quiz-progress-bar-wrap {
    background: var(--border);
    border-radius: 4px;
    height: 6px;
    margin-bottom: .4rem;
}

.quiz-progress-bar {
    height: 6px;
    background: var(--primary);
    border-radius: 4px;
    transition: width .3s;
}

.question-topic {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: .5rem;
}

#question-text {
    font-size: 1.2rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.mcq-options {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    margin-bottom: 1rem;
}

.mcq-option {
    padding: .7rem 1rem;
    border-radius: 8px;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: border-color .15s, background .15s;
    font-size: .9rem;
}

.mcq-option:hover {
    border-color: var(--primary);
    background: #f0f3ff;
}

.mcq-option.selected {
    border-color: var(--primary);
    background: var(--primary);
    /* solid blue fill — clearly shows which option is picked */
    color: #ffffff;
    /* white text on blue background for contrast */
    font-weight: 600;
    /* slightly bolder so it stands out from unselected options */
}

.mcq-option.selected:hover {
    background: var(--primary-h);
    /* slightly darker blue on hover so it still feels interactive */
    border-color: var(--primary-h);
}

.mcq-option.correct {
    border-color: var(--success);
    background: #f0fdf4;
}

.mcq-option.wrong {
    border-color: var(--danger);
    background: #fef2f2;
}

.text-input-area {
    margin-bottom: 1rem;
}

.text-input-area input {
    width: 100%;
    padding: .65rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: .95rem;
    transition: border-color .15s;
}

.text-input-area input:focus {
    outline: none;
    border-color: var(--primary);
}

.tf-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.tf-btn {
    flex: 1;
    padding: .75rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    /* rounded corners matching .btn style */
    border: 2px solid var(--border);
    /* visible border — NOT none, so border-color works */
    background: var(--border);
    /* default unselected gray fill */
    color: #374151;
    /* default dark text */
    cursor: pointer;
    /* pointer cursor on hover */
    transition: background .15s, border-color .15s, color .15s;
    /* smooth state transitions */
}

.tf-btn:hover {
    background: #d1d5db;
    /* slightly darker gray on hover */
    border-color: #d1d5db;
}

.tf-btn.selected {
    background: var(--primary);
    /* solid blue — clearly shows which button was picked */
    border-color: var(--primary);
    color: #ffffff;
    /* white text on blue for contrast */
}

.tf-btn.correct {
    background: var(--success);
    /* solid green — clearly correct answer after submit */
    border-color: var(--success);
    color: #ffffff;
}

.tf-btn.wrong {
    background: var(--danger);
    /* solid red — clearly wrong answer after submit */
    border-color: var(--danger);
    color: #ffffff;
}

.feedback-box {
    padding: .85rem 1.1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .9rem;
    line-height: 1.5;
}

.feedback-box.correct {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.feedback-box.wrong {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.quiz-actions {
    display: flex;
    gap: .75rem;
    align-items: center;
}

/* ── Results screen ──────────────────────────────────────────────────────── */
.score-display {
    text-align: center;
    font-size: 3rem;
    font-weight: 800;
    margin: 1rem 0;
    color: var(--primary);
}

.score-display span {
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--muted);
    display: block;
}

.review-list {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    margin-bottom: 1.5rem;
}

.review-item {
    padding: .75rem 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--border);
    background: var(--bg);
    font-size: .88rem;
}

.review-item.correct {
    border-left-color: var(--success);
}

.review-item.wrong {
    border-left-color: var(--danger);
}

.review-item .r-q {
    font-weight: 600;
    margin-bottom: .2rem;
}

.review-item .r-a {
    color: var(--muted);
}

.review-item .r-correct {
    color: #166534;
}

.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* ── Image upload step (admin: per-subsection image pickers) ────────────── */
.sub-img-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: .75rem;
    background: var(--bg);
}

.sub-img-header {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: .75rem;
}

/* Circular subsection number badge */
.sub-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: .1rem;
}

.img-count {
    display: block;
    font-size: .8rem;
    color: var(--muted);
    margin-top: .15rem;
}

/* Compact drop zone inside each subsection card */
.mini-drop-zone {
    border: 1.5px dashed var(--border);
    border-radius: 8px;
    padding: .65rem 1rem;
    font-size: .85rem;
    color: var(--muted);
    cursor: pointer;
    text-align: center;
    transition: border-color .15s, background .15s;
    margin-bottom: .5rem;
    user-select: none;
}

.mini-drop-zone:hover,
.mini-drop-zone.drag-over {
    border-color: var(--primary);
    background: #f0f3ff;
    color: var(--primary);
}

/* Row of image thumbnails below the mini drop zone */
.img-preview-row {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    min-height: 0;
}

.img-thumb {
    position: relative;
    width: 80px;
    height: 80px;
}

.img-thumb img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    /* fill the square, crop excess */
    border-radius: 6px;
    border: 1px solid var(--border);
}

/* ✕ remove button pinned to top-right of each thumbnail */
.img-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    border: none;
    font-size: .65rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

/* ── AI Professor section ───────────────────────────────────────────────────── */
.ai-section-select {
    width: 100%;
    padding: .55rem .85rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: .95rem;
    background: #fff;
    color: #111827;
    cursor: pointer;
    transition: border-color .15s;
    margin-bottom: 1rem;
}

.ai-section-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 99, 210, .15);
}

.ai-response-area {
    margin-top: 1.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    line-height: 1.8;
    font-size: .95rem;
    animation: fadeIn .2s ease;
}

.ai-lang-tag {
    display: inline-block;
    background: #fef9c3;
    border: 1px solid #fde047;
    color: #713f12;
    border-radius: 4px;
    padding: .1rem .4rem;
    font-size: .75rem;
    font-weight: 700;
    margin-bottom: .5rem;
}

/* ── AI Professor — round progress bar ──────────────────────────────────────── */
.ai-round-wrap {
    margin: 1rem 0 .25rem;
}

.ai-round-label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: .35rem;
}

.ai-round-bar-bg {
    background: var(--border);
    border-radius: 4px;
    height: 6px;
}

.ai-round-bar {
    height: 6px;
    background: var(--primary);
    border-radius: 4px;
    transition: width .4s ease;
    /* smooth fill as rounds progress */
    width: 0;
}

/* ── AI Professor — choice buttons ────────────────────────────────────────── */
.ai-choices {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-top: 1rem;
}

.ai-choice-btn {
    width: 100%;
    text-align: left;
    padding: .65rem 1rem;
    border-radius: 8px;
    border: 1.5px solid var(--primary);
    background: #f0f3ff;
    /* soft blue tint — visually distinct from plain text */
    color: var(--primary);
    font-size: .9rem;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.ai-choice-btn:hover {
    background: var(--primary);
    /* fill solid on hover so it feels like a real action */
    color: #fff;
}

/* choice was tapped — keep it filled so the student sees what they picked */
.ai-choice-btn.ai-choice-selected {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    cursor: default;
    font-weight: 600;
}

/* all other choices fade out once one is picked — only the selected one stays prominent */
.ai-choice-btn.ai-choice-dim {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

/* "You asked:" bubble — right-aligned, styled like a ChatGPT user message */
.ai-user-bubble {
    display: block;
    text-align: right;
    background: var(--primary);
    color: #fff;
    border-radius: 16px 16px 4px 16px;
    /* rounded top, sharp bottom-right = sent bubble shape */
    padding: .55rem 1rem;
    margin-bottom: 1rem;
    font-size: .9rem;
    line-height: 1.5;
    font-style: italic;
}

/* ══════════════════════════════════════════════════════════════════════════
   Admin Dashboard
   ══════════════════════════════════════════════════════════════════════════ */

/* Wider container for the admin page */
.admin-container {
    max-width: 1280px;
}

/* ── Stats cards ─────────────────────────────────────────────────────────── */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    color: var(--muted);
    font-size: .82rem;
    margin-top: .35rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-card--online .stat-value {
    color: var(--success);
}

.stat-card--admin .stat-value {
    color: #f59e0b;
}

/* ── Online chips strip ──────────────────────────────────────────────────── */
.online-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    min-height: 2rem;
    align-items: center;
}

.online-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
    border-radius: 999px;
    padding: .3rem .85rem;
    font-size: .82rem;
    font-weight: 500;
}

.online-dot {
    width: .45rem;
    height: .45rem;
    background: var(--success);
    border-radius: 50%;
    flex-shrink: 0;
}

.online-indicator {
    color: var(--success);
    font-size: .7rem;
    margin-left: .3rem;
}

/* ── Users table ─────────────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

.admin-table th {
    text-align: left;
    padding: .6rem .8rem;
    border-bottom: 2px solid var(--border);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    white-space: nowrap;
    background: var(--bg);
}

.admin-table td {
    padding: .6rem .8rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover td {
    background: #f9fafb;
}

.table-empty {
    text-align: center;
    padding: 2.5rem !important;
    color: var(--muted);
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .18rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    margin-right: .15rem;
    vertical-align: middle;
}

.badge-admin {
    background: #fef3c7;
    color: #92400e;
}

.badge-user {
    background: #eff6ff;
    color: #1e40af;
}

.badge-success {
    background: #f0fdf4;
    color: #15803d;
}

.badge-danger {
    background: #fef2f2;
    color: #991b1b;
}

.badge-warning {
    background: #fffbeb;
    color: #92400e;
}

.badge-tier-free {
    background: #f3f4f6;
    color: var(--muted);
}

.badge-tier-pro {
    background: #eff6ff;
    color: #1d4ed8;
}

.badge-tier-premium {
    background: #faf5ff;
    color: #6b21a8;
}

/* ── Row action buttons ──────────────────────────────────────────────────── */
.row-actions {
    display: flex;
    gap: .3rem;
    flex-wrap: nowrap;
}

/* ── Search input ────────────────────────────────────────────────────────── */
.search-input {
    padding: .4rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .88rem;
    width: 240px;
    background: #fff;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ── Modals ──────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 1rem;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 12px 48px rgba(0, 0, 0, .2);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.modal-body {
    padding: 1.25rem 1.5rem;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    flex-shrink: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.15rem;
    cursor: pointer;
    color: var(--muted);
    padding: .2rem .4rem;
    border-radius: 4px;
    line-height: 1;
}

.modal-close:hover {
    background: var(--bg);
    color: #111;
}

/* ── Edit form grid ──────────────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: .55rem .75rem;
    align-items: center;
}

.form-grid label {
    font-size: .88rem;
    font-weight: 500;
    color: #374151;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
    margin-bottom: 0;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-weight: 400 !important;
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: var(--primary);
}

/* ── Toast notification ──────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: .75rem 1.25rem;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .15);
    transition: opacity .3s;
}

.toast-success {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.toast-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* ── Responsive: stack stats on small screens ────────────────────────────── */
@media (max-width: 640px) {
    .admin-stats {
        grid-template-columns: 1fr;
    }

    .row-actions {
        flex-wrap: wrap;
    }

    .search-input {
        width: 160px;
    }
}