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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f8fafc;
    color: #1e293b;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    -webkit-text-size-adjust: 100%;
}

.page-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.home-card {
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.logo-circle {
    width: 56px;
    height: 56px;
    background: #4f46e5;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #0f172a;
}

.subtitle {
    color: #64748b;
    font-size: 0.938rem;
    line-height: 1.5;
    margin-bottom: 2rem;
}

.btn-google {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 0.938rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn-google:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Top navigation bar */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 100;
}

.topbar-title {
    font-weight: 600;
    font-size: 0.938rem;
    color: #0f172a;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-email {
    font-size: 0.813rem;
    color: #64748b;
}

.btn-logout {
    font-size: 0.813rem;
    font-weight: 500;
    color: #4f46e5;
    text-decoration: none;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    transition: background 0.15s;
}

.btn-logout:hover {
    background: #eef2ff;
}

/* Fixed topbar height — guest banner sits below, sticky under nav */
:root {
    --ap-topbar-height: 56px;
}

/* Guest strip below fixed .topbar (z-index 100); must not cover Dashboard / Log out */
.ap-guest-mode-below-topbar {
    margin-top: var(--ap-topbar-height);
    position: sticky;
    top: var(--ap-topbar-height);
    z-index: 90;
    background: #eff6ff;
    border-bottom: 1px solid #bfdbfe;
    color: #1e3a8a;
    padding: 10px 14px;
    font-size: 0.85rem;
    text-align: center;
    line-height: 1.45;
}

/* Banner already clears fixed topbar; avoid double top padding on main content */
.ap-guest-mode-below-topbar + .dashboard-content {
    padding-top: 1.25rem;
}

/* Dashboard card */
.dashboard-card {
    max-width: 480px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.avatar {
    width: 64px;
    height: 64px;
    background: #4f46e5;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 auto 1.25rem;
}

.info-row {
    margin-top: 1.5rem;
    background: #f8fafc;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    text-align: left;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.info-value {
    font-size: 0.875rem;
    color: #334155;
}

.dashboard-content {
    padding: 80px 1.5rem 2rem;
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.dashboard-content .card {
    max-width: 100%;
}

.children-card {
    text-align: left;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.children-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.children-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #0f172a;
}

.btn-add {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.813rem;
    font-weight: 500;
    color: #4f46e5;
    text-decoration: none;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    transition: background 0.15s;
}

.btn-add:hover {
    background: #eef2ff;
}

.children-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.child-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1rem;
    background: #f8fafc;
    border-radius: 8px;
}

.child-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
    overflow: hidden;
}

.child-name {
    font-size: 0.938rem;
    font-weight: 600;
    color: #0f172a;
    word-break: break-word;
}

.child-detail {
    font-size: 0.813rem;
    color: #64748b;
}

.btn-delete {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
}

.btn-delete:hover {
    color: #ef4444;
    background: #fef2f2;
}

.delete-form {
    display: flex;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #94a3b8;
    font-size: 0.875rem;
}

.form-card {
    max-width: 100%;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.form-card h1 {
    font-size: 1.25rem;
}

.count-selector {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.count-btn {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #334155;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.count-btn:hover {
    border-color: #4f46e5;
    color: #4f46e5;
}

.count-btn.active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
}

.child-fields {
    text-align: left;
}

.child-form-group {
    background: #f8fafc;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.child-form-group h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #4f46e5;
    margin-bottom: 0.875rem;
}

.form-field {
    margin-bottom: 0.75rem;
}

.form-field:last-child {
    margin-bottom: 0;
}

.form-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-field input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #1e293b;
    background: #fff;
    font-family: inherit;
    transition: border-color 0.15s;
}

.form-field input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.form-field input::placeholder {
    color: #94a3b8;
}

.btn-submit {
    display: block;
    width: 100%;
    padding: 0.75rem;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.938rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
    margin-top: 0.5rem;
}

.btn-submit:hover {
    background: #4338ca;
}

select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #1e293b;
    background: #fff;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.upload-type-toggle {
    display: flex;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
    margin-top: 0.25rem;
}

.upload-type-toggle input[type="radio"] {
    display: none;
}

.upload-type-toggle .toggle-btn {
    flex: 1;
    text-align: center;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s;
    border: none;
    background: transparent;
}

.upload-type-toggle .toggle-btn:hover {
    color: #334155;
}

.upload-type-toggle input[type="radio"]:checked + .toggle-btn {
    background: #fff;
    color: #4f46e5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.file-upload-area {
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.file-upload-area:hover,
.file-upload-area.dragover {
    border-color: #4f46e5;
    background: #f5f3ff;
}

.file-upload-area.has-file {
    border-color: #22c55e;
    background: #f0fdf4;
}

.file-upload-text {
    font-size: 0.875rem;
    color: #64748b;
}

.file-input-hidden {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    opacity: 0;
}

.books-subject-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: #4f46e5;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0.25rem 0.25rem;
    margin-top: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.books-subject-header:first-child {
    margin-top: 0;
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    width: 100%;
}

.select-all-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: #4f46e5;
    cursor: pointer;
    flex-shrink: 0;
}

.select-all-text {
    font-size: 0.688rem;
    font-weight: 400;
    color: #94a3b8;
    margin-left: auto;
    text-transform: none;
}

.book-checkbox-label {
    display: flex;
    align-items: center;
    padding-top: 0.125rem;
    flex-shrink: 0;
}

.book-checkbox {
    width: 15px;
    height: 15px;
    accent-color: #4f46e5;
    cursor: pointer;
}

