/* =====================================================================
   ICF-Lernsystem – Designsystem  (Linear / Stripe-inspiriert)
   Ruhiges, produkt-poliertes Look-and-feel. Akzent: edles Petrol/Teal.
   Barrierefrei (WCAG 2.1 AA): Kontraste >= 4.5:1, sichtbarer Fokus,
   skalierbare rem-Schrift, prefers-reduced-motion, prefers-contrast,
   forced-colors. Reines CSS, kein Build-Schritt.
   ===================================================================== */

:root {
  /* ---- Neutralpalette (kühles Schiefergrau) ---- */
  --bg: #eef1f5;
  --bg-grund: #e7ebf0;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --surface-3: #eff3f6;
  --text: #1f2937;
  --text-leise: #4b5765;          /* >= 4.5:1 auch auf getönten Flächen */
  --text-zart: #5d6876;           /* abgedunkelt für Placeholder-Reserve */
  --rahmen: #e1e6ec;
  --rahmen-stark: #cdd5de;
  --rahmen-fein: #edf1f5;

  /* ---- Marke: Petrol / Teal (kein Lila/Indigo) ---- */
  --primar: #0f766e;
  --primar-stark: #115e59;
  --primar-tief: #0c4a47;
  --primar-leise: #e6f2f0;
  --primar-zart: #f1f8f7;
  --primar-rahmen: #bfdedb;
  --primar-text: #0c4a47;
  --auf-primar: #ffffff;

  /* ---- Status (kontraststark, gedeckt) ---- */
  --erfolg: #15803d;
  --erfolg-text: #136229;         /* >= 4.5:1 auf hellgrün */
  --erfolg-bg: #eaf6ef;
  --erfolg-rahmen: #bfe3cb;
  --fehler: #b3261e;
  --fehler-text: #9f201a;
  --fehler-bg: #fcecea;
  --fehler-rahmen: #f1b8b2;
  --warn: #845300;                /* >= 4.5:1 auf hellgelb */
  --warn-bg: #fbf2dd;
  --warn-rahmen: #ecd4a0;
  --info: #155e75;
  --info-bg: #e6f1f5;
  --info-rahmen: #b9d8e2;

  /* ---- Header-Verlauf (dezent dunkel, leicht petrol getönt) ---- */
  --kopf-1: #15212c;
  --kopf-2: #16303a;
  --kopf-text: #f4f7f9;
  --kopf-text-leise: #c4d1d9;     /* heller für Reserve über 4.5:1 */
  --kopf-rahmen: rgba(255, 255, 255, 0.10);

  /* ---- Schrift ----
     --serif = „Überschriften-Schrift": Standard jetzt serifenlos (straighter).
     Die Darstellung-Einstellung kann sie auf die echte Serife umstellen. */
  --serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", "Consolas", "Liberation Mono", monospace;

  /* ---- Radien (bewusst straff/gerade) ---- */
  --r-xs: 5px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-pille: 999px;

  /* ---- Schatten (weich, mehrlagig) ---- */
  --schatten-fein: 0 1px 2px rgba(16, 28, 40, 0.05), 0 1px 1px rgba(16, 28, 40, 0.04);
  --schatten-karte: 0 1px 2px rgba(16, 28, 40, 0.05), 0 4px 12px rgba(16, 28, 40, 0.06), 0 12px 28px rgba(16, 28, 40, 0.05);
  --schatten-hover: 0 2px 4px rgba(16, 28, 40, 0.06), 0 8px 20px rgba(16, 28, 40, 0.10), 0 20px 44px rgba(16, 28, 40, 0.08);
  --schatten-kopf: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 10px 30px rgba(10, 18, 26, 0.18);

  /* ---- Fokusring (abgedunkelt für robusteren Rand-/Hintergrundkontrast) ---- */
  --fokus: #178c82;
  --fokus-schatten: 0 0 0 3px rgba(23, 140, 130, 0.45);

  --takt: 160ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

/* =====================================================================
   Grundlagen
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  color: var(--text);
  line-height: 1.22;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  text-wrap: balance;
}
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.08rem; font-weight: 600; }
h4 { font-size: 1.0rem; font-weight: 600; margin-top: 1.35rem; }
h4:first-child { margin-top: 0; }

p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--primar-stark); text-underline-offset: 2px; }
a:hover { color: var(--primar-tief); }

code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--surface-3);
  border: 1px solid var(--rahmen);
  border-radius: var(--r-xs);
  padding: 0.1em 0.4em;
  color: var(--primar-text);
}

strong { font-weight: 600; color: var(--text); }
em { font-style: italic; }

ul { margin: 0; padding: 0; }

/* =====================================================================
   Fokus – sichtbar auf JEDEM interaktiven Element
   ===================================================================== */
:focus-visible {
  outline: 3px solid var(--fokus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
/* Fallback für Browser ohne :focus-visible */
a:focus, button:focus, input:focus, select:focus, textarea:focus,
[tabindex]:focus {
  outline: 3px solid var(--fokus);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

input[type="radio"], input[type="checkbox"] { accent-color: var(--primar); }

/* =====================================================================
   Skip-Link
   ===================================================================== */
.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -120%;
  z-index: 1000;
  background: var(--primar-stark);
  color: var(--auf-primar);
  padding: 0.7rem 1.1rem;
  border-radius: var(--r-sm);
  font-weight: 600;
  box-shadow: var(--schatten-hover);
  transition: top var(--takt);
}
.skip-link:focus { top: 0.75rem; color: var(--auf-primar); outline-color: #ffffff; }

/* =====================================================================
   Kopf / Header
   ===================================================================== */
/* =====================================================================
   App-Shell: feste Seitenleiste (Marke/Navigation/Konto) + Arbeitsbereich.
   „Fokus-Produkt": dichte, ruhige Werkstatt-Optik.
   ===================================================================== */
.app-shell {
  --sidebar-w: 248px;
  --topbar-h: 56px;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar content";
}

/* ---- Topbar (voll breit): Menü/Einklappen + Marke links, Umschalter rechts ---- */
.topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem 0 0.75rem;
  color: var(--kopf-text);
  background: var(--kopf-2); /* flach */
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.topbar-links { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.topbar-rechts { display: flex; align-items: center; gap: 0.8rem; }
.marke-name {
  margin: 0;
  font-size: 1.14rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* ---- Seitenleiste (unter der Topbar) ---- */
.seitenleiste {
  grid-area: sidebar;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.9rem 0.85rem;
  color: var(--kopf-text);
  background: var(--kopf-2);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

/* Marken-Logo (in der Topbar) */
.marke-logo {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  color: #ffffff;
  background: var(--primar);
}
.marke-logo svg { width: 19px; height: 19px; }

/* Navigation */
.seiten-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.nav-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--kopf-text-leise);
  font: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  padding: 0.6rem 0.7rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  position: relative;
  transition: background var(--takt), color var(--takt);
}
.nav-ikon { flex: 0 0 auto; width: 20px; height: 20px; opacity: 0.9; }
.nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #ffffff; }
.nav-item.aktiv {
  background: rgba(15, 118, 110, 0.34);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.nav-item.aktiv::before {
  content: "";
  position: absolute;
  left: -0.85rem;
  top: 0.55rem;
  bottom: 0.55rem;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #4fd1c5;
}
.nav-item.aktiv .nav-ikon { opacity: 1; }
.nav-item:focus-visible { outline: 2px solid #7fe3d8; outline-offset: -2px; }

/* Fuß: Ansicht-Umschalter + Konto + Status */
.seiten-fuss {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.9rem 0.5rem 0.2rem;
  border-top: 1px solid var(--kopf-rahmen);
}

/* Ansicht-Umschalter (Segmented Control) – dunkel, in der Topbar */
.modus { display: flex; align-items: center; gap: 0.55rem; }
.modus-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--kopf-text-leise);
}
.modus-schalter {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--r-pille);
}
.modus-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--kopf-text-leise);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  min-height: 2rem;
  border-radius: var(--r-pille);
  cursor: pointer;
  transition: background var(--takt), color var(--takt);
}
.modus-btn:hover { color: #ffffff; }
.modus-btn[aria-pressed="true"] { background: #ffffff; color: var(--primar-tief); }
.modus-btn:focus-visible { outline-color: #ffffff; outline-offset: 2px; }

/* Konto */
.konto { display: flex; flex-direction: column; gap: 0.5rem; }
.konto-info {
  font-size: 0.82rem;
  color: var(--kopf-text);
  font-weight: 600;
  padding-left: 0.1rem;
}
.konto-aktionen { display: flex; flex-direction: column; gap: 0.35rem; }
.konto-btn {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--kopf-text-leise);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--r-xs);
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  transition: background var(--takt), color var(--takt), border-color var(--takt);
}
.konto-ikon { width: 18px; height: 18px; flex: 0 0 auto; }
.konto-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.22);
}
.konto-btn:focus-visible { outline-color: #ffffff; outline-offset: 2px; }

/* Topbar-Buttons: Menü (nur mobil) + Einklappen (nur Desktop) */
.menu-toggle,
.leiste-toggle {
  appearance: none;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.05);
  color: var(--kopf-text);
  cursor: pointer;
  transition: background var(--takt), color var(--takt);
}
.menu-toggle { width: 40px; height: 40px; display: none; } /* nur mobil */
.leiste-toggle { width: 34px; height: 34px; }              /* nur Desktop */
.menu-toggle:hover,
.leiste-toggle:hover { color: #fff; background: rgba(255, 255, 255, 0.10); }
.menu-toggle svg { width: 22px; height: 22px; }
.leiste-toggle svg { width: 18px; height: 18px; }
.menu-toggle:focus-visible,
.leiste-toggle:focus-visible { outline-color: #fff; outline-offset: 2px; }

.nav-backdrop { display: none; }

/* Echte Nutzer sehen den Ansicht-Umschalter nicht (Rolle kommt vom Server). */
body.rolle-nutzer .modus { display: none; }

/* ---- Eingeklappte Leiste (Rail, nur Desktop) ---- */
@media (min-width: 901px) {
  .app-shell.leiste-schmal { --sidebar-w: 66px; }
  .leiste-schmal .seitenleiste { padding-left: 0.55rem; padding-right: 0.55rem; }
  .leiste-schmal .nav-item > span,
  .leiste-schmal .konto-info,
  .leiste-schmal .konto-btn > span,
  .leiste-schmal .status-anzeige { display: none; }
  .leiste-schmal .leiste-toggle { transform: rotate(180deg); }
  .leiste-schmal .nav-item { justify-content: center; padding-left: 0.4rem; padding-right: 0.4rem; }
  .leiste-schmal .nav-item.aktiv::before { left: -0.55rem; }
  .leiste-schmal .konto-btn { justify-content: center; }
}

/* ---- Arbeitsbereich (Inhalts-Spalte) ----
   Block (kein Flex): sonst schrumpft .inhalt mit margin:0 auto auf Inhaltsbreite. */
.arbeitsbereich { grid-area: content; min-width: 0; }

/* ---- Mobile: Topbar bleibt, Sidebar wird Off-Canvas-Schublade ---- */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "content";
  }
  .menu-toggle { display: grid; }
  .leiste-toggle { display: none; }
  .seitenleiste {
    position: fixed;
    top: var(--topbar-h); left: 0;
    width: 264px;
    height: calc(100vh - var(--topbar-h));
    z-index: 60;
    transform: translateX(-100%);
    transition: transform var(--takt);
  }
  .app-shell.nav-offen .seitenleiste { transform: none; }
  .app-shell.nav-offen .nav-backdrop {
    display: block;
    position: fixed;
    top: var(--topbar-h); left: 0; right: 0; bottom: 0;
    z-index: 55;
    background: rgba(10, 18, 26, 0.5);
  }
}

/* ---- Anmelde-/Ersteinrichtungs-Overlay ---- */
body.auth-aktiv { overflow: hidden; }
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--kopf-2);   /* flach */
}
.auth-overlay[hidden] { display: none; }
.auth-box {
  width: min(420px, 100%);
  background: var(--surface, #ffffff);
  border: 1px solid var(--rahmen);
  border-radius: 16px;
  box-shadow: var(--schatten-hover);
  padding: 1.75rem 1.6rem 1.6rem;
}
.auth-titel {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  color: var(--primar-text);
}
.auth-hinweis {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--text);
  opacity: 0.85;
  line-height: 1.5;
}
.auth-form { display: flex; flex-direction: column; gap: 0.55rem; }
.auth-form h2 { margin: 0 0 0.3rem; font-size: 1.12rem; color: var(--text); }
.auth-form label { font-weight: 600; font-size: 0.88rem; color: var(--text); }
.auth-form input { width: 100%; box-sizing: border-box; }
.auth-form button[type="submit"] { margin-top: 0.7rem; width: 100%; }
.auth-form .sekundaer { width: 100%; margin-top: 0.4rem; }
.auth-form .status { margin-top: 0.5rem; }

