/* Base styles */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --border-radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--gray-900);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Card styles */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.card.centered {
    max-width: 420px;
    margin: 60px auto;
    text-align: center;
}

.card.wide {
    max-width: 800px;
    margin: 40px auto;
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--gray-500);
    margin-bottom: 24px;
}

.detail {
    color: var(--gray-700);
    margin-bottom: 24px;
}

/* Form styles */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

label {
    display: block;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 8px;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    resize: vertical;
}

.form-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Button styles */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

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

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

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

.btn-outline:hover {
    background: var(--gray-100);
}

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

.btn-danger:hover {
    background: #dc2626;
}

.text-muted {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.done-message {
    color: var(--success);
    font-weight: 500;
    margin-top: 8px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.button-row {
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

/* Header row */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.nav-links {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Badge */
.badge {
    display: inline-block;
    background: var(--gray-100);
    color: var(--gray-700);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.bonus-badge {
    background: var(--success);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Success icon */
.success-icon {
    width: 64px;
    height: 64px;
    background: var(--success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 20px;
}

/* Error message */
.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
    padding: 12px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}

/* Footer link */
.footer-link {
    margin-top: 24px;
    font-size: 0.875rem;
}

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

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

/* Dashboard styles */
.dashboard {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 32px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

/* Submissions list */
.submissions-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.submission-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 20px;
    transition: border-color 0.2s;
}

.submission-card.has-bonus {
    border-color: var(--success);
    background: #f0fdf4;
}

.submission-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.student-id {
    font-weight: 600;
    color: var(--gray-900);
}

.timestamp {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.code-block {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 16px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

.submission-actions {
    margin-top: 12px;
}

/* Submissions table view */
.submissions-table-wrapper {
    max-height: 75vh;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
}

.submissions-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.submissions-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--gray-100);
}

.submissions-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-300);
    white-space: nowrap;
}

.submissions-table .col-student { width: 100px; }
.submissions-table .col-time { width: 140px; }
.submissions-table .col-status { width: 70px; }
.submissions-table .col-actions { width: 120px; }
.submissions-table .col-code { width: auto; }

.submission-table-row {
    background: white;
    transition: background-color 0.15s ease;
}

.submission-table-row:hover {
    background: var(--gray-50);
}

.submission-table-row.has-bonus {
    background: #f0fdf4;
}

.submission-table-row.has-bonus:hover {
    background: #dcfce7;
}

.submissions-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: top;
}

.cell-student {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-900);
}

/* Student ID with points tooltip */
.student-id-tooltip {
    position: relative;
    cursor: pointer;
    border-bottom: 1px dotted var(--gray-400);
}

.student-id-tooltip .points-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    z-index: 100;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    margin-bottom: 4px;
}

.student-id-tooltip .points-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--gray-900);
}

.student-id-tooltip:hover .points-tooltip,
.student-id-tooltip:focus .points-tooltip {
    visibility: visible;
    opacity: 1;
}

.cell-time {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.cell-status {
    text-align: center;
}

.cell-status .bonus-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
}

.cell-status .no-bonus {
    color: var(--gray-300);
}

.cell-actions {
    white-space: nowrap;
}

.cell-actions .inline-form {
    display: inline;
}

.cell-actions .btn {
    margin-right: 4px;
}

/* Code preview in table - compact by default, expand on row hover */
.cell-code {
    position: relative;
}

.code-preview-table {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.75rem;
    color: var(--gray-700);
    margin: 0;
    padding: 4px 8px;
    background: var(--gray-50);
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.4;
    max-height: 2.8em; /* ~2 lines */
    overflow: hidden;
    cursor: pointer;
    /* Collapse immediately when mouse leaves */
    transition: max-height 0.2s ease, padding 0.2s ease;
}

.code-preview-table:hover {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px;
    /* Delay expansion by 0.4s to prevent accidental triggers */
    transition: max-height 0.25s ease 0.4s, padding 0.25s ease 0.4s;
}

/* Legacy compact view styles (kept for potential reuse) */
.submissions-compact {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 75vh;
    overflow-y: auto;
}

