:root {
    --bg-page: #f4f6f9;
    --bg-surface: #ffffff;
    --text-primary: #1e293b;
    --text-muted: #64748b;
    --brand-primary: #1d4ed8;
    --brand-dark: #1e3a8a;
    --border-subtle: #e2e8f0;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--brand-dark);
    text-decoration: none;
}

.brand-icon {
    font-size: 1.35rem;
    color: var(--brand-primary);
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.nav-link {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.nav-link:hover {
    background-color: var(--bg-page);
    color: var(--brand-primary);
}

.nav-cta {
    background-color: var(--brand-primary);
    color: #ffffff;
}

.nav-cta:hover {
    background-color: var(--brand-dark);
    color: #ffffff;
}

.app-user-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-greeting {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.inline-form {
    display: inline;
    margin: 0;
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.app-footer {
    text-align: center;
    padding: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
    background-color: var(--bg-surface);
}

.auth-container {
    max-width: 440px;
    margin: 2.5rem auto;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.form-field label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.full-width {
    width: 100%;
}

/* PrimeFaces sizes a dropdown to its longest option (autoWidth) with an inline min-width, which
   beats both .full-width and max-width and, with long course or module titles, made whole pages
   wider than a phone screen. Never let a dropdown be wider than its container; long labels end
   in "..." (the open list still shows them in full). */
.ui-selectonemenu {
    min-width: 0 !important;
    max-width: 100%;
}

/* Wide tables scroll sideways inside their own panel (above 640px; below it they reflow into
   cards). The browser's default overlay scrollbar there is a few pixels high, appears only while
   scrolling and cannot be grabbed with a finger: make it a thick, always-visible bar. Chrome,
   Edge and Android use these rules; iOS Safari ignores them (swipe the table there). */
.ui-datatable-tablewrapper::-webkit-scrollbar {
    height: 14px;
}

.ui-datatable-tablewrapper::-webkit-scrollbar-track {
    background: var(--bg-page, #f1f5f9);
    border-radius: 7px;
}

.ui-datatable-tablewrapper::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 7px;
    border: 3px solid var(--bg-page, #f1f5f9);
}

.ui-datatable-tablewrapper::-webkit-scrollbar-thumb:active {
    background: #64748b;
}

.ui-selectonemenu.full-width {
    width: 100% !important;
}

.ui-selectonemenu .ui-selectonemenu-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-footer-link {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-footer-link a {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 600;
}

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

.page-header h1 {
    margin: 0;
    font-size: 1.65rem;
}

.page-subtitle {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1.15rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--brand-dark);
}

.section-card {
    margin-bottom: 1.5rem;
}

.section-block {
    margin-top: 1.5rem;
}

.section-heading {
    margin: 0 0 1rem;
    font-size: 1.25rem;
}

.muted-text {
    color: var(--text-muted);
}

.field-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.monospace-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.inline-action-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.flex-grow {
    flex: 1;
    min-width: 220px;
}

.card-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.course-desc {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.5;
}

.table-title-cell {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.slug-badge {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.form-field-inline {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.dialog-footer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.breadcrumb-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.back-link {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.back-link:hover {
    text-decoration: underline;
}

/* Course Editor Two-Column Layout */
.editor-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 960px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
}

.editor-sidebar {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1rem;
}

.sidebar-header h2 {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
}

.add-module-row {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.sidebar-empty {
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

.module-block {
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.module-header {
    background-color: var(--bg-page);
    padding: 0.5rem 0.65rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border-subtle);
}

.module-title {
    font-weight: 600;
    font-size: 0.9rem;
    word-break: break-word;
}

.mini-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.1rem;
    flex-shrink: 0;
}

.lesson-list {
    display: flex;
    flex-direction: column;
}

.lesson-empty {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

.lesson-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.5rem 0.35rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    gap: 0.25rem;
}

.lesson-row:last-child {
    border-bottom: none;
}

.lesson-row-active {
    background-color: #eff6ff;
    border-left: 3px solid var(--brand-primary);
}

.lesson-select-link {
    flex: 1;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    word-break: break-word;
}

.lesson-select-link:hover {
    color: var(--brand-primary);
}

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

.editor-card-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

/* Video Embed Preview */
.video-embed-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    margin-bottom: 1.25rem;
    border-radius: 8px;
    overflow: hidden;
    background-color: #0f172a;
}

.video-embed-wrapper iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.inline-warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 0.6rem 0.85rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Markdown Split Editor & Preview */
.markdown-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.markdown-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

/* Insert Image dialog: upload, then the course's image library */
.image-dialog-help {
    margin-top: 0;
}

.image-uploader {
    margin-bottom: 1rem;
}

.image-library {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 50vh;
    overflow-y: auto;
}

.image-library-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
}

.image-library-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 4px;
    background-color: var(--bg-page);
    flex-shrink: 0;
}

.image-library-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    font-size: 0.9rem;
}

.image-library-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-library-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

/* Images in lessons and the editor preview: never wider than the text column */
.markdown-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.markdown-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 900px) {
    .markdown-split {
        grid-template-columns: 1fr;
    }
}

.markdown-preview {
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 0.85rem 1rem;
    background-color: #fafbfc;
    min-height: 260px;
    max-height: 460px;
    overflow-y: auto;
    line-height: 1.6;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
    margin-top: 0.5rem;
}

.markdown-preview pre {
    background-color: #0f172a;
    color: #f8fafc;
    padding: 0.75rem;
    border-radius: 6px;
    overflow-x: auto;
}

.markdown-preview code {
    background-color: #e2e8f0;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.88em;
}

.markdown-preview pre code {
    background-color: transparent;
    padding: 0;
}

.markdown-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
}

.markdown-preview th,
.markdown-preview td {
    border: 1px solid var(--border-subtle);
    padding: 0.4rem 0.6rem;
    text-align: left;
}

.attachment-uploader {
    margin-bottom: 1rem;
}

.attachment-link {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.attachment-link:hover {
    text-decoration: underline;
}

/* Token Generator */
.token-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.filter-bar {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.token-code-badge {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 600;
    background-color: #eff6ff;
    color: var(--brand-dark);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.88rem;
}

.token-note {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* Student Dashboard Progress */
.course-progress-block {
    margin-top: 1rem;
}

.course-progress-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.course-progress-meta strong {
    color: var(--text-primary);
}

.course-progress-bar.ui-progressbar {
    height: 0.55rem;
    border-radius: 999px;
}

/* Student Course Player */
.player-page-header {
    align-items: flex-end;
}

.player-header-progress {
    min-width: 240px;
    max-width: 320px;
    width: 100%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
}

.player-progress-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.player-progress-label strong {
    color: var(--brand-dark);
}

.player-layout {
    display: grid;
    grid-template-columns: 310px 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 960px) {
    .player-layout {
        grid-template-columns: 1fr;
    }
}

.player-sidebar {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1rem;
    position: sticky;
    top: 4.5rem;
}

@media (max-width: 960px) {
    .player-sidebar {
        position: static;
    }
}

.module-progress-badge {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
    flex-shrink: 0;
}

.player-lesson-row {
    border-bottom: 1px solid var(--border-subtle);
}

.player-lesson-row:last-child {
    border-bottom: none;
}

.player-lesson-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.75rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.35;
}

.player-lesson-link:hover {
    background-color: #f8fafc;
    color: var(--brand-primary);
}

.player-lesson-title {
    flex: 1;
    word-break: break-word;
}

.lesson-status-done {
    color: #16a34a;
    flex-shrink: 0;
}

.lesson-status-todo {
    color: #cbd5e1;
    flex-shrink: 0;
}

.lesson-media-icon {
    color: var(--text-muted);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.lesson-viewer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
}

.lesson-eyebrow {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.lesson-viewer-title {
    margin: 0;
    font-size: 1.45rem;
    color: var(--text-primary);
}

.lesson-markdown-content {
    line-height: 1.7;
    font-size: 1rem;
    color: var(--text-primary);
}

.lesson-markdown-content h1,
.lesson-markdown-content h2,
.lesson-markdown-content h3 {
    margin-top: 1.4rem;
    margin-bottom: 0.6rem;
    color: var(--text-primary);
}

.lesson-markdown-content p {
    margin: 0 0 1rem;
}

.lesson-markdown-content ul,
.lesson-markdown-content ol {
    margin: 0 0 1rem;
    padding-left: 1.5rem;
}

.lesson-markdown-content blockquote {
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    border-left: 4px solid var(--brand-primary);
    background-color: #f8fafc;
    color: var(--text-muted);
}

.lesson-markdown-content pre {
    background-color: #0f172a;
    color: #f8fafc;
    padding: 0.9rem 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1rem 0;
}

.lesson-markdown-content code {
    background-color: #e2e8f0;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.88em;
}

.lesson-markdown-content pre code {
    background-color: transparent;
    padding: 0;
}

.lesson-markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.lesson-markdown-content th,
.lesson-markdown-content td {
    border: 1px solid var(--border-subtle);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.lesson-markdown-content th {
    background-color: var(--bg-page);
}

.lesson-markdown-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.lesson-attachments-section {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-subtle);
}

.attachments-heading {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

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

.attachment-download-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background-color: #f8fafc;
    color: var(--text-primary);
    text-decoration: none;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.attachment-download-item:hover {
    border-color: var(--brand-primary);
    background-color: #eff6ff;
    color: var(--brand-primary);
}

.attachment-download-name {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    word-break: break-word;
}

.attachment-download-size {
    font-size: 0.82rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.lesson-nav-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-subtle);
}

.lesson-nav-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Phase 4: Quiz Builder & Student Quiz Runner */
.quiz-sidebar-list {
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    overflow: hidden;
}

.quiz-list-item-title {
    font-weight: 600;
    font-size: 0.92rem;
}

.quiz-list-item-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.question-builder-card {
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    background-color: #fafbfc;
}

.question-builder-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.question-builder-title {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    font-weight: 600;
    font-size: 0.98rem;
    line-height: 1.4;
}

.question-num-badge {
    display: inline-block;
    background-color: #eff6ff;
    color: var(--brand-dark);
    font-weight: 700;
    font-size: 0.78rem;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.option-builder-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.option-builder-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 0.35rem 0.55rem;
}

.option-row-correct {
    border-color: #86efac;
    background-color: #f0fdf4;
}

.option-builder-text {
    flex: 1;
    font-size: 0.92rem;
}

.add-option-row {
    margin-top: 0.5rem;
}

.quiz-status-icon {
    color: var(--brand-primary);
    flex-shrink: 0;
}

.quiz-question-card {
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1rem 1.15rem;
    margin-bottom: 1rem;
    background-color: #fafbfc;
}

.quiz-question-prompt {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    line-height: 1.45;
}

.quiz-radio-group td {
    padding: 0.3rem 0;
}

.quiz-submit-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

.quiz-result-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.15rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
}

.quiz-result-pass {
    background-color: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}

.quiz-result-fail {
    background-color: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.quiz-result-headline {
    font-weight: 700;
    font-size: 1.08rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.25rem;
}

.quiz-result-score {
    font-size: 0.92rem;
}

.quiz-feedback-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.quiz-feedback-item {
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 0.75rem 0.95rem;
    background-color: var(--bg-surface);
}

.feedback-correct {
    border-left: 4px solid #16a34a;
}

.feedback-incorrect {
    border-left: 4px solid #dc2626;
}

.feedback-question-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.feedback-wrong-icon {
    color: #dc2626;
    flex-shrink: 0;
}

.feedback-detail {
    font-size: 0.88rem;
    color: var(--text-muted);
    padding-left: 1.5rem;
}

/* Phase 5: Certificates & Verification */
.footer-sep {
    margin: 0 0.5rem;
}

.footer-link {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 500;
}

.footer-link:hover {
    text-decoration: underline;
}

.cert-download-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.42rem 0.75rem;
    border-radius: 6px;
    background-color: #16a34a;
    color: #ffffff;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}

.cert-download-pill:hover {
    background-color: #15803d;
}

.certificate-earned-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #f0fdf4 0%, #eff6ff 100%);
    border: 1px solid #86efac;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.certificate-earned-text {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.certificate-trophy-icon {
    font-size: 1.9rem;
    color: #ca8a04;
}

.certificate-earned-title {
    font-weight: 700;
    font-size: 1.08rem;
    color: #166534;
    margin-bottom: 0.2rem;
}

.certificate-earned-sub {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.cert-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1rem;
    border-radius: 6px;
    background-color: #16a34a;
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
}

.cert-download-btn:hover {
    background-color: #15803d;
}

.cert-verify-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.85rem;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-surface);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.cert-verify-link:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.verify-container {
    max-width: 680px;
    margin: 1rem auto 2rem;
}

.verify-valid-card {
    border: 1px solid #86efac;
}

.verify-status-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 1.15rem;
}

.verify-status-valid {
    color: #166534;
}

.verify-status-invalid {
    color: #991b1b;
}

.verify-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

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

.verify-detail-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.verify-detail-value {
    font-size: 1.02rem;
    color: var(--text-primary);
}

/* Mobile & Responsive Course Player Polish */
#lessonPlayerPanel {
    scroll-margin-top: 5rem;
}

/* The header (brand, up to five links, greeting, Sign Out) needs about 930px on one line: below
   1024px, the links move to their own row and the greeting goes, or the whole page would scroll
   sideways on landscape phones and small tablets. */
@media (max-width: 1024px) {
    .app-header-inner {
        flex-wrap: wrap;
        padding: 0.6rem 1rem;
        gap: 0.6rem 1rem;
    }

    .app-nav {
        order: 3;
        flex-basis: 100%;
        gap: 0.35rem;
        overflow-x: auto;
        padding-bottom: 0.15rem;
    }

    .nav-link {
        white-space: nowrap;
        font-size: 0.9rem;
        padding: 0.3rem 0.55rem;
    }

    .user-greeting {
        display: none;
    }

    /* Tables with reflow="true" show each row as a card (label: value) up to 1024px, not just up
       to PrimeFaces' fixed 640px: between 640 and 1024px the full table does not fit, and
       squeezing it wraps every column into a narrow strip. These are PrimeFaces 16's own reflow
       rules (components.css, @media max-width 640px) with a wider breakpoint; "body" in front
       because components.css loads after this file and hides the labels above 640px. */
    body .ui-datatable-reflow thead th,
    body .ui-datatable-reflow tfoot td {
        display: none;
    }

    body .ui-datatable-reflow .ui-datatable-data td[role=gridcell]:not(.ui-helper-hidden) {
        box-sizing: border-box;
        clear: left;
        float: left;
        border: 0 none;
        display: block;
        text-align: left !important;
        width: 100% !important;
    }

    body .ui-datatable-reflow .ui-datatable-data.ui-widget-content {
        border: 0 none;
    }

    body .ui-datatable-reflow .ui-datatable-data tr.ui-widget-content {
        border-left: 0 none;
        border-right: 0 none;
    }

    body .ui-datatable-reflow .ui-datatable-data td[role=gridcell] .ui-column-title {
        display: inline-block;
        font-weight: 700;
        margin: -0.4em 1em -0.4em -0.4em;
        min-width: 30%;
        max-width: 35%;
        padding: 0.4em;
    }

    body .ui-datatable-reflow .ui-reflow-label,
    body .ui-datatable-reflow .ui-reflow-dropdown {
        display: inline-block;
    }

    body .ui-datatable-reflow .ui-reflow-dropdown {
        margin-left: 5px;
        border-top-left-radius: 3px;
        border-bottom-left-radius: 3px;
    }

    body .ui-datatable-reflow tr.ui-datatable-empty-message > td {
        display: block;
        border: 0 none;
    }
}

@media (max-width: 768px) {
    .app-main {
        padding: 1rem;
    }

    #lessonPlayerPanel {
        scroll-margin-top: 7rem;
    }

    .lesson-viewer-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .lesson-nav-footer {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .lesson-markdown-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Admin Users & Learner Progress */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    align-items: center;
}

.filter-field {
    min-width: 220px;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.learner-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.detail-section-title {
    font-size: 1.02rem;
    margin: 1.25rem 0 0.65rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.user-account-link {
    font-size: 0.92rem;
}
