/* ============================================================
   BRP Deutsch Matura – Redesign: Warm Academic
   Fraunces (Serif Display) + Atkinson Hyperlegible (Body)
   Sidebar Layout · Lazy Content · Leitner Flashcards
   ============================================================ */

/* ========== LOCAL FONTS ========== */
@font-face {
  font-family: 'Fraunces';
  src: url('fonts/fraunces-variable.woff2') format('woff2');
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('fonts/fraunces-italic-variable.woff2') format('woff2');
  font-weight: 300 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('fonts/atkinson-regular.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('fonts/atkinson-italic.woff2') format('woff2');
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

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

/* ========== DESIGN TOKENS ========== */
:root {
  /* Fonts */
  --ff-display: 'Fraunces', 'Georgia', serif;
  --ff-body: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', system-ui, sans-serif;

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

  /* Radii */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Timing */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 0.2s;
  --dur-slow: 0.35s;

  /* Sidebar */
  --sidebar-w: 260px;

  /* Module Colors */
  --clr-operatoren: #C8956B;
  --clr-textsorten: #4A9E8E;
  --clr-analyse: #5B7FA6;
  --clr-stilmittel: #8B6AAE;
  --clr-komma: #A35E9A;
  --clr-bewertung: #5AAFA0;
}

/* ========== LIGHT THEME ========== */
[data-theme="light"] {
  --bg: #FAF6F0;
  --bg-card: #FFFDF9;
  --bg-sidebar: #F5EFE6;
  --bg-hover: #EDE6DA;
  --bg-active: #E5DCCE;
  --bg-overlay: rgba(44, 36, 24, 0.4);
  --text: #2C2418;
  --text-secondary: #5C4F3D;
  --text-muted: #8C7E6A;
  --border: #E5DCCE;
  --border-strong: #D4C9B8;
  --shadow: 0 1px 3px rgba(44, 36, 24, 0.06), 0 2px 8px rgba(44, 36, 24, 0.04);
  --shadow-hover: 0 4px 12px rgba(44, 36, 24, 0.08), 0 8px 24px rgba(44, 36, 24, 0.04);
  --shadow-elevated: 0 8px 30px rgba(44, 36, 24, 0.12);
  --fc-correct: #3B7A3E;
  --fc-wrong: #B8453A;
  --fc-correct-bg: #E8F5E8;
  --fc-wrong-bg: #FDEAEA;
}

/* ========== DARK THEME ========== */
[data-theme="dark"] {
  --bg: #1A1814;
  --bg-card: #242018;
  --bg-sidebar: #1E1B16;
  --bg-hover: #2E2A22;
  --bg-active: #3A342A;
  --bg-overlay: rgba(0, 0, 0, 0.6);
  --text: #E8E0D4;
  --text-secondary: #B8AD9E;
  --text-muted: #8C7E6A;
  --border: #3A342A;
  --border-strong: #4A4238;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-elevated: 0 8px 30px rgba(0, 0, 0, 0.35);
  --fc-correct: #5CB85C;
  --fc-wrong: #E05A4F;
  --fc-correct-bg: #1E3A1E;
  --fc-wrong-bg: #3A1E1E;
}

/* ========== BASE ========== */
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--ff-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ========== LAYOUT ========== */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--dur-slow) var(--ease);
}

.content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: var(--sp-xl) var(--sp-2xl) 100px;
  max-width: 900px;
}

/* ========== SIDEBAR: BRAND ========== */
.sidebar-brand {
  padding: var(--sp-lg) var(--sp-lg) var(--sp-md);
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  font-family: var(--ff-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  display: block;
}
.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
  display: block;
}

/* ========== SIDEBAR: SEARCH ========== */
.sidebar-search {
  padding: var(--sp-sm) var(--sp-lg);
  border-bottom: 1px solid var(--border);
}
.search-wrapper {
  position: relative;
}
.search-icon {
  position: absolute;
  left: var(--sp-sm);
  top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: var(--sp-sm) var(--sp-md) var(--sp-sm) 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 0.78rem;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  outline: none;
  border-color: var(--clr-analyse);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--clr-analyse) 20%, transparent);
}
.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-elevated);
  max-height: 360px;
  overflow-y: auto;
  z-index: 110;
}
.search-results.active { display: block; }
.search-result {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-sm);
  width: 100%;
  padding: var(--sp-sm) var(--sp-md);
  border: none;
  background: none;
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--dur);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--bg-hover); }
.search-result-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.search-result-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.search-result-title {
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-snippet {
  font-size: 0.68rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-no-results {
  padding: var(--sp-md);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.search-more {
  padding: var(--sp-sm) var(--sp-md);
  text-align: center;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ========== SIDEBAR: FACH NAVIGATION ========== */
.fach-nav {
  flex: 1;
  padding: var(--sp-md) var(--sp-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fach-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--ff-body);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  text-align: left;
  width: 100%;
  position: relative;
}
.fach-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.fach-item.active {
  background: var(--bg-active);
  color: var(--text);
  font-weight: 700;
}
.fach-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fach-clr);
  flex-shrink: 0;
}
.fach-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Progress ring */
.fach-progress-ring {
  width: 22px; height: 22px;
  flex-shrink: 0;
  transform: rotate(-90deg);
}
.ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 3;
}
.ring-fill {
  fill: none;
  stroke: var(--fach-clr);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dasharray var(--dur-slow) var(--ease);
}

/* ========== SIDEBAR: FOOTER ========== */
.sidebar-footer {
  padding: var(--sp-md) var(--sp-lg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}
.fc-trigger {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--ff-body);
  font-size: 0.78rem;
  cursor: pointer;
  flex: 1;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.fc-trigger:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}
.fc-trigger svg { width: 16px; height: 16px; flex-shrink: 0; }
.fc-trigger-label { flex: 1; }
.fc-badge, .fc-badge-mobile {
  background: var(--clr-operatoren);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  min-width: 18px;
  text-align: center;
}

.theme-toggle {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur) var(--ease);
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg-hover); }
.theme-toggle svg { width: 18px; height: 18px; }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* ========== MOBILE HEADER ========== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  z-index: 90;
  align-items: center;
  padding: 0 var(--sp-md);
  gap: var(--sp-sm);
}
.mobile-menu-btn, .mobile-fc-btn {
  width: 36px; height: 36px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  position: relative;
}
.mobile-menu-btn:hover, .mobile-fc-btn:hover { background: var(--bg-hover); }
.mobile-menu-btn svg, .mobile-fc-btn svg { width: 22px; height: 22px; }
.mobile-brand {
  font-family: var(--ff-display);
  font-size: 1.2rem;
  font-weight: 800;
  flex: 1;
  text-align: center;
}
.fc-badge-mobile {
  position: absolute;
  top: 2px; right: 2px;
  font-size: 0.58rem;
  padding: 0 4px;
}

