/*
 * Förder-Radar — Minimal-UI (S6 / #7 → Redesign structured form).
 * Zero Dependencies, keine externen Fonts/CDN. Alles lokal, intern/privat.
 * Farben mit Blick auf WCAG-AA-Kontrast gewählt.
 */

:root {
  /* Flächen / Text */
  --c-bg: #f4f6f8;
  --c-surface: #ffffff;
  --c-border: #d4dae0;
  --c-text: #1c2733;        /* auf #fff ~ 13:1 */
  --c-text-leise: #404d58;  /* A11Y-1: auf #f4f6f8 ~ 4.7:1 (war #4a5663) */
  --c-primaer: #0b5c8a;     /* auf #fff ~ 5.6:1, weißer Text darauf ~ 5.6:1 */
  --c-primaer-dunkel: #084766;
  --c-primaer-hell: #e8f1f6;
  --c-link: #0b5c8a;

  /* Begründungs-Bullets */
  --c-positiv: #1b6b3a;     /* auf #fff ~ 5.5:1 */
  --c-negativ: #404d58;     /* A11Y-2: ≥4.5:1 auf Panel-BG #e8f1f6 (war #5d6873) */

  /* Status */
  --c-fehler-bg: #fdecea;
  --c-fehler-text: #8a1f12; /* auf hellrot ~ 7:1 */
  --c-fehler-rand: #d9897f;
  --c-info-bg: #e8f1f6;
  --c-info-text: #084766;

  /* Deadline-Buckets (Dringlichkeit, §3.4) — Text/BG je AA-kontrastiert */
  --c-bucket-7-bg: #fdecea;   --c-bucket-7-text: #8a1f12;
  --c-bucket-14-bg: #fdf0e2;  --c-bucket-14-text: #8a4b10;
  --c-bucket-30-bg: #fcf7e0;  --c-bucket-30-text: #6b5710;
  --c-bucket-60-bg: #e8f1ea;  --c-bucket-60-text: #1b6b3a;

  /* Chips */
  --c-chip-bg: #eef2f5;
  --c-chip-border: #c6d0d9;
  --c-chip-text: #1c2733;
  --c-chip-aktiv-bg: #0b5c8a;
  --c-chip-aktiv-border: #084766;
  --c-chip-aktiv-text: #ffffff;
  --c-chip-impliziert-bg: #ddeef8;
  --c-chip-impliziert-border: #8bb8d4;

  --radius: 8px;
  --gap: 16px;
  --maxw: 880px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
}

/* Visuell verborgen, aber Screenreader-zugänglich */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Tastatur-Sprunglink: nur sichtbar bei Fokus */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--c-primaer);
  color: #fff;
  padding: 10px 16px;
  z-index: 10;
}
.skip-link:focus {
  left: 8px;
  top: 8px;
}

/* Sichtbarer Fokus für alle interaktiven Elemente */
:focus-visible {
  outline: 3px solid var(--c-primaer);
  outline-offset: 2px;
}

a { color: var(--c-link); }
a:hover { text-decoration: none; }

.kopf,
.hauptinhalt,
.fusszeile {
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gap);
}

.kopf {
  padding-top: 28px;
  padding-bottom: 8px;
}
/* Marke: AI:AT-Logo neben Titel + Untertitel (dezentes Co-Branding) */
.marke {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.marke-logo {
  flex: 0 0 auto;
  width: 34px;
  height: 45px;
  margin-top: 3px;
}
.marke-text {
  min-width: 0;
}
.kopf h1 {
  margin: 0 0 4px;
  font-size: 1.7rem;
}
.untertitel {
  margin: 0 0 8px;
  color: var(--c-text-leise);
}
.hinweis {
  margin: 0;
  font-size: 0.85rem;
  color: var(--c-text-leise);
}

.hauptinhalt {
  padding-bottom: 16px;
}

/* ---- Modus-Umschalter (Chat ⇄ Formular) ---- */
.modus-umschalter {
  margin-top: 14px;
}
.modus-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--c-chip-bg);
  border: 1px solid var(--c-chip-border);
  border-radius: 999px;
}
.modus-tab {
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--c-primaer);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 20px;
  min-height: 44px;   /* Touch-Target */
  cursor: pointer;
}
.modus-tab[aria-selected="true"] {
  background: var(--c-primaer);
  color: #fff;
  border-color: var(--c-primaer-dunkel);
}
.modus-tab[aria-selected="false"]:hover {
  background: var(--c-primaer-hell);
}
.modus-tab:focus-visible {
  outline: 3px solid var(--c-primaer);
  outline-offset: 2px;
}
.modus-erklaerung {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--c-text-leise);
  line-height: 1.45;
}
.modus-erklaerung strong {
  color: var(--c-text);
}

