:root {
    /* Dark-gray base (replacing pure black) */
    --bg: #121217;
    /* deep dark gray */
    --surface: #1b1b23;
    /* slightly lighter surface */
    --panel: #22222a;
    /* panel tone */
    --muted: #b1bed6;
    --text: #e6eef6;

    /* Palette swatches (from provided image) */
    --palette-1: #9eadcf;
    --palette-2: #7496c1;
    --palette-3: #5754a8;
    --palette-4: #34344d;
    --palette-5: #54526a;

    --accent: var(--palette-3);
    --accent-strong: var(--palette-1);

    --success: #22c55e;
    --danger: #fb7185;
    --flag: #ff8a3d;
    /* warm orange that complements the indigo palette */

    /* Galactic / atmospheric accents */
    --glow: rgba(87, 84, 168, 0.92);
    --galactic-bg1: rgba(87, 84, 168, 0.14);
    --galactic-bg2: rgba(116, 150, 193, 0.08);
    --star-1: rgba(255, 255, 255, 0.95);
    --star-2: rgba(255, 255, 255, 0.6);
    --star-opacity: 0.55;
}

* {
    box-sizing: border-box
}

html,
body {
    height: 100%;
    margin: 0
}

body {
    font-family: 'Montserrat', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    -webkit-font-smoothing: antialiased;

    /* layered nebula + base */
    background:
        radial-gradient(800px circle at 12% 15%, var(--galactic-bg1) 0%, transparent 35%),
        radial-gradient(1000px circle at 88% 82%, var(--galactic-bg2) 0%, transparent 28%),
        linear-gradient(180deg, var(--bg), rgba(17, 17, 20, 0.95));
    background-color: var(--bg);
    position: relative;
    min-height: 100vh;
    overflow-x: hidden;
}

/* starfield overlay (subtle, animated twinkle) */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: var(--star-opacity);
    background-image:
        radial-gradient(1px 1px at 8% 12%, var(--star-1) 50%, transparent 51%),
        radial-gradient(1px 1px at 22% 34%, var(--star-2) 50%, transparent 51%),
        radial-gradient(1px 1px at 36% 8%, var(--star-1) 50%, transparent 51%),
        radial-gradient(1px 1px at 54% 24%, var(--star-2) 50%, transparent 51%),
        radial-gradient(1px 1px at 70% 58%, var(--star-1) 50%, transparent 51%),
        radial-gradient(1px 1px at 86% 40%, var(--star-2) 50%, transparent 51%);
    mix-blend-mode: screen;
    animation: twinkle 6s ease-in-out infinite;
}

@keyframes twinkle {
    0% {
        opacity: calc(var(--star-opacity) * 0.85);
        transform: translateY(0);
    }

    50% {
        opacity: calc(var(--star-opacity) * 1);
        transform: translateY(-2px);
    }

    100% {
        opacity: calc(var(--star-opacity) * 0.85);
        transform: translateY(0);
    }
}

@keyframes nebula {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(-3px, 4px) scale(1.02);
    }

    100% {
        transform: translate(0, 0) scale(1);
    }
}

/* Topbar */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px;
    background: var(--surface);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03)
}

header h1 {
    margin: 0;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.6px;
    text-transform: uppercase
}

.mode-switch {
    display: flex;
    gap: 8px
}

.mode-switch button {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.02);
    background: transparent;
    color: var(--muted);
    cursor: pointer
}

.mode-switch button.active {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text)
}

main {
    max-width: 1100px;
    margin: 28px auto;
    padding: 16px
}

/* Panels */
.panel {
    background: transparent
}

.teacher-grid {
    display: flex;
    gap: 28px
}

.left {
    flex: 1
}

.right {
    flex: 1
}

/* Inputs */
input,
textarea,
select,
button {
    font-family: inherit
}

input,
textarea {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 10px;
    color: var(--text)
}

input::placeholder,
textarea::placeholder {
    color: rgba(255, 255, 255, 0.28)
}

textarea {
    min-height: 80px
}

button {
    cursor: pointer
}

.import-card {
    margin-top: 16px;
    padding: 18px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), rgba(255, 255, 255, 0.008));
    border: 1px solid rgba(255, 255, 255, 0.02);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.import-left {
    flex: 1
}

.import-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px
}

.hidden-file {
    display: none
}