/* ========== STREAK BAR ========== */
.streak-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--sp-md);
}
.streak-flame {
  font-size: 1.4rem;
  line-height: 1;
}
.streak-info {
  flex: 1;
  min-width: 0;
}
.streak-count {
  font-family: var(--ff-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.streak-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 2px;
}
.streak-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--clr-operatoren), var(--clr-stilmittel));
  border-radius: 2px;
  transition: width 0.4s var(--ease);
}
.streak-goal {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* ========== LERNPFAD HINT ========== */
.lernpfad-hint {
  padding: var(--sp-sm) var(--sp-md);
  background: color-mix(in srgb, var(--clr-textsorten) 8%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--clr-textsorten) 20%, var(--border));
  border-radius: var(--radius);
  margin-bottom: var(--sp-md);
  font-size: 0.82rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  flex-wrap: wrap;
}
.lernpfad-icon {
  font-size: 1rem;
}
.lernpfad-link {
  border: none;
  background: none;
  color: var(--clr-textsorten);
  font-family: var(--ff-body);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.lernpfad-link:hover {
  color: var(--text);
}

/* ========== BREADCRUMB ========== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-lg);
  font-size: 0.78rem;
  color: var(--text-muted);
}
.crumb {
  font-weight: 700;
  letter-spacing: 0.03em;
}
.crumb-fach { color: var(--text-secondary); }

/* ========== SUBTOPIC TABS ========== */
.subtopic-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-lg);
  padding-bottom: var(--sp-md);
  border-bottom: 1px solid var(--border);
}
.subtopic-tab {
  padding: var(--sp-sm) var(--sp-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--ff-body);
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur) var(--ease);
}
.subtopic-tab:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}
.subtopic-tab.read {
  border-color: color-mix(in srgb, var(--fach-clr, var(--clr-operatoren)) 30%, var(--border));
}
.tab-check {
  font-size: 0.65rem;
  margin-right: 3px;
  color: var(--fach-clr, var(--clr-operatoren));
  opacity: 0.7;
}
.subtopic-tab.active .tab-check { color: #fff; opacity: 0.9; }
.subtopic-tab.active {
  background: var(--fach-clr, var(--clr-operatoren));
  border-color: var(--fach-clr, var(--clr-operatoren));
  color: #fff;
  font-weight: 700;
}

/* ========== CONTENT PANEL ========== */
.content-panel {
  min-height: 300px;
  animation: fadeIn var(--dur-slow) var(--ease);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-welcome {
  padding: var(--sp-xl) var(--sp-lg);
  color: var(--text-muted);
}
.welcome-title {
  font-family: var(--ff-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--sp-lg);
  text-align: center;
}
.welcome-strategy {
  max-width: 720px;
  margin: 0 auto;
}
.welcome-lead {
  font-size: 1rem;
  color: var(--text);
  text-align: center;
  margin-bottom: var(--sp-xl);
  line-height: 1.7;
}
.welcome-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-md);
  margin-bottom: var(--sp-xl);
}
.welcome-card {
  padding: var(--sp-md);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-align: center;
  transition: transform var(--dur), box-shadow var(--dur);
}
.welcome-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.welcome-card-num {
  font-family: var(--ff-display);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--card-clr);
  line-height: 1.1;
}
.welcome-card-label {
  font-family: var(--ff-display);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  margin: var(--sp-xs) 0;
}
.welcome-card-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.welcome-mindset {
  padding: var(--sp-lg);
  background: color-mix(in srgb, var(--clr-textsorten) 6%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--clr-textsorten) 20%, var(--border));
  border-left: 3px solid var(--clr-textsorten);
  border-radius: var(--radius);
  margin-bottom: var(--sp-xl);
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text);
}
.welcome-mindset p {
  margin-bottom: var(--sp-sm);
}
.welcome-mindset p:last-child {
  margin-bottom: 0;
}
.welcome-cta {
  text-align: center;
  font-size: 0.92rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Content fade animation */
.content-panel > * {
  animation: fadeIn var(--dur-slow) var(--ease);
}

/* Rendered subtopic content */
.subtopic-panel-header {
  font-family: var(--ff-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--sp-lg);
  padding-bottom: var(--sp-md);
  border-bottom: 2px solid var(--border);
}
.subtopic-kern, .subtopic-praxis, .subtopic-details {
  margin-bottom: var(--sp-xl);
  line-height: 1.75;
  font-size: 0.92rem;
}
.subtopic-kern p, .subtopic-praxis p, .subtopic-details p,
.detail-section p, .sub-subtopic-body p {
  margin-bottom: var(--sp-md);
}
.subtopic-kern p:last-child, .subtopic-praxis p:last-child,
.subtopic-details p:last-child, .detail-section p:last-child,
.sub-subtopic-body p:last-child {
  margin-bottom: 0;
}

/* Sections with labels */
.subtopic-kern { position: relative; }
.subtopic-praxis {
  border-left: 3px solid var(--clr-textsorten, #4A9E8E);
  background: color-mix(in srgb, var(--clr-textsorten, #4A9E8E) 4%, transparent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: var(--sp-md) var(--sp-lg);
}
.subtopic-details {
  padding: var(--sp-lg);
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Collapsible overview */
.subtopic-overview {
  margin-bottom: var(--sp-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.subtopic-overview-toggle {
  display: block;
  padding: var(--sp-sm) var(--sp-md);
  font-family: var(--ff-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-hover);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.subtopic-overview-toggle::-webkit-details-marker { display: none; }
.subtopic-overview-toggle::before {
  content: '\25B6';
  display: inline-block;
  margin-right: var(--sp-sm);
  font-size: 0.65rem;
  transition: transform 0.2s;
}
.subtopic-overview[open] > .subtopic-overview-toggle::before {
  transform: rotate(90deg);
}
.subtopic-overview-body {
  padding: var(--sp-md);
  border-top: 1px solid var(--border);
}
/* Section labels */
.section-label, .detail-label {
  display: block;
  font-family: var(--ff-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--sp-md);
}

/* Content Structure Elements */
.subtopic-kern h4, .subtopic-details h4, .subtopic-praxis h4,
.detail-section h4, .sub-subtopic-body h4 {
  font-family: var(--ff-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  margin: var(--sp-xl) 0 var(--sp-md);
  padding-bottom: var(--sp-xs);
  border-bottom: 1px solid var(--border);
}
.subtopic-kern h4:first-child, .subtopic-details h4:first-child,
.detail-section h4:first-child, .sub-subtopic-body h4:first-child {
  margin-top: 0;
}
.subtopic-kern ul, .subtopic-details ul, .subtopic-praxis ul,
.detail-section ul, .sub-subtopic-body ul {
  margin: var(--sp-sm) 0 var(--sp-lg) var(--sp-lg);
  padding: 0;
  list-style: none;
}
.subtopic-kern ul li, .subtopic-details ul li, .subtopic-praxis ul li,
.detail-section ul li, .sub-subtopic-body ul li {
  position: relative;
  padding-left: var(--sp-lg);
  margin-bottom: var(--sp-md);
  line-height: 1.7;
  font-size: 0.9rem;
}
.subtopic-kern ul li:last-child, .subtopic-details ul li:last-child,
.subtopic-praxis ul li:last-child, .detail-section ul li:last-child,
.sub-subtopic-body ul li:last-child {
  margin-bottom: 0;
}
.subtopic-kern ul li::before, .subtopic-details ul li::before,
.subtopic-praxis ul li::before, .detail-section ul li::before,
.sub-subtopic-body ul li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}
/* Nested lists */
.subtopic-kern ul ul, .subtopic-details ul ul, .subtopic-praxis ul ul,
.detail-section ul ul, .sub-subtopic-body ul ul {
  margin-top: var(--sp-sm);
  margin-bottom: var(--sp-sm);
  margin-left: var(--sp-md);
}
.subtopic-kern ul ul li::before, .subtopic-details ul ul li::before,
.subtopic-praxis ul ul li::before, .detail-section ul ul li::before,
.sub-subtopic-body ul ul li::before {
  width: 4px;
  height: 4px;
  background: var(--text-muted);
  opacity: 0.6;
  border-radius: 1px;
}
/* Ordered lists */
.subtopic-kern ol, .subtopic-details ol, .subtopic-praxis ol,
.detail-section ol, .sub-subtopic-body ol {
  margin: var(--sp-sm) 0 var(--sp-lg) var(--sp-xl);
  padding: 0;
  list-style: decimal;
  list-style-position: outside;
}
.subtopic-kern ol li, .subtopic-details ol li, .subtopic-praxis ol li,
.detail-section ol li, .sub-subtopic-body ol li {
  margin-bottom: var(--sp-md);
  padding-left: var(--sp-sm);
  line-height: 1.7;
  font-size: 0.9rem;
}
.subtopic-kern ol li:last-child, .subtopic-details ol li:last-child,
.subtopic-praxis ol li:last-child, .detail-section ol li:last-child,
.sub-subtopic-body ol li:last-child {
  margin-bottom: 0;
}
/* Inline emphasis */
.subtopic-kern strong, .subtopic-praxis strong, .subtopic-details strong,
.detail-section strong, .sub-subtopic-body strong {
  font-weight: 700;
  color: var(--text);
}

/* Content section dividers */
.subtopic-kern + .subtopic-praxis,
.subtopic-kern + .subtopic-details,
.subtopic-praxis + .subtopic-details {
  margin-top: var(--sp-lg);
}

.merkbox {
  margin: var(--sp-md) 0;
  padding: var(--sp-sm) var(--sp-md);
  border-left: 3px solid var(--clr-komma, #A35E9A);
  background: color-mix(in srgb, var(--clr-komma, #A35E9A) 6%, var(--bg));
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

/* BRP Deutsch content classes */
.beispiel {
  background: var(--bg-hover);
  border-left: 3px solid var(--clr-operatoren);
  padding: 12px 16px;
  margin: 12px 0;
  border-radius: var(--radius-sm);
}
.merke {
  background: rgba(74, 158, 142, 0.1);
  border-left: 3px solid var(--clr-textsorten);
  padding: 12px 16px;
  margin: 12px 0;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.tipp {
  background: rgba(91, 127, 166, 0.1);
  border-left: 3px solid var(--clr-analyse);
  padding: 12px 16px;
  margin: 12px 0;
  border-radius: var(--radius-sm);
}
.achtung {
  background: rgba(163, 94, 154, 0.1);
  border-left: 3px solid var(--clr-komma);
  padding: 12px 16px;
  margin: 12px 0;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.merkbox-inline {
  background: color-mix(in srgb, var(--clr-komma, #A35E9A) 8%, var(--bg));
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.84rem;
}
.zusammenfassung {
  margin: var(--sp-lg) 0 var(--sp-md);
  padding: var(--sp-md);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-hover);
  font-size: 0.85rem;
}
.zusammenfassung ul {
  margin-top: var(--sp-sm);
}
table.vergleich {
  width: 100%;
  border-collapse: collapse;
  margin: var(--sp-md) 0;
  font-size: 0.82rem;
}
table.vergleich th, table.vergleich td {
  padding: var(--sp-sm) var(--sp-md);
  border: 1px solid var(--border);
  text-align: left;
  line-height: 1.5;
}
table.vergleich th {
  background: var(--bg-hover);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.vergleich td {
  background: var(--bg-card);
}

.detail-label {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-right: var(--sp-sm);
  margin-bottom: var(--sp-xs);
  vertical-align: middle;
}
.detail-section {
  margin-bottom: var(--sp-xl);
  line-height: 1.75;
  font-size: 0.9rem;
}
.detail-section:last-child {
  margin-bottom: 0;
}

/* Personal notes */
.personal-note {
  margin: var(--sp-lg) 0;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: var(--sp-md);
  background: color-mix(in srgb, var(--clr-operatoren) 3%, var(--bg));
}
.personal-note-header {
  font-family: var(--ff-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--sp-sm);
}
.personal-note-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-sm);
  font-family: var(--ff-body);
  font-size: 0.85rem;
  line-height: 1.5;
  background: var(--bg-card);
  color: var(--text);
  resize: vertical;
  min-height: 60px;
  transition: border-color var(--dur) var(--ease);
}
.personal-note-textarea:focus {
  outline: none;
  border-color: var(--clr-operatoren);
}
.personal-note-textarea::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* Sub-subtopics (details/summary) */
.sub-subtopics {
  margin-top: var(--sp-xl);
}
.sub-subtopics-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-md);
}
.expand-all-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.72rem;
  padding: var(--sp-xs) var(--sp-sm);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.expand-all-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.sub-subtopics-label {
  font-family: var(--ff-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sub-subtopic {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--sp-md);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease);
}
.sub-subtopic[open] {
  border-color: var(--border-strong);
}
.sub-subtopic-header {
  padding: var(--sp-md) var(--sp-lg);
  font-family: var(--ff-display);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  border-left: 3px solid var(--border);
  transition: background var(--dur) var(--ease);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}
.sub-subtopic-header::-webkit-details-marker { display: none; }
.sub-subtopic-header::before {
  content: '';
  width: 6px; height: 6px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform var(--dur) var(--ease);
  flex-shrink: 0;
}
.sub-subtopic[open] > .sub-subtopic-header::before {
  transform: rotate(45deg);
}

/* Cross-Reference Links */
.xref {
  color: var(--accent, #5B7FA6);
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
  cursor: pointer;
  font-weight: 500;
  transition: color var(--dur, .2s) var(--ease, ease), border-color var(--dur, .2s) var(--ease, ease);
}
.xref:hover {
  color: var(--accent-hover, #4A6E95);
  border-bottom-style: solid;
}
.xref::before {
  content: '\2192\00a0';
  font-size: 0.85em;
  opacity: 0.6;
}
.xref-hint {
  color: var(--text-muted, #888);
  border-bottom: 1px dotted var(--text-muted, #888);
  cursor: help;
  font-style: italic;
}
.xref-hint::before {
  content: '\2192\00a0';
  font-size: 0.85em;
  opacity: 0.5;
}
.sub-subtopic-header:hover {
  background: var(--bg-hover);
}
.sub-subtopic-body {
  padding: var(--sp-lg) var(--sp-lg) var(--sp-xl);
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

/* ========== CONTENT FOOTER / LEARN BTN ========== */
.content-footer {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  padding: var(--sp-md) var(--sp-2xl);
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  pointer-events: none;
  z-index: 50;
}
.learn-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-xl);
  border: none;
  border-radius: var(--radius-pill);
  background: var(--text);
  color: var(--bg);
  font-family: var(--ff-body);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  box-shadow: var(--shadow);
}
.learn-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.learn-btn svg { width: 18px; height: 18px; }

/* ========== CONCEPT DIAGRAM ========== */
.concept-diagram {
  margin: var(--sp-xl) 0 var(--sp-lg);
  padding: var(--sp-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
}
.concept-diagram-title {
  font-family: var(--ff-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--sp-md);
  text-align: left;
}
.concept-diagram svg {
  max-width: 100%;
  height: auto;
}
.concept-diagram svg text {
  font-family: var(--ff-body);
  fill: var(--text);
}
.concept-diagram svg .diagram-node {
  fill: var(--bg-hover);
  stroke: var(--border-strong);
  stroke-width: 1.5;
}
.concept-diagram svg .diagram-node-accent {
  fill: color-mix(in srgb, var(--clr-stilmittel) 15%, var(--bg-card));
  stroke: var(--clr-stilmittel);
  stroke-width: 2;
}
.concept-diagram svg .diagram-line {
  stroke: var(--border-strong);
  stroke-width: 1.5;
  fill: none;
}
.concept-diagram svg .diagram-arrow {
  fill: var(--border-strong);
}

/* ========== ZUSAMMENFASSUNGS-BOX ========== */
.zusammenfassung-box {
  margin: var(--sp-xl) 0 var(--sp-lg);
  padding: var(--sp-lg);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--clr-stilmittel) 8%, var(--bg-card)),
    color-mix(in srgb, var(--clr-analyse) 6%, var(--bg-card))
  );
  border: 1px solid color-mix(in srgb, var(--clr-stilmittel) 20%, var(--border));
  position: relative;
}
.zusammenfassung-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, var(--clr-stilmittel), var(--clr-analyse));
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.zusammenfassung-box-title {
  font-family: var(--ff-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--sp-md);
}
.zusammenfassung-box-list {
  margin: 0;
  padding: 0 0 0 var(--sp-lg);
  counter-reset: merke;
  list-style: none;
}
.zusammenfassung-box-list li {
  position: relative;
  padding-left: var(--sp-sm);
  margin-bottom: var(--sp-sm);
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
  counter-increment: merke;
}
.zusammenfassung-box-list li::before {
  content: counter(merke);
  position: absolute;
  left: calc(-1 * var(--sp-lg));
  top: 0;
  width: 22px;
  height: 22px;
  background: var(--clr-stilmittel);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.zusammenfassung-box-list li:last-child {
  margin-bottom: 0;
}

/* ========== MICRO-QUIZ ========== */
.micro-quiz {
  margin-top: var(--sp-2xl);
  padding: var(--sp-lg);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.micro-quiz-title {
  font-family: var(--ff-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--sp-md);
}
.micro-quiz-card {
  margin-bottom: var(--sp-lg);
  padding-bottom: var(--sp-lg);
  border-bottom: 1px solid var(--border);
}
.micro-quiz-card:last-of-type {
  border-bottom: none;
  margin-bottom: var(--sp-md);
}
.micro-quiz-question {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-sm);
  line-height: 1.6;
}
.micro-quiz-options {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}
.micro-quiz-opt {
  text-align: left;
  padding: var(--sp-sm) var(--sp-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background var(--dur), border-color var(--dur);
}
.micro-quiz-opt:hover:not(:disabled) {
  background: var(--bg-hover);
}
.micro-quiz-opt.correct {
  background: color-mix(in srgb, #22c55e 15%, var(--bg));
  border-color: #22c55e;
  color: var(--text);
}
.micro-quiz-opt.wrong {
  background: color-mix(in srgb, #ef4444 12%, var(--bg));
  border-color: #ef4444;
}
.micro-quiz-opt:disabled {
  cursor: default;
  opacity: 0.8;
}
.micro-quiz-reveal {
  padding: var(--sp-sm) var(--sp-md);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
}
.micro-quiz-reveal:hover {
  background: var(--bg-hover);
}
.micro-quiz-answer {
  margin-top: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  border-left: 3px solid #22c55e;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.6;
  animation: stFadeIn 0.3s ease;
}
@keyframes stFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.micro-quiz-text-input {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}
.micro-quiz-textarea {
  width: 100%;
  padding: var(--sp-sm) var(--sp-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 0.82rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 60px;
  transition: border-color var(--dur);
}
.micro-quiz-textarea:focus {
  outline: none;
  border-color: var(--clr-stilmittel);
}
.micro-quiz-textarea:disabled {
  opacity: 0.6;
  cursor: default;
}
.micro-quiz-check {
  align-self: flex-start;
  padding: var(--sp-sm) var(--sp-md);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur);
}
.micro-quiz-check:hover {
  background: var(--bg-active);
}
.mq-user-answer, .mq-correct-answer {
  margin-bottom: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  line-height: 1.6;
}
.mq-user-answer {
  background: color-mix(in srgb, var(--clr-analyse) 10%, var(--bg));
  border-left: 3px solid var(--clr-analyse);
}
.mq-correct-answer {
  background: color-mix(in srgb, #22c55e 10%, var(--bg));
  border-left: 3px solid #22c55e;
}

.mq-source {
  margin-top: var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  background: color-mix(in srgb, var(--clr-textsorten) 8%, var(--bg));
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-xs);
}
.mq-source-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
}
.mq-source strong {
  color: var(--text);
}
.mq-source-link {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--dur), border-color var(--dur);
  margin-left: auto;
}
.mq-source-link:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.fc-source {
  margin-top: auto;
  margin-bottom: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}
.fc-source-icon {
  font-size: 0.85rem;
}
.fc-source strong {
  color: var(--text);
}

.fc-text-input {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  margin-top: var(--sp-lg);
}
.fc-textarea {
  width: 100%;
  padding: var(--sp-md);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 0.88rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 80px;
}
.fc-textarea:focus {
  outline: none;
  border-color: var(--clr-stilmittel);
}
.fc-check-btn {
  align-self: flex-start;
  padding: var(--sp-sm) var(--sp-lg);
  border: none;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-family: var(--ff-body);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--dur);
}
.fc-check-btn:hover { opacity: 0.85; }

.micro-quiz-more {
  display: block;
  width: 100%;
  padding: var(--sp-sm) var(--sp-md);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background var(--dur);
}
.micro-quiz-more:hover {
  background: var(--border);
}

/* ========== GLOSSAR TOOLTIPS ========== */
.glossar-term {
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
  position: relative;
}
.glossar-term:hover, .glossar-term:focus {
  color: var(--clr-komma);
}

/* ========== BOTTOM BAR (MOBILE) ========== */
.bottom-bar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 56px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  z-index: 90;
  justify-content: space-around;
  align-items: center;
  padding: 0 var(--sp-sm);
}
.bottom-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--sp-xs) var(--sp-sm);
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--ff-body);
  font-size: 0.62rem;
  cursor: pointer;
  transition: color var(--dur) var(--ease);
  min-width: 48px;
}
.bottom-item.active {
  color: var(--fach-clr, var(--text));
  font-weight: 700;
}
.bottom-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--fach-clr);
  transition: transform var(--dur) var(--ease);
}
.bottom-item.active .bottom-dot {
  transform: scale(1.4);
}
.bottom-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========== OVERLAY & SIDEBAR OVERLAY ========== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 999;
}
.sidebar-overlay.active {
  display: block;
  animation: fadeIn var(--dur) var(--ease);
}

/* ========== FLASHCARD OVERLAY ========== */
.flashcard-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 200;
  justify-content: center;
  align-items: center;
  padding: var(--sp-lg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.flashcard-overlay.active {
  display: flex;
}

.flashcard-container {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  margin: auto;
}

.flashcard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
}
.flashcard-progress-text {
  font-size: 0.82rem;
  opacity: 0.9;
}
.flashcard-progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  margin-top: var(--sp-xs);
}
.flashcard-progress-fill {
  height: 100%;
  background: rgba(255,255,255,0.8);
  border-radius: 2px;
  transition: width 0.4s var(--ease);
}
.flashcard-close {
  width: 40px; height: 40px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1.5rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.flashcard-close:hover { background: rgba(255,255,255,0.25); }
.flashcard-close:active { transform: scale(0.9); }

.flashcard-card {
  cursor: pointer;
}
.flashcard-face {
  border-radius: var(--radius-lg);
  padding: clamp(16px, 4vw, 32px);
  background: var(--bg-card);
  box-shadow: var(--shadow-elevated);
  display: flex;
  flex-direction: column;
  animation: fcFadeIn 0.3s ease;
}
@keyframes fcFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.flashcard-front {}
.flashcard-back { display: none; }
.flashcard-card.flipped .flashcard-front { display: none; }
.flashcard-card.flipped .flashcard-back { display: flex; }

.fc-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--sp-md);
}
.fc-question {
  font-family: var(--ff-display);
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 600;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: var(--sp-sm);
}
.fc-answer {
  font-size: clamp(0.92rem, 2vw, 1.05rem);
  line-height: 1.65;
  color: var(--text);
  margin-bottom: var(--sp-md);
}
.fc-explanation {
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: var(--sp-md);
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-md);
  line-height: 1.6;
}

.fc-options {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  margin-top: var(--sp-md);
}
.fc-option {
  padding: clamp(10px, 2.5vw, 16px) clamp(12px, 3vw, 20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: clamp(0.85rem, 2vw, 0.95rem);
  line-height: 1.5;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.fc-option:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}
.fc-option:active {
  transform: scale(0.98);
}
.fc-option.correct {
  border-color: var(--fc-correct);
  background: var(--fc-correct-bg);
  color: var(--fc-correct);
  font-weight: 700;
}
.fc-option.wrong {
  border-color: var(--fc-wrong);
  background: var(--fc-wrong-bg);
  color: var(--fc-wrong);
}

.fc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
  margin-top: auto;
}
.fc-tag {
  font-size: 0.62rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-hover);
  color: var(--text-muted);
}

.flashcard-rating {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-sm);
  margin-top: var(--sp-lg);
}
.fc-rate-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--sp-sm) var(--sp-xs);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  cursor: pointer;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.fc-rate-btn:hover {
  background: var(--bg-hover);
  transform: translateY(-1px);
}
.fc-rate-icon { font-size: 1.2rem; }
.fc-rate-label { font-size: 0.68rem; font-weight: 700; color: var(--text); }
.fc-rate-interval { font-size: 0.58rem; color: var(--text-muted); }

