/**
 * AUTOGRADING AI - Next-Gen UI/UX Responsive Engine (Prototype V2 Architecture)
 * Standards: WCAG 2.1 AA, B2B Pedagogical Copywriting, Controller Delegation Pattern.
 * File size limit: <= 800 lines hard ceiling.
 */

/* ================= APP: TOKENS ================= */
:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #edf1f6;
  --border: #e2e8f0;
  --border-strong: #cdd6e2;
  --text: #0b1b33;
  --muted: #53637b;
  --subtle: #8592a6;
  --primary: #00c5df;
  --primary-hover: #00b3cb;
  --primary-ink: #04263f;
  --primary-text: #007a8f;
  --primary-soft: #e2f8fb;
  --navy: #082850;
  --success: #11804a;
  --success-bg: #e6f6ed;
  --success-dot: #1fb26b;
  --warning: #965700;
  --warning-bg: #fff3d9;
  --warning-dot: #f0a20b;
  --danger: #c22a2a;
  --danger-bg: #fdeceb;
  --danger-dot: #e5484d;
  --info: #2459c4;
  --info-bg: #e9f0fd;
  --info-dot: #3b7cf0;
  --t-ex: #1fb26b;
  --t-good: #3b7cf0;
  --t-avg: #f0a20b;
  --t-low: #e5484d;
  --t-none: #b3bfcf;
  --paper: #fffdf6;
  --paper-line: #e4ebf5;
  --ink: #1d3a8a;
  --pen: #d32f2f;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow-lg: 0 14px 36px rgba(16,24,40,.18);
}

[data-theme="dark"], html[data-theme="dark"], body.theme-dark {
  --bg: #061329;
  --surface: #0b1d3b;
  --surface-2: #0f2547;
  --surface-3: #142d56;
  --border: #1d385f;
  --border-strong: #2b4a7a;
  --text: #e8effa;
  --muted: #a3b4cd;
  --subtle: #7489aa;
  --primary-text: #45dcef;
  --primary-soft: rgba(0,197,223,.15);
  --success: #4fd494;
  --success-bg: rgba(31,178,107,.16);
  --warning: #f6c453;
  --warning-bg: rgba(240,162,11,.17);
  --danger: #ff8085;
  --danger-bg: rgba(229,72,77,.17);
  --info: #86adff;
  --info-bg: rgba(59,124,240,.2);
  --t-none: #4a6286;
  --paper: #f7f4ec;
  --shadow-lg: 0 14px 36px rgba(0,0,0,.5);
}

/* ================= APP: SHELL & PRIMITIVES ================= */
.ag, .ag-shell-wrapper, .studio-canvas {
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (max-width: 767px) {
  .t-up { display: none !important; }
}
@media (min-width: 768px) and (max-width: 1199px) {
  .lt-d { display: block; }
}
@media (max-width: 767.98px) { .t-up { display: none !important; } }
@media (min-width: 768px) { .m-only { display: none !important; } }
@media (max-width: 1199.98px) { .d-up { display: none !important; } }
@media (min-width: 1200px) { .lt-d { display: none !important; } }

/* SpeedGrader Focus Mode & Active States */
body.speedgrader-active .studio-topbar, body.speedgrader-active .mobile-bottom-dock { display: none !important; }
body.speedgrader-active aside.ag-side, body.speedgrader-active aside.cockpit-sidebar { width: 72px !important; padding: 12px 8px !important; }
body.speedgrader-active aside.ag-side .lbl, body.speedgrader-active aside.cockpit-sidebar .lbl, body.speedgrader-active aside.ag-side .side-sec, body.speedgrader-active aside.cockpit-sidebar .side-sec, body.speedgrader-active aside.ag-side .full-only, body.speedgrader-active aside.cockpit-sidebar .full-only { display: none !important; }
body.speedgrader-active aside.ag-side .nav-item, body.speedgrader-active aside.cockpit-sidebar .nav-item { justify-content: center !important; padding: 0 !important; }


.ag-btn, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, opacity .15s;
  cursor: pointer;
}
.btn-primary { background: var(--primary) !important; color: var(--primary-ink) !important; border: none !important; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover) !important; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong) !important; color: var(--text) !important; }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { color: var(--muted); background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-icon { width: 38px; padding: 0; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 48px; font-size: 15px; border-radius: 12px; padding: 0 18px; }
.w-full { width: 100%; } .grow { flex: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--muted);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.chip.success { background: var(--success-bg); color: var(--success); }
.chip.warning { background: var(--warning-bg); color: var(--warning); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chip.info { background: var(--info-bg); color: var(--info); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); }
.field { height: 40px; width: 100%; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); padding: 0 12px; font-size: 14px; color: var(--text); }
.field:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.field { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; line-height: 1.5; }

.search { position: relative; display: flex; align-items: center; min-width: 0; }
.search svg { position: absolute; left: 12px; color: var(--subtle); pointer-events: none; z-index: 2; }
.search .field, .search input { padding-left: 36px !important; }
#exam-hub-search-box { background: transparent !important; border: none !important; box-shadow: none !important; padding: 0 !important; }
#input-search-exams { padding-left: 36px !important; border: 1px solid var(--border-strong) !important; border-radius: 10px !important; background: var(--surface) !important; color: var(--text) !important; height: 38px !important; width: 100% !important; }

.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 10px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.seg::-webkit-scrollbar { display: none; }
.seg button { height: 30px; padding: 0 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; border: none; cursor: pointer; background: transparent; flex-shrink: 0; max-width: 160px; text-overflow: ellipsis; overflow: hidden; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16,24,40,.12); }
[data-theme="dark"] .seg button.active { background: var(--surface-2); color: var(--text) !important; }