.import-btn {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.02);
    padding: 10px 14px;
    border-radius: 10px
}

.import-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6)
}

.import-btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none
}

/* import progress UI */
.import-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-bottom: 6px
}

.spinner {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 4px solid rgba(87, 84, 168, 0.08);
    border-top-color: var(--glow);
    animation: spin 1s linear infinite
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.progress-track {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 999px;
    overflow: hidden
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-strong);
    transition: width 240ms ease
}

.import-progress-text {
    min-width: 160px;
    text-align: right;
    font-size: 13px;
    color: var(--muted)
}

/* placeholder when no questions */
.questions-empty {
    padding: 28px;
    border-radius: 12px;
    border: 2px dashed rgba(255, 255, 255, 0.03);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.002), transparent);
    text-align: center
}

.questions-empty .qe-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px
}

.questions-empty .qe-sub {
    color: var(--muted)
}

/* small import/add buttons inside the placeholder */
.questions-empty .btn.import-btn {
    padding: 10px 14px
}

.questions-empty .btn {
    margin-left: 8px
}




.tests-list {
    list-style: none;
    padding: 0;
    margin: 12px 0;
}

.tests-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.005);
    border: 1px solid rgba(255, 255, 255, 0.02);
    margin-bottom: 12px;
    transition: transform .12s ease, box-shadow .12s ease
}

.tests-list li:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(2, 6, 23, 0.6)
}

.tests-list li .meta {
    font-size: 15px
}

.tests-list button {
    margin-left: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.02);
    background: transparent;
    color: var(--text)
}

/* Student exams list - nicer cards */
#studentTestsList {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding-left: 0
}

.tests-list-item {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.006), rgba(255, 255, 255, 0.002));
    border: 1px solid rgba(255, 255, 255, 0.02);
    max-width: 720px;
    box-shadow: 0 8px 30px rgba(2, 6, 23, 0.6);
}

.t-icon {
    width: 58px;
    height: 58px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: rgba(255, 255, 255, 0.02);
}

.t-body {
    flex: 1
}

.t-title {
    font-weight: 800;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 12px
}

.t-badge {
    background: var(--panel);
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 700;
    font-size: 12px
}

.t-desc {
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px
}

.t-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    min-width: 160px
}

.start-btn {
    min-width: 160px;
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 800;
    transition: transform .14s ease, box-shadow .14s ease;
    box-shadow: 0 8px 18px rgba(3, 8, 15, 0.35);
    position: relative;
    overflow: hidden;
}

.start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 40px rgba(3, 8, 15, 0.5);
}

.start-btn:active {
    transform: translateY(0) scale(.98);
}

.start-btn:focus {
    outline: none;
    box-shadow: 0 0 0 6px rgba(87, 84, 168, 0.12);
}

.start-btn.pressing,
.start-btn.pressing:active {
    transform: scale(.96);
    transition: transform .12s ease;
}

/* ripple element inside buttons */
.ripple {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: rgba(255, 255, 255, 0.12);
    pointer-events: none;
    animation: ripple 540ms cubic-bezier(.2, .8, .2, 1);
    mix-blend-mode: screen
}

@keyframes ripple {
    to {
        transform: translate(-50%, -50%) scale(12);
        opacity: 0;
    }
}

/* badge pulse for new tests */
@keyframes badgePulse {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.16);
    }

    70% {
        transform: scale(.98);
    }

    100% {
        transform: scale(1);
    }
}

.t-badge.pulse {
    animation: badgePulse 900ms cubic-bezier(.2, .8, .2, 1);
}

/* small highlight for newly added card */
.tests-list-item.new {
    box-shadow: 0 26px 80px rgba(2, 6, 23, 0.7);
}

/* Card micro-interactions */
.tests-list-item {
    transition: transform .16s ease, box-shadow .16s ease;
}

.tests-list-item:hover,
.tests-list-item:focus-within {
    transform: translateY(-6px);
    box-shadow: 0 22px 60px rgba(2, 6, 23, 0.62);
}

.t-icon {
    transition: transform .18s ease;
}

.tests-list-item:hover .t-icon,
.tests-list-item:focus-within .t-icon {
    transform: rotate(-6deg) scale(1.02);
}

.t-badge {
    transition: transform .12s ease, background .12s ease;
}

.tests-list-item:hover .t-badge {
    transform: translateY(-2px);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
}