/* ---- Chat-Panel ---- */
.chat-panel h2 {
  margin: 0 0 12px;
}
.chat-verlauf {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px 2px;
  margin-bottom: 12px;
}
.chat-nachricht {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chat-nachricht--assistant {
  align-self: flex-start;
  background: var(--c-primaer-hell);
  border: 1px solid #b6d2e0;
  color: var(--c-text);
  border-bottom-left-radius: 2px;
}
.chat-nachricht--user {
  align-self: flex-end;
  background: var(--c-primaer);
  color: #fff;
  border-bottom-right-radius: 2px;
}
.chat-rolle {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.75;
  margin-bottom: 2px;
}

/* „denkt nach…"-Indikator */
.chat-denkt {
  margin: 0 0 12px;
  padding: 8px 14px;
  font-size: 0.9rem;
  color: var(--c-text-leise);
  font-style: italic;
}
.chat-denkt::after {
  content: "";
  display: inline-block;
  width: 12px; height: 12px;
  margin-left: 8px;
  vertical-align: -1px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  /* A11Y-19: Spinner ganz ausblenden statt nur einzufrieren (kein Rest-Bogen). */
  .chat-denkt::after { animation: none; display: none; }
}

/* Degrade-/Fehler-Hinweis */
.chat-hinweis {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.45;
  background: var(--c-info-bg);
  border: 1px solid #b6d2e0;
  border-left: 4px solid var(--c-primaer);
  color: var(--c-info-text);
}
.chat-hinweis.fehler {
  background: var(--c-fehler-bg);
  border-color: var(--c-fehler-rand);
  border-left-color: var(--c-fehler-text);
  color: var(--c-fehler-text);
  font-weight: 600;
}

/* Direkte Handlungspfade unter dem Chat-Hinweis (z. B. needsKey) */
.chat-hinweis-aktionen {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 12px;
}
.btn-chat-hinweis {
  font-size: 0.9rem;
  padding: 8px 16px;
  min-height: 44px;   /* Touch-Target */
}

/* „Das hab ich verstanden"-Zusammenfassung */
.chat-zusammenfassung {
  margin: 0 0 12px;
  padding: 14px 16px;
  background: var(--c-info-bg);
  border: 1px solid #b6d2e0;
  border-radius: var(--radius);
}
.chat-zusammenfassung h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.chat-zusammenfassung dl {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 0;
  font-size: 0.92rem;
}
.chat-zusammenfassung > dl > div { white-space: normal; }
.chat-zusammenfassung dt { font-weight: 600; display: inline; }
.chat-zusammenfassung dd { display: inline; margin: 0 0 0 4px; }

/* Eingabe */
.chat-form {
  margin-top: 4px;
}
.chat-eingabe {
  width: 100%;
  resize: vertical;
  min-height: 56px;
}
.chat-aktionen {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

@media (max-width: 560px) {
  .chat-nachricht { max-width: 100%; }
  .chat-aktionen .btn { width: 100%; }
  /* A11Y-17: kein Resize-Griff auf schmalen Viewports (Touch-Konflikt). */
  .chat-eingabe { resize: none; }
}

/* ---- Panel / Formular ---- */
.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
}
.panel h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
}

.feld-gruppe {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--gap);
  flex: 1 1 0;
  min-width: 0;
}
.feld-gruppe label {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.95rem;
}
.feld-reihe {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}

/* Pflichtfeld- und Optional-Marker */
.pflicht-marker {
  color: var(--c-fehler-text);
  margin-left: 2px;
}
.optional-marker {
  font-weight: 400;
  color: var(--c-text-leise);
  font-size: 0.88em;
}

/* Feld-Hilfetext */
.feld-hilfe {
  margin: 0 0 8px;
  font-size: 0.88rem;
  color: var(--c-text-leise);
  line-height: 1.4;
}
.feld-hilfe em { font-style: italic; }

