@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=JetBrains+Mono:ital,wght@0,400;0,500;1,400&display=swap');

/* ============================================================================
   LERNSOFTWARE EMIL — Night Coder Design System
   ============================================================================ */

:root {
  --bg-base:       #0d1117;
  --bg-panel:      #161b22;
  --bg-elevated:   #21262d;
  --bg-hover:      #2d333b;
  --border:        #30363d;
  --border-muted:  #1e2329;

  --text-primary:  #e6edf3;
  --text-secondary:#8b949e;
  --text-muted:    #484f58;

  --amber:         #f59e0b;
  --amber-light:   #fbbf24;
  --amber-dim:     rgba(245, 158, 11, 0.12);
  --amber-glow:    rgba(245, 158, 11, 0.25);

  --green:         #22c55e;
  --green-dim:     rgba(34, 197, 94, 0.12);

  --red:           #f85149;
  --red-dim:       rgba(248, 81, 73, 0.12);

  --blue:          #58a6ff;
  --blue-dim:      rgba(88, 166, 255, 0.10);

  --radius-sm:     0.375rem;
  --radius-md:     0.75rem;
  --radius-lg:     1.125rem;
  --radius-xl:     1.5rem;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background-color: var(--bg-base);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.025) 1px, transparent 0);
  background-size: 28px 28px;
  color: var(--text-primary);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 {
  font-family: 'Syne', sans-serif;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

code, pre, .mono {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ── Navigation ─────────────────────────────────────────────────────────── */

.top-nav {
  background: rgba(22, 27, 34, 0.90);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 3.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  transition: color 0.15s;
}

.nav-brand:hover { color: var(--amber); }

.nav-brand-icon {
  width: 2rem;
  height: 2rem;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9375rem;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
  flex-shrink: 0;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-username {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  display: none;
}

@media (min-width: 600px) { .nav-username { display: block; } }

.btn-ghost {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.875rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
  background: var(--bg-elevated);
}

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

.page-wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.page-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  width: 100%;
  flex: 1;
}

@media (max-width: 640px) {
  .page-content { padding: 1.5rem 1rem; }
}

/* ── Flash Messages ─────────────────────────────────────────────────────── */

.flash {
  border-radius: var(--radius-md);
  padding: 0.875rem 1.125rem;
  margin-bottom: 1.25rem;
  font-size: 0.9375rem;
}
.flash-success { background: var(--green-dim); border: 1px solid rgba(34,197,94,0.2); color: #4ade80; }
.flash-error   { background: var(--red-dim);   border: 1px solid rgba(248,81,73,0.2);  color: #fca5a5; }
.flash-info    { background: var(--blue-dim);  border: 1px solid rgba(88,166,255,0.2); color: #93c5fd; }

/* ── Breadcrumb ─────────────────────────────────────────────────────────── */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.breadcrumb a { transition: color 0.15s; }
.breadcrumb a:hover { color: var(--amber); }
.breadcrumb__sep { color: var(--text-muted); }
.breadcrumb__current { color: var(--text-primary); font-weight: 500; }

/* ── Dashboard Greeting ─────────────────────────────────────────────────── */

.greeting {
  margin-bottom: 2.5rem;
  animation: fadeUp 0.4s ease-out both;
}

.greeting__title {
  font-family: 'Syne', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.greeting__name {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.greeting__sub {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: 0.375rem;
}

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

.curriculum-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.125rem;
}

.curriculum-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  animation: fadeUp 0.4s ease-out both;
}

.curriculum-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--amber-dim), transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.curriculum-card:hover {
  border-color: var(--amber);
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.18);
  transform: translateY(-3px);
}

.curriculum-card:hover::after { opacity: 1; }

.curriculum-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}

.curriculum-card__emoji { font-size: 2.5rem; line-height: 1; }

.curriculum-card__badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--amber);
  background: var(--amber-dim);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 99px;
  padding: 0.2rem 0.625rem;
  white-space: nowrap;
}