.btn-delete-selected {
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 0.4rem 0.875rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-delete-selected:hover {
    background: #dc2626;
}

.book-actions {
    display: flex;
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
}

.btn-redetect {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #c7d2fe;
    padding: 0.3rem 0.625rem;
    border-radius: 5px;
    font-size: 0.688rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.btn-redetect:hover {
    background: #e0e7ff;
}

.redetect-form {
    margin: 0;
}

.book-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-radius: 8px;
}

.book-type-badge {
    display: inline-block;
    font-size: 0.688rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

.book-type-badge.book {
    background: #dbeafe;
    color: #1d4ed8;
}

.book-type-badge.chapter {
    background: #f0fdf4;
    color: #15803d;
}

.book-type-badge.image {
    background: #fef3c7;
    color: #92400e;
}

.book-type-badge.processing {
    background: #dbeafe;
    color: #1d4ed8;
    animation: processingPulse 1.5s ease-in-out infinite;
}

@keyframes processingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.book-processing {
    border-left: 3px solid #3b82f6;
}

.book-failed {
    border-left: 3px solid #dc2626;
    background: #fef2f2;
}

.processing-live-text {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.processing-dot-pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3b82f6;
    animation: dotPulse 1.2s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { transform: scale(0.8); opacity: 0.4; }
    50% { transform: scale(1.2); opacity: 1; }
}

.processing-label {
    font-size: 0.78rem;
    color: #3b82f6;
    font-weight: 500;
}

.failed-details {
    margin-top: 2px;
}

.failed-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: #dc2626;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.failed-badge::-webkit-details-marker {
    display: none;
}

.failed-message {
    margin: 6px 0 0;
    font-size: 0.75rem;
    color: #7f1d1d;
    line-height: 1.4;
    padding: 6px 8px;
    background: #fee2e2;
    border-radius: 6px;
}

.btn-retry {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
    background: #2563eb;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-retry:hover {
    background: #1d4ed8;
}

.chapters-details {
    margin-top: 0.5rem;
    font-size: 0.813rem;
}

.chapters-details summary {
    cursor: pointer;
    color: #4f46e5;
    font-weight: 500;
}

.chapters-list {
    margin-top: 0.375rem;
    padding-left: 1.25rem;
    color: #475569;
    line-height: 1.6;
}

.chapters-list li {
    margin-bottom: 0.125rem;
}

@media (max-width: 640px) {
    :root {
        --ap-topbar-height: 50px;
    }

    .topbar {
        padding: 0 0.75rem;
        height: 50px;
    }

    .topbar-title {
        font-size: 0.875rem;
    }

    .topbar-right {
        gap: 0.375rem;
    }

    .btn-logout {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .user-email {
        display: none;
    }

    .dashboard-content {
        padding: 62px 0.75rem 1.5rem;
        gap: 1rem;
    }

    .ap-guest-mode-below-topbar + .dashboard-content {
        padding: 1rem 0.75rem 1.5rem;
    }

    .card {
        padding: 1.25rem 1rem;
        border-radius: 10px;
    }

    h1 {
        font-size: 1.25rem;
    }

    .subtitle {
        font-size: 0.85rem;
        margin-bottom: 1.25rem;
    }

    .form-card h1 {
        font-size: 1.125rem;
    }

    .children-header h2 {
        font-size: 1rem;
    }

    .avatar {
        width: 52px;
        height: 52px;
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    .info-row {
        padding: 0.75rem 1rem;
    }

    .child-row {
        padding: 0.75rem 0.875rem;
    }

    .child-name {
        font-size: 0.875rem;
    }

    .child-detail {
        font-size: 0.75rem;
    }

    .book-row {
        padding: 0.625rem 0.75rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    .book-actions {
        margin-left: 0;
        width: 100%;
        padding-left: 1.75rem;
    }
    .btn-review-concepts {
        width: 100%;
        justify-content: center;
    }

    .book-type-badge {
        font-size: 0.625rem;
        padding: 0.1rem 0.375rem;
    }

    .books-subject-header {
        font-size: 0.688rem;
        padding: 0.375rem 0.125rem 0.25rem;
    }

    .select-all-text {
        font-size: 0.625rem;
    }

    .form-field label {
        font-size: 0.7rem;
    }

    .form-field input,
    select {
        padding: 0.75rem 0.875rem;
        font-size: 0.9rem;
    }

    .file-upload-area {
        padding: 1.25rem 1rem;
    }

    .file-upload-text {
        font-size: 0.8rem;
    }

    .btn-submit {
        padding: 0.875rem;
        font-size: 0.9rem;
    }

    .btn-redetect {
        font-size: 0.625rem;
        padding: 0.25rem 0.5rem;
        gap: 0.25rem;
    }

    .btn-delete-selected {
        font-size: 0.688rem;
        padding: 0.35rem 0.625rem;
    }

    .count-selector {
        gap: 0.375rem;
    }

    .count-btn {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }

    .child-form-group {
        padding: 1rem;
    }

    .child-form-group h3 {
        font-size: 0.813rem;
    }

    .progress-card {
        padding: 1.5rem 1.25rem;
    }

    .progress-card h2 {
        font-size: 1.05rem;
    }

    .step-item {
        font-size: 0.8rem;
    }

    .quiz-header-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .quiz-header-info h2 {
        font-size: 0.95rem;
    }

    .quiz-badge {
        font-size: 0.688rem;
        padding: 0.2rem 0.5rem;
    }

    .quiz-progress-dots {
        gap: 4px;
    }

    .progress-dot {
        width: 22px;
        height: 5px;
    }

    .question-number {
        font-size: 0.688rem;
        margin-bottom: 0.5rem;
    }

    .question-text {
        font-size: 0.95rem;
        margin-bottom: 1rem;
    }

    .option-btn {
        padding: 0.75rem 0.875rem;
        gap: 0.625rem;
        font-size: 0.85rem;
        border-radius: 8px;
    }

    .option-label {
        width: 26px;
        height: 26px;
        font-size: 0.75rem;
    }

    .question-explanation {
        padding: 0.875rem;
        margin-top: 1rem;
    }

    .explanation-header {
        font-size: 0.75rem;
    }

    .question-explanation p,
    .question-explanation .explanation-formatted {
        font-size: 0.813rem;
    }

    .quiz-nav {
        gap: 0.5rem;
    }

    .btn-quiz-nav {
        padding: 0.5rem 0.875rem;
        font-size: 0.813rem;
        gap: 0.25rem;
    }

    .quiz-nav-counter {
        font-size: 0.75rem;
    }

    .quiz-results-card h2 {
        font-size: 1.125rem;
    }

    .results-score {
        font-size: 0.875rem;
    }

    .results-stats {
        gap: 1.25rem;
    }

    .stat-num {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.688rem;
    }

    .results-actions {
        flex-direction: column;
    }

    .results-actions .btn-submit {
        width: 100%;
        min-width: unset;
    }

    .quiz-loading-content h2 {
        font-size: 1rem;
    }
}

@media (max-width: 380px) {
    .dashboard-content {
        padding: 58px 0.5rem 1rem;
    }

    .ap-guest-mode-below-topbar + .dashboard-content {
        padding: 0.85rem 0.5rem 1rem;
    }

    .card {
        padding: 1rem 0.875rem;
    }

    .topbar {
        padding: 0 0.5rem;
    }

    .btn-logout {
        font-size: 0.688rem;
        padding: 0.2rem 0.375rem;
    }

    .option-btn {
        padding: 0.625rem 0.75rem;
        font-size: 0.8rem;
    }

    .btn-quiz-nav {
        padding: 0.5rem 0.625rem;
        font-size: 0.75rem;
    }
}

.progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.progress-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.progress-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 1.5rem;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 4px;
    width: 0%;
    transition: width 1s ease;
}

.progress-step {
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 1.5rem;
}

.progress-steps-list {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: #94a3b8;
    transition: color 0.3s ease;
}

.step-item.active {
    color: #6366f1;
    font-weight: 500;
}

.step-item.done {
    color: #22c55e;
}

.step-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.pulse-dot {
    animation: pulse 1.2s ease-in-out infinite;
}

.quiz-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1.5rem;
}

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

.quiz-loading-content {
    text-align: center;
}

.quiz-loading-content h2 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.quiz-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quiz-container .card {
    max-width: 100%;
}

.quiz-header-card {
    text-align: left;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.quiz-header-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.quiz-header-info h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #0f172a;
    margin: 0;
}

.quiz-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.quiz-timer {
    font-size: 0.875rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    background: #f1f5f9;
    color: #475569;
}

.quiz-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    background: #eef2ff;
    color: #4f46e5;
}

.quiz-badge-score {
    background: #f0fdf4;
    color: #15803d;
}

.score-high { background: #dcfce7; color: #15803d; }
.score-mid { background: #fef3c7; color: #b45309; }
.score-low { background: #fee2e2; color: #dc2626; }

.quiz-progress-dots {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.progress-dot {
    width: 28px;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.progress-dot.current {
    background: #6366f1;
    transform: scaleY(1.3);
}

.progress-dot.correct {
    background: #22c55e;
}

.progress-dot.wrong {
    background: #ef4444;
}

.quiz-question-card {
    text-align: left;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.question-number {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6366f1;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.question-text {
    font-size: 1.05rem;
    font-weight: 500;
    line-height: 1.6;
    color: #0f172a;
    margin-bottom: 1.5rem;
}

.match-question-intro {
    margin-bottom: 0.75rem;
}

.match-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.match-table th {
    background: #f1f5f9;
    font-weight: 600;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e2e8f0;
    color: #1e3a8a;
}

.match-table td {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e2e8f0;
    vertical-align: top;
}

.match-table tr:nth-child(even) td {
    background: #f8fafc;
}

.review-q-text .match-table {
    margin-top: 0.5rem;
}

.match-single-col {
    margin-bottom: 1rem;
}

.match-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.match-list li {
    padding: 0.4rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-bottom: none;
    font-size: 0.95rem;
}

.match-list li:first-child {
    border-radius: 6px 6px 0 0;
}

.match-list li:last-child {
    border-bottom: 1px solid #e2e8f0;
    border-radius: 0 0 6px 6px;
}

.match-list li:nth-child(even) {
    background: #f8fafc;
}

.match-col-b-label {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #64748b;
}

.question-diagram {
    margin-bottom: 1.25rem;
    text-align: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    overflow: visible;
}

.diagram-actions {
    display: flex;
    justify-content: center;
    margin: -0.5rem 0 1rem;
}

.diagram-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    border-radius: 999px;
    padding: 0.45rem 0.85rem;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.diagram-retry-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #1e293b;
}

.diagram-retry-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.question-diagram svg {
    display: block;
    width: 100%;
    max-width: min(100%, 560px);
    height: auto;
    margin: 0 auto;
}

.review-diagram {
    margin: 0.5rem 0 0.75rem;
    text-align: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.75rem;
    overflow: visible;
}

.review-diagram svg {
    display: block;
    width: 100%;
    max-width: min(100%, 560px);
    height: auto;
    margin: 0 auto;
}

.question-diagram .jsxgraph-diagram-wrap,
.question-diagram .ocl-molecule-wrap,
.question-diagram .circuit-diagram-wrap,
.question-diagram .lewis-diagram-wrap,
.question-diagram .mo-diagram-wrap,
.question-diagram .orbital-diagram-wrap,
.question-diagram .geometry-diagram-wrap,
.review-diagram .jsxgraph-diagram-wrap,
.review-diagram .ocl-molecule-wrap,
.review-diagram .circuit-diagram-wrap,
.review-diagram .lewis-diagram-wrap,
.review-diagram .mo-diagram-wrap,
.review-diagram .orbital-diagram-wrap,
.review-diagram .geometry-diagram-wrap {
    width: 100%;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

.question-diagram canvas,
.review-diagram canvas {
    display: block;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 auto;
}

@media (max-width: 640px) {
    .question-diagram {
        padding: 0.75rem;
    }

    .review-diagram {
        padding: 0.65rem;
    }
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    font-family: inherit;
    font-size: 0.9rem;
    color: #1e293b;
    width: 100%;
}

.option-btn:hover:not(.disabled) {
    border-color: #6366f1;
    background: #f5f3ff;
}

.option-btn.disabled {
    cursor: default;
}

.option-btn.correct {
    border-color: #22c55e;
    background: #f0fdf4;
}

.option-btn.wrong {
    border-color: #ef4444;
    background: #fef2f2;
}

.option-btn.selected {
    border-color: #3b82f6;
    background: #eff6ff;
}

.option-btn.selected .option-label {
    background: #3b82f6;
    color: #fff;
}

.progress-dot.answered {
    background: #3b82f6;
}

.option-label {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.813rem;
}

.option-btn.correct .option-label {
    background: #22c55e;
    color: #fff;
}

.option-btn.wrong .option-label {
    background: #ef4444;
    color: #fff;
}

.tf-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.tf-btn {
    text-align: center;
    justify-content: center;
    font-weight: 600;
}

.option-text {
    flex: 1;
    line-height: 1.5;
}

.question-explanation {
    margin-top: 1.25rem;
    padding: 1rem;
    background: #f0fdf4;
    border-radius: 8px;
    border-left: 3px solid #22c55e;
}

.explanation-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: #15803d;
    font-size: 0.813rem;
    margin-bottom: 0.5rem;
}

.question-explanation p,
.question-explanation .explanation-formatted {
    color: #334155;
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 0;
}

.explanation-formatted div {
    line-height: 1.7;
}

.quiz-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.btn-quiz-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.625rem 1.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #475569;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.btn-quiz-nav:hover:not(:disabled) {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.btn-quiz-nav:disabled {
    opacity: 0.4;
    cursor: default;
}

.btn-quiz-nav-primary {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
}

.btn-quiz-nav-primary:hover:not(:disabled) {
    background: #4338ca;
    border-color: #4338ca;
}

.quiz-nav-counter {
    font-size: 0.813rem;
    color: #94a3b8;
    font-weight: 500;
}

.quiz-results-card {
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.results-icon {
    margin-bottom: 1rem;
}

.quiz-results-card h2 {
    font-size: 1.375rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

.results-score {
    font-size: 1rem;
    color: #64748b;
    margin-bottom: 1.5rem;
}

.results-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stat-num {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-correct .stat-num { color: #22c55e; }
.stat-wrong .stat-num { color: #ef4444; }
.stat-total .stat-num { color: #6366f1; }

.stat-label {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.results-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.results-actions .btn-submit {
    width: auto;
    min-width: 140px;
}

.repeat-quiz-btn {
    background: #8b5cf6;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    text-decoration: none;
}

.repeat-quiz-btn:hover {
    background: #7c3aed;
}

.review-actions-bar {
    display: flex;
    justify-content: center;
    padding: 0.5rem 0 0.75rem;
}

.review-actions-bar .repeat-quiz-btn {
    font-size: 0.875rem;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    border: none;
}

.quiz-page-content {
    max-width: 100%;
    background: #f8fafc;
    min-height: calc(100vh - var(--ap-topbar-height, 56px));
    padding-top: 80px;
    padding-bottom: 2.5rem;
}

.quiz-page-content > * {
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
}

.quiz-filter-section {
    text-align: left;
    padding: 0 1rem;
}

.quiz-page-header {
    margin-bottom: 1.75rem;
    text-align: center;
}

.quiz-page-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1.75rem;
    font-weight: 800;
    color: #4f46e5;
    margin-bottom: 0.5rem;
}

.quiz-page-subtitle {
    font-size: 0.938rem;
    color: #64748b;
    margin-bottom: 0;
    margin-top: 0.5rem;
}

.quiz-config-card {
    --theme-primary: #6366f1;
    --theme-light: #eef2ff;
    --theme-ring: rgba(99, 102, 241, 0.15);
    --theme-border: #a5b4fc;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1.75rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.config-mode-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.625rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.config-mode-label {
    font-size: 0.813rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(145deg, #c4c8cc, #d8dcdf);
    border-radius: 26px;
    transition: background 0.3s, box-shadow 0.3s;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2), 0 1px 0 rgba(255,255,255,0.6);
    border: 1px solid #b0b5ba;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    bottom: 2px;
    background: linear-gradient(145deg, #f0f0f0, #d4d4d4);
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.8), 0 0 0 1px rgba(0,0,0,0.08);
    border: 1px solid #a8a8a8;
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(145deg, #8a8f96, #a3a8ae);
    border-color: #7a7f85;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3), 0 1px 0 rgba(255,255,255,0.4);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: linear-gradient(145deg, #e8e8e8, #c8c8c8);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.7), 0 0 0 1px rgba(0,0,0,0.1);
}

.quiz-filter-field {
    margin-bottom: 1.25rem;
}

.quiz-filter-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 0.5rem;
}

.quiz-filter-label svg {
    color: var(--theme-primary, #6366f1);
    stroke: var(--theme-primary, #6366f1);
    flex-shrink: 0;
}

.label-optional {
    font-weight: 400;
    color: #94a3b8;
    font-size: 0.813rem;
}

.quiz-filter-icon {
    flex-shrink: 0;
}

.quiz-filter-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.938rem;
    color: #94a3b8;
    background: #fff;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.quiz-filter-select:focus {
    outline: none;
    border-color: var(--theme-primary, #6366f1);
    box-shadow: 0 0 0 3px var(--theme-ring, rgba(99, 102, 241, 0.15));
}

.quiz-filter-select:not(:disabled) {
    color: #1e293b;
}

.quiz-difficulty-section {
    margin-bottom: 1.5rem;
}

.segmented-control {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 3px;
}

.seg-btn {
    padding: 0.625rem 0.5rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    text-align: center;
}

.seg-btn:hover {
    color: #334155;
}

.seg-btn.selected {
    background: #fff;
    color: var(--theme-primary, #6366f1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.custom-section {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.5s ease-in-out, opacity 0.4s ease-in-out;
}

.custom-section.expanded {
    max-height: 800px;
    opacity: 1;
}

.custom-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 0.5rem 0 1.5rem 0;
}

.custom-field {
    margin-bottom: 1.25rem;
}

.chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.875rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 20px;
    background: #fff;
    font-size: 0.813rem;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
}

.chip:hover {
    border-color: var(--theme-border, #a5b4fc);
    background: var(--theme-light, #eef2ff);
}

.chip.selected {
    border-color: var(--theme-primary, #6366f1);
    background: var(--theme-light, #eef2ff);
    color: var(--theme-primary, #6366f1);
    font-weight: 600;
}

.format-hint {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--theme-primary, #6366f1);
    opacity: 0.8;
    margin-left: 0.25rem;
}

.multi-select-wrapper {
    position: relative;
}

.multi-select-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    padding: 0.4rem 0.75rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s;
    gap: 0.5rem;
}

.multi-select-display:hover,
.multi-select-display:focus {
    border-color: var(--theme-primary, #6366f1);
    outline: none;
}

.multi-select-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    flex: 1;
}

.ms-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.2rem 0.5rem;
    background: var(--theme-light, #eef2ff);
    border: 1px solid var(--theme-border, #c7d2fe);
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--theme-primary, #4f46e5);
    white-space: nowrap;
}

.ms-tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--theme-primary, #6366f1);
    padding: 0 0.1rem;
    line-height: 1;
    opacity: 0.6;
}

.ms-tag-remove:hover {
    opacity: 1;
}

.btn-submit-answer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 2rem;
    background: #1e3a8a;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.btn-submit-answer:hover:not(:disabled) {
    background: #1e40af;
    transform: translateY(-1px);
}
.btn-submit-answer:active {
    transform: translateY(0);
}
.btn-submit-answer:disabled {
    background: #cbd5e1;
    color: #94a3b8;
    cursor: not-allowed;
    transform: none;
}

.ms-placeholder {
    color: #94a3b8;
    font-size: 0.85rem;
}

.multi-select-arrow {
    flex-shrink: 0;
    font-size: 0.7rem;
    color: #94a3b8;
    transition: transform 0.15s;
}

.multi-select-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    z-index: 50;
    max-height: 220px;
    overflow-y: auto;
    padding: 0.35rem 0;
}

.multi-select-dropdown.open {
    display: block;
}

.ms-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: #334155;
    transition: background 0.1s;
}

.ms-option:hover {
    background: #f8fafc;
}

.ms-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--theme-primary, #6366f1);
    cursor: pointer;
    flex-shrink: 0;
}

.quiz-style-section {
    margin-top: 0.25rem;
}

.quiz-style-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.quiz-style-radio {
    cursor: pointer;
    display: block;
}

.quiz-style-radio input[type="radio"] {
    display: none;
}

.quiz-style-card {
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.7rem 0.75rem;
    background: #fff;
    transition: all 0.15s;
}

.quiz-style-radio input[type="radio"]:checked ~ .quiz-style-card {
    border-color: var(--theme-primary, #1e3a8a);
    background: #eff6ff;
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.1);
}

.quiz-style-card:hover {
    border-color: #93c5fd;
    background: #f8fafc;
}

.quiz-style-card-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.25rem;
}

.quiz-style-card-header svg {
    color: var(--theme-primary, #1e3a8a);
    flex-shrink: 0;
}

.quiz-style-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #1e293b;
}

.quiz-style-desc {
    font-size: 0.73rem;
    color: #64748b;
    line-height: 1.3;
    display: block;
    padding-left: 1.65rem;
}

@media (max-width: 480px) {
    .quiz-style-options {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .quiz-style-card {
        padding: 0.6rem 0.7rem;
    }
    .multi-select-display {
        min-height: 40px;
        font-size: 16px;
    }
    .ms-option {
        padding: 0.6rem 0.85rem;
        font-size: 16px;
    }
    .ms-option input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }
}

.format-grid-wrapper {
    min-height: 120px;
    position: relative;
}

.format-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
    transition: opacity 0.15s ease;
}

.format-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font-size: 0.813rem;
    font-weight: 500;
    color: #475569;
    transition: all 0.2s;
}

.format-checkbox:hover {
    border-color: var(--theme-border, #a5b4fc);
    background: #fafbff;
}

.format-checkbox input[type="checkbox"] {
    display: none;
}

.format-check-mark {
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e1;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    position: relative;
}

.format-checkbox input[type="checkbox"]:checked ~ .format-check-mark {
    background: var(--theme-primary, #6366f1);
    border-color: var(--theme-primary, #6366f1);
}

.format-checkbox input[type="checkbox"]:checked ~ .format-check-mark::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    position: absolute;
    top: 1px;
}

.format-checkbox input[type="checkbox"]:checked ~ span:last-child {
    color: var(--theme-primary, #6366f1);
    font-weight: 600;
}

.focus-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.875rem;
    font-family: inherit;
    color: #1e293b;
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.2s, box-shadow 0.2s;
    line-height: 1.5;
}

.focus-textarea::placeholder {
    color: #94a3b8;
}

.focus-textarea:focus {
    outline: none;
    border-color: var(--theme-primary, #6366f1);
    box-shadow: 0 0 0 3px var(--theme-ring, rgba(99, 102, 241, 0.15));
}

.length-chips {
    display: flex;
    gap: 0.625rem;
}

.length-chip {
    flex: 1;
    padding: 0.625rem 0.5rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    font-size: 0.938rem;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    text-align: center;
}

.length-chip:hover {
    border-color: var(--theme-border, #a5b4fc);
    background: var(--theme-light, #eef2ff);
}

.length-chip.selected {
    border-color: var(--theme-primary, #6366f1);
    background: var(--theme-light, #eef2ff);
    color: var(--theme-primary, #6366f1);
}

.quiz-start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem;
    background: #cbd5e1;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.25s;
    letter-spacing: 0.01em;
    margin-top: 1.5rem;
}

.quiz-start-btn:hover:not(:disabled) {
    filter: brightness(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.quiz-start-btn:disabled {
    background: #cbd5e1;
    cursor: default;
}

.quiz-start-btn:active:not(:disabled) {
    transform: scale(0.99);
}

@media (max-width: 640px) {
    .quiz-page-title {
        font-size: 1.375rem;
    }
    .quiz-page-subtitle {
        font-size: 0.85rem;
    }
    .quiz-page-header {
        margin-bottom: 1.25rem;
    }
    .quiz-config-card {
        padding: 1.25rem 1rem;
        border-radius: 14px;
    }
    .quiz-filter-field {
        margin-bottom: 1.125rem;
    }
    .quiz-filter-label {
        font-size: 0.813rem;
    }
    .format-grid {
        grid-template-columns: 1fr;
    }
    .format-checkbox {
        font-size: 0.813rem;
    }
}

@media (max-width: 380px) {
    .quiz-page-title {
        font-size: 1.25rem;
    }
    .quiz-config-card {
        padding: 1rem 0.875rem;
        border-radius: 12px;
    }
    .quiz-filter-field {
        margin-bottom: 1rem;
    }
    .chip {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }
    .length-chips {
        gap: 0.5rem;
    }
    .quiz-start-btn {
        padding: 0.75rem;
        font-size: 0.938rem;
        border-radius: 10px;
    }
}

/* ===== Admin Dashboard ===== */
.admin-wrapper {
    min-height: 100vh;
    background: #f1f5f9;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-header-left {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.admin-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
}

.admin-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.admin-user-badge {
    font-size: 0.75rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
}

.admin-back-btn {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #6366f1;
    text-decoration: none;
    padding: 0.375rem 0.875rem;
    border: 1.5px solid #6366f1;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.admin-back-btn:hover {
    background: #6366f1;
    color: #fff;
}

.admin-content {
    padding: 1.5rem;
    max-width: 1280px;
    margin: 0 auto;
}

.admin-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 4rem 1rem;
    color: #64748b;
    font-size: 0.9375rem;
}

.admin-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: adminSpin 0.7s linear infinite;
}

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

.admin-kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.analytics-range-btn {
    padding: 5px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Inter', sans-serif;
}
.analytics-range-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}
.analytics-range-btn.active {
    background: #1e3a8a;
    color: #fff;
    border-color: #1e3a8a;
}

.admin-kpi-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
}

.admin-kpi-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    margin-bottom: 0.625rem;
}

.admin-kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.admin-kpi-label {
    font-size: 0.8125rem;
    color: #64748b;
    margin-top: 0.25rem;
}

.admin-section {
    margin-bottom: 2rem;
}

.admin-accordion {
    margin-bottom: 1.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.admin-accordion-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}
.admin-accordion-toggle:hover {
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
}
.admin-accordion-toggle h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    flex: 1;
    text-align: left;
}
.admin-accordion-toggle .acc-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    flex-shrink: 0;
}
.admin-accordion-toggle .acc-chevron {
    transition: transform 0.3s ease;
    flex-shrink: 0;
    color: #94a3b8;
}
.admin-accordion.open .acc-chevron {
    transform: rotate(180deg);
}
.admin-accordion-toggle .acc-count {
    font-size: 0.75rem;
    color: #6b7280;
    background: #e2e8f0;
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 600;
}

.admin-accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}
.admin-accordion.open .admin-accordion-body {
    max-height: none;
    overflow: visible;
}
.admin-accordion-body-inner {
    padding: 1.25rem;
}

.admin-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.admin-section-header h2 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #0f172a;
}

.admin-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    min-width: 0;
}

.admin-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.admin-card-header h3 {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #0f172a;
}

.admin-card h3 {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 1rem;
}

.admin-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6366f1;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    padding: 0.375rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}

.admin-export-btn:hover {
    background: #c7d2fe;
}

.admin-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.admin-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.admin-table thead th {
    text-align: left;
    padding: 0.625rem 0.75rem;
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    border-bottom: 1.5px solid #e2e8f0;
    white-space: nowrap;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.admin-table tbody td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

.admin-table tbody tr:hover {
    background: #f8fafc;
}

.admin-empty {
    text-align: center;
    color: #94a3b8;
    padding: 1.5rem !important;
    font-style: italic;
}

.admin-chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.admin-chart-container {
    position: relative;
    height: 250px;
    overflow: hidden;
    max-width: 100%;
}

.admin-chart-wide {
    height: 220px;
}

.admin-leaderboard {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.admin-lb-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
}

.admin-lb-rank {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #6366f1;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
    flex-shrink: 0;
}

.admin-lb-name {
    flex: 1;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #1e293b;
}

.admin-lb-count {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
}

.admin-stat-card {
    text-align: center;
    padding: 1.5rem 1rem;
}

.admin-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    margin-bottom: 0.75rem;
}

.admin-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
}

.admin-stat-label {
    font-size: 0.8125rem;
    color: #64748b;
    margin-top: 0.25rem;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.admin-mini-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 10px;
}

.admin-mini-label {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.375rem;
    font-weight: 500;
}

.admin-mini-value {
    font-size: 1.375rem;
    font-weight: 700;
    color: #0f172a;
}

@media (max-width: 900px) {
    .admin-grid-2,
    .admin-grid-3 {
        grid-template-columns: 1fr;
    }
    .admin-kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .admin-content {
        padding: 1rem;
    }
    .admin-kpi-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    .admin-kpi-value {
        font-size: 1.375rem;
    }
    .admin-table {
        font-size: 0.75rem;
    }
}

.history-page {
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

.history-tutor-mode-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-right: 0.25rem;
    font-size: 0.813rem;
}

.history-tutor-mode-link {
    color: #64748b;
    text-decoration: none;
    font-weight: 500;
}

.history-tutor-mode-link:hover {
    color: #334155;
}

.history-tutor-mode-link.active {
    color: #1e3a8a;
    font-weight: 600;
}

.history-tutor-mode-sep {
    color: #cbd5e1;
    user-select: none;
}

.history-selector-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid #dbeafe;
    border-radius: 16px;
    padding: 1rem 1.125rem;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.08);
}

.history-selector-field {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.history-selector-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: 0.01em;
}

.history-selector-icon {
    color: #4f46e5;
    stroke: #4f46e5;
    flex-shrink: 0;
}

.history-child-select {
    width: 100%;
    padding: 0.875rem 1rem;
    padding-right: 2.75rem;
    border: 1.5px solid #cbd5e1;
    border-radius: 12px;
    font-size: 0.96rem;
    line-height: 1.4;
    color: #1e293b;
    background-color: #fff;
    background-image: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.98)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%236366f1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.2' d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat, no-repeat;
    background-position: center, right 0.95rem center;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.history-child-select:hover {
    border-color: #a5b4fc;
}

.history-child-select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
}

.history-selector-help {
    font-size: 0.8rem;
    color: #64748b;
    line-height: 1.45;
}

.history-child-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 1.25rem;
}
.history-child-tabs::-webkit-scrollbar { display: none; }

.history-child-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    background: #fff;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
}
.history-child-tab:hover {
    border-color: #a5b4fc;
    background: #f5f3ff;
}
.history-child-tab.active {
    border-color: #6366f1;
    background: #eef2ff;
    color: #4338ca;
}
.tab-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #4338ca;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}
.history-child-tab.active .tab-avatar {
    background: #6366f1;
    color: #fff;
}

.history-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem;
    color: #64748b;
}

.history-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    padding: 0 1rem;
    margin-bottom: 1.25rem;
}