/* ---- Status (dezent im Fuß der Seitenleiste) ---- */
.status-anzeige {
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--kopf-text-leise);
  opacity: 0.82;
  padding: 0 0.1rem;
}
.status-anzeige:empty { display: none; }
.status-anzeige.ok { color: #7fe3d8; opacity: 1; }
.status-anzeige.warn { color: #f2cd7a; opacity: 1; }
.status-anzeige.fehler { color: #f6a89f; opacity: 1; }

/* =====================================================================
   Hauptinhalt-Layout
   ===================================================================== */
.inhalt {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1.8rem 2rem 3rem;
  display: block;
}
@media (max-width: 900px) { .inhalt { padding: 1.25rem 1.1rem 2.5rem; } }
.ansicht { display: block; }
.ansicht[hidden] { display: none; }

#projekt-liste-bereich,
#projekt-detail-bereich,
#ansicht-einstellungen,
.reiter {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
[hidden] { display: none !important; }

/* =====================================================================
   Karten
   ===================================================================== */
.karte {
  background: var(--surface);
  border: 1px solid var(--rahmen);
  border-radius: var(--r-lg);
  box-shadow: var(--schatten-karte);
  padding: 1.5rem 1.6rem;
  position: relative;
}
.karte > h2,
.karte > h3 { margin-top: 0; }
.karte > h2 + .status,
.karte > h3 + .status { margin-top: -0.25rem; }

/* Hinweis-/Hilfe-Karte etwas zurückgenommen (flach) */
.hinweis-karte {
  background: var(--primar-zart);
  border-color: var(--primar-rahmen);
  box-shadow: none;
}

/* =====================================================================
   Projekt-Kopf (Detail)
   ===================================================================== */
.projekt-kopf {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem 1.25rem;
}
.projekt-kopf-titel { grid-column: 2; min-width: 0; }
.projekt-kopf-titel h2 { margin: 0; }
.projekt-kopf-titel .hinweis { margin: 0.15rem 0 0; }
.projekt-kopf > #zurueck-btn { grid-column: 1; }
.projekt-kopf > .aktionen { grid-column: 3; margin: 0; }
/* Inline-Bearbeitung des Projektkopfs */
.projekt-kopf-titel .feld { margin-bottom: 0.6rem; }
.projekt-kopf-titel .aktionen { margin-top: 0.4rem; }

/* =====================================================================
   Unter-Tabs (innerhalb eines Projekts)
   ===================================================================== */
.unter-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.3rem;
  background: var(--surface-2);
  border: 1px solid var(--rahmen);
  border-radius: var(--r-md);
  box-shadow: var(--schatten-fein);
  flex-wrap: wrap;
}
.unter-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-leise);
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.5rem 0.95rem;
  min-height: 2.5rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--takt), color var(--takt), border-color var(--takt), box-shadow var(--takt);
}
.unter-tab:hover { color: var(--text); background: var(--surface-3); }
.unter-tab.aktiv, .unter-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--primar-text);
  border-color: var(--rahmen);
  box-shadow: var(--schatten-fein);
}