.submission-row {
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    background: white;
    overflow: hidden;
}

.submission-row:hover {
    border-color: var(--primary);
}

.submission-row.has-bonus {
    background: #f0fdf4;
    border-color: var(--success);
}

.submission-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
}

.submission-row .student-id {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-900);
}

.submission-row .timestamp {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.submission-row .bonus-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
}

.submission-row-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

/* Code preview - 3 lines by default, expand on hover */
.submission-row .code-preview {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    color: var(--gray-700);
    margin: 0;
    padding: 8px 12px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.4;
    max-height: 4.2em; /* ~3 lines */
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.submission-row:hover .code-preview {
    max-height: 400px;
    overflow-y: auto;
}

.inline-form {
    display: inline;
}

.btn-tiny {
    padding: 3px 8px;
    font-size: 0.7rem;
}

.submission-count {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 12px;
}

/* Submissions controls */
.submissions-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    flex-wrap: wrap;
    gap: 12px;
}

.controls-left,
.controls-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-badge {
    font-size: 0.875rem;
    color: var(--gray-600);
    padding: 4px 12px;
    background: white;
    border-radius: 20px;
    border: 1px solid var(--gray-200);
}

/* Session selector */
.session-select-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
}

.session-select {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    background: white;
    min-width: 250px;
    cursor: pointer;
}

.session-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

/* Historical session banner */
.viewing-historical-banner {
    background: #e0f2fe;
    border: 1px solid #0ea5e9;
    color: #0369a1;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.page-info {
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
}

.data-table tr:hover {
    background: var(--gray-50);
}

.points-cell {
    font-weight: 600;
    color: var(--success);
}

/* Session selector */
.session-selector {
    margin-bottom: 24px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
}

.session-selector label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.session-selector select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

.session-selector select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Session stats card */
.session-stats-card {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 24px;
}

.session-stats-card h2 {
    margin-bottom: 4px;
}

.session-time {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.stats-row {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    background: white;
    padding: 16px 24px;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-200);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.export-session {
    margin-top: 16px;
}

/* Status indicators */
.status-yes {
    color: var(--success);
    font-weight: 600;
}

.status-no {
    color: var(--gray-400);
}

/* Session styles */
.session-status-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 24px;
}

.session-status-bar.active {
    background: #f0fdf4;
    border: 1px solid var(--success);
}

.session-status-bar.inactive {
    background: #fef3c7;
    border: 1px solid #f59e0b;
}

.session-status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.session-status-badge.active {
    background: var(--success);
    color: white;
}

.session-status-badge.inactive {
    background: #f59e0b;
    color: white;
}

.session-info {
    flex: 1;
    color: var(--gray-700);
}

.session-card {
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 24px;
}

.session-card.active {
    border-color: var(--success);
    background: #f0fdf4;
}

.session-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.session-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.session-details {
    margin-bottom: 16px;
}

.session-details p {
    margin-bottom: 8px;
    color: var(--gray-700);
}

.session-actions {
    margin-top: 16px;
}

.start-session-form {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 24px;
}

.start-session-form h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
}

