/* educAItion Web Interface Styles */

:root {
    --primary-color: #206dc5;
    --success-color: #52c41a;
    --danger-color: #f5222d;
    --warning-color: #faad14;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Navigation */
.navbar {
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color 0.3s;
}

.nav-menu a:hover,
.nav-menu a.active {
    color: var(--primary-color);
}

.logout-link {
    color: var(--danger-color) !important;
}

/* ED-507 — logout is a POST form; its button looks like the link it replaced */
.logout-form {
    display: inline;
    margin: 0;
}

.logout-form button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #4360e5 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 450px;
    padding: 2rem;
}

.login-box {
    background: white;
    padding: 3rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-box h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.login-form {
    margin: 2rem 0;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.help-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.password-field-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field-wrapper input {
    padding-right: 2.75rem;
    flex: 1;
}

.toggle-password-btn {
    position: absolute;
    right: 0.6rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1;
    opacity: 0.7;
}

.toggle-password-btn:hover {
    opacity: 1;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: #185091;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #3ea01a;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #d4161f;
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

/* ED-467 — a disabled button looks disabled; every .btn hover rule skips it (:hover:not(:disabled)).
   Also a btn-* variant used without the base class (class="btn-primary"). */
.btn:disabled,
[class^="btn-"]:disabled,
[class*=" btn-"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Dashboard */
.welcome-section {
    margin-bottom: 2rem;
}

.welcome-section h2 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.dashboard-section {
    margin-bottom: 3rem;
}

.dashboard-section h3 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Lessons Grid */
.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.lesson-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.lesson-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.lesson-card h4 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.lesson-card-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.lesson-card-title-row h4 {
    margin-bottom: 0;
}

.lesson-subject {
    color: var(--primary-color);
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.lesson-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.lesson-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-assigned {
    background: #e6f7ff;
    color: #206dc5; /* ED-461: was #1890ff, 2.95:1 on its tint */
}

.badge-in_progress {
    background: #fff7e6;
    color: #faad14;
}

.badge-completed {
    background: #f6ffed;
    color: #52c41a;
}

.badge-pending {
    background: #f5f5f5;
    color: #8c8c8c;
}

.badge-paused {
    background: #fff1f0;
    color: #f5222d;
}

/* ED-39: Lesson card actions */
.lesson-card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}

/* ED-61: Lesson card visibility and ordering controls */
.dashboard-available-card {
    position: relative;
}

.dashboard-available-card[draggable="true"] .lesson-card-title-row {
    cursor: grab;
}

.dashboard-available-card.is-dragging {
    opacity: 0.55;
}

.dashboard-available-card.drop-before {
    box-shadow: inset 0 4px 0 var(--primary-color);
}

.dashboard-available-card.drop-after {
    box-shadow: inset 0 -4px 0 var(--primary-color);
}

.dashboard-available-card.drop-left {
    box-shadow: inset 4px 0 0 var(--primary-color);
}

.dashboard-available-card.drop-right {
    box-shadow: inset -4px 0 0 var(--primary-color);
}

.lesson-visibility-btn {
    position: relative;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: #f7f9fc;
    color: #4b5f7c;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.lesson-visibility-btn:hover {
    background: #e8edf7;
    border-color: #c3d1e6;
}

.lesson-visibility-btn::before {
    content: '\1F441';
    font-size: 0.95rem;
    line-height: 1;
}

.lesson-visibility-btn.is-hidden::after {
    content: '';
    position: absolute;
    top: 0.35rem;
    left: 0.9rem;
    width: 2px;
    height: 1.2rem;
    background: currentColor;
    transform: rotate(-35deg);
}

.lesson-card.lesson-card-hidden {
    background: #e6e8eb;
    border: 1px solid #c8cdd4;
    color: #646b73;
    filter: grayscale(1);
}

.lesson-card.lesson-card-hidden:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.lesson-card.lesson-card-hidden .btn {
    opacity: 0.8;
}

/* ED-58: Subject Groups */
.subject-group {
    margin-bottom: 1.5rem;
}

.subject-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: background 0.2s;
}

.subject-header:hover {
    background: #f0f4ff;
}

.subject-chevron {
    font-size: 0.7rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.subject-header.collapsed .subject-chevron {
    transform: rotate(-90deg);
}

.subject-name {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.subject-count {
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    min-width: 1.5rem;
    text-align: center;
}

.subject-lessons {
    padding: 1rem 0 0 0;
    transition: max-height 0.3s ease;
}

.subject-lessons.hidden {
    display: none;
}

/* ED-117: Active lessons use the same visual language as other lesson cards */
.lesson-card.active-lesson {
    border: 1px solid var(--border-color);
}

.active-lesson-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.active-lesson-actions .btn {
    width: 100%;
    height: 48px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ED-58: Completed lesson card */
.lesson-card.completed-lesson {
    opacity: 0.85;
}

.lesson-card.completed-lesson:hover {
    opacity: 1;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Lesson Chat */
.lesson-container {
    max-width: 1400px;
    margin: 0 auto;
}

.lesson-header {
    background: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ED-63 Phase 0: Lesson timer */
.lesson-timer-container {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    font-family: 'Courier New', monospace;
}

.lesson-timer {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-color);
}

.lesson-timer-plan {
    font-size: 0.9rem;
    color: #999;
}

.lesson-timer.timer-warning {
    color: #e67e22;
}

.lesson-timer.timer-overtime {
    color: #e74c3c;
}

/* ED-63 Phase 0: Message timestamps */
.msg-time {
    font-size: 0.75rem;
    color: #999;
    font-weight: 400;
}

/* ED-92: Report message button & modal */
.message-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.report-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: #bbb;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.15s;
}

.report-btn:hover {
    color: #e53e3e;
}

.report-btn.reported {
    color: #e53e3e;
    cursor: default;
}

/* ED-115: TTS button */
.tts-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: #bbb;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.15s;
}

.tts-btn:hover {
    color: #206dc5;
}

.tts-btn.speaking {
    color: #206dc5;
    opacity: 1;
}

.report-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.report-modal[hidden] {
    display: none;
}

.report-modal-box {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    width: min(480px, 90vw);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.report-modal-box h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.report-modal-preview {
    font-size: 0.85rem;
    color: #555;
    background: #f7f7f7;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.report-comment {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
}

.report-comment:focus {
    outline: none;
    border-color: var(--primary-color, #0f766e);
}

.report-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ED-59: Expanded chat area — use more screen width */
.lesson-content {
    padding: 1rem;
    max-width: 900px;
    margin: 0 auto;
}

@media (min-width: 1200px) {
    .lesson-content {
        max-width: 1000px;
    }
}

@media (max-width: 768px) {
    .active-lesson-actions {
        grid-template-columns: 1fr;
    }

    .lesson-content {
        padding: 0.5rem;
    }
    .lesson-header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
}

.lesson-script {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    height: fit-content;
}

.lesson-script h3 {
    margin-bottom: 1rem;
}

.script-content {
    max-height: 600px;
    overflow-y: auto;
}

.script-content pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    color: var(--text-secondary);
}

/* Chat */
/* ED-59: Chat container takes most of viewport */
.chat-container {
    background: white;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 400px;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.message-role {
    font-size: 0.85rem;
    font-weight: 600;
}

.message.user .message-role {
    color: var(--primary-color);
}

.message.assistant .message-role {
    color: var(--success-color);
}

.message-content {
    padding: 1rem;
    border-radius: 12px;
    line-height: 1.5;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.message.user .message-content {
    background: var(--primary-color);
    color: white;
    white-space: pre-wrap;
}

.message.assistant .message-content {
    background: #f0f0f0;
    color: var(--text-primary);
}

/* Markdown content styling for bot messages */
.message.assistant .message-content p {
    margin-bottom: 0.75rem;
}

.message.assistant .message-content p:last-child {
    margin-bottom: 0;
}

.message.assistant .message-content ul,
.message.assistant .message-content ol {
    margin: 0.5rem 0 0.75rem 1.5rem;
    padding: 0;
}

.message.assistant .message-content li {
    margin-bottom: 0.25rem;
}

.message.assistant .message-content strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message.assistant .message-content em {
    font-style: italic;
}

.message.assistant .message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

.message.assistant .message-content pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.message.assistant .message-content pre code {
    background: none;
    padding: 0;
}

.message.assistant .message-content blockquote {
    border-left: 3px solid var(--primary-color);
    padding-left: 1rem;
    margin: 0.5rem 0;
    color: var(--text-secondary);
}

/* ED-53: Images in lesson messages */
.message.assistant .message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 0.75rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message.loading .message-content {
    opacity: 0.6;
    font-style: italic;
}

/* ED-15: System notice for lesson completion */
.message.system-notice {
    padding: 0;
}

.message.system-notice .message-content {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 2px solid #4caf50;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.message.system-notice h4 {
    color: #2e7d32;
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
}

.message.system-notice p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* ED-520 — AI quota in a learner's chat (public/js/ai-quota.js; board docs/product/design/ai-usage/04) */
.ai-quota-warn {
    background: #fff4e0;
    border: 1px solid #ffd8a8;
    color: #7a4100;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 14px;
    margin-bottom: 12px;
}

.message.system-notice.ai-quota-stop .message-content {
    background: #fff5f5;
    border: 1px solid #ffc9c9;
    border-radius: 10px;
    padding: 16px 18px;
    text-align: left;
}

.message.system-notice.ai-quota-stop h4 {
    color: #a61e1e;
    font-size: 16px;
    margin-bottom: 6px;
}

.message.system-notice.ai-quota-stop p {
    margin-bottom: 0;
    font-size: 14px;
}

.message.system-notice .btn {
    display: inline-block;
    margin-top: 0.5rem;
}

/* Disabled form state */
.chat-input-form textarea:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.chat-input-form button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.chat-input-form {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    background: white;
    flex-shrink: 0; /* Don't shrink input area */
}

.chat-input-form textarea {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    min-height: 44px;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.5;
}

.chat-input-form textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.chat-input-form .btn {
    width: auto;
    min-width: 100px;
    white-space: nowrap;
    height: 44px;
    flex-shrink: 0;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-info {
    background: #e6f7ff;
    border: 1px solid #91d5ff;
    color: #096dd9;
}

.error-message {
    background: #fff2f0;
    border: 1px solid #ffccc7;
    color: #cf1322;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    background: white;
    margin-top: 3rem;
}

/* Error Page */
.error-container {
    text-align: center;
    padding: 4rem 2rem;
}

.error-container h1 {
    font-size: 6rem;
    color: var(--danger-color);
}

.error-container h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.error-details {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: 8px;
    margin: 2rem auto;
    max-width: 600px;
    text-align: left;
}

.error-details pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.dev-info {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Debug Panel Styles */
.debug-panel {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    border: 1px solid #ffc107;
    border-radius: 8px;
    margin: 1rem 2rem;
    padding: 0;
}

.debug-panel > details > summary {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-weight: 600;
    color: #856404;
    list-style: none;
}

.debug-panel > details > summary::-webkit-details-marker {
    display: none;
}

.debug-panel > details > summary::before {
    content: "▶ ";
}

.debug-panel > details[open] > summary::before {
    content: "▼ ";
}

.debug-content {
    padding: 0 1rem 1rem;
}

.debug-content details {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.debug-content details summary {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-weight: 500;
    background: #f8f9fa;
    border-radius: 4px 4px 0 0;
}

.debug-content details[open] summary {
    border-bottom: 1px solid var(--border-color);
}

.debug-text {
    padding: 0.75rem;
    margin: 0;
    background: #fafafa;
    font-size: 0.8rem;
    line-height: 1.4;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 300px;
    overflow-y: auto;
}

/* ED-60: Lesson History */
.history-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.history-chat {
    height: auto;
    max-height: calc(100vh - 200px);
}

.history-section-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.history-section-divider::before,
.history-section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.history-section-divider span {
    white-space: nowrap;
}

/* ==========================================
   Language selector (ED-153)
   ========================================== */
.lang-selector {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.lang-btn {
    background: none;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary, #666);
    transition: all 0.15s ease;
}

.lang-btn:hover {
    background: var(--bg-secondary, #f5f5f5);
    color: var(--text-primary, #333);
}

.lang-btn-active {
    background: var(--primary-color, #206dc5);
    border-color: var(--primary-color, #206dc5);
    color: #fff;
}

/* ED-159: Overtime banner */
.overtime-banner {
    background: #fff8e1;
    border-left: 4px solid #f59e0b;
    padding: 0.75rem 1.5rem;
}

.overtime-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.overtime-banner-content > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.overtime-banner-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
    height: auto;
}

/* ED-157: Mobile responsiveness */
@media (max-width: 480px) {
    .navbar {
        padding: 0.6rem 1rem;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .nav-brand h1 {
        font-size: 1.1rem;
    }

    .nav-menu {
        gap: 0.75rem;
        flex-wrap: wrap;
        justify-content: flex-end;
        width: 100%;
    }

    .container {
        padding: 0 1rem;
        margin: 1rem auto;
    }

    /* Lesson chat: adjust height for taller stacked mobile header */
    .chat-container {
        height: calc(100vh - 310px);
        min-height: 300px;
    }

    .lesson-header {
        gap: 0.4rem;
    }

    .lesson-timer {
        font-size: 1.1rem;
    }

    .chat-messages {
        padding: 0.75rem;
    }

    .chat-input-form {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .chat-input-form .btn {
        min-width: 70px;
    }
}

/* ===== Toast notifications (ED-205) ===== */
#toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
    width: max-content;
    max-width: calc(100vw - 2rem);
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    pointer-events: all;
    max-width: 480px;
    animation: toast-in 0.25s ease;
}

.toast.removing {
    animation: toast-out 0.25s ease forwards;
}

.toast-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.toast-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.toast-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #86efac;
}

.toast-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.toast-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fcd34d;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-12px); }
}

/* =============================================
   ED-251: Learning Home — student dashboard
   ============================================= */

/* Top bar */
.lh-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-left: 200px;
}

.lh-topbar__name {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary, #1a2035);
    margin: 0 0 0.2rem;
}

.lh-topbar__subline {
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
    margin: 0;
}

.lh-progress-widget {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #f8f9fd;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    padding: 0.5rem 1.1rem;
    min-width: 80px;
}

.lh-progress-widget__count {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary, #1a2035);
    line-height: 1;
}

.lh-progress-widget__label {
    font-size: 0.65rem;
    color: var(--text-secondary, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* Two-column layout */
.lh-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.lh-main-feed {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.lh-right-panel {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
}

/* Shared section header */
.lh-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.lh-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
    margin: 0;
}

/* Primary Continue Card */
.lh-continue {
    margin-bottom: 2rem;
}
.lh-continue__card {
    background: linear-gradient(135deg, var(--primary-color, #365df7) 0%, #6a3de8 100%);
    color: #fff;
    border-radius: 16px;
    padding: 1.5rem 1.75rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.25rem;
    box-shadow: 0 4px 20px rgba(54, 93, 247, 0.3);
}

.lh-continue__content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lh-continue__illustration {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
}

.lh-continue__illustration img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.lh-continue__label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.75;
}
.lh-continue__title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}
.lh-continue__meta {
    font-size: 0.85rem;
    opacity: 0.8;
}
.lh-continue__actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}
.lh-continue__actions .btn-outline {
    border-color: rgba(255,255,255,0.5);
    color: #fff;
}
.lh-continue__actions .btn-outline:hover:not(:disabled) {
    border-color: #fff;
    background: rgba(255,255,255,0.15);
    color: #fff;
}
.lh-continue__secondary {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.lh-continue__secondary-item {
    background: var(--bg-color, #f3f4f6);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.lh-continue__secondary-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary, #1a1a2e);
}

/* Up Next strip */
.lh-up-next {
    margin-bottom: 2rem;
}
.lh-up-next__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}
.lh-up-next__card {
    background: var(--bg-color, #f9fafb);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.lh-up-next__subject {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--subject-color, #8892a4);
}
.lh-up-next__title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary, #1a1a2e);
    margin: 0;
    overflow: hidden;
    line-clamp: 2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.lh-up-next__duration {
    font-size: 0.78rem;
    color: var(--text-secondary, #6b7280);
    margin-top: auto;
}

.lh-up-next__card-form {
    margin-top: 0.5rem;
}

/* Profile Insight Card */
.lh-profile-insight {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    padding: 1rem 1rem 0.75rem;
}

.lh-profile-insight__title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-primary, #1a2035);
    margin: 0 0 0.75rem;
}

.lh-profile-insight__items {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.lh-insight-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.lh-insight-item__icon {
    width: 16px;
    height: 16px;
    opacity: 0.6;
    flex-shrink: 0;
}

.lh-insight-item__text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.lh-insight-item__label {
    font-size: 0.7rem;
    color: var(--text-secondary, #6b7280);
    line-height: 1;
}

.lh-insight-item__value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary, #1a2035);
    line-height: 1.2;
}

.lh-profile-insight__edit-link {
    display: block;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color, #365df7);
    text-decoration: none;
    text-align: center;
}

/* Completed strip */
.lh-completed {
    margin-bottom: 2rem;
}
.lh-completed__strip {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.lh-completed__item {
    background: var(--bg-color, #f9fafb);
    border-radius: 8px;
    padding: 0.65rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
}
.lh-completed__check {
    color: #27ae60;
    font-size: 0.875rem;
    flex-shrink: 0;
    margin-right: 0.25rem;
}
.lh-completed__title {
    font-weight: 500;
    color: var(--text-primary, #1a1a2e);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lh-completed__subject {
    font-size: 0.78rem;
    color: var(--text-secondary, #6b7280);
    flex-shrink: 0;
}
.lh-completed__more {
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
    text-align: center;
    padding: 0.25rem 0;
    margin: 0;
}

/* Responsive */
@media (max-width: 640px) {
    .lh-continue__card { padding: 1.25rem; }
    .lh-continue__actions { flex-direction: column; }
}

@media (max-width: 768px) {
    body.has-sidebar .container,
    body.has-sidebar footer,
    .lh-topbar {
        margin-left: 0;
    }
    .lh-layout {
        flex-direction: column;
    }
    .lh-right-panel {
        width: 100%;
        position: static;
    }
    .lh-continue__card {
        flex-direction: column;
    }
    .lh-continue__illustration {
        display: none;
    }
    .lh-up-next__grid {
        grid-template-columns: 1fr;
    }
}

/* =============================================
   STUDENT SIDEBAR (ED-251 v2)
   ============================================= */

.student-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 200px;
    height: 100vh;
    background: #1a2035;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
}

.student-sidebar__brand {
    padding: 20px 16px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.student-sidebar__brand-name {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    letter-spacing: -0.3px;
    display: block;
}

.student-sidebar__brand-sub {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.35);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 3px 0 0;
}

.student-sidebar__nav {
    padding: 12px 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.student-sidebar__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    border-left: 3px solid transparent;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.student-sidebar__item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.85);
}

.student-sidebar__item.is-active {
    background: rgba(54, 93, 247, 0.18);
    border-left-color: #365df7;
    color: #ffffff;
    font-weight: 600;
}

.student-sidebar__footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.student-sidebar__avatar {
    width: 30px;
    height: 30px;
    background: #365df7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.student-sidebar__user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.student-sidebar__username {
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.student-sidebar__logout {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.35);
    text-decoration: none;
}

.student-sidebar__logout:hover {
    color: rgba(255, 255, 255, 0.65);
}

/* Push main content when sidebar is present (.lesson-container: lesson-history) */
body.has-sidebar .container,
body.has-sidebar .lesson-container {
    margin-left: 200px;
    max-width: none;
}

body.has-sidebar footer {
    margin-left: 200px;
}

@media (max-width: 768px) {
    body.has-sidebar .container,
    body.has-sidebar .lesson-container,
    body.has-sidebar footer {
        margin-left: 0;
    }
}

/* =============================================
   MOBILE NAV (ED-255)
   ============================================= */

.sb-hamburger {
    display: none;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: #1a2035;
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sb-page-header {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 0 16px;
}

.sb-page-header__title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary, #1a2035);
}

.sb-desktop-only {
    display: block;
}

.sb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 150;
}

.sb-overlay.is-open {
    display: block;
}

@media (max-width: 768px) {
    .sb-hamburger {
        display: flex;
    }

    .sb-page-header {
        display: flex;
    }

    .sb-desktop-only {
        display: none;
    }

    .lh-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 16px;
    }

    .lh-topbar__greeting {
        flex: 1;
        min-width: 0;
    }

    .student-sidebar {
        transform: translateX(-200px);
        transition: transform 0.25s ease;
        pointer-events: none;
    }

    .student-sidebar.is-open {
        transform: translateX(0);
        pointer-events: auto;
        z-index: 300;
    }
}

/* ===== Learning Passport — Student Profile (ED-254) ===== */

/* Hero block */
.lp-hero {
    background: white;
    border-radius: 12px;
    padding: 1.5rem 2rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.lp-hero__avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary-color, #365df7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    font-weight: 700;
    flex-shrink: 0;
}

.lp-hero__info {
    flex: 1;
}

.lp-hero__name {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    color: var(--text-primary, #1a2035);
}

.lp-hero__meta {
    color: var(--text-secondary, #718096);
    font-size: 0.875rem;
    margin: 0 0 0.4rem;
}

.lp-hero__summary {
    color: var(--text-secondary, #4a5568);
    font-size: 0.9375rem;
    margin: 0;
    line-height: 1.5;
}

.lp-hero__actions {
    flex-shrink: 0;
}

/* Body: main feed + recommendations panel */
.lp-body {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.lp-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.lp-recs {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Section card wrapper */
.lp-section {
    background: white;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.lp-section__title {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary, #a0aec0);
    margin: 0 0 0.875rem;
    font-weight: 600;
}

/* Learning settings row */
.lp-settings {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

.lp-settings__group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.lp-settings__label {
    font-size: 0.8125rem;
    color: var(--text-secondary, #718096);
    font-weight: 500;
}

.lp-settings__controls {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* Profile cards grid */
.lp-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.75rem;
}

.lp-card {
    background: var(--bg-color, #f7f8ff);
    border-radius: 10px;
    padding: 0.875rem 1rem;
}

.lp-card__label {
    font-size: 0.6875rem;
    color: #7c8db5;
    font-weight: 600;
    margin: 0 0 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.lp-card__value {
    font-size: 0.875rem;
    color: var(--text-primary, #2d3748);
    margin: 0;
    line-height: 1.45;
}

/* AI Recommendations right panel */
.lp-rec-header {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary, #a0aec0);
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.lp-rec-card {
    background: white;
    border-radius: 12px;
    padding: 1rem 1.125rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    border-left: 3px solid var(--primary-color, #365df7);
}

.lp-rec-card__text {
    font-size: 0.875rem;
    color: var(--text-primary, #2d3748);
    margin: 0;
    line-height: 1.5;
}

/* Collapsible full narrative */
.lp-narrative {
    background: white;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.lp-narrative__toggle {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--primary-color, #365df7);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.lp-narrative__toggle:hover {
    color: #3a5cd7;
}

.lp-narrative__body {
    display: none;
    margin-top: 0.875rem;
    color: var(--text-secondary, #4a5568);
    line-height: 1.7;
    font-size: 0.9375rem;
    white-space: pre-line;
}

.lp-narrative__body.is-open {
    display: block;
}

/* Responsive */
@media (max-width: 900px) {
    .lp-body {
        flex-direction: column;
    }

    .lp-recs {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .lp-hero {
        flex-direction: column;
        padding: 1.25rem;
    }

    .lp-settings {
        flex-direction: column;
        gap: 1rem;
    }

    .lp-cards {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============================================================
   ED-278 SP1 — Assessments UI
   Base styles first; mobile overrides at end (CSS source order)
   ============================================================ */

/* ---- Shared assessment error banner ---- */
.assessment-error {
    padding: 10px 14px;
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    color: #dc2626;
    font-size: 13px;
}

/* ---- Tests/assessments grid (shared with tests.ejs) ---- */
.tests-grid,
.assessment-cards-grid {
    display: grid;
    gap: 16px;
    padding: 4px 0;
}

.tests-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.assessment-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
}

/* ---- Structured exam form grid (ED-295, assessments teacher dashboard) ---- */
.exam-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

/* ---- Generic test card (used by tests.ejs + assessments) ---- */
.test-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.test-card h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #111827;
}

.test-card .test-description {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
}

.test-card .test-meta {
    font-size: 12px;
    color: #9ca3af;
}

/* ED-337: push the Start test action to the card's bottom edge so buttons
   align across a grid row regardless of title/description/metadata length. */
.tests-grid .test-card > .btn {
    margin-top: auto;
}

/* ---- Assessment card ---- */
.assessment-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.assessment-card__body {
    padding: 18px 20px 12px;
    flex: 1;
}

.assessment-card__title {
    margin: 0 0 12px;
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.assessment-card__preview {
    margin: 0 0 10px;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.assessment-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.assessment-card__tag {
    display: inline-block;
    background: #f0fdfa;
    color: #0f766e;
    border: 1px solid #ccfbf1;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.assessment-card__tag-label {
    color: #0f766e;
}

.assessment-card__date {
    font-size: 11px;
    color: #9ca3af;
    margin-left: auto;
}

.assessment-card__actions {
    padding: 0;
    display: flex;
    flex-direction: column;
    border-top: 1px solid #f3f4f6;
}

/* ED-464: title + "⋮" actions menu. The card clips overflow, so the menu is
   position: fixed; assessments-learning-teacher.js places it from the button. */
.assessment-card__head {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.assessment-card__head .assessment-card__title {
    flex: 1;
    min-width: 0;
}

.card-menu-btn {
    flex: none;
    width: 32px;
    height: 32px;
    margin: -4px -8px 0 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #4b5563;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.card-menu-btn:hover,
.card-menu-btn[aria-expanded="true"] {
    background: #f3f4f6;
    color: #111827;
}

.card-menu-btn:focus-visible,
.card-menu__item:focus-visible {
    outline: 3px solid rgba(32, 109, 197, 0.45);
    outline-offset: -3px;
}

.card-menu {
    position: fixed;
    z-index: 1000;
    min-width: 220px;
    max-width: calc(100vw - 16px);
    overflow-y: auto;
    padding: 4px 0;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
}

.card-menu[hidden] {
    display: none;
}

.card-menu__item {
    appearance: none;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    border: 0;
    background: transparent;
    color: #111827;
    font: inherit;
    font-size: 14px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.card-menu__item:hover:not(:disabled),
.card-menu__item:focus {
    background: #f3f4f6;
}

.card-menu__item:disabled {
    color: #9ca3af;
    cursor: default;
}

.card-menu__check {
    flex: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid #9ca3af;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    line-height: 1;
    color: #ffffff;
}

.card-menu__item[aria-checked="true"] .card-menu__check {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.card-menu__item[aria-checked="true"] .card-menu__check::after {
    content: "\2713";
}

.card-menu__sep {
    height: 1px;
    margin: 4px 0;
    background: #e5e7eb;
}

/* #dc2626, not --danger-color: red text on white needs 4.5:1 contrast. */
.card-menu__item--danger {
    color: #dc2626;
}

.card-menu__item--danger:hover:not(:disabled),
.card-menu__item--danger:focus {
    background: #fef2f2;
}

.assessment-card__summary {
    display: grid;
    gap: 6px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
}

.assessment-card__summary p {
    margin: 0;
    color: #4b5563;
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.assessment-card__summary-label {
    color: #374151;
    font-weight: 700;
}

.assessment-card__action {
    appearance: none;
    width: 100%;
    min-width: 0;
    border: 0;
    border-bottom: 1px solid #f3f4f6;
    border-radius: 0;
    background: #ffffff;
    color: #111827;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 18px;
    text-align: left;
    text-decoration: none;
    font: inherit;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.assessment-card__action:last-child {
    border-bottom: 0;
}

.assessment-card__action:hover:not(:disabled) {
    background: #f8fafc;
}

.assessment-card__action:focus-visible {
    position: relative;
    z-index: 1;
    outline: 3px solid rgba(15, 118, 110, 0.35);
    outline-offset: -3px;
}

.assessment-card__action:disabled {
    background: #f9fafb;
    color: #6b7280;
    cursor: not-allowed;
    opacity: 1;
}

.assessment-card__action-copy {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.assessment-card__action-label {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.assessment-card__action-status {
    color: #6b7280;
    font-size: 11px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.assessment-card__action-chevron {
    color: #9ca3af;
    flex-shrink: 0;
    font-size: 20px;
    line-height: 1;
}

.assessment-card__action--danger .assessment-card__action-label,
.assessment-card__action--danger .assessment-card__action-chevron {
    color: #b91c1c;
}

/* ---- Assessment exam row (student list) ---- */
.assessment-exam-row {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.assessment-exam-row__info {
    flex: 1;
}

.assessment-exam-row__title {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.assessment-exam-row__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.assessment-exam-row__actions {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
}

/* ED-491 — .btn-primary is width:100% globally; inside the row it must stay compact. */
.assessment-exam-row__actions .btn {
    width: auto;
}

/* ED-491 — past reports of an assigned plan, on their own line at the bottom of the card. */
.assessment-exam-row__history {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    padding-top: 10px;
    border-top: 1px solid #f3f4f6;
    font-size: 13px;
}

.assessment-exam-row__history-label {
    color: #6b7280;
}

.assessment-exam-row__history-link {
    color: var(--primary-color);
    text-decoration: none;
}

.assessment-exam-row__history-link:hover {
    text-decoration: underline;
}

.assessment-exam-row__history-more {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    color: #6b7280;
    cursor: pointer;
}

.assessment-exam-row__history-more:hover {
    color: #111827;
}

/* ---- Status badges (reused from teacher dashboard) ---- */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.status-draft       { background: #e0f2fe; color: #0c4a6e; }
.status-active      { background: #d1fae5; color: #065f46; }
.status-completed   { background: #ede9fe; color: #4c1d95; }
.status-paused      { background: #fef3c7; color: #92400e; }
.status-in_progress { background: #d1fae5; color: #065f46; }
.status-assigned    { background: #f3f4f6; color: #374151; }

/* NOTE: .empty-state is intentionally NOT redefined here — the global definition
   (earlier in this file) is reused by the assessments views, /tests, and others.
   Redefining it later would silently override that shared rule everywhere. */

/* ---- Mobile overrides (after all base rules — CSS source order rule) ---- */
@media (max-width: 600px) {
    .assessment-cards-grid,
    .tests-grid {
        grid-template-columns: 1fr;
    }

    .assessment-exam-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .assessment-exam-row__actions,
    .assessment-exam-row__history,
    .assessment-exam-row__actions .btn {
        width: 100%;
    }

    .assessment-card__action {
        padding: 12px 16px;
    }

    .card-menu-btn {
        width: 40px;
        height: 40px;
    }

    .card-menu__item {
        padding: 12px 16px;
    }

    .exam-form-grid {
        grid-template-columns: 1fr;
    }
}

/* =============================================
   ED-299: Typing indicator (exam/lesson chat)
   ============================================= */

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 4px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ===== Help & Support (ED-334) ===== */

.help-support-page {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.help-support-intro {
    margin-bottom: 0.25rem;
}

.help-support-heading {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.4rem;
    color: var(--text-primary, #1a2035);
}

.help-support-lede {
    color: var(--text-secondary, #718096);
    font-size: 0.9375rem;
    line-height: 1.5;
    margin: 0;
    max-width: 60ch;
}

.help-support-faq,
.help-support-contact {
    background: white;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.help-support-faq__item {
    border-top: 1px solid var(--border-color, #e2e8f0);
    padding: 0.75rem 0;
}

.help-support-faq__item:first-of-type {
    border-top: none;
    padding-top: 0.5rem;
}

.help-support-faq__question {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary, #2d3748);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.help-support-faq__question::-webkit-details-marker {
    display: none;
}

.help-support-faq__question::before {
    content: '▸';
    color: var(--primary-color, #365df7);
    flex-shrink: 0;
}

.help-support-faq__item[open] > .help-support-faq__question::before {
    content: '▾';
}

.help-support-faq__question:focus-visible {
    outline: 2px solid var(--primary-color, #365df7);
    outline-offset: 2px;
}

.help-support-faq__answer {
    margin: 0.6rem 0 0;
    color: var(--text-secondary, #4a5568);
    font-size: 0.9rem;
    line-height: 1.6;
    max-width: 65ch;
}

.help-support-contact__intro {
    color: var(--text-secondary, #4a5568);
    font-size: 0.9375rem;
    margin: 0 0 1rem;
    max-width: 60ch;
}

.help-support-contact__cta {
    display: inline-block;
    width: auto;
    padding: 0.6rem 1.25rem;
}

.help-support-contact__unavailable {
    color: var(--text-secondary, #718096);
    font-size: 0.9375rem;
    margin: 0;
}

.help-support-checklist {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color, #e2e8f0);
}

.help-support-checklist__heading {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary, #718096);
    margin: 0 0 0.5rem;
}

.help-support-checklist__list {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--text-secondary, #4a5568);
    font-size: 0.875rem;
    line-height: 1.7;
}

@media (max-width: 600px) {
    .help-support-faq,
    .help-support-contact {
        padding: 1rem 1.125rem;
    }

    .help-support-contact__cta {
        display: block;
        width: 100%;
        text-align: center;
    }
}

/* ===== ED-472 Stage 4b — «Мой курс» (tasks/active/ED-472/my-course-mockup.md) ===== */
.mc-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1rem;
}
.mc-header__title { margin: 0; font-size: 1.35rem; }
.mc-header__title .sb-desktop-only { display: inline; }
.mc-header__learned { white-space: nowrap; font-weight: 600; }
.mc-message { margin-bottom: 1rem; }
.mc-message--ok {
    padding: 10px 14px;
    background: #dcfce7;
    border: 1px solid #86efac;
    border-radius: 8px;
    color: #166534;
    font-size: 13px;
}
.mc-order,
.mc-chapters,
.mc-diagnostic {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 1rem;
}
.mc-section {
    border: none;
    padding: 1rem 1.25rem;
    min-width: 0;
}
.mc-section + .mc-section { border-top: 1px solid var(--border-color); }
.mc-section__title { font-size: 1rem; font-weight: 600; margin: 0 0 0.5rem; padding: 0; }
.mc-mode { display: flex; gap: 0.5rem; align-items: baseline; margin: 0.25rem 0; cursor: pointer; }
.mc-muted { color: var(--text-secondary); font-size: 0.9rem; }
/* ED-477 — the «Проверка» block: a card like the order form, its button not stretched. */
.mc-diagnostic p { margin: 0 0 0.5rem; }
.mc-diagnostic .btn { width: auto; }
.mc-goals__head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.mc-goals__left-head { color: var(--text-secondary); font-size: 0.85rem; }
.mc-goals { list-style: none; padding: 0; margin: 0; counter-reset: mc-goal; }
.mc-goal {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 5.5rem;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0;
}
.mc-goal { counter-increment: mc-goal; }
.mc-goal__title { min-width: 0; overflow-wrap: anywhere; }
.mc-goal__title::before { content: counter(mc-goal) ". "; }
.mc-goal__actions { display: flex; gap: 0.25rem; }
.mc-goal__left { text-align: right; font-variant-numeric: tabular-nums; }
.mc-goal--done .mc-goal__title,
.mc-goal--done .mc-goal__left { color: var(--text-secondary); }
.mc-icon-btn {
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}
.mc-icon-btn:hover { background: var(--bg-color); }
.mc-add { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.mc-add__select {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    font: inherit;
}
.mc-save { display: flex; justify-content: flex-end; margin-top: 0.75rem; }
.mc-save .btn-primary { width: auto; }
.mc-chapter + .mc-chapter { border-top: 1px solid var(--border-color); }
.mc-chapter__head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}
.mc-chapter__head::-webkit-details-marker { display: none; }
.mc-chapter__head::before { content: "▸"; margin-right: -0.5rem; }
.mc-chapter[open] > .mc-chapter__head::before { content: "▾"; }
.mc-chapter__head > span:first-of-type { flex: 1 1 auto; }
.mc-chapter__count { white-space: nowrap; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.mc-nodes { list-style: none; margin: 0; padding: 0 1.25rem 0.75rem; }
.mc-node {
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    gap: 0.75rem;
    padding: 0.2rem 0;
    font-size: 0.9rem;
}
.mc-node__label { overflow-wrap: anywhere; }
.mc-node__title { overflow-wrap: anywhere; }

/* the sidebar's page header takes over the page name where .sb-desktop-only hides */
@media (max-width: 768px) {
    .mc-header__title .sb-desktop-only { display: none; }
}
@media (max-width: 640px) {
    .mc-header { flex-direction: column; gap: 0.25rem; }
    .mc-section { padding: 0.75rem 1rem; }
    .mc-goal {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "title actions" "left actions";
        row-gap: 0;
    }
    .mc-goal__title { grid-area: title; }
    .mc-goal__actions { grid-area: actions; }
    .mc-icon-btn { width: 2.5rem; height: 2.5rem; }
    .mc-goal__left { grid-area: left; text-align: left; color: var(--text-secondary); font-size: 0.85rem; }
    .mc-add { flex-direction: column; }
    .mc-chapter__head { padding: 0.75rem 1rem; }
    .mc-nodes { padding: 0 1rem 0.75rem; }
    .mc-node { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .mc-save .btn-primary { width: 100%; }
}

/* ===== ED-516 — course progress: the line on the course card in «Моё обучение» and the Progress page
   (approved mockup: tasks/completed/ED-501-600/ED-516/mockup.html). One colour per group, shared by both. ===== */
.cp-fill-know { background: #3f9d14; }
.cp-fill-due { background: #c98a00; }
.cp-fill-weak { background: #d9363e; }
.cp-fill-seen { background: #8a7fc8; }
.cp-fill-none { background: #d4d9e0; }
.cp-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: #d4d9e0;
    min-width: 0;
}
.cp-bar i { display: block; }
.cp-muted { color: var(--text-secondary); font-size: 0.82rem; }
.cp-due { color: #a87300; font-weight: 600; }

/* The course card in «Моё обучение»: one tappable line under the title. */
/* Full width in both layouts: a flex line on a wide screen, a column with align-items: flex-start on a
   phone (the row's own mobile rule), where only width keeps it from shrinking to its text. */
.assessment-exam-row__progress {
    flex-basis: 100%;
    width: 100%;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 12px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--bg-color);
    color: inherit;
    text-decoration: none;
}
.assessment-exam-row__progress:hover { background: #eef1f5; }
.assessment-exam-row__progress:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 1px; }
.assessment-exam-row__progress .cp-bar { grid-column: 1; }
.assessment-exam-row__progress-line {
    grid-column: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 2px 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.assessment-exam-row__progress-line b { color: var(--text-primary); font-weight: 600; }
.assessment-exam-row__progress-go {
    grid-column: 2;
    grid-row: 1 / 3;
    color: var(--primary-color);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

/* The Progress page. */
/* body.has-sidebar .container sets max-width: none (0,2,1); match it to cap the page. */
body.has-sidebar .cp-page { max-width: 760px; }
.cp-card {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    padding: 14px 16px;
    margin-bottom: 12px;
    min-width: 0;
}
.cp-head { margin-bottom: 12px; display: grid; gap: 2px; }
.cp-back { color: var(--primary-color); font-size: 0.85rem; text-decoration: none; justify-self: start; }
.cp-head__title { margin: 0; font-size: 1.3rem; text-wrap: balance; }
.cp-head__row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px 12px;
    margin-top: 6px;
}
.cp-head__row form { margin: 0; }
.cp-start.btn-primary { width: auto; }
.cp-summary { display: grid; gap: 10px; }
.cp-counts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cp-count {
    display: grid;
    gap: 1px;
    padding: 8px 4px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-primary);
    font: inherit;
    text-align: center;
    cursor: pointer;
}
.cp-count b { font-size: 1.35rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.cp-count span { font-size: 0.75rem; color: var(--text-secondary); line-height: 1.2; overflow-wrap: anywhere; hyphens: auto; }
.cp-count.cp-seg-know b { color: #3f9d14; }
.cp-count.cp-seg-due b { color: #a87300; }
.cp-count.cp-seg-weak b { color: #d9363e; }
.cp-count.cp-seg-none b { color: var(--text-secondary); }
.cp-count[aria-pressed="true"] { background: var(--card-bg); border-color: currentColor; }
.cp-count.cp-seg-know[aria-pressed="true"] { border-color: #3f9d14; }
.cp-count.cp-seg-due[aria-pressed="true"] { border-color: #c98a00; }
.cp-count.cp-seg-weak[aria-pressed="true"] { border-color: #d9363e; }
.cp-count.cp-seg-none[aria-pressed="true"] { border-color: #9aa3ae; }
.cp-count:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.cp-legend { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 0.75rem; color: var(--text-secondary); }
.cp-legend i { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 2px; margin-right: 4px; }
.cp-topics { display: grid; gap: 8px; }
.cp-topics__title { margin: 0; font-size: 1rem; }
.cp-search {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    font: inherit;
    font-size: 0.88rem;
}
.cp-list { list-style: none; margin: 0; padding: 0; }
.cp-topic {
    display: grid;
    grid-template-columns: 0.5rem minmax(0, 1fr) auto;
    gap: 2px 10px;
    align-items: baseline;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
    font-size: 0.88rem;
}
.cp-topic:first-child { border-top: 0; }
.cp-topic[hidden] { display: none; }
.cp-topic__dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; align-self: center; background: #d4d9e0; }
.cp-topic.cp-seg-know .cp-topic__dot { background: #3f9d14; }
.cp-topic.cp-seg-due .cp-topic__dot { background: #c98a00; }
.cp-topic.cp-seg-weak .cp-topic__dot { background: #d9363e; }
.cp-topic.cp-seg-seen .cp-topic__dot { background: #8a7fc8; }
.cp-topic__name { font-weight: 600; overflow-wrap: anywhere; }
.cp-topic__when { color: var(--text-secondary); font-size: 0.78rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cp-topic__sub {
    grid-column: 2 / 4;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0 10px;
    color: var(--text-secondary);
    font-size: 0.78rem;
}
.cp-marks { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-primary); letter-spacing: 0.02em; overflow-wrap: anywhere; }
.cp-more {
    justify-self: start;
    padding: 2px 0;
    border: 0;
    background: none;
    color: var(--primary-color);
    font: inherit;
    font-size: 0.88rem;
    cursor: pointer;
}
.cp-marks-legend { margin: 4px 0 0; font-size: 0.75rem; }
.cp-chapters summary { cursor: pointer; font-weight: 600; }
.cp-chapter {
    display: grid;
    grid-template-columns: 4rem minmax(0, 1fr) 3rem;
    gap: 10px;
    align-items: center;
    padding: 4px 0;
    font-size: 0.82rem;
}
.cp-chapters summary + .cp-chapter { margin-top: 8px; }
.cp-chapter__n { text-align: right; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
    .cp-card { padding: 12px; }
    .cp-head__title { font-size: 1.15rem; }
    .cp-counts { gap: 6px; }
    .cp-count { padding: 6px 2px; min-width: 0; }
    .cp-count b { font-size: 1.2rem; }
    .cp-count span { font-size: 0.7rem; }
    .cp-chapter { grid-template-columns: 3.2rem minmax(0, 1fr) 2.6rem; gap: 8px; }
}

/* ===== ED-479 — Lithuanian letters above the answer field (tasks/active/ED-479/task.md) ===== */
.answer-letters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.answer-letters__key {
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
    font: inherit;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}
.answer-letters__key:hover { background: var(--bg-color); }
.answer-letters__key:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.answer-letters__caps { margin-left: auto; font-size: 0.85rem; color: var(--text-secondary); }
.answer-letters.is-caps .answer-letters__caps { background: #e0e7ff; border-color: #6366f1; color: #3730a3; }
.answer-letters.is-caps .answer-letters__key:not(.answer-letters__caps) { text-transform: uppercase; }

@media (max-width: 640px) {
    .answer-letters { gap: 4px; }
    .answer-letters__key { min-width: 2rem; padding: 0 0.35rem; }
    .answer-letters__caps { margin-left: 0; }
}

/* ===== ED-513 — lesson page (assessments/learning-run.ejs) on a phone =====
   Long words and runs like "______" wrap instead of widening the page (overflow-wrap + min-width: 0 on flex
   children). A tutor message is markdown rendered to HTML, so it gets no pre-wrap: the newlines between its <p>/<li>
   were drawn as empty lines and its list numbers fell out of the bubble. Student text keeps its line breaks. */
.lr-chat {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    min-height: 300px;
    max-height: 55vh;
    overflow-y: auto;
    margin-bottom: 16px;
}
.lr-chat__empty { color: #9ca3af; font-size: 13px; text-align: center; padding: 16px; }
.lr-msg { display: flex; justify-content: flex-start; margin-bottom: 12px; }
.lr-msg--student { justify-content: flex-end; }
.lr-msg__body { max-width: 85%; min-width: 0; }
.lr-msg__label { font-size: 11px; font-weight: 600; color: #9ca3af; margin-bottom: 3px; }
.lr-msg--student .lr-msg__label { text-align: right; }
.lr-bubble {
    background: #f3f4f6;
    color: #111827;
    border-radius: 12px 12px 12px 2px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.lr-msg--student .lr-bubble { background: #0f766e; color: #fff; border-radius: 12px 12px 2px 12px; }
.lr-bubble--plain { white-space: pre-wrap; }
.lr-bubble p, .lr-report p { margin: 0 0 0.5em; }
.lr-bubble p:last-child, .lr-report p:last-child { margin-bottom: 0; }
.lr-bubble ol, .lr-bubble ul, .lr-report ol, .lr-report ul { margin: 0.25em 0 0.5em; padding-left: 1.5em; }
.lr-bubble li > p, .lr-report li > p { margin: 0; }
/* Blocks with a width of their own (code, a table, display math) scroll inside themselves, not the page. */
.lr-bubble pre, .lr-bubble table, .lr-bubble .katex-display,
.lr-report pre, .lr-report table, .lr-report .katex-display { display: block; max-width: 100%; overflow-x: auto; }
.lr-bubble pre, .lr-report pre { white-space: pre; overflow-wrap: normal; }

.lr-input-row { display: flex; gap: 10px; align-items: flex-end; }
.lr-input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    box-sizing: border-box;
}
.lr-send { white-space: nowrap; width: auto; flex: 0 0 auto; }

.lr-report {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    overflow-wrap: anywhere;
}
.lr-report__title { margin: 0 0 16px; font-size: 20px; font-weight: 700; color: #111827; }
.lr-report__section { margin-bottom: 14px; }
.lr-report__heading { font-size: 15px; font-weight: 700; color: #111827; margin: 0 0 6px; }
.lr-report__section--strengths .lr-report__heading { color: #065f46; }
.lr-report__section--improve .lr-report__heading { color: #92400e; }
.lr-report__text { font-size: 14px; color: #374151; line-height: 1.6; }
.lr-report__unit { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 10px 12px; background: #f9fafb; border-radius: 8px; margin-bottom: 8px; }
.lr-report__unit-text { flex: 1; min-width: 0; }
.lr-report__unit-title { font-size: 13px; font-weight: 600; color: #111827; }
.lr-report__unit-comment { font-size: 12px; color: #6b7280; margin-top: 3px; }
.lr-report__unit-score { font-size: 18px; font-weight: 800; color: #0f766e; flex-shrink: 0; }
.lr-report-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.lr-report-actions .btn { width: auto; }
/* .btn sets display: inline-block, which beats the hidden attribute: "Next lesson" stays hidden until the script shows it. */
.lr-report-actions .btn[hidden] { display: none; }

@media (max-width: 768px) {
    /* iOS Safari zooms the page in when a field under 16px gets focus, and the zoomed page is cut off on the right. */
    .lr-input { font-size: 16px; }
    .lr-report { padding: 16px; }
    /* The "Development Interface" footer took the space under the answer field. */
    body.lr-page footer { display: none; }
}

/* ED-519: student scenarios — the page «Сценарии», the strip above a scenario's lesson or test,
   and the block under a finished step (/js/scenario-step.js). Mobile overrides follow the base rules. */
.scenarios-lead { margin: 0 0 20px; color: var(--text-secondary); font-size: 14px; }
.scenario-card { background: #fff; border: 1px solid #e3e6ea; border-radius: 10px; padding: 16px 18px; margin-bottom: 14px; }
.scenario-card__top { display: flex; align-items: flex-start; gap: 12px; }
.scenario-card__title { margin: 0; font-size: 16px; font-weight: 700; color: #1f2933; }
.scenario-card__meta { margin: 4px 0 0; font-size: 12px; color: #5f6672; }
.scenario-card__desc { margin: 10px 0 0; font-size: 14px; color: #4b5563; }
.scenario-card__action { margin-left: auto; flex-shrink: 0; }
.scenario-card__action .btn { width: auto; white-space: nowrap; }
.scenario-badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 9px; margin-left: 8px; vertical-align: middle; }
.scenario-badge--run { background: #e7f0fd; color: #1c5fb8; }
.scenario-badge--new { background: #f1f3f5; color: #495057; }
.scenario-badge--done { background: #e7f5ec; color: #1d6b3a; }
.scenario-bar { height: 8px; background: #e9ecef; border-radius: 4px; overflow: hidden; margin: 14px 0 10px; }
.scenario-bar i { display: block; height: 100%; background: #2b8a3e; }
.scenario-steps { margin: 0; padding: 0; list-style: none; }
.scenario-step { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid #f1f3f5; font-size: 14px; }
.scenario-step__icon { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: 0 0 22px; background: #e9ecef; color: #868e96; }
.scenario-step--done .scenario-step__icon { background: #2b8a3e; color: #fff; }
.scenario-step--current .scenario-step__icon { background: #206dc5; color: #fff; }
.scenario-step--current { font-weight: 600; }
.scenario-step--upcoming { color: #868e96; }
.scenario-step__kind { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: #5f6672; flex: 0 0 auto; min-width: 48px; }
.scenario-step__title { min-width: 0; overflow-wrap: anywhere; }
.scenario-step__here { font-size: 12px; color: #206dc5; margin-left: auto; white-space: nowrap; }
.scenario-strip { display: flex; align-items: center; gap: 10px; background: #f3f0ff; border: 1px solid #d0bfff; color: #5f3dc4; padding: 9px 16px; font-size: 14px; border-radius: 6px; margin: 10px 0; }
.scenario-strip__back { margin-left: auto; color: #5f3dc4; font-weight: 600; text-decoration: none; white-space: nowrap; }
.scenario-step-result { margin-top: 18px; padding-top: 16px; border-top: 1px solid rgba(0, 0, 0, .08); text-align: center; }
.scenario-step-result p { margin: 0 0 12px; font-size: 14px; color: #2b3a2e; }
.scenario-step-result__form { display: inline; margin: 0; }
.scenario-step-result .btn { width: auto; margin: 4px; }

@media (max-width: 640px) {
    .scenario-card__top { flex-direction: column; }
    .scenario-card__action { margin-left: 0; width: 100%; }
    .scenario-card__action .btn { width: 100%; }
    .scenario-strip { flex-wrap: wrap; }
}
