/* ════════════════════════════════════════════════════════════════════════
   LernHub — Design System
   Optimiert für iOS Safari, iPadOS, macOS Safari/Chrome, Desktop
   ════════════════════════════════════════════════════════════════════════ */

:root {
  /* Brand */
  --primary: #0d2d5e;
  --primary-dark: #061a3d;
  --primary-light: #1a4a8a;
  --gold: #c8a030;
  --gold-light: #f0d080;
  --gold-dark: #a07820;

  /* Surfaces */
  --bg: #f3f4f8;
  --bg-elevated: #ffffff;
  --bg-subtle: #f7f8fb;
  --border: #e5e7eb;
  --border-soft: #eef0f4;

  /* Text */
  --text: #1a2233;
  --text-muted: #6b7280;
  --text-soft: #9aa0ab;

  /* Semantic */
  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --info: #0284c7;
  --info-bg: #dbeafe;

  /* Shadows — schichtweise für realistische Tiefe */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, .07), 0 2px 4px -2px rgba(15, 23, 42, .05);
  --shadow-md: 0 10px 15px -3px rgba(15, 23, 42, .08), 0 4px 6px -4px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 30px -10px rgba(15, 23, 42, .15), 0 8px 12px -4px rgba(15, 23, 42, .06);
  --shadow-xl: 0 25px 50px -12px rgba(15, 23, 42, .25);

  /* Radii */
  --r-sm: 8px;
  --r: 12px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Safe area (iOS Notch / Home Indicator) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* ── Reset & Base ──────────────────────────────────────────────────── */

*,
*::before,
*::after {
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               system-ui, "Helvetica Neue", Roboto, sans-serif;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  /* iOS: kein elastisches Overscroll oben */
  overscroll-behavior-y: none;
}

/* Typografie auf Apple-Geräten satter */
h1, h2, h3, h4, h5, h6 { letter-spacing: -0.01em; }
h1, .h1 { font-weight: 700; letter-spacing: -0.02em; }
h2, .h2 { font-weight: 700; letter-spacing: -0.015em; }

/* Links sauber */
a { transition: color .15s var(--ease); }

/* Buttons: bessere Tap-Performance */
button, .btn, a.btn { touch-action: manipulation; }

/* Standard-Bootstrap-Schatten überschreiben */
.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow { box-shadow: var(--shadow) !important; }

/* ── Navbar ────────────────────────────────────────────────────────── */

.bg-primary-custom {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%) !important;
}

.navbar {
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
  padding-top: max(.5rem, var(--safe-top));
  padding-left: max(.75rem, var(--safe-left));
  padding-right: max(.75rem, var(--safe-right));
}

.navbar .navbar-brand {
  font-weight: 700;
  letter-spacing: -0.01em;
}

.navbar .nav-link {
  font-weight: 500;
  border-radius: var(--r-sm);
  padding: .4rem .85rem !important;
  transition: background .15s var(--ease);
}
.navbar .nav-link:hover { background: rgba(255,255,255,.08); }
.navbar .nav-link.active { background: rgba(255,255,255,.16); }

/* Avatar */
.avatar-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  color: var(--primary);
  font-weight: 700;
  font-size: .82rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.dropdown-menu {
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  padding: .35rem;
}
.dropdown-item {
  border-radius: var(--r-sm);
  padding: .55rem .8rem;
  font-weight: 500;
  font-size: .92rem;
}
.dropdown-item:hover { background: var(--bg-subtle); color: var(--primary); }
.dropdown-item.text-danger:hover { background: var(--danger-soft); color: var(--danger) !important; }

/* ── Layout ────────────────────────────────────────────────────────── */

.main-content {
  margin-top: 58px;
  padding-top: 1.25rem;
  padding-bottom: calc(2rem + var(--safe-bottom));
  padding-left: max(0px, var(--safe-left));
  padding-right: max(0px, var(--safe-right));
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── Cards ─────────────────────────────────────────────────────────── */

.card {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  background: var(--bg-elevated);
}
.card-header {
  border-radius: var(--r-md) var(--r-md) 0 0 !important;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-subtle);
}