.form-hint {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.past-sessions {
    margin-top: 32px;
}

.past-sessions h2 {
    font-size: 1.25rem;
    margin-bottom: 16px;
}

.no-active-session {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    margin-bottom: 24px;
    color: var(--gray-700);
}

.warning-banner {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
    padding: 12px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 0.875rem;
}

.warning-icon {
    width: 64px;
    height: 64px;
    background: #f59e0b;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    margin: 0 auto 20px;
}

.info-icon {
    width: 64px;
    height: 64px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    font-style: italic;
    margin: 0 auto 20px;
}

.session-label {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-top: 4px;
}

.starter-text-preview {
    margin-top: 12px;
}

.starter-text-preview pre {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.75rem;
    max-height: 150px;
    overflow: auto;
    margin-top: 8px;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
}

/* Excursion (focused submission view) */
.excursion {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    max-width: 1000px;
    margin: 0 auto;
}

.excursion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.excursion-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.student-id-large {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.excursion-code {
    margin-bottom: 24px;
}

.code-display {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 24px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.95rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
    max-height: 50vh;
    overflow-y: auto;
}

.excursion-feedback {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 24px;
}

.excursion-feedback .form-group {
    margin-bottom: 16px;
}

.excursion-feedback textarea {
    min-height: 120px;
}

.excursion-feedback .btn {
    margin-right: 12px;
}

.bonus-form {
    display: inline;
}

/* Submission row actions */
.submission-row-actions {
    padding: 0 12px 8px 12px;
}

.submission-row-main {
    text-decoration: none;
    color: inherit;
}

.submission-row-main:hover {
    text-decoration: none;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 20px;
    }

    .card {
        padding: 24px;
    }

    .card.centered {
        margin: 20px auto;
    }

    .dashboard {
        padding: 20px;
    }

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

    .nav-links {
        width: 100%;
    }

    .btn {
        padding: 10px 16px;
        font-size: 0.875rem;
    }
}

/* Quiz styles */
.session-mode-badge-container {
    margin-bottom: 12px;
}

.session-mode-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.session-mode-badge.bonus {
    background: var(--success);
    color: white;
}

.session-mode-badge.participation {
    background: var(--primary);
    color: white;
}

.session-type-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
}

.session-type-badge.bonus {
    background: var(--success);
    color: white;
}

.session-type-badge.participation {
    background: var(--primary);
    color: white;
}

/* Quiz builder styles */
.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    transition: border-color 0.2s, background 0.2s;
}

.radio-label:hover {
    border-color: var(--primary);
}

.radio-label input[type="radio"]:checked + span,
.radio-label input[type="radio"]:checked + .badge-preview {
    font-weight: 600;
}

.radio-label:has(input:checked) {
    border-color: var(--primary);
    background: var(--gray-50);
}

.badge-preview {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-preview.bonus {
    background: var(--success);
    color: white;
}

.badge-preview.participation {
    background: var(--primary);
    color: white;
}

.quiz-builder {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-top: 16px;
}

.quiz-builder h3 {
    margin-bottom: 8px;
}

.quiz-question {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 16px;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.options-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-row input[type="text"] {
    flex: 1;
}

.option-letter {
    font-weight: 600;
    color: var(--gray-500);
    min-width: 24px;
}

/* Student quiz form styles */
.quiz-question-card {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
}

.question-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 16px;
}

.answer-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.answer-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.answer-option:hover {
    border-color: var(--primary);
}

.answer-option:has(input:checked) {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.option-text {
    flex: 1;
}

/* Quiz results styles */
.quiz-results-summary {
    text-align: center;
    padding: 24px;
    margin: 24px 0;
    background: var(--gray-50);
    border-radius: var(--border-radius);
}

.score-display {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
}

.score-separator {
    color: var(--gray-400);
    margin: 0 4px;
}

.score-label {
    color: var(--gray-500);
    margin-top: 8px;
}

.quiz-results-detail {
    margin-top: 24px;
}

.quiz-results-detail h2 {
    margin-bottom: 16px;
}

.result-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    border-radius: var(--border-radius);
    margin-bottom: 12px;
}

.result-card.correct {
    background: #f0fdf4;
    border: 1px solid var(--success);
}

.result-card.incorrect {
    background: #fef2f2;
    border: 1px solid var(--danger);
}

.result-status {
    flex-shrink: 0;
}

.status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    font-weight: bold;
}

.status-icon.correct {
    background: var(--success);
    color: white;
}

.status-icon.incorrect {
    background: var(--danger);
    color: white;
}

.result-content {
    flex: 1;
}

.result-question {
    font-weight: 500;
    margin-bottom: 8px;
}

.result-answer {
    color: var(--gray-700);
    margin-bottom: 4px;
}

.result-correct {
    color: var(--success);
}

/* Participation mode styles */
.participation-summary {
    background: #e0f2fe;
    border: 1px solid #0ea5e9;
}

