/* ═══════════════════════════════════════════════════════
   TestLab — Student View (iPad-Optimized, Light Theme)
   ═══════════════════════════════════════════════════════ */

/* ── Language Selector ─────────────────────────────── */

/* When inside the toolbar wrapper, lang selector is no longer fixed-positioned */
.tl-student-toolbar .tl-lang-selector {
  position: static;
}

.tl-lang-selector {
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--tl-radius-lg);
  padding: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.tl-lang-btn {
  font-family: var(--tl-font);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border: none;
  border-radius: calc(var(--tl-radius-lg) - 2px);
  background: transparent;
  color: var(--tl-text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
}

.tl-lang-btn:hover {
  background: rgba(79, 70, 229, 0.08);
  color: var(--tl-primary);
}

.tl-lang-btn.active {
  background: var(--tl-primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(79, 70, 229, 0.3);
}

/* ── Join Screen ───────────────────────────────────── */

.join-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--tl-space-xl);
  background: linear-gradient(135deg, #f0f4ff 0%, #f8fafc 50%, #fdf4ff 100%);
}

.join-logo {
  width: 80px;
  height: 80px;
  background: var(--tl-primary);
  border-radius: var(--tl-radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--tl-space-lg);
  box-shadow: 0 8px 30px rgba(79, 70, 229, 0.25);
}

.join-logo svg {
  width: 40px;
  height: 40px;
  color: white;
}

.join-title {
  font-size: var(--tl-text-3xl);
  font-weight: 700;
  color: var(--tl-text);
  margin-bottom: var(--tl-space-xs);
  letter-spacing: -0.02em;
}

.join-subtitle {
  color: var(--tl-text-secondary);
  font-size: var(--tl-text-lg);
  margin-bottom: var(--tl-space-2xl);
}

.join-card {
  width: 100%;
  max-width: 420px;
}

.join-field {
  margin-bottom: var(--tl-space-lg);
}

.join-field label {
  display: block;
  font-weight: 600;
  font-size: var(--tl-text-sm);
  color: var(--tl-text-secondary);
  margin-bottom: var(--tl-space-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.join-code-input {
  text-align: center;
  font-size: clamp(1.5rem, 5vw, 2rem) !important;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-family: var(--tl-font-mono);
}

.join-code-input::placeholder {
  letter-spacing: 0.1em;
  font-weight: 400;
  opacity: 0.4;
}

.join-name-input {
  font-size: var(--tl-text-xl) !important;
}

.join-btn {
  width: 100%;
  margin-top: var(--tl-space-sm);
}

.join-error {
  color: var(--tl-danger);
  font-size: var(--tl-text-sm);
  text-align: center;
  margin-top: var(--tl-space-md);
  min-height: 1.5em;
}

/* Results page link */
.results-link {
  display: inline-block;
  margin-top: var(--tl-space-lg);
  color: var(--tl-text-secondary);
  font-size: var(--tl-text-base);
  text-decoration: none;
  transition: color 0.15s;
}
.results-link:hover {
  color: var(--tl-primary);
  text-decoration: underline;
}

/* Name dropdown for roster mode */
.join-name-select {
  width: 100%;
  padding: var(--tl-space-sm) var(--tl-space-md);
  border: 2px solid var(--tl-border);
  border-radius: var(--tl-radius-md);
  font-size: var(--tl-text-xl);
  background: var(--tl-bg-card);
  color: var(--tl-text);
  min-height: 48px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

/* ── Waiting Room ──────────────────────────────────── */

.waiting-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--tl-space-xl);
  text-align: center;
  background: linear-gradient(135deg, #f0f4ff 0%, #f8fafc 50%, #fdf4ff 100%);
}

.waiting-icon {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tl-primary-light), var(--tl-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--tl-space-xl);
  animation: tl-breathe 3s ease-in-out infinite;
}

@keyframes tl-breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.3); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 20px rgba(79, 70, 229, 0); }
}

