/* =============================================================================
   style.css — Test tool (digital tests with anti-cheat focus detection)
   Color space: oklch · Theme: light-dark() · Layout: logical properties
   ============================================================================= */

/* Shared tokens (type scale, spacing, radius, color palette, --bg) are in /tokens.css */
:root {
  /* Accent (--accent/--accent-hover/--accent-subtle) sættes nu af rolig.css
     via [data-tool="test"] → plum. De gamle --purple*-referencer her var døde:
     --purple* fandtes kun i tokens.css (ikke længere loadet), og rolig.css
     overskriver alligevel accenten på <body>. */

  /* Semantic surfaces */
  --card: light-dark(oklch(1 0 0), oklch(0.18 0.02 260));
  --input-bg: light-dark(oklch(0.96 0.005 240), oklch(0.22 0.02 260));
  --text: light-dark(oklch(0.15 0.02 260), oklch(0.93 0.01 80));
  --text-muted: light-dark(oklch(0.45 0.02 260), oklch(0.65 0.02 240));
  --border: light-dark(oklch(0 0 0 / 8%), oklch(1 0 0 / 10%));
  --muted: light-dark(oklch(0.55 0.01 260), oklch(0.55 0.01 240));
}


/* =============================================================================
   BASE
   ============================================================================= */

body {
  min-block-size: 100dvh;
}

body:has(.page) { padding: 0; }

dialog { margin: auto; }

::selection {
  background: oklch(0.55 0.22 293 / 25%);
}


/* =============================================================================
   CREATE PAGE — Opret/rediger test
   ============================================================================= */

.opret-main {
  max-inline-size: 780px;
  margin-inline: auto;
  padding: var(--space-m);
  display: flex;
  flex-direction: column;
  gap: var(--space-l);
}

/* Form cards */
.form-card {
  background: var(--card);
  border-radius: var(--radius-l);
  padding: var(--space-l);
  box-shadow: var(--shadow-s);
  display: flex;
  flex-direction: column;
  gap: var(--space-m);
}

.form-card-label {
  font-size: var(--step--2);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}


/* ─── Question cards ─── */

.question-card {
  background: var(--card);
  border-radius: var(--radius-l);
  padding: var(--space-m) var(--space-l);
  box-shadow: var(--shadow-s);
  transition: box-shadow 0.2s;
  position: relative;

  &:hover { box-shadow: var(--shadow-m); }
}

.question-header {
  display: flex;
  align-items: center;
  gap: var(--space-s);
}

.question-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 2rem;
  block-size: 2rem;
  border-radius: 50%;
  background: var(--accent);
  color: oklch(1 0 0);
  font-weight: 700;
  font-size: var(--step--1);
  flex-shrink: 0;
}

.question-header input {
  flex: 1;
  font-family: var(--font-body);
  font-size: var(--step-0);
  padding: var(--space-xs) var(--space-s);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--input-bg);
  color: var(--text);
  outline: none;

  &:focus {
    border-color: var(--accent);
  }
}

/* Markdown question preview (replaces text input) — click to open editor */
.question-text-preview {
  flex: 1;
  font-family: var(--font-body);
  font-size: var(--step-0);
  padding: var(--space-xs) var(--space-s);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--input-bg);
  color: var(--text);
  cursor: pointer;
  min-block-size: 2.25rem;
  line-height: 1.5;
  overflow: hidden;
  /* Vokser med spørgsmålet (lange skriveøvelse-prompts) op til ~9 linjer,
     derefter scroll — så feltet er stort nok når det er nødvendigt. */
  max-block-size: 14rem;
  overflow-y: auto;

  /* markdown content inside preview */
  & p { margin: 0; }
  & p + p { margin-block-start: 0.3em; }
  & img { max-inline-size: 120px; block-size: auto; vertical-align: middle; }

  &:hover, &:focus {
    border-color: var(--accent);
    outline: none;
  }
}

.question-text-placeholder {
  color: var(--muted);
  font-style: italic;
}

/* md-dialog modal (shared between dagsorden + test) */
.md-dialog {
  inline-size: min(900px, 95vw);
  block-size: min(560px, 90dvh);
  border: none;
  border-radius: var(--radius-l);
  padding: 0;
  background: var(--card);
  box-shadow: var(--shadow-hover);
  flex-direction: column;
  margin: auto;

  &[open] { display: flex; }

  &::backdrop {
    background: oklch(0 0 0 / 35%);
    backdrop-filter: blur(2px);
  }
}

.md-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-m) var(--space-l);
  border-block-end: 1px solid var(--border);
  flex-shrink: 0;
}

