/* Gestaltung der Interviewanwendung: ruhig, sachlich, gut lesbar.
   Nur Systemschriften, keine externen Quellen. Kontraste von Text zu Hintergrund
   mindestens 4.5:1 (WCAG AA), Knöpfe mindestens 48 px hoch. */

:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-soft: #f1f0eb;
  --ink: #1f2725;
  --ink-soft: #364240;
  --muted: #55605d;
  --line: #d3d5cf;
  --line-strong: #7f8f8b;
  --primary: #24584f;
  --primary-dark: #173f39;
  --primary-tint: #e4eeeb;
  --hint-bg: #f6f0e1;
  --hint-line: #b89a52;
  --danger: #9f3128;
  --danger-tint: #fbeeec;
  --focus: #1d5fa5;
  --radius: 14px;
  --width: 860px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 100%;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

a { color: var(--primary-dark); }
a:hover { color: var(--primary); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* --- Kopf, Inhalt, Fuß ------------------------------------------------------ */

.site-header {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  /* Ränder so, dass Kopf und Inhalt an derselben Kante beginnen. */
  padding: 0 max(1rem, calc((100% - var(--width)) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}
/* Zeitraum unter dem Titel, nur auf der Startseite. */
.brand small { display: block; color: var(--muted); font-size: 0.875rem; font-weight: 400; }

/* Fortschritt: Erzählen, Prüfen, Freigeben. */
.schritte {
  display: flex;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.875rem;
}
.schritte li { display: flex; align-items: center; gap: 0.4rem; }
.schritte li + li::before {
  content: "";
  width: 0.9rem;
  height: 1px;
  margin-right: 0.1rem;
  background: var(--line-strong);
}
.schritte b {
  display: inline-grid;
  width: 1.4rem;
  height: 1.4rem;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 650;
}
.schritte li.aktiv { color: var(--ink); font-weight: 650; }
.schritte li.aktiv b,
.schritte li.erledigt b { color: #ffffff; background: var(--primary); border-color: var(--primary); }
.schritte li.erledigt { color: var(--ink); }

/* Leiser Knopf zum Beenden unter dem Eingabefeld; beim Angebot der KI steht der
   Hauptknopf im Hinweis über dem Eingabefeld. Doppelte Klasse, weil .button
   weiter unten steht. */
.button.end-button {
  min-height: 44px;
  padding: 0.4rem 0.9rem;
  color: var(--primary-dark);
  background: transparent;
  border-color: var(--line-strong);
  font-size: 0.9375rem;
}
.button.end-button:hover:not(:disabled) { background: var(--primary-tint); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.page-shell {
  width: min(100% - 2rem, var(--width));
  flex: 1 0 auto;
  margin: 0 auto;
  padding: 2.5rem 0 3rem;
}

.site-footer {
  padding: 1.5rem 1rem 2rem;
  color: var(--muted);
  text-align: center;
  font-size: 0.875rem;
}

.site-footer a { color: inherit; }
.site-footer .fuss-kontakt { display: block; margin-top: 0.35rem; }

/* --- Startseite (konfiguration/startseite.toml) -------------------------------- */

.startseite { width: min(100%, 640px); margin: 0 auto; }
.startseite .kicker {
  margin-bottom: 0.5rem;
  color: var(--primary-dark);
  font-size: 0.875rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.startseite .lead { margin-bottom: 1.5rem; }

.schrittkarten {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin: 0 0 1.4rem;
  padding: 0;
  list-style: none;
}
.schrittkarten li {
  padding: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.schrittkarten b {
  display: inline-grid;
  width: 1.5rem;
  height: 1.5rem;
  margin-bottom: 0.5rem;
  place-items: center;
  border-radius: 50%;
  color: var(--primary-dark);
  background: var(--primary-tint);
  font-size: 0.8125rem;
}
.schrittkarten strong { display: block; margin-bottom: 0.15rem; }
.schrittkarten p { margin: 0; color: var(--ink-soft); font-size: 0.9375rem; line-height: 1.5; }

.hinweisliste { display: grid; gap: 0.6rem; margin: 0 0 1.4rem; padding: 0; list-style: none; }
.hinweisliste li { display: grid; grid-template-columns: 1.6rem 1fr; gap: 0.5rem; }
.hinweisliste li::before {
  content: "✓";
  display: grid;
  width: 1.4rem;
  height: 1.4rem;
  margin-top: 0.1rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--primary);
  background: var(--surface);
  font-size: 0.75rem;
}
/* Der Namenshinweis ist der einzige, den man aktiv beachten muss. */
.hinweisliste li.wichtig::before {
  content: "!";
  color: #6f4c0e;
  background: var(--hint-bg);
  border-color: var(--hint-line);
  font-weight: 700;
}

.angaben {
  margin-bottom: 1.5rem;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.angaben summary { cursor: pointer; font-weight: 650; }
.angaben p { margin: 0.6rem 0 0; color: var(--ink-soft); font-size: 0.9375rem; }

/* --- Text --------------------------------------------------------------------- */

/* Lange Wörter wie „Newsletterfreigabeprozess“ nach deutscher Silbentrennung umbrechen. */
h1, h2 { line-height: 1.25; color: var(--ink); hyphens: auto; }
h1 { margin: 0 0 0.75rem; font-size: clamp(1.75rem, 1.35rem + 1.6vw, 2.25rem); font-weight: 700; }
h2 { margin: 0 0 0.6rem; font-size: 1.25rem; font-weight: 650; }
p { margin: 0 0 1rem; }

.eyebrow {
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.lead { color: var(--ink-soft); font-size: 1.125rem; }
.form-hint { color: var(--muted); font-size: 0.9375rem; }
.error-text { color: var(--danger); }
.hidden { display: none !important; }

.form-error {
  /* Abstand zum Bildschirmrand, wenn die Meldung ins Bild gescrollt wird. */
  scroll-margin: 1rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--danger);
  border-radius: 6px;
  background: var(--danger-tint);
  color: var(--danger);
}

.notice {
  margin: 1rem 0;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: var(--surface);
}

/* --- Karten ------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.narrow-card { width: min(100%, 720px); margin: 0 auto; }
.hero-card { padding: clamp(1.25rem, 4vw, 2.75rem); }
.hero-card > :last-child { margin-bottom: 0; }

/* Informationsblatt aus konfiguration/datenhinweise.md */
.informationsblatt h1 { font-size: clamp(1.5rem, 1.2rem + 1.3vw, 2rem); }
.informationsblatt h2 { margin-top: 2rem; }
.informationsblatt form,
.informationsblatt > .button { margin-top: 2rem; }

/* --- Knöpfe ------------------------------------------------------------------- */

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button.primary { color: #ffffff; background: var(--primary); }
.button.primary:hover:not(:disabled) { color: #ffffff; background: var(--primary-dark); }
.button.secondary { color: var(--primary-dark); background: var(--surface); border-color: var(--line-strong); }
.button.secondary:hover:not(:disabled) { background: var(--primary-tint); }
.button:disabled { opacity: 0.55; cursor: not-allowed; }
.full-width { width: 100%; }

/* --- Gespräch ----------------------------------------------------------------- */

.section-header { margin-bottom: 1.25rem; }
.section-header .lead { max-width: 42rem; margin-bottom: 0.5rem; }

.chat-card {
  display: flex;
  min-height: 40vh;
  max-height: 60vh;
  flex-direction: column;
  gap: 1.1rem;
  overflow-y: auto;
  padding: clamp(0.9rem, 3vw, 1.5rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* Die KI schreibt ohne Blase, mit Kürzel; die eigenen Antworten stehen rechts in der Blase. */
.message { max-width: 85%; }
.message.user { align-self: flex-end; }
.message.assistant {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.75rem;
  align-items: start;
  align-self: flex-start;
  max-width: 40rem;
}

.kuerzel {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.message-content {
  /* Lange Wörter oder Adressen umbrechen statt die Seite zu verbreitern. */
  overflow-wrap: anywhere;
}
/* Während des Einlaufens steht der Text noch ohne Absätze im Element. */
.message.assistant .message-content { padding-top: 0.15rem; white-space: pre-line; }
.message.assistant .message-content p { margin: 0 0 0.6rem; }
.message.assistant .message-content p:last-child { margin-bottom: 0; }
.message.assistant .message-content p.frage { font-weight: 650; }
.message.user .message-content {
  padding: 0.6rem 0.9rem;
  white-space: pre-wrap;
  background: var(--primary-tint);
  border-radius: 16px 16px 4px 16px;
}

.message.streaming .message-content::after {
  content: "▍";
  margin-left: 1px;
  color: var(--primary);
  animation: blink 1.2s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.composer { margin-top: 1.25rem; }

/* Eingabefeld als Hauptelement, Senden direkt daneben. */
.eingabe {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  padding: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.eingabe:focus-within { border-color: var(--focus); }
.eingabe textarea { min-height: 3.5rem; padding: 0.4rem 0.3rem; border: 0; }
.eingabe textarea:focus-visible { outline: none; }
.eingabe .button { flex: 0 0 auto; }

/* Spracheingabe: runder Mikrofonknopf neben „Senden“, rot während der Aufnahme. */
.button.mikrofon { width: 48px; padding: 0; flex: 0 0 48px; border-radius: 50%; }
.button.mikrofon svg { width: 22px; height: 22px; fill: currentColor; }
.button.mikrofon .symbol-stopp { display: none; }
.button.mikrofon .mikrofon-text { display: none; }
/* Während der Aufnahme: roter Knopf mit Stoppsymbol und „Beenden“; „Senden“ ist dann ausgeblendet. */
.button.mikrofon.aufnahme {
  width: auto;
  flex: 0 0 auto;
  gap: 0.4rem;
  padding: 0 1.1rem 0 0.9rem;
  border-radius: 999px;
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}
.button.mikrofon.aufnahme:hover:not(:disabled) { background: var(--danger); }
.button.mikrofon.aufnahme .symbol-mikrofon { display: none; }
.button.mikrofon.aufnahme .symbol-stopp { display: block; }
.button.mikrofon.aufnahme .mikrofon-text { display: inline; }
.sprach-status {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem 1rem;
  margin: 0.5rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}
.restzeit { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 650; }
.restzeit.knapp { color: var(--danger); }

.eingabe-unten {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
}

.chip {
  min-height: 44px;
  padding: 0.3rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--primary-dark);
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}
.chip:hover:not(:disabled) { background: var(--primary-tint); }
.chip:disabled { opacity: 0.55; cursor: not-allowed; }

.gespraech-knoepfe {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-left: auto;
}

/* Erscheint über dem Eingabefeld, wenn die KI den Abschluss anbietet, mit eigenem Knopf. */
.angebot-hinweis {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  margin: 1.25rem 0 -0.5rem;
  padding: 0.6rem 0.6rem 0.6rem 0.9rem;
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  background: var(--primary-tint);
  color: var(--ink);
  font-size: 0.9375rem;
}
.angebot-hinweis p { margin: 0; }
.angebot-hinweis .button { min-height: 44px; padding: 0.4rem 1rem; }

/* Rückfrage beim Beenden. */
.dialog {
  width: min(31rem, calc(100% - 2rem));
  padding: 1.4rem;
  border: 0;
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
}
.dialog::backdrop { background: rgba(28, 35, 33, 0.38); }
.dialog p { color: var(--ink-soft); }
.dialog-aktionen { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; }
.dialog-aktionen form { margin: 0; }

/* Wartezustand im Dialog, während die Zusammenfassung entsteht. */
.warten h2:focus { outline: none; }
.warten p:last-child { margin-bottom: 0; }
.fortschritt {
  position: relative;
  height: 6px;
  margin: 0.4rem 0 1.1rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--primary-tint);
}
.fortschritt span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 35%;
  border-radius: inherit;
  background: var(--primary);
  animation: fortschritt 1.8s ease-in-out infinite;
}
@keyframes fortschritt {
  from { transform: translateX(-100%); }
  to { transform: translateX(290%); }
}

label { display: block; margin-bottom: 0.4rem; font-size: 1rem; font-weight: 650; }

textarea {
  display: block;
  width: 100%;
  min-height: 6.5rem;
  resize: vertical;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
}
textarea:focus-visible { border-color: var(--focus); }
textarea:disabled { background: var(--surface-soft); }

/* Namenshinweis direkt unter dem Eingabefeld. */
.eingabehinweis { margin: 0; color: var(--muted); font-size: 0.875rem; }

.composer .form-error { margin-top: 0.85rem; }

/* --- Prüfseite ---------------------------------------------------------------- */

.action-card { padding: clamp(1.1rem, 3vw, 1.5rem); }
.action-card h3 { margin: 0 0 0.6rem; font-size: 1.25rem; font-weight: 650; line-height: 1.25; }
.zwischentitel { margin: 2rem 0 0.75rem; }
.section-header + .zwischentitel,
.form-error + .zwischentitel { margin-top: 1.5rem; }
.summary-field + .summary-field { margin-top: 1.5rem; }
.summary-field .form-hint { margin: -0.2rem 0 0.4rem; }
/* Die Felder wachsen mit ihrem Inhalt (app.js) statt Platz für leere Zeilen zu reservieren. */
.summary-field textarea { min-height: 3.5rem; }
.leer-hinweis { margin: 0 0 0.4rem; color: var(--muted); font-size: 0.9375rem; font-style: italic; }
#summary-edit .button { margin-top: 1.5rem; }

/* Bestätigung nach dem Speichern und ruhiger Hinweis bei offenen Änderungen. */
.erfolg {
  padding: 0.6rem 0.9rem;
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  background: var(--primary-tint);
}
.ungespeichert {
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border-left: 4px solid var(--hint-line);
  border-radius: 6px;
  background: var(--hint-bg);
}
.ungespeichert p { margin-bottom: 0.6rem; }

.two-column-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.two-column-actions .action-card { display: flex; flex-direction: column; }
.two-column-actions .action-card .button { margin-top: auto; }
.approval-card { border-color: var(--primary); }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0.5rem 0 1.25rem;
  font-weight: 500;
  cursor: pointer;
}
.checkbox-row input {
  flex: 0 0 auto;
  width: 1.4rem;
  height: 1.4rem;
  margin: 0.1rem 0 0;
  accent-color: var(--primary);
}

/* --- Schmale Bildschirme ------------------------------------------------------ */

@media (max-width: 720px) {
  .page-shell { padding: 1.25rem 0 2rem; }
  .site-header { min-height: 52px; flex-wrap: wrap; padding-top: 0.6rem; padding-bottom: 0.6rem; }
  /* Am Handy nur die Ziffern der Schritte. */
  .schritte span { display: none; }
  .schrittkarten { grid-template-columns: 1fr; }
  .two-column-actions { grid-template-columns: 1fr; }
  .chat-card { min-height: 45vh; max-height: 55vh; }
  .message { max-width: 94%; }
  .message.assistant { grid-template-columns: 1.75rem 1fr; gap: 0.6rem; }
  .kuerzel { width: 1.75rem; height: 1.75rem; font-size: 0.6875rem; }
}

@media (prefers-reduced-motion: reduce) {
  .message.streaming .message-content::after { animation: none; }
  /* Ohne Bewegung: ein ruhender Balken in voller Breite. */
  .fortschritt span { width: 100%; animation: none; opacity: 0.45; }
}