.waiting-icon svg { width: 48px; height: 48px; color: white; }

.waiting-name {
  font-size: var(--tl-text-2xl);
  font-weight: 700;
  margin-bottom: var(--tl-space-sm);
}

.waiting-name .tl-badge { font-size: var(--tl-text-sm); vertical-align: middle; margin-left: 8px; }

.waiting-message {
  font-size: var(--tl-text-lg);
  color: var(--tl-text-secondary);
}

.waiting-room-code {
  margin-top: var(--tl-space-xl);
  font-size: var(--tl-text-sm);
  color: var(--tl-text-muted);
}

.waiting-room-code span {
  font-family: var(--tl-font-mono);
  font-weight: 600;
  color: var(--tl-text-secondary);
}

/* ── Test View ─────────────────────────────────────── */

.test-screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Hide the disclaimer footer completely during the test */
.test-screen:not(.tl-hidden) ~ .tl-disclaimer {
  display: none !important;
}

/* Top bar */
.test-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--tl-space-sm) var(--tl-space-lg);
  background: var(--tl-bg-card);
  border-bottom: 1px solid var(--tl-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.test-topbar-left {
  display: flex;
  align-items: center;
  gap: var(--tl-space-md);
}

.test-question-nav {
  font-weight: 600;
  font-size: var(--tl-text-lg);
  color: var(--tl-text);
}

.test-topbar-right {
  display: flex;
  align-items: center;
  gap: var(--tl-space-md);
}

.test-timer {
  font-family: var(--tl-font-mono);
  font-weight: 700;
  font-size: var(--tl-text-xl);
  color: var(--tl-text);
  padding: var(--tl-space-xs) var(--tl-space-sm);
  background: var(--tl-bg-elevated);
  border-radius: var(--tl-radius-md);
  min-width: 70px;
  text-align: center;
}

.test-timer.warning { color: var(--tl-warning); background: #fef3c7; }
.test-timer.danger { color: var(--tl-danger); background: #fee2e2; animation: tl-pulse 1s infinite; }

/* Progress dots */
.test-progress {
  display: flex;
  gap: 6px;
  padding: var(--tl-space-xs) 0;
  justify-content: center;
  flex-wrap: wrap;
  padding: var(--tl-space-sm) var(--tl-space-lg);
  background: var(--tl-bg-card);
  border-bottom: 1px solid var(--tl-border);
}

.progress-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--tl-border);
  background: var(--tl-bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--tl-text-muted);
  cursor: pointer;
  transition: all var(--tl-transition);
}

.progress-dot:hover { border-color: var(--tl-primary-light); }
.progress-dot.current { border-color: var(--tl-primary); color: var(--tl-primary); background: #eef2ff; }
.progress-dot.answered { border-color: var(--tl-success); background: var(--tl-success); color: white; }
.progress-dot.flagged { border-color: var(--tl-warning); background: #fef3c7; color: #92400e; }

/* Question area */
.test-question-area {
  flex: 1;
  padding: var(--tl-space-lg);
  display: flex;
  flex-direction: column;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.question-type-badge {
  margin-bottom: var(--tl-space-sm);
}

.question-text {
  font-size: var(--tl-text-2xl);
  font-weight: 600;
  line-height: 1.4;
  color: var(--tl-text);
  margin-bottom: var(--tl-space-xl);
}

/* ── Multiple Choice ───────────────────────────────── */

.mc-options {
  display: flex;
  flex-direction: column;
  gap: var(--tl-space-md);
}

.mc-option {
  display: flex;
  align-items: center;
  gap: var(--tl-space-md);
  padding: var(--tl-space-md) var(--tl-space-lg);
  border: 2px solid var(--tl-border);
  border-radius: var(--tl-radius-lg);
  background: var(--tl-bg-card);
  cursor: pointer;
  transition: all var(--tl-transition);
  min-height: 56px;
  user-select: none;
  -webkit-user-select: none;
}

.mc-option:hover { border-color: var(--tl-primary-light); background: #f8f7ff; }
.mc-option.selected { border-color: var(--tl-primary); background: #eef2ff; }
.mc-option:active { transform: scale(0.98); }

.mc-option-key {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--tl-bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--tl-text-sm);
  color: var(--tl-text-secondary);
  flex-shrink: 0;
  transition: all var(--tl-transition);
}

.mc-option.selected .mc-option-key {
  background: var(--tl-primary);
  color: white;
}

.mc-option-text {
  font-size: var(--tl-text-lg);
  color: var(--tl-text);
  flex: 1;
}

/* ── True/False ────────────────────────────────────── */

.tf-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--tl-space-lg);
}

.tf-option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--tl-space-xl);
  border: 2px solid var(--tl-border);
  border-radius: var(--tl-radius-xl);
  background: var(--tl-bg-card);
  cursor: pointer;
  transition: all var(--tl-transition);
  font-size: var(--tl-text-2xl);
  font-weight: 700;
  user-select: none;
  -webkit-user-select: none;
}

.tf-option:hover { border-color: var(--tl-primary-light); }
.tf-option.selected { border-color: var(--tl-primary); background: #eef2ff; color: var(--tl-primary); }
.tf-option:active { transform: scale(0.97); }

.tf-option.true-opt.selected { border-color: var(--tl-success); background: #ecfdf5; color: var(--tl-success); }
.tf-option.false-opt.selected { border-color: var(--tl-danger); background: #fef2f2; color: var(--tl-danger); }

/* ── Fill in the blank ─────────────────────────────── */

.fill-blank-input {
  font-size: var(--tl-text-2xl) !important;
  text-align: center;
  padding: var(--tl-space-lg) !important;
  border: 2px dashed var(--tl-border);
  border-radius: var(--tl-radius-lg);
}

.fill-blank-input:focus {
  border-style: solid;
}

/* ── Open-ended ────────────────────────────────────── */

.open-ended-textarea {
  width: 100%;
  min-height: 200px;
  padding: var(--tl-space-lg);
  border: 2px solid var(--tl-border);
  border-radius: var(--tl-radius-lg);
  font-size: var(--tl-text-lg);
  line-height: 1.6;
  resize: vertical;
  font-family: var(--tl-font);
}

.open-ended-textarea:focus {
  outline: none;
  border-color: var(--tl-border-focus);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.char-count {
  text-align: right;
  font-size: var(--tl-text-sm);
  color: var(--tl-text-muted);
  margin-top: var(--tl-space-xs);
}

/* ── Matching ──────────────────────────────────────── */

.matching-container {
  display: flex;
  flex-direction: column;
  gap: var(--tl-space-md);
}

.matching-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--tl-space-md);
  align-items: center;
}

.matching-left {
  padding: var(--tl-space-md);
  background: var(--tl-bg-elevated);
  border-radius: var(--tl-radius-md);
  font-weight: 600;
  text-align: center;
}

.matching-arrow { color: var(--tl-text-muted); font-size: 1.25rem; }

.matching-select {
  padding: var(--tl-space-sm) var(--tl-space-md);
  border: 2px solid var(--tl-border);
  border-radius: var(--tl-radius-md);
  font-size: var(--tl-text-base);
  background: var(--tl-bg-card);
  min-height: 48px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.matching-select.matched {
  border-color: var(--tl-success);
  background-color: #f0fdf4;
}

/* ── Ordering ──────────────────────────────────────── */

.ordering-list {
  display: flex;
  flex-direction: column;
  gap: var(--tl-space-sm);
}

.ordering-item {
  display: flex;
  align-items: center;
  gap: var(--tl-space-md);
  padding: var(--tl-space-md) var(--tl-space-lg);
  border: 2px solid var(--tl-border);
  border-radius: var(--tl-radius-lg);
  background: var(--tl-bg-card);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: box-shadow var(--tl-transition), border-color var(--tl-transition);
}

.ordering-item:active { cursor: grabbing; }
.ordering-item.dragging {
  box-shadow: var(--tl-shadow-lg);
  border-color: var(--tl-primary);
  opacity: 0.9;
  z-index: 10;
}

.ordering-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--tl-bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--tl-text-sm);
  color: var(--tl-text-secondary);
  flex-shrink: 0;
}

.ordering-handle {
  color: var(--tl-text-muted);
  flex-shrink: 0;
  cursor: grab;
}

.ordering-text { flex: 1; font-size: var(--tl-text-lg); }

.ordering-buttons {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.ordering-move-btn {
  width: 32px;
  height: 24px;
  border: 1px solid var(--tl-border);
  border-radius: var(--tl-radius-sm);
  background: var(--tl-bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tl-text-muted);
  font-size: 12px;
}

.ordering-move-btn:hover { background: var(--tl-bg-elevated); color: var(--tl-text); }
.ordering-move-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Bottom navigation ─────────────────────────────── */

.test-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  bottom: 0;
  /* relative for absolute-positioned Submit button */
  padding: var(--tl-space-md) var(--tl-space-lg);
  background: var(--tl-bg-card);
  border-top: 1px solid var(--tl-border);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
  z-index: 1000;
}

/* Prev/Next are truly centred; Submit is positioned independently */
.test-nav-btns {
  display: flex;
  gap: var(--tl-space-xl);
}

/* Make Previous / Next buttons more prominent and equal width */
.test-nav-btns .tl-btn {
  width: 140px;
  font-size: var(--tl-text-base);
  font-weight: 600;
  padding: var(--tl-space-sm) var(--tl-space-lg);
  background: var(--tl-bg-card);
  border: 2px solid var(--tl-primary);
  color: var(--tl-primary);
  border-radius: var(--tl-radius-lg);
  transition: background 0.2s, color 0.2s, transform 0.1s;
}

.test-nav-btns .tl-btn:hover:not(:disabled) {
  background: var(--tl-primary);
  color: #fff;
}

.test-nav-btns .tl-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.test-nav-btns .tl-btn:disabled {
  opacity: 0.35;
  border-color: var(--tl-border);
  color: var(--tl-text-muted);
}

/* Submit button — replaces Next on the last question */
.test-nav-btns > .tl-btn-success {
  width: 140px;
  font-size: var(--tl-text-base);
  font-weight: 600;
  padding: var(--tl-space-sm) var(--tl-space-lg);
  border-radius: var(--tl-radius-lg);
  white-space: nowrap;
}

/* ── Submission Screen ─────────────────────────────── */

.submitted-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--tl-space-xl);
  text-align: center;
  background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 50%, #f0f9ff 100%);
}

