/* ═══════════════════════════════════════════════════════
   Kando – Design System
   Dark Premium Theme · iPad-optimiert
═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');


/* ── Design Tokens ── */
:root {
  /* Kando Homepage Tokens */
  --navy:        #06245C;
  --navy-light:  #0d3a8a;
  --teal:        #42B8AD;
  --teal-light:  #5DCFC4;
  --teal-bg:     #E8F8F7;
  --yellow:      #F4B24D;
  --yellow-bg:   #FEF5E7;
  --bg:          #F7FAFC;
  --white:       #FFFFFF;
  --text:        #102040;
  --text-sec:    #5B6B84;
  --border:      #E2EAF0;
  --navy-alpha:  rgba(6, 36, 92, 0.07);

  /* Colors */
  --bg-base:        var(--bg);
  --bg-surface:     var(--white);
  --bg-elevated:    #f2f8fc;
  --bg-hover:       #ecf4fb;
  --bg-border:      var(--border);

  --accent:         var(--navy);
  --accent-hover:   var(--navy-light);
  --accent-dim:     #e9f1ff;
  --accent-contrast: var(--navy);

  --green:          var(--teal);
  --green-dim:      var(--teal-bg);
  --red:            #d14343;
  --red-dim:        #fdeeee;
  --amber:          var(--yellow);
  --amber-dim:      var(--yellow-bg);

  --text-primary:   var(--text);
  --text-secondary: var(--text-sec);
  --text-tertiary:  #6f84a3;

  /* Typography */
  --font:           'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-xs:        11px;
  --text-sm:        13px;
  --text-base:      15px;
  --text-md:        17px;
  --text-lg:        20px;
  --text-xl:        24px;
  --text-2xl:       30px;
  --text-3xl:       38px;

  /* Spacing */
  --sp-xs:    4px;
  --sp-sm:    8px;
  --sp-md:    16px;
  --sp-lg:    24px;
  --sp-xl:    32px;
  --sp-2xl:   48px;

  /* Radius */
  --r-sm:   8px;
  --r-md:   16px;
  --r-lg:   24px;
  --r-xl:   32px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(6,36,92,0.07);
  --shadow-md: 0 8px 24px rgba(6,36,92,0.10);
  --shadow-lg: 0 16px 48px rgba(6,36,92,0.14);

  /* Transitions */
  --ease: cubic-bezier(.4,0,.2,1);
  --dur:  200ms;
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ── iOS: prevent zoom on input focus ──
   iOS Safari zooms in whenever a focused input has font-size < 16px.
   This rule guarantees the minimum threshold is always met.
   The viewport maximum-scale=1 in index.html is the primary guard;
   this CSS is a belt-and-suspenders fallback for edge cases.        */
input, textarea, select {
  font-size: max(16px, 1em);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── View System ── */
.view {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
}
.view.active {
  display: flex;
  flex-direction: column;
}

/* ── Page Layout ── */
.page-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.page-content {
  flex: 1;
  min-height: 0;                    /* ← Fix: iOS WebKit flex+overflow-y Bug */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--sp-md) var(--sp-lg);
}

.page-content.center-content {
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-content.form-page {
  padding: var(--sp-lg);
  padding-bottom: calc(var(--sp-lg) * 4);  /* genug Raum am unteren Ende */
  display: flex;
  flex-direction: column;
  gap: var(--sp-lg);
}

/* ── Top Bar ── */
.top-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-lg);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  min-height: 60px;
  flex-shrink: 0;
}

.top-bar-title {
  flex: 1;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.top-bar-actions {
  display: flex;
  gap: var(--sp-sm);
  align-items: center;
}

.btn-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  transition: background var(--dur) var(--ease);
}
.btn-back:hover { background: var(--bg-hover); }

.btn-icon {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  transition: background var(--dur) var(--ease);
}
.btn-icon:hover { background: var(--bg-hover); }

/* LRS toggle button (text only, clear active/inactive state) */
.lrs-btn {
  background: #4b5563;
  color: #e5e7eb;
  border: 1px solid #6b7280;
  border-radius: var(--r-md);
  min-width: 44px;
  height: 36px;
  padding: 0 10px;
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: .2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.lrs-btn:hover { background: #5b6573; }
.lrs-btn.lrs-active {
  background: var(--amber-dim);
  color: var(--amber);
  border-color: var(--amber);
}
.lrs-btn.lrs-active:hover { background: #3f3722; }

/* LE (Förderschwerpunkt Lernen) uses the turquoise sail color */
.lrs-btn.support-btn.lrs-active {
  background: #e6fbf8;
  color: #0f766e;
  border-color: #5eead4;
}
.lrs-btn.support-btn.lrs-active:hover { background: #d4f7f2; }

/* LRS badge on student cards */
.lrs-badge {
  display: inline-flex;
  align-items: center;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid var(--green);
  border-radius: var(--r-full);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  white-space: nowrap;
}


/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 12px 20px;
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(.97); }
.btn-primary.small { padding: 8px 16px; font-size: var(--text-sm); }
.btn-primary.large { padding: 16px 28px; font-size: var(--text-md); border-radius: var(--r-lg); }
.btn-primary.full { width: 100%; }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-md);
  padding: 12px 20px;
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-secondary.full { width: 100%; }
.btn-secondary.small { padding: 8px 14px; font-size: var(--text-sm); }

.btn-danger {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 12px 20px;
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--dur) var(--ease);
}
.btn-danger:hover { opacity: .85; }

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease);
}
.btn-text:hover { background: var(--accent-dim); }

/* ── Loading ── */
.loading-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--sp-xl);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-elevated);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App Logo ── */
.app-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}
.app-logo.large { flex-direction: column; gap: var(--sp-xs); }

.logo-icon {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: pulse 3s ease-in-out infinite;
}
.app-logo.large .logo-icon { width: 56px; height: 56px; }
.kando-mark { width: 100%; height: 100%; display: block; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

.logo-text {
  font-size: var(--text-md);
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -.5px;
}
.app-logo.large .logo-text { font-size: var(--text-2xl); }

/* ── Home Screen ── */
.home-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 20% 12%, rgba(11,46,115,.12) 0%, transparent 58%),
              radial-gradient(ellipse at 78% 78%, rgba(45,183,163,.14) 0%, transparent 52%),
              linear-gradient(180deg, #f9fcff 0%, #f2f8ff 100%);
  pointer-events: none;
}

.home-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: var(--sp-2xl);
  gap: var(--sp-2xl);
}

.home-header {
  text-align: center;
}

.home-subtitle {
  margin-top: var(--sp-sm);
  color: var(--text-secondary);
  font-size: var(--text-md);
}

.home-cards {
  display: flex;
  gap: var(--sp-lg);
  width: 100%;
  max-width: 700px;
}

.home-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-2xl) var(--sp-lg);
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-xl);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease),
              background var(--dur) var(--ease),
              transform var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}
.home-card:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.home-card:active { transform: scale(.97) translateY(0); }

.teacher-card:hover { border-color: var(--accent); }
.student-card:hover { border-color: var(--green); }

.card-icon { font-size: 56px; }
.card-title { font-size: var(--text-lg); font-weight: 700; }
.card-sub { font-size: var(--text-sm); color: var(--text-secondary); text-align: center; }

.home-footer {
  position: absolute;
  bottom: var(--sp-lg);
}