/* Stat-Karten Dashboard */
.stat-card {
  border-radius: var(--r-md);
  padding: 1.25rem 1.4rem;
  color: #fff;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.12) 0%, transparent 60%);
  pointer-events: none;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-value { font-size: 2.1rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.stat-card .stat-label { font-size: .82rem; opacity: .9; margin-top: .35rem; font-weight: 500; }

/* Kategorie-Karte */
.cat-card {
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: var(--bg-elevated);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
  border: 1px solid var(--border-soft);
}
.cat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.cat-card .cat-header {
  padding: 1rem 1.2rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: .85rem;
  position: relative;
  overflow: hidden;
}
.cat-card .cat-header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.15) 0%, transparent 70%);
  pointer-events: none;
}
.cat-card .cat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
}
.cat-card .cat-body { padding: 1rem 1.2rem 1.2rem; }

/* Progress-Bar */
.progress {
  border-radius: var(--r-pill);
  height: 8px;
  background: var(--border-soft);
  overflow: hidden;
}
.progress-bar {
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 100%);
  transition: width .4s var(--ease-out);
}

/* ── Buttons ───────────────────────────────────────────────────────── */

.btn {
  font-weight: 600;
  border-radius: var(--r);
  padding: .55rem 1.1rem;
  transition: all .15s var(--ease);
  border-width: 1.5px;
  letter-spacing: -0.005em;
}
.btn:active { transform: scale(.98); }

.btn-primary-custom {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border: none;
  color: #fff;
  padding: .7rem 1.4rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .15);
  font-weight: 600;
}
.btn-primary-custom:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  box-shadow: 0 4px 8px rgba(13, 45, 94, .2);
  transform: translateY(-1px);
}
.btn-primary-custom:active { transform: translateY(0); }
.btn-primary-custom:focus-visible {
  outline: 3px solid rgba(13, 45, 94, .4);
  outline-offset: 2px;
}

.btn-outline-primary {
  border-color: var(--primary);
  color: var(--primary);
}
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }

.btn-outline-secondary {
  border-color: var(--border);
  color: var(--text);
  background: var(--bg-elevated);
}
.btn-outline-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--text-muted);
  color: var(--text);
}

.btn-success { background: var(--success); border-color: var(--success); }
.btn-outline-success { color: var(--success); border-color: var(--success); }
.btn-outline-success:hover { background: var(--success); }

.btn-outline-danger { color: var(--danger); border-color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); border-color: var(--danger); }

.btn-sm {
  padding: .45rem .85rem;
  font-size: .88rem;
  min-height: 36px;
}
.btn-lg { padding: .9rem 1.6rem; font-size: 1.1rem; }

/* ── Forms ─────────────────────────────────────────────────────────── */

.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: .65rem .9rem;
  font-size: 1rem;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  background: var(--bg-elevated);
  color: var(--text);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(13, 45, 94, .12);
}
.form-control::placeholder { color: var(--text-soft); }

.form-label { font-weight: 600; color: var(--text); margin-bottom: .4rem; font-size: .92rem; }
.form-text { color: var(--text-muted); font-size: .85rem; }

/* ── Lerneinheit: Frage-Karte ──────────────────────────────────────── */

.learn-card {
  max-width: 760px;
  margin: 1.5rem auto;
}

.question-box {
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-soft);
}

.question-text {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.45;
  letter-spacing: -0.01em;
}

.answer-input {
  font-size: 1.05rem;
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  padding: .8rem 1rem;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.answer-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(13, 45, 94, .12);
}

/* Choice-Buttons (Multiple Choice / Scenario) */
.choice-btn {
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: .85rem 1.15rem;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition: all .15s var(--ease);
  width: 100%;
  font-weight: 500;
  color: var(--text);
  min-height: 50px;
  user-select: none;
}
.choice-btn:hover {
  border-color: var(--primary);
  background: #f5f8fd;
  transform: translateX(2px);
}
.choice-btn.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, #e8eef8 0%, #d8e3f5 100%);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 0 0 3px rgba(13, 45, 94, .12);
}
.choice-btn:active { transform: scale(.99); }