.submitted-icon {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tl-success-light), var(--tl-success));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--tl-space-xl);
  animation: tl-scaleIn 0.5s ease;
}

.submitted-icon svg { width: 60px; height: 60px; color: white; }

.submitted-title {
  font-size: var(--tl-text-3xl);
  font-weight: 700;
  color: var(--tl-text);
  margin-bottom: var(--tl-space-sm);
}

.submitted-message {
  font-size: var(--tl-text-lg);
  color: var(--tl-text-secondary);
}

/* ── Not Selected Screen ───────────────────────────── */

.not-selected-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--tl-space-xl);
  text-align: center;
  background: linear-gradient(135deg, #f0f4ff 0%, #f8fafc 100%);
}

.not-selected-icon {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--tl-bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--tl-space-xl);
}

/* ── Question Media ──────────────────────────── */

.question-media {
  margin-bottom: var(--tl-space-lg);
}
.question-media-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--tl-radius-lg);
  border: 1px solid var(--tl-border);
  display: block;
}
.question-media-video {
  width: 100%;
  max-width: 100%;
  border-radius: var(--tl-radius-lg);
  display: block;
}
.question-media audio {
  width: 100%;
  margin-top: var(--tl-space-sm);
}

/* ── Table Fill ──────────────────────────────── */