.md-dialog-titel {
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.md-dialog-luk {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: var(--step-0);
  padding: var(--space-2xs);
  border-radius: var(--radius-s);
  line-height: 1;

  &:hover { background: var(--input-bg); color: var(--text); }
}

.md-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-s);
  padding: var(--space-m) var(--space-l);
  border-block-start: 1px solid var(--border);
  flex-shrink: 0;
}

/* Quill WYSIWYG editor wrapper in modal */
.quill-editor-wrap {
  flex: 1;
  min-block-size: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;

  & .ql-toolbar.ql-snow {
    border-block-end: 1px solid var(--border);
    border-block-start: none;
    border-inline: none;
    background: var(--card);
    flex-shrink: 0;

    & .ql-stroke { stroke: var(--text); }
    & .ql-fill { fill: var(--text); }
    & .ql-picker-label { color: var(--text); }
    & button:hover .ql-stroke, & .ql-active .ql-stroke { stroke: var(--accent); }
    & button:hover .ql-fill, & .ql-active .ql-fill { fill: var(--accent); }
    & .ql-picker-label:hover { color: var(--accent); }
    & .ql-picker-options { background: var(--card); border-color: var(--border); color: var(--text); }
  }

  & .ql-container.ql-snow {
    flex: 1;
    min-block-size: 0;
    border: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  & .ql-editor {
    flex: 1;
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: 1.7;
    background: var(--card);
    color: var(--text);
    overflow-y: auto;
    padding: var(--space-m);
    max-block-size: none;
  }

  & .ql-editor.ql-blank::before {
    color: var(--muted);
    font-style: normal;
    left: var(--space-m);
  }

  & img { max-inline-size: 100%; block-size: auto; border-radius: var(--radius-s); margin-block: var(--space-s); }
}

.question-type-select {
  font-family: var(--font-body);
  font-size: var(--step--1);
  padding: var(--space-2xs) var(--space-s);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--input-bg);
  color: var(--text);
  cursor: pointer;
}

.question-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: var(--space-2xs);
  border-radius: var(--radius-s);
  transition: color 0.15s;

  &:hover { color: var(--red); }
}

.question-body {
  padding-block-start: var(--space-s);
  display: flex;
  flex-direction: column;
  gap: var(--space-s);
}

/* "Afspil skrivning"-knap ved fritekst-svar (resultater + live svar) */
.tr-open-btn {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font-family: var(--font-body);
  font-size: var(--step--2);
  font-weight: 600;
  color: var(--accent);
  background: oklch(from var(--accent) l c h / 10%);
  border: none;
  border-radius: var(--radius-s);
  padding: var(--space-2xs) var(--space-xs);
  cursor: pointer;

  &:hover {
    background: oklch(from var(--accent) l c h / 18%);
  }

  & .hi {
    width: 0.9em;
    height: 0.9em;
  }
}

/* Fritekst: vejledende ordmål-input i opret-siden */
.freetext-wordtarget {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--step--1);
  color: var(--muted);

  & .hi {
    color: var(--accent);
  }

  & .wordtarget-input {
    inline-size: 5rem;
    font-family: var(--font-body);
    font-size: var(--step--1);
    padding: var(--space-xs) var(--space-s);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-s);
    background: var(--input-bg);
    color: var(--text);
    outline: none;

    &:focus {
      border-color: var(--accent);
    }
  }
}

.freetext-wordtarget-unit {
  font-size: var(--step--2);
}

/* Options list */
.option-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.option-row input[type="text"] {
  flex: 1;
  font-family: var(--font-body);
  font-size: var(--step--1);
  padding: var(--space-xs) var(--space-s);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--input-bg);
  color: var(--text);
  outline: none;

  &:focus {
    border-color: var(--accent);
  }
}

/* Flueben for rigtigt svar (et eller flere) */
.option-row .correct-check {
  accent-color: var(--accent);
  inline-size: 18px;
  block-size: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

/* Vises under svarmulighederne, når mere end ét svar er markeret rigtigt */
.multi-correct-note {
  margin: 0;
  font-size: var(--step--2);
  color: var(--muted);
}

/* Elevens hint over svarmulighederne: "Vælg alle rigtige svar" */
.test-multi-hint {
  margin: 0;
  font: 500 11px var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.option-row .option-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: var(--step--1);
  padding: 0.2em;

  &:hover { color: var(--red); }
}

.add-option-btn {
  font-family: var(--font-body);
  font-size: var(--step--1);
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-s);
  padding: var(--space-xs) var(--space-s);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;

  &:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
}

.add-question-btn {
  font-family: var(--font-body);
  font-size: var(--step-0);
  font-weight: 600;
  background: none;
  border: 2px dashed var(--border);
  border-radius: var(--radius-l);
  padding: var(--space-m);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;

  &:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
}