/* ── PIN Screen ── */
.modal-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: var(--sp-xl);
  background: var(--bg-base);
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-xl);
  padding: var(--sp-2xl);
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-lg);
  box-shadow: var(--shadow-lg);
}

.modal-icon { font-size: 48px; }

.modal-card h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  text-align: center;
}

.modal-card p {
  color: var(--text-secondary);
  text-align: center;
  font-size: var(--text-sm);
}

/* PIN Dots */
.pin-display {
  display: flex;
  gap: var(--sp-md);
  justify-content: center;
  min-height: 28px;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--bg-border);
  background: transparent;
  transition: all var(--dur) var(--ease);
}
.pin-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.1);
}

/* PIN Pad */
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  grid-template-rows: repeat(4, 64px);
  gap: var(--sp-sm);
}

.pin-key {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-lg);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur) var(--ease), transform 100ms;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pin-key:hover { background: var(--bg-hover); }
.pin-key:active { transform: scale(.93); background: var(--accent-dim); }
.pin-key.del { font-size: var(--text-md); color: var(--text-secondary); }
.pin-key.ok { background: var(--accent); color: #fff; font-size: var(--text-sm); font-weight: 700; }
.pin-key.ok:hover { background: var(--accent-hover); }

.pin-hint {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: center;
}
.pin-hint.error   { color: var(--red); }
.pin-hint.warning { color: var(--amber); font-weight: 600; }

/* ── PIN Lockout Panel ── */
.pin-lockout {
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  text-align: center;
  margin-top: var(--sp-sm);
  animation: fadeIn .3s var(--ease);
}
.pin-lockout-icon {
  font-size: 32px;
  margin-bottom: var(--sp-sm);
}
.pin-lockout-msg {
  color: var(--red);
  font-size: var(--text-base);
  font-weight: 700;
  margin: 0 0 var(--sp-sm);
}
.pin-lockout-countdown {
  color: var(--red);
  font-size: 42px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  margin: 0 0 var(--sp-sm);
  animation: pin-pulse 1s ease-in-out infinite;
}
.pin-lockout-sub {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin: 0;
}
@keyframes pin-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .55; }
}


/* ── Stats Row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-md);
  margin-bottom: var(--sp-xl);
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-xs);
  transition: border-color var(--dur) var(--ease);
}
.stat-card:hover { border-color: var(--accent); }

.stat-num {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ── Section Title ── */
.section-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-md);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-size: var(--text-xs);
}

/* ── Quick Grid ── */
.quick-actions {
  margin-bottom: var(--sp-xl);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-md);
}

.quick-btn {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  padding: var(--sp-lg) var(--sp-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease),
              background var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.quick-btn-icon {
  width: 28px;
  height: 28px;
  stroke: currentColor;
  flex-shrink: 0;
}
.quick-btn:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
  transform: translateY(-2px);
}

/* ── List Container ── */
.list-container {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.task-tag-multi-filter,
.task-bulk-edit {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  padding: var(--sp-md);
  margin-bottom: var(--sp-md);
}

.task-tag-multi-filter-head,
.task-bulk-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-sm);
}

.task-tag-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
}

.task-tag-chip {
  border: 1px solid var(--bg-border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: var(--r-full);
  padding: 5px 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.task-tag-chip.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent-contrast);
}

.task-bulk-edit-row {
  display: flex;
  gap: var(--sp-sm);
  align-items: center;
}
.task-bulk-edit-row .form-input {
  flex: 1;
}

.signature-preview {
  margin-top: 8px;
  max-width: 240px;
  max-height: 80px;
  object-fit: contain;
  border: 1px dashed var(--bg-border);
  border-radius: var(--r-sm);
  background: #fff;
  padding: 6px;
}

.task-row-select {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.empty-hint {
  color: var(--text-tertiary);
  text-align: center;
  padding: var(--sp-2xl) var(--sp-lg);
  font-size: var(--text-sm);
  line-height: 1.8;
}

/* Task / Test List Items */
.list-item {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  padding: var(--sp-md) var(--sp-lg);
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease),
              background var(--dur) var(--ease);
  min-height: 72px;
}
.list-item:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
}
.list-item:active { background: var(--bg-hover); }

.item-icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 40px;
  text-align: center;
}

.item-body {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: var(--text-base);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-sub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

.item-actions {
  display: flex;
  gap: var(--sp-sm);
  flex-shrink: 0;
}

.item-badge {
  background: var(--accent-dim);
  color: var(--accent-contrast);
  padding: 2px 10px;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 600;
  flex-shrink: 0;
}

.item-badge.green { background: var(--green-dim); color: var(--green); }
.item-badge.amber { background: var(--amber-dim); color: var(--amber); }
.item-badge.red { background: var(--red-dim); color: var(--red); }
.item-badge.blue { background: #172554; color: #93c5fd; }

.test-level-selector {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.test-level-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.test-level-btn:hover {
  background: var(--bg-hover);
}

.test-level-btn.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent-contrast);
}

/* Eindeutige Niveau-Codierung im Teacher-Test-Editor:
   aktiv = grün, inaktiv = grau */
#test-level-selector .test-level-btn {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #4b5563;
}

#test-level-selector .test-level-btn:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}

#test-level-selector .test-level-btn.active {
  background: #dcfce7;
  border-color: #16a34a;
  color: #166534;
}

.btn-item-delete {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--r-sm);
  transition: color var(--dur), background var(--dur);
}
.btn-item-delete:hover { color: var(--red); background: var(--red-dim); }

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-lg);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  overflow-x: auto;
  flex-shrink: 0;
}

.filter-chip {
  background: none;
  border: 1px solid var(--bg-border);
  border-radius: var(--r-full);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 6px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur) var(--ease);
}
.filter-chip.active, .filter-chip:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

/* ── Form Elements ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.form-input {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-base);
  padding: 12px 16px;
  width: 100%;
  outline: none;
  transition: border-color var(--dur) var(--ease);
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--accent); }
.form-input.large { font-size: var(--text-lg); padding: 16px; }
.form-input::placeholder { color: var(--text-tertiary); }

textarea.form-input { resize: vertical; min-height: 80px; }

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.form-select {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-sm);
  padding: 8px 12px;
  outline: none;
  cursor: pointer;
}

/* ── Tag Pills ── */
.tag-pill {
  display: inline-flex;
  align-items: center;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 10px;
  white-space: nowrap;
}

.tag-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
  min-height: 0;
  margin-top: var(--sp-xs);
}

.tag-input-row {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

/* Tag filter select in the filter bar */
.tag-filter-select {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-full);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 6px 14px;
  outline: none;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  -webkit-appearance: none;
  appearance: none;
  /* Arrow indicator */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b949e'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.tag-filter-select:focus,
.tag-filter-select.active {
  border-color: var(--accent);
  color: var(--accent-contrast);
  background-color: var(--accent-dim);
}

/* Type Selector */
.type-selector {
  display: flex;
  gap: var(--sp-sm);
  flex-wrap: wrap;
}

.type-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 10px 18px;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.type-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.direction-selector {
  display: flex;
  gap: var(--sp-sm);
}

.dir-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 10px 20px;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.dir-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

/* TF Selector */
.tf-selector {
  display: flex;
  gap: var(--sp-md);
}
.tf-btn {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: var(--text-md);
  font-weight: 600;
  padding: 18px;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.tf-btn[data-val="true"].active  { background: var(--green-dim); border-color: var(--green); color: var(--green); }
.tf-btn[data-val="false"].active { background: var(--red-dim);   border-color: var(--red);   color: var(--red); }

/* Points Row */
.points-row {
  display: flex;
  align-items: center;
  gap: var(--sp-lg);
}
.points-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: var(--text-xl);
  width: 52px;
  height: 52px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur) var(--ease);
}
.points-btn:hover { border-color: var(--accent); color: var(--accent); }
.points-val {
  font-size: var(--text-2xl);
  font-weight: 700;
  min-width: 48px;
  text-align: center;
}
.points-input {
  width: 92px;
  min-width: 92px;
  text-align: center;
  padding-left: 8px;
  padding-right: 8px;
  font-size: var(--text-xl);
  font-weight: 700;
}

