/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #eff6ff;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --bg: #ffffff;
    --surface: #f9fafb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success-bg: #f0fdf4;
    --success-border: #86efac;
    --success-text: #166534;
    --error-bg: #fef2f2;
    --error-border: #fca5a5;
    --error-text: #991b1b;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    font-size: 16px;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

/* Nav */
.nav {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.brand:hover {
    text-decoration: none;
    color: var(--primary-hover);
}

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

.nav-user {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    text-decoration: none;
}
.nav-user:hover { color: var(--text); }

.profile-dl {
    display: grid;
    grid-template-columns: 8rem 1fr;
    gap: 0.4rem 1rem;
    margin: 0;
}
.profile-dl dt { color: var(--text-muted); font-size: 0.9rem; }
.profile-dl dd { margin: 0; font-weight: 500; }

/* Main content spacing */
main.container {
    padding-top: 2rem;
    padding-bottom: 3rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    background: var(--primary);
    color: white;
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    line-height: 1.4;
    white-space: nowrap;
    font-family: inherit;
}

.btn:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    text-decoration: none;
    color: white;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--surface);
    color: var(--text);
    border-color: #d1d5db;
}

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

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

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.75rem 1.75rem;
    font-size: 1rem;
}

.btn-full {
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.5;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-group input.input-error {
    border-color: var(--danger);
}

.form-group input.input-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.field-error {
    display: block;
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 0.3rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-text);
}

.alert-error {
    background: var(--error-bg);
    border-color: var(--error-border);
    color: var(--error-text);
}

/* Card */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.card-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.badge-admin {
    background: var(--primary-light);
    color: var(--primary);
}

/* Hero */
.hero {
    padding: 3rem 0;
}