/* Points input */
.points-input {
  inline-size: 3.5rem;
  font-family: var(--font-body);
  font-size: var(--step--1);
  padding: var(--space-2xs) var(--space-xs);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--input-bg);
  color: var(--text);
  text-align: center;
}

/* Per-question duration input (timedQuestions mode) */
.question-duration-wrap {
  display: none; /* shown via JS when timedQuestions is active */
  color: var(--muted);

  & input.duration-q-input {
    inline-size: 3rem;
    font-family: var(--font-body);
    font-size: var(--step--1);
    padding: var(--space-2xs) var(--space-xs);
    border: 1.5px solid var(--accent);
    border-radius: var(--radius-s);
    background: var(--input-bg);
    color: var(--text);
    text-align: center;
  }
}


/* ─── Settings toggles ─── */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-s);

  @media (min-width: 480px) {
    grid-template-columns: 1fr 1fr;
  }
}

.setting-item {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  padding: var(--space-xs) var(--space-s);
  border-radius: var(--radius-s);
}

.setting-item label {
  font-size: var(--step--1);
  color: var(--text);
  cursor: pointer;
}


/* =============================================================================
   TEST PAGE — Student test-taking view
   ============================================================================= */

.test-container {
  block-size: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Topbar */
.test-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  padding: var(--space-xs) var(--space-m);
  background: var(--card);
  box-shadow: var(--shadow-s);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.test-topbar-code {
  font-weight: 700;
  font-size: var(--step--1);
  color: var(--accent);
  background: var(--accent-subtle);
  padding: 0.15em 0.5em;
  border-radius: var(--radius-s);
}

.test-topbar-step {
  font-size: var(--step--1);
  color: var(--muted);
}

.test-topbar-spacer { flex: 1; }

.test-topbar-timer {
  font-weight: 700;
  font-size: var(--step-0);
  font-variant-numeric: tabular-nums;
}

.timer-ok { color: var(--accent); }
.timer-warn { color: var(--amber); }
.timer-danger { color: var(--red); }
.timer-expired {
  color: var(--red);
  animation: pulse-text 1s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Focus warning banner */
.focus-warning {
  background: light-dark(oklch(0.95 0.06 27), oklch(0.25 0.08 27));
  color: light-dark(oklch(0.35 0.12 27), oklch(0.9 0.06 27));
  padding: var(--space-xs) var(--space-m);
  font-size: var(--step--1);
  font-weight: 600;
  text-align: center;
  transition: opacity 0.3s;
}

.focus-warning[hidden] { display: none; }


/* Question area */
.test-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-l) var(--space-m);
  display: flex;
  flex-direction: column;
  align-items: center;

  @media (min-width: 640px) {
    padding: var(--space-2xl) var(--space-xl);
  }
}

.test-question-card {
  background: var(--card);
  border-radius: var(--radius-l);
  padding: var(--space-l);
  box-shadow: var(--shadow-m);
  inline-size: 100%;
  max-inline-size: 640px;
  display: flex;
  flex-direction: column;
  gap: var(--space-m);
}

.test-question-text {
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.4;
}

.test-question-points {
  font-size: var(--step--2);
  color: var(--muted);
  font-weight: 500;
}

/* Choice options */
.test-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.test-option {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  padding: var(--space-s) var(--space-m);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-m);
  cursor: pointer;
  transition: all 0.15s;
  font-size: var(--step-0);
  background: var(--card);

  &:hover { border-color: var(--accent); background: var(--accent-subtle); }

  &.selected {
    border-color: var(--accent);
    background: var(--accent-subtle);
    font-weight: 600;
  }

  /* Question locked (time expired) — disable hover/pointer, mute colors */
  &.locked {
    cursor: default;
    opacity: 0.6;
    pointer-events: none;

    &:hover { border-color: var(--border); background: var(--card); }
  }

  & input[type="radio"],
  & input[type="checkbox"] {
    accent-color: var(--accent);
    flex-shrink: 0;
  }
}

/* Freetext answer */
.test-freetext {
  font-family: var(--font-body);
  font-size: var(--step-0);
  padding: var(--space-s) var(--space-m);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-m);
  background: light-dark(oklch(1 0 0), oklch(0.2 0.02 260));
  color: var(--text);
  inline-size: 100%;
  min-block-size: 120px;
  resize: vertical;
  outline: none;

  &:focus {
    border-color: var(--accent);
  }
}

.test-freetext-counter {
  font-size: var(--step--2);
  color: var(--muted);
  display: flex;
  align-items: baseline;
  gap: var(--space-s);
  margin-block-start: var(--space-2xs);
}

/* Ordtæller — det pædagogisk vigtige tal, så det er fremhævet */
.test-freetext-words {
  font-weight: 700;
  color: var(--text);
}