@media(max-width:720px) {
    .tests-list-item {
        flex-direction: column;
        align-items: flex-start
    }

    .t-actions {
        width: 100%;
        flex-direction: row;
        justify-content: space-between
    }

    .start-btn {
        width: 48%
    }
}

.editor {
    margin-top: 18px;
    padding: 20px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.003), transparent);
    border: 1px solid rgba(255, 255, 255, 0.03);
    box-shadow: 0 8px 30px rgba(2, 6, 23, 0.7);
}

.hidden {
    display: none
}

/* Student card and question layout */
.card {
    background: linear-gradient(180deg, rgba(52, 52, 77, 0.35), rgba(34, 34, 42, 0.6));
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(87, 84, 168, 0.06);
    box-shadow: 0 12px 36px rgba(52, 52, 77, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(4px);
}

.card:before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: radial-gradient(400px circle at 10% 10%, rgba(87, 84, 168, 0.03), transparent 30%);
    pointer-events: none;
    z-index: 0;
}

.card * {
    position: relative;
    z-index: 2;
}

#examHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px
}

#examHeader h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700
}

#progressWrap {
    flex: 1;
    margin-left: 18px;
    height: 8px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 999px;
    overflow: hidden
}

#progressBar {
    height: 100%;
    width: 0;
    background: var(--accent-strong);
    border-radius: 999px
}

#qNav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px
}

.q-num {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    cursor: pointer
}

.q-num.answered {
    background: var(--success);
    color: #fff
}

.q-num.flagged {
    background: var(--flag);
    color: #000;
    font-weight: 800;
    box-shadow: 0 8px 22px rgba(255, 138, 61, 0.22);
    outline: none;
}

#qCard {
    position: relative;
    padding: 28px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.02);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.005), transparent);
    min-height: 220px;
}

/* Flag ribbon on top-right of question card */
#qCard.flagged::after {
    content: '⚑ Flagged';
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(180deg, rgba(255, 138, 61, 1), rgba(255, 138, 61, 0.9));
    color: #000;
    font-weight: 800;
    padding: 6px 10px;
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(255, 138, 61, 0.22);
    border: 1px solid rgba(255, 138, 61, 0.24);
    z-index: 10;
}

@media(max-width:980px) {
    #qCard.flagged::after {
        top: 8px;
        right: 8px;
        padding: 4px 8px;
        font-size: 13px
    }
}

/* Larger, card-like options */
.opt {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 18px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(255, 255, 255, 0.01);
    cursor: pointer;
    transition: transform .08s ease, box-shadow .08s ease, background .12s ease;
    outline: none;
}

.opt .badge {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    font-weight: 700;
    color: var(--muted);
}

.opt .label {
    flex: 1;
    color: var(--text);
    font-size: 18px;
}

.opt:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.6);
}

.opt:focus {
    box-shadow: 0 0 0 4px rgba(87, 84, 168, 0.08);
}

.opt.selected {
    border-color: rgba(87, 84, 168, 0.18);
    background: linear-gradient(180deg, rgba(87, 84, 168, 0.045), rgba(87, 84, 168, 0.015));
    box-shadow: 0 10px 30px rgba(87, 84, 168, 0.12);
}

/* Runner controls */
.runner-controls {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.5));
    border-top: 1px solid rgba(255, 255, 255, 0.02);
    margin-top: 12px;
}

.runner-controls .left,
.runner-controls .center,
.runner-controls .right {
    display: flex;
    gap: 12px;
    align-items: center
}

/* Header improvements */
#examHeader {
    padding: 18px 0;
}

#examHeader h3 {
    font-size: 20px;
}

#qCount {
    font-weight: 600;
}

/* Flag pill */
.flag-indicator {
    background: linear-gradient(180deg, rgba(255, 138, 61, 0.22), rgba(255, 138, 61, 0.08));
    color: #000;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 138, 61, 0.22);
    font-weight: 800;
    display: inline-block;
}

.flag-indicator.hidden {
    display: none !important;
}

.flag-indicator.small {
    padding: 4px 8px;
    font-size: 13px
}

/* small badge next to review */
.flag-count {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--flag);
    color: #000;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 138, 61, 0.28);
    font-weight: 900;
    margin-left: 8px;
    font-size: 14px;
    box-shadow: 0 10px 26px rgba(255, 138, 61, 0.18);
}