.curriculum-card__title {
  font-family: 'Syne', sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  position: relative;
  z-index: 1;
  transition: color 0.15s;
}

.curriculum-card:hover .curriculum-card__title { color: var(--amber-light); }

.curriculum-card__desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* XP Bar */
.xp-bar-wrap { margin-top: auto; position: relative; z-index: 1; }

.xp-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.xp-bar-label .xp-pct { color: var(--amber); }

.xp-bar-track {
  height: 5px;
  background: var(--bg-elevated);
  border-radius: 99px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber), var(--amber-light));
  border-radius: 99px;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
  transition: width 1.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.xp-bar-fill.complete {
  background: linear-gradient(90deg, var(--green), #4ade80);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

/* ── Empty State ────────────────────────────────────────────────────────── */

.empty-state {
  background: var(--bg-panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius-xl);
  padding: 4rem 2rem;
  text-align: center;
}

.empty-state__icon { font-size: 3rem; margin-bottom: 1rem; }

.empty-state__title {
  font-family: 'Syne', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
}

.empty-state__sub {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.empty-state code {
  display: inline-block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  color: var(--amber);
}

/* ── Curriculum Page Header ─────────────────────────────────────────────── */

.page-hero {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
  animation: fadeUp 0.4s ease-out both;
}

.page-hero__emoji { font-size: 3rem; line-height: 1; flex-shrink: 0; }

.page-hero__title {
  font-family: 'Syne', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
}

.page-hero__sub {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-top: 0.375rem;
}

/* ── Phase Section ──────────────────────────────────────────────────────── */

.phase-section {
  margin-bottom: 2.25rem;
  animation: fadeUp 0.4s ease-out both;
}

.phase-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 0.75rem;
}

.phase-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--amber);
  background: var(--amber-dim);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 99px;
  padding: 0.25rem 0.75rem;
}

.phase-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
}

.phase-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 0.875rem;
  padding-left: 0.125rem;
}

.einheit-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ── Einheit Row ────────────────────────────────────────────────────────── */

.einheit-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: 0.8125rem 1rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.einheit-row:hover {
  border-color: var(--amber);
  background: var(--bg-elevated);
  transform: translateX(4px);
}

.einheit-row.done {
  border-color: rgba(34, 197, 94, 0.18);
  background: rgba(34, 197, 94, 0.03);
}

.einheit-row.done:hover {
  border-color: rgba(34, 197, 94, 0.4);
  background: var(--green-dim);
  transform: translateX(4px);
}

.einheit-num {
  width: 2.125rem;
  height: 2.125rem;
  border-radius: 0.4375rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all 0.15s;
}

.einheit-row:hover .einheit-num {
  background: var(--amber-dim);
  border-color: rgba(245, 158, 11, 0.35);
  color: var(--amber);
}

.einheit-num.done {
  background: var(--green-dim);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--green);
}

.einheit-info { flex: 1; min-width: 0; }

.einheit-name {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s;
}

.einheit-row:hover .einheit-name { color: var(--amber); }
.einheit-row.done .einheit-name { color: var(--green); }

.einheit-lernziele {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.einheit-meta {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}

.meta-item { display: flex; align-items: center; gap: 0.25rem; }

/* ── Einheit Detail Page ────────────────────────────────────────────────── */

.einheit-title-block { margin-bottom: 1.75rem; animation: fadeUp 0.4s ease-out both; }

.einheit-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 0.875rem;
}

.lernziele-box {
  display: flex;
  gap: 0.875rem;
  background: var(--amber-dim);
  border: 1px solid rgba(245, 158, 11, 0.18);
  border-left: 3px solid var(--amber);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 0.875rem 1.125rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  line-height: 1.6;
}

.lernziele-icon { font-size: 1.125rem; flex-shrink: 0; margin-top: 0.15em; }

/* ── Content Prose ──────────────────────────────────────────────────────── */

.content-prose {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 2.25rem;
  margin-bottom: 1.75rem;
  animation: fadeUp 0.4s ease-out 0.05s both;
}