/* Vejledende ordmål — grønt når eleven har nået målet */
.test-freetext-target {
  color: var(--muted);
}
.test-freetext-target.reached {
  color: var(--green);
  font-weight: 600;
}

/* Tegn-tæller skubbes til højre, dæmpet (sekundær info) */
.test-freetext-chars {
  margin-inline-start: auto;
}


/* Navigation bar */
.test-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
  padding: var(--space-s) var(--space-m);
  background: var(--card);
  box-shadow: 0 -2px 8px oklch(0 0 0 / 5%);
  flex-shrink: 0;
}

.test-nav-prev,
.test-nav-next {
  font-family: var(--font-body);
  font-size: var(--step-0);
  font-weight: 600;
  padding: var(--space-s) var(--space-l);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s;
}

.test-nav-prev {
  background: var(--input-bg);
  color: var(--text);
  &:hover { background: oklch(0 0 0 / 8%); }
  &:disabled { opacity: 0.4; cursor: default; }
}

.test-nav-next {
  background: var(--accent);
  color: oklch(1 0 0);
  &:hover { background: var(--accent-hover); }
}

.test-submit-btn {
  background: var(--green);
  color: oklch(1 0 0);
  font-family: var(--font-body);
  font-size: var(--step-0);
  font-weight: 700;
  padding: var(--space-s) var(--space-xl);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s;
  /* --green-hover fandtes kun i den gamle tokens.css (ikke længere loadet) —
     afled hover-farven fra --green som rolig.css gør med sine accenter */
  &:hover { background: oklch(from var(--green) calc(l - 0.04) c h); }
}

.test-nav-dots {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: center;
}

.test-nav-dot {
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.2s;

  &.active { background: var(--accent); transform: scale(1.3); }
  &.answered { background: var(--accent); opacity: 0.5; }
}


/* Lobby (waiting for teacher) */
.test-lobby {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-m);
  text-align: center;
  padding: var(--space-xl);
}

.test-lobby-title {
  font-size: var(--step-2);
  font-weight: 700;
}

.test-lobby-subtitle {
  font-size: var(--step-0);
  color: var(--muted);
}

.test-lobby-code {
  /* --step-hero fandtes kun i den gamle tokens.css (ikke længere linket), så
     var() var udefineret og koden faldt til arvet ~16px. Eksplicit clamp her. */
  font-size: clamp(72px, 15vw, 140px);
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--accent);
}

/* Submitted state */
.test-submitted {
  flex: 1;
  min-block-size: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-block: var(--s-5);
  padding-inline: var(--s-4);
  max-inline-size: 640px;
  inline-size: 100%;
  margin-inline: auto;
}

.test-submitted-check {
  inline-size: 4rem;
  block-size: 4rem;
  color: var(--green);
}

/* ─── Summary view (kompakt resultat efter aflevering) ─── */
.test-summary { display: flex; flex-direction: column; gap: var(--s-3); }

.test-summary-kicker {
  font: 500 10px var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 10px;
}
.test-summary-kicker::before { content: ""; inline-size: 20px; block-size: 1px; background: var(--accent); }

.test-summary-title {
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 700;
  letter-spacing: -0.028em;
  line-height: 1.08;
  margin-block-end: var(--s-3);
}

.test-summary-score {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  padding: 20px 22px;
  border: 1px solid var(--rule);
  border-radius: var(--r-xl);
  background: var(--paper);
  margin-block-end: var(--s-3);
}
.test-score-num {
  font: 800 56px var(--sans);
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.test-score-total {
  font: 600 22px var(--mono);
  color: var(--ink-3);
}
.test-score-time {
  margin-inline-start: auto;
  text-align: end;
}
.test-score-time-label {
  font: 600 10px var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  margin-block-end: 3px;
}
.test-score-time-value {
  font: 600 14px var(--mono);
  color: var(--ink);
}

/* Grid med spørgsmål-status (rigtigt/forkert/ikke graderet) */
.test-summary-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  margin-block-end: var(--s-3);
}
.test-grid-cell {
  aspect-ratio: 1;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 11px var(--mono);
  border: 1px solid var(--rule);
  background: var(--paper-2);
  color: var(--ink-3);
}
.test-grid-cell.cell-ok {
  background: oklch(from var(--green) l c h / 14%);
  border-color: var(--green);
  color: var(--green);
}
.test-grid-cell.cell-bad {
  background: oklch(from var(--red) l c h / 10%);
  border-color: var(--red);
  color: var(--red);
}
.test-grid-cell.cell-na {
  background: var(--paper-2);
  border-color: var(--rule-2);
  color: var(--ink-3);
}

.test-summary-note {
  padding: 12px 14px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-m);
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-2);
  margin-block-end: var(--s-3);
}
.test-summary-note strong { color: var(--ink); font-weight: 600; }