.flag-count.hidden {
    display: none !important;
}

.flag-count.small {
    padding: 4px 8px;
    font-size: 13px
}

/* Pulse animation for attention when count changes */
.flag-count.pulse {
    animation: pulseFlag 520ms ease;
}

@keyframes pulseFlag {
    0% {
        transform: scale(1);
        box-shadow: 0 10px 26px rgba(255, 138, 61, 0.18);
    }

    40% {
        transform: scale(1.12);
        box-shadow: 0 18px 40px rgba(255, 138, 61, 0.28);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 10px 26px rgba(255, 138, 61, 0.18);
    }
}

/* Make review section visually lighter and style review cards */
#reviewSection {
    margin-top: 18px;
    padding: 18px 18px 12px;
}

.review-section h2 {
    margin: 6px 0 18px;
    font-size: 28px;
    font-weight: 800;
}

.review-grid {
    display: flex;
    gap: 18px;
    align-items: flex-start;
}

@media(max-width:980px) {
    .review-grid {
        flex-direction: column;
    }
}

.review-card {
    flex: 1;
    padding: 16px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.008), rgba(255, 255, 255, 0.004));
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.rc-header {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 12px;
    color: var(--text)
}

.rc-header .rc-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
}

.review-card.flagged .rc-icon {
    background: linear-gradient(180deg, rgba(255, 138, 61, 0.12), rgba(255, 138, 61, 0.06));
    color: var(--flag);
}

.review-card.unanswered .rc-icon {
    background: linear-gradient(180deg, rgba(255, 0, 0, 0.06), rgba(255, 0, 0, 0.02));
    color: var(--danger);
}

.rc-list {
    display: flex;
    flex-direction: column;
    gap: 12px
}

.rc-item {
    padding: 12px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.12);
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    border: 1px solid rgba(255, 255, 255, 0.02)
}

.rc-item-title {
    font-weight: 700;
    min-width: 56px
}

.rc-item-snippet {
    flex: 1;
    color: var(--muted);
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.18);
    margin-right: 12px
}

.review-card.flagged .rc-item-snippet {
    background: rgba(255, 138, 61, 0.06);
    color: #f3e6d9
}

.review-submit {
    text-align: center;
    margin-top: 18px
}

.review-submit .btn {
    min-width: 260px;
    padding: 12px 20px;
    font-size: 16px;
    border-radius: 12px
}


/* Review modal tweaks */
#reviewModal .modal-content {
    max-width: 820px;
    width: calc(100% - 48px);
    max-height: 80vh;
    overflow: hidden;
    padding: 20px;
}

#reviewModal .modal-content h3 {
    font-size: 20px;
    margin: 0 0 12px;
    font-weight: 800;
}

#reviewModalList {
    max-height: calc(80vh - 150px);
    overflow: auto;
    padding-right: 8px;
    padding-left: 4px;
}

/* custom scrollbar for easier scanning */
#reviewModalList::-webkit-scrollbar {
    width: 10px;
}

#reviewModalList::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

#reviewModalList::-webkit-scrollbar-track {
    background: transparent;
}

/* rows in modal */
.review-modal-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.review-modal-row .rm-left {
    flex: 1;
    font-weight: 700;
    font-size: 15px;
    line-height: 1.25;
    color: var(--text);
}

.review-modal-row .rm-status {
    white-space: nowrap;
    margin-left: 12px;
    color: var(--muted);
    align-self: flex-start;
}

.review-modal-row .rm-go {
    align-self: flex-start;
    margin-left: 8px;
}

/* small adjustments to modal action buttons */
.modal .modal-content .btn.small {
    padding: 8px 10px;
}

.modal .modal-content .btn.primary {
    min-width: 140px;
    padding: 10px 14px;
    font-weight: 700;
    border-radius: 10px;
}

/* keep backward compatibility for previous row selector */
#reviewModal .row {
    display: block;
}

@media(max-width:980px) {
    .opt .label {
        font-size: 16px
    }

    .opt .badge {
        width: 44px;
        height: 44px
    }

    .runner-controls {
        padding: 12px
    }
}

#qTextDisplay {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 18px
}

#qOptions {
    display: flex;
    flex-direction: column;
    gap: 12px
}

.opt {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.02);
    background: transparent;
    cursor: pointer
}