/* Matching-Grid */
.matching-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .9rem;
}
.match-item {
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: .8rem 1rem;
  cursor: pointer;
  transition: all .15s var(--ease);
  font-size: .95rem;
  user-select: none;
  font-weight: 500;
  min-height: 50px;
  display: flex;
  align-items: center;
}
.match-item:hover { border-color: var(--primary); background: #f5f8fd; }
.match-item.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, #e8eef8 0%, #d8e3f5 100%);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 0 0 3px rgba(13, 45, 94, .12);
}
.match-item.matched-correct {
  border-color: var(--success);
  background: var(--success-soft);
  color: #14532d;
  cursor: default;
  font-weight: 600;
}
.match-item.matched-wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: #7f1d1d;
  animation: shake .4s var(--ease);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Cloze-Lücken */
.cloze-blank {
  display: inline-block;
  border: none;
  border-bottom: 2px solid var(--primary);
  background: #eaf1fb;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary);
  padding: 4px 10px;
  margin: 0 4px;
  border-radius: 6px 6px 0 0;
  min-width: 110px;
  outline: none;
  transition: all .15s var(--ease);
  font-family: inherit;
}
.cloze-blank:focus {
  background: #d8e3f5;
  border-bottom-color: var(--gold);
  box-shadow: 0 2px 0 var(--gold);
}

/* Feedback (richtig/falsch Border) */
.feedback-correct { border-left: 5px solid var(--success); }
.feedback-wrong { border-left: 5px solid var(--danger); }

/* Session-Progress oben */
.session-progress {
  height: 4px;
  border-radius: 0;
  background: rgba(0, 0, 0, .06);
}
.session-progress .progress-bar {
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 100%);
}

/* ── Type-Badges ───────────────────────────────────────────────────── */

.badge {
  border-radius: var(--r-pill);
  padding: .35em .8em;
  font-weight: 600;
  font-size: .76rem;
  letter-spacing: .01em;
}