.test-summary-actions {
  display: flex;
  gap: 8px;
  margin-block-start: auto;
}
.test-summary-actions .btn { flex: 1; block-size: 44px; }

/* ─── Review (gennemse hvert spørgsmål) ─── */
.test-review { display: flex; flex-direction: column; gap: var(--s-3); }
.test-review-back { align-self: flex-start; margin-block-end: var(--s-2); }

.test-review-card {
  padding: 18px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--r-xl);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.test-review-card.card-ok {
  border-color: var(--green);
  background: oklch(from var(--green) l c h / 5%);
}
.test-review-card.card-bad {
  border-color: var(--red);
  background: oklch(from var(--red) l c h / 5%);
}

.test-review-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: 600 10px var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.test-review-num { color: var(--ink-3); }
.test-review-card.card-ok .test-review-status { color: var(--green); }
.test-review-card.card-bad .test-review-status { color: var(--red); }
.test-review-card.card-na .test-review-status { color: var(--ink-3); }

.test-review-q {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.3;
  color: var(--ink);
  margin: 0;
}

.test-review-opts { display: flex; flex-direction: column; gap: 6px; }
.test-review-opt {
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-m);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-2);
}
.test-review-opt.opt-correct {
  border-color: var(--green);
  background: oklch(from var(--green) l c h / 8%);
  color: var(--ink);
}
.test-review-opt.opt-wrong {
  border-color: var(--red);
  background: oklch(from var(--red) l c h / 6%);
  color: var(--ink-2);
}
.test-review-letter {
  inline-size: 22px;
  block-size: 22px;
  border-radius: 50%;
  background: var(--paper-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 600 10px var(--mono);
  flex-shrink: 0;
}
.test-review-opt.opt-correct .test-review-letter { background: var(--green); color: var(--paper); }

.test-review-freetext {
  padding: 12px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-m);
  background: var(--paper-2);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
}


/* =============================================================================
   RESULTS PAGE — Teacher dashboard
   ============================================================================= */

.results-container {
  min-block-size: 100dvh;
  display: flex;
  flex-direction: column;
}

.results-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-m);
  padding: var(--space-s) var(--space-l);
  background: var(--card);
  box-shadow: var(--shadow-s);
  flex-shrink: 0;
}

.results-topbar-title {
  font-size: var(--step-1);
  font-weight: 700;
}

.results-topbar-spacer { flex: 1; }

.results-topbar-meta {
  font-size: var(--step--1);
  color: var(--muted);
}

.results-topbar-timer {
  font-weight: 700;
  font-size: var(--step-0);
  font-variant-numeric: tabular-nums;
}

.results-content {
  flex: 1;
  padding: var(--space-l);
  max-inline-size: 1000px;
  margin-inline: auto;
  inline-size: 100%;
}

/* Lobby state */
.results-lobby {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-block-size: 80vh;
  gap: var(--space-s);
  text-align: center;
}

.results-lobby-code {
  font-size: clamp(100px, 20vw, 220px);
  font-weight: 800;
  letter-spacing: 0.15em;
  line-height: 1;
  color: var(--accent);
}

.results-lobby-count {
  font-size: clamp(1.2rem, 3vw, 2rem);
  color: var(--muted);
}

/* Lobby logo: dida.dk/t */
.lobby-logo {
  font-size: clamp(2.5rem, 1rem + 4vw, 4.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--text);
}

.lobby-logo-dot {
  color: var(--accent);
}

.lobby-logo-accent {
  color: var(--accent);
}

/* Student table */
.student-table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
}