.history-stat-card {
    background: #fff;
    border-radius: 0.75rem;
    padding: 1rem;
    text-align: center;
    border: 1px solid #e2e8f0;
}
.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.5rem;
}
.stat-icon-blue { background: #e0e7ff; color: #4338ca; }
.stat-icon-score-high { background: #dcfce7; color: #16a34a; }
.stat-icon-score-mid { background: #fef3c7; color: #d97706; }
.stat-icon-score-low { background: #fee2e2; color: #dc2626; }
.stat-icon-purple { background: #f3e8ff; color: #7c3aed; }
.stat-icon-orange { background: #ffedd5; color: #ea580c; }

.stat-card-value {
    font-size: 1.375rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}
.stat-card-label {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.125rem;
}

.history-section {
    padding: 0 1rem;
    margin-bottom: 1.25rem;
}
.history-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.history-section-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.history-subject-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    overflow: hidden;
}
.subject-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
    gap: 0.5rem;
}
.subject-header:hover {
    background: #f8fafc;
}
.subject-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.subject-info h3 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1e293b;
}
.subject-badge {
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}
.subject-badge.score-high { background: #dcfce7; color: #16a34a; }
.subject-badge.score-mid { background: #fef3c7; color: #d97706; }
.subject-badge.score-low { background: #fee2e2; color: #dc2626; }
.subject-quiz-count {
    font-size: 0.75rem;
    color: #94a3b8;
}
.subject-chevron {
    transition: transform 0.2s;
    color: #94a3b8;
    flex-shrink: 0;
}

.subject-topics {
    border-top: 1px solid #f1f5f9;
    padding: 0.5rem;
}
.topic-section {
    margin-bottom: 0.5rem;
}
.topic-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #475569;
    padding: 0.375rem 0.5rem;
}
.topic-attempts {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.attempt-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.625rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    gap: 0.5rem;
}
.attempt-row.score-high { background: #f0fdf4; }
.attempt-row.score-mid { background: #fffbeb; }
.attempt-row.score-low { background: #fef2f2; }

.attempt-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}
.attempt-date {
    font-size: 0.75rem;
    color: #475569;
}
.attempt-diff {
    font-size: 0.6875rem;
    color: #94a3b8;
    text-transform: capitalize;
}
.attempt-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.attempt-score-pill {
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    font-weight: 700;
    font-size: 0.75rem;
}
.attempt-score-pill.score-high { background: #bbf7d0; color: #166534; }
.attempt-score-pill.score-mid { background: #fde68a; color: #92400e; }
.attempt-score-pill.score-low { background: #fecaca; color: #991b1b; }
.attempt-detail {
    font-size: 0.75rem;
    color: #64748b;
}
.attempt-time {
    font-size: 0.6875rem;
    color: #94a3b8;
}
.btn-review {
    padding: 0.25rem 0.625rem;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}
.btn-review:hover {
    background: #4f46e5;
}

.focus-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
}
.focus-badge {
    padding: 0.25rem 0.625rem;
    background: #ef4444;
    color: #fff;
    border-radius: 1rem;
    font-size: 0.6875rem;
    font-weight: 700;
    white-space: nowrap;
}
.focus-info {
    flex: 1;
    min-width: 0;
}
.focus-info strong {
    display: block;
    font-size: 0.875rem;
    color: #1e293b;
}
.focus-detail {
    font-size: 0.75rem;
    color: #64748b;
}

.progress-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}
.progress-chart-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.75rem;
    position: relative;
    min-height: 280px;
    overflow: visible;
}
.progress-chart-card canvas {
    max-height: 260px !important;
    width: 100% !important;
}
.progress-chart-card h4 {
    margin: 0 0 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #475569;
}

.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 3rem 1rem;
    color: #94a3b8;
    text-align: center;
}
.history-empty h3 {
    margin: 0;
    color: #475569;
    font-size: 1.125rem;
}
.history-empty p {
    margin: 0;
    font-size: 0.875rem;
}

.mastery-badge-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.25rem 1.5rem;
    border-radius: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
}
.mastery-badge-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.mastery-badge-info h3 {
    margin: 0 0 2px;
    font-size: 1.35rem;
    font-weight: 700;
}
.mastery-badge-info .mastery-score {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}
.mastery-badge-info .mastery-label {
    font-size: 0.85rem;
    color: #64748b;
    margin: 0;
}

.subject-mastery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.subject-mastery-card {
    padding: 1rem;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.subject-mastery-card .sm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.subject-mastery-card .sm-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1e293b;
}
.subject-mastery-card .sm-grade {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    color: #fff;
}
.subject-mastery-card .sm-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}
.subject-mastery-card .sm-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}
.subject-mastery-card .sm-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: #94a3b8;
}

.qtype-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}
.qtype-chart-wrap {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 16px;
}
.qtype-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.qtype-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
}
.qtype-card .qtype-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.qtype-card .qtype-info {
    flex: 1;
}
.qtype-card .qtype-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #1e293b;
    text-transform: capitalize;
}
.qtype-card .qtype-detail {
    font-size: 0.75rem;
    color: #94a3b8;
}
.qtype-card .qtype-pct {
    font-weight: 700;
    font-size: 1rem;
}

