/* Minimum browser support: Chrome 90+, Firefox 90+, Safari 14+, Edge 90+ */
:root {
  --bg: #edf1f7;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: #ffffff;
  --text: #1f2437;
  --muted: #667085;
  --border: rgba(67, 97, 238, 0.12);
  --accent: #1d4ed8;
  --primary: #4361ee;
  --secondary: #b45309;
  --success: #2f9e44;
  --danger: #b91c1c;
  --error: #dc2626;
  --shadow: 0 14px 32px rgba(31, 36, 55, 0.08);
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

body {
  padding: 0;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1;
  margin-bottom: 12px;
}

.page-shell {
  max-width: 1200px;
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

.eyebrow,
.subject-meta,
.topic-chip {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--accent);
}

.hero-text,
.panel-head p,
.card-head p,
.empty-state,
.module-card-head p,
.subject-card p,
.result-item,
.progress-highlight span {
  color: var(--muted);
  line-height: 1.6;
}

.auth-page {
  min-height: calc(100vh - 36px);
  display: grid;
  place-items: center;
}

.auth-card,
.view-panel,
.card,
.hero-copy,
.hero-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .auth-card,
  .view-panel,
  .card,
  .hero-copy,
  .hero-card,
  .panel {
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
}

.auth-card {
  width: min(100%, 520px);
  padding: 28px;
}

.error-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(220, 38, 38, 0.96);
  color: #fff;
}

.error-banner-close {
  color: var(--error);
  min-height: 44px;
}

.auth-form,
.admin-form {
  display: grid;
  gap: 12px;
}

.role-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.role-tab {
  font: inherit;
  border-radius: 20px;
  padding: 6px 16px;
  background: transparent;
  border: 1.5px solid var(--border);
  cursor: pointer;
}

.role-tab.is-active {
  background: var(--accent, #4f46e5);
  color: #fff;
  border-color: transparent;
}

.field-label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

input,
textarea,
select,
.answer-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  font: inherit;
}

.action-button,
.module-action,
.mini-button,
.choice-button {
  font: inherit;
  border-radius: 14px;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.action-button {
  cursor: pointer;
  border: none;
  padding: 13px 16px;
  background: linear-gradient(135deg, var(--primary), #15803d);
  color: #fff;
  font-weight: 700;
}

.action-button.secondary {
  background: linear-gradient(135deg, var(--secondary), #ea580c);
}

.mini-button,
.module-action,
.choice-button {
  border: 1px solid var(--border);
  background: #fff;
  padding: 11px 14px;
}

.mini-button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  gap: 24px;
  min-height: 100vh;
}

.app-header {
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  color: #fff;
  background: linear-gradient(90deg, #5c6cf0 0%, #2f1bb9 100%);
  box-shadow: 0 8px 24px rgba(47, 27, 185, 0.18);
}

.app-stack {
  display: grid;
  gap: 18px;
  width: min(100%, 920px);
  margin: 0 auto 32px;
}

.view-panel {
  padding: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}

.session-actions,
.view-toolbar,
.module-action-grid,
.action-row,
.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.session-actions {
  align-items: center;
  justify-content: flex-end;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.subject-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  padding: 18px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 10px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.subject-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent, var(--primary));
  box-shadow: 0 12px 26px rgba(23, 32, 42, 0.08);
}

.subject-card strong {
  font-size: 1.15rem;
}

.subject-open {
  color: var(--primary);
  font-weight: 700;
}

.subject-hero,
.focus-header {
  padding: 0 0 8px;
  background: transparent;
  border: none;
  box-shadow: none;
}

.subject-progress,
.focus-meta,
.progress-mini-list,
.module-stack,
.practice-list,
.assessment-list,
.theory-focus,
.result-breakdown,
.admin-catalog,
.admin-form-grid,
.admin-module-list,
.admin-subitems {
  display: grid;
  gap: 12px;
}

.progress-highlight,
.game-strip,
.result-summary,
.import-preview pre,
.empty-state {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
}

.progress-mini-list {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.progress-mini-item,
.score-chip {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 10px 12px;
}

.progress-mini-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.module-card,
.question-card,
.admin-module,
.admin-subitem,
.result-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
}

.module-card {
  padding: 20px;
  box-shadow: 0 8px 20px rgba(31, 36, 55, 0.06);
}

.module-card-head {
  margin-bottom: 14px;
}

.chapter-card {
  display: grid;
  gap: 12px;
}

.chapter-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.phase-button {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.phase-theory,
.primary-button {
  background: var(--primary);
}

.phase-practice {
  background: var(--success);
}

.phase-assessment {
  background: #f77f00;
}

.phase-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
}

.module-action {
  cursor: pointer;
}

.teacher-layout {
  display: grid;
  gap: 18px;
  width: min(100%, 1120px);
  margin: 0 auto 32px;
}

.teacher-filters,
.teacher-kpi-grid,
.teacher-breakdown-grid {
  display: grid;
  gap: 16px;
}

.teacher-filters {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.teacher-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 16px;
}

.teacher-breakdown-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 16px;
}

.teacher-kpi-card,
.teacher-breakdown-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  padding: 18px;
}