.student-table th {
  text-align: start;
  padding: var(--space-xs) var(--space-s);
  border-block-end: 2px solid var(--border);
  font-weight: 700;
  color: var(--muted);
  font-size: var(--step--2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.student-table td {
  padding: var(--space-xs) var(--space-s);
  border-block-end: 1px solid var(--border);
  vertical-align: middle;
}

.student-table tr:hover td {
  background: var(--accent-subtle);
}

/* Online indicator */
.online-dot {
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  display: inline-block;
  margin-inline-end: 0.3rem;
}

.online-dot.on { background: var(--green); }
.online-dot.off { background: var(--muted); opacity: 0.4; }

/* Focus warning in table */
.focus-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
  padding: 0.1em 0.4em;
  border-radius: var(--radius-s);
  font-weight: 700;
  font-size: var(--step--2);
}

.focus-badge.ok { color: var(--muted); }

.focus-badge.warn {
  background: light-dark(oklch(0.95 0.06 27), oklch(0.25 0.08 27));
  color: light-dark(oklch(0.5 0.15 27), oklch(0.85 0.1 27));
}

.focus-badge.alert {
  background: light-dark(oklch(0.9 0.1 27), oklch(0.3 0.12 27));
  color: light-dark(oklch(0.45 0.18 27), oklch(0.9 0.12 27));
  animation: pulse-text 2s ease-in-out infinite;
}

/* Submitted badge */
.submitted-badge {
  font-size: var(--step--2);
  font-weight: 600;
  padding: 0.1em 0.4em;
  border-radius: var(--radius-s);
  background: light-dark(oklch(0.92 0.05 163), oklch(0.25 0.06 163));
  color: light-dark(oklch(0.4 0.15 163), oklch(0.85 0.1 163));
}

/* Progress bar */
.progress-bar {
  inline-size: 100%;
  block-size: 0.4rem;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  block-size: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: inline-size 0.3s;
}

/* Controls bar */
.results-controls {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  padding: var(--space-s) var(--space-l);
  background: var(--card);
  box-shadow: 0 -2px 8px oklch(0 0 0 / 5%);
  flex-shrink: 0;
}


/* =============================================================================
   SHARED — Toggle switch (reused from components)
   ============================================================================= */

.toggle-switch {
  position: relative;
  inline-size: 2.5rem;
  block-size: 1.25rem;
  flex-shrink: 0;

  & input {
    opacity: 0;
    inline-size: 0;
    block-size: 0;
    position: absolute;
  }
}

.toggle-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: var(--border);
  border-radius: var(--radius-full);
  transition: background 0.2s;

  &::after {
    content: '';
    position: absolute;
    inset-block-start: 2px;
    inset-inline-start: 2px;
    inline-size: calc(1.25rem - 4px);
    block-size: calc(1.25rem - 4px);
    background: oklch(1 0 0);
    border-radius: 50%;
    transition: transform 0.2s;
  }
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);

  &::after {
    transform: translateX(1.25rem);
  }
}


/* =============================================================================
   DIALOG (shared pattern)
   ============================================================================= */

/* :not(.md-dialog):not(.tr-dialog) undtager Quill-editor-modalen OG skrive-
   afspilleren (replay.js). Uden det ville denne regels højere specificitet
   (0,2,1) overstyre deres egne bredde-/padding-regler og klemme dem ned til
   480px + påtvinge padding — begge styrer selv deres bredde (afspilleren op til
   96vw i stor visning, editoren 900px), begge med padding:0. */
dialog[open]:not(.md-dialog):not(.tr-dialog) {
  border: none;
  border-radius: var(--radius-l);
  padding: var(--space-l);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-hover);
  max-inline-size: min(90vw, 480px);
}

dialog::backdrop {
  background: oklch(0 0 0 / 50%);
}


/* =============================================================================
   ACCESSIBILITY
   ============================================================================= */

@media (prefers-contrast: more) {
  .test-option { border-width: 2px; }
  .student-table th { border-block-end-width: 3px; }
}

@media (forced-colors: active) {
  .online-dot { forced-color-adjust: none; }
  .focus-badge { forced-color-adjust: none; }
}


/* =============================================================================
   STATUS BADGES — Mine tests list on index.html
   ============================================================================= */

.status-badge {
  display: inline-block;
  padding: 0.1em 0.5em;
  border-radius: var(--radius-full);
  font-size: var(--step--2);
  font-weight: 700;
  vertical-align: middle;
}

.status-badge-kladde {
  background: var(--border);
  color: var(--muted);
}

.status-badge-aktiv {
  background: light-dark(oklch(0.92 0.08 163), oklch(0.25 0.08 163));
  color: light-dark(oklch(0.4 0.18 163), oklch(0.85 0.1 163));
}

.status-badge-afsluttet {
  background: var(--border);
  color: var(--text);
  opacity: 0.7;
}


/* =============================================================================
   DRAG & DROP — Create page question ordering
   ============================================================================= */

.drag-handle {
  cursor: grab;
  color: var(--muted);
  opacity: 0.35;
  flex-shrink: 0;
  transition: opacity 0.15s;
  user-select: none;

  &:hover { opacity: 0.9; }
  &:active { cursor: grabbing; }
}

.question-card.dragging {
  opacity: 0.4;
  box-shadow: none;
}

.question-card.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}


/* =============================================================================
   DRAFT BANNER — Auto-save restore prompt on create page
   ============================================================================= */

.draft-banner {
  background: light-dark(oklch(0.97 0.05 75), oklch(0.22 0.05 75));
  color: light-dark(oklch(0.38 0.12 75), oklch(0.85 0.08 75));
  padding: var(--space-xs) var(--space-l);
  display: flex;
  align-items: center;
  gap: var(--space-s);
  font-size: var(--step--1);
  font-weight: 500;
  flex-wrap: wrap;
}


/* =============================================================================
   STORE DAYS PILLS — Retention selector on create page
   ============================================================================= */

