:root {
    --ink: #172033;
    --muted: #667085;
    --line: #e6eaf0;
    --brand: #2563eb;
    --brand-dark: #1e40af;
    --success: #168653;
    --danger: #c2413a;
    --surface: #ffffff;
    --soft: #f5f7fb;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--soft);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { text-decoration: none; }
h1, h2, h3 { letter-spacing: 0; }

.landing {
    min-height: 100vh;
    color: #fff;
    background: linear-gradient(135deg, rgba(18, 31, 59, .96), rgba(37, 99, 235, .88)), url('../images/exam-bg.svg') center/cover;
}
.home-auth {
    min-height: 100vh;
    display: grid;
    place-items: start end;
    padding: 15vh 13.8vw 24px 24px;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, .08), rgba(222, 225, 255, .2)),
        url('../images/login-bg.jpg') center/cover no-repeat;
}
.home-auth-card {
    width: min(100%, 560px);
    padding: 28px;
    border-radius: 18px;
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 22px 55px rgba(18, 33, 62, .14);
    backdrop-filter: blur(6px);
    color: #0b2a64;
}
.home-logo {
    width: 92px;
    height: 72px;
    object-fit: contain;
    margin-bottom: 12px;
}
.home-auth-card h1 {
    font-size: clamp(1.9rem, 4vw, 3rem);
    line-height: 1.05;
    font-weight: 850;
}
.home-auth-card p { color: #475467; font-size: 1.05rem; }
.home-auth-card small { display: block; margin-top: 14px; color: #667085; }
.home-auth-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}
.home-auth-actions .btn {
    min-width: 160px;
    min-height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 800;
}
.home-auth-actions .btn-primary {
    border: 0;
    background: #0b2a64;
}
.home-auth-actions .btn-primary:hover { background: #123a85; }
.home-auth-actions .btn-light {
    color: #0b2a64;
    border: 1px solid #d8dde8;
    background: #fff;
}
.home-auth-actions .btn-outline-light {
    color: #0b2a64;
    border-color: #c9d2e3;
}
.hero { padding: 70px 12px 90px; }
.hero h1 { max-width: 760px; font-size: clamp(2.2rem, 6vw, 4.6rem); line-height: 1.02; font-weight: 800; }
.hero .lead { color: rgba(255, 255, 255, .82); max-width: 720px; }
.hero-panel, .auth-card, .panel, .subject-card, .test-question, .review-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(25, 35, 55, .08);
}
.hero-panel { color: var(--ink); padding: 24px; }
.question-card { background: #f8fafc; border-radius: 8px; padding: 18px; }
.option { padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; margin-top: 10px; }
.option.active { border-color: var(--brand); background: #eaf1ff; }
.eyebrow { text-transform: uppercase; font-size: .75rem; font-weight: 800; letter-spacing: .08em; }

.auth-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at top left, #dbeafe, transparent 34%), #f8fafc;
}
.auth-card { width: min(100%, 430px); padding: 30px; }
.auth-card h1 { font-size: 2rem; font-weight: 800; }
.auth-card p { color: var(--muted); }
.branded-auth {
    min-height: 100vh;
    place-items: start end;
    padding: 15vh 13.8vw 24px 24px;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, .08), rgba(222, 225, 255, .2)),
        url('../images/login-bg.jpg') center/cover no-repeat;
}
.branded-auth .auth-card {
    width: min(100%, 455px);
    padding: 46px 44px 40px;
    border: 0;
    border-radius: 18px;
    background: rgba(255, 255, 255, .88);
    box-shadow: 0 22px 55px rgba(18, 33, 62, .14);
    backdrop-filter: blur(6px);
}
.branded-auth .auth-card h1 {
    margin-bottom: 6px;
    text-align: center;
    color: #0f2757;
    font-size: 2.1rem;
}
.branded-auth .auth-card p {
    margin-bottom: 28px;
    text-align: center;
}
.auth-field {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 0 18px;
    border: 1px solid #d8dde8;
    border-radius: 8px;
    background: rgba(255, 255, 255, .72);
}
.auth-field span {
    width: 24px;
    color: #606978;
    font-size: 1.3rem;
    line-height: 1;
    text-align: center;
}
.auth-field .form-control {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    font-size: 1.03rem;
}
.branded-auth .btn-primary {
    min-height: 64px;
    border: 0;
    border-radius: 8px;
    background: #0b2a64;
    font-size: 1.05rem;
    font-weight: 800;
}
.branded-auth .btn-primary:hover { background: #123a85; }
.branded-auth a { color: #0b2a64; font-weight: 700; }
.auth-logo {
    display: block;
    width: 92px;
    height: 72px;
    object-fit: contain;
    margin: 0 auto 12px;
}
.admin-corner-link,
.teacher-corner-link {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 5;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    color: #0b2a64;
    background: rgba(255,255,255,.9);
    border: 1px solid #d8dde8;
    box-shadow: 0 14px 30px rgba(18, 33, 62, .16);
}
.teacher-corner-link {
    right: 72px;
}
.admin-corner-link:hover,
.teacher-corner-link:hover { color: #123a85; background: #fff; }
.question-image {
    display: block;
    max-width: min(100%, 680px);
    max-height: 360px;
    object-fit: contain;
    margin: 12px 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.subject-check-list {
    display: grid;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.subject-check-list label {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 0;
}
.pwa-install-prompt {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 2500;
    width: min(92vw, 390px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .22);
}
.pwa-install-prompt[hidden] {
    display: none;
}
.pwa-install-prompt strong,
.pwa-install-prompt span {
    display: block;
}
.pwa-install-prompt span {
    color: var(--muted);
    font-size: .9rem;
}
.auth-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 18px;
    font-size: .95rem;
}
.local-reset-link {
    margin-top: 18px;
    padding: 12px;
    border: 1px dashed #94a3b8;
    border-radius: 8px;
    background: rgba(255, 255, 255, .75);
    word-break: break-all;
}
.local-reset-link a { display: block; margin-top: 6px; font-size: .85rem; }

.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
    position: sticky;
    top: 0;
    width: 255px;
    min-height: 100vh;
    padding: 22px;
    background: #111827;
    color: #fff;
}
.sidebar-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1200;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: #0f172a;
    font-size: 1.25rem;
    line-height: 1;
}
body.sidebar-collapsed .site-sidebar {
    display: none;
}
body.sidebar-collapsed .admin-shell,
body.sidebar-collapsed .student-shell {
    display: block;
}
body.sidebar-collapsed .admin-main,
body.sidebar-collapsed .student-main {
    padding-left: 72px;
}
.admin-sidebar .nav {
    padding-top: 2px;
}
.admin-sidebar .brand { display: block; color: #fff; font-size: 1.3rem; font-weight: 800; margin-bottom: 22px; }
.admin-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, .75);
    border-radius: 8px;
    padding: 11px 13px;
}
.admin-sidebar .nav-link.active, .admin-sidebar .nav-link:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.admin-main { flex: 1; padding: 28px; min-width: 0; }
.topbar, .dashboard-head, .test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}
.topbar h1, .dashboard-head h1, .test-header h1 { margin: 0; font-weight: 800; }
.topbar p, .dashboard-head p, .test-header p, .subject-card p { color: var(--muted); margin-bottom: 0; }
.panel { padding: 20px; }
.panel h2, .subject-card h2, .test-question h2, .review-card h2 { font-size: 1.15rem; font-weight: 750; }
.stat-card {
    padding: 20px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
}
.stat-card span { color: var(--muted); display: block; }
.stat-card strong { display: block; font-size: 2rem; line-height: 1.1; }
.question-preview { max-width: 380px; }
.table td, .table th { vertical-align: middle; }
.course-row-title {
    display: flex;
    align-items: center;
    gap: 12px;
}
.course-row-title img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--line);
    background: #fff;
}
.course-row-vertical {
    display: grid;
    justify-items: center;
    text-align: center;
}
.course-row-vertical img {
    width: 74px;
    height: 74px;
}
.compact-course-card {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 10px;
}
.course-check-list {
    max-height: 170px;
    overflow: auto;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.user-nav { background: #16213e; }
.user-nav .navbar-brand, .user-nav .nav-link { color: #fff; }
.student-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 255px minmax(0, 1fr);
    background: #f4f7fb;
}
.student-sidebar {
    position: sticky;
    top: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    color: #fff;
    background: linear-gradient(180deg, #071a32, #0d2b4c);
}
.student-brand {
    display: block;
    padding: 12px 14px 18px;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 850;
}
.student-nav {
    display: grid;
    gap: 6px;
}
.student-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 8px;
    color: rgba(255,255,255,.82);
    font-weight: 700;
}
.student-nav-link span {
    width: 22px;
    text-align: center;
}
.nav-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    min-width: 24px;
    padding: 2px 7px;
    border-radius: 999px;
    color: #fff;
    background: #dc3545;
    font-size: .78rem;
    text-align: center;
}
.student-nav-link:hover,
.student-nav-link.active {
    color: #fff;
    background: #0d6efd;
}
.logout-link {
    margin-top: auto;
}
.student-main {
    min-width: 0;
    padding: 24px 30px;
}
.student-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}
.student-topbar h1 {
    margin: 0;
    font-weight: 850;
}
.student-topbar p {
    color: var(--muted);
    margin-bottom: 0;
}
.student-panel {
    padding: 20px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(25, 35, 55, .06);
}
.student-panel h2 {
    font-size: 1.2rem;
    font-weight: 850;
}
.student-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.student-stat-card {
    padding: 18px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.student-stat-card span {
    display: block;
    color: var(--muted);
}
.student-stat-card strong {
    display: block;
    margin-top: 6px;
    font-size: 2rem;
    line-height: 1;
}
.student-course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}
.student-course-tile {
    min-height: 150px;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 10px;
    padding: 18px;
    color: var(--ink);
    text-align: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(25, 35, 55, .06);
}
.student-course-tile:hover {
    color: var(--ink);
    border-color: #b9c7df;
}
.student-course-tile img {
    width: 78px;
    height: 78px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}
