:root {
  --bg: #f4f7fb;
  --ink: #1b2430;
  --muted: #4d5c70;
  --accent: #ff6f3c;
  --accent-2: #18b0b8;
  --card: #ffffff;
  --ok: #0f8f4f;
  --warn: #b54708;
  --border: #d8e1ec;
  --font-scale: 1;
  --base-font: 'Space Grotesk', sans-serif;
  --heading-font: 'Manrope', sans-serif;
  --access-gap: max(8px, env(safe-area-inset-right));
  --access-top: max(8px, env(safe-area-inset-top));
  --access-fab-size: 45px;
}

html {
  font-size: calc(16px * var(--font-scale));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--base-font);
  font-size: 1rem;
  color: var(--ink);
  background: radial-gradient(circle at 10% 10%, #dcf8ff 0%, transparent 30%),
    radial-gradient(circle at 80% 15%, #ffe7db 0%, transparent 35%),
    var(--bg);
  min-height: 100vh;
}

body.high-contrast .bg-logo {
  display: none;
}

body.dyslexia-font {
  --base-font: 'Lexend', sans-serif;
  --heading-font: 'Lexend', sans-serif;
}

body.high-contrast {
  --bg: #000000;
  --ink: #fff35c;
  --muted: #8fff63;
  --accent: #8fff63;
  --accent-2: #fff35c;
  --card: #000000;
  --ok: #8fff63;
  --warn: #fff35c;
  --border: #8fff63;
  background: var(--bg);
}

body.high-contrast .bg-shape {
  display: none;
}

body.high-contrast .panel,
body.high-contrast .quiz,
body.high-contrast .results,
body.high-contrast .question-card,
body.high-contrast .result-card,
body.high-contrast .diagram-wrap,
body.high-contrast .accessibility-panel,
body.high-contrast .access-toggle,
body.high-contrast .diagram-font-control,
body.high-contrast .dashboard-card,
body.high-contrast .mini-card,
body.high-contrast .stat-card,
body.high-contrast .meta span,
body.high-contrast .account-menu-bar {
  background: #000 !important;
  border-color: #8fff63 !important;
  color: #fff35c !important;
}

body.high-contrast select,
body.high-contrast input,
body.high-contrast textarea {
  background: #000;
  color: #fff35c;
  border-color: #8fff63;
}

body.high-contrast button {
  background: #8fff63;
  color: #000;
}

body.high-contrast .secondary,
body.high-contrast .purple-print,
body.high-contrast .access-fab {
  background: #fff35c;
  color: #000;
}

body.high-contrast .diagram-canvas {
  background: #000;
  border-color: #8fff63;
}

body.high-contrast .question-figure {
  background: #000;
  border-color: #8fff63;
}

body.high-contrast .video-modal-dialog,
body.high-contrast .video-modal-frame-wrap {
  background: #000;
  border-color: #8fff63;
  color: #fff35c;
}

.bg-shape {
  position: fixed;
  z-index: -2;
  border-radius: 999px;
  filter: blur(20px);
  opacity: 0.4;
}

.bg-logo {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url('/Images/logo.png') center 56% / min(70vw, 900px) no-repeat;
  opacity: 0.09;
  filter: saturate(0.9);
}

.shape-a {
  width: 280px;
  height: 280px;
  background: #9df0f7;
  top: -80px;
  right: 5%;
}

.shape-b {
  width: 220px;
  height: 220px;
  background: #ffd2c0;
  bottom: 40px;
  left: -50px;
}

.container {
  width: min(980px, 92vw);
  margin: 2rem auto 3rem;
}

.hero {
  margin-bottom: 1.2rem;
}

.hero-brand {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.hero-text {
  min-width: 0;
}

.site-logo {
  display: inline-block;
  width: clamp(81px, 11.2vw, 126px);
  height: auto;
  margin: 0;
}

.eyebrow {
  margin: 0;
  text-transform: none;
  font-size: clamp(1.7rem, 3.5vw, 2.8rem);
  letter-spacing: 0;
  color: var(--accent-2);
  font-weight: 800;
  font-family: var(--heading-font);
}

h1 {
  margin: 0.2rem 0;
  font-family: var(--heading-font);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.panel,
.quiz,
.results {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(26, 36, 48, 0.08);
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

.quiz-mode-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.quiz-mode-option {
  text-align: left;
}

.quiz-mode-option.active {
  outline: 2px solid rgba(24, 176, 184, 0.42);
  outline-offset: 1px;
}

.quiz-spec-picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

.accessibility-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 10px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--access-bar-height, 50px);
  min-height: 50px;
  overflow: hidden;
  white-space: normal;
}

.floating-access {
  position: fixed;
  top: var(--access-top);
  right: var(--access-gap);
  z-index: 36;
}

.floating-account-menu {
  position: fixed;
  top: var(--access-top);
  left: max(8px, env(safe-area-inset-left));
  z-index: 39;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: flex-start;
}

.account-menu-fab {
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.account-menu-panel {
  min-width: 200px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem;
  background: #fff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  display: grid;
  gap: 0.42rem;
}

.account-menu-panel button {
  width: 100%;
  text-align: left;
}

.account-menu-dialog {
  width: min(420px, 92vw);
}

.account-menu-dialog .student-banner {
  margin: 0 0 0.45rem;
}

.account-menu-dialog .actions {
  margin-top: 0.45rem;
  flex-direction: column;
}

.account-menu-dialog .actions button {
  width: 100%;
}

.access-fab {
  position: fixed;
  top: var(--access-top);
  right: var(--access-gap);
  width: var(--access-fab-size);
  height: var(--access-fab-size);
  display: grid;
  place-items: center;
  border-radius: 999px;
  padding: 0;
  background: linear-gradient(135deg, #202837, #3d4f68);
  z-index: 38;
}

.access-fab-icon {
  width: 45px;
  height: 45px;
  object-fit: contain;
  display: block;
}

.floating-access .accessibility-panel.access-collapsed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-12px);
}

.floating-access .accessibility-panel {
  position: fixed;
  top: max(0px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  right: calc(var(--access-gap) + var(--access-fab-size) + 10px);
  min-width: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease, height 0.18s ease;
  z-index: 37;
}

.access-title {
  margin: 0;
  font-weight: 800;
  font-size: 14px;
  flex: 0 0 auto;
}

.access-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px 8px;
  align-items: center;
  align-content: flex-start;
  flex: 1;
  min-width: 0;
}

.access-btn {
  padding: 6px 10px;
  border-radius: 10px;
  flex: 0 0 auto;
}

.access-readout {
  font-weight: 700;
  min-width: 3.2rem;
  text-align: center;
  flex: 0 0 auto;
}

.access-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 9px;
  background: #fff;
  font-weight: 600;
  flex: 0 0 auto;
}

.access-toggle input[type='checkbox'] {
  width: auto;
}

.access-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 8px;
  background: #fff;
  font-weight: 600;
  flex: 0 0 auto;
}