.fc-flip-hint {
  text-align: center;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.7);
  margin-top: var(--sp-sm);
  padding: var(--sp-xs) 0;
  flex-shrink: 0;
}

/* ========== FLASHCARD DASHBOARD ========== */
.fc-dashboard {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 190;
  justify-content: center;
  align-items: center;
  padding: var(--sp-lg);
}
.fc-dashboard.active {
  display: flex;
}
.fc-dashboard-inner {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--sp-xl);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-elevated);
}
.fc-dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-lg);
}
.fc-dashboard-header h2 {
  font-family: var(--ff-display);
  font-size: 1.2rem;
  font-weight: 700;
}
.fc-dashboard-close {
  width: 32px; height: 32px;
  border: none;
  background: var(--bg-hover);
  color: var(--text);
  font-size: 1.2rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fc-dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-md);
  margin-bottom: var(--sp-lg);
}
.fc-stat {
  text-align: center;
}
.fc-stat-value {
  font-family: var(--ff-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}
.fc-stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.fc-dashboard-filters {
  display: flex;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}
.fc-filter-select {
  flex: 1;
  padding: var(--sp-sm) var(--sp-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 0.78rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238C7E6A' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.fc-filter-select:focus {
  outline: 2px solid var(--clr-analyse);
  outline-offset: 1px;
}
.fc-dashboard-actions {
  margin-bottom: var(--sp-lg);
}
.btn-primary {
  width: 100%;
  padding: var(--sp-md);
  border: none;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-family: var(--ff-body);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--dur) var(--ease);
}
.btn-primary:hover { opacity: 0.85; }

.fc-dashboard-boxes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--sp-sm);
}
.fc-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-xs);
  padding: var(--sp-sm);
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
}
.fc-box-bar {
  width: 100%;
  background: var(--border);
  border-radius: 2px;
  min-height: 8px;
  transition: height var(--dur-slow) var(--ease);
}
.fc-box-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 700;
}
.fc-box-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
}