@media (max-width: 640px) {
  .content-prose { padding: 1.25rem; }
}

.content-prose h1, .content-prose h2, .content-prose h3, .content-prose h4 {
  font-family: 'Syne', sans-serif;
  color: var(--text-primary);
  margin-top: 1.75em;
  margin-bottom: 0.625em;
}

.content-prose > *:first-child { margin-top: 0 !important; }

.content-prose h1 { font-size: 1.5rem; font-weight: 800; }
.content-prose h2 { font-size: 1.1875rem; font-weight: 700; padding-bottom: 0.5em; border-bottom: 1px solid var(--border); }
.content-prose h3 { font-size: 1rem; font-weight: 700; color: var(--amber); }
.content-prose h4 { font-size: 0.9375rem; font-weight: 600; color: var(--text-secondary); }

.content-prose p { color: var(--text-secondary); margin-bottom: 0.875em; }
.content-prose strong { color: var(--text-primary); font-weight: 600; }
.content-prose em { color: var(--text-secondary); }

.content-prose ul, .content-prose ol {
  padding-left: 1.5rem;
  margin-bottom: 0.875em;
  color: var(--text-secondary);
}

.content-prose li { margin-bottom: 0.3em; }
.content-prose li::marker { color: var(--amber); }
.content-prose ol li::marker { color: var(--text-muted); font-family: 'JetBrains Mono', monospace; font-size: 0.8em; }

.content-prose a { color: var(--amber); text-decoration: underline; text-underline-offset: 3px; }
.content-prose a:hover { color: var(--amber-light); }

.content-prose blockquote {
  border-left: 3px solid var(--amber);
  padding-left: 1.125rem;
  margin: 1.25em 0;
  color: var(--text-secondary);
  font-style: italic;
}

.content-prose hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }

/* Code blocks */
.content-prose pre:not(.mermaid) {
  background: #090d14;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 1.25em 0;
  overflow: hidden;
}

.content-prose pre:not(.mermaid) code {
  display: block;
  padding: 1.125rem 1.25rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  line-height: 1.75;
  color: #cdd9e5;
  overflow-x: auto;
}

.content-prose :not(pre) > code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.125em 0.4em;
  color: var(--amber-light);
}

/* Tables */
.content-prose table { width: 100%; border-collapse: collapse; margin: 1.25em 0; font-size: 0.875rem; }
.content-prose th {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border);
  font-family: 'Syne', sans-serif;
  font-size: 0.875rem;
}
.content-prose td {
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border-muted);
  color: var(--text-secondary);
}
.content-prose tr:hover td { background: rgba(255,255,255,0.02); }

/* Mermaid */
.content-prose .mermaid {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 1.25em 0;
  text-align: center;
  overflow-x: auto;
  cursor: zoom-in;
  transition: border-color 0.15s;
}
.content-prose .mermaid:hover {
  border-color: var(--amber);
}

/* Diagram zoom modal */
.diagram-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
  animation: modal-fade-in 0.15s ease;
}
@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.diagram-modal-inner {
  position: relative;
  width: min(95vw, 1400px);
  max-height: 90vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2rem;
  overflow: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.diagram-modal-inner svg {
  width: 100%;
  height: auto;
  display: block;
}
.diagram-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-panel);
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}
.diagram-modal-close:hover {
  background: var(--amber);
  color: #0d1117;
  border-color: var(--amber);
}

/* Math (KaTeX) */
.math-block {
  display: block;
  text-align: center;
  padding: 0.75rem 0;
  overflow-x: auto;
}
.math-inline {
  display: inline;
}
.katex-display {
  margin: 0.75em 0;
}

/* Code run button */
.code-run-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1.25rem;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}

.code-run-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--amber);
  background: var(--amber-dim);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.code-run-btn:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--amber);
}

.code-output {
  background: #050710;
  border-top: 1px solid var(--border);
  padding: 0.875rem 1.25rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  color: #4ade80;
  white-space: pre-wrap;
  line-height: 1.6;
  display: none;
}