.opt .badge {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.02);
    font-weight: 700;
    color: var(--muted)
}

.opt .label {
    flex: 1;
    color: var(--text);
    font-size: 16px
}

.opt.selected {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.01)
}

.opt.selected .badge {
    background: var(--text);
    color: #000
}

.q-controls {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-top: 22px
}

.q-controls .nav {
    display: flex;
    gap: 12px
}

.btn {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.02);
    background: transparent;
    color: var(--text)
}

.btn.primary {
    background: linear-gradient(180deg, var(--palette-3), var(--palette-2));
    color: #fff;
    font-weight: 700;
    border: none;
    box-shadow: 0 8px 28px rgba(87, 84, 168, 0.24);
    padding: 12px 18px;
    border-radius: 12px;
}

.btn.danger {
    background: transparent;
    border-color: rgba(255, 0, 50, 0.08);
    color: var(--danger)
}

/* === FIX: Ensure modal is hidden by default and correctly shown by JS === */
.modal {
    position: fixed;
    inset: 0;
    /* CRITICAL FIX: Hide by default */
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
}

/* Show the modal only when the 'hidden' class is removed by JavaScript */
.modal:not(.hidden) {
    display: flex;
}

/* ======================================================================== */

.modal .modal-content {
    position: relative;
    background: var(--panel);
    padding: 18px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.02);
    max-width: 520px
}

.modal .modal-content input.large {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(255, 255, 255, 0.01);
    color: var(--text);
    width: 100%;
}

.modal .modal-content input.large:focus {
    outline: none;
    box-shadow: 0 6px 20px rgba(87, 84, 168, 0.12);
    border-color: rgba(87, 84, 168, 0.12);
}

.modal .modal-content .close {
    position: absolute;
    right: 10px;
    top: 10px;
    padding: 6px 8px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--muted);
}

.modal.hidden {
    display: none !important;
}

/* Results dashboard styling (stronger colors / single-column list) */
.results-dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 18px 0 28px;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.results-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 800
}

.results-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px
}

.results-perc {
    font-size: 64px;
    font-weight: 900;
    color: var(--text);
    line-height: 1
}

.results-meta {
    font-size: 14px;
    color: var(--muted)
}

.needs-review {
    margin-top: 6px;
    background: #ff4d4f;
    color: #fff;
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: 800
}

.results-filters {
    display: flex;
    gap: 10px;
}

.filter-btn {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.02);
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer
}

.filter-btn.active {
    background: var(--panel);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

/* Force vertical order: single column for all viewports */
.results-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 8px
}

.result-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 18px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.004), rgba(255, 255, 255, 0.002));
    border: 1px solid rgba(255, 255, 255, 0.02);
    transition: transform .12s ease, box-shadow .12s ease
}

.result-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 48px rgba(2, 6, 23, 0.6)
}

/* Left status capsule */
.rc-left {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-weight: 900;
    color: #fff;
    font-size: 18px
}

.result-card[data-ok='1'] {
    background: linear-gradient(180deg, rgba(20, 80, 40, 0.08), rgba(20, 80, 40, 0.03));
    border-left: 6px solid rgba(34, 197, 94, 0.9)
}

.result-card[data-ok='1'] .rc-left {
    background: rgba(34, 197, 94, 0.95);
    color: #06260e
}

.result-card[data-ok='0'] {
    background: linear-gradient(180deg, rgba(80, 20, 20, 0.04), rgba(80, 20, 20, 0.02));
    border-left: 6px solid rgba(255, 77, 77, 0.95)
}

.result-card[data-ok='0'] .rc-left {
    background: rgba(255, 77, 77, 0.95);
    color: #3b0303
}

.rc-body {
    flex: 1
}

.rc-q {
    font-weight: 800;
    margin-bottom: 8px;
    font-size: 15px
}

.rc-meta {
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 13px
}

.rc-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap
}

.option-tile {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    min-width: 160px;
    max-width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.02);
    transition: transform .12s ease, box-shadow .12s ease
}

.option-tile:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(2, 6, 23, 0.6)
}

.option-tile .ot-badge {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    color: var(--text);
    background: rgba(0, 0, 0, 0.06)
}