/* =====================================================================
   Formulare
   ===================================================================== */
form { margin: 0; }

.feld { margin-bottom: 1.1rem; }
.feld:last-child { margin-bottom: 0; }

.feld > label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.feld-zeile {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.1rem;
  margin-bottom: 1.1rem;
}
.feld-zeile .feld { margin-bottom: 0; }

input[type="text"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--rahmen-stark);
  border-radius: var(--r-sm);
  padding: 0.6rem 0.75rem;
  min-height: 2.75rem;
  box-shadow: var(--schatten-fein);
  transition: border-color var(--takt), box-shadow var(--takt);
}
textarea {
  min-height: 6rem;
  line-height: 1.55;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.86rem;
}
input::placeholder, textarea::placeholder { color: var(--text-leise); }

input:hover, select:hover, textarea:hover { border-color: #b7c0cb; }

input:focus, select:focus, textarea:focus {
  border-color: var(--primar);
  box-shadow: var(--fokus-schatten);
  outline: none;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-leise) 50%),
    linear-gradient(135deg, var(--text-leise) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) center,
    calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
  cursor: pointer;
}

input[type="file"] {
  padding: 0.45rem 0.6rem;
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  margin-right: 0.85rem;
  padding: 0.45rem 0.85rem;
  color: var(--primar-text);
  background: var(--primar-leise);
  border: 1px solid var(--primar-rahmen);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--takt);
}
input[type="file"]::file-selector-button:hover { background: #d8ebe8; }

/* Checkbox-Zeile */
.check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-weight: 500 !important;
  font-size: 0.95rem !important;
  cursor: pointer;
  margin-bottom: 0 !important;
}
.check input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  min-height: 0;
  margin: 0.15rem 0 0;
  flex: 0 0 auto;
  cursor: pointer;
}
.check span { color: var(--text); }