.participation-message {
    font-size: 1.2rem;
    color: var(--gray-700);
    margin-bottom: 16px;
}

.participation-note {
    color: var(--gray-500);
    font-size: 0.9rem;
    font-style: italic;
}

.result-participation-note {
    color: var(--gray-500);
    font-size: 0.85rem;
    font-style: italic;
    margin-top: 4px;
}

.score-secondary {
    opacity: 0.85;
}

.score-secondary .score-display {
    font-size: 2rem;
}

.result-card.neutral {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
}

.status-icon.neutral {
    background: var(--gray-400);
    color: white;
}

/* Quiz builder participation-only styles */
.no-correct-option {
    margin-bottom: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--gray-600);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.options-container.participation-only {
    opacity: 0.6;
}

.options-container.participation-only input[type="radio"] {
    visibility: hidden;
}

/* Quiz stats section on dashboard */
.quiz-stats-section {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
}

.quiz-stats-section h2 {
    margin-bottom: 16px;
}

.quiz-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.quiz-stat-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 16px;
}

.quiz-stat-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 12px;
    line-height: 1.4;
}

.quiz-stat-content {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.pie-chart-container {
    flex-shrink: 0;
}

.pie-chart {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: conic-gradient(
        #10b981 0% var(--slice-0),
        #6366f1 var(--slice-0) calc(var(--slice-0) + var(--slice-1)),
        #f59e0b calc(var(--slice-0) + var(--slice-1)) calc(var(--slice-0) + var(--slice-1) + var(--slice-2)),
        #ef4444 calc(var(--slice-0) + var(--slice-1) + var(--slice-2)) 100%
    );
}

.quiz-stat-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-item-0 .legend-color { background: #10b981; }
.legend-item-1 .legend-color { background: #6366f1; }
.legend-item-2 .legend-color { background: #f59e0b; }
.legend-item-3 .legend-color { background: #ef4444; }

.legend-label {
    color: var(--gray-600);
}

/* Quiz score badge in submissions table */
.quiz-score-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--gray-100);
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-700);
}

/* Quiz answers display in table */
.quiz-answers-display {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    color: var(--gray-700);
    background: var(--gray-50);
    padding: 4px 8px;
    border-radius: 4px;
}

.no-answers {
    color: var(--gray-300);
}

/* Mobile-friendly quiz styles */
@media (max-width: 640px) {
    /* Quiz question cards */
    .quiz-question-card {
        padding: 16px;
    }

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

    /* Answer options - larger touch targets */
    .answer-option {
        padding: 16px;
        min-height: 48px;
        font-size: 1rem;
    }

    .answer-option input[type="radio"] {
        width: 24px;
        height: 24px;
        min-width: 24px;
    }

    /* Quiz builder options */
    .option-row {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 0;
    }

    .option-row input[type="text"] {
        flex: 1 1 100%;
        order: 2;
        margin-left: 32px;
    }

    .option-row input[type="radio"] {
        width: 24px;
        height: 24px;
    }

    /* Quiz stats on mobile */
    .quiz-stats-grid {
        grid-template-columns: 1fr;
    }

    .quiz-stat-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .pie-chart {
        width: 80px;
        height: 80px;
    }

    .quiz-stat-legend {
        align-items: center;
    }

    /* Quiz results */
    .quiz-results-summary {
        padding: 20px;
    }

    .score-display {
        font-size: 2.5rem;
    }

    .result-card {
        flex-direction: column;
        gap: 12px;
    }

    .result-status {
        align-self: flex-start;
    }

    /* Session mode badges */
    .session-mode-badge {
        font-size: 0.85rem;
        padding: 8px 16px;
    }

    /* Form improvements for mobile */
    .radio-group {
        flex-direction: column;
        gap: 12px;
    }

    .radio-label {
        width: 100%;
        justify-content: flex-start;
        padding: 12px 16px;
    }

    /* Quiz builder on mobile */
    .quiz-builder {
        padding: 16px;
    }

    .quiz-question {
        padding: 12px;
    }

    .add-opt-btn {
        width: 100%;
        margin-top: 12px;
    }
}

/* Extra small screens */
@media (max-width: 400px) {
    .card.wide {
        padding: 16px;
    }

    .answer-option {
        padding: 14px 12px;
    }

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

/* Modal styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.modal-header {
    padding: 24px 24px 0;
}

.modal-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.modal-body {
    padding: 24px;
}

.modal-code {
    margin-bottom: 24px;
}

.modal-code .code-display {
    max-height: 40vh;
}

.modal-feedback {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 20px;
}

.modal-feedback .form-group {
    margin-bottom: 16px;
}

.modal-feedback textarea {
    min-height: 80px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Modal navigation */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    z-index: 1001;
}

.modal-nav:hover:not(.disabled) {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(-50%) scale(1.05);
}

.modal-nav:active:not(.disabled) {
    transform: translateY(-50%) scale(0.95);
}

.modal-nav.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.modal-nav-prev {
    left: 20px;
}

.modal-nav-next {
    right: 20px;
}

.nav-arrow {
    font-size: 2rem;
    line-height: 1;
    color: var(--gray-700);
    font-weight: 300;
}

.modal-nav.disabled .nav-arrow {
    color: var(--gray-400);
}

/* Modal top bar with position indicator */
.modal-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    border-bottom: 1px solid var(--gray-100);
}

.modal-position {
    font-size: 0.85rem;
    color: var(--gray-500);
    font-weight: 500;
}

.modal-top-bar .modal-close {
    position: static;
    margin: -8px -12px -8px 0;
}

/* Adjust modal header now that we have top bar */
.modal-header {
    padding: 16px 24px 0;
}

/* Modal responsive */
@media (max-width: 640px) {
    .modal-overlay {
        padding: 10px;
    }

    .modal-content {
        max-height: 95vh;
    }

    .modal-header {
        padding: 16px 20px 0;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .modal-code .code-display {
        max-height: 30vh;
        font-size: 0.85rem;
    }

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

    .modal-actions .btn {
        width: 100%;
        text-align: center;
    }

    /* Navigation on mobile */
    .modal-nav {
        width: 40px;
        height: 40px;
    }

    .modal-nav-prev {
        left: 8px;
    }

    .modal-nav-next {
        right: 8px;
    }

    .nav-arrow {
        font-size: 1.5rem;
    }

    .modal-top-bar {
        padding: 10px 16px;
    }
}

/* Student history styles */
.info-banner {
    background: #eff6ff;
    border: 1px solid #3b82f6;
    color: #1e40af;
    padding: 12px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 0.875rem;
}

.button-group {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.feedback-badge {
    background: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.student-summary-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 16px 20px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.student-id-badge {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--gray-900);
}

.points-summary,
.submission-count-summary {
    font-size: 0.95rem;
    color: var(--gray-700);
}

.points-summary strong,
.submission-count-summary strong {
    color: var(--primary);
}

.bonus-percent {
    color: var(--success);
    font-weight: 600;
}

.submission-row.has-feedback {
    border-left: 3px solid var(--primary);
}

a.submission-row {
    text-decoration: none;
    color: inherit;
}

a.submission-row:hover {
    text-decoration: none;
}

.section-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 16px;
    margin-top: 8px;
}

.session-title-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-900);
}

