:root {
  --app-bg: #f5f8fc;
  --app-ink: #1f2937;
  --app-muted: #64748b;
  --app-primary: #2563eb;
  --app-primary-dark: #1e3a8a;
  --app-secondary: #0ea5e9;
  --app-accent: #f59e0b;
  --app-success: #16a34a;
  --app-danger: #dc2626;
  --app-info: #0891b2;
  --app-card: #ffffff;
  --app-border: #d9e2f0;
  --app-soft-blue: #eaf2ff;
  --app-shadow: 0 10px 24px rgba(15, 23, 42, .09);
  --app-shadow-sm: 0 6px 16px rgba(15, 23, 42, .06);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--app-ink);
}

main.container {
  position: relative;
}

.app-navbar {
  background: linear-gradient(90deg, #0f172a, #1e3a8a 55%, #2563eb);
  box-shadow: 0 4px 16px rgba(15, 23, 42, .18);
}

.app-navbar .navbar-brand {
  letter-spacing: -.02em;
}

.app-navbar .nav-link {
  border-radius: .55rem;
  padding-left: .85rem !important;
  padding-right: .85rem !important;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus,
.app-navbar .nav-link.active {
  background: rgba(255,255,255,.12);
}

.site-footer {
  color: #64748b;
  background: transparent;
}

.page-kicker {
  color: var(--app-primary);
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: .78rem;
}

.app-card {
  border: 1px solid var(--app-border);
  border-radius: .9rem;
  box-shadow: var(--app-shadow-sm);
  background: var(--app-card);
}

.app-card .card-header {
  border-top-left-radius: .9rem;
  border-top-right-radius: .9rem;
  background: #f8fbff;
  border-bottom-color: var(--app-border);
}

.btn {
  border-radius: .55rem;
  font-weight: 700;
}

.btn-primary {
  background: linear-gradient(90deg, var(--app-primary), var(--app-secondary));
  border-color: transparent;
  box-shadow: 0 5px 12px rgba(37, 99, 235, .22);
}

.btn-primary:hover,
.btn-primary:focus {
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(37, 99, 235, .28);
}

.btn-outline-primary {
  border-color: rgba(37, 99, 235, .5);
}

.form-control,
.form-select {
  border-radius: .55rem;
  border-color: #cbd7ea;
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(37,99,235,.65);
  box-shadow: 0 0 0 .2rem rgba(37,99,235,.12);
}

.table thead th {
  color: var(--app-muted);
  font-size: .78rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.alert {
  border-radius: .75rem;
}

.login-shell {
  min-height: calc(100vh - 210px);
}

.login-intro {
  background: linear-gradient(135deg, #1e3a8a, #2563eb 55%, #0ea5e9);
  color: #fff;
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: var(--app-shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-feature {
  height: 100%;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: .75rem;
  padding: .9rem;
}

.login-feature i {
  font-size: 1.4rem;
  display: block;
  margin-bottom: .45rem;
}

.login-feature strong,
.login-feature span {
  display: block;
}

.login-feature span {
  font-size: .9rem;
  opacity: .85;
  margin-top: .25rem;
}

.login-card {
  box-shadow: var(--app-shadow);
}

.login-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: inline-grid;
  place-items: center;
  border-radius: .75rem;
  background: var(--app-soft-blue);
  color: var(--app-primary);
  font-size: 1.45rem;
}

.login-register-note {
  border: 1px solid var(--app-border);
  background: #f8fbff;
  border-radius: .75rem;
  padding: .9rem;
}

.login-register-note strong,
.login-register-note span {
  display: block;
}

.login-register-note span {
  color: var(--app-muted);
  font-size: .95rem;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--app-border);
  border-top: 4px solid var(--stat-accent, var(--app-primary));
  border-radius: .85rem;
  padding: 1rem;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--app-shadow-sm);
}

.stat-card span {
  color: var(--app-muted);
  font-size: .9rem;
  font-weight: 700;
}

.stat-card strong {
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -.03em;
}

.stat-card.primary { --stat-accent: #2563eb; }
.stat-card.success { --stat-accent: #16a34a; }
.stat-card.warning { --stat-accent: #f59e0b; }
.stat-card.purple { --stat-accent: #7c3aed; }
.stat-card.info { --stat-accent: #0891b2; }
.stat-card.danger { --stat-accent: #dc2626; }

.student-hero {
  background: linear-gradient(90deg, #1e3a8a, #2563eb 60%, #0ea5e9);
  color: #fff;
  border-radius: 1rem;
  padding: 1.35rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  box-shadow: var(--app-shadow);
}

.hero-stats {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  justify-content: end;
}

.hero-stats div,
.hero-stat-card {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: .75rem;
  padding: .75rem 1rem;
  min-width: 112px;
}

.hero-stats span {
  display: block;
  font-size: .78rem;
  opacity: .82;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.hero-stats strong {
  font-size: 1.65rem;
  line-height: 1;
}

.hero-stats small {
  display: block;
  margin-top: .25rem;
  font-size: .72rem;
  opacity: .86;
  font-weight: 600;
}

.topic-card {
  --topic-accent: #2563eb;
  position: relative;
  display: block;
  height: 100%;
  background: #fff;
  color: inherit;
  text-decoration: none;
  border: 1px solid var(--app-border);
  border-top: 4px solid var(--topic-accent);
  border-radius: .9rem;
  padding: 1.1rem;
  box-shadow: var(--app-shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.topic-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--app-shadow);
  border-color: #b9c9e8;
}

.topic-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: inline-grid;
  place-items: center;
  border-radius: .7rem;
  background: var(--topic-icon-bg, var(--app-soft-blue));
  color: var(--topic-accent);
  font-size: 1.2rem;
}

.topic-card-heading {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  padding-right: 5.8rem;
}

.topic-title-wrap {
  min-width: 0;
}

.topic-level-badge {
  position: absolute;
  top: .85rem;
  right: .85rem;
  box-shadow: 0 6px 16px rgba(16, 185, 129, .18);
}

.topic-count-badge {
  vertical-align: middle;
  margin-left: .35rem;
  font-size: .7rem;
}

.topic-card h3 {
  font-size: 1.12rem;
  margin-bottom: .35rem;
}

.topic-card p {
  color: var(--app-muted);
  margin-bottom: 0;
}

.topic-card .progress {
  height: .5rem;
  border-radius: 999px;
  background-color: #e8eefb;
}

.topic-card .progress-bar {
  background: linear-gradient(90deg, var(--topic-accent), #38bdf8);
}

@media (max-width: 575.98px) {
  .student-hero {
    align-items: stretch;
  }

  .hero-stats {
    justify-content: stretch;
  }

  .hero-stat-card {
    width: 100%;
  }

  .topic-card-heading {
    padding-right: 0;
    padding-top: 1.65rem;
  }

  .topic-level-badge {
    left: 1.1rem;
    right: auto;
  }
}

.level-pill {
  border: 1px solid var(--app-border);
  border-radius: .55rem;
  padding: .32rem .6rem;
  background: #fff;
  font-weight: 800;
  font-size: .78rem;
}

.question-header-panel,
.mission-panel,
.problem-panel {
  border: 1px solid var(--app-border);
  border-radius: .9rem;
  background: #fff;
  box-shadow: var(--app-shadow-sm);
}

.question-header-panel {
  padding: 1rem;
}

.mission-panel {
  background: linear-gradient(90deg, #eff6ff, #f8fbff);
  padding: 1rem;
}

.mission-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: inline-grid;
  place-items: center;
  border-radius: .7rem;
  color: var(--app-primary);
  background: #dbeafe;
  font-size: 1.25rem;
}

.problem-panel {
  padding: 1.15rem;
}

.question-text {
  background: #f8fbff;
  border: 1px solid var(--app-border);
  border-radius: .75rem;
  padding: 1rem;
  font-size: 1.07rem;
  line-height: 1.65;
}

.practice-column-card {
  min-height: 100%;
}

.drop-zone {
  display: grid;
  gap: .75rem;
}

.drop-slot {
  background: #f8fafc;
  border: 2px dashed #b8c5e4;
  border-radius: .75rem;
  min-height: 86px;
  padding: .75rem;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.drop-slot.drag-over,
.card-bank.drag-over {
  background: #eff6ff;
  border-color: var(--app-primary);
  transform: translateY(-1px);
}

.slot-label {
  display: inline-block;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--app-muted);
  text-transform: uppercase;
  margin-bottom: .35rem;
}

.slot-content {
  font-size: .95rem;
}

.card-bank {
  background: #f8fbff;
  border: 2px dashed #cbd7ea;
  border-radius: .75rem;
  padding: .75rem;
  min-height: 260px;
  display: grid;
  gap: .75rem;
  align-content: start;
}

.reasoning-card {
  background: #fff;
  border: 1px solid #cfd8ee;
  border-left: 5px solid var(--app-primary);
  border-radius: .7rem;
  padding: .85rem 1rem;
  box-shadow: 0 5px 12px rgba(15,23,42,.06);
  cursor: grab;
  user-select: none;
  line-height: 1.45;
}

.reasoning-card:active {
  cursor: grabbing;
}

.reasoning-card.dragging {
  opacity: .55;
}

.reasoning-card.selected {
  outline: 3px solid rgba(37,99,235,.25);
  border-color: var(--app-primary);
}

.reasoning-card.correct,
.drop-slot.slot-correct {
  border-color: var(--app-success);
}

.reasoning-card.incorrect,
.drop-slot.slot-incorrect {
  border-color: var(--app-danger);
}

.drop-slot.slot-correct {
  background: #f0fdf4;
}

.drop-slot.slot-incorrect {
  background: #fef2f2;
}

.feedback-panel {
  border-radius: .75rem;
}

.mission-timer {
  background: #fff;
  border: 1px solid var(--app-border);
  border-left: 4px solid var(--app-accent);
  border-radius: .75rem;
  padding: .75rem 1rem;
  min-width: 130px;
  box-shadow: var(--app-shadow-sm);
}

.user-card {
  border: 1px solid var(--app-border);
  border-radius: .85rem;
  background: #fff;
  padding: 1rem;
  box-shadow: 0 5px 14px rgba(15,23,42,.05);
}

.user-avatar {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: .7rem;
  background: var(--app-soft-blue);
  color: var(--app-primary-dark);
  font-weight: 900;
}

.role-badge-admin {
  background: rgba(124, 58, 237, .12);
  color: #5b21b6;
  border: 1px solid rgba(124, 58, 237, .22);
}

.role-badge-student {
  background: rgba(8, 145, 178, .12);
  color: #0e7490;
  border: 1px solid rgba(8, 145, 178, .22);
}

@media (max-width: 767px) {
  .student-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-stats {
    justify-content: stretch;
  }

  .hero-stats div {
    flex: 1;
    min-width: 0;
  }

  .login-intro {
    padding: 1.35rem;
  }
}

/* V4 reasoning workspace: flexible insertion, step groups and highlighting. */
.sticky-problem-panel {
  position: sticky;
  top: 76px;
  z-index: 10;
}

.problem-panel.sticky-problem-panel {
  border-left: 4px solid var(--app-primary);
}

.question-text.highlighter-surface {
  background: #ffffff;
  border-color: #b7c7e7;
  font-size: 1.12rem;
  line-height: 1.75;
  min-height: 92px;
}

.highlighter-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem;
}

.highlight-btn {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(15,23,42,.22);
  border-radius: .35rem;
  box-shadow: inset 0 -3px 0 rgba(15,23,42,.08);
  cursor: pointer;
}

.highlight-btn:hover,
.highlight-btn:focus {
  outline: 3px solid rgba(37,99,235,.15);
}

.highlight-yellow,
.student-highlight.highlight-yellow { background: #fef08a; }
.highlight-green,
.student-highlight.highlight-green { background: #bbf7d0; }
.highlight-blue,
.student-highlight.highlight-blue { background: #bfdbfe; }
.highlight-pink,
.student-highlight.highlight-pink { background: #fbcfe8; }
.student-highlight {
  border-radius: .18rem;
  padding: .05rem .08rem;
}

.sequence-drop-zone {
  display: grid;
  gap: .75rem;
  min-height: 360px;
  background: #f8fbff;
  border: 2px dashed #b8c5e4;
  border-radius: .65rem;
  padding: .85rem;
  align-content: start;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.sequence-drop-zone.drag-over,
.card-bank.drag-over {
  background: #eff6ff;
  border-color: var(--app-primary);
}

.drop-zone-empty {
  min-height: 115px;
  border: 1px dashed #cbd7ea;
  border-radius: .55rem;
  display: grid;
  place-items: center;
  background: #fff;
  font-weight: 700;
}

.insert-marker {
  border: 2px solid var(--app-primary);
  border-radius: 999px;
  height: 28px;
  display: grid;
  place-items: center;
  background: #eff6ff;
  color: var(--app-primary-dark);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  box-shadow: 0 4px 10px rgba(37,99,235,.12);
}

.reasoning-card.in-sequence {
  border-left-color: var(--app-accent);
  padding-top: .95rem;
}

.card-position-badge {
  display: inline-block;
  margin: 0 .55rem .25rem 0;
  padding: .18rem .45rem;
  border-radius: .35rem;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: .74rem;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.reasoning-card.correct {
  background: #f0fdf4;
  border-color: var(--app-success);
}

.reasoning-card.incorrect {
  background: #fef2f2;
  border-color: var(--app-danger);
}

.sequence-status {
  min-height: 1.2rem;
}

@media (max-width: 991px) {
  .sticky-problem-panel {
    top: 64px;
  }
}


/* V5 multi-topic/multi-path interface refinements. */
.topic-checkbox-grid {
  max-height: 150px;
  overflow: auto;
}

.problem-tags .badge {
  font-weight: 700;
}

.problem-panel .h5 {
  letter-spacing: -.01em;
}

.highlighter-toolbar .btn-sm {
  border-radius: .4rem;
  font-weight: 700;
}

.step-admin-row {
  border-color: var(--app-border) !important;
}

.step-admin-row .form-label {
  font-size: .82rem;
  font-weight: 800;
  color: var(--app-muted);
}

.sequence-drop-zone .reasoning-card {
  position: relative;
}

@media (max-width: 991px) {
  .sticky-problem-panel {
    top: 64px;
  }

  .highlighter-toolbar {
    width: 100%;
  }
}

/* V6 teacher solution editor + diagnostics. */
.question-editor-card .form-label {
  font-weight: 800;
  color: var(--app-muted);
  font-size: .84rem;
}

.solution-admin-card {
  border-color: #d8e2f1 !important;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .04);
}

.solution-admin-card::before {
  content: "Accepted Solution";
  display: inline-block;
  margin-bottom: .55rem;
  padding: .18rem .5rem;
  border-radius: .35rem;
  background: #eaf2ff;
  color: var(--app-primary-dark);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.solution-step-row {
  background: #f8fbff;
  border-color: #dbe7f6 !important;
}

.distractor-admin-row {
  border-color: #fde2b7 !important;
  background: #fffaf0 !important;
}

.log-context {
  max-width: 520px;
  max-height: 160px;
  overflow: auto;
  font-size: .76rem;
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: .4rem;
  padding: .5rem;
}

.error-log-table td {
  vertical-align: top;
}

/* V7 M1 marking logic + user reset tools. */
.reasoning-card.supporting-correct {
  background: #f8fafc;
  border-color: #94a3b8;
  border-style: dashed;
}

.logic-assessment-panel {
  border: 1px solid #dbe7f6;
  border-radius: .65rem;
  background: #fff;
  padding: .9rem;
  box-shadow: inset 4px 0 0 rgba(37, 99, 235, .18);
}

.logic-assessment-panel.incomplete {
  background: #fffbeb;
  border-color: #fde68a;
  box-shadow: inset 4px 0 0 #f59e0b;
}

.logic-assessment-panel.complete {
  background: #f0fdf4;
  border-color: #bbf7d0;
  box-shadow: inset 4px 0 0 #22c55e;
}

.logic-assessment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}

.logic-step-list {
  padding-left: 0;
  margin-bottom: 0;
  list-style: none;
  display: grid;
  gap: .55rem;
}

.logic-step-item {
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(148, 163, 184, .25);
  border-radius: .55rem;
  padding: .7rem;
}

.logic-step-number {
  display: inline-grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: .35rem;
  background: #e0edff;
  color: var(--app-primary-dark);
  font-weight: 900;
  font-size: .75rem;
  margin-right: .35rem;
}

.logic-step-badges {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 125px;
}

.logic-used,
.logic-added {
  font-size: .72rem;
  font-weight: 800;
  color: var(--app-muted);
  white-space: nowrap;
}

.logic-answer {
  border-top: 1px dashed rgba(34, 197, 94, .45);
  padding-top: .75rem;
}

.user-admin-danger-zone {
  border: 1px solid #fecaca;
  background: #fff7f7;
  border-radius: .65rem;
}

.user-admin-danger-zone .form-label,
.user-admin-override-zone .form-label {
  font-size: .82rem;
  font-weight: 800;
  color: var(--app-muted);
}

.user-admin-override-zone {
  border: 1px solid #bfdbfe;
  background: #f8fbff;
  border-radius: .65rem;
}

.question-actions {
  display: grid;
  gap: .4rem;
  width: 122px;
}

.question-actions form,
.question-actions .btn {
  width: 100%;
}

.question-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  white-space: nowrap;
}

.question-status {
  min-width: 64px;
  border-radius: .45rem;
  padding: .42rem .62rem;
  font-weight: 800;
}

.question-status.active {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #86efac;
}

.question-status.draft {
  color: #57534e;
  background: #f5f5f4;
  border: 1px solid #d6d3d1;
}

.sortable-heading {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  text-decoration: none;
  white-space: nowrap;
}

.sortable-heading:hover,
.sortable-heading.active {
  color: var(--app-primary);
}

.question-list-table th {
  font-size: .78rem;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.question-title-cell {
  min-width: 260px;
}

.question-preview {
  max-width: 420px;
  margin-top: .2rem;
}


/* Keep admin question editor modals above their backdrops even when embedded from within page containers. */
.question-edit-modal {
  z-index: 2060;
}

.question-edit-modal .modal-dialog {
  position: relative;
  z-index: 2061;
}

.modal-backdrop {
  z-index: 2050;
}

.question-edit-modal .modal-dialog {
  max-width: min(1180px, calc(100vw - 1.5rem));
}

.question-edit-modal .modal-body {
  height: min(84vh, 940px);
  background: var(--app-bg);
}

.question-edit-modal iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--app-bg);
}

.modal-editor-body {
  background: var(--app-bg);
}

.question-editor-modal-shell {
  max-width: 1120px;
}

.user-card-actions {
  display: grid;
  gap: .4rem;
  width: 148px;
  flex: 0 0 148px;
}

.user-card-actions form,
.user-card-actions .btn {
  width: 100%;
}

.user-card-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  white-space: nowrap;
}

@media (max-width: 1199px) {
  .user-card-actions {
    width: 100%;
    flex-basis: auto;
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  }
}

.admin-action-btn {
  display: inline-grid !important;
  grid-template-columns: 1.35rem minmax(0, 1fr);
  align-items: center;
  justify-content: start;
  column-gap: .45rem;
  text-align: left;
}

.admin-action-btn .btn-icon-col {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  line-height: 1;
}

.admin-action-btn .btn-label {
  display: inline-block;
  min-width: 0;
}

.question-actions .admin-action-btn,
.user-card-actions .admin-action-btn {
  justify-content: start;
}

.question-actions {
  width: 132px;
}

.user-card-actions {
  width: 154px;
  flex-basis: 154px;
}

/* Admin math quick-insert toolbar */
.math-symbol-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .4rem;
}

.math-toolbar-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: .25rem;
  padding-right: .45rem;
  border-right: 1px solid rgba(15, 23, 42, .12);
}

.math-toolbar-group:last-child {
  border-right: 0;
  padding-right: 0;
}

.math-symbol-toolbar .btn {
  min-width: 2.4rem;
  line-height: 1.1;
  font-weight: 600;
  border-radius: .45rem;
}

.math-symbol-toolbar .format-btn {
  min-width: 2.25rem;
}

.math-symbol-toolbar .btn[title="Square"],
.math-symbol-toolbar .btn[title="Cube"] {
  min-width: 2.8rem;
}

.question-editor-card .math-symbol-toolbar + .form-text {
  margin-top: .25rem;
}

/* V20 next-step hints + animated result modal. */
.result-modal .modal-dialog {
  transform: translateY(22px) scale(.96);
  transition: transform .26s cubic-bezier(.2, .9, .3, 1.2), opacity .2s ease;
}

.result-modal.show .modal-dialog {
  transform: translateY(0) scale(1);
}

.result-modal-content {
  border: 0;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .24);
}

.result-modal-header {
  background: linear-gradient(135deg, #f8fbff, #eef6ff);
  border-bottom: 1px solid #dbe7f6;
}

.result-modal-success .result-modal-header {
  background: linear-gradient(135deg, #ecfdf5, #e0f2fe);
}

.result-modal-review .result-modal-header {
  background: linear-gradient(135deg, #fffbeb, #eef6ff);
}

.result-modal-icon {
  width: 54px;
  height: 54px;
  display: inline-grid;
  place-items: center;
  border-radius: .9rem;
  background: #e0edff;
  color: var(--app-primary-dark);
  font-size: 1.55rem;
  box-shadow: inset 0 -4px 0 rgba(15, 23, 42, .06);
}

.result-modal-success .result-modal-icon {
  background: #dcfce7;
  color: #15803d;
  animation: resultIconPop .55s cubic-bezier(.2, 1.4, .3, 1) both;
}

.result-modal-review .result-modal-icon {
  background: #fef3c7;
  color: #b45309;
}

.result-modal-subtitle {
  color: var(--app-muted);
}

.result-score-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}

.result-score-box {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  border-radius: .8rem;
  padding: .9rem 1rem;
  box-shadow: 0 8px 18px rgba(22, 163, 74, .08);
}

.result-score-value {
  font-size: 1.8rem;
  line-height: 1;
  font-weight: 900;
  color: #15803d;
}

.result-message-panel {
  border-radius: .75rem;
}

.result-modal .logic-assessment-panel {
  margin: 0;
}

.success-burst {
  position: relative;
  height: 0;
  pointer-events: none;
}

.success-burst span {
  position: absolute;
  top: -10px;
  left: 50%;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #22c55e;
  opacity: 0;
  animation: successBurst .85s ease-out both;
}

.success-burst span:nth-child(2) {
  background: #f59e0b;
  animation-delay: .05s;
}

.success-burst span:nth-child(3) {
  background: #2563eb;
  animation-delay: .1s;
}

.success-burst span:nth-child(4) {
  background: #ec4899;
  animation-delay: .15s;
}

.success-burst span:nth-child(5) {
  background: #14b8a6;
  animation-delay: .2s;
}

@keyframes resultIconPop {
  0% { transform: scale(.65) rotate(-8deg); opacity: .4; }
  65% { transform: scale(1.12) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes successBurst {
  0% { transform: translate(-50%, 0) scale(.4); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--burst-x, 0px)), var(--burst-y, -60px)) scale(1); opacity: 0; }
}

.success-burst span:nth-child(1) { --burst-x: -120px; --burst-y: -52px; }
.success-burst span:nth-child(2) { --burst-x: -60px; --burst-y: -78px; }
.success-burst span:nth-child(3) { --burst-x: 0px; --burst-y: -62px; }
.success-burst span:nth-child(4) { --burst-x: 62px; --burst-y: -82px; }
.success-burst span:nth-child(5) { --burst-x: 124px; --burst-y: -55px; }

@media (max-width: 575px) {
  .result-score-row {
    grid-template-columns: 1fr;
  }

  .result-modal-icon {
    width: 46px;
    height: 46px;
    font-size: 1.3rem;
  }
}

/* V21 result modal z-index hotfix: keep student assessment modals above the shared Bootstrap backdrop. */
.result-modal {
  z-index: 2070;
}

.result-modal .modal-dialog {
  position: relative;
  z-index: 2071;
}

body.modal-open .result-modal.show {
  display: block;
}

/* V22 progression locking */
.progress-level-section.progress-level-locked .topic-icon {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #64748b;
}

.progress-lock-note {
  max-width: 100%;
  white-space: normal;
  text-align: left;
}

.question-path-card.is-locked {
  background: #f8fafc;
  border-style: dashed;
  box-shadow: none;
}

.question-path-card.is-locked .card-body {
  color: #64748b;
}

/* V23 success-modal actions: keep wrong attempts focused; offer retry/next after completion. */
.result-modal-footer-actions .btn,
.result-keep-working-btn {
  min-width: 150px;
}

@media (max-width: 575px) {
  .result-modal-footer,
  .result-modal-footer-actions {
    width: 100%;
  }

  .result-modal-footer .btn,
  .result-modal-footer-actions .btn,
  .result-keep-working-btn {
    width: 100%;
  }
}

/* V27 student whiteboard side drawer */
.student-whiteboard-shell {
  position: fixed;
  inset: 0 0 auto auto;
  pointer-events: none;
  z-index: 1040;
}

.whiteboard-tab {
  position: fixed;
  right: 0;
  top: 44%;
  transform: translateY(-50%);
  pointer-events: auto;
  border: 1px solid rgba(37, 99, 235, .45);
  border-right: 0;
  border-radius: .75rem 0 0 .75rem;
  background: linear-gradient(135deg, var(--app-primary), var(--app-secondary));
  color: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .2);
  padding: .85rem .55rem;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-weight: 800;
  letter-spacing: .02em;
}

.whiteboard-tab i {
  writing-mode: horizontal-tb;
  transform: rotate(90deg);
  font-size: 1.05rem;
}

.whiteboard-tab:hover,
.whiteboard-tab:focus {
  filter: brightness(1.04);
  outline: none;
  box-shadow: 0 14px 32px rgba(37, 99, 235, .28);
}

.whiteboard-drawer {
  position: fixed;
  top: 72px;
  right: 0;
  bottom: 18px;
  width: min(430px, calc(100vw - 48px));
  transform: translateX(104%);
  transition: transform .24s ease;
  pointer-events: auto;
  background: #ffffff;
  border: 1px solid var(--app-border);
  border-right: 0;
  border-radius: 1rem 0 0 1rem;
  box-shadow: -18px 22px 48px rgba(15, 23, 42, .18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.student-whiteboard-shell.is-open .whiteboard-drawer {
  transform: translateX(0);
}

.student-whiteboard-shell.is-open .whiteboard-tab {
  transform: translate(-430px, -50%);
  transition: transform .24s ease;
}

.whiteboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem .85rem;
  background: linear-gradient(135deg, #f8fbff, #edf6ff);
  border-bottom: 1px solid var(--app-border);
}

.whiteboard-kicker {
  color: var(--app-primary);
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: .72rem;
}

.whiteboard-toolbar {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-wrap: wrap;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--app-border);
  background: #fff;
}

.whiteboard-colours {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.whiteboard-colour {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid #fff;
  background: var(--wb-colour);
  box-shadow: 0 0 0 1px #cbd5e1;
  padding: 0;
}

.whiteboard-colour.is-active {
  box-shadow: 0 0 0 2px var(--app-primary), 0 4px 10px rgba(37, 99, 235, .18);
}

.whiteboard-size {
  min-width: 96px;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  margin: 0;
}

.whiteboard-size .form-range {
  width: 70px;
}

.whiteboard-canvas-wrap {
  flex: 1 1 auto;
  min-height: 330px;
  margin: 1rem;
  border: 1px solid #cbd5e1;
  border-radius: .75rem;
  overflow: hidden;
  background-color: #fff;
  background-image:
    linear-gradient(rgba(148, 163, 184, .16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, .16) 1px, transparent 1px);
  background-size: 24px 24px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.6), 0 8px 20px rgba(15, 23, 42, .06);
}

#whiteboardCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#whiteboardCanvas.is-erasing {
  cursor: cell;
}

.whiteboard-footer {
  padding: 0 1rem 1rem;
}

@media (max-width: 575px) {
  .whiteboard-drawer {
    top: 64px;
    bottom: 0;
    width: calc(100vw - 34px);
    border-radius: .8rem 0 0 0;
  }

  .student-whiteboard-shell.is-open .whiteboard-tab {
    transform: translate(calc(-100vw + 34px), -50%);
  }

  .whiteboard-tab {
    padding: .75rem .48rem;
    font-size: .9rem;
  }

  .whiteboard-toolbar {
    gap: .5rem;
  }

  .whiteboard-size {
    min-width: 86px;
  }
}

/* V28 student audio reader */
.reader-control {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  vertical-align: middle;
  position: relative;
  max-width: 100%;
}

.reader-button,
.reader-mini-btn {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: var(--app-primary-dark);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  line-height: 1;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.reader-button {
  min-height: 2rem;
  padding: .38rem .65rem;
  font-size: .85rem;
  font-weight: 700;
}

.reader-control-compact .reader-button,
.reader-control-card .reader-button {
  width: 2rem;
  height: 2rem;
  min-height: 2rem;
  padding: 0;
}

.reader-control-compact .reader-button-label,
.reader-control-card .reader-button-label {
  display: none;
}

.reader-button:hover,
.reader-mini-btn:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  color: var(--app-primary-dark);
  transform: translateY(-1px);
}

.reader-control.is-reading .reader-button {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, .24);
}

.reader-control.is-paused .reader-button {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #fff;
}

.reader-wave {
  display: none;
  align-items: end;
  gap: 2px;
  height: 12px;
}

.reader-wave span {
  display: block;
  width: 2px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
  animation: readerWave .75s ease-in-out infinite;
}

.reader-wave span:nth-child(2) { animation-delay: .12s; }
.reader-wave span:nth-child(3) { animation-delay: .24s; }

.reader-control.is-reading:not(.is-paused) .reader-wave {
  display: inline-flex;
}

.reader-control.is-reading .reader-button > i {
  animation: readerPulse .9s ease-in-out infinite;
}

.reader-controls {
  display: none;
  align-items: center;
  gap: .28rem;
  padding: .24rem;
  border: 1px solid #dbe7f6;
  border-radius: 999px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 10px 22px rgba(15, 23, 42, .12);
}

.reader-control.is-reading .reader-controls {
  display: inline-flex;
}

.reader-mini-btn {
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  font-size: .8rem;
}

.reader-stop {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #be123c;
}

.reader-speed {
  min-width: 2.25rem;
  text-align: center;
  font-size: .78rem;
  font-weight: 800;
  color: #334155;
}

.reader-control-card {
  position: absolute;
  right: .55rem;
  top: .55rem;
  z-index: 2;
}

.reader-control-card.is-reading {
  right: .45rem;
}

.reasoning-card {
  position: relative;
  padding-right: 3.05rem;
}

.reasoning-card .reader-controls {
  position: absolute;
  top: 2.25rem;
  right: 0;
}

.reasoning-card-content {
  min-width: 0;
}

.feedback-panel {
  position: relative;
  padding-right: 3.2rem;
}

.feedback-panel .reader-injected {
  position: absolute;
  right: .75rem;
  top: .55rem;
}

.result-reader-control .reader-controls {
  position: absolute;
  right: 0;
  top: 2.35rem;
  z-index: 5;
}

@keyframes readerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

@keyframes readerWave {
  0%, 100% { height: 4px; opacity: .72; }
  50% { height: 12px; opacity: 1; }
}

@media (max-width: 575px) {
  .reader-control.is-reading {
    flex-wrap: wrap;
  }

  .reader-controls {
    border-radius: .8rem;
  }

  .reasoning-card .reader-controls,
  .result-reader-control .reader-controls {
    position: static;
    margin-top: .35rem;
  }

  .reader-control-card {
    align-items: flex-end;
    flex-direction: column;
  }
}

/* V30 gamified student topic path */
.topic-path-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background:
    radial-gradient(circle at 14% 15%, rgba(14, 165, 233, .18), transparent 26%),
    radial-gradient(circle at 90% 10%, rgba(245, 158, 11, .18), transparent 22%),
    linear-gradient(135deg, #ffffff, #f8fbff);
}

.topic-path-hero-main {
  display: flex;
  align-items: center;
  gap: .9rem;
}

.topic-path-hero-icon {
  width: 54px;
  height: 54px;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--app-primary), var(--app-secondary));
  box-shadow: 0 12px 28px rgba(37, 99, 235, .24);
  font-size: 1.45rem;
}

.topic-path-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .65rem;
  flex-wrap: wrap;
  color: #64748b;
  font-size: .82rem;
  font-weight: 700;
}

.topic-path-legend span {
  display: inline-flex;
  align-items: center;
  gap: .28rem;
}

.legend-dot {
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-size: .72rem;
  box-shadow: 0 5px 12px rgba(15, 23, 42, .12);
}

.legend-perfect { background: linear-gradient(135deg, #f59e0b, #facc15); }
.legend-cleared { background: linear-gradient(135deg, #16a34a, #22c55e); }
.legend-current { background: linear-gradient(135deg, #2563eb, #0ea5e9); }
.legend-locked { background: #94a3b8; }

.topic-view-toggle {
  padding: .25rem;
  border: 1px solid var(--app-border);
  border-radius: .75rem;
  background: #fff;
  box-shadow: var(--app-shadow-sm);
}

.topic-view-toggle .nav-link {
  border-radius: .55rem;
  color: #475569;
  font-weight: 800;
}

.topic-view-toggle .nav-link.active {
  color: #fff;
  background: linear-gradient(90deg, var(--app-primary), var(--app-secondary));
  box-shadow: 0 8px 18px rgba(37, 99, 235, .22);
}

.topic-map-section {
  position: relative;
  margin-bottom: 1.45rem;
  border: 1px solid var(--app-border);
  border-radius: 1.1rem;
  background: #fff;
  box-shadow: var(--app-shadow-sm);
  padding: 1.05rem;
  overflow: hidden;
}

.topic-map-section::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--level-accent), rgba(14, 165, 233, .35));
}

.topic-map-section.is-level-locked {
  background: #f8fafc;
}

.topic-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.level-medallion {
  width: 50px;
  height: 50px;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--level-accent), #0ea5e9);
  box-shadow: 0 12px 24px rgba(37, 99, 235, .18);
  font-size: 1.25rem;
}

.level-medallion.is-locked {
  background: linear-gradient(135deg, #94a3b8, #cbd5e1);
  box-shadow: none;
}

.level-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 800;
  padding: .5rem .78rem;
  white-space: nowrap;
}

.level-status-pill.is-open {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
}

.level-status-pill.is-locked {
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
}

.level-map {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(74px, 1fr));
  grid-auto-rows: 112px;
  gap: .9rem;
  min-height: 132px;
  padding: 1.2rem;
  border-radius: 1rem;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .82), rgba(248, 251, 255, .96)),
    radial-gradient(circle at 16px 16px, rgba(37, 99, 235, .09) 2px, transparent 2.5px);
  background-size: auto, 28px 28px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.level-map::before {
  content: '';
  position: absolute;
  inset: 1.2rem;
  border: 3px dashed color-mix(in srgb, var(--level-accent) 38%, transparent);
  border-radius: 42px;
  opacity: .42;
  pointer-events: none;
}

.level-map::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 28%, rgba(250, 204, 21, .18), transparent 18%),
    radial-gradient(circle at 82% 74%, rgba(14, 165, 233, .15), transparent 20%);
  pointer-events: none;
}

.path-connections {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.path-connector-glow {
  fill: none;
  stroke: var(--level-accent);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1 18;
  opacity: .18;
}

.path-connector-line {
  fill: none;
  stroke: color-mix(in srgb, var(--level-accent) 70%, #ffffff);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1 16;
  opacity: .75;
}

.path-node-shell {
  grid-column: var(--path-col);
  grid-row: var(--path-row);
  display: grid;
  place-items: center;
  position: relative;
  z-index: 2;
}

.path-node {
  --node-bg: #ffffff;
  --node-border: #bfdbfe;
  --node-ink: #1e3a8a;
  --node-ring: rgba(37, 99, 235, .18);
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 999px;
  border: 3px solid var(--node-border);
  background: var(--node-bg);
  color: var(--node-ink);
  text-decoration: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(15, 23, 42, .12);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.path-node:hover,
.path-node:focus-visible {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 16px 30px rgba(15, 23, 42, .18);
  outline: none;
}

.path-node.status-perfect {
  --node-bg: linear-gradient(135deg, #fef3c7, #facc15);
  --node-border: #f59e0b;
  --node-ink: #78350f;
  --node-ring: rgba(245, 158, 11, .26);
}

.path-node.status-cleared {
  --node-bg: linear-gradient(135deg, #dcfce7, #bbf7d0);
  --node-border: #22c55e;
  --node-ink: #166534;
  --node-ring: rgba(22, 163, 74, .22);
}

.path-node.status-improve {
  --node-bg: linear-gradient(135deg, #fff7ed, #fed7aa);
  --node-border: #fb923c;
  --node-ink: #9a3412;
  --node-ring: rgba(251, 146, 60, .22);
}

.path-node.status-locked {
  --node-bg: #f1f5f9;
  --node-border: #cbd5e1;
  --node-ink: #64748b;
  --node-ring: rgba(100, 116, 139, .12);
  box-shadow: none;
  cursor: help;
}

.path-node.is-current {
  --node-bg: linear-gradient(135deg, #dbeafe, #bfdbfe);
  --node-border: #2563eb;
  --node-ink: #1e3a8a;
  animation: pathNodeBob 1.9s ease-in-out infinite;
}

.path-node-glow {
  position: absolute;
  inset: -12px;
  border-radius: inherit;
  background: var(--node-ring);
  opacity: 0;
  transform: scale(.7);
  z-index: -1;
}

.path-node.is-current .path-node-glow {
  opacity: 1;
  animation: pathNodeGlow 1.4s ease-out infinite;
}

.path-node-main {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.72);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.6);
  font-size: 1.35rem;
  font-weight: 900;
}

.path-node-number {
  position: absolute;
  top: -.58rem;
  right: -.45rem;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 .38rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #334155;
  border: 1px solid #e2e8f0;
  font-size: .72rem;
  font-weight: 900;
}

.path-stars {
  position: absolute;
  bottom: -.72rem;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  gap: .04rem;
  padding: .16rem .32rem;
  border-radius: 999px;
  background: rgba(255,255,255,.95);
  color: #f59e0b;
  font-size: .68rem;
  line-height: 1;
  border: 1px solid #fde68a;
  box-shadow: 0 4px 10px rgba(15, 23, 42, .08);
}

.level-gate {
  margin-top: 1rem;
  border-radius: .95rem;
  padding: .95rem;
  border: 1px solid #e2e8f0;
  background: #fff;
}

.level-gate.is-open {
  background: linear-gradient(135deg, #f0fdf4, #ffffff);
  border-color: #bbf7d0;
}

.level-gate.is-closed {
  background: linear-gradient(135deg, #fff7ed, #ffffff);
  border-color: #fed7aa;
}

.gate-icon {
  width: 44px;
  height: 44px;
  border-radius: .85rem;
  display: grid;
  place-items: center;
  background: #f8fafc;
  color: #475569;
  font-size: 1.2rem;
}

.level-gate.is-open .gate-icon {
  color: #166534;
  background: #dcfce7;
}

.level-gate.is-closed .gate-icon {
  color: #9a3412;
  background: #ffedd5;
}

.gate-progress {
  height: .48rem;
  border-radius: 999px;
  background: #e2e8f0;
}

.gate-progress .progress-bar {
  border-radius: inherit;
  background: linear-gradient(90deg, var(--level-accent), #22c55e);
}

.topic-status-badge.status-perfect { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.topic-status-badge.status-cleared { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.topic-status-badge.status-improve { background: #ffedd5; color: #9a3412; border: 1px solid #fed7aa; }
.topic-status-badge.status-open { background: #dbeafe; color: #1e3a8a; border: 1px solid #bfdbfe; }
.topic-status-badge.status-locked { background: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; }

.topic-path-popover {
  min-width: 230px;
  max-width: 300px;
}

.popover.topic-node-popover {
  border-color: #cbd7ea;
  box-shadow: var(--app-shadow);
  border-radius: .85rem;
}

.popover.topic-node-popover .popover-body {
  padding: .85rem;
}

@keyframes pathNodeGlow {
  0% { transform: scale(.72); opacity: .45; }
  75%, 100% { transform: scale(1.15); opacity: 0; }
}

@keyframes pathNodeBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.topic-map-section.path-enter,
.level-gate.path-enter,
.path-node-shell.path-enter {
  opacity: 0;
  animation-fill-mode: forwards;
  animation-timing-function: cubic-bezier(.2, .75, .25, 1);
  animation-delay: var(--path-delay, 0ms);
}

.topic-map-section.path-enter {
  animation-name: pathSectionEnter;
  animation-duration: .26s;
}

.path-node-shell.path-enter {
  animation-name: pathNodeEnter;
  animation-duration: .22s;
}

.level-gate.path-enter {
  animation-name: pathGateEnter;
  animation-duration: .24s;
}

@keyframes pathSectionEnter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pathNodeEnter {
  from { opacity: 0; transform: translateY(7px) scale(.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pathGateEnter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .topic-map-section.path-enter,
  .level-gate.path-enter,
  .path-node-shell.path-enter {
    opacity: 1;
    animation: none !important;
    transform: none !important;
  }
}

@media (max-width: 991px) {
  .topic-path-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .topic-path-legend {
    justify-content: flex-start;
  }

  .level-map {
    grid-template-columns: repeat(3, minmax(74px, 1fr));
  }

  .path-node-shell {
    grid-column: auto !important;
    grid-row: auto !important;
  }
}

@media (max-width: 575px) {
  .topic-map-section {
    padding: .9rem;
  }

  .topic-map-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .level-map {
    grid-template-columns: repeat(2, minmax(80px, 1fr));
    grid-auto-rows: 106px;
    padding: .9rem;
  }

  .level-map::before {
    inset: 1rem;
    border-radius: 30px;
  }

  .path-node {
    width: 78px;
    height: 78px;
  }

  .path-node-main {
    width: 44px;
    height: 44px;
  }
}

/* V34 whiteboard model-board upgrade */
.student-whiteboard-shell {
  --whiteboard-width: min(560px, calc(100vw - 48px));
}

.whiteboard-drawer {
  width: var(--whiteboard-width);
}

.student-whiteboard-shell.is-open .whiteboard-tab {
  transform: translate(calc(-1 * var(--whiteboard-width)), -50%);
}

.whiteboard-mode-tabs {
  display: flex;
  gap: .5rem;
  padding: .7rem 1rem 0;
  background: #fff;
}

.whiteboard-mode-tabs .btn {
  min-width: 92px;
}

.whiteboard-toolbar {
  align-items: flex-start;
}

.whiteboard-model-tools {
  gap: .55rem;
}

.whiteboard-model-toolset,
.whiteboard-selected-tools {
  flex-wrap: wrap;
  gap: .35rem;
}

.whiteboard-model-toolset .btn,
.whiteboard-selected-tools .btn {
  border-radius: .5rem !important;
}

.whiteboard-canvas-wrap {
  position: relative;
  min-height: 430px;
}

#whiteboardCanvas,
.whiteboard-model-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#whiteboardCanvas {
  z-index: 1;
}

.whiteboard-model-layer {
  z-index: 2;
  touch-action: none;
  user-select: none;
  overflow: hidden;
}

.student-whiteboard-shell.is-draw-mode .whiteboard-model-layer {
  pointer-events: none;
}

.student-whiteboard-shell.is-model-mode #whiteboardCanvas {
  pointer-events: none;
  cursor: default;
}

.student-whiteboard-shell.is-model-mode .whiteboard-model-layer {
  pointer-events: auto;
  cursor: crosshair;
}

.student-whiteboard-shell.is-model-mode .whiteboard-model-layer[data-tool="select"] {
  cursor: default;
}

.wb-object {
  position: absolute;
  touch-action: none;
  user-select: none;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 800;
  color: #1f2937;
  border-radius: .45rem;
  z-index: 3;
}

.wb-object:active {
  cursor: grabbing;
}

.wb-object.is-selected {
  outline: 3px solid rgba(37, 99, 235, .42);
  outline-offset: 3px;
  z-index: 5;
}

.wb-unit {
  border: 2px solid #f59e0b;
  background: linear-gradient(180deg, #fff7cc, #fde68a);
  box-shadow: 0 6px 14px rgba(245, 158, 11, .18);
  font-size: .85rem;
}

.wb-unit span:empty::before {
  content: "unit";
  color: rgba(120, 53, 15, .45);
  font-weight: 900;
}

.wb-label {
  justify-content: flex-start;
  padding: .15rem .45rem;
  background: rgba(255,255,255,.86);
  border: 1px solid rgba(37, 99, 235, .22);
  color: #1e3a8a;
}

.wb-quantity {
  padding: .2rem .55rem;
  background: #eff6ff;
  border: 1px solid #93c5fd;
  color: #1d4ed8;
  box-shadow: 0 5px 12px rgba(37, 99, 235, .12);
}

.wb-arrow,
.wb-bracket {
  background: transparent;
  border-radius: .2rem;
}

.wb-arrow svg,
.wb-bracket svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.wb-arrow line {
  stroke: #2563eb;
  stroke-width: 5;
  stroke-linecap: round;
}

.wb-arrow marker path {
  fill: #2563eb;
}

.wb-arrow span,
.wb-bracket span {
  position: relative;
  align-self: flex-start;
  margin-top: -.1rem;
  max-width: calc(100% - 16px);
  padding: .1rem .4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(148, 163, 184, .45);
  font-size: .8rem;
  line-height: 1.1;
  box-shadow: 0 4px 10px rgba(15, 23, 42, .08);
}

.wb-arrow span:empty,
.wb-bracket span:empty {
  display: none;
}

.wb-bracket path {
  fill: none;
  stroke: #7c3aed;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wb-bracket span {
  align-self: flex-end;
  margin-bottom: .05rem;
  color: #5b21b6;
}

@media (max-width: 575px) {
  .student-whiteboard-shell {
    --whiteboard-width: calc(100vw - 34px);
  }

  .student-whiteboard-shell.is-open .whiteboard-tab {
    transform: translate(calc(-1 * var(--whiteboard-width)), -50%);
  }

  .whiteboard-canvas-wrap {
    min-height: 390px;
    margin: .75rem;
  }

  .whiteboard-model-toolset .btn,
  .whiteboard-selected-tools .btn {
    font-size: .78rem;
    padding-left: .45rem;
    padding-right: .45rem;
  }
}

/* V35/V36 model whiteboard polish */
.student-whiteboard-shell.is-maximized {
  z-index: 1065;
}

.student-whiteboard-shell.is-maximized .whiteboard-drawer {
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: min(1180px, calc(100vw - 28px));
  border: 1px solid var(--app-border);
  border-radius: 1rem;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .28);
}

.student-whiteboard-shell.is-maximized .whiteboard-tab {
  transform: translateY(-50%);
  opacity: .36;
}

.student-whiteboard-shell.is-maximized.is-open .whiteboard-tab {
  transform: translateY(-50%);
}

.student-whiteboard-shell.is-maximized .whiteboard-canvas-wrap {
  min-height: 620px;
}

/* Drawing layer is intentionally above model objects so students can annotate or cross out models. */
.whiteboard-model-layer {
  z-index: 1;
}

#whiteboardCanvas {
  z-index: 2;
  background: transparent;
}

.student-whiteboard-shell.is-draw-mode #whiteboardCanvas {
  pointer-events: auto;
}

.student-whiteboard-shell.is-model-mode #whiteboardCanvas {
  pointer-events: none;
}

.student-whiteboard-shell.is-model-mode .whiteboard-model-layer {
  pointer-events: auto;
}

.whiteboard-model-layer .wb-object {
  transition: outline-color .12s ease, box-shadow .12s ease;
}

.wb-object.is-selected {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .10), 0 8px 20px rgba(15, 23, 42, .16);
}

.wb-unit span {
  padding-inline: .25rem;
}

.wb-unit span:empty::before {
  content: "1u";
}

.wb-arrow path {
  fill: none;
  stroke: #2563eb;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wb-arrow svg,
.wb-bracket svg {
  filter: drop-shadow(0 3px 5px rgba(15, 23, 42, .10));
}

.wb-resize-handle {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  border: 2px solid #2563eb;
  background: #ffffff;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 10px rgba(15, 23, 42, .22);
  pointer-events: auto;
  cursor: ew-resize;
  z-index: 9;
}

.wb-resize-start {
  left: 0;
}

.wb-resize-end {
  left: 100%;
}

.whiteboard-context-menu {
  position: absolute;
  z-index: 30;
  display: none;
  width: 190px;
  padding: .35rem;
  border: 1px solid rgba(148, 163, 184, .45);
  border-radius: .75rem;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 18px 38px rgba(15, 23, 42, .18);
  backdrop-filter: blur(8px);
}

.whiteboard-context-menu.is-open {
  display: grid;
  gap: .2rem;
}

.whiteboard-context-menu button {
  display: grid;
  grid-template-columns: 1.45rem 1fr;
  align-items: center;
  gap: .45rem;
  width: 100%;
  border: 0;
  border-radius: .5rem;
  background: transparent;
  padding: .45rem .55rem;
  color: #334155;
  font-weight: 700;
  text-align: left;
}

.whiteboard-context-menu button:hover,
.whiteboard-context-menu button:focus {
  background: #eff6ff;
  color: #1d4ed8;
  outline: none;
}

.whiteboard-context-menu button[data-wb-action="delete"] {
  color: #b91c1c;
}

.whiteboard-context-menu button[data-wb-action="delete"]:hover,
.whiteboard-context-menu button[data-wb-action="delete"]:focus {
  background: #fef2f2;
  color: #991b1b;
}

.whiteboard-selected-tools .btn {
  display: inline-grid;
  grid-template-columns: 1.15rem auto;
  align-items: center;
  gap: .25rem;
}

@media (max-width: 575px) {
  .student-whiteboard-shell.is-maximized .whiteboard-drawer {
    inset: 8px;
    width: auto;
    border-radius: .85rem;
  }

  .student-whiteboard-shell.is-maximized .whiteboard-canvas-wrap {
    min-height: 500px;
  }

  .whiteboard-context-menu {
    width: 176px;
  }
}