/* Schlüssel-/Inline-Zeile (Feld + Button nebeneinander) */
.key-zeile {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
}
.key-zeile input, .key-zeile select { flex: 1 1 auto; }
.key-zeile .sekundaer { flex: 0 0 auto; align-self: stretch; }

/* Fieldset (Modell pro Schritt) */
.modell-fieldset {
  border: 1px solid var(--rahmen);
  border-radius: var(--r-md);
  padding: 1.1rem 1.25rem 1.25rem;
  margin: 0 0 1.1rem;
  background: var(--surface-2);
}
.modell-fieldset legend {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  padding: 0 0.5rem;
  color: var(--text);
}

/* =====================================================================
   Buttons
   ===================================================================== */
.aktionen {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1.1rem;
}

button {
  appearance: none;
  font: inherit;
  cursor: pointer;
}

/* Primärbutton */
button[type="submit"],
.aktionen > button:not(.sekundaer),
button.klein:not(.sekundaer),
#lern-erzeugen-btn,
#test-erzeugen-btn {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--auf-primar);
  background: var(--primar);   /* flach, kein Verlauf */
  border: 1px solid var(--primar-stark);
  border-radius: var(--r-sm);
  padding: 0.6rem 1.15rem;
  min-height: 2.75rem;
  box-shadow: none;
  transition: background var(--takt), box-shadow var(--takt), transform var(--takt);
}
button[type="submit"]:hover,
.aktionen > button:not(.sekundaer):hover,
button.klein:not(.sekundaer):hover {
  background: var(--primar-stark);
}
button[type="submit"]:active,
.aktionen > button:not(.sekundaer):active { transform: translateY(1px); }

/* Sekundärbutton */
.sekundaer {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--rahmen-stark);
  border-radius: var(--r-sm);
  padding: 0.6rem 1.05rem;
  min-height: 2.75rem;
  box-shadow: var(--schatten-fein);
  transition: background var(--takt), border-color var(--takt), color var(--takt);
}
.sekundaer:hover { background: var(--surface-2); border-color: #b7c0cb; color: var(--text); }
.sekundaer:active { background: var(--surface-3); }

/* Kleine Variante */
.klein {
  font-size: 0.85rem !important;
  padding: 0.4rem 0.8rem !important;
  min-height: 2.4rem !important;
  border-radius: var(--r-xs) !important;
}

/* Gefahr / destruktiv */
.gefahr {
  color: var(--fehler-text);
  border-color: var(--fehler-rahmen);
  background: var(--surface);
}
.gefahr:hover {
  background: var(--fehler);
  border-color: var(--fehler);
  color: #ffffff;
}

button:disabled,
.sekundaer:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
  transform: none;
  box-shadow: none;
}

/* =====================================================================
   Status-Meldungen (.status + Zustände)
   ===================================================================== */
.status {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: var(--text-leise);
  min-height: 1.2em;
}
.status:empty { margin: 0; min-height: 0; }

.status.lädt,
.status[class~="lädt"] {
  color: var(--info);
  font-weight: 500;
}
.status.erfolg {
  color: var(--erfolg-text);
  font-weight: 600;
}
.status.fehler {
  color: var(--fehler-text);
  font-weight: 600;
}
/* Status mit Akzentfläche, wenn nicht leer */
.status.erfolg:not(:empty),
.status.fehler:not(:empty),
.status[class~="lädt"]:not(:empty) {
  display: block;
  padding: 0.55rem 0.85rem;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
}
.status.erfolg:not(:empty) { background: var(--erfolg-bg); border-color: var(--erfolg-rahmen); }
.status.fehler:not(:empty) { background: var(--fehler-bg); border-color: var(--fehler-rahmen); }
.status[class~="lädt"]:not(:empty) { background: var(--info-bg); border-color: var(--info-rahmen); }

/* =====================================================================
   Hinweise / Leer-Hinweise
   ===================================================================== */
.hinweis {
  color: var(--text-leise);
  font-size: 0.86rem;
  line-height: 1.55;
  margin: 0.4rem 0 0;
}
.feld .hinweis:first-of-type { margin-top: 0.5rem; }
/* Ein einleitender Hinweis (nicht das letzte Element seines Containers) braucht
   Abstand nach unten, damit folgende Felder/Feldzeilen nicht ankleben. */
