/* ==============================================================
   WORKSHEET GENERATOR STYLES
   Professional AI-powered worksheet creation tool
   ============================================================== */

/* ─── Modal Base ──────────────────────────────────────────── */
#worksheetModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(16px);
    z-index: 200000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#worksheetModal.show {
    opacity: 1;
}

.ws-modal-box {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    width: 96%;
    max-width: 1100px;
    height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(99, 102, 241, 0.1);
    animation: wsModalIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes wsModalIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ─── Header ──────────────────────────────────────────────── */
.ws-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.05), transparent);
}

.ws-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ws-header-left h2 {
    color: #e2e8f0;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0;
    font-family: 'Outfit', sans-serif;
}

.ws-header-left h2 i {
    color: #818cf8;
    margin-right: 6px;
}

.ws-close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1rem;
}

.ws-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

/* ─── Tabs ────────────────────────────────────────────────── */
.ws-tabs {
    display: flex;
    gap: 0;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.2);
}

.ws-tab {
    background: none;
    border: none;
    color: #64748b;
    padding: 14px 20px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ws-tab:hover {
    color: #cbd5e1;
}

.ws-tab.active {
    color: #818cf8;
    border-bottom-color: #6366f1;
}

.ws-tab i {
    font-size: 0.8rem;
}

/* ─── Content Area ────────────────────────────────────────── */
.ws-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

.ws-content::-webkit-scrollbar {
    width: 6px;
}

.ws-content::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 10px;
}

.ws-tab-panel {
    display: none;
}

.ws-tab-panel.show {
    display: block;
    animation: wsFadeIn 0.25s ease;
}

@keyframes wsFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Setup Form ──────────────────────────────────────────── */
.ws-setup-form {
    max-width: 580px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ws-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ws-form-group label {
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-family: 'Outfit', sans-serif;
}

.ws-input {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    padding: 13px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: 'Outfit', sans-serif;
    transition: all 0.2s;
    outline: none;
}

.ws-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.ws-input::placeholder {
    color: #475569;
}

.ws-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.ws-form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
}

/* ─── Question Type Selector ──────────────────────────────── */
.ws-type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.ws-type-chip {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #94a3b8;
    padding: 12px 10px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-family: 'Outfit', sans-serif;
}

.ws-type-chip:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
    color: #c7d2fe;
}

.ws-type-chip.selected {
    background: rgba(99, 102, 241, 0.15);
    border-color: #6366f1;
    color: #c7d2fe;
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.3);
}

.ws-type-chip i {
    font-size: 1.2rem;
    color: #6366f1;
}

/* ─── Generate Button ─────────────────────────────────────── */
.ws-generate-btn {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    color: white;
    padding: 16px 24px;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s;
    margin-top: 10px;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.ws-generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.4);
}

.ws-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ─── Question Cards (Editor) ─────────────────────────────── */
.ws-questions-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 800px;
    margin: 0 auto;
}

.ws-question-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 20px;
    transition: all 0.3s;
    position: relative;
}

.ws-question-card:hover {
    border-color: rgba(99, 102, 241, 0.2);
    background: rgba(255, 255, 255, 0.04);
}

.ws-q-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.ws-q-number {
    color: #6366f1;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'Outfit', sans-serif;
}

.ws-q-type-badge {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: #818cf8;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ws-q-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.ws-q-action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    padding: 5px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
}

.ws-q-action-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
    color: #c7d2fe;
}

.ws-q-action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.ws-q-action-btn.regen:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.3);
    color: #c084fc;
}

.ws-q-textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    padding: 12px 14px;
    border-radius: 10px;
    min-height: 50px;
    font-size: 0.9rem;
    font-family: 'Outfit', sans-serif;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.6;
}

.ws-q-textarea:focus {
    border-color: #6366f1;
}

.ws-q-img-preview {
    position: relative;
    margin: 10px 0;
}

.ws-q-img-preview img {
    max-height: 150px;
    max-width: 100%;
    border-radius: 10px;
    object-fit: contain;
}

.ws-q-img-preview img[src*="svg+xml"] {
    max-height: 220px;
    min-width: 200px;
    background: #ffffff;
    border-radius: 8px;
    padding: 8px;
    border: 1px solid rgba(255,255,255,0.08);
}

/* ─── Answer Options (for MCQ/TF) ─────────────────────────── */
.ws-options-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.ws-option-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    padding: 6px 10px;
    border-radius: 8px;
}

.ws-option-label {
    color: #6366f1;
    font-weight: 800;
    font-size: 0.85rem;
    min-width: 24px;
    text-align: center;
}