.access-select select {
  width: auto;
  min-width: 108px;
  padding: 5px 7px;
  border-radius: 8px;
}

.access-select input[type='range'] {
  width: 120px;
}

.floating-access button,
.floating-access select,
.floating-access input,
.floating-access label,
.floating-access .access-readout,
.floating-access .access-title {
  font-size: 14px !important;
  line-height: 1.2;
}

.reading-overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  pointer-events: none;
}

.marking-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.marking-overlay-card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  box-shadow: 0 10px 24px rgba(26, 36, 48, 0.18);
  max-width: min(560px, 92vw);
  text-align: center;
}

.marking-overlay-card p {
  margin: 0;
  font-weight: 700;
  color: var(--ink);
}

body.high-contrast .marking-overlay {
  background: rgba(0, 0, 0, 0.78);
}

body.high-contrast .marking-overlay-card {
  background: #000;
  border-color: #8fff63;
}

body.high-contrast .marking-overlay-card p {
  color: #fff35c;
}

label {
  font-weight: 700;
  font-size: 0.95rem;
}

select,
textarea,
button {
  font-family: inherit;
  font-size: 1rem;
  border-radius: 12px;
}

select,
input,
textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
}

button {
  border: 0;
  background: linear-gradient(135deg, var(--accent), #ff965f);
  color: #fff;
  font-weight: 700;
  padding: 0.72rem 1rem;
  cursor: pointer;
  transition: transform 0.14s ease, opacity 0.14s ease;
}

button:hover {
  transform: translateY(-1px);
}

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

.secondary {
  background: linear-gradient(135deg, #2d6cdf, #5e8fea);
}

.purple-print {
  background: linear-gradient(135deg, #6d28d9, #9333ea);
}

.button-icon {
  margin-right: 0.35rem;
}

.status {
  margin: 0.7rem 0 0;
  min-height: 1.2rem;
  color: var(--muted);
}

.student-banner {
  margin: 0;
  font-weight: 700;
}

#streakLine {
  margin: 0.3rem 0 0;
  font-weight: 700;
  color: var(--ok);
}

.auth-toggle {
  display: flex;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.auth-toggle button.active {
  outline: 2px solid rgba(24, 176, 184, 0.45);
}

.auth-form {
  margin-top: 0.35rem;
}

.account-menu-title {
  margin: 0 0 0.55rem;
}

.account-menu-bar {
  margin-top: 0.3rem;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(135deg, #eef4ff, #f8fbff);
}

.account-menu-bar button {
  flex: 1 1 180px;
}

#accountJoinClassWrap {
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

#accountJoinClassWrap h3 {
  margin: 0 0 0.45rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

#teacherDashboardPanel .dashboard-grid {
  align-items: start;
}

#teacherDashboardPanel .teacher-dashboard-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

#teacherDashboardPanel .teacher-dashboard-column {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-width: 0;
}

#teacherDashboardPanel .teacher-dashboard-right {
  gap: 0.9rem;
}

.dashboard-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.8rem;
  background: #fff;
}