.hinweis:not(:last-child) { margin-bottom: 1rem; }

.leer-hinweis {
  color: var(--text-leise);
  font-size: 0.95rem;
  text-align: center;
  padding: 1.75rem 1rem;
  margin: 0;
  background: var(--surface-2);
  border: 1px dashed var(--rahmen-stark);
  border-radius: var(--r-md);
}

/* Aufzählungen */
.aufzaehlung {
  margin: 0.4rem 0 0;
  padding-left: 1.25rem;
  list-style: disc;
}
.aufzaehlung li { margin-bottom: 0.5rem; }
.aufzaehlung li:last-child { margin-bottom: 0; }

/* =====================================================================
   Projekt-Übersicht: Projekt-Karten (JS-erzeugt: .projekt-karte)
   ===================================================================== */
#projekt-liste {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}
.projekt-karte {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  text-align: left;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--rahmen);
  border-radius: var(--r-md);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--schatten-fein);
  cursor: pointer;
  transition: border-color var(--takt), box-shadow var(--takt), transform var(--takt);
}
.projekt-karte:hover {
  border-color: var(--primar-rahmen);
  box-shadow: var(--schatten-hover);
  transform: translateY(-2px);
}
.projekt-karte:active { transform: translateY(0); }
.pk-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.pk-meta {
  font-size: 0.85rem;
  color: var(--text-leise);
}

/* =====================================================================
   Listen-Zeilen (JS-erzeugt: Dokumente / Lerninhalte / Tests)
   ===================================================================== */
#dokumente-liste, #lern-liste, #test-liste {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}
.liste-zeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--rahmen);
  border-radius: var(--r-md);
  padding: 0.85rem 1.05rem;
  box-shadow: var(--schatten-fein);
  transition: border-color var(--takt), box-shadow var(--takt);
}
.liste-zeile:hover { border-color: var(--rahmen-stark); box-shadow: var(--schatten-karte); }
.lz-haupt { min-width: 0; flex: 1 1 16rem; }
.lz-titel {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.lz-meta {
  font-size: 0.84rem;
  color: var(--text-leise);
  margin-top: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.lz-aktionen {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

/* Auswahl-Dialog (natives <dialog>, JS-erzeugt): Dokument einem weiteren
   Projekt zuordnen. Tastatur-/Fokus-/Esc-Verhalten kommt vom <dialog>. */
.auswahl-dialog {
  border: 1px solid var(--rahmen-stark);
  border-radius: 10px;
  padding: 1.25rem 1.4rem;
  max-width: 26rem;
  width: calc(100% - 2rem);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 14px 40px rgba(15, 23, 32, 0.22);
}
.auswahl-dialog::backdrop {
  background: rgba(15, 23, 32, 0.42);
}
.auswahl-dialog h3 {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
}
.auswahl-dialog .dialog-hinweis {
  margin: 0 0 1rem;
  color: var(--text-leise);
  font-size: 0.9rem;
}
.auswahl-dialog .feld {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.2rem;
}
.auswahl-dialog select {
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--rahmen-stark);
  border-radius: 8px;
  font: inherit;
  background: var(--surface);
  color: inherit;
}
.auswahl-dialog .dialog-aktionen {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* =====================================================================
   Marken / Badges (JS-erzeugt: .marke + ok/warn/info/korrigiert)
   ===================================================================== */
.marke {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  padding: 0.28rem 0.55rem;
  border-radius: var(--r-pille);
  border: 1px solid var(--rahmen-stark);
  background: var(--surface-3);
  color: var(--text-leise);
  white-space: nowrap;
  vertical-align: middle;
}
.marke.ok { background: var(--erfolg-bg); border-color: var(--erfolg-rahmen); color: var(--erfolg-text); }
.marke.ok::before { content: "✓"; font-weight: 700; }
.marke.warn { background: var(--warn-bg); border-color: var(--warn-rahmen); color: var(--warn); }
.marke.warn::before { content: "!"; font-weight: 700; }
.marke.info { background: var(--info-bg); border-color: var(--info-rahmen); color: var(--info); }
.marke.korrigiert { background: var(--primar-leise); border-color: var(--primar-rahmen); color: var(--primar-text); }
.marke.korrigiert::before { content: "✎"; }

/* =====================================================================
   Wissensmodell-Anzeige (JS-erzeugt)
   ===================================================================== */
#analyse-inhalt h4, #lern-ansicht-inhalt h4 { color: var(--primar-text); }
.zusammenfassung {
  font-size: 1.0rem;
  color: var(--text-leise);
  line-height: 1.6;
  border-left: 3px solid var(--primar-rahmen);
  padding-left: 0.9rem;
  margin: 0.25rem 0 0.5rem;
}

.begriff-liste {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.begriff-liste > li {
  background: var(--surface-2);
  border: 1px solid var(--rahmen);
  border-radius: var(--r-md);
  padding: 0.8rem 0.95rem;
  line-height: 1.55;
}
.begriff-name {
  font-weight: 700;
  color: var(--primar-text);
}
.begriff-liste em { color: var(--text-leise); }

/* Leichte Sprache: eigenständige, gleichwertige Variante */
.leichte-sprache {
  display: block;
  margin-top: 0.55rem;
  padding: 0.65rem 0.8rem;
  background: var(--primar-zart);
  border: 1px solid var(--primar-rahmen);
  border-radius: var(--r-sm);
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--text);
}
.leichte-sprache::before {
  content: "Leichte Sprache";
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primar-stark);
  margin-bottom: 0.3rem;
}

/* Klassifikations-Tabellen */
.skala {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0.6rem 0 0.4rem;
  border: 1px solid var(--rahmen);
  border-radius: var(--r-md);
  overflow: hidden;
  font-size: 0.92rem;
}
.skala caption {
  caption-side: top;
  text-align: left;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  padding: 0 0 0.5rem;
}
.skala th, .skala td {
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--rahmen);
  vertical-align: top;
}
.skala thead th {
  background: var(--surface-2);
  color: var(--text-leise);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.skala tbody tr:last-child td { border-bottom: none; }
.skala tbody tr:nth-child(even) td { background: var(--surface-2); }
.skala td:first-child {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--primar-text);
  white-space: nowrap;
}

/* JSON-Details / pre */
details {
  margin-top: 1.25rem;
  border: 1px solid var(--rahmen);
  border-radius: var(--r-md);
  background: var(--surface-2);
  overflow: hidden;
}
summary {
  cursor: pointer;
  padding: 0.7rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-leise);
  list-style-position: inside;
}
summary:hover { color: var(--text); background: var(--surface-3); }
details[open] summary { border-bottom: 1px solid var(--rahmen); }
pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
}