/* ========== LOADING SKELETON ========== */
.subtopic-loading {
  text-align: center;
  padding: var(--sp-2xl);
  color: var(--text-muted);
  font-size: 0.85rem;
}
.subtopic-loading-skeleton {
  margin-top: var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}
.subtopic-loading-skeleton > div {
  height: 14px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  animation: pulse 1.5s ease-in-out infinite;
}
.subtopic-loading-skeleton > div:nth-child(1) { width: 80%; }
.subtopic-loading-skeleton > div:nth-child(2) { width: 60%; }
.subtopic-loading-skeleton > div:nth-child(3) { width: 70%; }
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* ========== SKIP LINKS (ACCESSIBILITY) ========== */
.skip-link {
  position: fixed;
  top: -100px;
  left: var(--sp-md);
  background: var(--text);
  color: var(--bg);
  padding: var(--sp-sm) var(--sp-lg);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  z-index: 999;
  transition: top 0.2s;
  text-decoration: none;
}
.skip-link:focus {
  top: 0;
  outline: 2px solid var(--clr-analyse);
  outline-offset: 2px;
}

/* ========== TABLET RESPONSIVE (769-1024px) ========== */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --sidebar-w: 220px;
  }
  .content {
    padding: var(--sp-lg) var(--sp-lg) 100px;
  }
  .fach-name {
    font-size: 0.75rem;
  }
  .subtopic-tab {
    font-size: 0.72rem;
    padding: 6px 10px;
  }
  .content-footer {
    padding: var(--sp-md) var(--sp-lg);
  }
  .flashcard-rating {
    grid-template-columns: repeat(4, 1fr);
  }
  .fc-rate-btn {
    padding: var(--sp-xs) 2px;
  }
  .fc-rate-label {
    font-size: 0.62rem;
  }
  .fc-dashboard-stats {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-sm);
  }
  .fc-stat-value {
    font-size: 1.1rem;
  }
  .welcome-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ========== MOBILE RESPONSIVE ========== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 85vw;
    max-width: 320px;
    z-index: 1000;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-header {
    display: flex;
  }
  .bottom-bar {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start;
    padding: 0 var(--sp-xs);
    gap: var(--sp-xs);
  }
  .bottom-bar::-webkit-scrollbar { display: none; }
  .bottom-item { flex-shrink: 0; min-width: 52px; }
  .content {
    margin-left: 0;
    padding: 60px var(--sp-sm) 80px;
    max-width: 100%;
  }
  .content-footer {
    left: 0;
    bottom: 56px;
    padding: var(--sp-sm) var(--sp-md);
  }

  .breadcrumb { font-size: 0.75rem; margin-bottom: var(--sp-sm); }

  .subtopic-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: var(--sp-sm);
    gap: var(--sp-xs);
  }
  .subtopic-tabs::-webkit-scrollbar { display: none; }
  .subtopic-tab {
    white-space: nowrap;
    font-size: 0.78rem;
    padding: var(--sp-xs) var(--sp-sm);
    flex-shrink: 0;
  }

  .subtopic-panel-header {
    font-size: 1.1rem;
    margin-bottom: var(--sp-md);
    padding-bottom: var(--sp-sm);
  }

  .subtopic-kern, .subtopic-praxis, .subtopic-details {
    font-size: 0.88rem;
    margin-bottom: var(--sp-lg);
    line-height: 1.65;
  }
  .subtopic-details { padding: var(--sp-md); }
  .subtopic-praxis { padding: var(--sp-sm) var(--sp-md); }

  .subtopic-kern ul, .subtopic-details ul, .subtopic-praxis ul,
  .detail-section ul, .sub-subtopic-body ul {
    margin-left: var(--sp-md);
  }
  .subtopic-kern ul li, .subtopic-details ul li, .subtopic-praxis ul li,
  .detail-section ul li, .sub-subtopic-body ul li {
    padding-left: var(--sp-md);
    margin-bottom: var(--sp-sm);
  }

  .subtopic-kern h4, .subtopic-details h4, .subtopic-praxis h4,
  .detail-section h4, .sub-subtopic-body h4 {
    font-size: 0.85rem;
    margin: var(--sp-lg) 0 var(--sp-sm);
  }

  .merkbox, .beispiel, .merke, .tipp, .achtung {
    font-size: 0.82rem;
    padding: var(--sp-xs) var(--sp-sm);
  }
  .zusammenfassung-box {
    padding: var(--sp-sm);
  }
  .zusammenfassung-box-title {
    font-size: 0.85rem;
  }

  .sub-subtopic-header {
    padding: var(--sp-sm) var(--sp-md);
    font-size: 0.82rem;
  }
  .sub-subtopic-body {
    padding: var(--sp-sm) var(--sp-md);
    font-size: 0.84rem;
  }

  .micro-quiz { padding: var(--sp-sm); }
  .micro-quiz-question { font-size: 0.84rem; }
  .micro-quiz-opt { font-size: 0.82rem; padding: var(--sp-sm); }

  .flashcard-overlay {
    padding: var(--sp-xs);
    align-items: flex-start;
  }
  .flashcard-container {
    max-width: 100%;
    margin: 0;
  }
  .flashcard-face {
    padding: var(--sp-md);
  }
  .fc-label { font-size: 0.62rem; margin-bottom: var(--sp-sm); }
  .fc-question { font-size: 1rem; line-height: 1.5; }
  .fc-answer { font-size: 0.92rem; }
  .fc-option {
    padding: 10px 14px;
    font-size: 0.88rem;
  }

  .flashcard-rating {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-xs);
    margin-top: var(--sp-md);
  }
  .fc-rate-btn { padding: var(--sp-sm); }
  .fc-rate-icon { font-size: 1rem; }
  .fc-rate-label { font-size: 0.65rem; }
  .fc-rate-interval { font-size: 0.55rem; }

  .fc-dashboard { padding: var(--sp-sm); }
  .fc-dashboard-inner { padding: var(--sp-md); max-height: 90vh; }
  .fc-dashboard-header h2 { font-size: 1rem; }
  .fc-dashboard-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-sm);
  }
  .fc-dashboard-filters {
    flex-direction: column;
  }
  .fc-dashboard-boxes {
    grid-template-columns: repeat(3, 1fr);
  }

  .streak-bar { font-size: 0.78rem; padding: var(--sp-xs) var(--sp-sm); }

  .search-results {
    position: fixed;
    top: auto;
    left: var(--sp-sm);
    right: var(--sp-sm);
    max-height: 50vh;
  }

  .concept-diagram {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .concept-diagram svg {
    min-width: 360px;
  }

  table.vergleich {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.78rem;
  }

  .lernpfad-hint { font-size: 0.82rem; padding: var(--sp-xs) var(--sp-sm); }

  .welcome-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-sm);
  }
  .welcome-mindset {
    padding: var(--sp-md);
    font-size: 0.82rem;
  }
}