.table-fill-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 calc(-1 * var(--tl-space-md));
  padding: 0 var(--tl-space-md);
}
.table-fill {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--tl-text-base);
}
.table-fill th {
  background: var(--tl-bg-elevated);
  padding: var(--tl-space-sm) var(--tl-space-md);
  font-weight: 600;
  text-align: left;
  border: 1px solid var(--tl-border);
  font-size: var(--tl-text-sm);
  white-space: nowrap;
}
.table-fill td {
  padding: var(--tl-space-xs);
  border: 1px solid var(--tl-border);
  vertical-align: top;
}
.table-fill-fixed {
  background: var(--tl-bg-elevated);
  font-weight: 500;
  padding: var(--tl-space-sm) var(--tl-space-md);
  min-width: 120px;
}
.table-fill-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--tl-radius-sm);
  padding: var(--tl-space-xs) var(--tl-space-sm);
  font-family: var(--tl-font);
  font-size: var(--tl-text-base);
  background: var(--tl-bg-card);
  color: var(--tl-text);
  resize: vertical;
  transition: border-color var(--tl-transition);
}
.table-fill-input:focus {
  border-color: var(--tl-primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}
textarea.table-fill-input {
  min-height: 60px;
}

/* ── True/False + Correction ─────────────────── */

.tfc-statements {
  display: flex;
  flex-direction: column;
  gap: var(--tl-space-lg);
}
.tfc-statement {
  border: 2px solid var(--tl-border);
  border-radius: var(--tl-radius-lg);
  padding: var(--tl-space-md);
  transition: border-color var(--tl-transition);
}
.tfc-statement-text {
  font-size: var(--tl-text-lg);
  margin-bottom: var(--tl-space-md);
  line-height: 1.5;
}
.tfc-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--tl-space-sm);
  margin-bottom: var(--tl-space-xs);
}
.tfc-btn {
  padding: var(--tl-space-sm);
  border: 2px solid var(--tl-border);
  border-radius: var(--tl-radius-md);
  background: var(--tl-bg-card);
  color: var(--tl-text);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--tl-text-base);
  text-align: center;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--tl-transition);
  user-select: none;
  -webkit-user-select: none;
}
.tfc-btn:active {
  transform: scale(0.97);
}
.tfc-btn.true-opt.selected {
  border-color: #10b981;
  background: #ecfdf5;
  color: #059669;
}
.tfc-btn.false-opt.selected {
  border-color: #ef4444;
  background: #fef2f2;
  color: #dc2626;
}
.tfc-correction {
  margin-top: var(--tl-space-sm);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
}
.tfc-correction.visible {
  max-height: 200px;
  opacity: 1;
}
.tfc-correction-label {
  font-size: var(--tl-text-sm);
  font-weight: 600;
  color: var(--tl-text-secondary);
  margin-bottom: var(--tl-space-xs);
}
.tfc-correction-input {
  width: 100%;
  padding: var(--tl-space-sm) var(--tl-space-md);
  border: 2px dashed #ef4444;
  border-radius: var(--tl-radius-md);
  font-family: var(--tl-font);
  font-size: var(--tl-text-base);
  background: var(--tl-bg-card);
  color: var(--tl-text);
  min-height: 48px;
  transition: border-style var(--tl-transition), border-color var(--tl-transition);
}
.tfc-correction-input:focus {
  border-style: solid;
  border-color: #ef4444;
  outline: none;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}