/* =====================================================================
   Lernmodul-Anzeige (JS-erzeugt: article.lernmodul)
   ===================================================================== */
.lernmodul {
  max-width: 70ch;
  line-height: 1.7;
}
.lernmodul h4 {
  font-size: 1.15rem;
  margin-top: 1.6rem;
  padding-top: 0.3rem;
  color: var(--primar-text);
}
.lernmodul h4:first-of-type { margin-top: 0.5rem; }
.lernmodul p { font-size: 1.02rem; color: var(--text); }
.niveau-marke {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--primar-text);
  background: var(--primar-leise);
  border: 1px solid var(--primar-rahmen);
  border-radius: var(--r-pille);
  padding: 0.3rem 0.7rem;
  margin: 0 0 1rem;
}

/* Leichte Sprache: eigene, gut lesbare Darstellung. Große serifenlose Schrift,
   1,8 Zeilenhöhe, linksbündig, hoher Kontrast; jeder Satz bleibt in seiner
   eigenen Zeile (white-space: pre-line erhält die von der KI gesetzten Umbrüche). */
.leichte-sprache-ansicht {
  max-width: 60ch;
  font-size: 1.25rem;
  line-height: 1.8;
  text-align: left;
}
.leichte-sprache-ansicht p:not(.niveau-marke) {
  font-size: 1.25rem;
  line-height: 1.8;
  white-space: pre-line;
  margin: 0 0 1.1rem;
  color: var(--text);
}
.leichte-sprache-ansicht h4 { font-size: 1.4rem; margin-top: 2rem; }
.leichte-sprache-ansicht li { font-size: 1.2rem; line-height: 1.7; margin-bottom: 0.6rem; }
/* Der Prüf-Hinweis behält seine kompakte Info-Note-Größe (nicht pre-line). */
.leichte-sprache-ansicht .ls-pruef-hinweis { white-space: normal; }

/* =====================================================================
   Test / Fragen (JS-erzeugt: fieldset.frage, .option, .aufloesung)
   ===================================================================== */
#test-fragen {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.frage {
  border: 1px solid var(--rahmen);
  border-radius: var(--r-md);
  padding: 1.1rem 1.25rem 1.2rem;
  margin: 0;
  background: var(--surface);
  box-shadow: var(--schatten-fein);
}
.frage legend {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.45;
  padding: 0 0.5rem;
  color: var(--text);
  max-width: 100%;
}
.frage textarea { margin-top: 0.3rem; font-family: var(--sans); font-size: 0.95rem; }

.option {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--rahmen);
  border-radius: var(--r-sm);
  margin-top: 0.55rem;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--takt), background var(--takt);
}
.option:hover { border-color: var(--primar-rahmen); background: var(--primar-zart); }
.option:focus-within { border-color: var(--primar); box-shadow: var(--fokus-schatten); }
.option input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0.2rem 0 0;
  flex: 0 0 auto;
  cursor: pointer;
}
.option label {
  flex: 1;
  cursor: pointer;
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--text);
}

/* Auflösungen */
.aufloesung {
  margin: 0.85rem 0 0;
  padding: 0.7rem 0.9rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--rahmen);
  font-size: 0.92rem;
  line-height: 1.6;
  background: var(--surface-2);
}
.aufloesung.korrekt {
  background: var(--erfolg-bg);
  border-color: var(--erfolg-rahmen);
  color: var(--erfolg-text);
}
.aufloesung.falsch {
  background: var(--fehler-bg);
  border-color: var(--fehler-rahmen);
  color: var(--fehler-text);
}
.aufloesung.muster {
  background: var(--info-bg);
  border-color: var(--info-rahmen);
  color: var(--info);
}
.aufloesung strong { color: inherit; }

/* =====================================================================
   Nutzer-/Admin-Modus
   ===================================================================== */
body.modus-nutzer .admin-nur { display: none !important; }
/* Zielgruppen-Filter nur im Nutzer-Modus zeigen */
.nutzer-zielgruppe { display: none; }
body.modus-nutzer .nutzer-zielgruppe { display: block; }
body.modus-nutzer .nutzer-zielgruppe.feld { margin-bottom: 1.1rem; }

/* =====================================================================
   Fuß
   ===================================================================== */