.code-output.visible { display: block; }

/* ── Section Card (Quiz / Flashcards) ───────────────────────────────────── */

.section-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  overflow: hidden;
  animation: fadeUp 0.4s ease-out 0.1s both;
}

.section-card__head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid var(--border-muted);
}

.section-card__icon {
  width: 2.625rem;
  height: 2.625rem;
  background: var(--bg-elevated);
  border-radius: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1875rem;
  flex-shrink: 0;
}

.section-card__head-info h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.section-card__head-info p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.125rem;
}

.section-card__body { padding: 1.5rem; }

/* ── Quiz ───────────────────────────────────────────────────────────────── */

.quiz-q-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.55;
  margin-bottom: 1.125rem;
}

.quiz-q-num {
  font-family: 'JetBrains Mono', monospace;
  color: var(--amber);
  font-size: 0.8125rem;
  font-weight: 700;
  margin-right: 0.5rem;
}

.quiz-answers {
  display: flex;
  flex-direction: column;
  gap: 0.4375rem;
}

.quiz-answer {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.8125rem 1rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-family: 'DM Sans', sans-serif;
}

.quiz-answer:hover:not(:disabled) {
  border-color: rgba(245, 158, 11, 0.45);
  color: var(--text-primary);
  background: var(--amber-dim);
}

.quiz-answer:disabled { cursor: not-allowed; opacity: 0.85; }

.ans-letter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  width: 1.5rem;
  height: 1.5rem;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.15em;
  transition: all 0.15s;
}

.quiz-answer:hover:not(:disabled) .ans-letter {
  background: var(--amber-dim);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--amber);
}

.quiz-answer[data-state="correct"] {
  border-color: rgba(34, 197, 94, 0.5);
  background: var(--green-dim);
  color: #4ade80;
}

.quiz-answer[data-state="correct"] .ans-letter {
  background: var(--green-dim);
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--green);
}

.quiz-answer[data-state="wrong"] {
  border-color: rgba(248, 81, 73, 0.45);
  background: var(--red-dim);
  color: #fca5a5;
}

.quiz-answer[data-state="wrong"] .ans-letter {
  background: var(--red-dim);
  border-color: rgba(248, 81, 73, 0.4);
  color: var(--red);
}

.quiz-feedback {
  font-size: 0.875rem;
  padding: 0.6875rem 1rem;
  border-radius: var(--radius-sm);
  margin-top: 0.75rem;
  display: none;
  line-height: 1.5;
}

.quiz-feedback.correct {
  background: var(--green-dim);
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: #4ade80;
  display: block;
}

.quiz-feedback.wrong {
  background: var(--red-dim);
  border: 1px solid rgba(248, 81, 73, 0.2);
  color: #fca5a5;
  display: block;
}

.quiz-nav { margin-top: 1rem; }

/* Open-ended reveal questions */
.quiz-reveal { margin-top: 1rem; }

.quiz-reveal-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: var(--amber-dim);
  border: 1px solid var(--amber);
  border-radius: var(--radius-sm);
  color: var(--amber-light);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.quiz-reveal-btn:hover {
  background: var(--amber);
  color: #0d1117;
}

.quiz-reveal-text {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9375rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

.quiz-result {
  text-align: center;
  padding: 2.5rem 1rem;
  display: none;
}

.quiz-result.visible { display: block; }

.quiz-result__trophy { font-size: 3.25rem; margin-bottom: 0.625rem; }

.quiz-result h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
}

.quiz-result p { color: var(--text-secondary); font-size: 0.9375rem; }

/* ── Interactive Exercises ──────────────────────────────────────────────── */

.exercise-widget {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}

.exercise-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.875rem;
  flex-wrap: wrap;
}

.exercise-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--amber);
  background: var(--amber-dim);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 4px;
  padding: 0.1875rem 0.5rem;
  text-transform: uppercase;
}