.store-days-pills {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.store-days-pill {
  font-family: var(--font-body);
  font-size: var(--step--2);
  padding: 0.2em 0.75em;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;

  &:hover {
    border-color: var(--accent);
    color: var(--accent);
  }

  &.active {
    background: var(--accent);
    border-color: var(--accent);
    color: oklch(1 0 0);
    font-weight: 600;
  }
}


/* =============================================================================
   IMPORT / EKSPORT / AI-PROMPT — sammenklappelig kort under spørgsmålslisten
   ============================================================================= */

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
}

.ie-card { margin-block-start: var(--space-m); }

.collapsible-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0;
  cursor: pointer;
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: none;
  background: none;
  inline-size: 100%;
  font-family: inherit;
  transition: color 0.15s;
}

.collapsible-toggle:hover { color: var(--text); }

.collapsible-arrow {
  margin-inline-start: auto;
  font-size: var(--step--2);
  transition: transform 0.2s;
}

.collapsible-toggle.open .collapsible-arrow { transform: rotate(90deg); }

.collapsible-body {
  animation: fade-in 0.15s ease-out;
  padding-block-start: var(--space-m);
}

.ie-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-block-end: var(--space-s);

  & .btn {
    font-size: var(--step--1);
    padding: 0.3em 0.7em;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    box-shadow: none;
    font-weight: 500;

    &:hover {
      color: var(--text);
      border-color: var(--accent);
      background: oklch(from var(--accent) l c h / 8%);
    }
  }
}

.import-area {
  margin-block-start: var(--space-m);
  animation: fade-in 0.2s ease-out;
}

.import-textarea {
  inline-size: 100%;
  min-block-size: 120px;
  padding: var(--space-m);
  border: 2px solid var(--border);
  border-radius: var(--radius-m);
  font-family: 'Courier New', monospace;
  font-size: var(--step--1);
  line-height: 1.5;
  resize: vertical;
  background: var(--card);
  color: var(--text);
  transition: border-color 0.2s ease;

  &:focus {
    outline: none;
    border-color: var(--accent);
  }
}

.import-error {
  margin-block-start: var(--space-s);
  padding: var(--space-s) var(--space-m);
  border-radius: var(--radius-s);
  background: oklch(0.63 0.24 27 / 10%);
  color: oklch(0.55 0.22 27);
  font-size: var(--step--1);
  font-weight: 500;
}

.import-preview {
  margin-block-start: var(--space-s);
  padding: var(--space-m);
  border-radius: var(--radius-m);
  background: oklch(from var(--accent) l c h / 8%);
  font-size: var(--step--1);

  & .preview-slide {
    padding: var(--space-xs) 0;

    &:not(:last-child) {
      border-block-end: 1px solid oklch(from var(--accent) l c h / 15%);
      margin-block-end: var(--space-xs);
      padding-block-end: var(--space-xs);
    }
  }

  & .preview-type {
    display: inline-block;
    padding: 0.1em 0.5em;
    border-radius: var(--radius-full);
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    background: oklch(from var(--accent) l c h / 18%);
    color: oklch(from var(--accent) calc(l - 0.2) c h);
    margin-inline-end: var(--space-s);
  }

  & .preview-q { font-weight: 600; color: var(--text); }

  & .preview-answers {
    color: var(--muted);
    font-size: 0.85em;
    margin-block-start: 2px;
  }
}

.import-actions {
  display: flex;
  gap: var(--space-s);
  justify-content: flex-end;
  margin-block-start: var(--space-m);
}


/* =============================================================================
   DARK MODE — Results page projector/smartboard mode
   ============================================================================= */

body.dark {
  color-scheme: dark;
}


/* =============================================================================
   CONNECTION BANNER — Slow connection warning on test page
   ============================================================================= */

.connection-banner {
  background: light-dark(oklch(0.96 0.06 75), oklch(0.22 0.06 75));
  color: light-dark(oklch(0.38 0.12 75), oklch(0.85 0.08 75));
  padding: var(--space-xs) var(--space-m);
  font-size: var(--step--1);
  font-weight: 600;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
}


/* =============================================================================
   ADMIN OFFLINE-BADGE + ELEV FALLBACK-KNAP — lærerstyret tempo
   ============================================================================= */