.ws-option-input {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    padding: 6px 4px;
    font-size: 0.85rem;
    font-family: 'Outfit', sans-serif;
    outline: none;
}

.ws-option-input:focus {
    border-bottom-color: #6366f1;
}

/* Answer line for short answer / fill in blank */
.ws-answer-line {
    border-bottom: 2px dashed rgba(255, 255, 255, 0.15);
    min-height: 40px;
    margin-top: 10px;
    position: relative;
}

.ws-answer-hint {
    color: #475569;
    font-size: 0.75rem;
    position: absolute;
    bottom: -18px;
    left: 0;
}

/* ─── Editor Toolbar ──────────────────────────────────────── */
.ws-editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: 20px;
    gap: 10px;
    flex-wrap: wrap;
}

.ws-toolbar-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
}

.ws-toolbar-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
}

.ws-toolbar-btn.primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.ws-toolbar-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.ws-toolbar-btn.success {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.ws-toolbar-btn.success:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

/* ─── Worksheet Header Config ─────────────────────────────── */
.ws-header-config {
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
}

.ws-header-config h4 {
    color: #818cf8;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ─── Print Preview ───────────────────────────────────────── */
#wsPreviewOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(16px);
    z-index: 300000;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
}

#wsPreviewOverlay.show {
    display: flex;
}

.ws-preview-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.ws-scale-group {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.08);
    padding: 4px 8px;
    border-radius: 8px;
}

.ws-scale-label {
    font-size: 12px;
    color: #94a3b8;
    margin-right: 4px;
}

.ws-scale-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: #cbd5e1;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.ws-scale-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.ws-scale-btn.active {
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
}

.ws-scale-btn.compact-toggle.active {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: #fff;
}

.ws-preview-page {
    background: white;
    width: 210mm;
    min-height: 297mm;
    padding: 15mm 18mm;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
    position: relative;
    font-family: 'Outfit', 'Segoe UI', Tahoma, sans-serif;
    color: #1e293b;
    border-radius: 4px;
    flex-shrink: 0;
    box-sizing: border-box;
    overflow: visible;
}

/* For PDF rendering - hide offscreen clone */
.ws-preview-page.ws-pdf-clone {
    position: absolute;
    left: -9999px;
    top: 0;
}

/* A4 Preview - School Header */
.ws-print-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 3px double #334155;
    margin-bottom: 16px;
}

.ws-print-school {
    text-align: center;
    flex: 1;
}

.ws-print-school h1 {
    font-size: 16pt;
    font-weight: 800;
    color: #1e293b;
    margin: 0 0 2px 0;
    letter-spacing: normal;
}

.ws-print-school h2 {
    font-size: 12pt;
    font-weight: 600;
    color: #475569;
    margin: 0 0 4px 0;
}

.ws-print-info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 10pt;
    color: #475569;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 14px;
    gap: 16px;
}

.ws-print-info-row span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ws-print-info-line {
    border-bottom: 1px solid #94a3b8;
    min-width: 100px;
    display: inline-block;
}

/* A4 Preview - Questions */
.ws-print-question {
    margin-bottom: 18px;
    page-break-inside: avoid;
}

.ws-print-q-text {
    font-size: 11pt;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
    line-height: 1.6;
}

.ws-print-q-text .q-num {
    color: #6366f1;
    font-weight: 800;
    margin-right: 6px;
}

.ws-print-q-img {
    max-width: 50%;
    max-height: 120px;
    margin: 6px 0 6px 30px;
    border-radius: 6px;
    object-fit: contain;
    border: 1px solid #e2e8f0;
}

.ws-print-q-img[src*="svg+xml"] {
    max-width: 70%;
    max-height: 180px;
    min-width: 250px;
    background: white;
    padding: 10px;
}

/* MCQ Options in print */
.ws-print-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 20px;
    padding-left: 28px;
    font-size: 10.5pt;
    color: #334155;
}

.ws-print-option {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 3px 0;
}

.ws-print-option .opt-letter {
    font-weight: 800;
    color: #6366f1;
    min-width: 16px;
}

/* Answer Lines in print */
.ws-print-answer-lines {
    padding-left: 28px;
    margin-top: 6px;
}

.ws-print-answer-line {
    border-bottom: 1px solid #cbd5e1;
    height: 28px;
    margin-bottom: 2px;
}

/* TF Options in print */
.ws-print-tf {
    display: flex;
    gap: 30px;
    padding-left: 28px;
    font-size: 10.5pt;
    color: #334155;
    margin-top: 4px;
}