.dashboard-card-full {
  grid-column: 1 / -1;
}

.dashboard-card h3 {
  margin: 0 0 0.55rem;
}

.dashboard-subsection {
  margin-top: 0.7rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.mini-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem;
  margin-top: 0.55rem;
  background: #fff;
}

.mini-card p {
  margin: 0.2rem 0;
  color: var(--muted);
}

.mini-card .actions {
  margin-top: 0.5rem;
}

.leaderboard-group-card {
  margin-top: 0.55rem;
}

.leaderboard-group-card:first-child {
  margin-top: 0;
}

.leaderboard-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.leaderboard-title-row p {
  margin: 0.2rem 0;
}

.leaderboard-table-wrap {
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  max-height: 260px;
  background: #fff;
}

.leaderboard-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 480px;
}

.leaderboard-table th,
.leaderboard-table td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.45rem;
  font-size: 0.88rem;
  text-align: left;
  vertical-align: top;
}

.leaderboard-table thead th {
  background: #f4f8ff;
  position: sticky;
  top: 0;
  z-index: 1;
}

.leaderboard-table td:nth-child(1),
.leaderboard-table th:nth-child(1) {
  width: 52px;
  text-align: center;
}

.leaderboard-table td:nth-child(3),
.leaderboard-table td:nth-child(4),
.leaderboard-table td:nth-child(5) {
  text-align: center;
}

.leaderboard-row-me td {
  background: #eef7ff;
  font-weight: 700;
}

.leaderboard-modal-list {
  margin-top: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem;
  max-height: 62vh;
  overflow: auto;
  background: #fff;
}

.leaderboard-filter-controls {
  margin-bottom: 0.35rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f9fcff;
}

.leaderboard-custom-dates {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.leaderboard-filter-actions {
  margin-top: 0.2rem;
}

.teacher-class-card {
  cursor: pointer;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem;
  background: #fff;
}

.stat-card.interactive-card {
  cursor: pointer;
  transition: box-shadow 0.14s ease, transform 0.14s ease, border-color 0.14s ease;
}

.stat-card.interactive-card:hover {
  transform: translateY(-1px);
  border-color: #9eb4cf;
  box-shadow: 0 8px 20px rgba(37, 55, 82, 0.12);
}

.stat-card.interactive-card:focus-visible {
  outline: 2px solid rgba(45, 108, 223, 0.5);
  outline-offset: 2px;
}

.stat-card .label {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-card .value {
  margin: 0.2rem 0 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
}

.hidden {
  display: none;
}

.question-card,
.result-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem;
  margin-top: 0.9rem;
  background: #fff;
}

.meta {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.meta span {
  background: #f5f8fc;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

h3 {
  margin: 0.2rem 0 0.6rem;
  font-size: 1.05rem;
}

.question-text {
  margin: 0.2rem 0 0.6rem;
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1.45;
}

.question-figure-wrap {
  margin: 0.35rem 0 0.7rem;
}

.question-figure-wrap p {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
  color: var(--muted);
  font-weight: 700;
}

.question-figure {
  width: 100%;
  max-width: 620px;
  max-height: 440px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.diagram-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem;
  margin-top: 0.8rem;
  background: #f9fcff;
}

.diagram-title {
  margin: 0 0 0.55rem;
  font-weight: 700;
  color: var(--ink);
}

.diagram-type-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.55rem;
}

.diagram-type-row label {
  font-size: 0.9rem;
}

.diagram-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.6rem;
}

.palette-item {
  border: 1px dashed #6a7f97;
  border-radius: 10px;
  background: #fff;
  color: #27425f;
  font-weight: 700;
  padding: 0.4rem 0.55rem;
  cursor: grab;
  user-select: none;
}

.diagram-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.6rem;
}