/* Feld-Fehler (inline) */
.feld-fehler {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: var(--c-fehler-text);
  font-weight: 600;
}

input,
select,
textarea {
  font: inherit;
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 10px 12px;
  min-height: 44px;   /* Touch-Target */
  width: 100%;
}
textarea { resize: vertical; min-height: 88px; }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--c-primaer);
}

input:disabled {
  background: var(--c-bg);
  color: var(--c-text-leise);
  cursor: not-allowed;
}

/* ---- Chips ---- */
.chip-gruppe {
  border: none;
  padding: 0;
  margin: 0 0 var(--gap);
}
.chip-gruppe legend {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
  padding: 0;
  /* A26: legend ist Block-Level — display:block statt fragilem float:left
     (kein nachgelagertes clear:both mehr nötig). */
  display: block;
  width: 100%;
}
.chip-hinweis {
  font-weight: 400;
  font-size: 0.85em;
  color: var(--c-text-leise);
  margin-left: 6px;
}
.chip-liste {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 2px;
}
.chip-liste--inline {
  display: inline-flex;
}
.chip-laden {
  color: var(--c-text-leise);
  font-size: 0.9rem;
  margin: 0;
}

/* Das eigentliche Chip-Element: <label> wrapping <input type="checkbox"> + <span> */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: var(--c-chip-bg);
  border: 1.5px solid var(--c-chip-border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--c-chip-text);
  min-height: 44px;         /* Touch-Target */
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
  user-select: none;
}
@media (prefers-reduced-motion: reduce) {
  .chip { transition: none; }
}

/* Die echte Checkbox: versteckt aber erreichbar */
.chip-checkbox {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
  /* Reset width/min-height von input-Regel */
  min-height: unset !important;
}

/* Aktivierter Chip (Checkbox checked) */
.chip:has(.chip-checkbox:checked) {
  background: var(--c-chip-aktiv-bg);
  border-color: var(--c-chip-aktiv-border);
  color: var(--c-chip-aktiv-text);
}

/* Chip mit Tastaturfokus auf der versteckten Checkbox → Fokus-Ring am Label */
.chip:has(.chip-checkbox:focus-visible) {
  outline: 3px solid var(--c-primaer);
  outline-offset: 2px;
}

/* Implizierter Chip (durch Branche/Vorhaben-Typ erschlossen, noch nicht explizit gewählt) */
.chip--impliziert {
  background: var(--c-chip-impliziert-bg);
  border-color: var(--c-chip-impliziert-border);
}
.chip--impliziert:has(.chip-checkbox:checked) {
  background: var(--c-chip-aktiv-bg);
  border-color: var(--c-chip-aktiv-border);
  color: var(--c-chip-aktiv-text);
}

.chip:hover:not(:has(.chip-checkbox:checked)) {
  background: var(--c-primaer-hell);
  border-color: var(--c-primaer);
}

/* Erkannte-Themen Preview (unter der Chip-Gruppe) */
.erkannte-themen-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: -8px 0 var(--gap);
  font-size: 0.88rem;
}
.erkannte-themen-label {
  color: var(--c-text-leise);
  font-weight: 600;
  flex: 0 0 auto;
}
.chip-preview {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  background: var(--c-chip-impliziert-bg);
  border: 1px solid var(--c-chip-impliziert-border);
  border-radius: 999px;
  font-size: 0.875rem;   /* A11Y-3: lesbarer (war 0.82rem) */
  color: var(--c-info-text);
}

/* ---- Themen-Details (collapsible) ---- */
.themen-details {
  margin-bottom: var(--gap);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 0;
  background: var(--c-bg);
}
.themen-details[open] {
  background: var(--c-surface);
}
.themen-summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 14px;
  list-style: none;         /* WebKit */
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.themen-summary::-webkit-details-marker { display: none; }
/* A11Y-13: dekoratives Border-Dreieck statt Text-Glyph "▶" (kein Textknoten,
   wird von Screenreadern nicht vorgelesen). */