.hero-content {
    text-align: center;
    margin-bottom: 3rem;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 1rem;
    color: var(--text);
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 520px;
    margin: 0 auto 2rem;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.feature-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.feature-card p {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Auth pages */
.auth-page {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.auth-card {
    width: 100%;
    max-width: 440px;
}

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

/* School page */
.school-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.school-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.school-header-actions {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

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

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Invite box */
.invite-box {
    background: var(--primary-light);
    border-color: #bfdbfe;
}

.invite-label {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.invite-url-row {
    display: flex;
    gap: 0.5rem;
}

.invite-url-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: monospace;
    background: var(--bg);
    color: var(--text);
}

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

/* Members table */
.members-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.members-table th {
    text-align: left;
    padding: 0.625rem 0.75rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.members-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.members-table tbody tr:last-child td {
    border-bottom: none;
}

.members-table tbody tr:hover {
    background: var(--surface);
}

/* Invite page */
.invite-card {
    text-align: center;
}

.invite-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.invite-auth-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* Utility */
.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Import divider */
.import-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.25rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.import-divider::before,
.import-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.import-divider span {
    padding: 0 0.75rem;
}

/* Generic table */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.table th {
    text-align: left;
    padding: 0.625rem 0.75rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: var(--surface);
}

.row-warning {
    background: #fffbeb;
}

/* Badge variants */
.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef9c3;
    color: #854d0e;
}

.badge-info {
    background: var(--primary-light);
    color: var(--primary);
}

/* Inline table inputs */
.input-inline {
    width: 100%;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    min-width: 120px;
}

.input-inline:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Course list */
.course-list {
    display: grid;
    gap: 1rem;
}

.course-card {
    display: block;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.course-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.12);
    text-decoration: none;
    color: var(--text);
}

.course-card-code {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.course-card-name {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.course-card-role {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.course-card-dates {
    font-size: 0.85rem;
}

/* Version choice (import preview) */
.version-choice {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.4rem;
    flex-wrap: wrap;
}

.version-btn {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    cursor: pointer;
    font-family: inherit;
    color: var(--text-muted);
    white-space: nowrap;
    line-height: 1.4;
}

.version-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* Invite actions row */
.invite-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

/* ---- Sections & Modules ---- */
.sections-area {
    display: grid;
    gap: 1.5rem;
}

.section-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
}

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

.section-title {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 0;
}

.section-actions {
    display: flex;
    gap: 0.4rem;
}

.module-card {
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    margin-bottom: 0.5rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}

.module-card:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    text-decoration: none;
    color: var(--text);
}

.module-card-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.module-card-dates {
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

.add-inline-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.add-section-form {
    display: flex;
    gap: 0.5rem;
}

/* ---- Quiz editor ---- */
.question-block {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--surface);
}

.question-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.question-number {
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
    width: 1.5rem;
}

.question-meta {
    flex: 1;
}

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

.question-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* ---- Quiz question edit ---- */
.option-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    background: var(--surface);
    gap: 1rem;
}

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

.option-actions {
    display: flex;
    gap: 0.4rem;
}

.btn-success {
    background: #16a34a;
    border-color: #16a34a;
    color: white;
}

.btn-success:hover {
    background: #15803d;
    border-color: #15803d;
    color: white;
}

/* ---- Quiz taking ---- */
.quiz-timer {
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 0.4rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    min-width: 120px;
    text-align: center;
}

.quiz-meta {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.question-card {
    margin-bottom: 1rem;
}

.question-card-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.question-card-text {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
}

.question-card-points {
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.options-list {
    display: grid;
    gap: 0.4rem;
    margin-left: 2rem;
}

.option-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--surface);
    font-size: 0.9rem;
    transition: border-color 0.15s, background 0.15s;
}

.option-label:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.option-label input {
    margin-top: 2px;
    flex-shrink: 0;
}

.quiz-submit-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* ---- Quiz results ---- */
.quiz-score-card {
    text-align: center;
    padding: 2rem;
}

.quiz-score-value {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--primary);
}

.quiz-score-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.results-heading {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.question-result {
    border-left: 4px solid var(--border);
}

.result-correct {
    border-left-color: #22c55e;
}

.result-wrong {
    border-left-color: var(--danger);
}

.result-pending {
    border-left-color: #f59e0b;
}

.result-graded {
    border-left-color: var(--primary);
}

.options-result {
    margin-top: 0.25rem;
}

.option-result {
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid transparent;
}

.opt-correct-selected {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
    font-weight: 600;
}

.opt-wrong-selected {
    background: var(--error-bg);
    border-color: var(--error-border);
    color: var(--error-text);
}

.opt-correct-unselected {
    background: #fef9c3;
    border-color: #fde047;
    color: #854d0e;
}

.opt-tag {
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: auto;
}

.result-text-answer {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0 0.75rem;
    margin-left: 2rem;
    font-size: 0.9rem;
    white-space: pre-wrap;
}

.grade-form {
    margin-left: 2rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .features {
        grid-template-columns: 1fr;
    }

    .hero-title {
        font-size: 1.75rem;
    }

    .school-header,
    .page-header {
        flex-direction: column;
    }

    .school-header-actions {
        width: 100%;
    }

    .members-table {
        font-size: 0.8rem;
    }

    .members-table th,
    .members-table td {
        padding: 0.5rem;
    }
}

/* --- AI Quiz Assistant panel --- */
.ai-toggle-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    z-index: 1000;
    transition: background 0.15s;
}
.ai-toggle-btn:hover { background: var(--primary-dark, #2563eb); }

.ai-panel {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 380px;
    max-width: calc(100vw - 2rem);
    max-height: 520px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
}

.ai-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
}
.ai-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.25rem;
}
.ai-close:hover { opacity: 0.75; }

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-message {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.88rem;
    line-height: 1.45;
    max-width: 90%;
    white-space: pre-wrap;
    word-break: break-word;
}
.ai-user {
    background: var(--primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}
.ai-assistant {
    background: var(--bg-secondary, #f1f5f9);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.ai-reload-notice {
    padding: 0.4rem 0.75rem;
    background: #fef9c3;
    font-size: 0.82rem;
    text-align: center;
    border-top: 1px solid #fde68a;
}
.ai-reload-notice a { color: var(--primary); font-weight: 600; }

.ai-input-row {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-top: 1px solid var(--border);
    background: #fff;
}
.ai-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.88rem;
    font-family: inherit;
    line-height: 1.4;
}
.ai-input:focus { outline: none; border-color: var(--primary); }
.ai-send-btn {
    align-self: flex-end;
    padding: 0.4rem 0.85rem;
    font-size: 0.88rem;
}

/* Help page */
.help-chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    min-height: 400px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
.help-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.help-message {
    padding: 0.65rem 0.9rem;
    border-radius: 14px;
    line-height: 1.5;
    max-width: 80%;
    white-space: pre-wrap;
    word-break: break-word;
}
.help-user {
    background: var(--primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}
.help-assistant {
    background: var(--bg-secondary, #f1f5f9);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}
.help-thinking {
    opacity: 0.5;
    font-style: italic;
}
.help-input-row {
    display: flex;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: #fff;
}
.help-textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.4;
}
.help-textarea:focus { outline: none; border-color: var(--primary); }

/* Nav link */
.nav-link {
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
}
.nav-link:hover { color: var(--primary); }

/* Markdown inside assistant messages */
.help-assistant ul { margin: 0.4rem 0 0.4rem 1.2rem; padding: 0; }
.help-assistant li { margin: 0.15rem 0; }
.help-assistant strong { font-weight: 600; }
.help-assistant code { background: rgba(0,0,0,0.08); border-radius: 3px; padding: 0.1em 0.3em; font-size: 0.88em; }
.help-assistant pre { background: rgba(0,0,0,0.08); border-radius: 6px; padding: 0.6rem 0.75rem; margin: 0.4rem 0; overflow-x: auto; }
.help-assistant pre code { background: none; padding: 0; }

/* Ticket bar on help page */
.help-ticket-bar {
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border);
    background: #fafafa;
    font-size: 0.88rem;
    color: var(--text-muted, #64748b);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Ticket thread */
.ticket-thread {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}
.ticket-message {
    background: var(--bg-secondary, #f1f5f9);
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
    max-width: 75%;
    align-self: flex-start;
}
.ticket-mine {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
}
.ticket-meta {
    font-size: 0.82rem;
    margin-bottom: 0.4rem;
    opacity: 0.75;
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}
.ticket-mine .ticket-meta { color: rgba(255,255,255,0.85); }
.ticket-body { white-space: pre-wrap; line-height: 1.55; }

/* Ticket filter tabs */
.ticket-filters { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.btn-active { background: var(--primary); color: #fff; }
.btn-active:hover { background: var(--primary); }

/* formatDate helper works on time.Time, add adapter */

.help-ticket-notice {
    align-self: center;
    background: #fef9c3;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 0.5rem 0.9rem;
    font-size: 0.88rem;
    text-align: center;
}
.help-ticket-notice a { color: var(--primary); font-weight: 600; }