.subtopic-dual {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.subtopic-panel {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 16px;
}
.subtopic-panel h4 {
    margin: 0 0 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
}
.subtopic-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid #f1f5f9;
}
.subtopic-row:last-child {
    border-bottom: none;
}
.subtopic-row .st-name {
    flex: 1;
    font-size: 0.82rem;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.subtopic-row .st-bar {
    width: 80px;
    height: 5px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}
.subtopic-row .st-bar-fill {
    height: 100%;
    border-radius: 3px;
}
.subtopic-row .st-pct {
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 42px;
    text-align: right;
}

.time-analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}
.time-card {
    padding: 14px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    text-align: center;
}
.time-card .tc-type {
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    text-transform: capitalize;
    margin-bottom: 6px;
}
.time-card .tc-avg {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1e293b;
}
.time-card .tc-unit {
    font-size: 0.75rem;
    color: #94a3b8;
}
.time-card .tc-range {
    font-size: 0.72rem;
    color: #94a3b8;
    margin-top: 4px;
}

.weekly-trend-wrap {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 16px;
}

.ai-details-card {
    padding: 1.25rem;
    border-radius: 14px;
    background: linear-gradient(135deg, #ede9fe 0%, #f5f3ff 100%);
    border: 1px solid #c4b5fd;
}
.ai-details-summary {
    cursor: pointer;
    list-style: none;
    -webkit-tap-highlight-color: transparent;
}
.ai-details-summary::-webkit-details-marker { display: none; }
.ai-details-summary::marker { display: none; content: ''; }
.ai-header-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.ai-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #5b21b6;
}
.ai-chevron-icon {
    margin-left: auto;
    color: #7c3aed;
    font-size: 0.75rem;
    transition: transform 0.3s;
}
.ai-details-card[open] .ai-chevron-icon {
    transform: rotate(180deg);
}
.ai-preview-text {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 4px 0 0;
    line-height: 1.5;
}
.ai-details-card[open] .ai-preview-text {
    display: none;
}
.ai-details-body {
    font-size: 0.88rem;
    color: #374151;
    line-height: 1.6;
}
.ai-details-body p {
    margin: 6px 0;
}
.ai-generated {
    font-size: 0.72rem;
    color: #7c3aed;
    margin-top: 10px;
    text-align: right;
}
.ai-insight-card {
    background: #faf5ff;
    border: 1px solid #e9d5ff;
    border-radius: 12px;
    padding: 16px;
}
.ai-insight-body p {
    margin: 6px 0;
    font-size: 0.88rem;
    line-height: 1.6;
    color: #1e293b;
}
.ai-no-data {
    text-align: center;
    padding: 16px;
    color: #64748b;
    font-size: 0.88rem;
}
.ai-generated-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e5e7eb;
}
.ai-generated-text {
    font-size: 0.72rem;
    color: #7c3aed;
}
.past-insights-header {
    font-size: 0.82rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.regen-insights-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #7c3aed;
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.regen-insights-btn:hover {
    background: #ede9fe;
    border-color: #c4b5fd;
    color: #6d28d9;
}
.ai-summary-loading {
    text-align: center;
    padding: 1rem;
    color: #7c3aed;
    font-size: 0.9rem;
}

.export-pdf-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: linear-gradient(135deg, #1e3a8a 0%, #312e81 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}
.export-pdf-btn:hover { opacity: 0.88; }
.export-pdf-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.export-pdf-btn svg { flex-shrink: 0; }

/* Metric tooltip bubble */
.metric-help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #4338ca;
    font-size: 11px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
    position: relative;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}
.metric-help-btn:hover {
    background: #c7d2fe;
}
.metric-tooltip {
    display: none;
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #f1f5f9;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.45;
    width: max-content;
    max-width: 240px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
    pointer-events: none;
}
.metric-tooltip::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid #1e293b;
}
.metric-help-btn.active .metric-tooltip {
    display: block;
}
.past-insights-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 20px;
    border: 1px solid #c4b5fd;
    background: #f5f3ff;
    color: #5b21b6;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.past-insights-btn:hover {
    background: #ede9fe;
    border-color: #8b5cf6;
}
.past-insight-card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
    background: #fff;
}
.past-insight-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    background: #faf9ff;
    transition: background 0.15s;
}
.past-insight-header:hover {
    background: #f3f0ff;
}
.past-insight-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.past-insight-date {
    font-weight: 600;
    font-size: 0.85rem;
    color: #374151;
}
.past-insight-stats {
    font-size: 0.75rem;
    color: #6b7280;
}
.past-insight-chevron {
    transition: transform 0.2s;
    flex-shrink: 0;
}
.past-insight-body {
    padding: 14px 16px;
    font-size: 0.85rem;
    color: #374151;
    line-height: 1.6;
    border-top: 1px solid #f3f4f6;
}
.past-insight-body p {
    margin: 5px 0;
}
.past-insight-gen {
    font-size: 0.72rem;
    color: #7c3aed;
    margin-top: 8px;
    text-align: right;
}