.themen-summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 0.45em solid var(--c-text-leise);
  border-top: 0.32em solid transparent;
  border-bottom: 0.32em solid transparent;
  display: inline-block;
  transition: transform 150ms ease;
  flex: 0 0 auto;
  align-self: center;
}
.themen-details[open] .themen-summary::before {
  transform: rotate(90deg);
}
@media (prefers-reduced-motion: reduce) {
  .themen-summary::before { transition: none; }
}
.themen-summary:focus-visible {
  outline: 3px solid var(--c-primaer);
  outline-offset: 2px;
  border-radius: 6px;
}
.themen-summary-sub {
  font-weight: 400;
  font-size: 0.85em;
  color: var(--c-text-leise);
}
.themen-details .chip-liste {
  padding: 4px 14px 14px;
}

/* ---- Erweiterte Optionen (collapsible) ---- */
.erweitert-details {
  margin-bottom: var(--gap);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  background: var(--c-bg);
}
.erweitert-details[open] {
  background: var(--c-surface);
}
.erweitert-summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 14px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.erweitert-summary::-webkit-details-marker { display: none; }
/* A11Y-13: dekoratives Border-Dreieck statt Text-Glyph "▶" (siehe themen-summary). */
.erweitert-summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 0.45em solid var(--c-text-leise);
  border-top: 0.32em solid transparent;
  border-bottom: 0.32em solid transparent;
  display: inline-block;
  transition: transform 150ms ease;
  flex: 0 0 auto;
}
.erweitert-details[open] .erweitert-summary::before {
  transform: rotate(90deg);
}
@media (prefers-reduced-motion: reduce) {
  .erweitert-summary::before { transition: none; }
}
.erweitert-summary:focus-visible {
  outline: 3px solid var(--c-primaer);
  outline-offset: 2px;
  border-radius: 6px;
}
.erweitert-inhalt {
  padding: 4px 14px 14px;
}

/* ---- Gesuchte Summe + "weiß noch nicht" ---- */
.summe-reihe {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.summe-reihe input[type="number"] {
  flex: 1 1 160px;
  min-width: 120px;
}
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  font-size: 0.92rem;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;         /* Touch-Target */
  margin-bottom: 0;
}
.toggle-label input[type="checkbox"] {
  /* Reset from general input rule */
  width: auto;
  min-height: unset;
  padding: 0;
  border-radius: 3px;
  flex: 0 0 auto;
  accent-color: var(--c-primaer);
}

/* ---- Conditional-Reveal Hinweis (Internationalisierung) ---- */
.hinweis-box {
  background: #fff8e6;
  border: 1px solid #e8c97a;
  border-left: 4px solid #c8a840;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: var(--gap);
  font-size: 0.9rem;
  color: #3d2e00;
  line-height: 1.45;
}

/* ---- Taxonomy-Ladefehler ---- */
.taxonomy-fehler {
  background: var(--c-fehler-bg);
  color: var(--c-fehler-text);
  border: 1px solid var(--c-fehler-rand);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.92rem;
  margin-bottom: var(--gap);
}

