:root {
    --primary: #7c3aed;
    --primary-2: #00c4cc;
    --primary-3: #ff6b6b;
    --accent: #ffd166;
    --bg: #f7f3ff;
    --surface: rgba(255, 255, 255, 0.84);
    --surface-solid: #ffffff;
    --text: #201a3d;
    --text-dim: #6b6386;
    --border: rgba(124, 58, 237, 0.16);
    --shadow: 0 24px 70px rgba(34, 24, 76, 0.14);
    --danger: #e11d48;
    --warning: #f59e0b;
    --success: #10b981;
    --info: #0ea5e9;
    --radius-lg: 28px;
    --radius-md: 18px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 8% 10%, rgba(0, 196, 204, 0.24), transparent 30%),
        radial-gradient(circle at 92% 12%, rgba(255, 107, 107, 0.22), transparent 26%),
        radial-gradient(circle at 48% 92%, rgba(124, 58, 237, 0.25), transparent 34%),
        linear-gradient(135deg, #fff8f0 0%, #f3f0ff 48%, #eafcff 100%);
    overflow-x: hidden;
    padding: 28px;
}

#matrixCanvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    opacity: 0.82;
}

.container {
    position: relative;
    z-index: 2;
    width: min(1220px, 100%);
    margin: 0 auto;
}

.app-header,
.card,
.login-card,
.metric-card,
.modal-card {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 22px;
    margin-bottom: 24px;
    padding: 28px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
}

.app-header::after {
    content: "";
    position: absolute;
    width: 180px;
    height: 180px;
    right: -55px;
    top: -70px;
    background: conic-gradient(from 120deg, var(--primary), var(--primary-2), var(--primary-3), var(--primary));
    border-radius: 44% 56% 68% 32% / 42% 43% 57% 58%;
    opacity: 0.16;
    animation: morphBlob 9s ease-in-out infinite;
}

.app-header > * {
    position: relative;
    z-index: 1;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.74rem;
}

.app-header h1,
.login-card h2,
.card h2,
.table-actions h2,
.modal-card h2 {
    margin: 0;
    color: var(--text);
    letter-spacing: -0.04em;
}

.app-header h1 {
    font-size: clamp(2rem, 4vw, 4.2rem);
    line-height: 0.94;
    max-width: 720px;
}

.header-subtitle,
.login-copy,
.muted,
.help-text {
    color: var(--text-dim);
}

.header-subtitle {
    margin: 14px 0 0;
    max-width: 720px;
    font-size: 1rem;
    line-height: 1.6;
}

.typing-text::after {
    content: "|";
    color: var(--primary-2);
    animation: blink 0.75s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes morphBlob {
    0%, 100% { transform: rotate(0deg) scale(1); border-radius: 44% 56% 68% 32% / 42% 43% 57% 58%; }
    50% { transform: rotate(18deg) scale(1.08); border-radius: 65% 35% 45% 55% / 35% 65% 35% 65%; }
}

.grid-2 {
    display: grid;
    grid-template-columns: 0.92fr 1.08fr;
    gap: 24px;
    align-items: start;
}

.card {
    border-radius: var(--radius-lg);
    padding: 26px;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.08), transparent 36%, rgba(0, 196, 204, 0.08));
    pointer-events: none;
}

.card > * {
    position: relative;
    z-index: 1;
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 18px;
}

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

.form-group,
.filter-control {
    margin-bottom: 16px;
}

.form-group label,
.filter-control label {
    display: block;
    margin-bottom: 8px;
    font-weight: 800;
    color: var(--text);
}

input,
select,
textarea {
    width: 100%;
    padding: 13px 15px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border);
    color: var(--text);
    font: inherit;
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

textarea {
    resize: vertical;
    min-height: 92px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(124, 58, 237, 0.62);
    box-shadow: 0 0 0 5px rgba(124, 58, 237, 0.12);
    transform: translateY(-1px);
}

.help-text {
    display: block;
    margin-top: 7px;
    font-size: 0.82rem;
    line-height: 1.45;
}

.submission-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 14px 0 18px;
    background: rgba(255, 255, 255, 0.58);
    animation: panelIn 0.28s ease;
}

