/* Ergänzende Regeln: Footer mit Anmeldestatus und Live-Statistik, Teilen, Admin-Menü,
   Hover-/Fokuszustände und die vollständige mobile Darstellung. Wird nach reference.css
   und controls.css geladen und überschreibt deren Werte gezielt. */
:root {
  --footer-height: 48px;
  --composer-height: 150px;
  --mobile-bar: 58px;
  --brand-start: #667eea;
  --brand-end: #764ba2;
  --ring: 0 0 0 3px rgb(102 126 234 / 35%);
}

/* ---------- Fußzeile: Live-Statistik, Anmeldestatus, Recht, Teilen ---------- */
.portal-legal {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 3px 10px calc(3px + env(safe-area-inset-bottom));
  background: rgb(255 255 255 / 92%); backdrop-filter: blur(10px);
  border-top: 1px solid rgb(99 102 241 / 12%);
  font: 12px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; color: #39415c; text-align: center;
}
.footer-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 12px; max-width: 100%; }
.portal-legal .legal-links { padding: 0; font: inherit; }
.legal-links a { color: #453a81; text-decoration-thickness: 1px; text-underline-offset: 2px; border-radius: 4px; transition: color .15s, background .15s; }
.legal-links a:hover, .legal-links a:focus-visible { color: #fff; background: #6d5bd0; text-decoration: none; outline: none; }
.legal-links .narrow-only { display: none; }

.login-status-indicator {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  padding: 1px 9px; border-radius: 999px; background: rgb(40 167 69 / 10%); border: 1px solid rgb(40 167 69 / 35%);
  color: #1e7b34; font-weight: 600; white-space: nowrap;
}
.login-status-indicator #loginStatusUser { overflow: hidden; text-overflow: ellipsis; max-width: 26ch; }
.login-status-indicator #loginStatusRole { font-size: 11px; font-weight: 500; opacity: .85; }
.login-status-label { font-weight: 500; }

.share-trigger {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgb(118 75 162 / 35%); background: linear-gradient(135deg, #f5f3ff, #fdf2f8);
  color: #5b3f8f; font: 600 12px/1.45 system-ui, sans-serif; transition: transform .15s, box-shadow .15s, background .15s;
}
.share-trigger:hover, .share-trigger:focus-visible { background: linear-gradient(135deg, var(--brand-start), var(--brand-end)); color: #fff; box-shadow: var(--ring); outline: none; }

/* Live-Statistik: klein, zentriert, mit Zähleffekt */
.footer-stats { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0 14px; font-size: 11px; color: #5b5f7a; min-height: 16px; }
.footer-stats[hidden] { display: none !important; }
.stat-chip { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.stat-chip b { color: #4c3b9a; font-variant-numeric: tabular-nums; }
.stat-chip .stat-emoji { display: inline-block; }
.stat-chip.live .stat-emoji { animation: stat-pulse 2.4s ease-in-out infinite; }
.stat-chip.bumped b { animation: stat-pop .6s ease-out; }
@keyframes stat-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
@keyframes stat-pop { 0% { color: #16a34a; transform: translateY(-2px); } 100% { color: #4c3b9a; transform: none; } }

/* Die Eingabe sitzt über der Fußzeile. */
.chat-input-modal { bottom: calc(var(--footer-height) + 10px); }
#question-form { margin-bottom: 0; }

/* ---------- Begrüßung im Stil der Startseite ---------- */
.welcome-message { max-width: 620px; margin: 0 auto; }
.welcome-eyebrow { display: block; font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: #8b7ba8; margin-bottom: 10px; font-weight: 600; }
.welcome-message h3 { font-size: clamp(22px, 3.2vw, 32px); line-height: 1.2; color: #5b3f8f; letter-spacing: -.02em; }
.welcome-bubbles { display: grid; gap: 8px; margin: 18px auto 14px; max-width: 360px; text-align: left; }
.welcome-bubbles div { display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: #fff; border: 1px solid #eee7f6; border-radius: 12px; box-shadow: 0 6px 18px rgb(78 53 114 / 7%); font-size: 13px; color: #5f5472; animation: bubble-in .5s ease-out both; }
.welcome-bubbles div:nth-child(2) { margin-left: 26px; animation-delay: .15s; }
.welcome-bubbles div:nth-child(3) { margin-left: 8px; animation-delay: .3s; }
.mini-avatar { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; font-size: 11px; font-weight: 700; }
.mini-avatar.green { background: #e7f6ec; color: #3f8b5c; }
.mini-avatar.orange { background: #fdeee4; color: #c26a3a; }
.mini-avatar.purple { background: #f1eafa; color: #8a5cc0; }
.welcome-privacy { display: block; font-size: 12px; color: #7b6f8c; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Login- und Registrierungsdialog ---------- */
dialog.auth-modal[open] { flex-direction: column; align-items: center; justify-content: flex-start; padding: 16px; overflow-y: auto; }
.auth-content { width: 100%; max-width: 460px; flex: none; margin: auto 0; }
.auth-content .legal-links { padding: 10px 16px 14px; border-top: 1px solid #f0edf6; font-size: 12px; }
.auth-lead { color: #6b6280; font-size: 14px; margin: -8px 0 18px; }
.auth-hint { color: #7a7090; font-size: 12.5px; margin: 6px 0 0; }
.auth-tagline { padding: 0 16px 6px; color: #8b84a0; font-size: 11px; text-align: center; }
.auth-form label:has(input[type=checkbox]) { display: block; font-size: 13px; line-height: 1.5; color: #4b5563; }
#registration-status { font-size: 13px; color: #6b6280; margin-bottom: 10px; }

/* ---------- Hover- und Fokuszustände ---------- */
@media (hover: hover) {
  .settings-dropdown-menu > a:hover, .settings-dropdown-menu button:hover { background: linear-gradient(135deg, #eef0ff, #f6effc); color: #3c2f7a; }
  .modal-content :is(.primary, .secondary, .text-button):hover, .admin-content :is(.primary, .secondary):hover,
  .billing-content :is(.primary, .secondary):hover, .modal-content .code-action-btn:hover { background: #e9e7fb; border-color: #c7c2f0; color: #3c2f7a; }
  .user-action:hover { background: #e9e7fb; transform: translateY(-1px); }
  .stat-card:hover { box-shadow: 0 10px 24px rgb(102 126 234 / 18%); }
}
.settings-dropdown-menu > a {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-radius: 8px; background: #f3f4f6;
  color: #1f2937; font-size: 14px; font-weight: 500; text-decoration: none; transition: background .2s, color .2s;
}
:is(button, a, input, select, textarea, summary):focus-visible { outline: 3px solid #a5b4fc; outline-offset: 2px; }

/* ---------- Administration ---------- */
.admin-nav { gap: 10px; }
.admin-nav-item {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px;
  color: #374151; text-decoration: none; font-size: 14px; line-height: 1.2;
  border: 1px solid #dee2e6; background: #fff;
  transition: background .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
#admin-tabs .admin-nav-item { border: 1px solid #dee2e6; }
#admin-tabs .admin-nav-item:hover, #admin-tabs .admin-nav-item:focus-visible {
  background: linear-gradient(135deg, var(--brand-start), var(--brand-end)); color: #fff; border-color: transparent;
  box-shadow: 0 6px 16px rgb(102 126 234 / 35%); transform: translateY(-1px);
}
#admin-tabs .admin-nav-item.active { background: var(--brand-start); color: #fff; border-color: var(--brand-start); box-shadow: inset 0 -3px 0 rgb(0 0 0 / 15%); }
#admin-tabs .admin-nav-link { margin-left: auto; border-style: dashed; }
.admin-close:hover, .admin-close:focus-visible { background: rgb(255 255 255 / 35%); }
.audit-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.audit-toolbar input { padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; min-width: 220px; font: inherit; }
.audit-event strong { display: block; }
.audit-event.warn strong { color: #b42318; }
.audit-event.warn { background: #fff8f7; }
.audit-event.good strong { color: #166534; }
.audit-event small { color: #6b7280; }

/* ---------- Teilen ---------- */
#share-dialog { width: min(560px, 94vw); }
.share-intro { color: #4b5563; }
.share-choice { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 6px 0 10px; }
.share-choice label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
#share-text { width: 100%; min-height: 150px; padding: 10px 12px; border: 1px solid #d6d3e4; border-radius: 10px; font: 14px/1.5 system-ui, sans-serif; resize: vertical; }
.share-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0 6px; }
.share-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 8px 10px;
  border: 0; border-radius: 12px; cursor: pointer; color: #fff; font: 600 14px/1.2 system-ui, sans-serif;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.share-btn .share-icon { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: rgb(255 255 255 / 22%); font-size: 13px; }
.share-btn:hover, .share-btn:focus-visible { transform: translateY(-2px); box-shadow: 0 8px 18px rgb(0 0 0 / 18%); filter: saturate(1.15); }
.share-btn.whatsapp { background: #25d366; color: #073b1f; }
.share-btn.instagram { background: linear-gradient(45deg, #f58529, #dd2a7b 45%, #8134af 75%, #515bd4); }
.share-btn.facebook { background: #1877f2; }
.share-btn.tiktok { background: #111; box-shadow: inset 2px 0 0 #25f4ee, inset -2px 0 0 #fe2c55; }
.share-btn.email { background: #4b5563; }
.share-btn.copy, .share-btn.native { background: #ede9fe; color: #4c3b9a; }
#share-status { min-height: 1.4em; color: #166534 !important; font-weight: 600; }

/* ---------- Desktop-Layout: Fenster beginnt oben und reicht bis zur Fußzeile ---------- */
@media (min-width: 769px) {
  body { padding: 16px 20px 0; }
  .main-container, .main-container.single-mode {
    align-items: flex-start; justify-content: center; padding: 0 70px;
    height: calc(100svh - 16px - var(--footer-height) - 8px);
  }
  #chatContainer, .chat-container.single-ki-mode { width: 100%; max-width: 1400px; min-width: 0; height: 100%; max-height: none; }
  #chatMessages { padding-bottom: calc(var(--composer-height) + 28px); }
  .multi-ki-container { width: auto; margin: 0 70px; height: calc(100svh - 16px - var(--footer-height) - 8px); }
  .settings-dropdown-menu { top: 90px; right: 92px; }
  .ki-selection-dropdown { top: 150px; right: 92px; }
  body.is-authenticated .toggle-settings { top: 30px; }
  body.is-authenticated .pdf-export-button { top: 90px; }
  body.is-authenticated .ki-selection-button { top: 150px; }
  body.is-authenticated .settings-dropdown-menu { top: 30px; }
  body.is-authenticated .ki-selection-dropdown { top: 90px; }
}
/* Abmelden sitzt nach der Anmeldung unten links; Anmelden bleibt oben rechts. */
body.is-authenticated .logout-button { top: auto; right: auto; left: 16px; bottom: calc(var(--footer-height) + 12px); }

/* ---------- Tablet ---------- */
@media (max-width: 1024px) and (min-width: 769px) {
  .chat-input-modal { min-width: 0; width: calc(100vw - 110px); left: 80px; transform: none; }
  .main-container, .main-container.single-mode { padding: 0 70px 0 70px; }
}


/* ---------- Sprechblasen: versetzt, mit Spitze ---------- */
.message-bubble { resize: none; overflow: visible; min-width: min(200px, 100%); }
.message-wrapper.assistant .message-bubble { max-width: min(84%, 920px); }
.message-wrapper.user .message-bubble { max-width: min(76%, 760px); }
.message-wrapper.assistant[data-slot="1"] { padding-left: 5%; }
.message-wrapper.assistant[data-slot="2"] { padding-left: 10%; }
.message-wrapper:is([data-kind="draft"], [data-kind="revision"]) { justify-content: center; padding-left: 0; }
.message-wrapper:is([data-kind="draft"], [data-kind="revision"]) .message-bubble { max-width: min(94%, 980px); border: 2px dashed rgb(99 102 241 / 40%); border-radius: 18px; }
.message-wrapper:is([data-kind="draft"], [data-kind="revision"]) .message-bubble::after { display: none; }
.message-wrapper[data-kind="review"] .message-bubble { max-width: min(62%, 560px); }
.message-wrapper.assistant .message-bubble::after { left: -9px; bottom: 6px; }
.message-wrapper.user .message-bubble::after { right: -9px; bottom: 6px; }
.message-content { overflow-wrap: anywhere; }
.message-content .code-block, .message-content .table-wrap { max-width: 100%; }

/* Bewertung mit fünf Sternen */
.message-rating { display: flex; align-items: center; gap: 1px; margin-top: 8px; }
.star-btn { background: none !important; border: 0; padding: 0 2px; font-size: 18px; line-height: 1; color: inherit; opacity: .45; cursor: pointer; transition: transform .12s ease, opacity .12s ease, color .12s ease; box-shadow: none; }
.star-btn.on { color: #f5a623; opacity: 1; }
.message-rating:hover .star-btn { color: #f5a623; opacity: 1; }
.message-rating .star-btn:hover ~ .star-btn { color: inherit; opacity: .45; }
.star-btn:hover { transform: scale(1.25); }
.rating-thanks { font-size: 11px; margin-left: 6px; opacity: .75; }

/* Tabellen, Bilder und Diagramme in Antworten */
.table-wrap { overflow-x: auto; margin: 8px 0; border-radius: 10px; }
.message-content table { border-collapse: collapse; min-width: 50%; background: rgb(255 255 255 / 70%); color: #1f2937; }
.message-content th { background: #eef0ff; font-weight: 600; }
.message-content :is(th, td) { padding: 6px 10px; text-align: left; vertical-align: top; }
.ai-figure { margin: 10px 0; }
.message-wrapper .message-bubble:has(.ai-figure, .ai-image, .table-wrap) { width: min(84%, 700px); }
@media (max-width: 768px) { .message-wrapper .message-bubble:has(.ai-figure, .ai-image, .table-wrap) { width: 92%; } }
.ai-figure details { margin-top: 4px; font-size: 12px; }
.ai-chart, .ai-image { display: block; max-width: 100%; height: auto; border-radius: 12px; background: #fff; box-shadow: 0 2px 10px rgb(0 0 0 / 8%); }
.ai-image { margin: 8px 0; }
.ai-image-link { display: inline-block; margin: 6px 0; padding: 6px 10px; border-radius: 8px; background: #eef0ff; color: #3730a3 !important; }
.ai-chart .chart-title { font: 600 16px system-ui, sans-serif; fill: #1f2937; }
.ai-chart .chart-axis { font: 11px system-ui, sans-serif; fill: #6b7280; }
.ai-chart .chart-label { font: 12px system-ui, sans-serif; fill: #374151; }
.ai-chart .chart-grid { stroke: #e5e7eb; stroke-width: 1; }

/* Ausführliche Statistik */
.stats-details { margin-top: 12px; display: grid; gap: 16px; }
.stats-section h4 { margin: 4px 0 8px; font-size: 15px; }
.stats-section .stat-item { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px dashed #eee; }
.stats-section .stat-item strong { text-align: right; overflow-wrap: anywhere; }
.stats-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mini-card { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid #ebe7f7; border-radius: 12px; background: linear-gradient(135deg, #f8f7ff, #fdf7fb); }
.mini-card strong { font-size: 20px; color: #4c3b9a !important; font-variant-numeric: tabular-nums; }
.mini-card span { font-size: 12px; } .mini-card small { font-size: 11px; color: #6b7280 !important; }
.budget-bar { height: 8px; border-radius: 99px; background: #eef0ff; overflow: hidden; margin: 10px 0 4px; }
.budget-bar span { display: block; height: 100%; background: linear-gradient(90deg, #10b981, #f59e0b, #ef4444); border-radius: inherit; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats-table :is(th, td) { padding: 6px 8px; border-bottom: 1px solid #eee; text-align: left; vertical-align: top; }
.stats-table td small { display: block; color: #6b7280 !important; font-size: 11px; }

/* ---------- Mobil (bis 768 px) ---------- */
@media (max-width: 768px) {
  html, body { height: 100%; }
  body { padding: calc(var(--mobile-bar) + env(safe-area-inset-top)) 8px 0; overflow: hidden; }
  input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]), select, textarea,
  .chat-input, .ki-role-search-input, .form-input { font-size: 16px; }

  /* Runde Schaltflächen als Werkzeugleiste oben statt über dem Chat */
  :is(.auth-button.guest-only, .logout-button, .toggle-settings, .pdf-export-button, .ki-selection-button) {
    top: calc(9px + env(safe-area-inset-top)); width: 40px; height: 40px; min-width: 40px; font-size: 18px;
    box-shadow: 0 2px 8px rgb(0 0 0 / 10%);
  }
  .auth-button.guest-only, .logout-button { right: 10px; }
  .toggle-settings { right: 56px; }
  .pdf-export-button { right: 102px; }
  .ki-selection-button { right: 148px; }
  .settings-dropdown-menu, .ki-selection-dropdown {
    top: calc(var(--mobile-bar) + env(safe-area-inset-top)); left: 8px; right: 8px; min-width: 0; max-width: none;
    max-height: calc(100svh - var(--mobile-bar) - var(--footer-height) - 20px);
  }
  .settings-dropdown-menu button { white-space: normal; }
  #chat-mode-hint { max-width: none; }

  /* Chatfenster füllen den Platz zwischen Werkzeugleiste, Eingabe und Fußzeile */
  .main-container, .main-container.single-mode { display: block; height: auto; padding: 0; overflow: visible; }
  .chat-container, .chat-container.single-ki-mode {
    width: 100%; min-width: 0; max-width: none; min-height: 0; resize: none; border-radius: 16px;
    height: calc(100svh - var(--mobile-bar) - env(safe-area-inset-top) - var(--composer-height) - var(--footer-height) - 18px);
    max-height: none;
  }
  .chat-header { height: auto; min-height: 58px; padding: 10px 44px 10px 14px; text-align: left; }
  .chat-title { font-size: 16px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chat-subtitle { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .status-indicator { top: 14px; right: 14px; }
  .window-close-btn { top: 12px; right: 34px; }
  .ki-role-selector { padding: 8px; }
  .ki-role-search-input { padding: 9px 34px 9px 12px; }
  .ki-role-clear { top: 18px; }
  .chat-messages { height: auto; padding: 14px 12px; gap: 14px; }
  .chat-messages.show-line-numbers { padding-left: 40px; }
  .message-bubble { max-width: 92%; padding: 10px 12px; }
  .welcome-message { padding: 18px 6px; font-size: 15px; }
  .welcome-bubbles { margin: 14px auto 10px; }

  .multi-ki-container.active {
    display: flex; flex-direction: row; gap: 10px; padding: 0 0 4px; margin: 0;
    height: calc(100svh - var(--mobile-bar) - env(safe-area-inset-top) - var(--composer-height) - var(--footer-height) - 18px);
    overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  }
  .multi-ki-container.active > .chat-container {
    flex: 0 0 calc(100% - 26px); width: auto; min-width: 0; max-width: none; height: 100%; scroll-snap-align: start;
  }
  .multi-ki-container.active > .chat-container:only-child { flex-basis: 100%; }

  /* Kompakte Eingabe: Textfeld und Schaltflächen nebeneinander */
  .chat-input-modal {
    left: 8px; right: 8px; transform: none; width: auto; min-width: 0; max-width: none; resize: none;
    bottom: calc(var(--footer-height) + 6px); padding: 6px 10px 10px; border-radius: 16px;
  }
  .chat-input-modal.expanded { width: auto; }
  #token-counter { height: auto; font-size: 11px; margin-bottom: 2px; }
  .input-row { flex-direction: row; align-items: flex-end; gap: 8px; }
  .chat-input { flex: 1 1 auto; width: auto; min-width: 0; max-width: none; min-height: 46px; max-height: 32dvh; padding: 11px 14px; border-radius: 18px; resize: none; margin: 0; }
  .button-row { flex-direction: column; width: auto; gap: 6px; }
  .send-button, .reset-button { width: 40px; height: 40px; min-width: 40px; min-height: 40px; max-width: 40px; max-height: 40px; border-radius: 50%; }

  /* Dialoge nutzen die volle Breite und bleiben scrollbar */
  dialog.modal[open] { min-width: 0; }
  .modal { width: calc(100vw - 16px); max-width: none; min-width: 0; max-height: calc(100svh - 24px); border-radius: 16px; }
  .modal-header { padding: 12px 14px; cursor: default; position: sticky; top: 0; z-index: 2; }
  .modal-header h3 { font-size: 16px; }
  .modal-content { padding: 14px; }
  #security-dialog { width: calc(100vw - 16px); }
  .role-item-header { flex-wrap: wrap; gap: 8px; }
  .role-item-actions { display: flex; flex-wrap: wrap; gap: 6px; }
  .model-actions .model-alias { width: 100%; }
  #file-session { width: 100%; }
  .file-targets > div { width: 100%; }

  dialog.auth-modal[open] { padding: 10px; }
  .auth-header { padding: 18px 48px 16px; }
  .auth-title { font-size: 22px; margin-bottom: 4px; }
  .auth-subtitle { font-size: 14px; }
  .auth-close { top: 10px; right: 10px; width: 34px; height: 34px; }
  .auth-body { padding: 18px 18px 14px; }
  .auth-tabs { margin-bottom: 18px; }
  .auth-tab { padding: 12px 6px; font-size: 15px; }
  .form-group { margin-bottom: 14px; }
  .form-input { padding: 12px 14px; }

  /* Administration als Vollbild mit kompaktem Menü */
  dialog.admin-dashboard[open], dialog.billing-modal[open] { align-items: stretch; }
  .admin-content, .billing-content { width: 100%; height: 100%; max-height: none; border-radius: 0; }
  .admin-header, .billing-header { padding: calc(12px + env(safe-area-inset-top)) 14px 12px; position: sticky; top: 0; z-index: 3; }
  .admin-title, .billing-title { font-size: 19px; }
  .admin-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 10px 12px; }
  .admin-nav-item { padding: 9px 8px; font-size: 13px; border-radius: 12px; }
  #admin-tabs .admin-nav-link { grid-column: 1 / -1; margin-left: 0; }
  .admin-body, .billing-body { padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
  .stat-card { padding: 12px 8px; border-radius: 12px; }
  .stat-value { font-size: 24px; margin-bottom: 4px; }
  .stat-label { font-size: 12px; }
  .admin-body .operation-row { flex-direction: column; gap: 2px; }
  .table-header { display: flex; flex-direction: column; gap: 8px; padding: 10px; }
  #admin-users table, #admin-users thead, #admin-users tbody, #admin-users tr, #admin-users td { display: block; width: 100%; }
  #admin-users thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  #admin-users tr { border: 1px solid #e5e7eb; border-radius: 12px; padding: 8px 10px; margin-bottom: 10px; background: #fff; }
  #admin-users td { border: 0; padding: 3px 0; overflow-wrap: anywhere; }
  #admin-users td:nth-child(2)::before { content: 'Rolle: '; color: #6b7280; }
  #admin-users td:nth-child(4)::before { content: 'Zugang: '; color: #6b7280; }
  .audit-event { flex-direction: column; }
  .audit-toolbar input { min-width: 0; width: 100%; }
  #mail-form .form-row, #security-dialog .form-row { display: grid; grid-template-columns: minmax(0, 1fr); }

  /* Fußzeile: zwei kompakte Zeilen, Statistik als Lauftext */
  .portal-legal { font-size: 11px; padding-inline: 6px; }
  .footer-row { gap: 1px 8px; }
  .legal-links .wide-only { display: none; }
  .legal-links .narrow-only { display: inline; }
  .login-status-label, .share-label { display: none; }
  .footer-row .legal-links { order: 2; }
  .share-trigger { padding: 1px 8px; }
  .login-status-indicator #loginStatusUser { max-width: 18ch; }
  .footer-stats { flex-wrap: nowrap; overflow: hidden; height: 16px; position: relative; width: 100%; }
  .footer-stats .stat-chip { display: none; }
  .footer-stats .stat-chip.current { display: inline-flex; animation: stat-slide .45s ease-out; }
  @keyframes stat-slide { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

  .share-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Angemeldet: Abmelden unten links in der Fußzeile, Werkzeugleiste rückt nach rechts */
  body.is-authenticated .logout-button { top: auto; right: auto; left: 8px; bottom: calc(env(safe-area-inset-bottom) + 6px); width: 34px; height: 34px; min-width: 34px; font-size: 16px; z-index: 120; }
  body.is-authenticated .portal-legal { padding-left: 48px; }
  body.is-authenticated .toggle-settings { right: 10px; }
  body.is-authenticated .pdf-export-button { right: 56px; }
  body.is-authenticated .ki-selection-button { right: 102px; }
  .message-wrapper.assistant[data-slot="1"] { padding-left: 3%; }
  .message-wrapper.assistant[data-slot="2"] { padding-left: 6%; }
  .message-wrapper.assistant .message-bubble, .message-wrapper[data-kind="review"] .message-bubble { max-width: 92%; }
  .message-wrapper.user .message-bubble { max-width: 88%; }
  .stats-cards { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

.mobile-brand { display: none; position: fixed; z-index: 990; top: calc(9px + env(safe-area-inset-top)); left: 12px; height: 40px; align-items: center; gap: 8px; color: #5b3f8f; font: 700 18px/1 system-ui, sans-serif; letter-spacing: -.02em; text-decoration: none; }
.mobile-brand .brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, #8160bc, #a17bc9); font-size: 18px; }
@media (max-width: 768px) { .mobile-brand { display: flex; } }
@media (max-width: 350px) { .mobile-brand .brand-word { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .stat-chip.live .stat-emoji, .stat-chip.bumped b, .welcome-bubbles div, .footer-stats .stat-chip.current { animation: none !important; }
  .share-btn:hover, #admin-tabs .admin-nav-item:hover { transform: none; }
}

/* Echte KI-Bilder */
.ai-generated { position: relative; }
.ai-generated .image-frame { position: relative; min-height: 120px; border-radius: 12px; overflow: hidden; }
.ai-generated .image-frame.is-loading { aspect-ratio: 1 / 1; max-width: 420px; background: linear-gradient(110deg, #eef0ff 30%, #fdf2f8 50%, #eef0ff 70%); background-size: 200% 100%; animation: image-shimmer 1.6s linear infinite; }
.ai-generated .ai-generated-image { margin: 0; max-height: 70vh; width: auto; object-fit: contain; }
.ai-generated .image-caption { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px; font-size: 12px; }
.ai-generated .image-badge { padding: 2px 8px; border-radius: 999px; background: #eef0ff; color: #3730a3; font-weight: 600; }
.ai-generated .image-actions { display: inline-flex; gap: 6px; }
.ai-generated .image-actions .code-action-btn { cursor: pointer; }
.ai-generated .image-placeholder { display: grid; gap: 8px; justify-items: start; padding: 14px 16px; border: 2px dashed #c7d2fe; border-radius: 14px; background: #f8f9ff; }
.ai-generated .image-placeholder.is-busy { border-style: solid; background: linear-gradient(110deg, #f8f9ff 30%, #fdf2f8 50%, #f8f9ff 70%); background-size: 200% 100%; animation: image-shimmer 1.6s linear infinite; }
.ai-generated .image-state { font-weight: 600; color: #3730a3; }
.ai-generated .image-make { cursor: pointer; background: linear-gradient(135deg, #6366f1, #ec4899); color: #fff; border: 0; border-radius: 999px; padding: 7px 14px; font-weight: 600; transition: transform .15s ease, box-shadow .15s ease; }
.ai-generated .image-make:hover, .ai-generated .image-make:focus-visible { transform: translateY(-1px); box-shadow: 0 6px 16px rgb(99 102 241 / 30%); }
.ai-generated .image-cost, .ai-generated .image-note { color: #6b7280; font-size: 12px; }
.ai-generated .image-prompt { white-space: pre-wrap; margin: 6px 0 0; color: #4b5563; }
@keyframes image-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .ai-generated .image-frame.is-loading, .ai-generated .image-placeholder.is-busy { animation: none; } }
#limits-form .image-settings { display: grid; gap: 10px; margin: 6px 0 4px; padding: 12px 14px; border: 1px solid #e0e7ff; border-radius: 12px; background: #fafbff; min-width: 0; }
#limits-form .image-settings legend { padding: 0 6px; font-weight: 700; }
#limits-form .form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: end; }
#limits-form .image-models-button { min-height: 40px; cursor: pointer; }
@media (max-width: 520px) { #limits-form .form-row { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Eingabefenster: verschieben, Größe ändern, [_] minimieren, [□] maximieren ---------- */
.composer-window { resize: none; transition: box-shadow .2s ease, opacity .2s ease; padding: 0 14px 12px; min-width: min(600px, calc(100vw - 40px)); display: flex; flex-direction: column; gap: 6px; }
.composer-window.placed { transform: none; bottom: auto; right: auto; min-width: 0; max-width: none; }
.composer-window.dragging { cursor: grabbing; box-shadow: 0 18px 50px rgb(76 59 154 / 30%); opacity: .97; user-select: none; }
.composer-bar {
  display: flex; align-items: center; gap: 8px; margin: 0 -14px; padding: 6px 8px 6px 12px; cursor: grab;
  border-bottom: 1px solid rgb(99 102 241 / 12%); border-radius: 20px 20px 0 0; touch-action: none; user-select: none;
  background: linear-gradient(135deg, rgb(102 126 234 / 8%), rgb(118 75 162 / 8%));
}
.composer-grip { color: #9a8cc0; font-size: 12px; letter-spacing: -2px; }
.composer-title { font: 600 12px/1.4 system-ui, sans-serif; color: #4c3b9a; white-space: nowrap; }
.composer-bar #token-counter { margin: 0 0 0 auto; height: auto; font-size: 11px; color: #6b7280; white-space: nowrap; font-variant-numeric: tabular-nums; }
#token-counter.warn { color: #b45309; font-weight: 600; }
#token-counter.over { color: #b91c1c; font-weight: 700; }
.composer-win {
  display: grid; place-items: center; width: 26px; height: 24px; padding: 0; border-radius: 6px; flex-shrink: 0;
  border: 1px solid rgb(99 102 241 / 25%); background: #fff; color: #4c3b9a; font: 700 13px/1 ui-monospace, monospace;
}
.composer-win[data-composer="minimize"] span { transform: translateY(-2px); }
.composer-win:hover, .composer-win:focus-visible { background: linear-gradient(135deg, var(--brand-start), var(--brand-end)); color: #fff; box-shadow: var(--ring); outline: none; }
.composer-window .input-row { flex-direction: row; align-items: flex-end; gap: 10px; flex: 1 1 auto; min-height: 0; }
.composer-window .chat-input { flex: 1 1 auto; width: auto; min-width: 0; max-width: none; resize: none; margin: 0; border-radius: 18px; tab-size: 4; }
.composer-window .button-row { flex-direction: column; width: auto; gap: 8px; }
.composer-window:is(.sized, .maximized) .input-row { align-items: stretch; }
.composer-window:is(.sized, .maximized) .button-row { justify-content: flex-end; }
.composer-window.sized .chat-input, .composer-window.maximized .chat-input { height: auto !important; max-height: none; min-height: 60px; }
.composer-window.maximized {
  left: 70px; right: 70px; top: 16px; bottom: calc(var(--footer-height) + 10px); width: auto; height: auto;
  min-width: 0; max-width: none; transform: none; z-index: 5100;
}
.composer-window.maximized .chat-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.composer-resize {
  position: absolute; right: 3px; bottom: 3px; width: 16px; height: 16px; cursor: nwse-resize; touch-action: none; opacity: .55;
  background: linear-gradient(135deg, transparent 50%, #8b7bc4 50%, #8b7bc4 58%, transparent 58%, transparent 70%, #8b7bc4 70%, #8b7bc4 78%, transparent 78%);
}
.composer-window.maximized .composer-resize { display: none; }
.composer-window #run-state { margin: 0; }
.composer-dock {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--footer-height) + 8px); z-index: 5000;
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 18px 8px; border-radius: 16px 16px 12px 12px; cursor: pointer;
  background: rgb(255 255 255 / 96%); border: 1px solid rgb(99 102 241 / 25%); box-shadow: 0 6px 22px rgb(76 59 154 / 22%);
  color: #4c3b9a; font: 600 13px/1.3 system-ui, sans-serif; touch-action: none; user-select: none; animation: dock-in .25s ease-out;
}
.composer-dock[style*="left"] { transform: none; }
.composer-dock:hover, .composer-dock:focus-visible { box-shadow: var(--ring), 0 6px 22px rgb(76 59 154 / 22%); outline: none; }
.dock-handle { position: absolute; top: 4px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: #c4b8e6; }
.dock-state { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: #6b5fa0; }
.dock-state:empty { display: none; }
.dock-state .btn-small { padding: 3px 9px; font-size: 11px; }
@keyframes dock-in { from { opacity: 0; translate: 0 12px; } to { opacity: 1; translate: 0 0; } }

/* ---------- Kopf der Chatfenster: neues Gespräch ---------- */
.new-chat-btn {
  position: absolute; top: 12px; right: 42px; z-index: 2; display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border-radius: 10px; border: 1px solid rgb(255 255 255 / 45%); background: rgb(255 255 255 / 18%); color: #fff;
}
.new-chat-btn:hover, .new-chat-btn:focus-visible { background: #fff; color: #5b3f8f; box-shadow: var(--ring); outline: none; transform: scale(1.06); }
.multi-mode .new-chat-btn { right: 88px; top: 14px; }
.chat-header { padding-left: 84px; padding-right: 84px; }
.multi-mode .chat-header { padding-left: 36px; padding-right: 116px; }
.chat-header .chat-title, .chat-header .chat-subtitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-colors .new-chat-btn { color: inherit; border-color: currentColor; }

/* ---------- Sprechblasen: Anbieter, Modell, Token, abgeschnittene Antworten ---------- */
.message-model { text-transform: none; letter-spacing: 0; font-weight: 500; opacity: .9; }
.token-info { align-items: center; gap: 6px 10px; }
.token-info .token-estimated { font-style: italic; }
.message-wrapper.user .token-info { opacity: 1; }
.message-wrapper.user .token-info span { color: #fff; background: rgb(255 255 255 / 20%); }
.token-info[title] { cursor: help; }
.truncated-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 10px; padding: 8px 10px; border-radius: 10px;
  background: #fff7ed; border: 1px solid #fdba74; color: #7c2d12; font-size: 12px; line-height: 1.5;
}
.truncated-note span { flex: 1 1 220px; }
.truncated-note .btn-small, .error-message .btn-small { padding: 4px 10px; font-size: 11px; }
.error-message .btn-small { margin-left: 6px; }

/* ---------- Gesprächsverlauf mit Zeitstempel und Titel ---------- */
#history-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.history-row { display: flex; align-items: center; gap: 6px; padding: 4px; border-radius: 12px; border: 1px solid #ece6f5; background: #fff; }
.history-row.current { border-color: #a78bfa; box-shadow: 0 0 0 2px rgb(167 139 250 / 20%); }
.history-open { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; flex: 1 1 auto; min-width: 0; padding: 6px 10px; border: 0; background: transparent; text-align: left; }
.history-open:hover { background: #f5f0fb; }
.history-stamp { font: 600 11px/1.3 ui-monospace, Menlo, monospace; color: #6b5fa0; }
.history-title { font-size: 13px; color: #2e2a3d; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-rename { flex-shrink: 0; padding: 6px 9px; }
.history-edit { flex: 1 1 auto; min-width: 0; padding: 6px 10px; font-size: 13px; }

/* ---------- Tresor merken, vertraute Browser ---------- */
.trust-choice { border: 1px solid #e4ddee; border-radius: 12px; padding: 10px 12px 6px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.trust-choice legend { padding: 0 6px; font-size: 12px; font-weight: 650; color: #5b3f8f; }
.trust-choice .check { display: flex; flex-direction: row; align-items: flex-start; gap: 9px; margin: 0; font-size: 13px; color: #3a3550; cursor: pointer; }
.trust-choice .check input { flex: 0 0 auto; width: 16px; height: 16px; margin: 3px 0 0; padding: 0; display: inline-block; accent-color: #6d5bd0; }
.trust-choice .check > span { display: block; min-width: 0; }
.trust-choice .check:has(input:checked) strong { color: #4c3b9a; }
.trust-choice .check small { display: block; font-size: 11px; color: #8a8199; font-weight: 400; }
.trust-reason { margin: 0; padding: 8px 10px; border-radius: 10px; background: #eef2ff; color: #3730a3; font-size: 12px; }
#vault-dialog .trust-unlock { font-size: 15px; padding: 13px 16px; color: #fff; border: 0; background: linear-gradient(135deg, var(--brand-start), var(--brand-end)); box-shadow: 0 6px 18px rgb(102 126 234 / 35%); }
#vault-dialog .trust-unlock:hover, #vault-dialog .trust-unlock:focus-visible { filter: brightness(1.08); box-shadow: var(--ring), 0 6px 18px rgb(102 126 234 / 35%); outline: none; }
#trust-list { display: flex; flex-direction: column; gap: 6px; }
.trust-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid #ece6f5; border-radius: 10px; background: #fff; }
.trust-row.current { border-color: #a78bfa; }
.trust-row small { display: block; }

@media (max-width: 768px) {
  .composer-window { min-width: 0; padding: 0 10px 10px; }
  .composer-bar { margin: 0 -10px; padding: 4px 6px 4px 10px; cursor: default; border-radius: 16px 16px 0 0; gap: 6px; }
  .composer-grip, .composer-resize { display: none; }
  .composer-title { font-size: 11px; }
  .composer-window.maximized { left: 8px; right: 8px; top: calc(var(--mobile-bar) + env(safe-area-inset-top) + 4px); bottom: calc(var(--footer-height) + 6px); }
  .composer-dock { bottom: calc(var(--footer-height) + 6px); padding: 12px 16px 8px; font-size: 12px; }
  .new-chat-btn { top: 13px; right: 34px; width: 30px; height: 30px; }
  .multi-mode .new-chat-btn { right: 70px; }
  .chat-header { padding-left: 14px; padding-right: 74px; }
  .multi-mode .chat-header { padding-left: 14px; padding-right: 108px; }
}
@media (max-width: 380px) {
  .composer-title { display: none; }
}
@media (prefers-reduced-motion: reduce) { .composer-dock { animation: none; } }

/* ---------- Logo in der Farbe der Chatköpfe ---------- */
.brand-mark, .mobile-brand .brand-mark { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); color: #fff; }
.brand { color: #4f46e5; }
.mobile-brand { color: #5b50e6; }
.mobile-brand .brand-word { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- „M“-Menü: ein Knopf statt drei ---------- */
.menu-m {
  position: fixed; top: 90px; right: 30px; z-index: 1002; display: grid; place-items: center; width: 50px; height: 50px; padding: 0;
  border-radius: 50%; border: 1px solid #e5e7eb; background: #fff; box-shadow: 0 4px 15px rgb(0 0 0 / 10%);
  transition: transform .25s ease, box-shadow .25s ease;
}
body.is-authenticated .menu-m { top: 30px; }
.menu-m:hover, .menu-m:focus-visible { background: #fff; transform: scale(1.08); box-shadow: var(--ring), 0 6px 20px rgb(99 102 241 / 25%); outline: none; }
.menu-m .m-shadow { fill: none; stroke: rgb(99 102 241 / 16%); stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; }
.menu-m .m-stroke { fill: none; stroke: url(#menu-m-gradient); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 80; stroke-dashoffset: 0; }
.menu-m .m-dot { fill: #8b5cf6; transform-box: fill-box; transform-origin: center; animation: m-pulse 3.2s ease-in-out infinite; }
.menu-m:hover .m-stroke { animation: m-draw .9s ease; }
body.menu-open .menu-m { transform: rotate(-8deg); box-shadow: var(--ring), 0 6px 20px rgb(99 102 241 / 25%); }
@keyframes m-draw { from { stroke-dashoffset: 80; } to { stroke-dashoffset: 0; } }
@keyframes m-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.35); opacity: .7; } }
.menu-item { transition: opacity .22s ease, transform .28s cubic-bezier(.2, .9, .3, 1.3), visibility .28s; }
body:not(.menu-open) .menu-item { opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(-16px) scale(.6); }
body.menu-open .pdf-export-button.menu-item { transition-delay: .04s; }
body.menu-open .ki-selection-button.menu-item { transition-delay: .08s; }
@media (min-width: 769px) {
  .toggle-settings.menu-item { top: 150px; } .pdf-export-button.menu-item { top: 210px; } .ki-selection-button.menu-item { top: 270px; }
  body.is-authenticated .toggle-settings.menu-item { top: 90px; } body.is-authenticated .pdf-export-button.menu-item { top: 150px; }
  body.is-authenticated .ki-selection-button.menu-item { top: 210px; }
  .settings-dropdown-menu { top: 150px; } .ki-selection-dropdown { top: 210px; }
  body.is-authenticated .settings-dropdown-menu { top: 90px; } body.is-authenticated .ki-selection-dropdown { top: 150px; }
}
@media (max-width: 768px) {
  .menu-m { top: calc(9px + env(safe-area-inset-top)); right: 56px; width: 40px; height: 40px; box-shadow: 0 2px 8px rgb(0 0 0 / 10%); }
  body.is-authenticated .menu-m { right: 10px; }
  .menu-m svg { width: 26px; height: 26px; }
  body .toggle-settings.menu-item, body .pdf-export-button.menu-item, body .ki-selection-button.menu-item { right: 56px; }
  body.is-authenticated .toggle-settings.menu-item, body.is-authenticated .pdf-export-button.menu-item, body.is-authenticated .ki-selection-button.menu-item { right: 10px; }
  body .toggle-settings.menu-item { top: calc(57px + env(safe-area-inset-top)); }
  body .pdf-export-button.menu-item { top: calc(105px + env(safe-area-inset-top)); }
  body .ki-selection-button.menu-item { top: calc(153px + env(safe-area-inset-top)); }
}

/* ---------- Fensterköpfe klappen nach 3 Sekunden ein ---------- */
.chat-header { max-height: 160px; transition: height .35s ease, min-height .35s ease, max-height .35s ease, padding .35s ease; }
.chat-header > * { transition: opacity .2s ease; }
.ki-role-selector { max-height: 140px; transition: max-height .3s ease, padding .3s ease, opacity .25s ease; }
.chat-container.header-collapsed > .chat-header { height: 10px; min-height: 10px; max-height: 10px; padding-top: 0; padding-bottom: 0; cursor: pointer; overflow: hidden; }
.chat-container.header-collapsed > .chat-header > * { opacity: 0; pointer-events: none; }
.chat-container.header-collapsed > .chat-header::after {
  content: ''; position: absolute; top: 3px; left: 50%; width: 44px; height: 4px; margin-left: -22px; border-radius: 4px;
  background: color-mix(in srgb, currentColor 55%, transparent);
}
.chat-container.header-collapsed > .ki-role-selector { max-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0; overflow: hidden; border: 0; }

/* ---------- Startansicht: TV-Bildschirme ---------- */
.tv {
  position: relative; display: block; width: 100%; padding: 9px 9px 0; border: 0; border-radius: 22px; text-align: left; color: inherit; font: inherit;
  background: linear-gradient(160deg, #2e2a45, #15131f); box-shadow: 0 18px 36px -14px rgb(24 16 60 / 50%), inset 0 0 0 1px rgb(255 255 255 / 8%);
  transition: transform .25s ease, box-shadow .25s ease;
}
.tv:hover, .tv:focus-visible { background: linear-gradient(160deg, #2e2a45, #15131f); transform: translateY(-4px); outline: none; box-shadow: 0 26px 46px -16px rgb(24 16 60 / 60%), 0 0 0 3px rgb(139 92 246 / 60%); }
.tv-screen { position: relative; isolation: isolate; display: flex; flex-direction: column; aspect-ratio: 3 / 4; padding: 12px 14px 0; border-radius: 15px; overflow: hidden; color: #1e1a33; }
.tv-coral .tv-screen { background: radial-gradient(130% 90% at 15% 0%, #ffe1dc 0%, #ff8a80 55%, #ef5f57 100%); }
.tv-green .tv-screen { background: radial-gradient(130% 90% at 15% 0%, #eaf8de 0%, #b2df8a 55%, #84c35c 100%); }
.tv-blue .tv-screen { background: radial-gradient(130% 90% at 15% 0%, #e2f8ff 0%, #91e1f9 55%, #56c2e8 100%); }
.tv-grey .tv-screen { background: radial-gradient(130% 90% at 15% 0%, #f7f7f9 0%, #d6d6d6 55%, #b3b3bb 100%); }
.tv-screen::before { content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none; background: repeating-linear-gradient(0deg, rgb(0 0 0 / 5%) 0 1px, transparent 1px 3px); animation: tv-flicker 7s infinite; }
.tv-glare { position: absolute; inset: 0; z-index: 4; pointer-events: none; background: linear-gradient(125deg, rgb(255 255 255 / 38%) 0%, transparent 30%); }
.tv-top { display: flex; align-items: center; gap: 8px; font: 700 10px/1 system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.tv-live { flex-shrink: 0; padding: 4px 7px; border-radius: 6px; background: #e11d48; color: #fff; animation: tv-live 1.8s ease-in-out infinite; }
.tv-channel { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .78; }
.tv-visual { display: grid; place-items: center; flex: 1 1 auto; min-height: 0; padding: 4px 0; }
.tv-art { width: 100%; max-height: 100%; animation: tv-zoom 14s ease-in-out infinite alternate; animation-delay: var(--tv-delay, 0s); }
.tv-slides { position: relative; min-height: 88px; }
.tv-slide { position: absolute; inset: 0; opacity: 0; transform: translateY(8px); transition: opacity .6s ease, transform .6s ease; }
.tv-slide.active { position: relative; opacity: 1; transform: none; }
.tv-title { display: block; margin-bottom: 4px; font: 800 clamp(15px, 1.25vw, 19px)/1.2 system-ui, sans-serif; letter-spacing: -.01em; color: #1e1a33; }
.tv-text { margin: 0; font-size: 12.5px; line-height: 1.45; color: rgb(30 26 51 / 84%); }
.tv-progress { display: flex; gap: 4px; margin: 8px 0 7px; }
.tv-progress i { flex: 1; height: 3px; border-radius: 3px; background: rgb(0 0 0 / 14%); transition: background .4s; }
.tv-progress i.on { background: #1e1a33; }
.tv-cta { align-self: flex-start; margin-bottom: 8px; padding: 6px 11px; border-radius: 999px; background: #1e1a33; color: #fff; font: 700 12px/1.2 system-ui, sans-serif; }
.tv-ticker { margin: 0 -14px; padding: 6px 0; overflow: hidden; white-space: nowrap; background: rgb(20 16 40 / 86%); color: #fff; font: 600 11px/1 system-ui, sans-serif; }
.tv-run { display: inline-block; animation: tv-ticker 28s linear infinite; }
.tv-stand { display: block; width: 34%; height: 9px; margin: 8px auto 0; border-radius: 0 0 10px 10px; background: linear-gradient(#3b3654, #1b1829); }
.tv-ring { fill: none; stroke: rgb(255 255 255 / 60%); stroke-width: 2; stroke-dasharray: 4 7; transform-box: fill-box; transform-origin: center; animation: tv-spin 40s linear infinite; }
.tv-link { stroke: rgb(255 255 255 / 75%); stroke-width: 2; }
.tv-bubble { fill: #fff; stroke: rgb(30 26 51 / 10%); }
.tv-lines { stroke: #8b5cf6; stroke-width: 2.4; stroke-linecap: round; }
.tv-node { transform-box: fill-box; transform-origin: center; animation: tv-pop 3.6s ease-in-out infinite; }
.tv-node[data-i="1"], .tv-column[data-i="1"], .tv-bar[data-i="1"], .tv-finger[data-i="1"] { animation-delay: .5s; }
.tv-node[data-i="2"], .tv-column[data-i="2"], .tv-bar[data-i="2"], .tv-finger[data-i="2"] { animation-delay: 1s; }
.tv-node[data-i="3"], .tv-column[data-i="3"], .tv-bar[data-i="3"], .tv-finger[data-i="3"] { animation-delay: 1.5s; }
.tv-node[data-i="4"], .tv-column[data-i="4"], .tv-bar[data-i="4"] { animation-delay: 2s; }
.tv-node[data-i="5"] { animation-delay: 2.5s; }
.tv-core { fill: #4f46e5; }
.tv-check { fill: none; stroke: #fff; stroke-width: 3.6; stroke-linecap: round; stroke-linejoin: round; }
.tv-card { fill: rgb(255 255 255 / 86%); }
.tv-avatar { fill: #4f46e5; }
.tv-line { fill: #b9c2d3; }
.tv-column { animation: tv-rise 4.5s ease-in-out infinite; }
.tv-bar { fill: #4f46e5; transform-box: fill-box; transform-origin: bottom; animation: tv-grow 3.4s ease-in-out infinite alternate; }
.tv-grid { stroke: #cbd5e1; stroke-width: 2; fill: none; }
.tv-mountain { fill: #34d399; }
.tv-sun { fill: #fbbf24; }
.tv-shield { fill: rgb(255 255 255 / 88%); stroke: #4f46e5; stroke-width: 3; }
.tv-lock { fill: #4f46e5; }
.tv-shackle { fill: none; stroke: #4f46e5; stroke-width: 6; stroke-linecap: round; }
.tv-keyhole { fill: #fff; }
.tv-finger { fill: none; stroke: #6366f1; stroke-width: 2.5; stroke-linecap: round; opacity: .75; animation: tv-scan 2.8s ease-in-out infinite; }
@keyframes tv-ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes tv-zoom { from { transform: scale(1); } to { transform: scale(1.06); } }
@keyframes tv-live { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes tv-flicker { 0%, 96%, 100% { opacity: 1; } 97% { opacity: .6; } 98% { opacity: 1; } 99% { opacity: .8; } }
@keyframes tv-spin { to { transform: rotate(360deg); } }
@keyframes tv-pop { 0%, 100% { transform: scale(1); } 45% { transform: scale(1.12); } }
@keyframes tv-rise { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes tv-grow { from { transform: scaleY(.55); } to { transform: scaleY(1); } }
@keyframes tv-scan { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@media (max-width: 768px) {
}

/* ---------- Chatmodus per langem Drücken auf „Senden“ ---------- */
#sendButton { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.mode-popover {
  position: fixed; z-index: 6000; width: min(340px, calc(100vw - 16px)); padding: 12px; border-radius: 18px;
  background: rgb(255 255 255 / 98%); border: 1px solid rgb(99 102 241 / 22%); box-shadow: 0 24px 60px -18px rgb(49 46 129 / 45%);
  animation: mode-pop .18s ease-out;
}
.mode-heading { margin: 2px 6px 8px; font: 700 11px/1.2 system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: #6366f1; }
.mode-options { display: flex; flex-direction: column; gap: 6px; }
.mode-option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid #ece8f7; background: #fff; text-align: left; color: #1f2937; font-weight: 400; }
.mode-option:hover, .mode-option:focus-visible { border-color: #a5b4fc; background: #f5f3ff; box-shadow: var(--ring); outline: none; }
.mode-option.current { border-color: #8b5cf6; background: linear-gradient(135deg, rgb(99 102 241 / 8%), rgb(139 92 246 / 12%)); }
.mode-icon { font-size: 22px; line-height: 1; }
.mode-label { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.mode-label strong { font-size: 14px; color: #312e81; }
.mode-label small { font-size: 11.5px; line-height: 1.4; color: #6b7280; }
.mode-check { font-weight: 800; color: #6366f1; }
.mode-note { margin: 8px 4px 0; font-size: 12px; color: #b45309; }
@keyframes mode-pop { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .chat-header, .chat-header > *, .ki-role-selector, .menu-item, .menu-m, .tv, .tv-slide { transition: none; }
  .tv-art, .tv-run, .tv-live, .tv-screen::before, .tv-ring, .tv-node, .tv-column, .tv-bar, .tv-finger, .menu-m .m-dot, .mode-popover { animation: none; }
}

/* ---------- TV-Bildschirme passen immer ins Chatfenster (Breite und Höhe) ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.chat-messages:has(> .tv-wall) { container-type: size; overflow: hidden; }
/* Startwand: Seite 1 die Erklär-Vitrine, darunter (senkrecht scrollen) die Kanäle */
.chat-messages .tv-wall {
  --tv-pad: clamp(12px, 3.2cqmin, 26px); --tv-gap: clamp(10px, 2.4cqmin, 24px); --tv-extra: 34px;
  width: 100%; height: 100cqh; margin: 0; padding: 0;
  overflow-x: hidden; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: thin;
}
.chat-messages .tv-intro, .chat-messages .tv-grid { height: 100cqh; scroll-snap-align: start; scroll-snap-stop: always; }
.chat-messages .tv-intro { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: var(--tv-pad) var(--tv-pad) 6px; }
.chat-messages .tv-grid {
  display: flex; align-items: center; gap: var(--tv-gap); padding: var(--tv-pad);
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scroll-padding-inline: var(--tv-pad);
}
/* Schmal (Handy): ein Bildschirm pro Ansicht, waagerecht wischbar */
.chat-messages .tv-grid > .tv { flex: 0 0 auto; width: min(82cqw, calc((100cqh - 2 * var(--tv-pad) - var(--tv-extra)) * .8)); scroll-snap-align: center; }
.chat-messages .tv-grid > .tv:first-child { margin-left: auto; }
.chat-messages .tv-grid > .tv:last-child { margin-right: auto; }
.chat-messages .tv-grid .tv-screen { aspect-ratio: 4 / 5; }
/* Mittel: 2 × 2 */
@container (min-width: 520px) {
  .chat-messages .tv-grid { display: grid; grid-template-columns: repeat(2, auto); place-content: center; overflow: hidden; }
  .chat-messages .tv-grid > .tv { margin: 0; width: min(calc((100cqw - 2 * var(--tv-pad) - var(--tv-gap)) / 2), calc(((100cqh - 2 * var(--tv-pad) - var(--tv-gap)) / 2 - var(--tv-extra)) * .75)); }
  .chat-messages .tv-grid .tv-screen { aspect-ratio: 3 / 4; }
}
/* Breit: vier nebeneinander */
@container (min-width: 520px) and (min-aspect-ratio: 3 / 2) {
  .chat-messages .tv-grid { grid-template-columns: repeat(4, auto); }
  .chat-messages .tv-grid > .tv { width: min(calc((100cqw - 2 * var(--tv-pad) - 3 * var(--tv-gap)) / 4), calc((100cqh - 2 * var(--tv-pad) - var(--tv-extra)) * .75)); }
}
/* Ein Bildschirm pro KI-Fenster im Parallelmodus */
.chat-messages .tv-wall.tv-single { display: flex; align-items: center; justify-content: center; padding: var(--tv-pad); overflow: hidden; scroll-snap-type: none; }
.chat-messages .tv-wall.tv-single > .tv { margin: 0; width: min(calc(100cqw - 2 * var(--tv-pad)), calc((100cqh - 2 * var(--tv-pad) - var(--tv-extra)) * .75), 360px); }
.chat-messages .tv-wall.tv-single .tv-screen { aspect-ratio: 3 / 4; }
/* Schrift und Abstände wachsen mit dem Bildschirm */
.tv { container-type: inline-size; }
.tv-screen { padding: 4cqi 4.6cqi 0; }
.tv-top { font-size: clamp(8px, 3.3cqi, 11px); gap: 2.4cqi; }
.tv-live { padding: 1.2cqi 2.2cqi; }
.tv-title { font-size: clamp(12px, 6.6cqi, 21px); }
.tv-text { font-size: clamp(10px, 4.3cqi, 14px); }
.tv-slides { min-height: 27cqi; }
.tv-progress { margin: 2.4cqi 0 2.2cqi; }
.tv-cta { font-size: clamp(10px, 4cqi, 13px); padding: 1.8cqi 3.4cqi; margin-bottom: 2.4cqi; }
.tv-ticker { font-size: clamp(9px, 3.5cqi, 12px); padding: 1.8cqi 0; margin: 0 -4.6cqi; }

/* ---------- „M“ auf dem Handy: auf Höhe des Logos, Menü als saubere Spalte ---------- */
@media (max-width: 768px) {
  body .menu-m, body.is-authenticated .menu-m { top: calc(9px + env(safe-area-inset-top)); }
  body .menu-item.toggle-settings { top: calc(58px + env(safe-area-inset-top)); }
  body .menu-item.pdf-export-button { top: calc(106px + env(safe-area-inset-top)); }
  body .menu-item.ki-selection-button { top: calc(154px + env(safe-area-inset-top)); }
  body.is-authenticated .menu-item.logout-button {
    top: calc(202px + env(safe-area-inset-top)); right: 10px; left: auto; bottom: auto; width: 40px; height: 40px; min-width: 40px; font-size: 18px; z-index: 1001;
  }
  body.menu-open .menu-m { transform: none; }
}
/* Abmelden als vierter Menüpunkt (Desktop) */
@media (min-width: 769px) {
  body.is-authenticated .menu-item.logout-button { top: 270px; right: 30px; left: auto; bottom: auto; width: 50px; height: 50px; z-index: 1001; }
}
body.menu-open .logout-button.menu-item { transition-delay: .12s; }

/* ---------- Vollbild-Arbeitsfläche: Fußzeile erst beim Scrollen ---------- */
body { overflow-x: hidden; overflow-y: auto; }
.portal-legal {
  position: relative; z-index: 1; left: auto; right: auto; bottom: auto; margin-top: 0; gap: 8px;
  padding: 22px 16px calc(22px + env(safe-area-inset-bottom)); background: rgb(255 255 255 / 88%);
  border-top: 1px solid rgb(99 102 241 / 14%); box-shadow: 0 -10px 30px -24px rgb(49 46 129 / 40%);
}
body.is-authenticated .portal-legal { padding-left: 16px; }
.footer-logout { padding: 2px 11px; border-radius: 999px; border: 1px solid rgb(211 47 47 / 30%); background: #fff5f5; color: #b42318; font: 600 12px/1.45 system-ui, sans-serif; }
.footer-logout:hover, .footer-logout:focus-visible { background: #fee4e2; box-shadow: var(--ring); outline: none; }
body.footer-in-view :is(#question-form, #composer-dock, .mode-popover) { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s ease, visibility .2s; }
#question-form, #composer-dock { transition: opacity .2s ease, visibility .2s; }
@media (min-width: 769px) {
  .main-container, .main-container.single-mode { height: calc(100svh - 16px - 12px); margin-bottom: 12px; }
  .multi-ki-container { height: calc(100svh - 16px - 12px); margin-bottom: 12px; }
}
@media (max-width: 768px) {
  html, body { height: auto; }
  body { min-height: 100%; overflow-x: hidden; overflow-y: auto; }
  .footer-stats { flex-wrap: wrap; height: auto; overflow: visible; gap: 2px 12px; }
  .footer-stats .stat-chip { display: inline-flex; }
}

/* ---------- „Neu“ in der Kopfzeile des Eingabefensters ---------- */
.composer-new {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; flex-shrink: 0;
  border: 1px solid rgb(99 102 241 / 30%); background: #fff; color: #4f46e5; font: 600 11.5px/1.2 system-ui, sans-serif;
}
.composer-new:hover, .composer-new:focus-visible { background: linear-gradient(135deg, var(--brand-start), var(--brand-end)); color: #fff; box-shadow: var(--ring); outline: none; }
@media (max-width: 420px) { .composer-new span { display: none; } .composer-new { padding: 4px 7px; } }
@media (max-width: 768px) {
  /* iPhone: Abstand zur Home-Leiste, Chatfenster endet genau über der Eingabe */
  .chat-input-modal, .composer-dock { bottom: calc(6px + env(safe-area-inset-bottom)); }
  #chatContainer, .multi-ki-container.active {
    height: calc(100svh - var(--mobile-bar) - env(safe-area-inset-top) - var(--composer-height) - env(safe-area-inset-bottom) - 18px);
    margin-bottom: calc(var(--composer-height) + env(safe-area-inset-bottom) + 18px);
  }
}
/* Die Grafik gibt Platz ab, damit Text, Fortschritt, Knopf und Laufband immer ganz sichtbar bleiben. */
.tv-visual { position: relative; flex: 1 1 0; min-height: 16%; overflow: hidden; padding: 0; margin: 1.6cqi 0; }
.tv-visual .tv-art { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; }
.tv-slides { flex: 0 0 auto; }
.tv-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.tv-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.tv-progress { flex: 0 0 auto; margin-top: 3cqi; }
.tv-cta, .tv-ticker { flex: 0 0 auto; }

/* ---------- Anmelden/Registrieren ebenfalls unter dem „M“ (Gäste) ---------- */
.menu-m { top: 30px; }
body.menu-open .auth-button.menu-item { transition-delay: .12s; }
@media (min-width: 769px) {
  .toggle-settings.menu-item { top: 90px; } .pdf-export-button.menu-item { top: 150px; } .ki-selection-button.menu-item { top: 210px; }
  .auth-button.guest-only.menu-item { top: 270px; right: 30px; z-index: 1001; }
  .settings-dropdown-menu { top: 90px; } .ki-selection-dropdown { top: 150px; }
}
@media (max-width: 768px) {
  body .menu-m { right: 10px; }
  body .menu-item.toggle-settings, body .menu-item.pdf-export-button, body .menu-item.ki-selection-button { right: 10px; }
  body .menu-item.auth-button.guest-only { top: calc(202px + env(safe-area-inset-top)); right: 10px; z-index: 1001; }
}

/* ---------- Obere Leiste: beim Scrollen lila gefüllt, nichts scheint durch ---------- */
.top-bar { display: none; }
@media (max-width: 768px) {
  .top-bar {
    display: block; position: fixed; top: 0; left: 0; right: 0; z-index: 985; pointer-events: none;
    height: calc(var(--mobile-bar) + env(safe-area-inset-top)); background: transparent;
    transition: background-color .25s ease, box-shadow .25s ease, opacity .25s ease; opacity: 0;
  }
  body.page-scrolled .top-bar { opacity: 1; background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); box-shadow: 0 8px 20px -10px rgb(49 46 129 / 55%); }
  .mobile-brand .brand-mark, .mobile-brand .brand-word { transition: background .25s ease, color .25s ease; }
  body.page-scrolled .mobile-brand .brand-mark { background: #fff; color: #6366f1; }
  body.page-scrolled .mobile-brand .brand-word { background: none; -webkit-background-clip: border-box; background-clip: border-box; color: #fff; }
  body.page-scrolled .menu-m { box-shadow: 0 2px 10px rgb(30 20 80 / 30%); }
}
@media (prefers-reduced-motion: reduce) { .top-bar, .mobile-brand .brand-mark, .mobile-brand .brand-word { transition: none; } }
/* Desktop: „M“ und Menüpunkte liegen vollständig im rechten Rand neben dem Chatfenster – auch beim Scrollen. */
@media (min-width: 769px) {
  .menu-m { right: 12px; }
  body .menu-item.toggle-settings, body .menu-item.pdf-export-button, body .menu-item.ki-selection-button,
  body.is-authenticated .menu-item.logout-button, body .menu-item.auth-button.guest-only { right: 12px; }
  .settings-dropdown-menu, .ki-selection-dropdown, body.is-authenticated .settings-dropdown-menu, body.is-authenticated .ki-selection-dropdown { right: 72px; }
}
.scroll-debug {
  position: fixed; left: 6px; right: 6px; top: calc(var(--mobile-bar) + env(safe-area-inset-top) + 4px); z-index: 99999; margin: 0; padding: 6px 8px;
  max-height: 30vh; overflow: hidden; pointer-events: none; opacity: .9; white-space: pre-wrap; word-break: break-all;
  font: 10px/1.35 ui-monospace, Menlo, monospace; color: #e5ffe5; background: rgb(10 10 20 / 82%); border-radius: 8px;
}

/* iPhone: stabile Höhen (svh statt dvh) ändern sich nicht, wenn Safaris Leiste beim Scrollen ein- und
   ausfährt; kein Gummiband und kein versehentliches „Ziehen zum Neuladen“ am Seitenanfang. */
@media (max-width: 768px) {
  html, body { overscroll-behavior-y: none; }
}
/* Schreibmodus (Touch): Während das Eingabefeld aktiv ist, gibt es keine „zweite Seite“, auf die iOS
   beim Einblenden der Tastatur springen könnte. Die Fußzeile kehrt danach unverändert zurück. */
body.composing #portalFooter { display: none; }

/* ---------- Erklär-Vitrine (Kanal 0): plakativ in drei Bildern, darunter die Kanäle ---------- */
.chat-messages .tv-wall .tv-hero { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; width: min(100%, 1120px); container: hero / size; }
.chat-messages .tv-wall.tv-single > .tv-hero { flex: 0 0 auto; width: min(calc(100cqw - 2 * var(--tv-pad)), 560px); height: calc(100cqh - 2 * var(--tv-pad)); }
.chat-messages .tv-wall .tv-hero .tv-screen {
  --hp: clamp(10px, 2.6cqmin, 22px);
  aspect-ratio: auto; flex: 1 1 auto; min-height: 0; gap: clamp(4px, 1.3cqmin, 12px); padding: var(--hp) var(--hp) 0;
  background: radial-gradient(120% 90% at 8% 0%, #fff7ed 0%, #f5f3ff 45%, #ddd6fe 100%);
}
.tv-hero .tv-top { flex: 0 0 auto; gap: 8px; font-size: clamp(9px, min(3cqi, 2.6cqb), 13px); }
.tv-hero .tv-live { padding: .35em .65em; }
.tv-hero .hero-badge { background: #f59e0b; color: #1e1a33; }
.hero-title {
  flex: 0 0 auto; display: flex; flex-wrap: wrap; column-gap: .32em;
  font: 900 clamp(20px, min(7.4cqi, 5.6cqb), 44px)/1.08 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: -.02em; color: #1e1a33;
}
.hero-mark-line { padding: 0 .06em; color: #4c1d95; background: linear-gradient(transparent 56%, #fde047 56%, #fde047 92%, transparent 92%); }
.hero-lead { flex: 0 0 auto; margin: 0; font: 650 clamp(12px, min(3.8cqi, 3.2cqb), 19px)/1.3 system-ui, -apple-system, sans-serif; color: #5b21b6; }
.hero-steps { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: clamp(5px, 1.5cqmin, 14px); }
.hero-step {
  position: relative; flex: 1 1 0; min-height: 0; display: flex; align-items: center; gap: 3cqi; padding: 1.2cqmin 2.4cqmin; overflow: hidden;
  border-radius: 16px; background: #fff; box-shadow: 0 6px 16px -10px rgb(76 29 149 / 45%), inset 0 0 0 2px rgb(76 29 149 / 9%);
  animation: hero-focus 9s ease-in-out infinite;
}
.hero-step[data-i="1"] { animation-delay: 3s; }
.hero-step[data-i="2"] { animation-delay: 6s; }
.hero-pic { position: relative; flex: 0 0 28%; align-self: stretch; min-height: 0; }
.hero-art { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.hero-cap { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .25em; }
.hero-step-title { display: flex; align-items: center; gap: .4em; font: 850 clamp(13px, min(4.6cqi, 3.4cqb), 24px)/1.15 system-ui, -apple-system, sans-serif; color: #1e1a33; }
.hero-num {
  flex: 0 0 auto; display: grid; place-items: center; width: 1.5em; height: 1.5em; border-radius: 50%;
  background: #fde047; color: #1e1a33; font-size: .8em; font-weight: 900; box-shadow: inset 0 0 0 2px #1e1a33;
}
.hero-sub { display: block; font: 500 clamp(10.5px, min(3.4cqi, 2.5cqb), 16px)/1.3 system-ui, -apple-system, sans-serif; color: #4b5563; }
.hero-foot { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding-bottom: 6px; }
.tv-hero .hero-cta {
  margin: 0; padding: .55em 1.15em; border-radius: 999px; background: #fde047; color: #1e1a33;
  font: 850 clamp(13px, min(4.4cqi, 3.8cqb), 20px)/1.1 system-ui, -apple-system, sans-serif;
  box-shadow: 0 0 0 2px #1e1a33, 0 4px 0 2px #1e1a33; animation: hero-nudge 2.4s ease-in-out infinite;
}
.hero-trust { font: 650 clamp(11px, min(3.3cqi, 2.8cqb), 15px)/1.3 system-ui, -apple-system, sans-serif; color: #166534; }
.chat-messages .tv-wall .tv-hero .tv-ticker { flex: 0 0 auto; margin: 0 calc(-1 * var(--hp)); padding: .55em 0; font-size: clamp(10px, min(3.2cqi, 2.6cqb), 14px); }
.tv-hero .tv-stand { flex: 0 0 auto; width: 22%; }
/* Breite Vitrine: drei Bilder nebeneinander, mit Pfeilen verbunden */
@container hero (min-aspect-ratio: 5 / 4) and (min-width: 560px) {
  .hero-title { font-size: clamp(22px, min(4.6cqi, 9.6cqb), 58px); }
  .hero-lead { font-size: clamp(12px, min(1.8cqi, 4cqb), 22px); }
  .hero-steps { flex-direction: row; gap: clamp(26px, 4.4cqi, 60px); }
  .hero-step { flex-direction: column; align-items: stretch; gap: .6cqmin; padding: 1.6cqmin 1.6cqmin 2cqmin; text-align: center; overflow: visible; }
  .hero-pic { flex: 1 1 0; align-self: auto; }
  .hero-cap { flex: 0 0 auto; align-items: center; }
  .hero-step-title { justify-content: center; font-size: clamp(14px, min(2.1cqi, 5cqb), 28px); }
  .hero-sub { font-size: clamp(11px, min(1.4cqi, 3.5cqb), 17px); }
  .hero-step:not(:last-child)::after {
    content: '➜'; position: absolute; top: 42%; right: calc(-.5 * clamp(26px, 4.4cqi, 60px)); transform: translate(50%, -50%);
    font: 900 clamp(18px, 2.6cqi, 34px)/1 system-ui, sans-serif; color: #7c3aed;
  }
  .tv-hero .hero-cta { font-size: clamp(14px, min(1.9cqi, 4.6cqb), 22px); }
  .hero-trust { font-size: clamp(11px, min(1.3cqi, 3.2cqb), 16px); }
  .chat-messages .tv-wall .tv-hero .tv-ticker { font-size: clamp(10px, min(1.2cqi, 3cqb), 14px); }
}
/* Niedrige Vitrine: Nebensätze weichen zuerst, die drei Bilder bleiben */
@container hero (max-height: 600px) and (max-aspect-ratio: 5 / 4) { .hero-lead { display: none; } }
@container hero (max-height: 380px) { .hero-lead { display: none; } }
@container hero (max-height: 440px) { .hero-trust { display: none; } }
@container hero (max-height: 380px) { .hero-sub { display: none; } }
/* Bilder */
.hero-shirt { fill: #8b5cf6; stroke: #1e1a33; stroke-width: 3; }
.hero-skin { fill: #ffd8b8; stroke: #1e1a33; stroke-width: 3; }
.hero-hair { fill: #3b2f5c; }
.hero-eye { fill: #1e1a33; }
.hero-mouth { fill: none; stroke: #1e1a33; stroke-width: 3; stroke-linecap: round; }
.hero-cloud { fill: #fff; stroke: #1e1a33; stroke-width: 3; stroke-linejoin: round; }
.hero-bot { transform-box: fill-box; transform-origin: center bottom; animation: hero-bob 2.4s ease-in-out infinite; }
.hero-bot[data-i="1"] { animation-delay: .4s; }
.hero-bot[data-i="2"] { animation-delay: .8s; }
.hero-head, .hero-ear { stroke: #1e1a33; stroke-width: 3; }
.hero-head.coral, .hero-ear.coral { fill: #ff8a80; }
.hero-head.green, .hero-ear.green { fill: #84c35c; }
.hero-head.blue, .hero-ear.blue { fill: #56c2e8; }
.hero-face { fill: #fff; }
.hero-antenna { stroke: #1e1a33; stroke-width: 3; stroke-linecap: round; }
.hero-light { fill: #fde047; stroke: #1e1a33; stroke-width: 2; animation: hero-blink 1.8s ease-in-out infinite; }
.hero-bot[data-i="1"] .hero-light { animation-delay: .6s; }
.hero-bot[data-i="2"] .hero-light { animation-delay: 1.2s; }
.hero-gold { fill: #fcd34d; stroke: #1e1a33; stroke-width: 3; stroke-linejoin: round; }
.hero-key { transform-box: fill-box; transform-origin: 25% 50%; animation: hero-turn 3.2s ease-in-out infinite; }
.hero-beam { fill: rgb(253 224 71 / 45%); animation: hero-glow 3s ease-in-out infinite; }
.hero-stage { fill: #7c3aed; stroke: #1e1a33; stroke-width: 3; stroke-linejoin: round; }
.hero-chat { animation: hero-chat 2.4s ease-in-out infinite; }
.hero-chat[data-i="1"] { animation-delay: 1.2s; }
.hero-heart { fill: #f43f5e; stroke: #1e1a33; stroke-width: 2.5; stroke-linejoin: round; transform-box: fill-box; transform-origin: center; animation: hero-beat 1.6s ease-in-out infinite; }
.hero-arm { fill: none; stroke-width: 9; stroke-linecap: round; }
.hero-arm.human { stroke: #8b5cf6; }
.hero-arm.machine { stroke: #56c2e8; }
.hero-hand { fill: #cbd5e1; stroke: #1e1a33; stroke-width: 3; }
.hero-spark { fill: #f59e0b; transform-box: fill-box; transform-origin: center; animation: hero-twinkle 2s ease-in-out infinite; }
.hero-spark[data-i="1"] { animation-delay: .5s; }
.hero-spark[data-i="2"] { animation-delay: 1s; }
.hero-spark[data-i="3"] { animation-delay: 1.5s; }
/* Weiter zu den Kanälen */
.tv-more {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 5px 15px; border: 0; border-radius: 999px; cursor: pointer;
  background: rgb(255 255 255 / 88%); color: #4c1d95; font: 700 13px/1.2 system-ui, -apple-system, sans-serif;
  box-shadow: 0 4px 14px -6px rgb(76 29 149 / 45%), inset 0 0 0 1px rgb(139 92 246 / 30%);
}
.tv-more:hover, .tv-more:focus-visible { background: #fff; color: #4c1d95; box-shadow: var(--ring); outline: none; }
.tv-more-arrow { display: inline-block; animation: hero-bounce 1.6s ease-in-out infinite; }
@keyframes hero-focus { 0%, 30%, 100% { transform: none; } 8%, 22% { transform: scale(1.03); box-shadow: 0 0 0 3px #8b5cf6, 0 14px 30px -14px rgb(76 29 149 / 60%); } }
@keyframes hero-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes hero-blink { 0%, 100% { fill: #fde047; } 50% { fill: #fb923c; } }
@keyframes hero-twinkle { 0%, 100% { transform: scale(.6); opacity: .45; } 50% { transform: scale(1.1); opacity: 1; } }
@keyframes hero-turn { 0%, 60%, 100% { transform: none; } 75% { transform: rotate(-8deg); } 88% { transform: rotate(4deg); } }
@keyframes hero-glow { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes hero-chat { 0%, 100% { opacity: .25; transform: translateY(3px); } 30%, 60% { opacity: 1; transform: none; } }
@keyframes hero-beat { 0%, 30%, 60%, 100% { transform: scale(1); } 15% { transform: scale(1.18); } 45% { transform: scale(1.1); } }
@keyframes hero-nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes hero-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) {
  .hero-step, .hero-bot, .hero-light, .hero-spark, .hero-key, .hero-beam, .hero-chat, .hero-heart, .tv-hero .hero-cta, .tv-more-arrow { animation: none; }
  .chat-messages .tv-wall { scroll-behavior: auto; }
}

/* ---------- Mikro-Schalter: Sprache (DE · EN · TR) und Hell/Dunkel, ganz unten mittig in der Fußzeile ---------- */
html.i18n-pending body { visibility: hidden; }
.footer-prefs { justify-content: center; padding-top: 2px; }
.locale-bar {
  position: static; display: inline-flex; align-items: center; gap: 1px; padding: 2px;
  border-radius: 999px; border: 1px solid rgb(99 102 241 / 22%); background: rgb(255 255 255 / 86%);
  box-shadow: 0 2px 10px rgb(30 20 80 / 10%); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.locale-bar button {
  min-width: 24px; height: 22px; margin: 0; padding: 0 5px; border: 0; border-radius: 999px; background: transparent; box-shadow: none;
  color: #3f3a6b; font: 700 10px/22px system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: .04em; cursor: pointer; transform: none;
}
.locale-bar button:hover { background: rgb(99 102 241 / 14%); color: #2e2a6b; transform: none; box-shadow: none; }
.locale-bar button:focus-visible { outline: 2px solid #6366f1; outline-offset: 1px; }
.locale-bar .lang-pick[aria-pressed="true"] { background: linear-gradient(135deg, #5b5bd6, #7c4ddb); color: #fff; }
.locale-bar .theme-pick { display: grid; place-items: center; width: 24px; padding: 0; margin-left: 2px; }
.locale-bar .theme-pick svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 340px) { .locale-bar button { min-width: 22px; padding: 0 4px; } }
@media print { .locale-bar { display: none; } }

/* ---------- Dunkles Design (html[data-theme="dark"]) ----------
   Eigene Farbpalette statt Invertieren: tiefes Violett-Schwarz, helle Schrift mit hohem Kontrast
   (Fließtext ≥ 7:1, Nebentexte ≥ 4.5:1 nach WCAG). Die TV-Vitrinen behalten ihre hellen Bildschirme. */
html[data-theme="dark"] {
  color-scheme: dark;
  --dk-page-a: #0e0c18; --dk-page-b: #1a1129;
  --dk-surface: #17151f; --dk-surface-2: #201d2d; --dk-surface-3: #2a2640;
  --dk-border: rgb(255 255 255 / 12%); --dk-border-strong: rgb(167 139 250 / 35%);
  --dk-text: #ece9f7; --dk-muted: #b8b2cf; --dk-accent: #c4b8ff; --dk-accent-2: #a78bfa;
  --ring: 0 0 0 3px rgb(167 139 250 / 45%);
}
/* !important: Das helle Farbthema der Einstellungen setzt den Seitenhintergrund inline am body. */
html[data-theme="dark"], html[data-theme="dark"] body { background: linear-gradient(135deg, var(--dk-page-a) 0%, var(--dk-page-b) 100%) fixed !important; color: var(--dk-text); }
html[data-theme="dark"] :is(.chat-container, .settings-panel) { background: rgb(23 21 31 / 96%); border-color: var(--dk-border); box-shadow: 0 18px 50px -20px rgb(0 0 0 / 70%); }
html[data-theme="dark"] .chat-messages { background: #13111b; color: var(--dk-text); }
html[data-theme="dark"] .welcome-message { color: var(--dk-muted); }
html[data-theme="dark"] :is(.welcome-message h2, .welcome-message h3) { color: var(--dk-text); }
/* Nachrichten */
html[data-theme="dark"] .message-wrapper.assistant .message-bubble { background: var(--dk-surface-2); color: var(--dk-text); border-color: var(--dk-border); }
html[data-theme="dark"] .message-wrapper.assistant :is(.message-sender, .message-model, .message-timestamp, .token-info, .token-info span) { color: var(--dk-muted); }
html[data-theme="dark"] .message-wrapper.assistant .message-sender { color: var(--dk-accent); }
html[data-theme="dark"] .message-content :is(a) { color: var(--dk-accent); }
html[data-theme="dark"] .message-content :is(blockquote) { color: var(--dk-muted); border-color: var(--dk-border-strong); }
html[data-theme="dark"] .message-content :is(table, th, td) { border-color: var(--dk-border); }
html[data-theme="dark"] .message-content th { background: var(--dk-surface-3); color: var(--dk-text); }
html[data-theme="dark"] .message-content table { background: var(--dk-surface); }
html[data-theme="dark"] .message-content :not(pre) > code { background: var(--dk-surface-3); color: #f3d9ff; }
html[data-theme="dark"] .error-message { background: #3a1620; border-color: #7f1d36; color: #ffc9d3; }
html[data-theme="dark"] .truncated-note { background: #3a2a10; border-color: #8a6420; color: #ffe2a8; }
html[data-theme="dark"] :is(.typing-indicator, .mini-card) { background: var(--dk-surface-2); border-color: var(--dk-border); color: var(--dk-text); }
/* Rollen-Suche und Kopf */
html[data-theme="dark"] .ki-role-selector { background: rgb(255 255 255 / 4%); border-color: var(--dk-border); }
html[data-theme="dark"] .ki-role-search-input { background: var(--dk-surface-3); border-color: var(--dk-border); color: var(--dk-text); }
html[data-theme="dark"] .ki-role-search-input::placeholder { color: var(--dk-muted); opacity: 1; }
html[data-theme="dark"] :is(.ki-role-suggestions, .role-search-dropdown) { background: var(--dk-surface-2); border-color: var(--dk-border); color: var(--dk-text); }
html[data-theme="dark"] :is(.ki-role-suggestions, .role-search-dropdown) :is(li, div, span, small, strong) { color: inherit; }
html[data-theme="dark"] :is(.ki-role-suggestions li:hover, .ki-role-suggestions .selected, .role-search-item:hover) { background: var(--dk-surface-3); }
/* Eingabefenster */
html[data-theme="dark"] :is(.chat-input-modal, .composer-dock) { background: rgb(23 21 31 / 97%); border-color: var(--dk-border); box-shadow: 0 16px 40px -18px rgb(0 0 0 / 80%); }
html[data-theme="dark"] .composer-bar { background: linear-gradient(135deg, rgb(129 140 248 / 14%), rgb(167 139 250 / 14%)); }
html[data-theme="dark"] :is(.composer-title, .composer-bar span, #token-counter) { color: var(--dk-muted); }
html[data-theme="dark"] :is(.composer-new, .composer-win) { background: var(--dk-surface-3); border-color: var(--dk-border-strong); color: var(--dk-accent); }
html[data-theme="dark"] :is(.composer-new, .composer-win) span { color: var(--dk-accent); }
html[data-theme="dark"] .chat-input { background: var(--dk-surface-3); border-color: var(--dk-border); color: var(--dk-text); }
html[data-theme="dark"] .chat-input:focus { background: #2f2a48; border-color: var(--dk-accent-2); }
html[data-theme="dark"] .chat-input::placeholder { color: var(--dk-muted); opacity: 1; }
/* Menü „M“, Menüpunkte und Aufklappmenüs */
html[data-theme="dark"] .menu-m { background: var(--dk-surface-2); border-color: var(--dk-border-strong); }
html[data-theme="dark"] .menu-m:hover, html[data-theme="dark"] .menu-m:focus-visible { background: var(--dk-surface-3); }
html[data-theme="dark"] .menu-m .m-shadow { stroke: rgb(167 139 250 / 22%); }
html[data-theme="dark"] :is(.toggle-settings, .pdf-export-button, .ki-selection-button, .auth-button, .logout-button) { background: var(--dk-surface-2); border-color: var(--dk-border-strong); color: var(--dk-text); }
html[data-theme="dark"] :is(.settings-dropdown-menu, .ki-selection-dropdown, .mode-popover, .notification) { background: var(--dk-surface-2); border-color: var(--dk-border); color: var(--dk-text); box-shadow: 0 18px 40px -16px rgb(0 0 0 / 80%); }
html[data-theme="dark"] .settings-dropdown-menu button, html[data-theme="dark"] .settings-dropdown-menu > a { background: var(--dk-surface); border-color: var(--dk-border); color: var(--dk-text); }
html[data-theme="dark"] .settings-dropdown-menu button:hover, html[data-theme="dark"] .settings-dropdown-menu > a:hover { background: var(--dk-surface-3); color: #fff; }
html[data-theme="dark"] :is(.ki-group-title, .menu-note, .ki-selection-item, .ki-selection-item *) { color: var(--dk-text); }
html[data-theme="dark"] .ki-selection-item:hover { background: var(--dk-surface-3); }
html[data-theme="dark"] .mode-option { background: var(--dk-surface); border-color: var(--dk-border); color: var(--dk-text); }
html[data-theme="dark"] .mode-option:hover, html[data-theme="dark"] .mode-option:focus-visible { background: var(--dk-surface-3); border-color: var(--dk-accent-2); }
html[data-theme="dark"] .mode-option.current { background: rgb(167 139 250 / 16%); border-color: var(--dk-accent-2); }
html[data-theme="dark"] .mode-label strong { color: var(--dk-text); }
html[data-theme="dark"] .mode-label small { color: var(--dk-muted); }
html[data-theme="dark"] .mode-check { color: var(--dk-accent); }
html[data-theme="dark"] .mode-note { color: #fcd38d; }
/* Dialoge, Formulare, Listen */
html[data-theme="dark"] :is(dialog.modal, .auth-modal, .admin-dashboard, .billing-modal) { background: var(--dk-surface); border-color: var(--dk-border); color: var(--dk-text); }
html[data-theme="dark"] dialog.modal::backdrop { background: rgb(0 0 0 / 55%); }
html[data-theme="dark"] :is(.modal-content, .auth-content, .admin-content, .billing-content) { background: transparent; color: var(--dk-text); }
html[data-theme="dark"] :is(.modal-header, .modal-content h2, .modal-content h3, .modal-content h4, .modal-content legend, .modal-content label, .modal-content summary) { color: var(--dk-text); }
html[data-theme="dark"] :is(.modal-content p, .modal-content small, .modal-content li, .modal-content dd, .modal-content .hint, .modal-content .menu-note) { color: var(--dk-muted); }
html[data-theme="dark"] :is(.modal-content, .auth-content, .admin-content) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea),
html[data-theme="dark"] :is(.settings-content select, .settings-content input, .settings-content textarea, .form-select, #chat-mode) { background: var(--dk-surface-3); border-color: var(--dk-border); color: var(--dk-text); }
html[data-theme="dark"] :is(.modal-content, .auth-content) :is(input, textarea)::placeholder { color: var(--dk-muted); opacity: 1; }
html[data-theme="dark"] :is(.modal-close-btn, .auth-close, .admin-close, .billing-close, .window-close-btn) { background: var(--dk-surface-3); color: var(--dk-text); border-color: var(--dk-border); }
html[data-theme="dark"] :is(.provider-list-item, .model-list-item, .role-item-card, .history-row, .trust-row, .stat-card, .stammdaten-card, .form-section, .checkbox-group, .settings-section, .admin-nav, .product-card) { background: var(--dk-surface-2); border-color: var(--dk-border); color: var(--dk-text); }
html[data-theme="dark"] :is(.settings-section .settings-header, .results-table th, .data-table th, .table-header) { background: var(--dk-surface-3); color: var(--dk-text); }
html[data-theme="dark"] :is(.results-table, .data-table, .transactions-table, #admin-users) :is(td, tr) { border-color: var(--dk-border); color: var(--dk-text); }
html[data-theme="dark"] :is(.btn-small, .btn-secondary, .code-action-btn, .reset-button, .icon-suggestion, .icon-preview, .admin-nav-item, .history-open, .footer-logout) { background: var(--dk-surface-3); border-color: var(--dk-border-strong); color: var(--dk-text); }
html[data-theme="dark"] .modal-content :is(.secondary, .text-button) { background: var(--dk-surface-3); border-color: var(--dk-border-strong); color: var(--dk-text); }
html[data-theme="dark"] .modal-content pre:not(.hljs) { background: #0f0e16; border-color: var(--dk-border); color: var(--dk-text); }
/* Fußzeile */
html[data-theme="dark"] .portal-legal { background: rgb(19 17 27 / 92%); border-top-color: var(--dk-border); color: var(--dk-muted); box-shadow: none; }
html[data-theme="dark"] .portal-legal :is(span, b, strong, .stat-emoji, .wide-only) { color: var(--dk-muted); }
html[data-theme="dark"] .portal-legal b { color: var(--dk-text); }
html[data-theme="dark"] .legal-links { color: var(--dk-muted); }
html[data-theme="dark"] .legal-links a { color: var(--dk-accent); }
html[data-theme="dark"] .legal-links a:hover, html[data-theme="dark"] .legal-links a:focus-visible { background: #6d5bd0; color: #fff; }
html[data-theme="dark"] .share-trigger { background: linear-gradient(135deg, #2a2240, #35203a); border-color: var(--dk-border-strong); }
html[data-theme="dark"] .share-trigger :is(span, .share-label) { color: var(--dk-accent); }
html[data-theme="dark"] .login-status-indicator { background: rgb(74 222 128 / 12%); border-color: rgb(74 222 128 / 40%); color: #b7f5cb; }
/* Handy-Kopf, Mikro-Schalter, Startwand */
html[data-theme="dark"] .mobile-brand .brand-word { background: linear-gradient(135deg, #c4b5fd 0%, #f0abfc 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
html[data-theme="dark"] .locale-bar { background: rgb(32 29 45 / 90%); border-color: var(--dk-border-strong); box-shadow: 0 2px 12px rgb(0 0 0 / 50%); }
html[data-theme="dark"] .locale-bar button { color: var(--dk-text); }
html[data-theme="dark"] .locale-bar button:hover { background: rgb(167 139 250 / 22%); color: #fff; }
html[data-theme="dark"] .locale-bar .lang-pick[aria-pressed="true"] { background: linear-gradient(135deg, #5b5bd6, #7c4ddb); color: #fff; }
html[data-theme="dark"] .tv-more { background: var(--dk-surface-3); color: var(--dk-accent); box-shadow: 0 4px 14px -6px rgb(0 0 0 / 70%), inset 0 0 0 1px var(--dk-border-strong); }
html[data-theme="dark"] .tv-screen { filter: brightness(.94); }

/* ---------- Lesbarkeit (WCAG AA, Kontrast ≥ 4.5:1) in beiden Designs ---------- */
.chat-header { background: linear-gradient(135deg, #5b5be0 0%, #7c4ddb 100%); }
.chat-subtitle { color: #fff; }
.composer-bar #token-counter { color: #4b5563; }
.chat-input::placeholder { color: #5f6673; opacity: 1; }
html[data-theme="dark"] #token-counter { color: var(--dk-muted); }
html[data-theme="dark"] .chat-input::placeholder { color: var(--dk-muted); }
/* Kopfleisten von Dialogen, Anmeldung und Verwaltung: weiße Schrift braucht ein dunkleres Lila */
:is(.modal-header, .auth-header, .admin-header, .billing-header, .balance-card) { background: linear-gradient(135deg, #5b5be0 0%, #764ba2 100%); }
:is(.auth-close, .admin-close, .billing-close) { background: rgb(20 12 50 / 38%); color: #fff; }
:is(.auth-close, .admin-close, .billing-close):hover { background: rgb(20 12 50 / 55%); }
#admin-tabs .admin-nav-item.active, .admin-nav-item.active { background: #5b5be0; border-color: #5b5be0; color: #fff; }
.auth-tab.active { color: #4f46e5; border-bottom-color: #4f46e5; }
:is(.password-help, .auth-link a) { color: #4f46e5; }
#loginButton, form .auth-button:not(.guest-only) { background: linear-gradient(135deg, #5b5be0 0%, #764ba2 100%); color: #fff; }
.auth-tagline, #vault-dialog span > small { color: #5f5878; }
.add-role-button { background: linear-gradient(135deg, #047857 0%, #065f46 100%); }
.share-btn.instagram { background: linear-gradient(45deg, #b4306a, #8a2fa3 60%, #4a4fc4); }
.share-btn.facebook { background: #1565d8; }
/* Dunkel: Dialogtexte (im Original per !important dunkelgrau erzwungen) */
html[data-theme="dark"] .modal-content :is(h4, p, label, span, div) { color: var(--dk-text) !important; }
html[data-theme="dark"] .modal-content :is(p.micro, p.muted, .micro, .muted, .menu-note, .hint) { color: var(--dk-muted) !important; }
html[data-theme="dark"] .modal-content :is(.btn-small, button.btn-small) { background: var(--dk-surface-3); border-color: var(--dk-border-strong); color: var(--dk-text); }
html[data-theme="dark"] .btn-small { background: var(--dk-surface-3); border-color: var(--dk-border-strong); color: var(--dk-text); }
html[data-theme="dark"] .btn-small:hover { background: #352f52; }
html[data-theme="dark"] #limits-form .image-settings { background: var(--dk-surface-2); border-color: var(--dk-border); }
html[data-theme="dark"] .icon-preview { color: var(--dk-text); }
html[data-theme="dark"] :is(.modal-content, .auth-content, dialog) a :is(strong, span) { color: inherit; }
html[data-theme="dark"] :is(.modal-content, .auth-content, dialog) a { color: var(--dk-accent); }
html[data-theme="dark"] #vault-dialog span > :is(strong, small) { color: var(--dk-text); }
html[data-theme="dark"] #vault-dialog span > small { color: var(--dk-muted); }
html[data-theme="dark"] .auth-content :is(.auth-tab) { color: var(--dk-muted); }
html[data-theme="dark"] .auth-content .auth-tab.active { color: var(--dk-accent); border-bottom-color: var(--dk-accent-2); }
html[data-theme="dark"] .auth-content :is(.form-label, label, h2, h3) { color: var(--dk-text); }
html[data-theme="dark"] .auth-content :is(.auth-lead, .auth-hint, .auth-tagline, p, small) { color: var(--dk-muted); }
html[data-theme="dark"] .auth-content :is(.password-help, .auth-link a) { color: var(--dk-accent); }
html[data-theme="dark"] .auth-content :is(input, select) { background: var(--dk-surface-3); border-color: var(--dk-border); color: var(--dk-text); }
html[data-theme="dark"] .share-btn:is(.copy, .native) { background: var(--dk-surface-3); color: var(--dk-accent); }

/* ---------- Begrüßungs-Vitrine (erste Seite): Willkommen, Nutzen, KOSTENLOS ---------- */
.chat-messages .tv-wall .tv-welcome .tv-screen { background: radial-gradient(120% 90% at 8% 0%, #ecfdf5 0%, #f5f3ff 50%, #e0e7ff 100%); }
.welcome-body { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: clamp(6px, 1.6cqmin, 16px); }
.welcome-pic { position: relative; flex: 1 1 0; min-height: 48px; }
.welcome-copy { flex: 0 0 auto; display: flex; flex-direction: column; gap: clamp(5px, 1.2cqmin, 12px); }
.welcome-lead { margin: 0; font: 800 clamp(14px, min(4.6cqi, 3.4cqb), 24px)/1.25 system-ui, -apple-system, sans-serif; color: #1e1a33; }
.welcome-text { margin: 0; font: 500 clamp(11.5px, min(3.6cqi, 2.7cqb), 17px)/1.4 system-ui, -apple-system, sans-serif; color: #374151; }
.welcome-perks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.welcome-perk {
  display: inline-flex; align-items: center; gap: .3em; padding: .35em .75em; border-radius: 999px; background: #fff; color: #1e1a33;
  font: 750 clamp(11px, min(3.3cqi, 2.6cqb), 15px)/1.2 system-ui, -apple-system, sans-serif; box-shadow: inset 0 0 0 2px rgb(76 29 149 / 16%);
}
.welcome-perk.free {
  background: #fde047; font-size: clamp(13px, min(4.4cqi, 3.4cqb), 22px); font-weight: 900; letter-spacing: .05em;
  box-shadow: 0 0 0 2px #1e1a33, 0 3px 0 2px #1e1a33; animation: welcome-free 2.6s ease-in-out infinite;
}
.welcome-note { font: 600 clamp(10.5px, min(3cqi, 2.4cqb), 14px)/1.3 system-ui, -apple-system, sans-serif; color: #4b5563; }
@container hero (min-aspect-ratio: 5 / 4) and (min-width: 560px) {
  .welcome-body { flex-direction: row; align-items: stretch; }
  .welcome-pic { flex: 1 1 44%; }
  .welcome-copy { flex: 1 1 56%; justify-content: center; }
  .welcome-lead { font-size: clamp(16px, min(2.5cqi, 5.6cqb), 32px); }
  .welcome-text { font-size: clamp(12px, min(1.6cqi, 3.8cqb), 20px); }
  .welcome-perk { font-size: clamp(12px, min(1.35cqi, 3.2cqb), 17px); }
  .welcome-perk.free { font-size: clamp(14px, min(2cqi, 4.4cqb), 26px); }
  .welcome-note { font-size: clamp(11px, min(1.2cqi, 3cqb), 15px); }
}
@container hero (max-height: 560px) and (max-aspect-ratio: 5 / 4) { .welcome-note { display: none; } }
@container hero (max-height: 400px) { .welcome-note { display: none; } }
@container hero (max-height: 300px) { .welcome-text { display: none; } }
.welcome-window { fill: #fff; stroke: #1e1a33; stroke-width: 3; }
.welcome-bar { fill: #ede9fe; stroke: #1e1a33; stroke-width: 3; }
.welcome-dot { fill: #f87171; }
.welcome-dot[data-i="1"] { fill: #fbbf24; }
.welcome-dot[data-i="2"] { fill: #34d399; }
.welcome-col { fill: #f5f3ff; stroke: rgb(30 26 51 / 25%); stroke-width: 2; }
.welcome-line { fill: #a78bfa; animation: welcome-type 2.4s ease-in-out infinite; }
@keyframes welcome-free { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-2deg) scale(1.05); } }
@keyframes welcome-type { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .welcome-perk.free, .welcome-line { animation: none; } }
.tv-text { color: #1e1a33; }
/* Eigene Nachrichten: etwas dunkleres Lila (weiße Schrift ≥ 4.5:1), Zeit und Tokens auf dunklem Grund */
:root { --user-bubble-start: #5b5be0; --user-bubble-end: #7c4ddb; }
.message-wrapper.user :is(.message-timestamp, .token-info span) { background: rgb(20 12 50 / 30%); color: #fff; opacity: 1; }
.error-message { color: #b91c1c; }
html[data-theme="dark"] .error-message { color: #ffc9d3; }
html[data-theme="dark"] .message-content :is(td, th, li, dt, dd, caption) { color: inherit; }
.btn-edit { color: #1d4ed8; }
.btn-delete { color: #b91c1c; }
html[data-theme="dark"] .btn-edit { color: #a9c4ff; }
html[data-theme="dark"] .btn-delete { color: #ffb4bf; }
html[data-theme="dark"] .message-content table { background: var(--dk-surface); color: var(--dk-text); }
html[data-theme="dark"] .message-content :is(th, td) { border-color: var(--dk-border); }
html[data-theme="dark"] .role-item-prompt { background: #0f0e16; border-color: var(--dk-border); color: var(--dk-muted); }
.brand-mark, .mobile-brand .brand-mark { background: linear-gradient(135deg, #5b5be0 0%, #7c4ddb 100%); }
.mini-avatar.green { color: #2f6b47; }
.mini-avatar.orange { color: #9a4a1f; }
.mini-avatar.purple { color: #6d3fb0; }
.welcome-eyebrow { color: #6b5a8a; }
html[data-theme="dark"] :is(.welcome-eyebrow, .welcome-privacy) { color: var(--dk-muted); }
html[data-theme="dark"] .welcome-message h2 { color: var(--dk-text); }
/* Lila Leiste beim Scrollen (Handy): weißes Logo-Wort und lila „a“ mit ≥ 4.5:1 */
body.page-scrolled .top-bar { background: linear-gradient(135deg, #5b5be0 0%, #7c4ddb 100%); }
@media (max-width: 768px) { body.page-scrolled .mobile-brand .brand-mark { color: #5b5be0; } }