.fuss {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1.75rem 2.5rem;
  color: var(--text-leise);      /* angehoben für >= 4.5:1 auf Body */
  font-size: 0.84rem;
  border-top: 1px solid var(--rahmen);
}
.fuss p { margin: 0; }

/* =====================================================================
   Screenreader-Only-Utility
   ===================================================================== */
.sr-nur {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 760px) {
  .kopf-zeile { padding: 1.25rem 1.1rem 0.9rem; gap: 0.9rem; }
  .tabs { padding: 0 1.1rem; flex-wrap: wrap; }
  .status-anzeige { width: 100%; max-width: 100%; margin: 0.25rem 0 0; }
  .inhalt { padding: 1.4rem 1.1rem 2.5rem; }
  .karte { padding: 1.2rem 1.15rem; border-radius: var(--r-md); }
  .projekt-kopf { grid-template-columns: 1fr; }
  .projekt-kopf > #zurueck-btn,
  .projekt-kopf-titel,
  .projekt-kopf > .aktionen { grid-column: 1; }
  .key-zeile { flex-direction: column; align-items: stretch; }
  .key-zeile .sekundaer { align-self: stretch; }
  .liste-zeile { flex-direction: column; align-items: flex-start; }
  .lz-aktionen { width: 100%; }
}

/* =====================================================================
   Bewegung reduzieren
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .projekt-karte:hover { transform: none; }
}

/* =====================================================================
   Höherer Kontrast (Systemwunsch)
   ===================================================================== */
@media (prefers-contrast: more) {
  :root {
    --rahmen: #9aa6b2;
    --rahmen-stark: #6f7c89;
    --text-leise: #3a4753;
    --text-zart: #44505c;
    --primar: #0c4a47;
    --primar-stark: #0a3d3a;
  }
  .karte, .liste-zeile, .frage { border-width: 1.5px; }
  :focus-visible { outline-width: 3px; }
}

/* =====================================================================
   Forced Colors (Windows-Kontrastmodus): native Select-Pfeil sichern
   ===================================================================== */
@media (forced-colors: active) {
  select {
    appearance: auto;
    background-image: none;
    padding-right: 0.75rem;
  }
  .tab.aktiv, .tab[aria-selected="true"],
  .unter-tab.aktiv, .unter-tab[aria-selected="true"] {
    border-bottom: 3px solid Highlight;
  }
  .modus-btn[aria-pressed="true"] { outline: 2px solid Highlight; }
}

/* =====================================================================
   OCR-Option in Dokument-Zeilen (kompakter Chip mit Checkbox)
   ===================================================================== */
.ocr-mini {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-leise);
  padding: 0.32rem 0.62rem;
  border: 1px solid var(--rahmen-stark);
  border-radius: var(--r-xs);
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
  transition: border-color var(--takt), color var(--takt);
}
.ocr-mini:hover { border-color: var(--primar-rahmen); color: var(--primar-text); }
.ocr-mini input { width: 1rem; height: 1rem; margin: 0; flex: 0 0 auto; }

/* =====================================================================
   Info-Hinweis (z. B. OCR-Erläuterung über der Dokumententabelle)
   ===================================================================== */
.info-note {
  margin: 0 0 1rem;
  padding: 0.75rem 0.95rem;
  background: var(--info-bg);
  border: 1px solid var(--info-rahmen);
  border-left: 4px solid var(--info);
  border-radius: var(--r-xs);
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.55;
}
.info-note strong { color: var(--info); }

/* =====================================================================
   Farbwähler (Darstellungs-Einstellungen)
   ===================================================================== */
input[type="color"] {
  width: 100%;
  max-width: 140px;
  height: 2.4rem;
  padding: 0.2rem;
  border: 1px solid var(--rahmen-stark);
  border-radius: var(--r-sm);
  background: #fff;
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
input[type="color"]:focus { outline: none; border-color: var(--primar); box-shadow: var(--fokus-schatten); }

/* =====================================================================
   Fortschrittsanzeige (Analyse / OCR)
   ===================================================================== */
.fortschritt {
  margin: 0.25rem 0 1rem;
  padding: 0.85rem 1rem;
  background: var(--primar-zart);
  border: 1px solid var(--primar-rahmen);
  border-radius: var(--r-sm);
}
.fortschritt-kopf {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.fortschritt-text { font-weight: 600; color: var(--primar-text); font-size: 0.95rem; }
.fortschritt-prozent { font-weight: 700; color: var(--primar-text); font-variant-numeric: tabular-nums; }
.fortschritt-bahn {
  height: 0.7rem;
  background: var(--surface-3);
  border-radius: var(--r-pille);
  overflow: hidden;
}
.fortschritt-balken {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primar), var(--primar-stark));
  border-radius: var(--r-pille);
  transition: width 0.35s ease;
}
/* Unbestimmter (laufender) Balken, wenn kein Prozentwert bekannt ist. */
.fortschritt.unbestimmt .fortschritt-balken {
  width: 40% !important;
  transition: none;
  animation: fortschritt-lauf 1.3s ease-in-out infinite;
}
@keyframes fortschritt-lauf {
  0% { margin-left: -42%; }
  100% { margin-left: 102%; }
}
@media (prefers-reduced-motion: reduce) {
  .fortschritt.unbestimmt .fortschritt-balken {
    animation: none;
    width: 100% !important;
    margin-left: 0;
    opacity: 0.6;
  }
}

/* =====================================================================
   Wissensmodell-Kopf (Dokumentbezug) + strukturierter Editor
   ===================================================================== */