/* Extra small screens */
@media (max-width: 400px) {
  .content {
    padding: 56px var(--sp-xs) 72px;
  }
  .subtopic-panel-header {
    font-size: 1rem;
  }
  .subtopic-kern, .subtopic-praxis, .subtopic-details {
    font-size: 0.82rem;
  }
  .bottom-bar {
    gap: 0;
  }
  .bottom-label {
    font-size: 0.6rem;
  }
  .fc-dashboard-stats {
    grid-template-columns: 1fr;
  }
  .flashcard-rating {
    grid-template-columns: 1fr 1fr;
  }
  .fc-question { font-size: 0.92rem; }
  .fc-option { padding: 8px 12px; font-size: 0.84rem; }
  .fc-flip-hint { font-size: 0.7rem; }
  .welcome-grid {
    grid-template-columns: 1fr;
  }
}

/* ========== SITE FOOTER ========== */
.site-footer {
  position: fixed;
  bottom: 0;
  right: 0;
  left: var(--sidebar-w);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-xs) var(--sp-md);
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 5;
}
.footer-links { display: flex; gap: var(--sp-sm); }
.footer-link {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 0.72rem;
  text-decoration: underline; font-family: var(--ff-body);
}
.footer-link:hover { color: var(--text); }
@media (max-width: 900px) {
  .site-footer { left: 0; bottom: 56px; }
}