.badge-written     { background: #dbe8fb; color: #1e3a72; }
.badge-mc          { background: #fff3cd; color: #7a5a00; }
.badge-matching    { background: #d1f0d8; color: #1a5e2d; }
.badge-flash       { background: #ede0fa; color: #5a1a8a; }
.badge-tf          { background: #ffe5d9; color: #8a3d10; }
.badge-cloze       { background: #d1f0f0; color: #0e5e5e; }
.badge-enum        { background: #fde2e4; color: #8a1538; }
.badge-ordering    { background: #dfeaff; color: #1e3a8a; }
.badge-scenario    { background: #ffe0b3; color: #8a4f10; }
.badge-paragraph   { background: #fef3c7; color: #7a5a00; }
.badge-audio       { background: #d8e8ff; color: #1a3a8a; }

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

.ordering-list { display: flex; flex-direction: column; gap: .6rem; }
.ordering-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: .85rem 1rem;
  text-align: left;
  cursor: pointer;
  transition: all .15s var(--ease);
  width: 100%;
  font-size: 1rem;
  font-weight: 500;
  user-select: none;
  min-height: 60px;
}
.ordering-item:hover { border-color: var(--primary); background: #f5f8fd; }
.ordering-item.positioned {
  border-color: var(--primary);
  background: linear-gradient(135deg, #e8eef8 0%, #d8e3f5 100%);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 0 0 3px rgba(13, 45, 94, .1);
}
.ordering-item .order-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-soft);
  font-weight: 700;
  font-size: 1.05rem;
  flex-shrink: 0;
  transition: all .2s var(--ease-bounce);
  border: 2px solid transparent;
}
.ordering-item.positioned .order-badge {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  border-color: rgba(255,255,255,.4);
  transform: scale(1.05);
}
.ordering-item .order-text { flex: 1; line-height: 1.35; }

/* ── §-Erkennung ───────────────────────────────────────────────────── */

.paragraph-grid input {
  font-size: 1.5rem;
  padding: .8rem .5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ── Speed-Drill Timer ─────────────────────────────────────────────── */

.speed-timer-wrap {
  height: 4px;
  background: rgba(0, 0, 0, .06);
  overflow: hidden;
}
.speed-timer-bar {
  height: 100%;
  width: 100%;
  background: var(--success);
  transition: background .3s var(--ease), width .1s linear;
  box-shadow: 0 0 8px currentColor;
}

/* ── Auto-Lern-Modus ──────────────────────────────────────────────── */

body.auto-mode {
  background: linear-gradient(180deg, #f7f8fb 0%, #eef2f8 100%);
}

.auto-card {
  max-width: 820px;
  padding: 0;
  margin-top: 0;
  margin-left: auto;
  margin-right: auto;
}

.auto-header {
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: var(--safe-top);
  z-index: 10;
  padding-top: max(.6rem, var(--safe-top));
  padding-left: max(1rem, var(--safe-left));
  padding-right: max(1rem, var(--safe-right));
}
.auto-header .btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r);
}

.question-box-auto {
  border-radius: 0;
  box-shadow: none;
  padding: 2rem 1.5rem calc(2rem + var(--safe-bottom));
  border: none;
  min-height: calc(100vh - 70px);
  min-height: calc(100dvh - 70px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.question-text-auto {
  font-size: clamp(1.4rem, 4.5vw, 1.9rem) !important;
  text-align: center;
  line-height: 1.4;
  padding: 1rem 0 2rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: -0.015em;
}

.choice-btn-big {
  font-size: 1.2rem;
  padding: 1.4rem 1.2rem;
  min-height: 84px;
  border-width: 2px;
  font-weight: 600;
  border-radius: var(--r-md);
}
.choice-btn-big:hover { transform: none; }

.tf-btn-auto {
  font-size: 1.6rem !important;
  padding: 2rem 1rem !important;
  min-height: 140px !important;
  border-width: 2.5px !important;
  border-radius: var(--r-md) !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em;
}

.btn-big {
  font-size: 1.15rem !important;
  padding: 1.1rem 1rem !important;
  min-height: 70px;
  font-weight: 600;
  border-radius: var(--r-md) !important;
}

/* ── Login-Seite ───────────────────────────────────────────────────── */

.login-wrapper {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top left, var(--primary-light) 0%, var(--primary) 50%, var(--primary-dark) 100%);
  padding: max(1rem, var(--safe-top)) max(1rem, var(--safe-right)) max(1rem, var(--safe-bottom)) max(1rem, var(--safe-left));
  position: relative;
  overflow: hidden;
}
.login-wrapper::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(200, 160, 48, .12), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, .08), transparent 50%);
  pointer-events: none;
}
.login-box {
  background: rgba(255, 255, 255, .98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--r-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3), 0 0 0 1px rgba(255, 255, 255, .1);
  position: relative;
}
.login-logo {
  color: var(--primary);
  font-size: 3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 78px;
  height: 78px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, #e8eef8 0%, #d8e3f5 100%);
  box-shadow: var(--shadow);
}

/* ── Tabellen ──────────────────────────────────────────────────────── */

.table {
  --bs-table-hover-bg: var(--bg-subtle);
  margin-bottom: 0;
}
.table th { font-weight: 600; color: var(--text-muted); font-size: .85rem; letter-spacing: .02em; text-transform: uppercase; border-bottom: 1.5px solid var(--border-soft); }
.table-hover tbody tr { transition: background-color .12s var(--ease); }
.table-hover tbody tr:hover { background: var(--bg-subtle); }
.table-light { background: var(--bg-subtle) !important; }

/* ── Alerts ────────────────────────────────────────────────────────── */

.alert {
  border-radius: var(--r);
  border: 1px solid transparent;
  padding: .85rem 1.1rem;
}
.alert-info { background: var(--info-bg); color: #075985; border-color: rgba(2, 132, 199, .2); }
.alert-success { background: var(--success-bg); color: #14532d; border-color: rgba(22, 163, 74, .2); }
.alert-warning { background: var(--warning-bg); color: #78350f; border-color: rgba(217, 119, 6, .2); }
.alert-danger { background: var(--danger-bg); color: #7f1d1d; border-color: rgba(220, 38, 38, .2); }
.alert-light { background: var(--bg-subtle); border-color: var(--border-soft); color: var(--text); }

/* ── Mobile Optimierungen ──────────────────────────────────────────── */

@media (max-width: 576px) {
  .matching-grid { grid-template-columns: 1fr; }
  .question-text { font-size: 1.18rem; }
  .question-box { padding: 1.4rem 1.2rem; border-radius: var(--r); }
  .learn-card { margin: 1rem auto; }
  .stat-card { padding: 1rem 1.15rem; }
  .stat-card .stat-value { font-size: 1.7rem; }
  .stat-card .stat-label { font-size: .78rem; }
  .login-box { padding: 1.75rem 1.4rem; border-radius: var(--r-lg); }
  .navbar .navbar-brand span { font-size: .95rem; }
  .choice-btn-big { font-size: 1.05rem; min-height: 70px; padding: 1rem 1.1rem; }
  .tf-btn-auto { font-size: 1.35rem !important; min-height: 110px !important; padding: 1.5rem 1rem !important; }
  .question-text-auto { padding: .5rem 0 1.5rem; }
}

/* iPad-Größe — komfortabler nutzen */
@media (min-width: 768px) and (max-width: 1024px) {
  .learn-card { max-width: 660px; }
  .question-text { font-size: 1.4rem; }
  .choice-btn { font-size: 1.05rem; padding: 1rem 1.2rem; min-height: 56px; }
  .stat-card .stat-value { font-size: 2.2rem; }
}

/* Touch-Devices: kein Hover-Transform (sonst springt es) */
@media (hover: none) {
  .choice-btn:hover, .ordering-item:hover, .match-item:hover, .cat-card:hover {
    transform: none;
  }
  .btn-primary-custom:hover { transform: none; }
}

/* ── Print (für Lerner die ausdrucken wollen) ──────────────────────── */
@media print {
  .navbar, .session-progress, .speed-timer-wrap, footer { display: none !important; }
  body { background: #fff; }
  .question-box { box-shadow: none; border: 1px solid #ccc; }
}

/* ── Accessibility: Sichtbarer Fokus für Tastatur-Nutzer ───────────── */

:focus-visible {
  outline: 3px solid rgba(13, 45, 94, .5);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.choice-btn:focus-visible,
.ordering-item:focus-visible,
.match-item:focus-visible {
  outline-offset: 4px;
}

/* iOS Safari: Inputs nicht zoomen beim Tippen (16px = no zoom threshold) */
@supports (-webkit-touch-callout: none) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px;
  }
  /* Cloze-Lücken bleiben kompakt */
  .cloze-blank { font-size: 16px; }
}

/* ════════════════════════════════════════════════════════════════════════
   Hintergrund-Effekt + Page-/Element-Animationen
   GPU-only (transform/opacity), respektiert prefers-reduced-motion.
   ════════════════════════════════════════════════════════════════════════ */

/* Statische, sehr dezente Hintergrund-Vignette auf allen Seiten */
body { position: relative; }
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(40% 35% at 12% 18%, rgba(13, 45, 94, 0.045), transparent 70%),
    radial-gradient(45% 40% at 88% 78%, rgba(200, 160, 48, 0.04), transparent 70%),
    radial-gradient(35% 30% at 50% 50%, rgba(26, 74, 138, 0.025), transparent 70%);
}
/* Inhalte über das ::before legen */
.main-content { position: relative; z-index: 1; }
.login-wrapper { z-index: 1; }
.login-box { position: relative; z-index: 2; }
.navbar { z-index: 1030; } /* Bootstrap Default — sicherheitshalber */

@media (prefers-reduced-motion: no-preference) {

  /* ── Hintergrund-Drift (sehr langsam, kaum wahrnehmbar) ─────────── */
  body::before {
    animation: bgDrift 40s ease-in-out infinite alternate;
    will-change: transform;
  }
  @keyframes bgDrift {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    50%  { transform: translate3d(20px, -14px, 0) scale(1.025); }
    100% { transform: translate3d(-15px, 12px, 0) scale(0.985); }
  }

  /* ── Navbar: Slide-Down beim Laden ──────────────────────────────── */
  .navbar { animation: navIn 0.4s var(--ease-out) both; }
  @keyframes navIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ── Hauptinhalt: sanftes Fade-Up ───────────────────────────────── */
  .main-content > .container-fluid > * {
    animation: contentIn 0.45s var(--ease-out) both;
  }
  .main-content > .container-fluid > *:nth-child(1) { animation-delay: 0.05s; }
  .main-content > .container-fluid > *:nth-child(2) { animation-delay: 0.10s; }
  .main-content > .container-fluid > *:nth-child(n+3) { animation-delay: 0.15s; }
  @keyframes contentIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ── Karten-Grids: sanfter Stagger über Bootstrap-Cols ─────────── */
  .row > [class*="col-"] {
    animation: cardIn 0.45s var(--ease-out) both;
  }
  .row > [class*="col-"]:nth-child(1)   { animation-delay: 0.10s; }
  .row > [class*="col-"]:nth-child(2)   { animation-delay: 0.16s; }
  .row > [class*="col-"]:nth-child(3)   { animation-delay: 0.22s; }
  .row > [class*="col-"]:nth-child(4)   { animation-delay: 0.28s; }
  .row > [class*="col-"]:nth-child(5)   { animation-delay: 0.34s; }
  .row > [class*="col-"]:nth-child(6)   { animation-delay: 0.40s; }
  .row > [class*="col-"]:nth-child(n+7) { animation-delay: 0.45s; }
  @keyframes cardIn {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }

  /* ── Frage-Box: Pop-In beim Erscheinen ──────────────────────────── */
  .question-box {
    animation: questionIn 0.4s var(--ease-out) both;
  }
  @keyframes questionIn {
    from { opacity: 0; transform: translateY(10px) scale(0.99); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }

  /* ── Multiple-Choice / Scenario: Buttons gestaffelt ─────────────── */
  #choiceGrid .choice-btn {
    animation: itemIn 0.3s var(--ease-out) both;
  }
  #choiceGrid .choice-btn:nth-child(1)   { animation-delay: 0.18s; }
  #choiceGrid .choice-btn:nth-child(2)   { animation-delay: 0.24s; }
  #choiceGrid .choice-btn:nth-child(3)   { animation-delay: 0.30s; }
  #choiceGrid .choice-btn:nth-child(4)   { animation-delay: 0.36s; }
  #choiceGrid .choice-btn:nth-child(n+5) { animation-delay: 0.40s; }

  /* ── Ordering-Liste: gestaffelt einblenden ──────────────────────── */
  .ordering-list .ordering-item {
    animation: itemIn 0.3s var(--ease-out) both;
  }
  .ordering-list .ordering-item:nth-child(1)   { animation-delay: 0.16s; }
  .ordering-list .ordering-item:nth-child(2)   { animation-delay: 0.21s; }
  .ordering-list .ordering-item:nth-child(3)   { animation-delay: 0.26s; }
  .ordering-list .ordering-item:nth-child(4)   { animation-delay: 0.31s; }
  .ordering-list .ordering-item:nth-child(n+5) { animation-delay: 0.36s; }

  /* ── Matching: links/rechts einblenden ──────────────────────────── */
  .matching-grid .match-item {
    animation: itemIn 0.3s var(--ease-out) both;
  }
  .matching-grid #leftCol .match-item:nth-child(1) { animation-delay: 0.18s; }
  .matching-grid #leftCol .match-item:nth-child(2) { animation-delay: 0.24s; }
  .matching-grid #leftCol .match-item:nth-child(3) { animation-delay: 0.30s; }
  .matching-grid #leftCol .match-item:nth-child(n+4) { animation-delay: 0.34s; }
  .matching-grid #rightCol .match-item:nth-child(1) { animation-delay: 0.20s; }
  .matching-grid #rightCol .match-item:nth-child(2) { animation-delay: 0.26s; }
  .matching-grid #rightCol .match-item:nth-child(3) { animation-delay: 0.32s; }
  .matching-grid #rightCol .match-item:nth-child(n+4) { animation-delay: 0.36s; }

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

  /* ── Flashcard-Antwort: smooth reveal ───────────────────────────── */
  #answerBox:not(.d-none),
  #evalButtons:not(.d-none) {
    animation: revealDown 0.35s var(--ease-out);
  }
  @keyframes revealDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ── Feedback-Page: Bounce des Status ───────────────────────────── */
  .feedback-correct, .feedback-wrong {
    animation: feedbackIn 0.45s var(--ease-bounce) both;
  }
  @keyframes feedbackIn {
    from { opacity: 0; transform: scale(0.94); }
    to   { opacity: 1; transform: scale(1); }
  }

  /* ── Speed-Timer: subtiles Glühen ───────────────────────────────── */
  .speed-timer-bar {
    animation: timerPulse 1.6s ease-in-out infinite;
  }
  @keyframes timerPulse {
    0%, 100% { box-shadow: 0 0 6px currentColor; }
    50%      { box-shadow: 0 0 14px currentColor; }
  }

  /* ── Progress-Bar Fortschritt-Anzeige (subtle shimmer) ──────────── */
  .progress-bar {
    background-size: 200% 100%;
    background-image: linear-gradient(90deg,
      var(--gold) 0%, var(--gold-light) 50%, var(--gold) 100%);
    animation: progressShimmer 6s ease-in-out infinite;
  }
  @keyframes progressShimmer {
    0%   { background-position: 0% 0; }
    100% { background-position: -200% 0; }
  }

  /* ── Alerts: Fade-In von oben ───────────────────────────────────── */
  .alert {
    animation: alertIn 0.35s var(--ease-out) both;
  }
  @keyframes alertIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ── Login-Seite ────────────────────────────────────────────────── */
  .login-wrapper::before {
    animation: loginBgDrift 22s ease-in-out infinite alternate;
    will-change: transform;
  }
  @keyframes loginBgDrift {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    50%  { transform: translate3d(40px, -28px, 0) scale(1.06); }
    100% { transform: translate3d(-25px, 18px, 0) scale(0.95); }
  }

  /* Zweiter, weicher Hintergrund-Layer auf der Login-Seite */
  .login-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
      radial-gradient(circle at 60% 20%, rgba(200, 160, 48, 0.08), transparent 35%),
      radial-gradient(circle at 30% 80%, rgba(26, 74, 138, 0.18), transparent 40%);
    pointer-events: none;
    animation: loginBgDrift2 28s ease-in-out infinite alternate-reverse;
    will-change: transform;
    z-index: 0;
  }
  @keyframes loginBgDrift2 {
    0%   { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(-30px, 25px, 0); }
  }

  .login-box {
    animation: loginBoxIn 0.6s var(--ease-out) both;
  }
  @keyframes loginBoxIn {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }

  /* Logo schwebt sanft */
  .login-logo {
    animation: logoFloat 4s ease-in-out infinite;
    will-change: transform;
  }
  @keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-5px); }
  }

  /* Login-Inhalte gestaffelt einblenden */
  .login-box > .text-center,
  .login-box > .alert,
  .login-box > form > * {
    animation: fieldIn 0.45s var(--ease-out) both;
  }
  .login-box > .text-center           { animation-delay: 0.18s; }
  .login-box > .alert                 { animation-delay: 0.22s; }
  .login-box > form > *:nth-child(1)  { animation-delay: 0.28s; }
  .login-box > form > *:nth-child(2)  { animation-delay: 0.35s; }
  .login-box > form > *:nth-child(3)  { animation-delay: 0.42s; }
  .login-box > form > *:nth-child(4)  { animation-delay: 0.49s; }
  @keyframes fieldIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Shake der Login-Form bei Fehlermeldung */
  .login-box:has(.alert-danger) form {
    animation: shakeForm 0.55s ease;
  }
  @keyframes shakeForm {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-7px); }
    40%      { transform: translateX(7px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
  }

  /* ── Auto-Mode: Frage faded sanft ein ───────────────────────────── */
  body.auto-mode .question-text-auto {
    animation: autoQuestionIn 0.5s var(--ease-out) both;
  }
  @keyframes autoQuestionIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Auto-Mode Buttons stagger */
  body.auto-mode #choiceGrid .choice-btn { animation-name: choiceInBig; }
  @keyframes choiceInBig {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }
}