.grade-scale-row {
  display: grid;
  grid-template-columns: 76px 1fr 1fr;
  gap: var(--sp-sm);
  align-items: center;
  margin-bottom: var(--sp-sm);
}

.grade-scale-note {
  font-weight: 700;
  color: var(--text-primary);
}

/* Preview Box */
.preview-box {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
}
.preview-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: var(--sp-md);
}
.task-preview-content {
  color: var(--text-primary);
  font-size: var(--text-base);
}

/* MC Options */
.mc-options { display: flex; flex-direction: column; gap: var(--sp-sm); }
.mc-option-row {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}
.mc-option-row input[type="radio"] {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.mc-option-row .form-input { flex: 1; }

/* ── Bulk Import ── */
.two-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-lg);
  overflow: hidden;
  padding: var(--sp-lg);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-header h3 { font-size: var(--text-md); font-weight: 600; }

.bulk-textarea {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-family: 'Menlo', 'Monaco', monospace;
  font-size: 14px;
  padding: var(--sp-md);
  outline: none;
  resize: none;
  transition: border-color var(--dur) var(--ease);
  min-height: 300px;
}
.bulk-textarea:focus { border-color: var(--accent); }

.bulk-format-hint {
  background: var(--amber-dim);
  border: 1px solid var(--amber);
  border-radius: var(--r-sm);
  padding: var(--sp-sm) var(--sp-md);
  font-size: var(--text-xs);
  color: var(--amber);
}

.right-panel .list-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.badge {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 4px 12px;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 700;
}

/* Preview Item in Bulk */
.preview-item {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-md);
  padding: var(--sp-md);
  margin-bottom: var(--sp-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.preview-item.error {
  border-color: var(--red);
  background: var(--red-dim);
}
.preview-item-type { font-size: var(--text-xs); color: var(--text-tertiary); text-transform: uppercase; }
.preview-item-q { font-size: var(--text-sm); font-weight: 600; }
.preview-item-a { font-size: var(--text-sm); color: var(--green); }

/* ── Task Picker (in Test Create) ── */
/* Toolbar above the task picker (label + select-all buttons) */
.picker-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-sm);
}

.picker-toolbar-actions {
  display: flex;
  gap: var(--sp-sm);
}

.task-picker {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  max-height: 300px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  padding: var(--sp-md);
}

/* Tag filter bar above the task picker */
.picker-tag-filter {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: var(--sp-sm);
  padding: 2px 0 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;          /* Firefox */
}
.picker-tag-filter::-webkit-scrollbar { display: none; } /* Safari/Chrome */
.picker-tag-filter:empty { display: none; }

/* Small tag badges shown inside each picker item */
.picker-tag-pill {
  display: inline-flex;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: var(--r-full);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  white-space: nowrap;
  vertical-align: middle;
  margin-left: 4px;
}

.picker-item {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
  min-height: 48px;
}
.picker-item:hover { background: var(--bg-hover); }
.picker-item input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.task-order-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  padding: var(--sp-md);
  min-height: 80px;
}

.order-item {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-md);
  cursor: grab;
  min-height: 52px;
}
.order-item.dragging { opacity: .5; cursor: grabbing; }

.drag-handle { color: var(--text-tertiary); font-size: 18px; cursor: grab; }

/* ── Distribute / Test detail ── */
.distribute-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-xl);
  padding: var(--sp-2xl);
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-lg);
  align-items: center;
}

.distribute-icon { font-size: 56px; }

.distribute-card h2 { font-size: var(--text-xl); font-weight: 700; text-align: center; }

.distribute-info {
  display: flex;
  gap: var(--sp-sm);
  align-items: center;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.guided-access-hint {
  background: var(--amber-dim);
  border: 1px solid var(--amber);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  width: 100%;
}
.guided-access-hint h3 { font-size: var(--text-sm); font-weight: 700; color: var(--amber); margin-bottom: var(--sp-sm); }
.guided-access-hint ol { padding-left: var(--sp-lg); color: var(--text-secondary); font-size: var(--text-sm); display: flex; flex-direction: column; gap: 4px; }

.divider-text {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  position: relative;
  width: 100%;
  text-align: center;
}
.divider-text::before, .divider-text::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--bg-border);
}
.divider-text::before { left: 0; }
.divider-text::after { right: 0; }

/* ── Results ── */
.results-filter-bar {
  padding: var(--sp-sm) var(--sp-lg);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.results-filters-row {
  display: flex;
  gap: var(--sp-sm);
}
.results-filters-row .form-select {
  flex: 1;
}

.results-action-row {
  display: flex;
  gap: var(--sp-sm);
  align-items: center;
}
.results-action-row .form-input {
  flex: 1;
  height: 38px;
  padding: 8px 12px;
  font-size: var(--text-sm);
}

.results-select-btns {
  display: flex;
  gap: var(--sp-xs);
  flex-shrink: 0;
}

/* Smart group selector: dropdown + optional new-group text input */
.group-selector {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  flex: 1;
  min-width: 0;
}
.group-selector .form-select {
  width: 100%;
}
.group-selector .form-input {
  width: 100%;
  height: 38px;
  padding: 8px 12px;
  font-size: var(--text-sm);
}
.group-selector .form-input.hidden {
  display: none;
}

.group-selector-inline {
  min-width: 260px;
  max-width: 340px;
}
.group-selector-inline .form-select,
.group-selector-inline .form-input {
  height: 36px;
  font-size: var(--text-sm);
}

.results-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-md);
  margin-bottom: var(--sp-lg);
}

.summary-stat {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  text-align: center;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--accent);
}

/* Score circle */
.detail-score-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-xl) 0;
}

.detail-group-row {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  width: 100%;
  max-width: 400px;
}
.detail-group-row .form-input {
  flex: 1;
  height: 40px;
  font-size: var(--text-sm);
  padding: 8px 12px;
}

/* Group section headers in the results list */
.results-group-header {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--sp-md) var(--sp-sm) var(--sp-xs);
  border-bottom: 1px solid var(--bg-border);
  margin-bottom: var(--sp-xs);
}
.results-group-header:not(:first-child) {
  margin-top: var(--sp-lg);
}
.results-group-ungrouped {
  color: var(--text-tertiary);
  font-style: italic;
}

/* ── View-mode toggle (Tests | Schüler) ── */
.view-mode-toggle {
  display: flex;
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  flex-shrink: 0;
}
.view-mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
}
.view-mode-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── Student Cards (Schüler-Ansicht) ── */
.student-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-xl);
  padding: var(--sp-lg);
  margin-bottom: var(--sp-md);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  box-shadow: var(--shadow-sm);
}

.student-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-md);
}
.student-card-identity {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  flex: 1;
  min-width: 0;
}
.student-avatar { font-size: 28px; flex-shrink: 0; }
.student-card-name {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
}
.student-nr {
  font-weight: 400;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}