@media (max-width: 768px) {
    .qtype-layout { grid-template-columns: 1fr; }
    .subtopic-dual { grid-template-columns: 1fr; }
    .subject-mastery-grid { grid-template-columns: 1fr; }
    .time-analytics-grid { grid-template-columns: repeat(2, 1fr); }
}

.review-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}
/* Scoped to history quiz review only; chapter concepts uses .review-modal-overlay + same class name */
.review-modal .review-modal-content {
    background: #fff;
    border-radius: 1rem;
    width: 100%;
    max-width: 700px;
    margin-top: 1rem;
    margin-bottom: 2rem;
    overflow: hidden;
}
.review-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    gap: 0.5rem;
}
.review-modal-header h2 {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
    color: #1e293b;
}
.review-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    padding: 0.25rem;
    border-radius: 0.375rem;
}
.review-close-btn:hover {
    background: #f1f5f9;
    color: #475569;
}
.review-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
}
.review-meta-item {
    padding: 0.125rem 0.5rem;
    background: #f1f5f9;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    color: #475569;
    font-weight: 500;
    text-transform: capitalize;
}
.review-meta-item.score-high { background: #dcfce7; color: #16a34a; }
.review-meta-item.score-mid { background: #fef3c7; color: #d97706; }
.review-meta-item.score-low { background: #fee2e2; color: #dc2626; }

.review-questions {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.review-question-card {
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 1rem;
}
.review-question-card.review-correct {
    border-color: #bbf7d0;
}
.review-question-card.review-wrong {
    border-color: #fecaca;
}
.review-q-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.review-q-num {
    font-weight: 600;
    font-size: 0.8125rem;
    color: #64748b;
}
.review-q-text {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    color: #1e293b;
    line-height: 1.5;
}
.review-options {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}
.review-opt {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    color: #475569;
    background: #f8fafc;
}
.review-opt-correct {
    background: #dcfce7;
    color: #166534;
    font-weight: 500;
}
.review-opt-wrong {
    background: #fee2e2;
    color: #991b1b;
    font-weight: 500;
}
.review-opt-label {
    font-weight: 700;
    min-width: 1.25rem;
    color: inherit;
}
.review-explanation {
    margin-top: 0.75rem;
    padding: 0.625rem 0.75rem;
    background: #f0f9ff;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    color: #0369a1;
    line-height: 1.5;
}

@media (max-width: 640px) {
    .history-selector-card {
        padding: 0.9rem;
    }
    .history-stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .stat-card-value {
        font-size: 1.125rem;
    }
    .attempt-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .attempt-right {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .review-modal {
        padding: 0.5rem;
    }
    .review-modal .review-modal-content {
        margin-top: 0.5rem;
        border-radius: 0.75rem;
    }
    .review-questions {
        padding: 0.75rem;
    }
    .progress-charts-grid {
        grid-template-columns: 1fr;
    }
    .focus-card {
        flex-direction: column;
        align-items: flex-start;
    }
}

.question-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.report-flag-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #94a3b8;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.report-flag-btn:hover {
    color: #ef4444;
    border-color: #fca5a5;
    background: #fef2f2;
}
.report-flag-btn.reported {
    color: #22c55e;
    border-color: #86efac;
    background: #f0fdf4;
    cursor: default;
    pointer-events: none;
}
.report-flag-label {
    font-weight: 500;
}
.report-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.report-modal {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 440px;
    padding: 1.25rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    animation: reportSlideIn 0.2s ease-out;
}
@keyframes reportSlideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.report-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.report-modal-header h3 {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}
.report-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
.report-close-btn:hover {
    color: #64748b;
}
.report-question-preview {
    font-size: 0.82rem;
    color: #64748b;
    background: #f8fafc;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.report-reason-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    display: block;
    margin-bottom: 0.4rem;
}
.report-reason-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}
.report-reason-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem 0.65rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    font-size: 0.78rem;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}
.report-reason-btn:hover {
    border-color: #c7d2fe;
    background: #eef2ff;
}
.report-reason-btn.selected {
    border-color: #ef4444;
    background: #fef2f2;
    color: #dc2626;
    font-weight: 500;
}
.report-comments {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.82rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}
.report-comments:focus {
    outline: none;
    border-color: #a5b4fc;
}
.report-comments-wrap {
    margin-bottom: 0.75rem;
}
.report-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}
.report-cancel-btn {
    padding: 0.45rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #64748b;
    font-size: 0.82rem;
    cursor: pointer;
}
.report-cancel-btn:hover {
    background: #f8fafc;
}
.report-submit-btn {
    padding: 0.45rem 1rem;
    border: none;
    border-radius: 6px;
    background: #ef4444;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.report-submit-btn:hover:not(:disabled) {
    background: #dc2626;
}
.report-submit-btn:disabled {
    background: #fca5a5;
    cursor: not-allowed;
}
.report-success {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.75rem;
    background: #f0fdf4;
    border-radius: 8px;
    color: #16a34a;
    font-size: 0.85rem;
    font-weight: 500;
}
@media (max-width: 480px) {
    .report-reason-options {
        grid-template-columns: 1fr;
    }
    .report-modal {
        padding: 1rem;
    }
}

/* Tips Callout Card */
.tips-callout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #f5f3ff 0%, #eef2ff 100%);
    border: 1px solid #e0e7ff;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.25rem;
}
.tips-callout:hover {
    border-color: #a5b4fc;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}
.tips-callout:active {
    transform: scale(0.99);
}
.tips-callout-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #4f46e5;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tips-callout-text {
    flex: 1;
    min-width: 0;
}
.tips-callout-title {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #312e81;
}
.tips-callout-sub {
    display: block;
    font-size: 0.75rem;
    color: #6366f1;
    margin-top: 1px;
}
.tips-callout-arrow {
    color: #a5b4fc;
    flex-shrink: 0;
    transition: transform 0.2s;
}
.tips-callout:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}
.tips-callout:hover .tips-callout-arrow {
    transform: translateX(2px);
    color: #6366f1;
}