.session-title-label.untitled {
    color: var(--gray-500);
    font-style: italic;
}

.session-title-large {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.session-title-large.untitled {
    color: var(--gray-500);
    font-style: italic;
}

.instructor-feedback-display {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-top: 24px;
}

.instructor-feedback-display h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 12px;
}

.feedback-content {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 16px;
    font-size: 0.95rem;
    color: var(--gray-700);
    line-height: 1.6;
    word-break: break-word;
}

.feedback-content pre {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    margin: 8px 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    white-space: pre-wrap;
}

.feedback-content code {
    background: var(--gray-100);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.85em;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

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

.no-feedback-message {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-top: 24px;
    text-align: center;
    color: var(--gray-500);
}

/* Participation tracking styles */
.participation-summary-count {
    font-size: 0.95rem;
    color: var(--gray-700);
}

.participation-summary-count strong {
    color: var(--success);
}

.participation-breakdown {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 24px;
}

.participation-breakdown h2 {
    font-size: 1rem;
    margin-bottom: 16px;
    color: var(--gray-700);
}

.participation-weeks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.participation-week {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--border-radius);
    min-width: 90px;
    text-align: center;
}

.participation-week.participated {
    background: #dcfce7;
    border: 1px solid var(--success);
}

.participation-week.missed {
    background: #fef2f2;
    border: 1px solid var(--danger);
}