.teacher-kpi-card strong {
  display: block;
  margin: 12px 0 8px;
  font-size: 1.9rem;
}

.teacher-breakdown-card h3 {
  margin-bottom: 12px;
}

.teacher-breakdown-card p,
.teacher-kpi-card p {
  margin-bottom: 8px;
}

.teacher-subject-card.is-selected,
.subject-card.teacher-subject-card:hover {
  border-color: var(--accent, var(--primary));
  box-shadow: 0 10px 22px rgba(31, 36, 55, 0.1);
}

.table-shell {
  overflow-x: auto;
}

.teacher-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.teacher-table th,
.teacher-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.teacher-table th {
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(67, 97, 238, 0.05);
}

.teacher-table tbody tr:last-child td {
  border-bottom: none;
}

.teacher-table .is-active-row td,
tr.is-active-row td {
  background: rgba(67, 97, 238, 0.08);
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 36, 55, 0.42);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.compact-head {
  margin-top: 8px;
  margin-bottom: -2px;
}

.password-strength {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(31, 36, 55, 0.08);
  overflow: hidden;
}

.password-strength-bar {
  height: 100%;
  width: 33%;
  transition: width 0.18s ease, background-color 0.18s ease;
}

.strength-weak {
  width: 33%;
  background: var(--danger);
}

.strength-medium {
  width: 66%;
  background: var(--secondary);
}

.strength-strong {
  width: 100%;
  background: var(--success);
}