.aktionen {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 6px;
  padding: 12px 20px;
  min-height: 44px;   /* Touch-Target */
  cursor: pointer;
  border: 1px solid transparent;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primaer {
  background: var(--c-primaer);
  color: #fff;
}
.btn-primaer:hover:not(:disabled) { background: var(--c-primaer-dunkel); }

.btn-sekundaer {
  background: var(--c-surface);
  color: var(--c-primaer);
  border-color: var(--c-primaer);
}
.btn-sekundaer:hover:not(:disabled) { background: var(--c-info-bg); }

/* M1: „noch nicht bereit"-Zustand des Chat-Such-Buttons. Optisch zurückhaltend
   (gedämpft), aber KLICKBAR — ein Klick zeigt, welche Felder noch fehlen.
   Kein `not-allowed`-Cursor: der Button ist bedienbar, nicht gesperrt. */
.btn--noch-nicht-bereit {
  opacity: 0.7;
}
.btn--noch-nicht-bereit:hover { opacity: 1; }

/* ---- Status-/Fehlerzeile ---- */
.status {
  max-width: var(--maxw);
  margin: 16px auto 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.status.fehler {
  background: var(--c-fehler-bg);
  color: var(--c-fehler-text);
  border-color: var(--c-fehler-rand);
}
.status.info {
  background: var(--c-info-bg);
  color: var(--c-info-text);
  border-color: #b6d2e0;
}
.status.laden::after {
  content: "";
  display: inline-block;
  width: 14px; height: 14px;
  margin-left: 8px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  /* A11Y-19: Spinner ausblenden (Lade-Text trägt die Info). */
  .status.laden::after { animation: none; display: none; }
}

/* ---- Ergebnisse ---- */
.ergebnisse {
  margin-top: 8px;
}
.ergebnis-kopf {
  margin: 24px 0 8px;
  font-size: 1.25rem;
}
/* Klarstellung „Ranking, kein Hard-Filter" direkt unter der Ergebnis-Überschrift. */
.ergebnis-hinweis {
  margin: 0 0 14px;
  font-size: 0.88rem;
  color: var(--c-text-leise);
  line-height: 1.4;
}
.leer-hinweis {
  background: var(--c-info-bg);
  color: var(--c-info-text);
  border: 1px solid #b6d2e0;
  border-radius: var(--radius);
  padding: 16px;
}

/* profileThemen (aus Server-Antwort) */
.profile-themen-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.88rem;
}
.profile-themen-label {
  color: var(--c-text-leise);
  font-weight: 600;
}

/* Ergebnis-Themen-Chips */
.chip-ergebnis {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  background: var(--c-chip-impliziert-bg);
  border: 1px solid var(--c-chip-impliziert-border);
  border-radius: 999px;
  font-size: 0.875rem;   /* A11Y-3: lesbarer (war 0.82rem) */
  color: var(--c-info-text);
}

/* matchedThemen Chips in Karte */
.matched-themen {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 0.88rem;
}
.matched-themen-label {
  color: var(--c-text-leise);
  font-weight: 600;
}

.karte {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: var(--gap);
}
.karte-kopf {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.rang {
  font-weight: 700;
  color: var(--c-text-leise);
}
.karte-name { margin: 0; font-size: 1.1rem; }
.karte-traeger {
  margin: 0 0 12px;
  color: var(--c-text-leise);
  font-size: 0.95rem;
}

/* Scores */
.scores {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--c-text-leise);
}
.score-total {
  font-weight: 700;
  color: var(--c-text);
}
.score-bar {
  display: inline-block;
  height: 8px;
  width: 120px;
  max-width: 40vw;
  background: var(--c-border);
  border-radius: 4px;
  overflow: hidden;
  vertical-align: middle;
}
.score-bar > span {
  display: block;
  height: 100%;
  background: var(--c-primaer);
}

/* Mini-Badge: Score-Dimension */
.score-dim {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  white-space: nowrap;
}
.score-dim-label {
  color: var(--c-text-leise);
}
.score-dim-wert {
  font-weight: 600;
  color: var(--c-text);
}
.score-dim-wert.ka {
  color: var(--c-text-leise);
  font-style: italic;
}

/* Eckdaten */
.eckdaten {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  font-size: 0.92rem;
}
.eckdaten dt { font-weight: 600; display: inline; }
.eckdaten dd { display: inline; margin: 0 0 0 4px; }
.eckdaten > div { white-space: nowrap; }

/* M4: gebündelte Sammelzeile für quellseitig fehlende Förderquote/Summe. */
.eckdaten-fehlend {
  margin: -4px 0 12px;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--c-text-leise);
}

/* M5: Erklärzeile, wenn keine thematische Überschneidung vorliegt. */
.matched-themen-leer {
  margin: 0 0 10px;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--c-text-leise);
}

/* H2: Score-Mikrolabel (nicht bewertet / schwache Passung). */
.score-mikrolabel {
  margin-left: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  font-style: italic;
  color: var(--c-text-leise);
}

/* H2: Score-Bar „nicht bewertet" — gestrichelter, leerer Rahmen statt Fill,
   eindeutig verschieden vom echten 0-Score (gefüllter, aber leerer Balken). */
.score-bar--unbewertet {
  background: transparent;
  border: 1px dashed var(--c-border);
}
.score-bar--unbewertet > span {
  background: transparent;
}

/* H1: Subhead über den schwachen Treffern („Weniger passend"). */
.weniger-passend-kopf {
  margin: 28px 0 12px;
  font-size: 1.05rem;
  color: var(--c-text-leise);
  border-top: 1px solid var(--c-border);
  padding-top: 16px;
}
.weniger-passend-sub {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--c-text-leise);
}