.av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--primary-soft); color: var(--primary-text); flex-shrink: 0; }
[data-theme="dark"] .av { background: rgba(0,197,223,.18) !important; color: #45dcef !important; }
.cb { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; background: var(--surface); color: var(--primary-ink); flex-shrink: 0; }
.cb.on { background: var(--primary); border-color: var(--primary); }
.cb.partial { background: var(--warning, #f59e0b); border-color: var(--warning, #f59e0b); color: #ffffff; }
.cbw { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; cursor: pointer; background: transparent; border: none; }
.ey { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.muted-s { font-size: 12px; color: var(--muted); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= APP: PAGE & SCREEN 1 (HUB) ================= */
.page { padding: 16px; max-width: 1260px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; width: 100%; box-sizing: border-box; }
@media (min-width: 768px) { .page { padding: 24px; gap: 20px; } }
.ph { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.ph h1 { font-size: 22px; font-weight: 750; letter-spacing: -.02em; line-height: 1.25; margin: 0; }
@media (min-width: 768px) { .ph h1 { font-size: 26px; } }
.ph p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.sec-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.sec-h h2 { font-size: 15px; font-weight: 700; margin: 0; }
.pad { padding: 14px 16px 16px; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 768px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; } }
.kpi { padding: 14px 16px; }
.kpi .k-l { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .k-v { font-size: 24px; font-weight: 750; margin-top: 6px; letter-spacing: -.02em; line-height: 1.1; }
.kpi .k-s { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi.warn .k-v { color: var(--warning); }

.hub-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) {
  .hub-grid { grid-template-columns: minmax(0, 1fr) 310px !important; align-items: start !important; gap: 18px !important; }
  .hub-grid .inbox { grid-column: 2 !important; grid-row: 1 !important; }
  .hub-grid .exams { grid-column: 1 !important; grid-row: 1 !important; }
}
@media (max-width: 1023.98px) {
  .hub-grid .exams { order: 1; }
  .hub-grid .inbox { order: 2; }
}

section.exams, .card.exams, #exam-hub-section.bento-exam-hub-card, #exam-hub-section.exam-hub-card { display: flex !important; flex-direction: column !important; padding: 0 !important; gap: 0 !important; border-radius: 14px !important; background: var(--surface) !important; border: 1px solid var(--border) !important; box-shadow: var(--shadow-sm) !important; overflow: hidden !important; }
#exam-hub-body, #exam-switcher-tray, .proto-exams-list-wrap { display: block !important; width: 100% !important; padding: 0 !important; margin: 0 !important; overflow: visible !important; }

.ii { display: flex; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--border); align-items: flex-start; }
.ii:first-of-type { border-top: 0; }
.ii-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.ii-ic.warning { background: var(--warning-bg); color: var(--warning); }
.ii-ic.danger { background: var(--danger-bg); color: var(--danger); }
.ii-ic.info { background: var(--info-bg); color: var(--info); }
.ii-ic.primary { background: var(--primary-soft); color: var(--primary-text); }
.ii-b { flex: 1; min-width: 0; }
.ii-b b { font-size: 13px; font-weight: 650; display: block; line-height: 1.35; }
.ii-b > span { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }
.ii-b .btn { margin-top: 10px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.toolbar .search { flex: 1 1 220px; }
@media (max-width: 767.98px) {
  .toolbar { flex-direction: column !important; align-items: stretch !important; padding: 12px !important; gap: 8px !important; }
  .toolbar .search, .toolbar .exam-hub-search-box-wrap { flex: 0 0 auto !important; width: 100% !important; max-width: 100% !important; box-sizing: border-box !important; }
  #exam-status-filters.seg { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 4px !important; width: 100% !important; overflow: visible !important; box-sizing: border-box !important; }
  #exam-status-filters.seg button { width: 100% !important; max-width: none !important; height: 34px !important; font-size: 12.5px !important; padding: 0 6px !important; }
}
.ex-head { display: none !important; }
div.ex-row { display: grid !important; gap: 10px 12px !important; padding: 14px 16px !important; border-top: 1px solid var(--border) !important; grid-template-columns: minmax(0, 1fr) auto !important; grid-template-areas: "t s" "p p" "m a" !important; cursor: pointer !important; align-items: center !important; transition: background 0.15s !important; }
div.ex-row:first-of-type { border-top: 0 !important; }
div.ex-row:hover { background: var(--surface-2) !important; }
.er-t { grid-area: t; min-width: 0 !important; word-break: normal !important; overflow-wrap: break-word !important; }
.er-t b { font-weight: 650 !important; font-size: 14px !important; color: var(--text) !important; display: block !important; line-height: 1.4 !important; white-space: normal !important; }
.er-t > span { font-size: 12px !important; color: var(--muted) !important; display: block !important; margin-top: 2px !important; }
.er-s { grid-area: s; justify-self: end; align-self: start; }
.er-p { grid-area: p; min-width: 0 !important; }
.er-m { grid-area: m; font-size: 12px; color: var(--muted); white-space: nowrap; }
.er-m b { color: var(--text); font-size: 14px; }
.er-a { grid-area: a; justify-self: end; color: var(--subtle); }
.prog-l { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 6px; white-space: nowrap; }
.prog-b { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; display: flex; }
.prog-b i { display: block; height: 100%; }

@media (min-width: 640px) and (max-width: 1279.98px) {
  div.ex-row { grid-template-columns: minmax(0, 1fr) auto auto !important; grid-template-areas: "t s a" "p m a" !important; gap: 8px 14px !important; }
  .er-s { align-self: center !important; }
  .er-p { max-width: 340px !important; width: 100% !important; }
  .er-m { justify-self: end !important; }
  .er-a { align-self: center !important; }
}

/* Desktop Exam Table Clean Styling */
.exam-hub-scalable-container { width: 100% !important; }
.exam-hub-table-wrapper { width: 100% !important; overflow-x: auto !important; background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: 12px !important; }
.exam-hub-table { width: 100% !important; table-layout: fixed !important; border-collapse: separate !important; border-spacing: 0 !important; }
.exam-hub-table th { background: var(--surface-2) !important; color: var(--muted) !important; font-size: 11px !important; font-weight: 700 !important; text-transform: uppercase !important; letter-spacing: 0.05em !important; padding: 10px 12px !important; border-bottom: 1px solid var(--border) !important; }
tr.exam-hub-table-row { display: table-row !important; height: 56px !important; transition: background 0.15s ease !important; cursor: pointer !important; }
tr.exam-hub-table-row:hover { background: var(--surface-2) !important; }
tr.exam-hub-table-row.active-row { background: var(--primary-soft) !important; }
tr.exam-hub-table-row td { padding: 8px 12px !important; vertical-align: middle !important; border-bottom: 1px solid var(--border) !important; font-size: 13px !important; }
.exam-hub-table th:nth-child(1), .exam-hub-table td:nth-child(1) { width: 34%; }
.exam-hub-table th:nth-child(2), .exam-hub-table td:nth-child(2) { width: 16%; }
.exam-hub-table th:nth-child(3), .exam-hub-table td:nth-child(3) { width: 12%; text-align: center; }
.exam-hub-table th:nth-child(4), .exam-hub-table td:nth-child(4) { width: 18%; }
.exam-hub-table th:nth-child(5), .exam-hub-table td:nth-child(5) { width: 12%; text-align: center; }
.exam-hub-table th:nth-child(6), .exam-hub-table td:nth-child(6) { width: 8%; text-align: right; }

#view-exam-hub.page:not([style*="display: none"]):not([style*="display:none"]),
.view-exam-hub.page:not([style*="display: none"]):not([style*="display:none"]),
#view-classes-hub.page:not([style*="display: none"]):not([style*="display:none"]) { display: flex !important; flex-direction: column !important; gap: 20px !important; max-width: 1360px !important; margin: 0 auto !important; width: 100% !important; padding: 24px !important; box-sizing: border-box !important; }
@media (max-width: 767.98px) { #view-exam-hub.page, .view-exam-hub.page, #view-classes-hub.page { padding: 16px !important; gap: 16px !important; } }

@media (min-width: 1280px) {
  .ex-head { display: grid !important; height: 38px !important; align-items: center !important; padding: 0 16px !important; font-size: 12px !important; font-weight: 600 !important; color: var(--muted) !important; background: var(--surface-2) !important; border-bottom: 1px solid var(--border) !important; text-transform: uppercase !important; letter-spacing: .04em !important; }
  .ex-head, div.ex-row { grid-template-columns: minmax(220px, 2.2fr) minmax(155px, 1.15fr) 116px 60px 18px !important; grid-template-areas: none !important; gap: 16px !important; }
  .er-t, .er-s, .er-p, .er-m, .er-a { grid-area: auto !important; }
  .er-s { justify-self: start !important; align-self: center !important; }
  .er-m .lbl-m { display: none !important; }
}

/* ================= SCREEN 2: EXAM DETAIL ================= */
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); height: 32px; margin-left: -4px; padding: 0 6px; border-radius: 8px; align-self: flex-start; background: none; border: none; cursor: pointer; }
.back:hover { background: var(--surface-3); color: var(--text); }
.xd-head { display: flex; flex-direction: column; gap: 8px; }
.xd-top { display: flex; flex-wrap: wrap; gap: 14px 20px; justify-content: space-between; align-items: flex-end; }
.xd-id { min-width: 0; flex: 1 1 auto; height: auto; }
.xd-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.xd-title h1 { font-size: 21px; font-weight: 750; letter-spacing: -.02em; line-height: 1.25; margin: 0; }
@media (min-width: 768px) { .xd-title h1 { font-size: 25px; } }
.meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.meta > span, .meta > button { display: inline-flex; align-items: center; gap: 6px; }
.meta .warn { color: var(--warning); font-weight: 600; border-radius: 6px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (max-width: 767.98px) { .actions { width: 100%; flex-wrap: wrap; gap: 6px; } .actions .btn-primary { flex: 1 1 calc(50% - 6px); min-width: 130px; } }

.alert { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; }
.alert.info { background: var(--info-bg); }
.alert.info .a-ic { color: var(--info); }
.alert.success { background: var(--success-bg); }
.alert.success .a-ic { color: var(--success); }
.alert.warning { background: var(--warning-bg); }
.alert.warning .a-ic { color: var(--warning); }
.a-b { flex: 1; min-width: 0; font-size: 13px; }
.a-b b { display: block; font-weight: 650; }
.a-b span { color: var(--muted); font-size: 12px; }
.mini-bar { height: 5px; border-radius: 9px; background: rgba(59,124,240,.2); margin-top: 8px; overflow: hidden; max-width: 420px; }
.mini-bar i { display: block; height: 100%; background: var(--info-dot); border-radius: 9px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { height: 44px; padding: 0 14px; font-size: 14px; font-weight: 600; color: var(--muted); border: none; background: transparent; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.tabs button.active { color: var(--text); border-color: var(--primary); }
.tabs .n { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--surface-3); padding: 1px 8px; border-radius: 99px; }

.dist { padding: 16px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--border); }
.dist-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.dist-top b { color: var(--text); font-size: 15px; }
.dist-top strong { color: var(--text); }
.dist-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; gap: 2px; }
.dist-bar button { height: 100%; min-width: 6px; transition: opacity .15s; border: none; cursor: pointer; }
.dist-bar button.dim { opacity: .25; }
.dist-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.dist-chips::-webkit-scrollbar { display: none; }
@media (min-width: 1024px) { .dist-chips { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); overflow: visible; margin: 0; padding: 0; } .dist-chips .dchip { min-width: 0; } }
.dchip { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); min-width: 112px; flex-shrink: 0; cursor: pointer; }
.dchip:hover { border-color: var(--border-strong); }
.dchip .dl { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.dchip .dv { font-size: 20px; font-weight: 750; line-height: 1.2; }
.dchip .dv small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.dchip.active { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: var(--primary-soft); }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.sub-head { display: none; }
.sub-row { display: grid; align-items: center; grid-template-columns: 28px minmax(0, 1fr) auto; grid-template-areas: "cb st sc" "cb mm mm"; gap: 5px 10px; padding: 10px 14px; border-top: 1px solid var(--border); cursor: pointer; transition: background 0.15s ease; }
.sub-row:hover { background: var(--surface-2); }
.sub-row.sel { background: var(--primary-soft); }
.c-cb { grid-area: cb; display: flex; align-items: center; justify-content: center; align-self: center; }
.c-st { grid-area: st; min-width: 0; }
.c-sc { grid-area: sc; justify-self: end; align-self: center; }
.c-mm { grid-area: mm; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-left: 42px; }
.c-var, .c-status, .c-time { display: none; }
.c-act { display: none !important; }
.stu { display: flex; align-items: center; gap: 10px; min-width: 0; }
.stu-t { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.stu-name-wrap { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
.stu-t b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.stu-t span, .stu-code-label { font-size: 12px; color: var(--muted); }
.btn-proto-sub-edit-inline { flex-shrink: 0; background: none; border: none; cursor: pointer; padding: 2px 4px; color: var(--muted, #64748b); display: inline-flex; align-items: center; border-radius: 4px; }
.btn-proto-sub-edit-inline:hover { color: var(--primary, #00c5df); background: var(--surface-3, #f1f5f9); }
.score { font-weight: 750; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.score .tdot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.score.none { color: var(--subtle); font-weight: 600; }

@media (max-width: 480px) {
  .sub-row { padding: 9px 12px; gap: 4px 8px; grid-template-columns: 26px minmax(0, 1fr) auto; }
  .c-mm { padding-left: 38px; gap: 6px; font-size: 11.5px; }
  .proto-submissions-list { padding-bottom: calc(var(--mobile-dock-height, 64px) + 24px); }
  .bulk { bottom: calc(var(--mobile-dock-height, 64px) + 12px); }
}
@media (max-width: 360px) {
  .c-mm { padding-left: 0; }
}

@media (min-width: 768px) {
  .sub-head { display: grid; height: 40px; align-items: center; padding: 0 16px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); text-transform: uppercase; letter-spacing: .04em; border-top: 1px solid var(--border); }
  .sub-head, .sub-row { grid-template-columns: 32px minmax(130px, 1fr) 90px 110px 65px 165px; grid-template-areas: none; gap: 8px; }
  .sub-row { padding: 10px 16px; }
  .c-cb, .c-st, .c-sc { grid-area: auto; }
  .c-mm, .c-time { display: none; }
  .c-var, .c-status { display: block; }
  .c-act { display: inline-flex !important; align-items: center; justify-content: flex-end; gap: 6px; }
  .c-var { font-size: 13px; color: var(--muted); display: flex; align-items: center; }
  .c-var button, .c-var select { white-space: nowrap !important; }
}
.proto-variant-picker { position: relative; display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2, #f1f5f9); border: 1px solid var(--border, #cbd5e1); border-radius: 6px; padding: 2px 7px; font-size: 12px; font-weight: 600; color: var(--text-main, #0f172a); cursor: pointer; max-width: 105px; line-height: 1.3; transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease; }
.proto-variant-picker:hover { background-color: #e2e8f0; border-color: #94a3b8; }
.proto-variant-picker:focus-within { border-color: var(--primary, #00c5df); box-shadow: 0 0 0 2px rgba(0,197,223,.25); }
.proto-variant-picker .proto-variant-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.proto-variant-picker svg { flex-shrink: 0; pointer-events: none; color: var(--muted, #64748b); }
.proto-variant-picker .proto-variant-select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 2; -webkit-appearance: none; appearance: none; border: none; margin: 0; padding: 0; }
[data-theme="dark"] .proto-variant-picker { background-color: var(--surface-2, #1e293b); border-color: var(--border, #334155); color: var(--text-main, #f8fafc); }
[data-theme="dark"] .proto-variant-picker:hover { background-color: #334155; border-color: #64748b; }
[data-theme="dark"] .proto-variant-picker .proto-variant-select option { background-color: #1e293b; color: #f8fafc; }
@media (min-width: 1024px) {
  .sub-head, .sub-row { grid-template-columns: 32px minmax(160px, 1fr) 105px 115px 65px 75px 165px; gap: 10px; }
  .c-time { display: block; font-size: 13px; color: var(--muted); }
}
.btn-batch-grade-hero { background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%) !important; color: #fff !important; border: none !important; font-weight: 750 !important; box-shadow: 0 2px 6px rgba(79, 70, 229, 0.32) !important; }
.btn-batch-grade-hero:hover { filter: brightness(1.08); box-shadow: 0 4px 12px rgba(79, 70, 229, 0.45) !important; }
#btn-exam-more-menu.btn-icon, .btn-exam-more-circle { width: 34px !important; min-width: 34px !important; height: 34px !important; padding: 0 !important; border-radius: 50% !important; display: inline-flex !important; align-items: center !important; justify-content: center !important; }

.bulk { position: sticky; bottom: 12px; display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 16px; border-radius: 14px; background: var(--navy); color: #fff; box-shadow: var(--shadow-lg); z-index: 5; }
[data-theme="dark"] .bulk { background: #e8effa; color: #0b1b33; }
.bulk > b { font-size: 14px; margin-right: auto; white-space: nowrap; }
.bulk .btn-ghost { color: inherit; opacity: .92; }
.bulk .btn-ghost:hover { background: rgba(255,255,255,.12); }
[data-theme="dark"] .bulk .btn-ghost:hover { background: rgba(8,40,80,.1); }

.an-grid { display: grid; gap: 16px; }
@media (min-width: 1024px) { .an-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }
.qbar { display: grid; grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) 48px; gap: 12px; align-items: center; font-size: 13.5px; padding: 8px 0; }
.qbar > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qbar .track { height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.qbar .track i { display: block; height: 100%; border-radius: 99px; }
.qbar b { text-align: right; }
.miss { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); align-items: flex-start; }
.miss:first-child { border-top: 0; padding-top: 0; }
.miss .mn { width: 28px; height: 28px; border-radius: 8px; background: var(--danger-bg); color: var(--danger); font-weight: 700; font-size: 13px; display: grid; place-items: center; flex-shrink: 0; margin-top: 2px; }
.miss .mb { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.55; }
.miss .mb .mb-t, .miss .mb > b { display: block; font-weight: 600; color: var(--text, #0f172a); font-size: 13.5px; line-height: 1.5; word-break: break-word; }
.miss .mb .mb-s, .miss .mb > span { display: block; font-size: 12.5px; color: var(--muted, #64748b); margin-top: 4px; line-height: 1.45; }
.miss .mb .katex { display: inline-block !important; font-size: 1.05em; white-space: nowrap !important; }
.miss .mb .katex .base { display: inline-block !important; white-space: nowrap !important; width: min-content !important; }
.miss .mb .katex .mord, .miss .mb .katex .mbin, .miss .mb .katex .mrel { display: inline-block !important; margin-top: 0 !important; margin-bottom: 0 !important; }
.miss .mb .katex .vlist-t { display: inline-table !important; } .miss .mb .katex .vlist-r { display: table-row !important; } .miss .mb .katex .vlist { display: table-cell !important; } .miss .mb .katex .vlist > span { display: block !important; } .miss .mb .katex .frac-line { display: inline-block !important; width: 100% !important; }
.miss .mc { font-weight: 700; font-size: 13px; color: var(--danger); white-space: nowrap; margin-top: 2px; }

/* ================= SCREEN 3: SPEEDGRADER ================= */
body.speedgrader-active #view-exam-detail.page { max-width: 100% !important; padding: 0 !important; margin: 0 !important; gap: 0 !important; }
.sg { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; background: var(--bg); overflow: hidden; height: calc(100vh - 60px); }
body.speedgrader-active .sg { height: 100vh !important; border: 0 !important; border-radius: 0 !important; }
.sg-head { grid-column: 1/-1; display: flex; align-items: center; gap: 4px; min-height: 60px; padding: 6px 8px; background: var(--surface); border-bottom: 1px solid var(--border); z-index: 2; }
@media (min-width: 768px) { .sg-head { gap: 8px; padding: 8px 14px; } }
.stu-sw { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1; }
.who { min-width: 0; flex: 1; text-align: center; line-height: 1.25; padding: 4px 6px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; cursor: pointer; background: transparent; border: none; color: var(--text) !important; }
.who:hover { background: var(--surface-3); }
.who b { display: flex; align-items: center; gap: 4px; max-width: 100%; font-size: 15px; color: var(--text) !important; }
.who b span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text) !important; }
.who > span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
@media (min-width: 768px) { .stu-sw { flex: 0 1 auto; } .who { min-width: 230px; } }
.sg-head-r { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.kbd-hint { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.scrim { position: absolute; inset: 0; background: rgba(6,19,41,.45); z-index: 25; opacity: 0; pointer-events: none; transition: opacity .2s; }
.sg.roster-open .scrim, .sg.sheet-open .scrim { opacity: 1; pointer-events: auto; }
.sg-roster { position: absolute; top: 0; bottom: 0; left: 0; width: min(86%, 320px); background: var(--surface); border-right: 1px solid var(--border); z-index: 30; transform: translateX(-104%); visibility: hidden; transition: transform .24s ease, visibility 0s .24s; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.sg.roster-open .sg-roster { transform: none; visibility: visible; transition: transform .24s ease; }
.sg-canvas { grid-column: 1; grid-row: 2; min-height: 0; display: flex; flex-direction: column; position: relative; }
.sg-rubric { position: absolute; left: 0; right: 0; bottom: 0; height: 84%; background: var(--surface); border-radius: 20px 20px 0 0; z-index: 30; transform: translateY(104%); transition: transform .26s ease; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.sg.sheet-open .sg-rubric { transform: none; }
.sheet-handle { width: 40px; height: 5px; border-radius: 9px; background: var(--border-strong); margin: 8px auto 0; flex-shrink: 0; }
.sg-bar { grid-row: 3; display: flex; gap: 8px; padding: 10px 12px 20px; background: var(--surface); border-top: 1px solid var(--border); }
.sgb-score { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 0 36px 0 14px; border-radius: 12px; border: 1px solid var(--border-strong); height: 50px; position: relative; line-height: 1.2; background: transparent; cursor: pointer; color: var(--text) !important; }
.sgb-score span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sgb-score b { font-size: 16px; white-space: nowrap; color: var(--text) !important; }

@media (min-width: 768px) {
  .sg { grid-template-columns: minmax(0, 1.7fr) minmax(235px, 260px); grid-template-rows: auto minmax(0, 1fr); }
  .sg-rubric { position: static; transform: none; height: auto; border-radius: 0; box-shadow: none; border-left: 1px solid var(--border); grid-column: 2; grid-row: 2; min-height: 0; z-index: auto; }
  .sg-rubric .sheet-handle, .sg-rubric .sheet-close { display: none; }
  .sg-bar { display: none; }
}
@media (min-width: 1200px) {
  .sg { grid-template-columns: 272px minmax(0, 1fr) 384px; }
  .sg-roster { position: static; transform: none; visibility: visible; transition: none; width: auto; box-shadow: none; grid-column: 1; grid-row: 2; min-height: 0; z-index: auto; }
  .sg-canvas { grid-column: 2; }
  .sg-rubric { grid-column: 3; }
  .scrim { display: none; }
}

.ro-head { padding: 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.ro-t { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--muted); }
.ro-t b { font-size: 15px; color: var(--text); }
.fchips { display: flex; flex-wrap: wrap; gap: 6px; }
.fchips button { height: 30px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); color: var(--muted); background: var(--surface); white-space: nowrap; cursor: pointer; }
.fchips button.active { background: var(--navy); border-color: var(--navy); color: #fff; }
[data-theme="dark"] .fchips button.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.ro-list { flex: 1; overflow-y: auto; padding: 6px; min-height: 0; }
.ro-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 10px; min-height: 54px; border: none; background: transparent; cursor: pointer; text-align: left; color: var(--text) !important; }
.ro-item:hover { background: var(--surface-2); }
.ro-item.active { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.ro-tx { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.ro-tx .nm { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text) !important; }
.ro-tx .st { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.ro-item .sc { font-weight: 700; font-size: 13px; color: var(--text) !important; }
.sdot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.sdot.approved { background: var(--success-dot); } .sdot.ai { background: var(--warning-dot); } .sdot.pending { background: var(--t-none); } .sdot.grading { background: var(--info-dot); }

.cv-tools { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 12px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.cv-pages { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pgtab { height: 28px; padding: 0 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; border: none; background: transparent; cursor: pointer; }
.pgtab.active { background: var(--surface-3); color: var(--text); }
.cv-mobile-nav { display: none; }
.cv-scroll { flex: 1; overflow: auto; padding: 12px 6px 24px; min-height: 0; background: var(--surface-3); }
[data-theme="dark"] .cv-scroll { background: #04101f; }
@media (min-width: 768px) { .cv-scroll { padding: 12px 8px 80px; } }
@media (min-width: 1200px) { .cv-scroll { padding: 24px 20px 88px; } }

.hud { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 4px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 5; white-space: nowrap; }
.hud button { height: 36px; min-width: 36px; border-radius: 999px; display: grid; place-items: center; color: var(--text); border: none; background: transparent; cursor: pointer; }
.hud button:hover:not(:disabled) { background: var(--surface-3); }
.hud-t { font-size: 13px; font-weight: 600; padding: 0 6px; min-width: 44px; text-align: center; color: var(--text); }
.hud .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

@media (max-width: 767.98px) {
  .hud { display: none !important; }
  .cv-tools { gap: 4px; padding: 5px 8px; flex-wrap: nowrap; }
  .cv-tools .seg { flex-shrink: 0; padding: 2px; }
  .cv-tools .seg button { height: 26px; padding: 0 6px; font-size: 11.5px; font-weight: 600; }
  .cv-mobile-nav { display: inline-flex; align-items: center; gap: 3px; margin-left: auto; flex-shrink: 0; }
  .cv-mobile-nav .btn-m-step { height: 26px; width: 26px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface); color: var(--text); display: grid; place-items: center; font-size: 10px; cursor: pointer; padding: 0; }
  .cv-mobile-nav .btn-m-step:disabled { opacity: 0.35; cursor: not-allowed; }
  .cv-mobile-nav .m-page-txt { font-size: 11.5px; font-weight: 700; color: var(--text); padding: 0 3px; white-space: nowrap; }
  .cv-mobile-nav .btn-m-zoom { height: 26px; padding: 0 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap; }
}

.paper { background: var(--paper); color: var(--ink); max-width: 700px; margin: 0 auto; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.14), 0 10px 30px rgba(15,23,42,.1); padding: 18px 12px 24px 14px; position: relative; background-image: repeating-linear-gradient(to bottom, transparent 0 33px, var(--paper-line) 33px 34px); background-position: 0 18px; font-family: "Segoe Print", "Noteworthy", "Chalkboard SE", "Comic Sans MS", ui-rounded, system-ui, sans-serif; font-size: 14.5px; line-height: 34px; }
@media (min-width: 768px) { .paper { padding: 18px 16px 24px 18px; font-size: 15px; } }
@media (min-width: 1200px) { .paper { padding: 30px 28px 34px 36px; font-size: 16px; } }
.p-form { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; padding: 4px 0 8px; font-size: 13.5px; border-bottom: 1.5px solid #c8d2e2; margin-bottom: 8px; }
.p-form.has-stamp { padding-right: 76px; }
.p-form.p-form-subpage { min-height: 44px; padding: 4px 0 8px; margin-bottom: 12px; align-items: center; justify-content: space-between; }
.p-form.p-form-subpage.has-stamp { padding-right: 76px; }
.p-form span { font-family: ui-sans-serif, system-ui, sans-serif; font-size: 11.5px; color: #6b7a90; text-transform: uppercase; letter-spacing: .04em; }
.p-form em { font-style: normal; font-size: 15px; color: #0b1b33 !important; font-weight: 700; }
.btn-canvas-edit-student { display: none !important; }
@media (min-width: 900px) { .btn-canvas-edit-student { display: inline-flex !important; margin-left: auto; } }
.stamp { position: absolute; top: 10px; right: 10px; width: 68px; height: 68px; border: 2.5px solid var(--pen); border-radius: 50%; color: var(--pen); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; transform: rotate(-7deg); line-height: 1; background: rgba(255,255,255,.96); z-index: 10; box-shadow: 0 2px 8px rgba(220,38,38,.16); pointer-events: none; }
.stamp b { font-size: 20px; font-weight: 700; }
.stamp small { font-size: 11px; font-weight: 600; }
.qcard-feedback { padding: 8px 12px; margin: 4px 10px 8px; font-size: 12px; line-height: 1.5; background: var(--surface-2, #f8fafc); border-left: 3px solid #3b82f6; border-radius: 6px; color: var(--text, #334155); word-break: break-word; }
.qcard-feedback .katex { font-size: 1.05em; }
.qcard .katex-display { margin: 6px 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.crit .ct .katex { font-size: 1.02em; }
.pq { position: relative; padding-right: 32px; border-radius: 6px; transition: background .4s; }
.pq.flash { background: rgba(0,197,223,.16); }
.pq-t { font-weight: 700; color: #0b1b33 !important; }
.pl { position: relative; word-break: break-word; overflow-wrap: break-word; color: #1d3a8a; max-width: 100%; overflow: visible; }
.pl.err { text-decoration: underline wavy var(--pen); text-decoration-thickness: 1.4px; text-underline-offset: 7px; }
.mk { position: absolute; top: 0; right: -32px; width: 32px; color: var(--pen); font-size: 13.5px; font-weight: 700; white-space: nowrap; transform: rotate(-5deg); text-decoration: none; display: inline-block; text-align: right; pointer-events: none; }
.note { display: block; color: var(--pen); font-size: 13px; line-height: 20px; margin: 0 0 8px 14px; transform: rotate(-.6deg); }
.paper .katex { font-size: 0.94em; white-space: normal !important; }
.paper .katex .katex-html { display: inline !important; white-space: normal !important; }
.paper .katex .base { display: inline-block !important; white-space: nowrap !important; }
.sgb-score::after { content: '▲'; font-size: 9px; color: var(--primary); margin-left: auto; opacity: .85; transition: transform .2s ease; }
@media (max-width: 850px) { #btn-sg-quick-edit-sub span { display: none; } #btn-sg-quick-edit-sub { padding: 0 8px !important; min-width: 32px; justify-content: center; } }
@media (min-width: 1200px) { .pq { padding-right: 48px; } .mk { right: -48px; width: 44px; font-size: 14px; } .paper .katex { font-size: 1em; } }

.rb-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.rb-ht { flex: 1; min-width: 0; }
#sg-live-score.rb-total, .rb-total { font-size: 28px !important; font-weight: 800 !important; letter-spacing: -.02em !important; line-height: 1.1 !important; margin-top: 2px !important; background: transparent !important; color: var(--text) !important; padding: 0 !important; border-radius: 0 !important; box-shadow: none !important; border: none !important; display: block !important; }
#sg-live-score.rb-total small, .rb-total small { font-size: 15px !important; color: var(--muted) !important; font-weight: 600 !important; letter-spacing: 0 !important; }
.rb-hr { display: flex; align-items: center; gap: 6px; }
.rb-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.ai-note { display: flex; gap: 8px; font-size: 12px; color: var(--muted); padding: 10px 12px; border-radius: 10px; background: var(--surface-2); line-height: 1.45; }
.qcard { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; flex-shrink: 0; }
.qcard-h { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px; min-height: 56px; border: none; background: transparent; cursor: pointer; text-align: left; color: var(--text) !important; }
.qcard-h:hover { background: var(--surface-2); }
.qh-t { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.qh-t b { font-size: 14px; color: var(--text) !important; }
.qh-t span { font-size: 12px; color: var(--muted); }
.qscore { font-weight: 750; font-size: 13px; padding: 3px 9px; border-radius: 8px; white-space: nowrap; background: var(--surface-3); color: var(--muted); }
.qscore.full { background: var(--success-bg); color: var(--success); }
.qscore.part { background: var(--warning-bg); color: var(--warning); }
.qscore.zero { background: var(--danger-bg); color: var(--danger); }
.crit { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 10px 12px; border-top: 1px solid var(--border); min-height: 46px; border-left: none; border-right: none; border-bottom: none; background: transparent; cursor: pointer; text-align: left; color: var(--text) !important; }
.crit:hover:not(:disabled) { background: var(--surface-2); }
.crit .cb { margin-top: 1px; }
.crit .ct { flex: 1; font-size: 13px; line-height: 1.4; color: var(--text) !important; }
.crit .ct span { color: var(--text) !important; }
.crit .ct small { display: block; color: var(--danger) !important; font-size: 12px; margin-top: 2px; }
.crit .cp { font-size: 13px; font-weight: 700; color: var(--subtle); white-space: nowrap; }
.crit.on .cp { color: var(--success) !important; }
.crit.partial .cp { color: var(--warning, #d97706) !important; font-weight: 750; }
.fb label { display: block; font-size: 13px; font-weight: 650; margin: 4px 0 6px; color: var(--text); }
.qc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.qc-chips button { height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface); cursor: pointer; }
.rb-foot { padding: 12px 14px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
@media (min-width: 768px) and (max-width: 1199px) {
  .rb-head { padding: 10px 12px; }
  .rb-body { padding: 8px; gap: 8px; }
  .qcard-h { padding: 8px 10px; min-height: 48px; }
  .qh-t b { font-size: 13px; }
  .crit { padding: 6px 8px; }
}

/* ================= SCREEN 4: STUDENT PORTAL ================= */
.portal { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.portal-head { display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ph-t { line-height: 1.2; }
.ph-t b { display: block; font-size: 15px; }
.ph-t span { font-size: 12px; color: var(--muted); }
.ph-chip { margin-left: auto; }
.portal-wrap { max-width: 1060px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); width: 100%; box-sizing: border-box; }
.portal-wrap.access-required-mode { grid-template-columns: minmax(0, 1fr) !important; max-width: 680px !important; margin: 0 auto !important; }
@media (min-width: 900px) { .portal-wrap { grid-template-columns: 340px minmax(0, 1fr); padding: 28px; gap: 24px; align-items: start; } .portal-wrap.access-required-mode { grid-template-columns: minmax(0, 1fr) !important; max-width: 680px !important; } }
.p-left { display: flex; flex-direction: column; gap: 16px; }
.exam-card { padding: 16px; }
.exam-card h2 { font-size: 18px; font-weight: 750; line-height: 1.3; margin-top: 4px; letter-spacing: -.01em; }
.exam-card p { font-size: 13px; color: var(--muted); margin-top: 4px; }
.countdown { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--warning-bg); color: var(--warning); font-weight: 650; font-size: 13px; margin-top: 12px; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.facts div { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 12px; color: var(--muted); line-height: 1.35; }
.facts b { display: block; color: var(--text); font-size: 13px; }
.p-tips { padding: 16px; }
.p-tips h3 { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.tip { display: flex; gap: 10px; font-size: 13px; color: var(--muted); padding: 6px 0; line-height: 1.45; }
.tip svg { color: var(--success); margin-top: 2px; }
@media (max-width: 899.98px) { .p-tips { display: none; } }
@media (min-width: 900px) { .tips-inline { display: none; } }
.tips-inline { margin-top: 12px; }
.flow { display: flex; flex-direction: column; }
.stepper { display: flex; align-items: center; gap: 8px; padding: 16px; }
.step { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); flex-shrink: 0; }
.step i { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 13px; font-weight: 700; border: 1.5px solid var(--border-strong); background: var(--surface); }
.step.on { color: var(--text); }
.step.on i { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.step.done i { background: var(--success-dot); border-color: var(--success-dot); color: #fff; }
.step-line { flex: 1; height: 2px; background: var(--border); min-width: 10px; border-radius: 2px; }
.step-line.done { background: var(--success-dot); }
.flow-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.capture { border: 1.5px dashed var(--border-strong); border-radius: 16px; padding: 22px 16px; text-align: center; background: var(--surface-2); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.capture b { font-size: 15px; }
.capture > span { font-size: 13px; color: var(--muted); max-width: 380px; }
.cap-ic { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-soft); color: var(--primary-text); display: grid; place-items: center; margin-bottom: 4px; }
.cap-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; width: 100%; }
.capture.compact { padding: 12px; flex-direction: row; justify-content: space-between; text-align: left; gap: 12px; }
.capture.compact .cap-actions { margin: 0; width: auto; flex-wrap: nowrap; }
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 10px; }
.pg { position: relative; aspect-ratio: 3/4; border-radius: 10px; border: 1px solid var(--border); background: #fffdf6; overflow: hidden; }
.pg-in { position: absolute; inset: 12px 10px 34px; background: repeating-linear-gradient(to bottom, transparent 0 11px, #dde5f1 11px 12px); opacity: .85; }
.pg.blur .pg-in { filter: blur(2.2px); }
.pg .no { position: absolute; left: 6px; top: 6px; font-size: 12px; font-weight: 700; background: rgba(11,27,51,.78); color: #fff; border-radius: 6px; padding: 0 6px; line-height: 20px; }
.pg .del { position: absolute; right: 4px; top: 4px; width: 30px; height: 30px; border-radius: 50%; background: rgba(11,27,51,.78); color: #fff; display: grid; place-items: center; border: none; cursor: pointer; }
.pg .q { position: absolute; left: 6px; right: 6px; bottom: 6px; font-size: 12px; font-weight: 650; border-radius: 7px; line-height: 22px; text-align: center; }
.pg .q.ok { background: #e6f6ed; color: #11804a; }
.pg .q.blur { background: #c22a2a; color: #fff; border: none; cursor: pointer; }
.add-tile { aspect-ratio: 3/4; border-radius: 10px; border: 1.5px dashed var(--border-strong); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; background: transparent; }
.flow-foot { position: sticky; bottom: 0; padding: 12px 16px 20px; background: var(--surface); border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; border-radius: 0 0 14px 14px; z-index: 3; }
.ff-info { font-size: 13px; color: var(--muted); margin-right: auto; }
.form-row label { display: block; font-size: 13px; font-weight: 650; margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 6px; align-items: flex-start; line-height: 1.4; }
.hint.ok { color: var(--success); }
.hint.warn { color: var(--warning); }
.field.ro { display: flex; align-items: center; justify-content: space-between; background: var(--surface-2); color: var(--muted); }
.seg.seg-lg button { height: 40px; padding: 0 20px; font-size: 14px; }
.pg-strip { display: flex; gap: 6px; overflow-x: auto; }
.pg-strip .pg { width: 54px; flex-shrink: 0; }
.confirm { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; border: 1px solid var(--border); width: 100%; font-size: 13px; line-height: 1.45; background: transparent; cursor: pointer; }
.confirm.on { border-color: var(--primary); background: var(--primary-soft); }
.receipt { text-align: center; padding: 12px 20px 20px; display: flex; flex-direction: column; align-items: center; }
.ok-ic { width: 68px; height: 68px; border-radius: 50%; background: var(--success-bg); color: var(--success); display: grid; place-items: center; margin-bottom: 14px; }
.receipt h2 { font-size: 20px; font-weight: 750; margin: 0; }
.receipt p { font-size: 13px; color: var(--muted); margin-top: 6px; max-width: 380px; }
.rc-code { margin-top: 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 20px; font-weight: 700; letter-spacing: .06em; padding: 10px 18px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--border-strong); }
.rc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 16px; width: 100%; max-width: 440px; text-align: left; }
.rc-grid div { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 12px; color: var(--muted); }
.rc-grid b { display: block; color: var(--text); font-size: 14px; margin-top: 2px; }

/* ==========================================================================
   APP COMPONENT INTEGRATION BRIDGES (PROTOTYPE V2 MAPPINGS)
   ========================================================================== */

/* Cockpit Sidebar -> Prototype V2 Shell Side */
.cockpit-sidebar {
  background: var(--surface) !important;
  border-right: 1px solid var(--border) !important;
  box-shadow: none !important;
}
.cockpit-sidebar .sidebar-brand h1 {
  color: var(--text) !important;
  font-weight: 800 !important;
}
.cockpit-sidebar .sidebar-brand p {
  color: var(--muted) !important;
}
.sidebar-smart-context-capsule { position: relative !important; background: var(--surface-2) !important; border: 1px solid var(--border) !important; border-radius: 12px !important; color: var(--text) !important; }
.sidebar-smart-context-capsule:hover { border-color: var(--border-strong) !important; }
.smart-context-popover { display: none !important; }
.smart-context-popover.open { display: flex !important; position: absolute !important; top: calc(100% + 4px) !important; left: 0 !important; right: 0 !important; z-index: 1200 !important; background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: 12px !important; box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12) !important; }
.cockpit-sidebar .nav-item-card { border-radius: 10px !important; color: var(--muted) !important; font-weight: 500 !important; transition: background 0.15s ease !important; }
.cockpit-sidebar .nav-item-card:hover { background: var(--surface-3) !important; color: var(--text) !important; }
.cockpit-sidebar .nav-item-card.active { background: var(--primary-soft) !important; color: var(--primary-text) !important; font-weight: 650 !important; }

/* Studio Topbar -> Prototype V2 ag-top */
.studio-topbar { display: flex !important; align-items: center !important; justify-content: space-between !important; gap: 12px !important; padding: 0 16px !important; height: 60px !important; background: var(--surface) !important; border-bottom: 1px solid var(--border) !important; box-shadow: none !important; position: relative !important; z-index: 100 !important; }
.topbar-left { display: flex !important; align-items: center !important; gap: 10px !important; flex-shrink: 0 !important; }
.breadcrumb-trail { font-size: 13px !important; color: var(--muted) !important; }
.breadcrumb-active { color: var(--text) !important; font-weight: 650 !important; }
.spotlight-trigger-box { display: flex !important; align-items: center !important; gap: 8px !important; background: var(--surface-2) !important; border: 1px solid var(--border) !important; border-radius: 12px !important; color: var(--subtle) !important; height: 38px !important; padding: 0 12px !important; font-size: 13px !important; max-width: 260px !important; flex: 0 1 260px !important; cursor: pointer !important; }
.spotlight-trigger-box:hover { border-color: var(--border-strong) !important; }
@media (max-width: 1023.98px) { .spotlight-trigger-box { display: none !important; } }
.prototype-v2-nav-strip { display: inline-flex !important; align-items: center !important; gap: 3px !important; padding: 3px !important; background: var(--surface-3) !important; border: 1px solid var(--border) !important; border-radius: 10px !important; flex-shrink: 0 !important; }
.topbar-right { display: flex !important; align-items: center !important; gap: 8px !important; margin-left: auto !important; flex-shrink: 0 !important; }
@media (max-width: 1279.98px) { #btn-quick-create-exam span, #btn-batch-grade span { display: none !important; } #btn-quick-create-exam, #btn-batch-grade { padding: 0 10px !important; } }

/* Exam Detail: Compact Assessment Bar -> Prototype V2 xd-head */
.compact-assessment-bar:not([style*="display: none"]):not([style*="display:none"]) { display: flex; flex-direction: column; gap: 12px; background: var(--surface) !important; border: 1px solid var(--border) !important; padding: 14px 18px !important; border-radius: 14px !important; margin-bottom: 16px !important; box-shadow: var(--shadow-sm) !important; height: auto !important; min-height: 0 !important; }
.assessment-main-row { display: flex !important; flex-wrap: wrap !important; gap: 14px 20px !important; justify-content: space-between !important; align-items: flex-end !important; height: auto !important; min-height: 0 !important; }
.assessment-identity-group { display: flex !important; align-items: center !important; gap: 12px !important; min-width: 0 !important; flex: 1 1 auto !important; height: auto !important; min-height: 0 !important; }
.compact-assessment-title { font-size: 21px !important; font-weight: 750 !important; letter-spacing: -.02em !important; line-height: 1.25 !important; margin: 0 !important; color: var(--text) !important; }
.assessment-sub-row { display: flex !important; flex-wrap: wrap !important; gap: 12px 20px !important; align-items: center !important; justify-content: space-between !important; border-top: 1px solid var(--border) !important; padding-top: 10px !important; }
.assessment-meta-pill { display: flex !important; flex-wrap: wrap !important; gap: 6px 16px !important; font-size: 13px !important; color: var(--muted) !important; }
#exam-class-tag, #exam-background-processing-banner.status-ready, .c-act .btn-proto-edit-sub, .p-form .btn-canvas-edit-student, .sg-head .kbd-hint { display: none !important; }
#sg-roster-filter-chips { display: flex !important; flex-wrap: nowrap !important; gap: 4px !important; }
#sg-roster-filter-chips button { padding: 4px 6px !important; font-size: 11px !important; white-space: nowrap !important; flex: 1 1 auto !important; text-align: center !important; }

/* Exam Detail: Class Pulse -> Prototype V2 dist & dchips */
.class-pulse-summary-bar { padding: 16px !important; display: flex !important; flex-direction: column !important; gap: 12px !important; background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: 14px !important; margin-bottom: 16px !important; box-shadow: var(--shadow-sm) !important; }
.pulse-distribution-bar { display: flex !important; height: 12px !important; border-radius: 99px !important; overflow: hidden !important; gap: 2px !important; background: var(--surface-3) !important; }
.pulse-bar-segment { height: 100% !important; min-width: 6px !important; transition: width 0.3s ease, opacity 0.15s !important; }
.pulse-bar-segment.seg-excellent { background: var(--t-ex, #1fb26b) !important; }
.pulse-bar-segment.seg-good { background: var(--t-good, #3b7cf0) !important; }
.pulse-bar-segment.seg-average { background: var(--t-avg, #f0a20b) !important; }
.pulse-bar-segment.seg-remedial { background: var(--t-low, #e5484d) !important; }

.pulse-stat-distribution { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)) !important; gap: 8px !important; }
.pulse-dist-chip { display: flex !important; flex-direction: column !important; align-items: flex-start !important; gap: 2px !important; padding: 10px 12px !important; border-radius: 12px !important; border: 1px solid var(--border) !important; background: var(--surface) !important; cursor: pointer !important; font-size: 12px !important; transition: all 0.15s ease !important; }
.pulse-dist-chip:hover { border-color: var(--border-strong) !important; }
.pulse-dist-chip.active { border-color: var(--primary) !important; box-shadow: inset 0 0 0 1px var(--primary) !important; background: var(--primary-soft) !important; }
.pulse-dist-chip strong { font-size: 20px !important; font-weight: 750 !important; line-height: 1.2 !important; color: var(--text) !important; }
.pulse-pct { font-size: 12px !important; color: var(--muted) !important; font-weight: 500 !important; }

/* Submissions Table -> Prototype V2 sub-head & sub-row */
.submissions-table-container { background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: 14px !important; overflow: hidden !important; box-shadow: var(--shadow-sm) !important; }
.submissions-table { width: 100% !important; border-collapse: collapse !important; }
.submissions-table thead tr { height: 40px !important; background: var(--surface-2) !important; border-bottom: 1px solid var(--border) !important; }
.submissions-table th { font-size: 12px !important; font-weight: 600 !important; color: var(--muted) !important; text-transform: uppercase !important; letter-spacing: .04em !important; padding: 0 16px !important; border: none !important; }
.submissions-table tbody tr { border-bottom: 1px solid var(--border) !important; transition: background 0.15s ease !important; }
.submissions-table tbody tr:hover { background: var(--surface-2) !important; }
.submissions-table td { padding: 12px 16px !important; font-size: 14px !important; color: var(--text) !important; border: none !important; vertical-align: middle !important; }

/* SpeedGrader Studio Layout -> Prototype V2 3-Column Studio */
.speedgrader-studio-layout { background: var(--bg) !important; border-radius: 14px !important; overflow: hidden !important; border: 1px solid var(--border) !important; }
.speedgrader-studio-layout #speedgrader-left-pane { background: var(--surface) !important; border-right: 1px solid var(--border) !important; }
.speedgrader-studio-layout #speedgrader-center-pane { background: var(--surface-3) !important; }
[data-theme="dark"] .speedgrader-studio-layout #speedgrader-center-pane { background: #04101f !important; }
.speedgrader-studio-layout #speedgrader-right-pane { background: var(--surface) !important; border-left: 1px solid var(--border) !important; }
#sg-live-score, #sg-live-score.rb-total, #sg-live-score.score-pill, .sg-rubric #sg-live-score {
  background: transparent !important; border: none !important; box-shadow: none !important; padding: 0 !important;
  border-radius: 0 !important; color: var(--text) !important; font-size: 28px !important; font-weight: 800 !important;
  line-height: 1.1 !important; letter-spacing: -0.03em !important;
}
#sg-live-score small { font-size: 14px !important; font-weight: 600 !important; color: var(--subtle) !important; }
/* Page 5 Decluttering: Assessment Studio, Quick Grade, Exam Barem & PDF-to-Word */
#assessment-studio-view { padding-bottom: 84px !important; }
#assessment-studio-view .ai-pedagogical-disclaimer,
#assessment-studio-view .ocr-header-badge,
#assessment-studio-view .studio-header-bar .ocr-header-title-group > div > div:nth-child(2),
#btn-studio-open-pdf-to-word, #btn-studio-open-math-visual, #studio-quota-capsule,
#assessment-studio-view .studio-seg-btn .seg-subhint,
#studio-audit-cost-tag, #studio-rubric-cost-tag, #studio-ocr-cost-tag,
#assessment-studio-view .ocr-card-desc,
#quick-upload-header-bar > div:first-child > div,
#btn-quick-toggle-upload-box,
.quick-mode-card .badge, .quick-mode-card > div:nth-child(2),
.teacher-exam-purpose-btn .purpose-sub,
.pdf-to-word-community-view .p2w-eyebrow,
.pdf-to-word-community-view .p2w-hero-subtitle,
.pdf-to-word-community-view .p2w-trust-strip,
#p2w-dropzone-hint, #p2w-workbench-tier-hint,
.pdf-to-word-community-view .p2w-archive-header .p2w-section-desc { display: none !important; }
#assessment-studio-view .studio-header-bar { padding: 8px 4px 12px !important; background: transparent !important; border: none !important; box-shadow: none !important; margin-bottom: 4px !important; }
.quick-math-input-row { display: flex !important; flex-direction: column !important; gap: 10px !important; align-items: stretch !important; }
.quick-submit-process-btn { align-self: flex-start !important; min-width: 240px !important; }
@media (min-width: 900px) and (hover: hover) and (pointer: fine) { #btn-quick-native-camera { display: none !important; } }
.pdf-to-word-community-view .p2w-hero-copy { margin-bottom: 1rem !important; }
.pdf-to-word-community-view .p2w-hero-title { font-size: 1.55rem !important; margin: 0 !important; }
/* Page 6 Decluttering: Math Visual 3D, Geometry Board, 3-Tier Solver & Core Modals */
body #math-visual-studio-view .mv-pill-badge,
body #math-visual-studio-view .math-visual-subtitle,
body #math-visual-studio-view #visual-quota-capsule.visual-quota-capsule,
body #math-visual-studio-view #btn-math-visual-new,
body #math-visual-studio-view #math-visual-constraint-badge,
body #math-visual-studio-view #mv-interactive-hint,
body #math-visual-studio-view .mv-cad-hint,
body #math-visual-studio-view .mv-inspector-heading-row .mv-cas-badge,
body #math-visual-studio-view #btn-inspector-export-all,
#quick-single-flow-stepper,
#modal-create-class .dlg-h > div > div,
#modal-edit-class .dlg-h > div > div,
#btn-exam-bulk-upload { display: none !important; }
body #math-visual-studio-view .math-visual-header { padding: 8px 14px !important; }
body #math-visual-studio-view .mv-scenario-pills-row { display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; overflow-x: auto !important; gap: 6px !important; align-items: center !important; padding-bottom: 2px !important; }
body #math-visual-studio-view .mv-scen-btn { white-space: nowrap !important; flex: 0 0 auto !important; width: auto !important; }
@media (max-width: 767.98px) {
  body #math-visual-studio-view #math-visual-workspace-grade-select,
  body #math-visual-studio-view #btn-mv-expand-problem,
  body #math-visual-studio-view .mv-scen-label,
  #geometry-drawing-board-view #tool-guide-pill { display: none !important; }
  #create-exam-mode-switcher { display: grid !important; grid-template-columns: 1fr 1fr !important; }
}