.student-card-meta {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  flex-wrap: wrap;
}
.student-card-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  flex-shrink: 0;
}

/* Trend badge */
.student-trend {
  font-size: var(--text-sm);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--r-full);
}
.student-trend.trend-up     { background: var(--green-dim); color: var(--green); }
.student-trend.trend-down   { background: var(--red-dim);   color: var(--red); }
.student-trend.trend-stable { background: var(--bg-elevated); color: var(--text-secondary); }

/* Progress dots row */
.student-progress-dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.progress-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: default;
}
.progress-dot.green { background: var(--green); }
.progress-dot.amber { background: var(--amber); }
.progress-dot.red   { background: var(--red); }

/* Individual test rows inside student card */
.student-test-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.student-test-row {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-xs) 0;
  cursor: pointer;
  border-radius: var(--r-md);
  transition: background var(--dur) var(--ease);
}
.student-test-row:hover { background: var(--bg-elevated); padding-left: var(--sp-sm); }
.student-test-date  { font-size: 12px; color: var(--text-tertiary); white-space: nowrap; }
.student-test-name  { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.student-progress-bar-wrapper {
  width: 80px;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--r-full);
  overflow: hidden;
  flex-shrink: 0;
}
.student-progress-bar {
  height: 100%;
  border-radius: var(--r-full);
  transition: width .3s var(--ease);
}
.student-progress-bar.green { background: var(--green); }
.student-progress-bar.amber { background: var(--amber); }
.student-progress-bar.red   { background: var(--red); }
.student-test-score {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  text-align: right;
}

.score-chip,
.grade-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
}

.score-chip.green, .grade-chip.green { background: var(--green-dim); color: var(--green); }
.score-chip.amber, .grade-chip.amber { background: var(--amber-dim); color: var(--amber); }
.score-chip.red,   .grade-chip.red   { background: var(--red-dim);   color: var(--red); }
.grade-chip.fsl {
  background: #e6fbf8;
  color: #0f766e;
  border: 1px solid #5eead4;
}


/* Checkbox inside a result row */
.result-row-cb {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--bg-border);
  border-radius: 6px;
  background: var(--bg-elevated);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--dur) var(--ease);
  position: relative;
}
.result-row-cb:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.result-row-cb:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -52%);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.score-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 6px solid var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.score-pct { font-size: var(--text-2xl); font-weight: 800; }
.score-pts { font-size: var(--text-sm); color: var(--text-secondary); }

/* Answer row in detail */
.answer-row {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  padding: var(--sp-md) var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.answer-row.correct { border-color: var(--green); }
.answer-row.partial { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 6%, var(--bg-surface)); }
.answer-row.wrong   { border-color: var(--red); }
.answer-row.manual  { border-color: var(--accent); }

.answer-q { font-size: var(--text-sm); font-weight: 600; }
.answer-given { font-size: var(--text-sm); color: var(--text-secondary); }
.answer-given .given-val { font-weight: 600; }
.given-val.correct { color: var(--green); }
.given-val.partial { color: var(--amber); }
.given-val.wrong   { color: var(--red); }

.answer-row-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.pts-adjuster {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}
.pts-adjuster button {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-size: 16px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pts-adjuster span { font-weight: 700; min-width: 24px; text-align: center; }

/* ── Export ── */
.export-options {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  width: 100%;
  max-width: 400px;
}

.export-panel {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}

.export-context-info {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid var(--bg-border);
  background: var(--bg-surface);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-align: center;
}

.export-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-xl);
  padding: var(--sp-xl);
  display: flex;
  align-items: center;
  gap: var(--sp-lg);
  cursor: pointer;
  font-family: var(--font);
  color: var(--text-primary);
  transition: border-color var(--dur) var(--ease),
              background var(--dur) var(--ease);
}
.export-card:hover { border-color: var(--accent); background: var(--bg-elevated); }
.export-card.danger:hover { border-color: var(--red); }

.export-icon { font-size: 36px; }
.export-title { font-size: var(--text-md); font-weight: 700; }
.export-sub { font-size: var(--text-sm); color: var(--text-secondary); }

/* ── Settings ── */
.settings-section {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.settings-heading {
  padding: var(--sp-sm) var(--sp-lg);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-primary);
  background: var(--bg-base);
  border-bottom: 1px solid var(--bg-border);
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: var(--sp-md) var(--sp-lg);
  background: none;
  border: none;
  border-bottom: 1px solid var(--bg-border);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-base);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
  min-height: 56px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row:hover { background: var(--bg-hover); }
.settings-row.danger { color: var(--red); }

/* Settings page: robust text layout + always scrollable content */
#view-settings .page-layout {
  min-height: 0;
}
#view-settings .page-content {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(var(--sp-2xl) + env(safe-area-inset-bottom));
}
.settings-section {
  overflow: visible;
}
.settings-row {
  align-items: flex-start;
  text-align: left;
  gap: var(--sp-md);
}
.settings-row > span:first-child {
  flex: 1;
  min-width: 0;
  white-space: normal;
  line-height: 1.4;
}
.settings-row > span:last-child {
  flex-shrink: 0;
  align-self: center;
}

/* LRS toggle row (non-button row within a settings-section) */
.settings-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-md) var(--sp-lg);
  gap: var(--sp-lg);
  min-height: 64px;
}
.settings-toggle-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.settings-toggle-label {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}
.settings-toggle-sub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

/* iOS-style toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 25px;
  height: 25px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,.4);
  transition: transform var(--dur) var(--ease);
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--green);
  border-color: var(--green);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.privacy-text {
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}
.privacy-text p { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.7; }

/* ── Student / Exam Screens ── */
.exam-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: var(--sp-xl);
  background: var(--bg-base);
}

.exam-welcome-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-xl);
  padding: var(--sp-2xl);
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-lg);
  box-shadow: var(--shadow-lg);
}

.exam-logo {
  text-align: center;
  font-size: var(--text-md);
  font-weight: 800;
  color: var(--accent);
}

.exam-welcome-card h2 {
  font-size: var(--text-2xl);
  font-weight: 800;
  text-align: center;
}

.exam-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.ready-card .ready-icon { font-size: 64px; text-align: center; }
.done-card .done-icon   { font-size: 64px; text-align: center; }

.done-hint {
  font-size: var(--text-sm);
  color: var(--green);
  text-align: center;
}

.student-no-file {
  background: var(--amber-dim);
  border: 1px solid var(--amber);
  border-radius: var(--r-md);
  padding: var(--sp-md);
  font-size: var(--text-sm);
  color: var(--amber);
  text-align: center;
}

/* ── Exam Mode ── */
.exam-mode {
  background: var(--bg-base);
}

.exam-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  /* Prevent students from selecting/copying question text */
  -webkit-user-select: none;
  user-select: none;
}

/* Re-enable for answer input fields */
.exam-layout input,
.exam-layout textarea {
  -webkit-user-select: text;
  user-select: text;
}

.exam-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-md) var(--sp-lg);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  flex-shrink: 0;
}

.exam-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  max-width: 300px;
}
.progress-track {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: width .3s var(--ease);
}

.exam-timer {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  padding: var(--sp-sm) var(--sp-md);
}
.exam-timer.warning { border-color: var(--amber); color: var(--amber); }
.exam-timer.danger  { border-color: var(--red);   color: var(--red); animation: blink 1s step-start infinite; }

@keyframes blink { 50% { opacity: .5; } }