.password-checklist {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.password-checklist-item.is-met {
  color: var(--success);
  font-weight: 700;
}

.module-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.theory-action {
  border-color: rgba(23, 100, 63, 0.24);
}

.practice-action {
  border-color: rgba(217, 119, 6, 0.25);
}

.assessment-action {
  border-color: rgba(23, 32, 42, 0.18);
}

.focus-card {
  display: grid;
  gap: 16px;
}

.main-study-card {
  padding: 22px;
  background: var(--surface-strong);
  border: 1px solid rgba(67, 97, 238, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.focus-topic-tabs,
.focus-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.topic-tab {
  border: 1px solid rgba(67, 97, 238, 0.12);
  background: #fff;
  color: var(--text);
  min-width: 40px;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.topic-tab.is-active {
  background: var(--primary);
  color: #fff;
}

.theory-section {
  padding-left: 14px;
  border-left: 4px solid var(--primary);
}

.theory-paragraph-tabs {
  position: sticky;
  top: 0;
  background: var(--surface, #fff);
  z-index: 10;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.theory-leerdoelen {
  border-left: 3px solid #4f46e5;
  padding-left: 12px;
}

.theory-kernbegrippen {
  border-left: 3px solid #0891b2;
  padding-left: 12px;
}

.theory-uitleg {
  border-left: 4px solid var(--primary);
}

.theory-body {
  line-height: 1.72;
}

.theory-body .katex {
  font-size: 1.05em;
}

.math-fallback {
  font-style: italic;
}

.game-strip {
  display: grid;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(67, 97, 238, 0.08);
}

.game-progress {
  height: 12px;
  border-radius: 999px;
  background: rgba(23, 32, 42, 0.08);
  overflow: hidden;
}

.game-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--secondary), var(--primary));
}

.score-celebration {
  animation: score-bounce 0.7s ease;
}

@keyframes score-bounce {
  0%,
  100% {
    transform: scale(1);
  }

  35% {
    transform: scale(1.08);
  }

  60% {
    transform: scale(0.98);
  }
}

.question-card {
  padding: 18px 0;
  display: grid;
  gap: 14px;
  border: none;
  border-bottom: 1px solid rgba(67, 97, 238, 0.1);
  border-radius: 0;
  box-shadow: none;
}

.question-card:last-child {
  border-bottom: none;
}

.question-card-head {
  display: block;
}

.question-prompt {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.55;
}

.choice-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-list {
  display: grid;
  gap: 10px;
  max-width: 520px;
}

.choice-button {
  text-align: left;
  cursor: pointer;
  min-height: 44px;
}

.choice-button:hover {
  border-color: var(--primary);
}

.hint-button,
.secondary-link-button {
  color: var(--secondary);
  border-color: rgba(217, 119, 6, 0.25);
}

.hint-copy {
  color: var(--muted);
  margin: 8px 0;
}

.secondary-link-button {
  margin-top: 8px;
}

.assessment-hint-area {
  margin-top: 10px;
}

.assessment-hint {
  background: #fffbeb;
  border-left: 3px solid var(--secondary);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.assessment-hint .secondary-link-button {
  margin-top: 0;
  flex-shrink: 0;
}

.hint-count-note {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 4px 0 0;
}

.choice-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
}

.choice-option input:checked + span {
  color: var(--text);
  font-weight: 700;
}

.inline-answer-form,
.assessment-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.inline-answer-form .answer-input {
  flex: 0 1 240px;
}

.feedback {
  border-radius: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
}

.feedback.correct,
.done-correct {
  background: rgba(23, 100, 63, 0.08);
  border-color: rgba(23, 100, 63, 0.22);
}

.feedback.wrong,
.done-wrong {
  background: rgba(185, 28, 28, 0.08);
  border-color: rgba(185, 28, 28, 0.22);
}

.timer-chip {
  font-weight: 700;
}

.assessment-result {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.result-summary.passed {
  background: rgba(23, 100, 63, 0.08);
}

.result-summary.not-passed {
  background: rgba(185, 28, 28, 0.08);
}

.result-item {
  padding: 14px 16px;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin-bottom: 24px;
}

.onboarding-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow);
}

.hero-copy,
.hero-card,
.card,
.panel {
  padding: 22px;
}

.layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 20px;
}

.admin-module {
  padding: 14px 16px;
}

.admin-module header,
.admin-subitem {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.admin-subitem {
  padding: 10px 12px;
}

.import-preview pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow: auto;
}

@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .app-header,
  .view-panel,
  .card,
  .hero-copy,
  .hero-card,
  .panel {
    padding: 18px;
  }

  h1 {
    font-size: clamp(1.8rem, 6vw, 2.7rem);
  }

  .subject-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .subject-card,
  .module-card,
  .question-card {
    padding: 14px;
  }

  .question-prompt {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 8px;
  }

  .subject-grid,
  .progress-mini-list,
  .layout,
  .hero,
  .admin-form-grid {
    grid-template-columns: 1fr;
  }

  .session-actions,
  .view-toolbar,
  .assessment-actions,
  .inline-answer-form {
    flex-direction: column;
    align-items: stretch;
  }

  .phase-button,
  .action-button,
  .mini-button,
  .choice-button {
    min-height: 44px;
  }

  .module-card,
  .subject-card,
  .question-card,
  .view-panel {
    padding: 12px;
  }

  .chapter-actions {
    gap: 8px;
  }

  .question-card-head {
    display: grid;
    gap: 8px;
  }
}

@media (max-width: 980px) {
  body {
    padding: 12px;
  }

  .app-header,
  .hero,
  .layout,
  .question-card-head,
  .inline-answer-form {
    grid-template-columns: 1fr;
  }

  .app-header,
  .question-card-head,
  .inline-answer-form {
    display: grid;
  }

  .session-actions {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .score-celebration {
    animation: none !important;
  }
}