/* Tips Modal */
.tips-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.tips-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.tips-modal-card {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.04);
    transform: translateY(12px) scale(0.97);
    transition: transform 0.25s ease;
}
.tips-modal-overlay.active .tips-modal-card {
    transform: translateY(0) scale(1);
}
.tips-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    position: sticky;
    top: 0;
    background: #fff;
    border-radius: 16px 16px 0 0;
    z-index: 1;
}
.tips-modal-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.tips-header-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tips-modal-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}
.tips-close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.tips-close-btn:hover {
    color: #475569;
    background: #f1f5f9;
}
.tips-close-btn:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 1px;
}
.tips-modal-body {
    padding: 1rem 1.25rem 1.5rem;
}
.tips-section {
    margin-bottom: 1.25rem;
}
.tips-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.6rem;
}
.tips-section-header h3 {
    font-size: 0.88rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}
.tips-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.tips-list li {
    position: relative;
    padding: 0.45rem 0 0.45rem 1.5rem;
    font-size: 0.82rem;
    color: #475569;
    line-height: 1.55;
}
.tips-list li + li {
    border-top: 1px solid #f8fafc;
}
.tips-list li::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 0.65rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
}
.tips-list li strong {
    color: #334155;
}
.tips-list.mobile-tips li::before {
    background: #6366f1;
    border-radius: 2px;
}
.tips-visual-aids {
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid #f1f5f9;
}
.tips-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 0.6rem;
}
.tips-compare-item {
    border-radius: 10px;
    overflow: hidden;
    border: 1.5px solid #e2e8f0;
    transition: border-color 0.2s;
}
.tips-compare-item.correct {
    border-color: #86efac;
    background: #f0fdf4;
}
.tips-compare-item.incorrect {
    border-color: #fca5a5;
    background: #fef2f2;
}
.tips-compare-img-wrap {
    position: relative;
    overflow: hidden;
}
.tips-compare-item img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
}
.tips-compare-info {
    padding: 0.5rem 0.6rem;
    text-align: center;
}
.tips-compare-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.2rem 0.55rem;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.correct-label {
    background: #dcfce7;
    color: #15803d;
}
.incorrect-label {
    background: #fee2e2;
    color: #dc2626;
}
.tips-compare-info p {
    font-size: 0.72rem;
    color: #94a3b8;
    margin: 0.3rem 0 0;
}