/* ========== LEGAL MODAL ========== */
.legal-overlay {
  display: none; position: fixed; inset: 0;
  background: var(--bg-overlay); z-index: 9999;
  justify-content: center; align-items: center;
}
.legal-overlay.active { display: flex; }
.legal-modal {
  background: var(--bg-card); border-radius: var(--radius-lg);
  max-width: 640px; width: 90%; max-height: 80vh;
  overflow-y: auto; padding: var(--sp-xl);
  box-shadow: var(--shadow-elevated); position: relative;
}
.legal-close {
  position: absolute; top: var(--sp-md); right: var(--sp-md);
  background: none; border: none; font-size: 1.5rem;
  cursor: pointer; color: var(--text-muted);
  line-height: 1; padding: var(--sp-xs);
}
.legal-close:hover { color: var(--text); }
.legal-content h2 {
  font-family: var(--ff-display); font-size: 1.3rem;
  margin-bottom: var(--sp-md);
}
.legal-content h3 {
  font-family: var(--ff-display); font-size: 1rem;
  margin: var(--sp-lg) 0 var(--sp-sm);
}
.legal-content p { margin-bottom: var(--sp-sm); line-height: 1.6; font-size: 0.88rem; }
.legal-content ul { margin: var(--sp-sm) 0 var(--sp-md) var(--sp-lg); font-size: 0.88rem; }
.legal-content li { margin-bottom: var(--sp-xs); }
.legal-content a { color: var(--text); }