#timer-display { font-size: var(--text-lg); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Exam Question Area */
.exam-question-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-2xl);
  overflow-y: auto;
}

.question-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-xl);
  padding: var(--sp-2xl);
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-xl);
  box-shadow: var(--shadow-md);
}

.question-type-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
}

.question-text {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

/* Vocab answer input */
.vocab-answer-input {
  font-size: var(--text-xl);
  padding: 18px 20px;
  border-radius: var(--r-lg);
  text-align: center;
}

/* MC options in exam */
.mc-exam-options {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.mc-exam-btn {
  background: var(--bg-elevated);
  border: 2px solid var(--bg-border);
  border-radius: var(--r-lg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-md);
  font-weight: 500;
  padding: 18px 24px;
  text-align: left;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  min-height: 64px;
}
.mc-exam-btn:hover { border-color: var(--accent); background: var(--accent-dim); }
.mc-exam-btn.selected { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

.mc-option-letter {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  flex-shrink: 0;
}

/* TF buttons in exam */
.tf-exam-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-md);
}

.tf-exam-btn {
  background: var(--bg-elevated);
  border: 2px solid var(--bg-border);
  border-radius: var(--r-xl);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-xl);
  font-weight: 700;
  padding: var(--sp-2xl);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
}
.tf-exam-btn.selected[data-val="true"]  { border-color: var(--green); background: var(--green-dim); color: var(--green); }
.tf-exam-btn.selected[data-val="false"] { border-color: var(--red);   background: var(--red-dim);   color: var(--red); }
.tf-exam-btn:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* Exam Nav – sits at the bottom of the flex container */
.exam-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-lg) var(--sp-xl);
  background: var(--bg-surface);
  border-top: 1px solid var(--bg-border);
  z-index: 200;
  /* Safe area: accounts for iPhone home bar */
  padding-bottom: max(var(--sp-lg), env(safe-area-inset-bottom));
  transition: transform 140ms ease-out;
}

.btn-exam-nav {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-md);
  font-weight: 600;
  padding: 14px 28px;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  min-width: 120px;
  min-height: 52px;
}
.btn-exam-nav:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-exam-nav:disabled { opacity: .3; cursor: not-allowed; }

.btn-exam-submit {
  background: var(--green);
  border: none;
  border-radius: var(--r-lg);
  color: #fff;
  font-family: var(--font);
  font-size: var(--text-md);
  font-weight: 700;
  padding: 14px 36px;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  min-height: 52px;
}
.btn-exam-submit:hover { opacity: .85; transform: translateY(-2px); }

/* ── Overlay ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.overlay.hidden { display: none; }

.overlay-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-xl);
  padding: var(--sp-2xl);
  max-width: 400px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-lg);
  box-shadow: var(--shadow-lg);
  animation: pop .2s var(--ease);
}

@keyframes pop {
  from { transform: scale(.9); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

.overlay-card h3 { font-size: var(--text-lg); font-weight: 700; }
.overlay-card p  { font-size: var(--text-sm); color: var(--text-secondary); }

.overlay-actions {
  display: flex;
  gap: var(--sp-md);
  justify-content: flex-end;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 32px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  color: var(--text-primary);
  padding: var(--sp-md) var(--sp-xl);
  border-radius: var(--r-full);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  white-space: nowrap;
  animation: toast-in .25s var(--ease);
  max-width: 90vw;
}
.toast.hidden { display: none; }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); }

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

/* ── Utilities ── */
.hidden { display: none !important; }
.dot { color: var(--text-tertiary); }
.version-tag { font-size: var(--text-xs); color: var(--text-tertiary); }
.version-tag.center { text-align: center; padding: var(--sp-lg); display: block; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 2px; }

/* ── Safe Area ── */
.page-layout { padding-bottom: env(safe-area-inset-bottom); }
.top-bar { padding-top: max(var(--sp-md), env(safe-area-inset-top)); }
.exam-nav { padding-bottom: max(var(--sp-lg), env(safe-area-inset-bottom)); }


/* ═══════════════════════════════════════════════════════
   GEFÜHRTER ZUGRIFF – Guided Access UI
═══════════════════════════════════════════════════════ */

/* Badge in der Exam-Top-Bar */
.exam-mode-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--green-dim);
  border: 1px solid var(--green);
  border-radius: var(--r-full);
  padding: 5px 12px;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
  transition: all var(--dur) var(--ease);
  animation: badge-pop .25s var(--ease);
}