.analyse-kopf {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.analyse-kopf-titel { flex: 1 1 16rem; }
.analyse-kopf-titel h3 { margin: 0; }
.analyse-quelle {
  margin: 0.2rem 0 0;
  font-size: 0.92rem;
  color: var(--text-leise);
  font-weight: 600;
}
.analyse-kopf .aktionen { margin-top: 0; }

/* Editor-Blöcke */
.editor-block {
  border: 1px solid var(--rahmen);
  border-radius: var(--r-md);
  padding: 1rem 1.1rem 1.1rem;
  margin: 0 0 1.1rem;
  background: var(--surface-2);
}
.editor-block legend {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--primar-text);
  padding: 0 0.45rem;
}
.ed-liste { display: grid; gap: 0.85rem; margin-bottom: 0.85rem; }
/* Prosa-Felder im Editor: normale Schrift statt Monospace (das ist nur für JSON). */
.editor-block textarea { font-family: var(--sans); font-size: 1rem; line-height: 1.5; }

/* Eine bearbeitbare Zeile (Begriff = Karte, Kernaussage/Lernziel = Zeile) */
.ed-row {
  background: var(--surface);
  border: 1px solid var(--rahmen);
  border-radius: var(--r-sm);
  padding: 0.85rem 1rem;
}
.ed-row .feld { margin-bottom: 0.7rem; }
.ed-row .feld:last-child { margin-bottom: 0; }
.ed-row-haupt { flex: 1 1 auto; }
.ed-row-fuss { margin-top: 0.4rem; }

/* Kernaussage/Lernziel: Inhalt + Entfernen nebeneinander */
.ed-kernaussage, .ed-lernziel {
  display: flex;
  gap: 0.85rem;
  align-items: flex-end;
}
.ed-kernaussage .ed-row-haupt, .ed-lernziel .ed-row-haupt { min-width: 0; }
.ed-lernziel .ed-row-haupt { display: flex; flex-wrap: wrap; gap: 0.85rem; }
.ed-lernziel .ed-row-haupt .feld:first-child { flex: 1 1 14rem; }
.ed-kernaussage [data-remove], .ed-lernziel [data-remove] { flex: 0 0 auto; }

@media (max-width: 560px) {
  .ed-kernaussage, .ed-lernziel { flex-direction: column; align-items: stretch; }
}
.ed-abschnitt .ed-row-haupt { min-width: 0; }

/* =====================================================================
   Lernmodul-Zusätze: Verständnisfragen, Glossar
   ===================================================================== */
#lern-vf-block, #lern-glossar-block, #kurs-uebungen-block {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rahmen);
}
.glossar { margin: 0.5rem 0 0; }
.glossar dt { font-weight: 700; color: var(--primar-stark); margin-top: 0.7rem; }
.glossar dd { margin: 0.15rem 0 0; }
.glossar dd .leichte-sprache { margin-top: 0.4rem; }

/* =====================================================================
   Kurs: Navigation (Lektion N von M) + Weiter/Zurück
   ===================================================================== */
.kurs-navi { margin: 1.1rem 0 1.25rem; }
.kurs-navi-buttons { justify-content: space-between; margin-top: 1.5rem; }
#kurs-intro { margin-bottom: 0.5rem; }

/* =====================================================================
   Wissen (projektübergreifende Begriffssuche)
   ===================================================================== */
#wissen-suche { width: 100%; box-sizing: border-box; }
.wissen-treffer { display: flex; flex-direction: column; gap: 1rem; }
.wissen-karte { padding: 1.15rem 1.3rem; }
.wissen-kopf {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.wissen-kopf h3 { margin: 0; }
.wissen-badges { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.wissen-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primar-text);
  background: var(--primar-leise);
  border: 1px solid var(--primar-rahmen);
  border-radius: var(--r-xs);
  padding: 0.12rem 0.5rem;
}
.wissen-karte > p { margin: 0.55rem 0 0; color: var(--text); }
.wissen-ls {
  border-left: 3px solid var(--primar-rahmen);
  padding-left: 0.7rem;
  color: var(--text-leise);
}
.wissen-ls-marke {
  display: inline-block;
  margin-right: 0.45rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--primar-text);
}
.wissen-vork-titel { font-size: 0.82rem; color: var(--text-leise); margin-top: 0.9rem !important; }
.wissen-vork {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.wissen-quelle {
  appearance: none;
  text-align: left;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--primar-stark);
  background: var(--surface-2);
  border: 1px solid var(--rahmen);
  border-radius: var(--r-xs);
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  transition: background var(--takt), border-color var(--takt);
}
.wissen-quelle:hover { background: var(--surface-3); border-color: var(--rahmen-stark); }

/* =====================================================================
   Druck / Als PDF speichern (nur den angezeigten Inhalt)
   ===================================================================== */
@media print {
  body * { visibility: hidden; }
  #lern-ansicht-bereich, #lern-ansicht-bereich *,
  #kurs-ansicht-bereich, #kurs-ansicht-bereich * { visibility: visible; }
  #lern-ansicht-bereich, #kurs-ansicht-bereich {
    position: absolute; left: 0; top: 0; width: 100%;
    box-shadow: none; border: none; padding: 0;
  }
  /* Interaktive/Bearbeitungs-Teile nicht mitdrucken */
  #lern-ansicht-aktionen, #kurs-ansicht-aktionen,
  #lern-struktur-form, #lern-edit-form, #kurs-json-form,
  #lern-vf-form .aktionen, #kurs-uebungen-form .aktionen,
  .kurs-navi, .kurs-navi-buttons, .fortschritt { display: none !important; }
  body { background: #fff; }
  a { color: #000; text-decoration: underline; }
}