/* ==========================================================================
   Crew Up Lotse — KI-Gesprächspartner (Komponente)
   Markup: <div class="lotse" data-lotse ...></div>, Logik: crew-up-lotse.js
   Farben nur aus dem Markenset; Seiten-Token werden genutzt, wenn vorhanden.
   ========================================================================== */
.lotse {
  --l-navy: var(--c-section, #17253F);
  --l-coral: var(--c-accent, #F5A999);
  --l-mint: var(--c-mint, #78C3A7);
  --l-cool: var(--c-cool, #97BAE2);
  --l-cream: var(--c-surface, #F9F3EB);
  --l-text: var(--c-text, #3D4A5F);
  --l-muted: var(--c-text-muted, #5A6578);
  --l-line: var(--c-line, rgba(23,37,63,0.14));
  --l-serif: var(--serif, 'Lora', Georgia, serif);
  --l-sans: var(--sans, 'Inter', system-ui, sans-serif);
  font-family: var(--l-sans);
  color: var(--l-text);
  background: #fff;
  border: 1px solid var(--l-line);
  border-radius: 20px;
  box-shadow: 0 16px 48px -24px rgba(23,37,63,0.22);
  display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
  height: min(680px, 86vh);
}

/* ---- Kopf: Flagge + Titel ---- */
.lotse-head { display: flex; align-items: center; gap: 14px; padding: 18px 22px 14px; border-bottom: 1px solid var(--l-line); background: var(--l-cream); }
.lotse-head-text { min-width: 0; }
.lotse-title { font-family: var(--l-serif); font-size: 19px; font-weight: 600; color: var(--l-navy); line-height: 1.2; margin: 0; }
.lotse-sub { font-size: 12.5px; color: var(--l-muted); line-height: 1.4; margin: 2px 0 0; }

/* ---- Die Flagge (H = „Lotse an Bord“, Weiß | Coral) ---- */
.lotse-flag { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; background: #fff; border: 1px solid var(--l-line); display: grid; place-items: center; }
.lotse-flag svg { width: 30px; height: 30px; overflow: visible; }
.lotse-flag.is-small { width: 30px; height: 30px; }
.lotse-flag.is-small svg { width: 20px; height: 20px; }
.lotse-flag .lf-cloth { transform-origin: 9px 11px; transform-box: view-box; }
.lotse.is-thinking .lotse-head .lf-cloth,
.lotse-typing .lf-cloth { animation: lotse-wave 1.1s ease-in-out infinite; }
@keyframes lotse-wave {
  0%, 100% { transform: skewY(0deg) scaleX(1); }
  30% { transform: skewY(-7deg) scaleX(0.93); }
  65% { transform: skewY(5deg) scaleX(0.97); }
}

/* ---- Kurs: fünf Stationen ---- */
.lotse-course { display: flex; align-items: center; gap: 0; padding: 10px 22px 12px; border-bottom: 1px solid var(--l-line); background: var(--l-cream); }
.lotse-course ol { list-style: none; margin: 0; padding: 0; display: flex; flex: 1; min-width: 0; }
.lotse-course li { flex: 1; min-width: 0; position: relative; font-size: 11px; color: var(--l-muted); text-align: center; padding-top: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lotse-course li::before { content: ""; position: absolute; top: 3px; left: 50%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: #fff; border: 1.5px solid var(--l-line); z-index: 1; }
.lotse-course li::after { content: ""; position: absolute; top: 6.5px; left: -50%; width: 100%; border-top: 1.5px dashed var(--l-line); }
.lotse-course li:first-child::after { display: none; }
.lotse-course li.is-done::before { background: var(--l-navy); border-color: var(--l-navy); }
.lotse-course li.is-done::after, .lotse-course li.is-now::after { border-top: 1.5px solid var(--l-navy); }
.lotse-course li.is-now { color: var(--l-navy); font-weight: 600; }
.lotse-course li.is-now::before { background: var(--l-coral); border-color: var(--l-navy); width: 10px; height: 10px; margin-left: -5px; top: 2px; }

/* ---- Verlauf ---- */
.lotse-log { flex: 1; overflow-y: auto; padding: 20px 22px 8px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.lotse-row { display: flex; gap: 10px; align-items: flex-end; max-width: 100%; }
.lotse-row.is-user { justify-content: flex-end; }
.lotse-row .lotse-flag { margin-bottom: 2px; }
.lotse-row.is-cont .lotse-flag { visibility: hidden; }
.lotse-bubble { max-width: min(520px, 82%); padding: 11px 15px; border-radius: 16px; font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.lotse-row.is-bot .lotse-bubble { background: var(--l-cream); color: var(--l-navy); border-bottom-left-radius: 5px; }
.lotse-row.is-user .lotse-bubble { background: var(--l-navy); color: #fff; border-bottom-right-radius: 5px; }
.lotse-bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.lotse-note { font-size: 12px; color: var(--l-muted); text-align: center; line-height: 1.5; margin: 0 auto; max-width: 460px; }
.lotse-note a { color: var(--l-navy); text-decoration: underline; }

/* Tippen: wehende Flagge statt Pünktchen */
.lotse-typing { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--l-muted); }

/* ---- Antwort-Chips ---- */
.lotse-chips { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 40px; }
.lotse-chip { font: inherit; font-size: 14px; color: var(--l-navy); background: #fff; border: 1.5px solid var(--l-line); border-radius: 999px; padding: 8px 15px; cursor: pointer; transition: border-color .2s, background .2s; text-align: left; }
.lotse-chip:hover { border-color: var(--l-navy); background: rgba(23,37,63,0.04); }
.lotse-chip:focus-visible { outline: 2px solid var(--l-navy); outline-offset: 2px; }
.lotse-chip.is-strong { background: var(--l-navy); border-color: var(--l-navy); color: #fff; font-weight: 600; }
.lotse-chip.is-strong:hover { background: #0E1A30; }
.lotse-chips.is-used { display: none; }

/* ---- Karten im Gespräch (Format, Steckbrief, Termin) ---- */
.lotse-card { margin-left: 40px; max-width: min(540px, calc(100% - 40px)); background: #fff; border: 1px solid var(--l-line); border-radius: 14px; padding: 16px 18px; box-shadow: 0 8px 24px -18px rgba(23,37,63,0.3); }
.lotse-card-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; font-weight: 700; color: var(--l-navy); margin: 0 0 6px; }
.lotse-format { border-left: 5px solid var(--fmt, var(--l-navy)); }
.lotse-format h3 { font-family: var(--l-serif); font-size: 20px; font-weight: 600; color: var(--l-navy); margin: 0 0 2px; }
.lotse-format .lf-kind { font-size: 13px; color: var(--l-muted); margin: 0 0 10px; }
.lotse-format p { font-size: 14.5px; line-height: 1.55; margin: 0 0 10px; color: var(--l-text); }
.lotse-format a { font-size: 14px; font-weight: 600; color: var(--l-navy); text-decoration: underline; text-underline-offset: 3px; }

.lotse-brief h3 { font-family: var(--l-serif); font-size: 18px; font-weight: 600; color: var(--l-navy); margin: 0 0 4px; }
.lotse-brief > p { font-size: 13.5px; color: var(--l-muted); margin: 0 0 12px; line-height: 1.5; }
.lotse-brief-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px 12px; }
.lotse-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lotse-field.is-wide { grid-column: 1 / -1; }
.lotse-field label { font-size: 12px; font-weight: 600; color: var(--l-navy); }
.lotse-field input, .lotse-field textarea { font: inherit; font-size: 14.5px; color: var(--l-navy); border: 1px solid var(--l-line); border-radius: 8px; padding: 9px 11px; background: #fff; width: 100%; }
.lotse-field textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.lotse-field input:focus, .lotse-field textarea:focus { outline: none; border-color: var(--l-navy); box-shadow: 0 0 0 3px rgba(23,37,63,0.08); }
.lotse-field input[aria-invalid="true"] { border-color: #a52d23; }
.lotse-consent { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; line-height: 1.5; color: var(--l-text); margin: 12px 0; }
.lotse-consent input { margin-top: 3px; accent-color: var(--l-navy); }
.lotse-consent a { color: var(--l-navy); text-decoration: underline; }
.lotse-btn { font: inherit; font-size: 14.5px; font-weight: 600; border-radius: 8px; padding: 11px 20px; cursor: pointer; border: 1.5px solid var(--l-navy); background: var(--l-navy); color: #fff; }
.lotse-btn:hover { background: #0E1A30; }
.lotse-btn[disabled] { opacity: .45; cursor: not-allowed; }
.lotse-btn.is-outline { background: #fff; color: var(--l-navy); border-color: var(--l-line); }
.lotse-btn.is-outline:hover { border-color: var(--l-navy); }
.lotse-done { display: flex; gap: 12px; align-items: flex-start; }
.lotse-done svg { flex: 0 0 auto; }

/* ---- Eingabe ---- */
.lotse-input { display: flex; gap: 10px; align-items: flex-end; padding: 12px 16px 10px; border-top: 1px solid var(--l-line); background: #fff; }
.lotse-input textarea { flex: 1; min-width: 0; font: inherit; font-size: 15px; color: var(--l-navy); border: 1px solid var(--l-line); border-radius: 12px; padding: 11px 14px; resize: none; max-height: 140px; line-height: 1.45; background: #fff; }
.lotse-input textarea:focus { outline: none; border-color: var(--l-navy); box-shadow: 0 0 0 3px rgba(23,37,63,0.08); }
.lotse-input textarea:disabled { background: var(--l-cream); }
.lotse-send { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 12px; border: 0; background: var(--l-navy); color: #fff; display: grid; place-items: center; cursor: pointer; }
.lotse-send:hover { background: #0E1A30; }
.lotse-send:disabled { opacity: .4; cursor: not-allowed; }
.lotse-foot { font-size: 11.5px; color: var(--l-muted); text-align: center; padding: 0 16px 12px; line-height: 1.45; }
.lotse-foot a { color: var(--l-navy); text-decoration: underline; }

.lotse-demo-hint { font-size: 12px; line-height: 1.45; color: var(--l-navy); background: rgba(151,186,226,0.22); padding: 7px 22px; text-align: center; }

.lotse-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 560px) {
  .lotse { border-radius: 16px; height: min(640px, 88vh); }
  .lotse-head { padding: 14px 16px 12px; }
  .lotse-course { padding: 8px 10px 10px; }
  .lotse-course li { font-size: 10px; }
  .lotse-log { padding: 16px 14px 8px; }
  .lotse-bubble { max-width: 86%; font-size: 14.5px; }
  .lotse-chips { padding-left: 0; }
  .lotse-card { margin-left: 0; max-width: 100%; }
  .lotse-brief-grid { grid-template-columns: minmax(0,1fr); }
  .lotse-input { padding: 10px 12px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .lotse .lf-cloth { animation: none !important; }
  .lotse-log { scroll-behavior: auto; }
}

/* Links in Karten: Navy statt Seiten-Linkfarbe (Coral ist als Textfarbe zu kontrastarm) */
.lotse-card a:not(.lotse-btn) { color: var(--l-navy); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.lotse-card a.lotse-btn { color: #fff; }