/* ── Briefing Form ───────────────────────────── */

.briefing-form {
  display: flex;
  flex-direction: column;
  gap: var(--tl-space-md);
}
.briefing-field {
  display: flex;
  flex-direction: column;
  gap: var(--tl-space-xs);
}
.briefing-field label {
  font-weight: 600;
  font-size: var(--tl-text-sm);
  color: var(--tl-text-secondary);
}
.briefing-field .tl-input,
.briefing-field textarea {
  font-size: var(--tl-text-lg);
  padding: var(--tl-space-sm) var(--tl-space-md);
  border: 2px solid var(--tl-border);
  border-radius: var(--tl-radius-md);
  background: var(--tl-bg-card);
  color: var(--tl-text);
  font-family: var(--tl-font);
  min-height: 48px;
  transition: border-color var(--tl-transition);
}
.briefing-field .tl-input:focus,
.briefing-field textarea:focus {
  border-color: var(--tl-primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}
.briefing-field textarea {
  min-height: 80px;
  resize: vertical;
}

/* ── Drawing Canvas ──────────────────────────── */

.drawing-container {
  display: flex;
  flex-direction: column;
  gap: var(--tl-space-sm);
}
.drawing-toolbar {
  display: flex;
  gap: var(--tl-space-xs);
  flex-wrap: wrap;
  align-items: center;
  padding: var(--tl-space-sm) var(--tl-space-md);
  background: var(--tl-bg-elevated);
  border-radius: var(--tl-radius-lg);
  border: 1px solid var(--tl-border);
}
.drawing-tool-btn {
  width: 40px;
  height: 40px;
  border: 2px solid var(--tl-border);
  border-radius: var(--tl-radius-md);
  background: var(--tl-bg-card);
  color: var(--tl-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all var(--tl-transition);
  user-select: none;
  -webkit-user-select: none;
}
.drawing-tool-btn:active {
  transform: scale(0.93);
}
.drawing-tool-btn.active {
  border-color: var(--tl-primary);
  background: #eef2ff;
  color: var(--tl-primary);
}
.drawing-tool-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.drawing-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--tl-border);
  cursor: pointer;
  transition: transform var(--tl-transition), border-color var(--tl-transition);
  flex-shrink: 0;
}
.drawing-color-swatch.active {
  border-color: var(--tl-primary);
  transform: scale(1.25);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.25);
}
.drawing-separator {
  width: 1px;
  height: 28px;
  background: var(--tl-border);
  margin: 0 var(--tl-space-xs);
  flex-shrink: 0;
}
.drawing-canvas-wrapper {
  border: 2px solid var(--tl-border);
  border-radius: var(--tl-radius-lg);
  overflow: hidden;
  background: #ffffff;
  position: relative;
}
.drawing-canvas {
  display: block;
  touch-action: none;
  cursor: crosshair;
  width: 100%;
  height: auto;
}
.drawing-hint {
  text-align: center;
  font-size: var(--tl-text-sm);
  color: var(--tl-text-muted);
  padding: var(--tl-space-xs) 0;
}
.drawing-size-slider {
  width: 60px;
  accent-color: var(--tl-primary);
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════
   Dark Mode Overrides
   ═══════════════════════════════════════════════════════ */

/* ── Toolbar (language + theme toggle) ────────────── */

.tl-student-toolbar {
  position: fixed;
  top: var(--tl-space-sm);
  right: var(--tl-space-sm);
  z-index: 1000;
  display: flex;
  gap: 6px;
  align-items: center;
}

.tl-theme-toggle {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--tl-radius-lg);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.tl-theme-toggle:hover {
  background: rgba(79, 70, 229, 0.08);
}

.tl-theme-toggle svg { width: 16px; height: 16px; }
.tl-theme-toggle .icon-sun  { display: none; }
.tl-theme-toggle .icon-moon { display: block; color: var(--tl-text-secondary); }

/* ── Dark-mode toolbar adjustments ────────────────── */

[data-theme="dark"] .tl-lang-selector {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .tl-lang-btn {
  color: var(--tl-text-muted);
}

[data-theme="dark"] .tl-lang-btn:hover {
  background: rgba(129, 140, 248, 0.15);
  color: var(--tl-primary-light);
}

[data-theme="dark"] .tl-theme-toggle {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .tl-theme-toggle:hover {
  background: rgba(129, 140, 248, 0.15);
}

[data-theme="dark"] .tl-theme-toggle .icon-sun  { display: block; color: #fbbf24; }
[data-theme="dark"] .tl-theme-toggle .icon-moon { display: none; }

/* ── Full-screen backgrounds ──────────────────────── */

[data-theme="dark"] .join-screen {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

[data-theme="dark"] .waiting-screen {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

[data-theme="dark"] .submitted-screen {
  background: linear-gradient(135deg, #042f2e 0%, #0f172a 50%, #0c1a2e 100%);
}

[data-theme="dark"] .not-selected-screen {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

[data-theme="dark"] .not-selected-icon svg { stroke: var(--tl-text-muted); }

/* ── Join card ────────────────────────────────────── */

[data-theme="dark"] .join-logo {
  box-shadow: 0 8px 30px rgba(79, 70, 229, 0.35);
}

[data-theme="dark"] .join-name-select {
  background-color: var(--tl-bg-card);
  color: var(--tl-text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

/* ── Interactive elements (MC, TF, ordering, matching) ── */

[data-theme="dark"] .mc-option:hover {
  border-color: var(--tl-primary-light);
  background: rgba(79, 70, 229, 0.1);
}
[data-theme="dark"] .mc-option.selected {
  border-color: var(--tl-primary);
  background: rgba(79, 70, 229, 0.15);
}

[data-theme="dark"] .tf-option:hover { border-color: var(--tl-primary-light); }
[data-theme="dark"] .tf-option.selected {
  border-color: var(--tl-primary);
  background: rgba(79, 70, 229, 0.15);
  color: var(--tl-primary-light);
}
[data-theme="dark"] .tf-option.true-opt.selected {
  border-color: var(--tl-success);
  background: rgba(16, 185, 129, 0.12);
  color: var(--tl-success-light);
}
[data-theme="dark"] .tf-option.false-opt.selected {
  border-color: var(--tl-danger);
  background: rgba(239, 68, 68, 0.12);
  color: var(--tl-danger-light);
}

[data-theme="dark"] .fill-blank-input {
  background: var(--tl-bg-card);
  color: var(--tl-text);
}

[data-theme="dark"] .open-ended-textarea {
  background: var(--tl-bg-card);
  color: var(--tl-text);
}
[data-theme="dark"] .open-ended-textarea:focus {
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

[data-theme="dark"] .matching-select {
  background-color: var(--tl-bg-card);
  color: var(--tl-text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}
[data-theme="dark"] .matching-select.matched {
  border-color: var(--tl-success);
  background-color: rgba(16, 185, 129, 0.1);
}

/* ── Progress dots ────────────────────────────────── */

[data-theme="dark"] .progress-dot.current {
  border-color: var(--tl-primary-light);
  color: var(--tl-primary-light);
  background: rgba(79, 70, 229, 0.2);
}

/* ── Timer ────────────────────────────────────────── */

[data-theme="dark"] .test-timer.warning { color: var(--tl-warning); background: rgba(245, 158, 11, 0.15); }
[data-theme="dark"] .test-timer.danger  { color: var(--tl-danger-light); background: rgba(239, 68, 68, 0.15); }

/* ── Modal ────────────────────────────────────────── */

[data-theme="dark"] .tl-modal {
  background: var(--tl-bg-card);
  border: 1px solid var(--tl-border);
}

/* ── Disclaimer ───────────────────────────────────── */

[data-theme="dark"] .tl-disclaimer {
  background: rgba(15, 23, 42, 0.8);
  border-top-color: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .tl-disclaimer-text {
  color: rgba(148, 163, 184, 0.8);
}
[data-theme="dark"] .tl-disclaimer-logo {
  filter: invert(1) brightness(0.85);
  opacity: 0.55;
}
[data-theme="dark"] .tl-disclaimer:hover .tl-disclaimer-logo { opacity: 0.9; }

/* ── Table Fill (dark) ───────────────────────── */

[data-theme="dark"] .table-fill-input {
  background: var(--tl-bg-elevated);
  color: var(--tl-text);
}
[data-theme="dark"] .table-fill-input:focus {
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.2);
}

/* ── True/False + Correction (dark) ──────────── */

[data-theme="dark"] .tfc-btn.true-opt.selected {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}
[data-theme="dark"] .tfc-btn.false-opt.selected {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}
[data-theme="dark"] .tfc-correction-input {
  background: var(--tl-bg-elevated);
  color: var(--tl-text);
}
[data-theme="dark"] .tfc-correction-input:focus {
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* ── Briefing Form (dark) ────────────────────── */

[data-theme="dark"] .briefing-field .tl-input,
[data-theme="dark"] .briefing-field textarea {
  background: var(--tl-bg-elevated);
  color: var(--tl-text);
}
[data-theme="dark"] .briefing-field .tl-input:focus,
[data-theme="dark"] .briefing-field textarea:focus {
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.2);
}

/* ── Drawing Canvas (dark) ───────────────────── */

[data-theme="dark"] .drawing-toolbar {
  background: var(--tl-bg-elevated);
}
[data-theme="dark"] .drawing-tool-btn.active {
  border-color: var(--tl-primary-light);
  background: rgba(129, 140, 248, 0.15);
  color: var(--tl-primary-light);
}
[data-theme="dark"] .drawing-canvas-wrapper {
  background: #ffffff;
}

/* ── Smooth transition for theme switching ────────── */

body, .join-screen, .waiting-screen, .submitted-screen,
.not-selected-screen, .test-topbar, .test-progress,
.test-bottom-bar, .tl-card, .mc-option, .tf-option,
.ordering-item, .fill-blank-input, .open-ended-textarea,
.matching-left, .matching-select, .progress-dot,
.table-fill-input, .tfc-btn, .tfc-statement, .tfc-correction-input,
.briefing-field .tl-input, .briefing-field textarea,
.drawing-toolbar, .drawing-tool-btn {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ── Reconnection Overlay ──────────────────────── */
.reconnect-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px;
}
.reconnect-overlay-msg {
  color: #fff; font-size: 1.1rem; font-weight: 600;
}
.reconnect-spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: reconnect-spin 0.8s linear infinite;
}
@keyframes reconnect-spin {
  to { transform: rotate(360deg); }
}

/* ── Emergency QR Button ──────────────────────────── */
.tl-btn-emergency {
  display: flex; align-items: center; gap: 6px;
  background: #fef2f2; color: #dc2626; border: 1px solid #fecaca;
  border-radius: var(--tl-radius-md);
  padding: 6px 14px; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s ease;
  position: absolute; right: 16px; bottom: 10px;
}
.tl-btn-emergency:hover { background: #fee2e2; border-color: #f87171; }
[data-theme="dark"] .tl-btn-emergency {
  background: rgba(220, 38, 38, 0.15); border-color: rgba(220, 38, 38, 0.3);
}

/* ── QR Code Full-Screen Overlay ──────────────────── */
.qr-screen {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.qr-card {
  background: #fff; border-radius: 20px; padding: 32px 28px;
  max-width: 420px; width: 100%; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.qr-header {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 8px;
}
.qr-header h2 { font-size: 1.1rem; font-weight: 700; color: #1e293b; }

.qr-subtitle {
  color: #64748b; font-size: 0.9rem; margin-bottom: 20px; line-height: 1.4;
}

.qr-code-container {
  display: flex; align-items: center; justify-content: center;
  padding: 16px; margin: 0 auto 16px;
  background: #fff; border-radius: 12px;
  border: 2px solid #e2e8f0;
}
.qr-code-container canvas, .qr-code-container img {
  display: block; max-width: 100%; height: auto;
}

.qr-info {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 20px;
}
.qr-student-name {
  font-weight: 700; font-size: 1rem; color: #1e293b;
}
.qr-answer-count {
  font-size: 0.85rem; color: #64748b;
}

.qr-close-btn {
  width: 100%; justify-content: center;
}