.diagram-font-control {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 0.9rem;
}

.diagram-font-control input[type='range'] {
  width: 130px;
}

.diagram-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  min-height: 420px;
  max-height: 84vh;
  border: 2px dashed #9fb4cb;
  border-radius: 10px;
  background: #fff;
  touch-action: none;
}

.diagram-item-body {
  cursor: move;
}

.diagram-handle {
  cursor: grab;
}

.diagram-move-indicator {
  cursor: move;
}

.diagram-resize-handle {
  cursor: nwse-resize;
}

.diagram-note {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.diagram-preview-wrap {
  margin: 0.55rem 0 0.3rem;
}

.diagram-preview {
  width: 100%;
  max-width: 540px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

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

.mcq-options {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.mcq-option {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  background: #fff;
}

.mcq-option input[type='radio'] {
  margin-top: 0.15rem;
}

.actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.setup-quiz-action-row {
  align-items: center;
}

.inline-setup-message {
  margin: 0;
  min-height: 0;
  max-width: 440px;
  color: var(--muted);
  font-size: 0.92rem;
}

.student-assignment-toolbar {
  margin-top: 0;
  margin-bottom: 0.45rem;
}

.student-assignment-summary {
  margin: 0 0 0.45rem;
}

.video-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
}

#quizSetupModal.video-modal {
  z-index: 62;
}

#assignmentPreviewModal.video-modal {
  z-index: 64;
}

#leaderboardModal.video-modal {
  z-index: 65;
}

#classReportModal.video-modal {
  overflow-y: auto;
  overscroll-behavior: contain;
}

#classReportModal .video-modal-backdrop {
  position: fixed;
}

#classReportModal .class-report-dialog {
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  margin: 3vh auto;
  max-height: none;
  overflow: visible;
}

.video-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.video-modal-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(940px, 94vw);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35);
}

.account-details-dialog {
  width: min(700px, 94vw);
  max-height: 88vh;
  overflow: auto;
}