/* ========== CONTENT TABLES ========== */
.content-panel table {
  border-collapse: collapse;
  width: 100%;
  margin: var(--sp-md) 0;
  font-size: 0.9rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.content-panel thead {
  background: var(--bg-hover);
}
.content-panel th {
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 0.85rem;
  text-align: left;
  padding: var(--sp-sm) var(--sp-md);
  border-bottom: 2px solid var(--border-strong);
}
.content-panel td {
  padding: var(--sp-sm) var(--sp-md);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}
.content-panel tr:last-child td {
  border-bottom: none;
}
.content-panel tr:hover td {
  background: var(--bg-hover);
}
@media (max-width: 600px) {
  .content-panel table {
    font-size: 0.82rem;
  }
  .content-panel th,
  .content-panel td {
    padding: var(--sp-xs) var(--sp-sm);
  }
}

/* ========== PRINT ========== */
@media print {
  .sidebar, .mobile-header, .bottom-bar, .content-footer,
  .flashcard-overlay, .fc-dashboard, .sidebar-overlay,
  .streak-bar, .lernpfad-hint, .skip-link, .sidebar-search,
  .micro-quiz, .learn-btn, .fc-trigger, .theme-toggle { display: none !important; }
  .content {
    margin-left: 0;
    padding: 20px;
    max-width: 100%;
  }
  body { background: #fff; color: #000; font-size: 11pt; }
  .subtopic-tabs { flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
  .subtopic-tab { font-size: 9pt; padding: 2px 8px; border: 1px solid #999; }
  .subtopic-panel { display: block !important; page-break-inside: avoid; }
  .sub-subtopic { break-inside: avoid; }
  .sub-subtopic[open] summary { font-weight: 700; }
  .merkbox, .beispiel, .merke, .tipp, .achtung, .zusammenfassung-box {
    border: 1px solid #666;
    background: #f5f5f5 !important;
    break-inside: avoid;
    padding: 8px 12px;
    margin: 8px 0;
  }
  .breadcrumb { font-size: 10pt; color: #666; margin-bottom: 8px; }
  h2, h3, h4 { page-break-after: avoid; }
  table { border-collapse: collapse; width: 100%; font-size: 10pt; }
  table th, table td { border: 1px solid #999; padding: 4px 8px; }
  a { color: #000; text-decoration: underline; }
  .concept-diagram svg { max-width: 100%; height: auto; }
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ========== SELECTION ========== */
::selection {
  background: var(--clr-operatoren);
  color: #fff;
}