.participation-week.skipped {
    background: #e0f2fe;
    border: 1px solid #0ea5e9;
}

.participation-week .week-number {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-700);
}

.participation-week .week-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: #0369a1;
}

.participation-week .week-status {
    font-size: 1.4rem;
    line-height: 1;
    margin: 4px 0;
}

.participation-week.participated .week-status {
    color: var(--success);
}

.participation-week.missed .week-status {
    color: var(--danger);
}

.participation-week .week-dates {
    font-size: 0.7rem;
    color: var(--gray-500);
}

/* Instructor participation config styles */
.participation-config {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 24px;
}

.participation-config h2 {
    margin-bottom: 20px;
}

.week-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}

.week-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.week-checkbox:hover {
    border-color: var(--primary);
}

.week-checkbox:has(input:checked) {
    border-color: var(--success);
    background: #f0fdf4;
}

.week-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.week-checkbox span {
    font-size: 0.9rem;
    font-weight: 500;
}

.config-section {
    margin-bottom: 24px;
}

.config-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.config-hint {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.skipped-weeks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skipped-week-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
}

.skipped-week-row input[type="number"] {
    width: 70px;
    padding: 6px 10px;
}

.skipped-week-row input[type="text"] {
    flex: 1;
    padding: 6px 10px;
}

.btn-remove-skipped {
    background: var(--danger);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-remove-skipped:hover {
    background: #dc2626;
}

@media (max-width: 640px) {
    .participation-weeks {
        flex-direction: column;
    }

    .participation-week {
        flex-direction: row;
        justify-content: space-between;
        min-width: auto;
        width: 100%;
    }

    .participation-week .week-status {
        margin: 0 12px;
    }
}

/* Weekly participation summary on instructor dashboard */
.weekly-participation-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.weekly-participation-summary .participation-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-600);
    white-space: nowrap;
}

.weekly-participation-summary .participation-weeks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.weekly-participation-summary .week-stat {
    display: inline-block;
    padding: 3px 8px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--gray-600);
    white-space: nowrap;
}

.weekly-participation-summary .week-stat.full {
    background: #dcfce7;
    border-color: var(--success);
    color: #166534;
}

.weekly-participation-summary .week-stat.empty {
    background: #fef2f2;
    border-color: var(--danger);
    color: #991b1b;
}

.weekly-participation-summary .week-stat.skipped {
    background: #e0f2fe;
    border-color: #0ea5e9;
    color: #0369a1;
    font-style: italic;
}

@media (max-width: 640px) {
    .weekly-participation-summary {
        flex-direction: column;
        align-items: flex-start;
    }

    .weekly-participation-summary .participation-weeks {
        width: 100%;
    }
}

/* ── Proof page layout styles (not part of standalone component) ── */
.proof-prompt {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 16px 20px;
    margin-bottom: 16px;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--gray-700);
}

.proof-prompt code {
    background: var(--gray-200);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.proof-prompt pre {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    margin: 12px 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}

.proof-prompt pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

.proof-toolbar {
    margin-bottom: 16px;
}

.proof-toolbar code {
    background: var(--gray-100);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.85em;
}

/* On mobile: show brief hint, hide full shortcuts */
.proof-shortcuts-brief {
    display: none;
}

@media (max-width: 640px) {
    .proof-shortcuts-full {
        display: none;
    }
    .proof-shortcuts-brief {
        display: inline;
    }
}