@keyframes slideUp {
  from { transform: translateY(1rem); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.admin-offline-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  background: light-dark(oklch(0.95 0.05 75), oklch(0.25 0.06 75));
  color: light-dark(oklch(0.45 0.12 75), oklch(0.85 0.1 75));
  border: 1px solid oklch(0.75 0.17 75 / 40%);
  border-radius: var(--radius-m);
  padding: var(--space-xs) var(--space-m);
  font-size: var(--step--1);
  font-weight: 600;
  text-align: center;
  margin: var(--space-xs) var(--space-m);
  animation: slideUp 0.3s ease;
}

.student-fallback-next {
  display: flex;
  margin: var(--space-s) var(--space-m) 0;
  opacity: 0.85;
  animation: slideUp 0.4s ease;

  &:hover { opacity: 1; }
}


/* =============================================================================
   LEAVE BUTTON — Student test topbar
   ============================================================================= */

.test-leave-btn {
  display: flex;
  align-items: center;
  gap: 0.25em;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: var(--step--1);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-s);
  transition: color 0.15s;
  flex-shrink: 0;
  white-space: nowrap;

  &:hover { color: var(--text); }
}


/* =============================================================================
   QUESTION TIMELINE — Live countdown per question (results.html teacher view)
   ============================================================================= */

.question-timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-block-end: var(--space-m);
}

.timeline-item {
  display: grid;
  grid-template-columns: 1.6rem 1fr auto;
  align-items: center;
  gap: var(--space-s);
  font-size: var(--step--1);

  &.active {
    font-weight: 700;
    color: var(--accent);
  }

  &.done { color: var(--muted); }
}

.timeline-item-nr {
  font-size: var(--step--2);
  font-weight: 700;
  color: var(--muted);
  text-align: end;
}

.timeline-bar-wrap {
  background: light-dark(oklch(0 0 0 / 6%), oklch(1 0 0 / 8%));
  border-radius: var(--radius-full);
  block-size: 6px;
  overflow: hidden;
}

.timeline-bar-fill {
  block-size: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
  transition: inline-size 1s linear;
}

.timeline-item.done .timeline-bar-fill {
  background: var(--muted);
  inline-size: 100% !important;
}

.timeline-time {
  font-variant-numeric: tabular-nums;
  font-size: var(--step--2);
  min-inline-size: 3ch;
  text-align: end;
}


/* =============================================================================
   EXPIRED WARNING — Time expired but student can still answer
   ============================================================================= */

.locked-badge {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-size: var(--step--1);
  font-weight: 600;
  color: light-dark(oklch(0.40 0.14 75), oklch(0.80 0.12 75));
  background: light-dark(oklch(0.96 0.06 75), oklch(0.22 0.06 75));
  border-radius: var(--radius-m);
  padding: 0.5em 0.8em;
  margin-block-start: var(--space-s);
}

/* Extend-time button on results page (teacher dashboard) */
.extend-time-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font-family: var(--font-body);
  font-size: var(--step--2);
  font-weight: 600;
  padding: 0.25em 0.75em;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-full);
  background: none;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.15s;

  &:hover {
    background: var(--accent);
    color: oklch(1 0 0);
  }

  &:disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
  }
}


/* =============================================================================
   EXTRA TIME (ordblind)
   ============================================================================= */

/* Checkbox in lobby */
.extra-time-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  margin-block-start: var(--space-l);
  padding: var(--space-s) var(--space-m);
  border-radius: var(--radius-m);
  background: light-dark(oklch(0.7 0.14 180 / 10%), oklch(0.7 0.14 180 / 15%));
  border: 1px solid light-dark(oklch(0.7 0.14 180 / 25%), oklch(0.7 0.14 180 / 30%));
  font-size: var(--step--1);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;

  & input[type="checkbox"] {
    accent-color: oklch(0.7 0.14 180);
    inline-size: 1.1rem;
    block-size: 1.1rem;
    cursor: pointer;
  }

  & .hi {
    color: oklch(0.7 0.14 180);
    flex-shrink: 0;
  }

  &:hover {
    background: light-dark(oklch(0.7 0.14 180 / 15%), oklch(0.7 0.14 180 / 20%));
  }
}

/* Badge in student topbar */
.extra-time-badge {
  font-size: var(--step--2);
  font-weight: 700;
  color: oklch(0.7 0.14 180);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: light-dark(oklch(0.7 0.14 180 / 12%), oklch(0.7 0.14 180 / 18%));
  white-space: nowrap;
}

/* Badge next to student name in teacher dashboard table */
.extra-time-table-badge {
  display: inline-flex;
  align-items: center;
  margin-inline-start: 0.4em;
  color: oklch(0.7 0.14 180);
  vertical-align: middle;

  & .hi {
    width: 0.95em;
    height: 0.95em;
  }
}

/* Toast notification for teacher dashboard */
.extra-time-toast {
  position: fixed;
  inset-block-end: 2rem;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-s);
  font-size: var(--step--1);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-s);
  z-index: 1000;
  box-shadow: var(--shadow-m);
  white-space: nowrap;
  animation: toast-in 0.25s ease;

  & .hi {
    color: oklch(0.7 0.14 180);
    flex-shrink: 0;
  }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(0.5rem); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