.option-tile .ot-label {
    color: var(--muted);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

/* Stronger correct / incorrect visuals */
.option-tile.correct {
    background: linear-gradient(180deg, rgba(34, 197, 94, 0.16), rgba(34, 197, 94, 0.08));
    border-color: rgba(34, 197, 94, 0.22);
    color: #04250f
}

.option-tile.correct .ot-badge {
    background: rgba(34, 197, 94, 0.95);
    color: #05260e
}

.option-tile.incorrect {
    background: linear-gradient(180deg, rgba(255, 77, 77, 0.14), rgba(255, 77, 77, 0.06));
    border-color: rgba(255, 77, 77, 0.22);
    color: #3b0303
}

.option-tile.incorrect .ot-badge {
    background: rgba(255, 77, 77, 0.95);
    color: #3b0303
}

.option-tile.selected {
    background: linear-gradient(180deg, rgba(87, 84, 168, 0.1), rgba(87, 84, 168, 0.04));
    border-color: rgba(87, 84, 168, 0.12);
    box-shadow: 0 10px 36px rgba(87, 84, 168, 0.12);
    color: #eaf0ff;
}

.results-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 12px
}

/* highlight in review modal when Go is used */
.review-modal-row.highlight {
    outline: 3px solid rgba(255, 193, 7, 0.16);
    background: linear-gradient(180deg, rgba(255, 193, 7, 0.03), transparent);
}

footer {
    padding: 18px;
    text-align: center;
    color: var(--muted);
    font-size: 13px
}

/* --- Larger inputs and aesthetic buttons for teacher UI --- */
input.large,
textarea.large {
    padding: 16px;
    border-radius: 12px;
    font-size: 16px
}

button.large {
    padding: 12px 18px;
    border-radius: 12px
}

/* Editor question styles */
.question-block {
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.02);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.002), transparent);
    margin-bottom: 12px
}

.question-block .q-header {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 8px
}

.question-block .large {
    min-height: 120px;
    padding: 16px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.02);
    background: rgba(255, 255, 255, 0.01)
}

.answer-block .label {
    margin: 12px 0 8px;
    font-weight: 600;
    color: var(--muted)
}

.option-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    padding: 6px;
    border-radius: 10px
}

.option-row.correct {
    background: rgba(87, 84, 168, 0.06);
    border: 1px solid rgba(87, 84, 168, 0.12)
}

.option-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    min-width: 90px
}

.option-row input[type="radio"] {
    width: 18px;
    height: 18px
}

.option-row .opt-letter {
    display: inline-block;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--muted)
}

.option-row input[type="text"],
.option-row input[type="search"],
.option-row input[type="email"],
.option-row input[type="url"],
.option-row input[type="password"],
.option-row input[type="number"],
.option-row input[type="tel"] {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text);
    transition: box-shadow .12s ease, border-color .12s ease
}

.option-row input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-strong);
    box-shadow: 0 6px 20px rgba(87, 84, 168, 0.12)
}

.option-row input[type="text"]:hover {
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 6px 20px rgba(2, 6, 23, 0.6)
}

/* Save exam floating button */
#saveExam {
    position: fixed;
    right: 26px;
    bottom: 26px;
    z-index: 60;
    padding: 14px 18px;
    border-radius: 12px;
    background: var(--accent-strong);
    color: #000;
    border: none;
    box-shadow: 0 6px 18px rgba(3, 8, 15, 0.6);
    font-weight: 700
}

/* Button hover and focus */
.btn {
    transition: all .16s ease
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35)
}

.btn.primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 48px rgba(87, 84, 168, 0.22);
    filter: brightness(1.02);
}

/* Button sizes */
.btn.small {
    padding: 6px 10px;
    border-radius: 8px
}

.btn.medium {
    padding: 10px 14px;
    border-radius: 10px
}

.btn.large {
    padding: 12px 18px;
    border-radius: 12px
}

/* Focus and accessibility */
.btn:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(87, 84, 168, 0.12)
}

/* Toast */
#toast {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 90px;
    background: rgba(20, 22, 24, 0.9);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    box-shadow: 0 8px 30px rgba(2, 6, 23, 0.7);
    z-index: 200;
    display: none
}

.btn.disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none
}

/* make exam nav buttons consistent */
#qCard .btn {
    padding: 10px 14px;
    border-radius: 10px
}

@media(max-width:980px) {
    .teacher-grid {
        flex-direction: column
    }

    .top-controls input {
        min-width: 150px
    }
}