/* Pre-flight Check */
.preflight-check {
    margin: 0.75rem 0 0.5rem;
    text-align: left;
}
.preflight-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
    color: #475569;
    cursor: pointer;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
}
.preflight-label:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
.preflight-label input[type="checkbox"] {
    accent-color: #4f46e5;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.preflight-label input[type="checkbox"]:checked ~ span {
    color: #334155;
}
.preflight-icon {
    flex-shrink: 0;
    color: #cbd5e1;
    transition: color 0.2s;
}
.preflight-label input[type="checkbox"]:checked ~ .preflight-icon {
    color: #22c55e;
}
.preflight-highlight {
    border-color: #fb923c !important;
    background: #fff7ed !important;
    animation: preflight-shake 0.4s ease;
}
@keyframes preflight-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}

/* Image Preview */
.image-preview-container {
    margin: 0.5rem 0;
    text-align: left;
}
.image-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}
.form-label-small {
    font-size: 0.78rem;
    color: #64748b;
    font-weight: 500;
}
.image-preview-count {
    font-size: 0.72rem;
    color: #4f46e5;
    font-weight: 600;
    background: #eef2ff;
    padding: 2px 8px;
    border-radius: 100px;
}
.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
    padding: 2px;
    scrollbar-width: thin;
    scrollbar-color: #e2e8f0 transparent;
}
.image-preview-thumb {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    transition: all 0.15s;
}
.image-preview-thumb:hover {
    border-color: #a5b4fc;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.12);
}
.image-preview-thumb img {
    width: 100%;
    height: 56px;
    object-fit: cover;
    display: block;
}
.preview-name {
    display: block;
    font-size: 0.62rem;
    color: #94a3b8;
    padding: 2px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 480px) {
    .tips-callout {
        padding: 0.65rem 0.85rem;
    }
    .tips-callout-icon {
        width: 32px;
        height: 32px;
    }
    .tips-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .tips-modal-card {
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }
    .tips-modal-overlay.active .tips-modal-card {
        transform: translateY(0);
    }
    .tips-compare-item img {
        height: 80px;
    }
    .image-preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }
}