.exercise-title {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.exercise-progress {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

.exercise-problem {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.7;
  margin-bottom: 1.125rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.exercise-steps-container {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.exercise-step {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  transition: border-color 0.15s;
}

.exercise-step[data-state="correct"] {
  border-color: rgba(34, 197, 94, 0.4);
  background: var(--green-dim);
}

.exercise-step[data-state="correct"] .step-instruction {
  color: #4ade80;
}

.step-answer-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.5rem;
  background: rgba(74, 222, 128, 0.15);
  border: 1px solid rgba(74, 222, 128, 0.4);
  border-radius: 0.25rem;
  font-family: var(--font-mono, monospace);
  font-size: 0.85em;
  color: #4ade80;
  vertical-align: middle;
}

.exercise-step[data-state="unlocked"] {
  border-color: rgba(245, 158, 11, 0.35);
  background: var(--amber-dim);
}

.exercise-step[data-state="pending"] {
  opacity: 0.6;
}

.step-instruction {
  font-size: 0.9375rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.55;
}

.step-instruction.step-locked {
  color: var(--text-muted);
}

.step-unlock-msg {
  font-size: 0.8125rem;
  color: var(--amber-light);
  margin: 0;
}

.step-unlock-answer {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0.375rem 0 0;
}

.step-next-btn {
  margin-top: 0.625rem;
  padding: 0.375rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.step-next-btn:hover { background: rgba(245, 158, 11, 0.2); }

.exercise-reset-btn {
  margin-left: 0.5rem;
  padding: 0.1875rem 0.5rem;
  font-size: 0.875rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}
.exercise-reset-btn:hover { color: var(--text-secondary); border-color: var(--text-muted); }

.step-confirm-hint {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.step-input-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  align-items: center;
}

.step-input {
  flex: 1;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9375rem;
  transition: border-color 0.15s;
  outline: none;
}

.step-input:focus {
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 0 0 2px var(--amber-dim);
}

.step-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.step-submit {
  flex-shrink: 0;
}

.step-feedback {
  font-size: 0.875rem;
  margin-top: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  display: none;
  line-height: 1.5;
}

.step-feedback.correct {
  background: var(--green-dim);
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: #4ade80;
  display: block;
}

.step-feedback.wrong {
  background: var(--red-dim);
  border: 1px solid rgba(248, 81, 73, 0.2);
  color: #fca5a5;
  display: block;
}

.exercise-solution {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.exercise-solution-inner {
  background: var(--bg-elevated);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: var(--radius-sm);
  padding: 1rem 1.125rem;
}

.exercise-solution-inner > strong {
  display: block;
  font-size: 0.875rem;
  color: #4ade80;
  margin-bottom: 0.625rem;
}

.exercise-solution-html {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.7;
}

.exercise-done-banner {
  margin-top: 0.875rem;
  padding: 0.75rem 1rem;
  background: var(--green-dim);
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: var(--radius-sm);
  color: #4ade80;
  font-weight: 600;
  font-size: 0.9375rem;
  text-align: center;
}

.exercise-error {
  color: var(--red);
  font-size: 0.9375rem;
  padding: 0.75rem 1rem;
  background: var(--red-dim);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(248, 81, 73, 0.2);
}

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

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--amber);
  color: #0d1117;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 0.9375rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.01em;
}

.btn-primary:hover {
  background: var(--amber-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.9375rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}

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

/* ── Flashcards ─────────────────────────────────────────────────────────── */

.flashcard-scene {
  perspective: 1200px;
  height: 13rem;
  cursor: pointer;
  margin-bottom: 0.625rem;
}

.flashcard-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.flashcard-inner.flipped { transform: rotateY(180deg); }
.flashcard-inner.flipped .flashcard-face--front { opacity: 0; transition: opacity 0.15s; }

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.75rem;
  text-align: center;
}

.flashcard-face--front {
  background: linear-gradient(150deg, var(--bg-elevated), var(--bg-panel));
  border: 1px solid var(--border);
}

.flashcard-face--back {
  background: linear-gradient(150deg, rgba(34, 197, 94, 0.07), var(--bg-panel));
  border: 1px solid rgba(34, 197, 94, 0.22);
  transform: rotateY(180deg);
}

.flashcard-face p {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.55;
}

.flashcard-hint {
  text-align: center;
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-bottom: 1.125rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.flashcard-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flashcard-counter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

/* ── Einheit Nav Bar ────────────────────────────────────────────────────── */

.einheit-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.btn-complete {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 0.9375rem;
  padding: 0.6875rem 1.625rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
  letter-spacing: 0.01em;
}

.btn-complete:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
}

.btn-complete-done {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: var(--radius-md);
  padding: 0.6875rem 1.625rem;
  font-weight: 600;
  font-size: 0.9375rem;
  font-family: 'DM Sans', sans-serif;
}

.nav-link {
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.nav-link:hover { color: var(--amber); }

/* ── Login Page ─────────────────────────────────────────────────────────── */

.login-wrap {
  min-height: calc(100vh - 3.75rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-box { width: 100%; max-width: 400px; }

.login-header {
  text-align: center;
  margin-bottom: 2rem;
  animation: fadeUp 0.4s ease-out both;
}

.login-logo {
  width: 4rem;
  height: 4rem;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-radius: 1.125rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 8px 28px rgba(245, 158, 11, 0.4);
}

.login-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--text-primary);
}

.login-sub {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-top: 0.4375rem;
}

.login-form-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.875rem;
  animation: fadeUp 0.4s ease-out 0.08s both;
}

.form-group { margin-bottom: 1.125rem; }

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4375rem;
}

.form-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-input::placeholder { color: var(--text-muted); }

.form-input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.form-check-row {
  display: flex;
  align-items: center;
  gap: 0.5625rem;
  margin-bottom: 1.375rem;
}

.form-check-row input[type=checkbox] {
  accent-color: var(--amber);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.form-check-row label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.btn-login {
  width: 100%;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0d1117;
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.875rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.01em;
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.4);
}

/* ── Setup Section (Bevor wir beginnen) ────────────────────────────────── */

.setup-section {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
  overflow: hidden;
}

.setup-section[open] .setup-section__arrow { transform: rotate(90deg); }

.setup-section__summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.125rem 1.5rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s;
}

.setup-section__summary::-webkit-details-marker { display: none; }

.setup-section__summary:hover { background: var(--bg-elevated); }

.setup-section__icon { font-size: 1.5rem; flex-shrink: 0; }

.setup-section__summary > div {
  flex: 1;
}

.setup-section__summary > div strong {
  display: block;
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.setup-section__summary > div span {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.setup-section__arrow {
  font-size: 1.125rem;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.setup-section__body {
  border-top: 1px solid var(--border-muted);
  padding: 1.5rem 1.75rem;
  border-radius: 0;
  border: none;
  margin-bottom: 0;
  animation: none;
}

/* ── Animations ─────────────────────────────────────────────────────────── */

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

.fade-up-1 { animation: fadeUp 0.4s ease-out 0.05s both; }
.fade-up-2 { animation: fadeUp 0.4s ease-out 0.10s both; }
.fade-up-3 { animation: fadeUp 0.4s ease-out 0.15s both; }
.fade-up-4 { animation: fadeUp 0.4s ease-out 0.20s both; }
.fade-up-5 { animation: fadeUp 0.4s ease-out 0.25s both; }
.fade-up-6 { animation: fadeUp 0.4s ease-out 0.30s both; }

/* ── Exercise stats bar ─────────────────────────────────────────────────── */
.exercise-stats-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-elevated);
  border-left: 3px solid var(--amber);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.exercise-stats-bar strong { color: var(--text-primary); }
.exercise-stats-label { color: var(--text-muted); }
.exercise-stats-hint { color: #b45309; }
.exercise-stats-done { color: #4ade80; font-weight: 600; }