@keyframes panelIn {
    from { opacity: 0; transform: translateY(8px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.panel-note {
    display: flex;
    flex-direction: column;
    gap: 3px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(0, 196, 204, 0.12));
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 14px;
}

.panel-note strong {
    font-size: 1.02rem;
}

.panel-note span {
    color: var(--text-dim);
    line-height: 1.45;
}

.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger-sm,
.btn-link {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.btn-primary {
    width: 100%;
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary), #a855f7 46%, var(--primary-2));
    box-shadow: 0 14px 34px rgba(124, 58, 237, 0.25);
}

.btn-secondary {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(124, 58, 237, 0.16);
}

.btn-success {
    color: #ffffff;
    background: linear-gradient(135deg, var(--success), var(--primary-2));
}

.btn-danger-sm {
    color: #ffffff;
    background: linear-gradient(135deg, var(--danger), #fb7185);
}

.btn-link {
    color: var(--primary);
    background: transparent;
    margin-top: 16px;
}

.btn-fit {
    width: auto;
    min-width: 220px;
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-success:hover,
.btn-danger-sm:hover,
.btn-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(45, 27, 105, 0.18);
}

button:disabled,
.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
}

.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(247, 243, 255, 0.65);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    padding: 20px;
    backdrop-filter: blur(18px);
}

.login-card {
    width: min(430px, 100%);
    padding: 34px;
    border-radius: 32px;
    text-align: center;
}

.login-card h2 {
    font-size: 2.1rem;
    margin-bottom: 8px;
}

.error-msg {
    color: var(--danger);
    font-weight: 700;
    font-size: 0.92rem;
    margin-top: 12px;
}

.result-card {
    position: sticky;
    top: 24px;
}

.result-header,
.section-heading-row,
.table-actions,
.header-actions,
.table-actions-right {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.total-score-box {
    text-align: center;
    padding: 22px;
    margin: 18px 0;
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(0, 196, 204, 0.14));
    border: 1px solid rgba(124, 58, 237, 0.14);
}

.total-score-box h3 {
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.8rem;
    margin: 0 0 6px;
}

.score-display {
    font-size: clamp(2.5rem, 5vw, 4.6rem);
    line-height: 1;
    font-weight: 1000;
    letter-spacing: -0.08em;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.rubric-list {
    margin: 0;
    padding-left: 20px;
    line-height: 1.9;
}

.feedback-box {
    margin-top: 18px;
    padding: 16px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid var(--border);
}

.feedback-box h4 {
    margin: 0 0 10px;
}

.feedback-line {
    margin: 0 0 9px;
    line-height: 1.55;
    color: var(--text);
}

.badge-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    padding: 6px 11px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-success { color: #047857; background: rgba(16, 185, 129, 0.13); border-color: rgba(16, 185, 129, 0.24); }
.badge-warning { color: #92400e; background: rgba(245, 158, 11, 0.16); border-color: rgba(245, 158, 11, 0.26); }
.badge-danger { color: #be123c; background: rgba(225, 29, 72, 0.12); border-color: rgba(225, 29, 72, 0.2); }
.badge-info { color: #0369a1; background: rgba(14, 165, 233, 0.13); border-color: rgba(14, 165, 233, 0.24); }

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}

.metric-card {
    padding: 22px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
}

.metric-card::after {
    content: "";
    position: absolute;
    width: 130px;
    height: 130px;
    right: -42px;
    top: -42px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
}

.metric-card h3 {
    margin: 0 0 8px;
    color: rgba(255, 255, 255, 0.86);
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.metric-card p {
    margin: 0;
    color: #ffffff;
    font-size: 2.2rem;
    font-weight: 1000;
    letter-spacing: -0.05em;
}

.gradient-card-a { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.gradient-card-b { background: linear-gradient(135deg, #00a6c8, #00c4cc); }
.gradient-card-c { background: linear-gradient(135deg, #ff6b6b, #f59e0b); }

.project-settings-card,
.controls-card {
    margin-bottom: 22px;
}

.settings-grid,
.filter-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 14px;
    align-items: end;
}

.settings-grid {
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) 1fr;
}

.settings-status {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(124, 58, 237, 0.1);
    color: var(--primary);
    font-weight: 900;
    font-size: 0.85rem;
}

.table-actions {
    margin: 28px 0 14px;
}

.table-actions h2 {
    font-size: 1.65rem;
}

.view-toggle {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.view-toggle .btn-secondary.active {
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.table-responsive {
    overflow-x: auto;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    min-width: 1180px;
}

th,
td {
    padding: 14px 15px;
    border-bottom: 1px solid rgba(107, 99, 134, 0.12);
    color: var(--text);
    vertical-align: top;
}

th {
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    background: rgba(255, 255, 255, 0.85);
    position: sticky;
    top: 0;
    z-index: 1;
}

a {
    color: var(--primary);
    font-weight: 800;
}

a:hover {
    color: var(--primary-2);
}

.student-name-link {
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
    font-weight: 900;
    background: none;
    border: 0;
    font: inherit;
    padding: 0;
}

.student-name-link:hover {
    color: var(--primary-2);
}

.tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 18px;
}

.tile-card {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 286px;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.tile-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 28px 80px rgba(34, 24, 76, 0.18);
}

.tile-header {
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(107, 99, 134, 0.14);
}

.tile-score {
    font-size: 2.45rem;
    line-height: 1;
    font-weight: 1000;
    letter-spacing: -0.07em;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 12px 0;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(32, 26, 61, 0.38);
    backdrop-filter: blur(14px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 80;
    padding: 20px;
}

.modal-card {
    border-radius: 32px;
    padding: 28px;
    max-width: 760px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    color: var(--danger);
    background: rgba(225, 29, 72, 0.12);
    font-size: 1.25rem;
    cursor: pointer;
}

.modal-close:hover {
    background: var(--danger);
    color: #ffffff;
}

.modal-rubric-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 15px 0;
}

.modal-rubric-grid div {
    border-radius: var(--radius-sm);
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.1);
    padding: 12px;
}

.modal-feedback-box {
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-top: 15px;
    line-height: 1.55;
}

.detail-list p {
    margin: 8px 0;
    line-height: 1.55;
}

.noscript-warning {
    position: relative;
    z-index: 100;
    background: #fff;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 16px;
    margin: 16px auto;
    max-width: 800px;
    text-align: center;
    border-radius: var(--radius-md);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 980px) {
    body { padding: 18px; }
    .grid-2 { grid-template-columns: 1fr; }
    .result-card { position: static; }
    .metrics-grid { grid-template-columns: 1fr; }
    .settings-grid,
    .filter-row { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .app-header { align-items: flex-start; flex-direction: column; }
    .header-actions,
    .table-actions-right { width: 100%; align-items: stretch; }
    .header-actions > *,
    .table-actions-right > *,
    .view-toggle,
    .view-toggle button { width: 100%; }
    .form-row { grid-template-columns: 1fr; }
    .modal-rubric-grid { grid-template-columns: 1fr; }
    .btn-fit { width: 100%; }
}

/* Detailed project rubric builder */
.settings-grid-compact {
    grid-template-columns: minmax(220px, 0.75fr) minmax(280px, 2fr);
}

.settings-title-field {
    grid-column: auto;
}

.rubric-builder {
    margin: 14px 0 18px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.48);
}

.rubric-builder-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.rubric-builder-heading h3 {
    margin: 0 0 4px;
    font-size: 1.12rem;
}

.rubric-rows {
    display: grid;
    gap: 12px;
}

.rubric-row {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 150px;
    gap: 12px;
    align-items: start;
    padding: 12px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.64);
    border: 1px solid rgba(124, 58, 237, 0.12);
}

.rubric-row .form-group {
    margin-bottom: 0;
}

.rubric-percent-group input {
    text-align: center;
    font-weight: 900;
}

@media (max-width: 720px) {
    .settings-grid-compact,
    .rubric-row {
        grid-template-columns: 1fr;
    }
}

/* Teacher dashboard navigation + responsive polish */
.dashboard-nav {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 0 22px;
    padding: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 16px 44px rgba(34, 24, 76, 0.10);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 12px;
    z-index: 20;
}

.dashboard-nav-btn {
    flex: 1 1 220px;
    border: 0;
    border-radius: 999px;
    padding: 13px 18px;
    color: var(--text-dim);
    background: transparent;
    font: inherit;
    font-weight: 950;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.dashboard-nav-btn:hover {
    transform: translateY(-1px);
    color: var(--primary);
}

.dashboard-nav-btn.active {
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 14px 30px rgba(124, 58, 237, 0.24);
}

.dashboard-panel {
    animation: panelIn 0.28s ease;
}

#submissionsPanel .table-actions {
    margin-top: 0;
}

@media (max-width: 980px) {
    .app-header,
    .section-heading-row,
    .result-header,
    .table-actions {
        align-items: flex-start;
    }

    .project-settings-card,
    .controls-card,
    .form-card,
    .result-card {
        padding: 20px;
        border-radius: 24px;
    }

    .dashboard-nav {
        position: relative;
        top: auto;
        border-radius: 24px;
    }
}

@media (max-width: 720px) {
    body {
        padding: 12px;
    }

    .container {
        width: 100%;
    }

    .app-header,
    .card,
    .login-card,
    .modal-card,
    .tile-card,
    .metric-card {
        border-radius: 20px;
    }

    .app-header {
        padding: 20px;
    }

    .app-header h1 {
        font-size: clamp(1.9rem, 12vw, 3rem);
    }

    .header-subtitle {
        font-size: 0.95rem;
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }

    .dashboard-nav {
        padding: 8px;
        gap: 8px;
    }

    .dashboard-nav-btn {
        flex-basis: 100%;
    }

    .metrics-grid {
        gap: 12px;
    }

    .metric-card {
        padding: 18px;
    }

    .metric-card p {
        font-size: 1.8rem;
    }

    .table-responsive {
        border-radius: 18px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    th,
    td {
        padding: 11px 12px;
        font-size: 0.88rem;
    }

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

    .total-score-box {
        padding: 18px;
    }
}

@media (max-width: 420px) {
    body {
        padding: 8px;
    }

    .card,
    .app-header,
    .login-card,
    .modal-card {
        padding: 16px;
    }

    .btn-primary,
    .btn-secondary,
    .btn-success,
    .btn-danger-sm,
    .btn-link {
        width: 100%;
        padding: 12px 14px;
    }

    .badge-container,
    .header-actions,
    .table-actions-right,
    .view-toggle {
        width: 100%;
    }

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

/* Output filter dropdown for teacher submissions */
.controls-card .filter-row {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: end;
}

#filterOutput {
    font-weight: 800;
}

@media (max-width: 720px) {
    .controls-card .filter-row {
        grid-template-columns: 1fr;
    }
}

/* ===== Live auto-refresh indicator ===== */
.live-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.1);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.25);
    transition: background 0.3s ease, color 0.3s ease;
}
.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
    animation: livePulse 1.8s infinite;
}
.live-status[data-state="syncing"] { background: rgba(99, 102, 241, 0.1); color: #4338ca; border-color: rgba(99, 102, 241, 0.25); }
.live-status[data-state="syncing"] .live-dot { background: #6366f1; }
.live-status[data-state="error"] { background: rgba(239, 68, 68, 0.1); color: #b91c1c; border-color: rgba(239, 68, 68, 0.25); }
.live-status[data-state="error"] .live-dot { background: #ef4444; animation: none; }
@keyframes livePulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.live-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    padding: 12px 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(76, 29, 149, 0.3);
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.live-toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 600px) {
    .live-toast { left: 12px; right: 12px; bottom: 12px; text-align: center; }
}

/* ===== Manual refresh button ===== */
.btn-refresh { display: inline-flex; align-items: center; gap: 6px; }
.btn-refresh .refresh-icon { display: inline-block; font-size: 1.05rem; line-height: 1; transition: transform 0.4s ease; }
.btn-refresh:hover .refresh-icon { transform: rotate(90deg); }
.btn-refresh.is-loading { opacity: 0.75; cursor: wait; }
.btn-refresh.is-loading .refresh-icon { animation: refreshSpin 0.8s linear infinite; }
@keyframes refreshSpin { to { transform: rotate(360deg); } }

/* ===== Points Claimed checkbox ===== */
.name-cell { white-space: nowrap; }
.tile-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.claim-box {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-right: 8px;
    vertical-align: middle;
    cursor: pointer;
    position: relative;
}
.claim-checkbox {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #10b981;
    cursor: pointer;
    transition: transform 0.15s ease;
}
.claim-checkbox:hover:not(:disabled) { transform: scale(1.12); }
.claim-box.is-claimed { cursor: not-allowed; }
.claim-box.is-claimed .claim-checkbox { cursor: not-allowed; opacity: 1; }
.claim-box.is-saving { opacity: 0.55; cursor: wait; }
.claim-lock { font-size: 0.75rem; line-height: 1; }
.claim-box.is-claimed .claim-lock { animation: claimPop 0.35s ease; }
@keyframes claimPop { 0% { transform: scale(0.4); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* ===== Teacher Master Submission: one row/card per student ===== */
#studentTableContainer table { min-width: 920px; }
.student-master-row:hover { background: rgba(124, 58, 237, 0.035); }
.student-master-row td { vertical-align: middle; }
.student-row-subtitle {
    display: block;
    margin-top: 5px;
    color: var(--text-dim);
    font-size: 0.76rem;
}
.student-claim-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 170px;
    max-width: 420px;
}
.student-claim-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 7px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    font-size: 0.72rem;
    white-space: nowrap;
}
.student-output-short-label { font-weight: 800; color: var(--text-dim); }
.student-claim-chip .claim-box { margin: 0; gap: 2px; }
.student-claim-chip .claim-checkbox { width: 16px; height: 16px; }
.btn-view-student-history { white-space: nowrap; width: auto; }
.empty-student-list {
    grid-column: 1 / -1;
    padding: 26px;
    text-align: center;
    color: var(--text-dim);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.student-tile-card { min-height: 0; gap: 12px; }
.student-tile-name { font-size: 1.22rem; }
.student-tile-identity { color: var(--text-dim); font-size: 0.85rem; margin: 8px 0; word-break: break-word; }
.student-tile-badges { display: flex; flex-wrap: wrap; gap: 7px; }
.student-tile-date { color: var(--text-dim); font-size: 0.86rem; margin: 0; }
.student-claims-title { font-size: 0.82rem; }
.student-list-help { margin: 5px 0 8px; font-size: 0.88rem; max-width: 780px; }

/* ===== All submissions + previous attempts modal ===== */
#studentModal .modal-card { max-width: 1020px; }
#studentModal .modal-card h2 { padding-right: 42px; }
.student-history-identity {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0;
}
.student-history-identity-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.58);
    overflow-wrap: anywhere;
}
.student-history-identity-item strong { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.student-history-identity-item span { font-weight: 750; }
.history-summary-line { font-weight: 800; color: var(--primary); margin: 12px 0; }
.history-loading-state,
.history-load-warning {
    padding: 14px 16px;
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.62);
    color: var(--text-dim);
}
.history-load-warning { border-color: rgba(234, 179, 8, 0.35); background: rgba(254, 243, 199, 0.52); color: #7c5b00; }
.history-output-section {
    margin: 15px 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.48);
}
.history-output-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding-bottom: 11px;
    margin-bottom: 11px;
    border-bottom: 1px solid var(--border);
}
.history-output-heading h3 { margin: 0 0 4px; }
.history-output-heading small { color: var(--text-dim); }
.history-claim-control { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 0.84rem; }
.history-claim-control .claim-box { margin: 0; }
.history-attempt {
    margin: 9px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.72);
}
.history-attempt.is-current-attempt { border-color: rgba(16, 185, 129, 0.35); }
.history-attempt-summary {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
    cursor: pointer;
    list-style: none;
    padding: 12px 14px;
}
.history-attempt-summary::-webkit-details-marker { display: none; }
.history-attempt-summary::after { content: '＋'; margin-left: auto; color: var(--primary); font-weight: 900; }
.history-attempt[open] .history-attempt-summary::after { content: '−'; }
.history-attempt-marker { border-radius: 999px; padding: 4px 8px; font-size: 0.7rem; font-weight: 900; }
.history-attempt-marker.is-latest { color: #047857; background: rgba(16, 185, 129, 0.14); }
.history-attempt-marker.is-previous { color: var(--text-dim); background: rgba(107, 99, 134, 0.12); }
.history-attempt-date { color: var(--text-dim); font-size: 0.82rem; }
.history-attempt-score { margin-left: auto; white-space: nowrap; }
.history-attempt-body { padding: 4px 14px 16px; border-top: 1px solid var(--border); }
.history-attempt-url { overflow-wrap: anywhere; line-height: 1.5; }
.history-scanner-summary { margin: 12px 0; color: var(--text-dim); font-size: 0.88rem; }
.history-feedback-heading { margin: 18px 0 0; }
.history-claimed-note { color: #047857; font-weight: 800; }

@media (max-width: 720px) {
    #studentTableContainer table { min-width: 800px; }
    .student-history-identity { grid-template-columns: 1fr; }
    .history-output-heading { align-items: flex-start; }
    .history-attempt-score { margin-left: 0; }
    .student-claim-list { max-width: 290px; }
}

/* ===== Password-protected Excel result download ===== */
.excel-download-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding: 16px 18px;
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.07), rgba(0, 196, 204, 0.07));
}
.excel-download-panel strong { display: block; margin-bottom: 3px; }
.excel-download-panel p { margin: 0; color: var(--text-dim); font-size: 0.86rem; line-height: 1.5; }
.btn-excel-download {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    color: #fff;
    background: linear-gradient(135deg, #047857, #0f766e);
    box-shadow: 0 10px 24px rgba(4, 120, 87, 0.18);
    font: inherit;
    font-weight: 850;
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease;
}
.btn-excel-download:not(:disabled):hover { transform: translateY(-2px); }
.btn-excel-download:disabled { opacity: 0.58; cursor: wait; }
.excel-download-status { flex-basis: 100%; }
.excel-download-status:empty { display: none; }
@media (max-width: 600px) {
    .excel-download-panel { align-items: stretch; }
    .btn-excel-download { width: 100%; }
}