@supports (-webkit-touch-callout: none) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    select,
    textarea {
        font-size: 16px !important;
    }

    .form-field input,
    .quiz-filter-select,
    .focus-textarea {
        font-size: 16px !important;
    }

    input,
    select,
    textarea,
    button {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border-radius: 6px;
    }

    select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 1rem center;
        padding-right: 2.5rem;
    }

    body.modal-open {
        position: fixed;
        width: 100%;
        overflow: hidden;
    }

    .progress-overlay,
    .review-modal,
    .report-overlay,
    .tips-modal-overlay {
        -webkit-overflow-scrolling: touch;
    }

    .review-modal .review-modal-content,
    .report-modal,
    .progress-card,
    .tips-modal-card {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }

    .progress-overlay,
    .report-overlay,
    .tips-modal-overlay {
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
    }

    .btn-submit,
    .btn-logout,
    .btn-retry,
    .btn-redetect,
    .btn-delete-selected {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .file-upload-area {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .topbar {
        padding-top: env(safe-area-inset-top, 0);
    }

    .dashboard-content {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .review-modal {
        padding-top: env(safe-area-inset-top, 1rem);
        padding-bottom: env(safe-area-inset-bottom, 1rem);
    }

    input[type="file"] {
        font-size: 16px !important;
    }

    .quiz-option {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        cursor: pointer;
    }

    .history-child-tabs {
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }

    .history-child-tab {
        scroll-snap-align: start;
    }
}

.skill-weakness-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 1px 6px;
    border-radius: 6px;
    margin-left: 6px;
    vertical-align: middle;
}

.error-class-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.error-class-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #e2e8f0;
}

.ec-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.ec-type {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ec-topic {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1e293b;
    margin-bottom: 4px;
}

.ec-label {
    font-size: 0.82rem;
    color: #64748b;
    margin-bottom: 6px;
}

.ec-detail {
    font-size: 0.82rem;
    font-weight: 600;
}

.bridge-recs-card {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    padding: 20px;
}

.bridge-current {
    font-size: 0.95rem;
    color: #334155;
    margin-bottom: 14px;
}

.bridge-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bridge-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.9rem;
    color: #1e3a5f;
    line-height: 1.4;
}

.bridge-item svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.pq-mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    color: #64748b;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pq-mode-btn.active {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
}

.pq-mode-btn:hover:not(.active) {
    background: #f1f5f9;
}

.pq-check-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s;
}

.pq-check-label:has(input:checked) {
    background: #eef2ff;
    border-color: #6366f1;
    color: #4338ca;
}

.pq-check-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #6366f1;
}