@keyframes badge-pop {
  from { transform: scale(.8); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

/* Wird aktiviert… (grau, pulsierend) */
.exam-mode-badge.activating {
  background: var(--bg-elevated);
  border-color: var(--text-tertiary);
  color: var(--text-secondary);
  animation: none;
}
.exam-mode-badge.activating .exam-mode-icon {
  animation: pulse 1.2s ease-in-out infinite;
}

/* Fehlgeschlagen (amber) */
.exam-mode-badge.failed {
  background: var(--amber-dim);
  border-color: var(--amber);
  color: var(--amber);
}

/* Fallback-Banner unterhalb der Exam-Top-Bar */
.exam-mode-fallback {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
  background: var(--amber-dim);
  border-bottom: 1px solid var(--amber);
  color: var(--amber);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: var(--sp-sm) var(--sp-lg);
  flex-shrink: 0;
}
.exam-mode-fallback button {
  background: none;
  border: none;
  color: var(--amber);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  transition: background var(--dur) var(--ease);
}
.exam-mode-fallback button:hover { background: rgba(210,153,34,.2); }

/* Hinweis auf dem Bereit-Screen */
.exam-mode-ready-hint {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  background: var(--green-dim);
  border: 1px solid var(--green);
  border-radius: var(--r-md);
  padding: var(--sp-sm) var(--sp-md);
  font-size: var(--text-xs);
  color: var(--green);
  font-weight: 500;
  line-height: 1.5;
  text-align: left;
}



/* ═══════════════════════════════════════════════════════
   RESPONSIVE – iPad-Mini / small tablets  (≤ 768 px)
═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Quick grid: 2 × 2 statt 4 × 1 */
  .quick-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Bulk-Import: Panels untereinander statt nebeneinander */
  .two-panel {
    grid-template-columns: 1fr;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Rechtes Panel (Vorschau) scrollt normal mit */
  .right-panel .list-container {
    overflow-y: visible;
    max-height: none;
  }

  /* Exam-Karte: volle Breite */
  .question-card {
    max-width: 100%;
  }
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE – iPhone  (≤ 480 px)
═══════════════════════════════════════════════════════ */
@media (max-width: 480px) {

  /* ── Home Screen ── */
  .home-content {
    padding: var(--sp-xl) var(--sp-md);
    gap: var(--sp-lg);
  }

  /* Karten untereinander */
  .home-cards {
    flex-direction: column;
    gap: var(--sp-md);
    max-width: 100%;
  }

  .home-card {
    flex-direction: row;
    justify-content: flex-start;
    padding: var(--sp-lg) var(--sp-md);
    gap: var(--sp-md);
    text-align: left;
  }

  .card-icon { font-size: 36px; }
  .card-title { font-size: var(--text-base); }
  .card-sub   { font-size: var(--text-xs); }

  /* ── Top Bar ── */
  .top-bar {
    padding-left: var(--sp-md);
    padding-right: var(--sp-md);
    min-height: 52px;
  }

  .top-bar-title { font-size: var(--text-base); }

  /* Kleine Buttons im Top-Bar enger */
  .btn-primary.small,
  .btn-secondary.small {
    padding: 7px 10px;
    font-size: 12px;
  }

  /* ── Page Content ── */
  .page-content {
    padding: var(--sp-md) var(--sp-md);
  }

  .page-content.form-page {
    padding: var(--sp-md);
    padding-bottom: calc(var(--sp-md) * 5);
    gap: var(--sp-md);
  }

  /* ── Stats ── */
  .stat-card {
    padding: var(--sp-md) var(--sp-sm);
  }

  .stat-num  { font-size: var(--text-2xl); }
  .stat-label { font-size: 11px; }

  /* ── Filter Bar ── */
  .filter-bar {
    padding: var(--sp-xs) var(--sp-md);
  }

  /* ── Bulk Import ── */
  .two-panel {
    padding: var(--sp-md);
    gap: var(--sp-md);
  }

  .bulk-textarea {
    min-height: 180px;
  }

  /* ── Exam ── */
  .exam-question-area {
    padding: var(--sp-lg) var(--sp-md);
    justify-content: flex-start;
    padding-top: var(--sp-xl);
  }

  .question-card {
    padding: var(--sp-lg);
    gap: var(--sp-md);
    border-radius: var(--r-lg);
  }

  .question-text {
    font-size: var(--text-xl);
  }

  /* Nav-Buttons kleiner */
  .exam-nav {
    padding: var(--sp-sm) var(--sp-md);
    padding-bottom: max(var(--sp-md), env(safe-area-inset-bottom));
  }

  .btn-exam-nav {
    min-width: 80px;
    padding: 11px 14px;
    font-size: var(--text-base);
  }

  .btn-exam-submit {
    padding: 11px 20px;
    font-size: var(--text-base);
  }

  /* TF-Buttons */
  .tf-exam-options { gap: var(--sp-sm); }
  .tf-exam-btn {
    padding: var(--sp-lg) var(--sp-md);
    font-size: var(--text-lg);
  }

  /* ── PIN Pad ── */
  .pin-pad {
    grid-template-columns: repeat(3, 64px);
    grid-template-rows: repeat(4, 58px);
  }

  /* ── Distribute / Exam-Welcome ── */
  .distribute-card,
  .exam-welcome-card {
    padding: var(--sp-xl) var(--sp-lg);
  }

  .exam-welcome-card h2 {
    font-size: var(--text-xl);
  }

  /* ── Modal (PIN) ── */
  .modal-card {
    padding: var(--sp-xl) var(--sp-lg);
  }

  /* ── List items ── */
  .list-item {
    padding: var(--sp-md);
    min-height: 64px;
  }

  /* ── Results top-bar: two buttons side by side ── */
  .results-filter-bar {
    padding: var(--sp-xs) var(--sp-md);
  }
}


/* ═══════════════════════════════════════════════════════
   REDESIGN – Sidebar + Light Teacher Theme + Warm Student
═══════════════════════════════════════════════════════ */

:root { --sidebar-w: 220px; }

.teacher-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0b2e73 0%, #0a255b 100%);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
}
.teacher-sidebar.hidden { display: none; }
.sidebar-logo {
  display: flex; align-items: center; justify-content: center;
  padding: 28px 20px 22px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo-icon {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sidebar-nav {
  flex: 1; display: flex; flex-direction: column;
  gap: 2px; padding: 14px 10px; overflow-y: auto;
}
.sidebar-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; border-radius: 10px; border: none;
  background: none; color: #c4d5ef;
  font-family: var(--font); font-size: 14px; font-weight: 500;
  cursor: pointer; text-align: left; width: 100%;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sidebar-item:hover  { background: rgba(255,255,255,.09); color: #ffffff; }
.sidebar-item.active { background: rgba(95,210,194,.2);  color: #8be9dc; }
.sidebar-icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-divider { height: 1px; background: rgba(255,255,255,.07); margin: 6px 0; }
.sidebar-footer { padding: 14px 10px; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-logout {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 13px; border: none; border-radius: 10px;
  background: none; color: #b8c8e2;
  font-family: var(--font); font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background var(--dur), color var(--dur);
}
.sidebar-logout:hover { background: rgba(255,255,255,.1); color: #ffffff; }

.teacher-view { left: var(--sidebar-w) !important; }

.teacher-view .page-layout { background: #f1f5f9; }
.teacher-view .page-content { background: #f1f5f9; }
.teacher-view .filter-bar { background: #f1f5f9; border-bottom: 1px solid #e2e8f0; }
.teacher-view .top-bar { background: #ffffff; border-bottom: 1px solid #e2e8f0; }
.teacher-view .top-bar-title { color: #0f172a; }
.teacher-view .btn-back  { color: #0b2e73; }
.teacher-view .btn-icon  { color: #475569; }
.teacher-view .btn-icon:hover { background: #f1f5f9; }

.teacher-view .stat-card {
  background: #ffffff; border: none; border-top: 3px solid #94a3b8;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
}
.teacher-view .stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); transform: translateY(-2px); border-color: inherit; }
.teacher-view #stat-tasks   { border-top-color: #0b2e73; }
.teacher-view #stat-tasks   .stat-num { color: #0b2e73; }
.teacher-view #stat-tests   { border-top-color: #2db7a3; }
.teacher-view #stat-tests   .stat-num { color: #2db7a3; }
.teacher-view #stat-results { border-top-color: #e6aa43; }
.teacher-view #stat-results .stat-num { color: #e6aa43; }
.teacher-view .stat-label { color: #64748b; }

.teacher-view .section-title { color: #1e293b; font-size: 13px; }
.teacher-view .quick-btn {
  background: #ffffff; border: none;
  box-shadow: 0 1px 5px rgba(0,0,0,.08); color: #0f172a;
}
.teacher-view .quick-btn:hover {
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
  background: #ffffff; border-color: transparent; transform: translateY(-3px);
}

.teacher-view .list-item {
  background: #ffffff; border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); color: #0f172a;
}
.teacher-view .list-item:hover { background: #f8fafc; box-shadow: 0 4px 14px rgba(0,0,0,.1); border-color: transparent; }
.teacher-view .item-title { color: #0f172a; }
.teacher-view .item-sub   { color: #64748b; }
.teacher-view .empty-hint { color: #94a3b8; }

.teacher-view .form-input { background: #ffffff; border: 1px solid #e2e8f0; color: #0f172a; }
.teacher-view .form-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.12); outline: none; }
.teacher-view .form-label { color: #374151; }
.teacher-view .form-hint  { color: #94a3b8; }

.teacher-view .filter-chip { background: #ffffff; border: 1px solid #e2e8f0; color: #64748b; }
.teacher-view .filter-chip.active { background: #2563eb; border-color: #2563eb; color: #ffffff; }
.teacher-view .filter-chip:hover:not(.active) { background: #f1f5f9; border-color: #cbd5e1; }
.teacher-view .tag-filter-select { background: #ffffff; border: 1px solid #e2e8f0; color: #374151; }

.teacher-view .answer-row { background: #ffffff; border: none; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.teacher-view .answer-row.correct { border-left: 3px solid #22c55e; }
.teacher-view .answer-row.wrong   { border-left: 3px solid #ef4444; }
.teacher-view .answer-row.partial { border-left: 3px solid #f97316; }
.teacher-view .answer-row.manual  { border-left: 3px solid #8b5cf6; }
.teacher-view .score-summary { background: #ffffff; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.teacher-view .results-group-header { color: #1e293b; background: transparent; }
.teacher-view .student-card { background: #ffffff; border: none; box-shadow: 0 1px 5px rgba(0,0,0,.08); }
.teacher-view .student-card-name { color: #0f172a; }
.teacher-view .student-card-meta { color: #64748b; }
.teacher-view .student-test-row  { background: #f8fafc; border-color: #e2e8f0; }
.teacher-view .student-test-name { color: #0f172a; }
.teacher-view .student-test-date  { color: #475569; }
.teacher-view .student-test-score { color: #334155; }
.teacher-view .settings-row { background: #ffffff; border: none; box-shadow: 0 1px 4px rgba(0,0,0,.06); color: #0f172a; }
.teacher-view .settings-heading { color: #f8fafc; }
.teacher-view .settings-toggle-label { color: #0f172a; }
.teacher-view .settings-toggle-sub   { color: #64748b; }
.teacher-view .picker-item { background: #ffffff; border-color: #e2e8f0; color: #0f172a; }
.teacher-view .picker-item:hover    { background: #eff6ff; border-color: #93c5fd; }
.teacher-view .picker-item.selected { background: #eff6ff; border-color: #3b82f6; }

.exam-page {
  background: linear-gradient(145deg, #f0f9ff 0%, #faf5ff 50%, #fff7ed 100%);
  display: flex; align-items: center; justify-content: center;
  min-height: 100%; padding: var(--sp-xl);
}
.exam-welcome-card {
  background: #ffffff; border: none; border-radius: var(--r-xl);
  box-shadow: 0 8px 32px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.06);
  padding: var(--sp-2xl) var(--sp-xl); width: 100%; max-width: 500px;
}
.exam-logo { color: #3b82f6; font-weight: 800; font-size: 16px; margin-bottom: var(--sp-sm); }
.exam-welcome-card h2 { color: #0f172a; }
.exam-welcome-card p  { color: #64748b; }
.exam-meta { color: #64748b; }
.exam-welcome-card .form-label { color: #374151; }
.exam-welcome-card .form-input { background: #f8fafc; border: 1.5px solid #e2e8f0; color: #0f172a; }
.exam-welcome-card .form-input:focus { border-color: #3b82f6; background: #ffffff; box-shadow: 0 0 0 3px rgba(59,130,246,.12); outline: none; }
.exam-welcome-card .btn-primary { background: linear-gradient(135deg, #3b82f6, #2563eb); font-size: 17px; box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.exam-welcome-card .btn-primary:hover { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.exam-welcome-card .btn-text { color: #64748b; }
.ready-icon, .done-icon { font-size: 64px; text-align: center; }
.done-hint { color: #64748b; }

.exam-layout { background: #f8fafc; }
.exam-top-bar { background: #ffffff; border-bottom: 1px solid #e2e8f0; }
.exam-timer { color: #0f172a; }
.progress-track { background: #e2e8f0; }
.exam-nav { background: #ffffff; border-top: 1px solid #e2e8f0; }
.btn-exam-nav { background: #f1f5f9; border: 1px solid #e2e8f0; color: #374151; border-radius: var(--r-md); }
.btn-exam-nav:hover:not(:disabled) { background: #e2e8f0; }
.btn-exam-nav:disabled { opacity: .35; }
.btn-exam-submit { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #ffffff; border: none; border-radius: var(--r-md); font-weight: 700; box-shadow: 0 2px 8px rgba(37,99,235,.3); }
.btn-exam-submit:hover { background: linear-gradient(135deg, #60a5fa, #3b82f6); }

.exam-nav .btn-exam-nav.is-primary,
.exam-nav .btn-exam-submit.is-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: none;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
.exam-nav .btn-exam-nav.is-primary:hover:not(:disabled),
.exam-nav .btn-exam-submit.is-primary:hover {
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  color: #ffffff;
}
.exam-nav .btn-exam-nav.is-secondary,
.exam-nav .btn-exam-submit.is-secondary {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #374151;
  box-shadow: none;
}
.exam-nav .btn-exam-submit.is-secondary:hover {
  background: #e2e8f0;
  transform: none;
}

.question-card { background: #ffffff; border: none; box-shadow: 0 2px 12px rgba(0,0,0,.08); border-radius: var(--r-xl); }
.question-text  { color: #0f172a; }
.exam-input { background: #ffffff; border: 1.5px solid #e2e8f0; color: #0f172a; border-radius: var(--r-md); }
.exam-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.12); outline: none; }
.mc-option { background: #ffffff; border: 1.5px solid #e2e8f0; color: #0f172a; border-radius: var(--r-md); }
.mc-option:hover    { background: #eff6ff; border-color: #93c5fd; }
.mc-option.selected { background: #eff6ff; border-color: #3b82f6; color: #1d4ed8; }
.mc-option.correct  { background: #f0fdf4; border-color: #22c55e; color: #166534; }
.mc-option.wrong    { background: #fef2f2; border-color: #ef4444; color: #991b1b; }

/* Level-based student test theme (very pale for readability) */
body.test-theme-sail .exam-page {
  background: linear-gradient(145deg, #effcfb 0%, #f3fffd 100%);
}
body.test-theme-regular .exam-page {
  background: linear-gradient(145deg, #f4fcf6 0%, #f7fff9 100%);
}
body.test-theme-regular-lrs .exam-page {
  background: linear-gradient(145deg, #fffdf0 0%, #fffef6 100%);
}

body.test-theme-sail .exam-layout { background: #f4fffe; }
body.test-theme-regular .exam-layout { background: #f7fff8; }
body.test-theme-regular-lrs .exam-layout { background: #fffef6; }

.teacher-card { background: linear-gradient(145deg, rgba(30,41,59,.9), rgba(15,23,42,.95)); border-color: rgba(59,130,246,.3); }
.teacher-card:hover { border-color: #3b82f6; box-shadow: 0 12px 40px rgba(37,99,235,.25); }
.student-card { background: linear-gradient(145deg, rgba(20,83,45,.6), rgba(5,46,22,.8)); border-color: rgba(34,197,94,.3); }
.student-card:hover { border-color: #22c55e; box-shadow: 0 12px 40px rgba(22,163,74,.25); }

/* ═══════════════════════════════════════════════════════
   SERVER-MODUS – Session Panel (Lehrer: Test verteilen)
═══════════════════════════════════════════════════════ */

.session-panel {
  background: var(--bg-surface);
  border: 1px solid var(--accent);
  border-radius: var(--r-xl);
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  margin-bottom: var(--sp-md);
  animation: fadeIn .3s var(--ease);
}

/* Der große Session-Code */
.session-code-display {
  text-align: center;
  padding: var(--sp-md) 0 var(--sp-sm);
}
.session-code-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: var(--sp-sm);
}
.session-code {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: 8px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 20px rgba(88,166,255,.4);
  line-height: 1;
  margin: var(--sp-sm) 0;
}
.session-code-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* Live-Statistiken (X abgegeben / Y Aufgaben / Z bis Ablauf) */
.session-live-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-sm);
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  padding: var(--sp-md);
}
.session-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.session-stat-num {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.session-stat-num.pulse {
  animation: session-pulse .6s var(--ease);
}
@keyframes session-pulse {
  0%   { transform: scale(1.3); color: var(--green); }
  100% { transform: scale(1);   color: var(--accent); }
}
.session-stat-time { color: var(--amber); }
.session-stat-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* Danger-Button (Session beenden) */
.btn-danger.full { width: 100%; display: flex; align-items: center; justify-content: center; }

/* ═══════════════════════════════════════════════════════
   SERVER-MODUS – Code-Eingabe (Schüler)
═══════════════════════════════════════════════════════ */

.student-code-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
  animation: fadeIn .2s var(--ease);
}
.student-code-panel h2 {
  font-size: var(--text-xl);
  font-weight: 700;
}
.exam-meta-hint {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: center;
}

/* Code-Eingabe Zeile: großes Input + Button nebeneinander */
.code-input-row {
  display: flex;
  gap: var(--sp-sm);
  width: 100%;
  max-width: 320px;
}
.code-input {
  flex: 1;
  font-size: var(--text-xl) !important;
  font-weight: 800;
  letter-spacing: 4px;
  text-align: center;
  text-transform: uppercase;
}
.student-mode-switch {
  margin-top: var(--sp-xs);
}

/* ═══════════════════════════════════════════════════════
   SERVER-EINSTELLUNGEN – Toggle Switch + Indent
═══════════════════════════════════════════════════════ */

.settings-row.no-arrow {
  cursor: default;
  align-items: center;
  gap: var(--sp-md);
}
.settings-row.no-arrow:hover {
  background: transparent;
}

/* Server-Toggle Zeile */
.server-toggle-label {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  flex: 1;
  cursor: pointer;
  /* Macht die gesamte linke Seite klickbar */
}
.server-toggle-icon { font-size: 20px; }
.server-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.server-toggle-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}
.server-toggle-sub {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* Teacher-View Override */
.teacher-view .server-toggle-title { color: #0f172a; }
.teacher-view .server-toggle-sub   { color: #64748b; }

/* Toggle Switch selbst */
.toggle-switch {
  position: relative;           /* ← nötig damit position:absolute input darin bleibt */
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  /* Explizit klickbar machen (iOS WKWebView) */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-track {
  width: 48px;
  height: 28px;
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-full);
  position: relative;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.toggle-switch input:checked + .toggle-track {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(20px);
  background: var(--accent);
}

/* Full-width Button Modifier (generisch) */
.btn-secondary.full,
.btn-primary.full  { width: 100%; text-align: center; }

/* Veralteter settings-indent – nicht mehr genutzt, aber für Kompatibilität */
.settings-indent {
  display: none;
}

/* ═══════════════════════════════════════════════════════
   DISTRIBUTE – Methoden-Auswahl
═══════════════════════════════════════════════════════ */

.distribute-methods {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  width: 100%;
}

.distribute-method-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--r-lg);
  padding: var(--sp-md) var(--sp-lg);
  cursor: pointer;
  font-family: var(--font);
  color: var(--text-primary);
  text-align: left;
  transition: border-color var(--dur) var(--ease),
              background   var(--dur) var(--ease),
              transform    100ms;
}
.distribute-method-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateX(2px);
}
.distribute-method-btn:active { transform: scale(.98); }

/* Server-Button mit blauem Akzent */
.distribute-method-btn.server {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.distribute-method-btn.server:hover {
  background: rgba(88,166,255,.18);
}

/* Unkonfigurierter Server-Button (gedimmt) */
.distribute-method-btn.unconfigured {
  opacity: 0.55;
  border-style: dashed;
  border-color: var(--text-tertiary);
  background: transparent;
}
.distribute-method-btn.unconfigured:hover {
  opacity: 0.75;
  background: var(--bg-elevated);
  border-color: var(--amber);
}

.distribute-method-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

.distribute-method-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.distribute-method-title {
  font-size: var(--text-base);
  font-weight: 600;
}

.distribute-method-sub {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.distribute-method-arrow {
  font-size: 20px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* Server-Hinweis wenn nicht konfiguriert */
.distribute-server-hint {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  background: var(--amber-dim);
  border: 1px solid var(--amber);
  border-radius: var(--r-md);
  padding: var(--sp-sm) var(--sp-md);
  font-size: var(--text-sm);
  color: var(--amber);
}

/* Inline-Text-Button (in Hinweistexten) */
.btn-text-inline {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font);
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

/* ═══════════════════════════════════════════════════════
   EXAM BLOCKER – Blockierung bei inaktivem Prüfungsmodus
═══════════════════════════════════════════════════════ */
.exam-blocker-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding:
    max(var(--sp-xl), env(safe-area-inset-top))
    var(--sp-xl)
    max(var(--sp-xl), env(safe-area-inset-bottom));
  animation: fadeIn .3s var(--ease);
}

.exam-blocker-card {
  background: #ffffff;
  border: 1.5px solid #ef4444;
  border-radius: var(--r-xl);
  padding: var(--sp-2xl) var(--sp-xl);
  max-width: 440px;
  width: 100%;
  text-align: left;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  color: #0f172a;
  max-height: min(86vh, 720px);
  overflow-y: auto;
}

.exam-blocker-icon {
  font-size: 56px;
  display: block;
  margin-bottom: var(--sp-md);
  animation: lock-wobble 1.5s ease-in-out infinite;
}

@keyframes lock-wobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

.exam-blocker-card h2 {
  font-size: var(--text-xl);
  font-weight: 800;
  color: #ef4444;
  margin-bottom: var(--sp-sm);
  margin-top: 0;
  text-align: center;
}

.exam-blocker-card p {
  color: #64748b;
  font-size: var(--text-sm);
  line-height: 1.5;
  margin-bottom: var(--sp-lg);
  text-align: left;
}

.exam-blocker-instruction {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--r-lg);
  padding: var(--sp-md) var(--sp-lg);
  text-align: left;
  margin-bottom: var(--sp-lg);
}

.exam-blocker-instruction strong {
  color: #0f172a;
  display: block;
  margin-bottom: var(--sp-xs);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.exam-blocker-instruction ol {
  margin: 0;
  padding-left: var(--sp-lg);
  color: #334155;
  font-size: var(--text-sm);
  line-height: 1.6;
}

.exam-blocker-status {
  font-size: var(--text-xs) !important;
  color: #94a3b8 !important;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  margin: 0 !important;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════
   GUIDED ACCESS STATUS – Detail-Anzeige beim Lehrer
═══════════════════════════════════════════════════════ */
.detail-exam-status-box {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  margin-top: var(--sp-sm);
  border: 1px solid transparent;
  animation: fadeIn .3s var(--ease);
  width: 100%;
  box-sizing: border-box;
}

.detail-exam-status-box.compliant {
  background: var(--green-dim) !important;
  border-color: var(--green) !important;
  color: var(--green) !important;
}

.detail-exam-status-box.interrupted {
  background: var(--red-dim) !important;
  border-color: var(--red) !important;
  color: var(--red) !important;
}

.detail-exam-status-box.never-active {
  background: var(--amber-dim) !important;
  border-color: var(--amber) !important;
  color: var(--amber) !important;
}

.detail-exam-status-title {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

.detail-exam-status-sub {
  font-size: var(--text-xs);
  opacity: 0.85;
}


/* ═══════════════════════════════════════════════════════
   PRINT STYLES (PDF EXPORT)
═══════════════════════════════════════════════════════ */
@media screen {
  #print-container {
    display: none !important;
  }
}

@media print {
  body * {
    visibility: hidden;
  }
  #print-container, #print-container * {
    visibility: visible;
  }
  #print-container {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
  }
  /* Remove background colors and shadows for print */
  body {
    background: transparent !important;
  }
}