/* H1: gedämpfte Karten-Variante für schwache Treffer (bestehende Tokens). */
.karte--schwach {
  background: var(--c-bg);
  opacity: 0.85;
}
.karte--schwach .karte-name {
  color: var(--c-text-leise);
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-7  { background: var(--c-bucket-7-bg);  color: var(--c-bucket-7-text); }
.badge-14 { background: var(--c-bucket-14-bg); color: var(--c-bucket-14-text); }
.badge-30 { background: var(--c-bucket-30-bg); color: var(--c-bucket-30-text); }
.badge-60 { background: var(--c-bucket-60-bg); color: var(--c-bucket-60-text); }

/* Begründung */
.begruendung {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  font-size: 0.92rem;
}
.begruendung li { display: flex; gap: 8px; padding: 2px 0; }
.begruendung .marker { font-weight: 700; flex: 0 0 auto; }
.passt-weil .marker { color: var(--c-positiv); }
.passt-nicht .marker { color: var(--c-negativ); }
.passt-nicht { color: var(--c-text-leise); }

/* Provenienz + Attribution */
.provenienz {
  font-size: 0.85rem;
  color: var(--c-text-leise);
  margin: 12px 0 6px;
  padding-top: 10px;
  border-top: 1px solid var(--c-border);
}
.provenienz .trenner { margin: 0 6px; }

/* PFLICHT (Legal §7.1): sichtbare Attribution je Karte */
.attribution {
  font-size: 0.82rem;
  color: var(--c-text-leise);
  margin: 0;
  font-style: italic;
}

/* Antrags-Absatz + Kosten */
.antrag {
  background: var(--c-info-bg);
  border: 1px solid #b6d2e0;
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 8px;
}
/* A11Y-5/6: Überschrift ist jetzt ein <h2> (Hierarchie), Optik bleibt gleich. */
.antrag h2 { margin: 0 0 8px; font-size: 1.05rem; }
.antrag-text { margin: 0 0 10px; white-space: pre-wrap; }
.kosten {
  margin: 0;
  font-size: 0.82rem;
  color: var(--c-text-leise);
}

/* ---- Deep-Dive „Warum passt das?" (opt-in, POST /explain) ---- */
.deep-dive {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--c-border);
}

/* Button im Stil der sekundären Aktion, aber kompakter (Karten-intern) */
.btn-deep-dive {
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--c-surface);
  color: var(--c-primaer);
  border: 1px solid var(--c-primaer);
  border-radius: 6px;
  padding: 8px 16px;
  min-height: 44px;   /* Touch-Target */
  cursor: pointer;
}
.btn-deep-dive:hover:not(:disabled) { background: var(--c-info-bg); }
.btn-deep-dive:disabled { opacity: 0.6; cursor: not-allowed; }

/* Lade-Zustand: Spinner direkt am Button-Label (optimistisches Feedback) */
.btn-deep-dive--laden::after {
  content: "";
  display: inline-block;
  width: 13px; height: 13px;
  margin-left: 8px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  /* A11Y-19: Spinner ausblenden (Button-Label + Lade-Text tragen die Info). */
  .btn-deep-dive--laden::after { animation: none; display: none; }
}

.deep-dive-panel {
  margin-top: 12px;
  background: var(--c-primaer-hell);
  border: 1px solid #b6d2e0;
  border-radius: var(--radius);
  padding: 14px 16px;
}

.deep-dive-titel {
  margin: 12px 0 6px;
  font-size: 0.98rem;
}
.deep-dive-titel:first-child {
  margin-top: 0;
}
.deep-dive-liste {
  margin-bottom: 8px;
}
.deep-dive-absatz {
  margin: 0 0 10px;
}

.deep-dive-laden {
  margin: 0;
  color: var(--c-text-leise);
  font-size: 0.92rem;
}

/* Lade-Skeleton: animierte Platzhalterzeilen, während die KI antwortet.
   Rein dekorativ (aria-hidden) — der Lade-Text trägt die Info für AT. */