.student-course-tile strong {
    font-weight: 850;
}
.student-course-tile small {
    color: var(--muted);
}
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.narrow-panel {
    max-width: 520px;
}
.doubt-list {
    display: grid;
    gap: 14px;
}
.doubt-thread {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}
.doubt-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.doubt-head small {
    display: block;
    color: var(--muted);
}
.doubt-message {
    padding: 12px;
    margin-top: 10px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
}
.doubt-message.admin-reply {
    background: #eef6ff;
    border-color: #cfe1ff;
}
.doubt-message p {
    margin: 6px 0;
}
.inbox-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 16px;
}
.inbox-list-panel {
    padding: 12px;
    max-height: calc(100vh - 220px);
    overflow: auto;
}
.inbox-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}
.inbox-thread-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 0;
    margin: 0;
    list-style: none;
}
.inbox-thread-list li {
    display: block;
    width: 100%;
}
.inbox-list {
    max-height: calc(100vh - 220px);
    overflow: auto;
}
.inbox-thread {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px;
    border-radius: 8px;
    color: var(--ink);
    border: 1px solid var(--line);
    background: #fff;
}
.inbox-thread-head {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}
.inbox-thread-head strong {
    min-width: 0;
}
.inbox-thread:hover,
.inbox-thread.active {
    color: var(--ink);
    border-color: #b9c7df;
    background: #f8fbff;
}
.inbox-thread small {
    color: var(--muted);
}
.subject-card { min-height: auto; padding: 18px; }
.section-title {
    margin: 0 0 14px;
    font-size: 1.35rem;
    font-weight: 800;
}
.course-card {
    min-height: 0;
    display: grid;
    justify-items: center;
    gap: 10px;
    padding: 18px 14px;
    text-align: center;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(25, 35, 55, .08);
}
.course-card:hover { color: var(--ink); border-color: #b9c7df; transform: translateY(-1px); }
.course-card img {
    width: 74px;
    height: 74px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}
.course-card h3 { font-size: 1.05rem; font-weight: 850; margin: 0; }
.course-card p, .course-card small { color: var(--muted); margin: 0; }
.course-card.compact-course p, .course-card.compact-course small { display: none; }
.empty-state { color: var(--muted); }
.course-hero {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 26px;
    margin-bottom: 20px;
    color: #fff;
    background: linear-gradient(135deg, #12355b, #2563eb);
    border-radius: 8px;
}
.course-hero img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 8px;
    background: #fff;
}
.course-hero h1 { margin: 0; font-weight: 850; }
.course-hero p { margin-bottom: 0; color: rgba(255,255,255,.82); }
.subject-section { margin-bottom: 18px; }
.subject-section-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}
.collapse-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
}
.collapse-toggle h2,
.collapse-toggle h3 { margin-bottom: 4px; }
.collapse-toggle span {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--brand);
    background: #eaf1ff;
    transition: transform .18s ease;
}
.collapse-toggle[aria-expanded="true"] > span { transform: rotate(180deg); }
.subject-toggle { margin-bottom: 0; }
.subject-toggle[aria-expanded="true"] { margin-bottom: 12px; }
.subject-section h2 { font-weight: 800; margin-bottom: 4px; }
.subject-section p, .class-row p { color: var(--muted); margin-bottom: 0; }
.class-list { display: grid; gap: 10px; }
.chapter-block {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    margin-top: 12px;
}
.chapter-block h3 {
    margin: 0 0 4px;
    font-size: 1.05rem;
    font-weight: 850;
}
.chapter-block > p, .chapter-toggle p { color: var(--muted); margin-bottom: 0; }
.chapter-toggle[aria-expanded="true"] { margin-bottom: 12px; }
.class-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}
.class-row h3 { margin: 0 0 4px; font-size: 1rem; font-weight: 800; }
.class-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}
.video-panel { padding: 16px; }
.video-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 8px;
    background: #050816;
}
.video-wrap iframe {
    width: 100%;
    height: 100%;
    border: 0;
}
.phone-watermark {
    position: absolute;
    z-index: 3;
    pointer-events: none;
    max-width: 70%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    padding: 7px 10px;
    border-radius: 8px;
    color: rgba(255,255,255,.78);
    background: rgba(15,23,42,.42);
    font-weight: 800;
    transition: opacity .3s ease;
}
.phone-watermark.visible { opacity: 1; }
.test-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 22px; }
.test-grid .btn { display: flex; justify-content: space-between; align-items: center; }
.test-grid small { color: inherit; opacity: .75; }
.test-grid-wide { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.test-series-icon {
    width: 76px;
    height: 76px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, #12355b, #2563eb);
    font-size: 2rem;
    font-weight: 850;
}

.timer-pill {
    color: #fff;
    background: rgba(255, 255, 255, .12);
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 800;
}
.progress-box { min-width: 190px; }
.test-question { padding: 22px; margin-bottom: 18px; }
.question-meta {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: .9rem;
    margin-bottom: 10px;
}
.answer-option {
    display: flex;
    gap: 12px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 10px;
    cursor: pointer;
}
.answer-option:has(input:checked) { border-color: var(--brand); background: #eaf1ff; }
.sticky-submit {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: end;
    padding: 14px 0;
    background: linear-gradient(transparent, var(--soft) 28%);
}
.result-hero {
    padding: 26px;
    color: #fff;
    background: linear-gradient(135deg, #12355b, #2563eb);
    border-radius: 8px;
    margin-bottom: 20px;
}
.result-summary-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(15, 23, 42, .62);
}
.result-summary-box {
    width: min(100%, 420px);
    padding: 24px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .25);
}
.result-summary-box h2 {
    margin-bottom: 18px;
    font-size: 1.35rem;
}
.result-summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
.result-summary-stats div {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: center;
}
.result-summary-stats span {
    display: block;
    color: var(--muted);
    font-size: .78rem;
}
.result-summary-stats strong {
    display: block;
    margin-top: 4px;
    font-size: 1.15rem;
}
.question-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(15, 23, 42, .62);
}
.question-modal-box {
    width: min(100%, 980px);
    max-height: 88vh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 22px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .25);
}
.question-modal-list {
    overflow-y: auto;
    padding-right: 8px;
}
.review-card { padding: 22px; margin-bottom: 16px; border-left: 5px solid var(--line); }
.review-card.correct { border-left-color: var(--success); }
.review-card.wrong { border-left-color: var(--danger); }
.review-option { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fff; }
.review-option.right { border-color: var(--success); background: #eaf8f0; }
.review-option.picked-wrong { border-color: var(--danger); background: #fff1f0; }
.answer-line { margin-top: 14px; font-size: .95rem; }
.answer-line span { margin-left: 14px; }
.explanation { color: var(--muted); margin: 10px 0 0; }
.exam-shell {
    min-height: 100vh;
    background: #eef3f5;
}
.exam-form {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
}
.exam-topbar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}
.exam-topbar strong {
    display: inline-block;
    padding: 7px 14px;
    color: #fff;
    background: #13aeca;
    text-transform: uppercase;
}
.exam-topbar span {
    margin-left: 8px;
    font-weight: 700;
}
.exam-instruction {
    display: grid;
    gap: 2px;
    padding: 4px 10px;
    border: 1px solid #9bd0d8;
    font-size: .78rem;
}
.exam-instruction span {
    margin: 0;
    color: #374151;
    font-weight: 700;
}
.exam-body {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
}
.exam-question-area {
    min-width: 0;
    padding: 16px;
    background: #fff;
    border-right: 1px solid var(--line);
}
.exam-question {
    display: none;
    min-height: 58vh;
    box-shadow: none;
}
.exam-question.active {
    display: block;
}
.exam-actions {
    display: flex;
    justify-content: center;
    gap: 22px;
    margin-top: 20px;
}
.exam-actions .btn {
    min-width: 112px;
    color: #fff;
    background: #13aeca;
    border-color: #13aeca;
    font-weight: 800;
}
.exam-palette {
    padding: 12px;
    background: #f8fbfc;
    overflow: auto;
}
.exam-palette h2 {
    font-size: 1rem;
    font-weight: 800;
}
.palette-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 10px;
}
.palette-btn {
    min-height: 34px;
    border: 1px solid #b8c5d0;
    border-radius: 4px;
    background: #fff;
    font-weight: 700;
}
.palette-btn.active {
    outline: 2px solid #0ea5e9;
}
.palette-btn.answered, .legend-dot.answered { background: #32e132; }
.palette-btn.marked, .legend-dot.marked { background: #8b5cf6; color: #fff; }
.palette-btn.skipped, .legend-dot.skipped { background: #ef4444; color: #fff; }
.palette-btn.not-attended, .legend-dot.not-attended { background: #fff; }
.palette-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
    font-size: .78rem;
}
.legend-dot {
    width: 22px;
    height: 22px;
    display: inline-block;
    margin-right: 6px;
    border: 1px solid #b8c5d0;
    vertical-align: middle;
}

@media (max-width: 900px) {
    .admin-shell { display: block; }
    .admin-sidebar { position: relative; width: 100%; min-height: auto; }
    .admin-sidebar .nav { flex-direction: row !important; overflow-x: auto; }
    .admin-main { padding: 18px; }
    .student-shell { display: block; }
    .student-sidebar {
        position: relative;
        min-height: auto;
    }
    .student-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .logout-link { margin-top: 8px; }
    .student-main { padding: 18px; }
    .student-stats { grid-template-columns: 1fr; }
    .inbox-layout { grid-template-columns: 1fr; }
    .student-course-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .table-responsive { overflow-x: auto; }
    .exam-body { grid-template-columns: 1fr; }
    .exam-palette { order: -1; }
    .exam-topbar { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
    body { font-size: 15px; }
    .topbar, .dashboard-head, .test-header { display: block; }
    .topbar .btn, .dashboard-head .btn { margin-top: 12px; }
    .hero { padding-top: 42px; }
    .auth-card, .panel, .subject-card, .test-question, .review-card { padding: 16px; }
    .branded-auth {
        place-items: center;
        padding: 24px;
        background-position: 42% center;
    }
    .branded-auth .auth-card {
        padding: 30px 22px;
        border-radius: 14px;
    }
    .home-auth {
        place-items: center;
        padding: 24px;
        background-position: 42% center;
    }
    .home-auth-actions {
        flex-direction: column;
    }
    .home-auth-card { width: min(100%, 380px); padding: 22px; }
    .home-auth-actions .btn { width: 100%; }
    .course-hero, .class-row { display: block; }
    .course-card img, .course-hero img { margin-bottom: 12px; }
    .class-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        justify-content: stretch;
        margin-top: 12px;
    }
    .class-actions .btn, .class-actions form, .class-actions form .btn { width: 100%; }
    .student-course-grid { grid-template-columns: 1fr; }
    .student-nav { grid-template-columns: 1fr; }
    .student-nav-link, .admin-sidebar .nav-link { min-height: 44px; }
    .admin-sidebar .nav { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-sidebar .nav-link { white-space: normal; }
    .course-hero img { width: 84px; height: 84px; }
    .course-hero h1, .student-topbar h1, .dashboard-head h1, .topbar h1 { font-size: 1.55rem; }
    .d-flex.gap-2, form.d-flex { flex-wrap: wrap; }
    form.d-flex .form-select, form.d-flex .form-control { min-width: 180px; }
    .test-grid { grid-template-columns: 1fr; }
    .answer-line span { display: block; margin-left: 0; margin-top: 4px; }
    .sticky-submit .btn { width: 100%; }
    .exam-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
    .palette-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 430px) {
    .admin-main, .student-main { padding: 12px; }
    .panel, .student-panel { padding: 14px; }
    .admin-sidebar, .student-sidebar { padding: 14px; }
    .admin-sidebar .nav { grid-template-columns: 1fr; }
    .class-actions { grid-template-columns: 1fr; }
}