.ws-print-tf-option {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ws-print-tf-circle {
    width: 16px;
    height: 16px;
    border: 1.5px solid #94a3b8;
    border-radius: 50%;
}

/* Matching in print */
.ws-print-matching {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 6px 24px;
    padding-left: 28px;
    font-size: 10.5pt;
    align-items: center;
}

.ws-print-match-line {
    border-bottom: 1px dotted #cbd5e1;
    width: 60px;
    justify-self: center;
}

/* ─── Sketch Overlay (Worksheet) ──────────────────────────── */
#wsSketchOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.88);
    z-index: 350000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Outfit', sans-serif;
}

.ws-sketch-box {
    background: #1e293b;
    border-radius: 24px;
    padding: 24px;
    width: 90%;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

.ws-sketch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ws-sketch-header h3 {
    color: white;
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.ws-sketch-header h3 i {
    color: #6366f1;
    margin-right: 6px;
}

.ws-sketch-canvas-wrap {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
}

.ws-sketch-footer {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.ws-sketch-hint {
    color: #64748b;
    font-size: 0.75rem;
    flex: 1;
}

/* ─── Saved Worksheets Grid ───────────────────────────────── */
.ws-saved-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.ws-saved-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.ws-saved-card:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.ws-saved-card h4 {
    color: #e2e8f0;
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 6px 0;
}

.ws-saved-card .ws-card-meta {
    color: #64748b;
    font-size: 0.78rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ws-saved-card .ws-card-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ws-saved-card .ws-card-meta i {
    width: 14px;
    text-align: center;
    color: #818cf8;
}

.ws-saved-card .ws-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.ws-saved-card .ws-card-actions button {
    flex: 1;
    padding: 8px;
    border-radius: 10px;
    border: none;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
}

.ws-btn-preview {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

.ws-btn-preview:hover {
    background: rgba(99, 102, 241, 0.25);
}

.ws-btn-edit {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.ws-btn-edit:hover {
    background: rgba(16, 185, 129, 0.25);
}

.ws-btn-delete {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}

.ws-btn-delete:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ─── Empty State ─────────────────────────────────────────── */
.ws-empty {
    text-align: center;
    padding: 60px 20px;
    color: #475569;
}

.ws-empty i {
    font-size: 3rem;
    margin-bottom: 16px;
    color: #334155;
}

.ws-empty p {
    font-size: 1rem;
    margin: 0;
}

/* ─── Loading Shimmer ─────────────────────────────────────── */
.ws-loading {
    text-align: center;
    padding: 40px;
    color: #818cf8;
    font-size: 0.95rem;
    font-weight: 600;
}

.ws-loading i {
    margin-right: 6px;
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .ws-modal-box {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    .ws-type-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .ws-form-row,
    .ws-form-row-3 {
        grid-template-columns: 1fr;
    }

    .ws-preview-page {
        width: 100%;
        min-height: auto;
        padding: 10mm;
    }

    .ws-print-options {
        grid-template-columns: 1fr;
    }

    .ws-q-actions {
        justify-content: flex-start;
    }
}

/* ─── Answer Key Section (Print) ──────────────────────────── */
.ws-print-answer-key {
    margin-top: 30px;
    padding-top: 16px;
    border-top: 2px solid #334155;
}

.ws-print-answer-key h3 {
    font-size: 12pt;
    color: #1e293b;
    font-weight: 800;
    margin-bottom: 10px;
}

.ws-print-answer-key-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    font-size: 10pt;
}

.ws-answer-key-item {
    display: flex;
    gap: 4px;
    color: #334155;
}

.ws-answer-key-item .key-num {
    font-weight: 800;
    color: #6366f1;
}

/* ─── Source Lesson Selector ──────────────────────────────── */
#ws-source-lesson optgroup {
    color: #1e293b;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: 'Outfit', sans-serif;
    background: #f1f5f9;
}

#ws-source-lesson option {
    color: #1e293b;
    font-weight: 400;
    padding: 4px 8px;
    background: white;
}

#ws-lesson-status {
    font-family: 'Outfit', sans-serif;
    line-height: 1.4;
}

/* ─── RTL Support for Math (KaTeX) ────────────────────────── */
[dir="rtl"] .katex {
    direction: ltr;
    unicode-bidi: isolate;
}

[dir="rtl"] .katex-display {
    direction: ltr;
    unicode-bidi: isolate;
}

/* ─── Compact KaTeX display math inside print preview ──────── */
/* Prevent display-mode equations from adding huge vertical gaps */
.ws-preview-page .katex-display,
.ws-print-q-text .katex-display,
.ws-print-option .katex-display {
    display: inline-block !important;
    margin: 0.1em 0.2em !important;
    vertical-align: middle !important;
}

.ws-print-q-text .katex {
    font-size: 1em !important;
}

.ws-print-option .katex {
    font-size: 0.95em !important;
}