.quiz-dialog {
  width: min(980px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.quiz-setup-dialog {
  width: min(980px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.quiz-limit-dialog {
  width: min(640px, 94vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.student-quiz-mode-dialog {
  width: min(860px, 94vw);
  max-height: 88vh;
}

.student-quiz-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.student-quiz-mode-btn {
  min-height: 172px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.45rem;
  text-align: left;
  padding: 1rem 1.1rem;
}

.student-quiz-mode-title {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
}

.student-quiz-mode-meta {
  display: block;
  font-size: 0.95rem;
  opacity: 0.94;
}

.teacher-groups-dialog {
  width: min(940px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.deadlines-dialog {
  width: min(760px, 94vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}

.deadlines-list {
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem;
  max-height: 64vh;
  overflow: auto;
  background: #fff;
}

.spend-drilldown-dialog {
  width: min(860px, 95vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.spend-drilldown-actions {
  margin: 0;
}

.spend-drilldown-list {
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem;
  max-height: 66vh;
  overflow: auto;
  background: #fff;
}

.spend-drilldown-empty {
  margin: 0;
}

.spend-row-btn {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 0.55rem;
  margin-top: 0.5rem;
  text-align: left;
}

.spend-row-btn:first-child {
  margin-top: 0;
}

.spend-row-btn[data-spend-group-id] {
  cursor: pointer;
}

.spend-row-btn[data-spend-group-id]:hover {
  border-color: #9eb4cf;
  box-shadow: 0 8px 20px rgba(37, 55, 82, 0.1);
}

.spend-row-btn .spend-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.3rem;
}

.spend-row-btn .spend-row-head p {
  margin: 0;
}

.spend-row-btn .spend-row-meta {
  margin: 0 0 0.3rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.spend-row-btn .spend-bar-track {
  width: 100%;
  height: 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #eef3fb;
  overflow: hidden;
}

.spend-row-btn .spend-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(135deg, #2d6cdf, #18b0b8);
}

.teacher-groups-list {
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem;
  max-height: 72vh;
  overflow: auto;
  background: #fff;
}

.assignment-preview-dialog {
  width: min(1120px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.assignment-preview-list {
  margin-top: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem;
  overflow: auto;
  max-height: 70vh;
  background: #fff;
}

.assignment-preview-card {
  margin-top: 0.65rem;
}

.assignment-preview-card:first-child {
  margin-top: 0;
}

.assignment-preview-options-wrap {
  margin-top: 0.45rem;
}

.assignment-preview-options-wrap p {
  margin: 0;
}

.assignment-preview-options {
  margin: 0.2rem 0 0.2rem 1.2rem;
}

.assignment-preview-options li {
  color: var(--muted);
  margin: 0.12rem 0;
}

.assignment-preview-markscheme {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f9fcff;
  padding: 0.55rem 0.6rem;
}

.assignment-preview-markscheme p {
  margin: 0.2rem 0;
}

.quiz-dialog #quizSection {
  margin: 0;
  max-height: calc(92vh - 110px);
  overflow: auto;
  border-color: var(--border);
  box-shadow: none;
}

.video-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.video-modal-header h3 {
  margin: 0;
}

.video-modal-frame-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}

.video-modal-frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.class-report-dialog {
  width: min(1160px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.student-history-dialog {
  width: min(1080px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.leaderboard-dialog {
  width: min(1120px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.class-report-actions {
  margin: 0;
}

.users-dialog {
  width: min(860px, 94vw);
  max-height: 86vh;
  overflow: auto;
}

.teacher-reset-student-dialog {
  width: min(920px, 94vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}

.teacher-reset-student-controls {
  margin: 0 0 0.35rem;
}

.teacher-reset-student-list {
  display: grid;
  gap: 0.55rem;
  overflow: auto;
  max-height: 62vh;
  padding-right: 0.1rem;
}

.teacher-reset-student-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
}

.teacher-reset-student-meta {
  flex: 1 1 auto;
}

.teacher-reset-student-meta p {
  margin: 0.18rem 0;
}

.admin-users-controls {
  margin: 0 0 0.35rem;
}

.admin-user-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
}

.admin-user-title {
  margin: 0;
  flex: 1 1 auto;
}

.admin-user-edit-btn {
  flex: 0 0 auto;
}

.admin-user-edit-panel {
  margin-top: 0.5rem;
}

.admin-user-controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.55rem;
  align-items: end;
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--border);
}

.admin-user-control label {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.admin-user-control input,
.admin-user-control select {
  margin-top: 0.2rem;
}

.admin-user-password-input {
  min-width: 260px;
}

.admin-user-action-cell {
  display: flex;
  align-items: flex-end;
}

.class-report-table-wrap {
  margin-top: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  max-height: 64vh;
  background: #fff;
}

.class-report-homework-wrap {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.55rem;
}

.class-homework-card {
  margin: 0;
}

.class-homework-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.65rem;
}

.class-homework-meta p {
  margin: 0.15rem 0;
}

.class-homework-actions {
  flex: 0 0 auto;
}

.class-homework-table-wrap {
  margin-top: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  max-height: 240px;
  background: #fff;
}

.class-homework-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 580px;
}

.class-homework-table th,
.class-homework-table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
  vertical-align: top;
  text-align: left;
}

.class-homework-table thead th {
  background: #f4f8ff;
  position: sticky;
  top: 0;
  z-index: 1;
}

.homework-status-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.homework-status-chip.is-complete {
  background: #ecfdf3;
  color: #027a48;
  border-color: #a6f4c5;
}

.homework-status-chip.is-pending {
  background: #fff8eb;
  color: #b54708;
  border-color: #fedf89;
}

.score-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
}

.score-table th,
.score-table td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.55rem;
  font-size: 0.92rem;
  text-align: center;
  vertical-align: top;
  white-space: nowrap;
}

.score-table thead th {
  position: sticky;
  top: 0;
  background: #f4f8ff;
  z-index: 1;
}

.score-table th:first-child,
.score-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  background: #fff;
  min-width: 200px;
}

.score-table thead th:first-child {
  z-index: 3;
  background: #eef4ff;
}

.score-table th:last-child,
.score-table td:last-child {
  font-weight: 700;
}

.score-table small {
  display: block;
  margin-top: 0.15rem;
  font-weight: 600;
  color: var(--muted);
}

.student-row-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}

.reset-student-password-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
}

.student-link-btn {
  background: transparent;
  color: #2d6cdf;
  padding: 0;
  font-size: 0.96rem;
  border: 0;
  text-decoration: underline;
  text-align: left;
}

.student-link-btn:hover {
  transform: none;
}

body.high-contrast .score-table thead th,
body.high-contrast .score-table th:first-child,
body.high-contrast .score-table td:first-child {
  background: #000 !important;
}

body.high-contrast .leaderboard-table thead th,
body.high-contrast .leaderboard-row-me td {
  background: #000 !important;
}

body.high-contrast .leaderboard-filter-controls {
  background: #000;
  border-color: #8fff63;
}

body.high-contrast .teacher-groups-list {
  background: #000;
  border-color: #8fff63;
}

body.high-contrast .class-homework-table thead th {
  background: #000 !important;
}

body.high-contrast .account-menu-panel,
body.high-contrast .account-menu-dialog {
  background: #000;
  border-color: #8fff63;
}

.result-top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.teacher-dashboard-top {
  align-items: center;
  gap: 0.65rem;
}

.teacher-top-actions {
  margin-top: 0;
  margin-left: auto;
  gap: 0.55rem;
}

.teacher-top-actions button {
  white-space: nowrap;
}

.result-top h2 {
  margin: 0;
}

#scoreLine {
  margin: 0;
  font-weight: 800;
}

.feedback {
  margin: 0.55rem 0 0;
  color: var(--ink);
}

.mark-chip {
  display: inline-block;
  margin-top: 0.4rem;
  font-weight: 800;
  color: var(--ok);
}

.pdf-export-host {
  position: fixed;
  left: -20000px;
  top: 0;
  width: 1120px;
  padding: 0;
  pointer-events: none;
  z-index: -1;
  background: #ffffff;
}

.pdf-export-sheet {
  width: 1080px;
  background: #ffffff;
  color: #1b2430;
  font-family: 'Space Grotesk', sans-serif;
  padding: 24px;
}

.pdf-export-summary,
.pdf-export-card {
  border: 1px solid #d8e1ec;
  border-radius: 12px;
  background: #ffffff;
  padding: 14px 16px;
}

.pdf-export-summary {
  margin-bottom: 12px;
}

.pdf-export-summary h2 {
  margin: 0 0 0.6rem;
  font-size: 1.35rem;
}

.pdf-export-summary p {
  margin: 0.2rem 0;
  line-height: 1.35;
  font-size: 0.96rem;
}

.pdf-export-card {
  margin-bottom: 12px;
}

.pdf-export-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
}

.pdf-export-meta span {
  background: #f5f8fc;
  border: 1px solid #d8e1ec;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.82rem;
  color: #4d5c70;
}

.pdf-export-question {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 400;
}

.pdf-export-label {
  margin: 0.45rem 0 0;
  font-size: 0.95rem;
  line-height: 1.45;
}

.pdf-export-image-wrap {
  margin: 0.45rem 0 0.2rem;
}

.pdf-export-image {
  display: block;
  width: 100%;
  max-width: 880px;
  border: 1px solid #d8e1ec;
  border-radius: 10px;
  background: #ffffff;
}

.pdf-export-awarded {
  margin: 0.5rem 0 0;
  font-weight: 800;
  color: #0f8f4f;
}

@media (pointer: coarse) {
  .palette-item {
    padding: 0.55rem 0.8rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    touch-action: manipulation;
  }

  .diagram-tools button,
  .diagram-font-control {
    min-height: 44px;
  }

  .diagram-note {
    font-size: 0.95rem;
  }
}

@media (max-width: 767px) and (pointer: coarse) {
  .floating-access {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .container {
    width: 94vw;
    margin-top: 1rem;
  }

  .diagram-canvas {
    min-height: 320px;
  }

  .floating-access .accessibility-panel {
    left: 6px;
    right: calc(var(--access-gap) + var(--access-fab-size) + 6px);
    border-radius: 10px;
  }

  .floating-account-menu {
    left: 6px;
  }

  .account-menu-dialog {
    width: min(96vw, 360px);
  }

  .accessibility-panel {
    padding: 0 6px;
    gap: 6px;
  }

  .access-title {
    display: none;
  }

  .dashboard-grid,
  .profile-stats {
    grid-template-columns: 1fr;
  }

  .dashboard-card-full {
    grid-column: auto;
  }

  #teacherDashboardPanel .teacher-dashboard-grid {
    grid-template-columns: 1fr;
  }

  #teacherDashboardPanel .teacher-dashboard-right {
    gap: 0.9rem;
  }

  .hero-brand {
    gap: 0.65rem;
  }

  .site-logo {
    width: clamp(57px, 18.2vw, 84px);
  }

  .class-report-dialog {
    width: 98vw;
    max-height: 92vh;
    padding: 0.6rem;
  }

  #classReportModal .class-report-dialog {
    margin: 2vh auto;
    max-height: none;
  }

  .users-dialog {
    width: 96vw;
  }

  .teacher-reset-student-dialog {
    width: 96vw;
  }

  .teacher-reset-student-head {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-user-head {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-user-edit-btn {
    align-self: flex-end;
  }

  .admin-user-controls-grid {
    grid-template-columns: 1fr;
  }

  .admin-user-password-input {
    min-width: 0;
  }

  .account-details-dialog,
  .quiz-dialog,
  .quiz-setup-dialog,
  .quiz-limit-dialog,
  .student-quiz-mode-dialog,
  .teacher-groups-dialog,
  .assignment-preview-dialog,
  .student-history-dialog,
  .leaderboard-dialog {
    width: 98vw;
    max-height: 92vh;
  }

  .leaderboard-modal-list {
    max-height: 70vh;
    padding: 0.5rem;
  }

  .teacher-groups-list {
    max-height: 72vh;
    padding: 0.5rem;
  }

  .leaderboard-custom-dates {
    grid-template-columns: 1fr;
  }

  .student-quiz-mode-grid {
    grid-template-columns: 1fr;
  }

  .assignment-preview-list {
    max-height: 72vh;
    padding: 0.5rem;
  }

  .quiz-dialog #quizSection {
    max-height: calc(92vh - 96px);
    padding: 0.75rem;
  }

  .class-report-table-wrap {
    max-height: 68vh;
  }

  .class-homework-head {
    flex-direction: column;
  }

  .class-homework-actions {
    width: 100%;
  }

  .class-homework-actions .secondary {
    width: 100%;
  }

  .class-homework-table {
    min-width: 0;
  }

  .class-homework-table th,
  .class-homework-table td {
    font-size: 0.84rem;
    padding: 0.35rem 0.42rem;
  }

  .leaderboard-table {
    min-width: 0;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    font-size: 0.82rem;
    padding: 0.32rem 0.38rem;
  }

  .score-table th,
  .score-table td {
    padding: 0.35rem 0.42rem;
    font-size: 0.84rem;
  }

  .score-table th:first-child,
  .score-table td:first-child {
    min-width: 155px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .no-print,
  .bg-shape {
    display: none !important;
  }

  .container {
    width: 100%;
    margin: 0;
  }

  .results,
  .result-card {
    box-shadow: none;
    border-color: #bbb;
  }
}

@media screen {
/* ===== Design Option A: Academic Slate ===== */
body:not(.high-contrast) {
  --bg: #eef3f9;
  --ink: #10233f;
  --muted: #425b79;
  --accent: #2e67d8;
  --accent-2: #1098a6;
  --card: #ffffff;
  --border: #cfdae8;
  --ok: #0e8a55;
  --warn: #b45309;
  background:
    radial-gradient(circle at 8% 8%, rgba(46, 103, 216, 0.09), transparent 32%),
    radial-gradient(circle at 84% 10%, rgba(16, 152, 166, 0.09), transparent 34%),
    linear-gradient(180deg, #f6f9ff 0%, #eef3f9 100%);
}

body:not(.high-contrast) .bg-logo {
  opacity: 0.06;
  filter: grayscale(1) contrast(1.06);
}

.container {
  width: min(1220px, 94vw);
  margin: 1.25rem auto 2.75rem;
}

.hero {
  position: relative;
  margin-bottom: 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid rgba(207, 218, 232, 0.9);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.97), rgba(247, 251, 255, 0.96));
  box-shadow: 0 14px 38px rgba(16, 35, 63, 0.08);
}

.hero::after {
  content: '';
  display: block;
  width: min(180px, 36%);
  height: 3px;
  margin-top: 0.75rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.hero-brand {
  align-items: center;
  gap: 1.05rem;
}

.site-logo {
  width: clamp(72px, 8vw, 106px);
  filter: drop-shadow(0 8px 18px rgba(16, 35, 63, 0.2));
}

.eyebrow {
  font-size: clamp(1.65rem, 2.9vw, 2.65rem);
  color: #0f8ca1;
}

h1 {
  margin: 0.25rem 0 0.4rem;
  font-size: clamp(0.92rem, 1.45vw, 1.05rem);
  letter-spacing: 0.11em;
  color: #2b4568;
}

.subtitle {
  max-width: 74ch;
  line-height: 1.42;
}

.panel,
.quiz,
.results {
  border-radius: 20px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow: 0 12px 34px rgba(16, 35, 63, 0.07);
  padding: 1.05rem;
}

.panel + .panel {
  margin-top: 0.95rem;
}

.result-top h2 {
  font-family: var(--heading-font);
  font-size: clamp(1.55rem, 2.1vw, 2rem);
  letter-spacing: -0.01em;
}

.result-top p {
  font-weight: 700;
}

.dashboard-grid {
  gap: 1rem;
}

#teacherDashboardPanel .teacher-dashboard-column {
  gap: 1rem;
}

.dashboard-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.92rem;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 10px 25px rgba(16, 35, 63, 0.06);
}

.dashboard-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, rgba(46, 103, 216, 0.95), rgba(16, 152, 166, 0.85));
}

.dashboard-card h3 {
  margin: 0 0 0.65rem;
  font-family: var(--heading-font);
  font-size: 1.05rem;
}

.dashboard-subsection {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed #bfcfe4;
}

.profile-stats {
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 0.72rem;
}

.stat-card {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fdfefe;
  padding: 0.68rem;
}

.stat-card .label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4d6484;
}

.stat-card .value {
  font-size: clamp(1.15rem, 1.85vw, 1.45rem);
  line-height: 1.1;
}

.mini-card,
.question-card,
.result-card {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #ffffff;
}

label {
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  color: #203858;
}

input,
select,
textarea {
  border-radius: 14px;
  border: 1px solid #c6d4e6;
  background: #f8fbff;
  color: var(--ink);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

input::placeholder,
textarea::placeholder {
  color: #6f7f97;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #4d79db;
  box-shadow: 0 0 0 3px rgba(77, 121, 219, 0.18);
  background: #ffffff;
}

button {
  border-radius: 14px;
  padding: 0.74rem 1rem;
  background: linear-gradient(135deg, #2f6fea, #2d8ccf);
  box-shadow: 0 8px 18px rgba(33, 85, 188, 0.25);
  transition: transform 0.14s ease, box-shadow 0.2s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(33, 85, 188, 0.28);
}

button:focus-visible {
  outline: none;
  box-shadow:
    0 12px 24px rgba(33, 85, 188, 0.28),
    0 0 0 3px rgba(78, 132, 230, 0.28);
}

button:disabled {
  box-shadow: none;
}

.secondary {
  background: linear-gradient(135deg, #355186, #49689c);
  box-shadow: 0 8px 18px rgba(34, 52, 86, 0.22);
}

.status {
  margin-top: 0.62rem;
  padding: 0.52rem 0.68rem;
  min-height: 0;
  border-radius: 12px;
  border: 1px solid #d0dceb;
  background: #f7fbff;
}

.status:empty {
  display: none;
}

.student-assignment-summary {
  border-style: solid;
}

.teacher-class-card {
  border-left: 4px solid #3a76e7;
}

.leaderboard-table thead th {
  background: #edf4ff;
}

.leaderboard-row-me td {
  background: #e7f0ff;
}

.score-table thead th {
  background: #edf4ff;
}

.video-modal-backdrop {
  background: rgba(6, 15, 33, 0.5);
  backdrop-filter: blur(4px);
}

.video-modal-dialog {
  border-radius: 18px;
  border: 1px solid #bfd0e5;
  box-shadow: 0 20px 46px rgba(7, 17, 36, 0.35);
}

.video-modal-header h3 {
  font-family: var(--heading-font);
}

.accessibility-panel {
  border-radius: 16px;
  border-color: #b9cce4;
  box-shadow: 0 12px 30px rgba(12, 29, 57, 0.22);
}

.account-menu-fab {
  border-radius: 999px;
  background: linear-gradient(135deg, #1f3e73, #355891);
  box-shadow: 0 10px 24px rgba(13, 33, 65, 0.3);
}
}

@media screen and (max-width: 640px) {
  .hero {
    padding: 0.85rem 0.9rem;
  }

  .hero::after {
    width: 48%;
  }

  .panel,
  .quiz,
  .results {
    padding: 0.82rem;
    border-radius: 16px;
  }

  .dashboard-card {
    padding: 0.75rem;
  }

  #teacherDashboardPanel .teacher-dashboard-top {
    align-items: stretch;
  }

  .teacher-top-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .teacher-top-actions button {
    flex: 1 1 148px;
    white-space: normal;
    text-align: center;
  }
}