.deep-dive-skeleton {
  margin-top: 10px;
}
.deep-dive-skeleton-zeile {
  display: block;
  height: 12px;
  margin-bottom: 8px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    #cfe2ee 0%,
    #e3f0f8 50%,
    #cfe2ee 100%
  );
  background-size: 200% 100%;
  animation: deep-dive-shimmer 1.3s ease-in-out infinite;
}
.deep-dive-skeleton-zeile:nth-child(1) { width: 92%; }
.deep-dive-skeleton-zeile:nth-child(2) { width: 78%; }
.deep-dive-skeleton-zeile:nth-child(3) { width: 60%; margin-bottom: 0; }
@keyframes deep-dive-shimmer {
  to { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .deep-dive-skeleton-zeile {
    animation: none;
    background: #cfe2ee;
  }
}

.deep-dive-fehler {
  margin: 0 0 10px;
  color: var(--c-fehler-text);
  font-size: 0.92rem;
  font-weight: 600;
}
.btn-deep-dive-retry {
  font-size: 0.88rem;
  padding: 8px 16px;
  min-height: 44px;
}

/* Degraded-Hinweis: dezent, nicht alarmierend */
.deep-dive-degraded {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--c-text-leise);
  font-style: italic;
}
.deep-dive-provider {
  font-style: normal;
  opacity: 0.85;
}

/* Attribution im Deep-Dive-Panel etwas abgesetzt */
.deep-dive-panel .attribution {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #b6d2e0;
}

/* Über-Limit-Notiz im Deep-Dive: freundlich (info), kein Fehler */
.deep-dive-limit {
  margin: 0 0 10px;
  padding: 10px 12px;
  background: var(--c-info-bg);
  border: 1px solid #b6d2e0;
  border-left: 4px solid var(--c-primaer);
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--c-info-text);
  line-height: 1.45;
}

/* ---- Schlüssel-Einstellungen (BYOK + AIAT-Tester) ---- */
.schluessel-details {
  margin-top: 16px;
}
/* #22: <form>-Wrapper um die Schlüsselfelder (behebt die Konsolen-Warnung
   „password field not in form" + Passwort-Manager). display:contents hält das
   Layout byte-identisch — der Wrapper erzeugt keine eigene Box. */
.schluessel-form {
  display: contents;
}
.schluessel-reihe {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.schluessel-reihe input[type="password"] {
  flex: 1 1 240px;
  min-width: 160px;
}
.btn-schluessel {
  flex: 0 0 auto;
  font-size: 0.9rem;
  padding: 10px 16px;
}
.schluessel-tipp {
  margin-top: -4px;
}
.schluessel-status {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--c-text-leise);
}
.schluessel-status.info {
  color: var(--c-info-text);
  font-weight: 600;
}
.schluessel-status.fehler {
  color: var(--c-fehler-text);
  font-weight: 600;
}

/* OpenRouter One-Click-Login (PKCE, Issue #15) */
.byok-oder {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 10px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-text-leise);
}
.byok-oder::before,
.byok-oder::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--c-border);
}
.byok-connect {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.btn-connect {
  align-self: flex-start;
  font-size: 0.95rem;
}
.byok-connect-hilfe {
  margin: 0;
}

@media (max-width: 560px) {
  .schluessel-reihe { flex-direction: column; align-items: stretch; }
  .schluessel-reihe .btn-schluessel { width: 100%; }
  .btn-connect { align-self: stretch; width: 100%; }
}

/* Alert-Zeilen */
.alert-zeile {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left-width: 5px;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 10px;
}
.alert-zeile.bucket-7  { border-left-color: var(--c-bucket-7-text); }
.alert-zeile.bucket-14 { border-left-color: var(--c-bucket-14-text); }
.alert-zeile.bucket-30 { border-left-color: var(--c-bucket-30-text); }
.alert-zeile.bucket-60 { border-left-color: var(--c-bucket-60-text); }
.alert-kopf { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.alert-name { font-weight: 600; }
.alert-meta { color: var(--c-text-leise); font-size: 0.9rem; }

.fusszeile {
  margin-top: 24px;
  padding-top: 16px;
  padding-bottom: 32px;
  border-top: 1px solid var(--c-border);
  font-size: 0.82rem;
  color: var(--c-text-leise);
}
.fusszeile p { margin: 0; }
/* Prototyp-/Haftungsvermerk: abgesetzt über der Quellenzeile */
.fusszeile .fuss-prototyp { margin: 0 0 8px; }
.fusszeile .fuss-prototyp strong { color: var(--c-text); }

/* ---- Responsive ---- */
@media (max-width: 560px) {
  .feld-reihe { flex-direction: column; gap: 0; }
  .aktionen .btn { width: 100%; }
  .score-bar { max-width: 100%; }
  .summe-reihe { flex-direction: column; align-items: flex-start; }
  .summe-reihe input[type="number"] { width: 100%; }
}
