/* KAI – schlankes UI. Alle IDs/Klassen aus app.js bleiben erhalten. */
:root {
  /* 5D Brandbook 2022 */
  --brand-red: #9b0230;      /* Pantone 207 C */
  --brand-red-dark: #7d0227;
  --brand-red-faint: #fdf2f5;
  --brand-teal: #69C9BA;
  --brand-blue: #0065A1;
  --brand-orange: #FF6B00;

  --grey-950: #111111;
  --grey-900: #1a1a1a;
  --grey-700: #3d3d3d;
  --grey-500: #6b7480;
  --grey-400: #9aa3ad;
  --grey-300: #d0d4d9;
  --grey-200: #e8eaed;
  --grey-100: #f4f6f8;
  --grey-50:  #fafbfc;
  --white:    #ffffff;

  --sidebar-width: 280px;
  --sidebar-bg: #faf8f8;
  --sidebar-border: #ecdde1;

  --font-ui: 'Open Sans', Arial, sans-serif;
  --font-display: 'Roboto Slab', Georgia, serif;
  --font-brand: 'Poppins', 'Open Sans', Arial, sans-serif;
  --font-mono: Consolas, 'Courier New', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.07);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.25);
  --shadow-focus: 0 0 0 3px rgba(155, 2, 48, 0.15);

  /* Semantische Tokens (hell) */
  --bg: var(--white);
  --bg-alt: var(--grey-50);
  --tile: var(--grey-200);
  --card-bg: var(--white);
  --text: var(--grey-900);
  --text-2: var(--grey-700);
  --text-muted: var(--grey-500);
  --text-faint: var(--grey-400);
  --border: var(--grey-200);
  --accent: var(--brand-red);
  --accent-hover: var(--brand-red-dark);
  --accent-text: var(--brand-red);
  --accent-soft: var(--brand-red-faint);
  --accent-contrast: #ffffff;
  --bubble-user: var(--brand-red);
  --bubble-assistant: var(--white);
  --ok: #22c55e;
  --ok-text: #16a34a;
  --ok-soft: rgba(34, 197, 94, 0.15);
  /* Warnung (PROJ-24): fuer Hinweise, die nicht "Fehler" bedeuten, sondern "das hier
     laeuft ohne Schutznetz" - auf Basis von --brand-orange. */
  --warn-text: #b45309;
  --warn-soft: rgba(255, 107, 0, 0.10);
  --warn-border: rgba(255, 107, 0, 0.35);
  /* PROJ-35: "Laeuft" in der Laeufe-Leiste - auf Basis von --brand-blue, damit es sich von
     "Eingabe noetig" (Orange), "Fertig" (Gruen) und "Fehlgeschlagen" (Rot) abhebt. */
  --info-text: var(--brand-blue);
  --info-soft: rgba(0, 101, 161, 0.10);
}

[data-theme="dark"] {
  --bg: #161920;
  --bg-alt: #1e2230;
  --sidebar-bg: #1a1d26;
  --sidebar-border: #2b2f3e;
  --tile: #2b2f3e;
  --card-bg: #1e2230;
  --text: #e4e6ed;
  --text-2: #c3c8d2;
  --text-muted: #8b95a4;
  --text-faint: #5c6472;
  --border: #2b2f3e;
  --accent-text: #ff8ca3;
  --accent-soft: rgba(155, 2, 48, 0.15);
  --bubble-assistant: #232736;
  --shadow: 0 1px 3px rgba(0,0,0,0.25);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.30);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.40);
  --shadow-focus: 0 0 0 3px rgba(155, 2, 48, 0.25);
  --warn-text: #fbbf24;
  --warn-soft: rgba(255, 107, 0, 0.12);
  --warn-border: rgba(255, 107, 0, 0.30);
  --info-text: #6cb6e6;
  --info-soft: rgba(0, 101, 161, 0.22);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
::placeholder { color: var(--text-faint); }
.hidden { display: none !important; }
/* Fuer #chat-input-row: display:none wuerde .chat-input-bar zusammenschrumpfen (nur noch
   .mode-bar drin), der Balken saesse dann in Konfiguration/Agent auf anderer Hoehe als in
   Datenbank-Chat/Doku - visibility haelt den Platz reserviert, der Umschalter bleibt exakt
   an derselben Stelle, nur das (eh nicht nutzbare) Eingabefeld ist unsichtbar. */
.invisible { visibility: hidden; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--grey-300); border-radius: 8px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #2b2f3e; }
::-webkit-scrollbar-track { background: transparent; }
.icon { width: 16px; height: 16px; flex-shrink: 0; }

/* Hoehe: 100vh ist auf iOS/iPadOS-Safari die "grosse" Viewporthoehe (also die Hoehe OHNE
   eingeblendete Browserleisten) - das Layout war dadurch auf Tablet/Handy genau um die
   Hoehe der Adress-/Tableiste zu hoch und die Eingabezeile unten abgeschnitten. 100dvh
   folgt der tatsaechlich sichtbaren Hoehe; 100vh bleibt als Fallback fuer alte Browser
   davor stehen (2026-09-16). */
.layout { display: flex; height: 100vh; height: 100dvh; }

/* ------------------------------------------------------------- Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 0;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 7px 20px 6px; border-bottom: 1px solid var(--sidebar-border); flex-shrink: 0; }
.brand-logo { height: 32px; width: auto; flex-shrink: 0; object-fit: contain; }
/* Eigenes Wrapper-Element fuer Padding/Dark-Mode-Kachel, NICHT auf .logo-blink-wrap selbst -
   sonst fuellt das per inset:0 positionierte Overlay-Bild die Box inklusive Padding und wirkt
   dadurch groesser als das Standard-Logo (siehe Bugfix 2026-09-10). */
.brand-logo-wrap { display: inline-flex; padding: 3px; box-sizing: content-box; }
[data-theme="dark"] .brand-logo-wrap { background: #fff; border-radius: 6px; }
.brand-text { min-width: 0; }
.brand-title { font-family: var(--font-brand); font-weight: 700; font-size: 22px; line-height: 1.2; color: var(--accent-text); }
[data-theme="dark"] .brand-title { color: var(--text); }
.brand-subtitle { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-muted); margin-top: 2px; }

.new-chat-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 14px 14px 0; padding: 11px 16px; flex-shrink: 0;
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  background: transparent; color: var(--accent-text);
  font-weight: 600; font-size: 13px; letter-spacing: 0.04em;
  transition: background .15s, color .15s;
}
.new-chat-btn:hover { background: var(--accent); color: var(--accent-contrast); }

/* Zwei unabhaengig scrollbare Bereiche ("Meine Läufe" oben, "Verlauf" unten) statt einer
   gemeinsamen Liste. flex-basis: auto (statt 0) heisst: jeder Bereich nimmt sich zuerst nur
   so viel Hoehe, wie sein tatsaechlicher Inhalt braucht - ein leerer/kurzer Bereich bleibt
   klein, der andere waechst automatisch in den so frei werdenden Platz (flex-grow: 1).
   Reicht der Platz fuer beide Inhalte trotzdem nicht, schrumpft der groessere Bereich
   ueberproportional (Flex-Shrink ist an seiner Basisgroesse gewichtet) - min-height als
   Untergrenze verhindert dabei, dass ein Bereich unter seine Kopfzeile gequetscht wird.
   Jeder Bereich scrollt selbst (.history-section-body), sobald sein zugeteilter Platz nicht
   mehr reicht. Eingeklappt (.collapsed) faellt ein Bereich fest auf Kopfzeilenhoehe zurueck
   (flex: 0 0 auto).
   BEWUSST kein flex-grow (erster Wert bleibt 0, nicht 1): mit flex-grow wuerde der jeweils
   andere, noch offene Bereich beim Einklappen den KOMPLETTEN frei werdenden Platz fuellen -
   auch wenn er selbst kaum Inhalt hat. Das riss ihn (bzw. den kollabierten Header des
   eingeklappten Bereichs direkt darunter) sichtbar ganz nach unten. Ohne flex-grow sorgt nur
   noch flex-shrink dafuer, dass ein Bereich mit ECHTEM Platzmangel (mehr Inhalt als frei ist)
   den anderen zurueckdraengt - ein leerer/kurzer Bereich bleibt dagegen klein, ungenutzter
   Rest bleibt als Leerraum am Ende der Liste stehen, statt kuenstlich aufgeblaeht zu werden. */
.history-list { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.history-section { flex: 0 1 auto; min-height: 44px; display: flex; flex-direction: column; }
.history-section.collapsed { flex: 0 0 auto; }
.history-section-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%; border: none; background: none;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-faint); padding: 18px 20px 10px; flex-shrink: 0; cursor: pointer; text-align: left;
}
.history-section-toggle:hover { color: var(--text-muted); }
.history-section-chevron { width: 11px; height: 11px; flex-shrink: 0; transition: transform .15s; }
.history-section.collapsed .history-section-chevron { transform: rotate(-90deg); }
.history-section-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; padding: 0 14px; }
.history-section.collapsed .history-section-body { display: none; }
.history-empty { color: var(--text-faint); font-size: 13px; margin: 6px 8px; flex-shrink: 0; }
.history-item {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  padding: 8px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item:hover { background: var(--tile); }
.history-item.active { background: var(--tile); color: var(--accent-text); }
.history-item-badge {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px;
  background: var(--tile); display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text-muted);
}
/* background-color statt background (Shorthand) - sonst ueberschreibt das die
   background-image des Chat-Icons aus .history-item-badge:empty weiter unten mit "none",
   das Icon verschwindet dann fuer den aktiven Chat. */
.history-item.active .history-item-badge { background-color: var(--accent-soft); }
.history-item-badge:empty {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='1.8' stroke-linejoin='round'%3E%3Cpath d='M20 4H4v12h4v4l5-4h7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 14px;
}
.history-item > span:nth-child(2) { flex: 1; min-width: 0; }
.history-item .del-btn { opacity: 0; border: none; background: none; color: var(--text-faint); font-size: 12px; padding: 4px; border-radius: 6px; }
.history-item:hover .del-btn { opacity: 1; }
.history-item .del-btn:hover { color: var(--accent-text); background: var(--accent-soft); }

/* Konfiguration-Eintrag (Sidebar-Navigationspunkt) */
#config-mode-btn.mode-switch-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 8px; margin: 8px 0 3px; border: none; border-radius: 8px;
  background: transparent; color: var(--text-2); font-size: 13.5px; font-weight: 600; text-align: left;
}
#config-mode-btn.mode-switch-btn:hover { background: var(--tile); }
#config-mode-btn.mode-switch-btn.active { background: var(--accent-soft); color: var(--accent-text); }

/* Umschliesst Konfiguration-Button (nur 5D-Admin/Admin) + .sidebar-footer als EINEN
   Block - der Trennstrich liegt bewusst hier oben drueber (nicht mehr an .sidebar-footer
   selbst), damit er bei Admin/5D-Admin ueber "Konfiguration" sitzt und bei Member (kein
   Konfiguration-Button) direkt ueber dem Avatar-Bereich - in beiden Faellen auf derselben
   Hoehe wie .chat-input-bar (siehe dort), zusammen wirkt das wie eine durchgehende Linie
   ueber die ganze Seitenbreite. justify-content: center zentriert den Blockinhalt in der
   zusaetzlichen Hoehe (bei Member entspricht das genau .sidebar-footer). */
.sidebar-bottom {
  border-top: 1px solid var(--sidebar-border); margin-top: auto; min-height: 116px;
  box-sizing: border-box; display: flex; flex-direction: column; justify-content: center;
  flex-shrink: 0;
}
.sidebar-footer { padding: 14px 14px 18px; display: flex; align-items: center; gap: 10px; }
/* Zusaetzlicher Trennstrich zwischen Konfiguration und Avatar-Bereich - nur wenn
   Konfiguration ueberhaupt da ist (5D-Admin/Admin), sonst waere es eine verwaiste Linie
   ueber dem sonst zentrierten Avatar-Block bei Member. */
#config-mode-btn + .sidebar-footer { border-top: 1px solid var(--sidebar-border); padding-top: 13px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-soft); border: 1.5px solid rgba(155,2,48,0.25); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 13px;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent-text); margin-top: 1px; }
.logout-btn {
  width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card-bg); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.logout-btn:hover { color: var(--accent-text); border-color: var(--accent); }

/* "Meine Agenten" */
.my-agents-list { display: flex; flex-direction: column; gap: 2px; }
.agent-chip {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 8px; border: none; border-radius: 8px; background: none;
  font-size: 13.5px; font-weight: 600; text-align: left;
}
.agent-chip:hover { background: var(--tile); }
.agent-chip > span:first-child {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px; background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}

/* ---------------------------------------------------------------- Main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
/* Hoehe auf .sidebar-brand daneben abgestimmt (Logo/KAI-Schriftzug-Zeile + dessen
   Innenabstand) - dadurch liegt border-bottom hier auf derselben Hoehe wie der
   border-bottom von .sidebar-brand, beide zusammen wirken wie eine durchgehende Linie
   ueber die ganze Seitenbreite (gleiches Prinzip wie unten bei .sidebar-footer/
   .chat-input-bar). */
.topbar {
  height: 56.4px; flex-shrink: 0; box-shadow: var(--shadow);
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 24px; border-bottom: 1px solid var(--border);
}
.topbar-status { font-size: 13px; display: flex; align-items: center; gap: 6px; }
/* Gleiches Gruen wie der "Abgeschlossen"-Status der Agenten-Laeufe
   (.agent-run-status-badge.status-abgeschlossen, siehe dort) - beide sind ein
   "alles ok"-Zustand und sollen dieselbe Bedeutung farblich gleich kommunizieren. */
.topbar-status-text {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  background: var(--ok-soft); color: var(--ok-text); font-weight: 600;
}
.topbar-status-text::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok-text);
}
.topbar-chat-name { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.topbar-chat-name::before { content: "·"; margin-right: 6px; color: var(--text-faint); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions > button, .demo-role-select {
  height: 34px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text-2);
}
.topbar-actions > button { width: 34px; display: flex; align-items: center; justify-content: center; padding: 0; }
.topbar-actions > button:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.demo-role-select { padding: 0 10px; font-size: 12.5px; font-weight: 600; }
.usage-badge { font-size: 12px; color: var(--text-muted); white-space: nowrap; padding: 0 10px; }
.usage-badge:empty { display: none; }
.usage-badge.limit-near { color: #b45309; }
.usage-badge.limit-reached { color: var(--accent-text); font-weight: 600; }
/* Sichtbarkeit der Admin-Werkzeuge nach Rolle (siehe PROJ-12) - 5D-Admin sieht alles,
   Admin sieht Konfiguration + einen eigenen, schmalen Einstellungen-Dialog (#settings-btn
   oeffnet je nach Rolle #settings-overlay oder #settings-model-overlay, siehe app.js),
   aber weder Token-Nutzung noch Playbook. Member sieht keinen der drei Knoepfe. */
.role-member #usage-badge, .role-member #settings-btn, .role-member #playbook-btn, .role-member #config-mode-btn { display: none; }
.role-admin #usage-badge, .role-admin #playbook-btn { display: none; }

/* Hell/Dunkel als Schiebeschalter */
#theme-toggle { width: auto !important; border-radius: 99px !important; background: var(--card-bg) !important; position: relative; gap: 6px; padding: 0 8px !important; margin-left: 4px; }
#theme-toggle .icon { width: 14px; height: 14px; position: relative; z-index: 1; }
#theme-toggle .icon-sun { color: #f59e0b; }
#theme-toggle .icon-moon { color: var(--text-faint); }
[data-theme="dark"] #theme-toggle .icon-sun { color: var(--text-faint); }
[data-theme="dark"] #theme-toggle .icon-moon { color: var(--text); }
#theme-toggle .toggle-knob {
  position: relative; width: 32px; height: 18px; border-radius: 99px; background: var(--grey-300); flex-shrink: 0;
}
#theme-toggle .toggle-knob::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.2); transition: transform 220ms cubic-bezier(.4,0,.2,1);
}
[data-theme="dark"] #theme-toggle .toggle-knob { background: var(--accent); }
[data-theme="dark"] #theme-toggle .toggle-knob::after { transform: translateX(14px); }
[data-theme="dark"] #theme-toggle .icon-moon { color: #818cf8; }

/* ------------------------------------------------------------- Welcome */
.chat-scroll { flex: 1; overflow-y: auto; padding: 28px 24px 12px; }
.welcome { max-width: 760px; margin: 60px auto 0; text-align: left; }
.welcome h1 { font-family: var(--font-display); font-size: 44px; line-height: 1.1; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 22px; }
.welcome h1 em { color: var(--accent-text); font-style: italic; font-weight: 400; }
.welcome-sub { max-width: 520px; font-size: 15px; line-height: 1.7; font-weight: 300; color: var(--text-muted); margin: 0 0 32px; text-wrap: pretty; }
.suggestion-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; text-align: left; }
.suggestion-card {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 18px 16px 16px; min-height: 140px; display: flex; flex-direction: column; gap: 8px;
  text-align: left; transition: border-color .15s;
}
.suggestion-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.suggestion-kicker { font-size: 9.5px; font-weight: 400; letter-spacing: 0.28em; text-transform: uppercase; color: var(--text-faint); }
.suggestion-title { font-family: var(--font-display); font-weight: 400; font-size: 15px; line-height: 1.3; }
.suggestion-desc { margin-top: auto; font-size: 12px; line-height: 1.55; color: var(--text-muted); }

/* ------------------------------------------------------------ Messages */
.messages { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg.assistant { gap: 12px; align-items: flex-start; }
/* Assistenten-Avatar: rotes KAI-Logo auf weißem Kreis (nie die Variante mit roten Augen -
   bei dieser Groesse (21px) waere der Blinzel-Unterschied ohnehin nicht wahrnehmbar, siehe
   PROJ-6/Login-Refine 2026-09-10: Avatar bewusst unveraendert gelassen). */
.msg.assistant::before {
  content: ""; width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; margin-top: 2px;
  background: #fff url("/static/logo-mark.png") center / 21px no-repeat;
  border: 1px solid var(--border);
}
.msg-bubble { max-width: 78%; padding: 11px 15px; border-radius: var(--radius-md); white-space: pre-wrap; line-height: 1.55; font-size: 13.5px; }
.msg.user .msg-bubble { background: var(--bubble-user); color: #fff; border-radius: var(--radius-md); border-bottom-right-radius: 3px; box-shadow: var(--shadow); }
.msg.assistant .msg-bubble { max-width: none; flex: 1; min-width: 0; background: var(--bubble-assistant); border: 1px solid var(--border); border-radius: var(--radius-md); border-bottom-left-radius: 3px; padding: 12px 16px; white-space: normal; box-shadow: var(--shadow); }
.msg.error .msg-bubble { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ol, .msg-bubble ul { margin: 0 0 8px; padding-left: 22px; }
.msg-bubble ol:last-child, .msg-bubble ul:last-child { margin-bottom: 0; }
.msg-bubble li { margin-bottom: 3px; }
.msg-bubble code { background: rgba(0,0,0,0.06); padding: 2px 5px; border-radius: 4px; font-size: 12.5px; font-family: var(--font-mono); }
[data-theme="dark"] .msg-bubble code { background: rgba(255,255,255,0.08); }
.msg-bubble a { color: var(--accent-text); text-decoration: none; overflow-wrap: anywhere; }
.msg-bubble a:hover { text-decoration: underline; }
.msg.user .msg-bubble code { background: rgba(255,255,255,0.22); }
/* Rechenweg unter Datenbank-Antworten (PROJ-36): eingeklappt, gleiche Aufklapp-Optik wie
   .technical-detail (PROJ-29), darin optional das SQL fuer Admins. */
.msg-trace { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--border); }
.msg-trace > summary {
  cursor: pointer; font-size: 12.5px; color: var(--text-muted);
  list-style: none; display: inline-flex; align-items: center; gap: 4px;
}
.msg-trace > summary::-webkit-details-marker { display: none; }
.msg-trace > summary::before { content: "▸"; font-size: 10px; transition: transform .12s ease; }
.msg-trace[open] > summary::before { transform: rotate(90deg); }
.msg-trace > summary:hover { color: var(--text-2); }
.msg-bubble .msg-trace-steps { margin: 8px 0 4px; padding-left: 18px; font-size: 13px; color: var(--text-2); }
.msg-trace-steps li { margin-bottom: 4px; }
.msg-trace-origin {
  display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: 999px;
  font-size: 11px; line-height: 18px; vertical-align: 1px;
  color: var(--text-muted); border: 1px solid var(--border); white-space: nowrap;
}
.msg-trace-origin.self { color: var(--brand-orange); border-color: var(--brand-orange); }
.msg-bubble a.msg-trace-origin.linked { color: var(--accent-text); border-color: var(--accent-text); text-decoration: none; }
.msg-bubble a.msg-trace-origin.linked:hover { background: var(--bg-alt); text-decoration: none; }
.msg-trace-empty { margin: 8px 0 4px; font-size: 13px; color: var(--text-muted); font-style: italic; }
.msg-trace .technical-detail { margin: 6px 0 0; }
.usage-footnote { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-faint); }
.msg-trace + .usage-footnote { margin-top: 6px; padding-top: 0; border-top: none; }
.thinking { color: var(--text-muted); font-style: italic; }
.thinking::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 8px; border-radius: 50%; background: var(--accent); vertical-align: middle; animation: kai-pulse 1s ease-in-out infinite; }
@keyframes kai-pulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
.msg-chart { max-width: 820px; margin: -6px 0 0 44px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px 14px; }
.msg-chart > div:first-child { font-family: var(--font-display); font-weight: 600; font-size: 14px; margin-bottom: 14px !important; }
.msg-chart canvas { max-height: 320px; }

/* ------------------------------------------------------------ Composer */
/* order: 1 verankert die Leiste visuell IMMER als letztes Kind von .main, unabhaengig von
   ihrer tatsaechlichen DOM-Position (zwischen #chat-scroll und #agent-mode-view/
   #config-placeholder, siehe index.html) - sie erschien bisher nur deshalb "unten", weil
   #chat-scroll (flex:1) davor den ganzen Platz einnahm. Sobald #chat-scroll ausgeblendet
   ist (Konfiguration/Agent) und die Leiste selbst dank .invisible (statt .hidden) sichtbar
   bleibt (siehe dort), rutschte sie ohne "order" direkt unter die Kopfzeile nach oben. */
.chat-input-bar {
  order: 1; flex-shrink: 0; width: 100%;
  border-top: 1px solid var(--border);
  padding: 12px 20px 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); margin: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.mode-bar { width: 100%; max-width: 880px; display: flex; align-items: center; gap: 10px; }
.mode-bar-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.mode-bar-label .icon { width: 14px; height: 14px; color: var(--accent-text); }
.mode-bar-hint { font-size: 12px; color: var(--text-faint); margin-left: 4px; }
/* Dauerhafter Hinweis "KI-Ergebnisse pruefen" unter der Eingabe und im Lauf-Fenster. Bewusst
   dezent, aber immer sichtbar - nicht wegklickbar. */
.ai-disclaimer { width: 100%; max-width: 880px; margin: 2px 0 0; text-align: center; font-size: 11.5px; line-height: 1.4; color: var(--text-muted); }
.settings-modal .ai-disclaimer { max-width: none; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
/* Ersetzt den statischen Hinweis, wenn ein Moduswechsel einen neuen Chat erzwungen hat */
.mode-bar-notice { font-size: 12px; color: var(--accent-text); margin-left: 4px; line-height: 1.35; }
.mode-switch { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: var(--sidebar-bg); }
.mode-switch .mode-switch-btn {
  border: none; border-radius: 6px; padding: 5px 12px;
  background: transparent; color: var(--text-muted); font-size: 12.5px; font-weight: 500;
}
.mode-switch .mode-switch-btn:hover { color: var(--text); }
.mode-switch .mode-switch-btn.active { background: var(--bg); color: var(--accent-text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.chat-input-row { width: 100%; max-width: 880px; display: flex; gap: 10px; }
.chat-input-row input {
  flex: 1; height: 44px; padding: 0 14px;
  border-radius: var(--radius-md); border: 1px solid var(--grey-300);
  background: var(--bg-alt); color: var(--text); font-size: 14px; outline: none;
}
.chat-input-row input:focus { border-color: var(--accent); background: var(--card-bg); box-shadow: var(--shadow-focus); }
#send-btn {
  height: 44px; padding: 0 20px; border: none; border-radius: var(--radius-md);
  background: var(--accent); color: var(--accent-contrast); font-family: var(--font-display); font-weight: 600; font-size: 13.5px;
  display: flex; align-items: center; gap: 8px;
}
#send-btn:hover { background: var(--accent-hover); }
#send-btn:disabled { opacity: .6; cursor: default; }

/* ------------------------------------------------------- Konfiguration */
.config-view { flex: 1; overflow-y: auto; padding: 36px 40px; background: var(--sidebar-bg); }
[data-theme="dark"] .config-view { background: var(--bg); }
.config-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 22px; }
.config-header h2 { margin: 0 0 6px; font-family: var(--font-display); font-size: 30px; line-height: 1.15; }
.config-header .settings-hint { margin: 0; max-width: 640px; font-size: 14.5px; line-height: 1.5; text-wrap: pretty; }
.config-header .settings-hint code { background: var(--tile); padding: 1px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: .9em; }
.config-header .new-chat-btn { width: auto; height: 42px; padding: 0 18px; background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); flex-shrink: 0; }
.config-header .new-chat-btn:hover { background: var(--accent-hover); }
.config-view .playbook-tabs { margin: 0 0 22px; }
.config-tab-panel .config-header { margin-bottom: 18px; align-items: center; }
.agent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.agent-card {
  border: 1px solid var(--border); border-radius: 14px; background: var(--card-bg);
  padding: 20px; display: flex; flex-direction: column; gap: 16px;
}
.agent-card-head { display: flex; align-items: flex-start; gap: 12px; }
.agent-card-icon {
  width: 42px; height: 42px; flex-shrink: 0; border-radius: 10px; background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center; font-size: 20px; line-height: 1;
}
.agent-card-head > div { flex: 1; min-width: 0; }
.agent-card-name { font-family: var(--font-display); font-weight: 600; font-size: 16px; line-height: 1.25; }
.agent-card-desc { font-size: 13px; line-height: 1.45; color: var(--text-muted); margin-top: 3px; }
.agent-card-predefined-badge {
  font-size: 11px; font-weight: 600; color: var(--accent-text); border: 1px solid var(--accent);
  border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.agent-flow { display: flex; align-items: center; gap: 8px; font-size: 12.5px; background: var(--sidebar-bg); border-radius: 10px; padding: 10px; }
[data-theme="dark"] .agent-flow { background: var(--bg); }
.agent-flow-node { border: 1px solid var(--border); background: var(--card-bg); border-radius: 7px; padding: 6px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-flow-arrow { color: var(--text-faint); flex-shrink: 0; }
.agent-card-meta { font-size: 12.5px; color: var(--text-muted); line-height: 1.6; }
.agent-card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.agent-release-toggle { position: relative; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); margin-right: auto; cursor: pointer; }
/* Echter Toggle-Schalter als Checkbox + eigenstaendiges <span> statt gestylter
   Checkbox-Pseudoelemente (Bugfix 2026-09-10): moderne Chromium-Versionen malen bei
   appearance:none + :checked trotzdem eine native, weisse Haken-Flaeche ueber das per CSS
   gesetzte background - der Schalter wirkte dadurch im eingeschalteten Zustand komplett
   unsichtbar (verschmolz mit dem weissen Modal-Hintergrund). Die Checkbox selbst ist jetzt
   visuell unsichtbar (opacity:0), das sichtbare Schalter-Element ist ein separates,
   natives-Rendering-freies <span>, das per :checked-Geschwisterselektor reagiert. */
.agent-release-toggle .toggle-switch-input { position: absolute; opacity: 0; width: 34px; height: 20px; margin: 0; cursor: pointer; }
.agent-release-toggle .toggle-switch-track {
  position: relative; display: inline-block; flex-shrink: 0; width: 34px; height: 20px;
  border-radius: 10px; background: var(--border); transition: background .15s;
}
.agent-release-toggle .toggle-switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: left .15s;
}
.agent-release-toggle .toggle-switch-input:checked + .toggle-switch-track { background: var(--accent); }
.agent-release-toggle .toggle-switch-input:checked + .toggle-switch-track::after { left: 16px; }
.agent-release-toggle .toggle-switch-input:focus-visible + .toggle-switch-track { box-shadow: 0 0 0 2px var(--accent-soft); }

.connector-slug-badge {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--accent-text);
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px; cursor: pointer;
}
.connector-slug-badge:hover { border-color: var(--accent); }
.connector-slug-badge[draggable="true"] { cursor: grab; }
.connector-slug-badge[draggable="true"]:active { cursor: grabbing; }

/* ------------------------------------------------------------ Overlays */
.overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(28, 25, 23, 0.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
}
.settings-modal {
  background: var(--card-bg); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 580px; max-width: 92vw; max-height: 88vh; overflow-y: auto; overflow-x: hidden;
  padding: 22px 26px 24px;
}
.playbook-modal { width: 720px; }
.wide-modal { width: 720px; }
/* Ersetzt window.confirm() fuer Loeschbestaetigungen (Unterhaltungen, Agenten,
   Connectoren, Accounts, Zeitplaene, siehe showConfirm() in app.js) - reine
   Browser-Dialoge (grau, System-Schriftart) passen nicht zum Rest der App. */
.confirm-modal {
  background: var(--card-bg); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 380px; max-width: 90vw; padding: 22px 24px;
}
.confirm-message {
  margin: 0 0 20px; font-size: 14.5px; line-height: 1.55; color: var(--text);
  /* Mehrzeilige Rueckfragen sollen ihre Absaetze behalten - der Text wird per
     textContent gesetzt (nicht innerHTML), sonst blieben Zeilenumbrueche unsichtbar. */
  white-space: pre-line;
}
/* Der Bestaetigungsdialog liegt IMMER ueber einem anderen Fenster (z.B. dem
   Agenten-Editor). Alle .overlay teilen sich z-index 70; bei Gleichstand gewinnt das
   spaetere Element im DOM - und das war bisher der Editor, sodass die Rueckfrage
   dahinter verschwand. */
#confirm-overlay { z-index: 90; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.confirm-actions button { height: 36px; padding: 0 16px; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; }
.confirm-actions .secondary-btn { margin-bottom: 0; }
.settings-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.settings-header h2 { margin: 0; font-family: var(--font-display); font-size: 21px; line-height: 1.2; }
.icon-btn { width: 32px; height: 32px; border: none; border-radius: 8px; background: var(--bg-alt); color: var(--text-muted); font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { color: var(--text); }

fieldset { border: none; border-top: 1px solid var(--border); border-radius: 0; margin: 0 0 22px; padding: 16px 0 0; }
fieldset:first-of-type { border-top: none; padding-top: 0; }
legend { padding: 0 8px 0 0; color: var(--text-faint); font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
legend .settings-hint { display: inline; font-size: 11px; letter-spacing: 0; text-transform: none; font-weight: 400; margin: 0; }
#settings-form label, #agent-form label:not(.agent-connector-item):not(.agent-release-toggle):not(.agent-input-field-required), #connector-form label,
#account-form label:not(.agent-release-toggle), #settings-model-form label, #agent-run-form label, #agent-run-reply-form label {
  display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 12px;
}
#settings-form input, #settings-form select, #settings-form textarea,
#agent-form input:not([type="checkbox"]):not([type="radio"]), #agent-form select, #agent-form textarea,
#connector-form input, #connector-form select, #connector-form textarea,
#account-form input:not([type="checkbox"]), #account-form select,
#settings-model-form select,
#agent-run-form input, #agent-run-form select, #agent-run-form textarea,
#agent-run-reply-form input, #agent-run-reply-form select, #agent-run-reply-form textarea,
.agent-field-search {
  width: 100%; height: 40px; padding: 0 12px; font-weight: 400; font-size: 14px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--bg-alt); color: var(--text); outline: none;
}
#settings-form textarea, #agent-form textarea, #agent-run-form textarea, #agent-run-reply-form textarea, #connector-form textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
#settings-form input:focus, #settings-form textarea:focus, #agent-form input:focus, #agent-form textarea:focus, #connector-form input:focus,
#connector-form textarea:focus,
#agent-run-form input:focus, #agent-run-form textarea:focus,
#agent-run-reply-form input:focus, #agent-run-reply-form select:focus, #agent-run-reply-form textarea:focus,
.agent-field-search:focus { border-color: var(--accent); background: var(--card-bg); }
.provider-fields { display: flex; flex-direction: column; }
.secondary-btn {
  height: 32px; padding: 0 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
  background: var(--card-bg); color: var(--text); border: 1px solid var(--border); margin-bottom: 6px;
}
.secondary-btn:hover { border-color: var(--text-faint); }
.settings-hint { color: var(--text-muted); font-size: 12.5px; line-height: 1.5; margin: 0 0 10px; }
/* Hinweis, der eine Einschraenkung nennt statt nur zu erklaeren - hebt sich vom gedaempften
   Standardhinweis ab, ohne ein eigenes Kasten-Layout zu brauchen. */
.settings-hint.warn-text { color: var(--warn-text); }
.usage-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; font-size: 12px; color: var(--text-muted);
}
.usage-stats div { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; text-align: left; }
.usage-stats div span { display: block; font-family: var(--font-display); font-weight: 600; font-size: 20px; line-height: 1.2; color: var(--text); margin: 4px 0 2px; }
.settings-actions { display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding-top: 6px; }
.settings-saved { color: var(--ok-text); font-size: 13px; }
/* Abgelehnte Einstellungen (z.B. kaputte Doku-Quellen) - der Server hat dann nichts gespeichert. */
.settings-error { color: var(--accent-text); font-size: 13px; font-weight: 600; }
/* Doku-Quellen (rag_sources) werden als rohes JSON gepflegt. */
.rag-sources-input { font-family: var(--font-mono); font-size: 12.5px; }
#settings-form .settings-hint code { background: var(--tile); padding: 1px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: .9em; }
.settings-actions button[type="submit"] {
  height: 40px; padding: 0 20px; border: none; border-radius: 9px;
  background: var(--accent); color: var(--accent-contrast); font-weight: 700; font-size: 14px;
}
.settings-actions button[type="submit"]:hover { background: var(--accent-hover); }

/* Tabs (Playbook + Konfiguration) */
.playbook-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.playbook-tab {
  border: none; background: none; padding: 10px 12px; font-size: 13.5px; font-weight: 500;
  color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.playbook-tab:hover { color: var(--text); }
.playbook-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.pending-list { display: flex; flex-direction: column; gap: 14px; max-height: 55vh; overflow-y: auto; }
.pending-empty { color: var(--text-muted); font-size: 13px; padding: 12px 0; }
.pending-item { border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; background: var(--card-bg); }
.pending-item-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.pending-item-meta::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.pending-item-note { font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; margin-bottom: 12px; }

/* Schreibbestaetigung im Klartext (PROJ-14): wer bestaetigt, soll Feldnamen und Werte lesen
   koennen, nicht SQL - das exakte Statement bleibt im <details> darunter pruefbar. */
.pending-write-headline { font-weight: 600; margin-bottom: 10px; }
.pending-write-fields {
  display: grid; grid-template-columns: minmax(120px, max-content) 1fr;
  gap: 4px 16px; margin: 0 0 10px; white-space: normal;
}
.pending-write-fields dt { color: var(--text-muted); }
.pending-write-fields dd { margin: 0; overflow-wrap: anywhere; }
.pending-write-condition { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; white-space: normal; }
.pending-write-sql { font-size: 13px; }
.pending-write-sql summary { cursor: pointer; color: var(--text-muted); }
.pending-write-sql pre {
  margin: 8px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--bg-alt);
  border: 1px solid var(--border); font-family: var(--font-mono); font-size: 12px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
@media (max-width: 560px) { .pending-write-fields { grid-template-columns: 1fr; gap: 2px 0; } }
.pending-item-actions { display: flex; gap: 8px; }
.pending-item-actions button { height: 34px; padding: 0 14px; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; }
/* Generische Bestaetigungs-Button-Klasse - NICHT playbook-spezifisch, obwohl hier definiert:
   wird auch von #confirm-ok-btn (showConfirm(), alle Loesch-Bestaetigungen) und
   #agent-run-confirm-yes (PROJ-14 Schreibbestaetigung) verwendet (siehe PROJ-7 QA Bug #1,
   2026-09-10 - vor jeder Entfernung erst projektweit nach Verwendungsstellen suchen). */
.approve-btn { background: var(--accent); color: #fff; }
.approve-btn:hover { background: var(--accent-hover); }
.reject-btn { background: var(--card-bg); color: var(--text-2); border: 1px solid var(--border) !important; }
.reject-btn:hover { border-color: var(--text-faint) !important; }
.playbook-file-content { flex: 1; overflow-y: auto; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-family: var(--font-mono); font-size: 12px; line-height: 1.5; white-space: pre-wrap; margin: 0; }
.pending-item .playbook-file-content { margin-bottom: 12px; }

/* Agenten-Editor / Connector-Editor */
.agent-template-picker { margin-bottom: 6px; }
.agent-template-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.agent-template-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--card-bg);
}
.agent-template-card:hover { border-color: var(--accent); }
.agent-template-card > span:first-child { width: 36px; height: 36px; flex-shrink: 0; border-radius: 9px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.agent-template-card strong { display: block; font-size: 14px; }
.agent-template-card div span { font-size: 12.5px; color: var(--text-muted); }
/* Die Blaupausen-Karte legt zusaetzlich Connectoren an - abgesetzt, damit sie sich
   sichtbar von den reinen Prompt-Vorlagen unterscheidet. */
.agent-template-card.blueprint { border-color: var(--accent); background: var(--accent-soft); }
/* Bericht nach dem Anlegen eines Standard-Agenten. Nur Tokens, damit beide Themes
   ohne eigene Regeln stimmen. */
.blueprint-report {
  margin: 0 0 16px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-alt); font-size: 13px; line-height: 1.6;
}
.blueprint-report h3 { margin: 0 0 8px; font-size: 14px; }
.blueprint-report p { margin: 0 0 6px; }
.blueprint-report ul { margin: 2px 0 10px; padding-left: 20px; }
.blueprint-report li { margin: 0 0 2px; }
.blueprint-report .warn { color: var(--warn-text); }
/* Ergebnis von "Als Vorgehen speichern" - eine Warnung darin (z.B. Probelauf an der
   Schrittgrenze) soll sich vom normalen Hinweistext abheben. */
.warn-text { color: var(--warn-text); }
.blueprint-report code { font-size: 12.5px; }
.agent-connector-checklist { display: flex; flex-direction: column; gap: 6px; }
.agent-connector-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-alt); font-size: 13.5px;
}
.agent-connector-item input { flex-shrink: 0; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.agent-connector-item .agent-connector-name { flex: 1; font-weight: 600; }
.agent-connector-item .agent-connector-desc { color: var(--text-muted); font-size: 12px; font-weight: 400; }
.agent-input-field-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.agent-input-field-form input[type="text"] { flex: 1 1 160px; min-width: 0; margin-bottom: 0; }
.agent-input-field-form select { flex: 0 0 150px; margin-bottom: 0; }
.agent-input-field-form button { margin-bottom: 0; }
.agent-input-field-required { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 400; color: var(--text-2); white-space: nowrap; }
.agent-input-field-required input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
/* Eigener Drag-Griff, deutlich groesser als der urspruengliche reine Zeichen-Bereich
   (Bugfix 2026-09-10) - bewusst NICHT die ganze Zeile draggable (ein zweiter Versuch mit
   `item.draggable = true` brach das direkt danebenliegende, ebenfalls draggable Badge:
   verschachtelte draggable-Elemente sind browseruebergreifend nicht zuverlaessig
   aufloesbar). 32x32px statt ~10x14px reiner Glyphen-Flaeche, mit Hover-Hintergrund als
   sichtbarem Hinweis, dass hier gezogen werden kann. */
.agent-input-field-drag-handle {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px;
  color: var(--text-faint); font-size: 16px; line-height: 1; user-select: none; cursor: grab;
}
.agent-input-field-drag-handle:hover { background: var(--tile); color: var(--text-2); }
.agent-input-field-drag-handle:active { cursor: grabbing; }
.agent-connector-item.dragging { opacity: 0.5; }
.agent-field-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.agent-field-picker select { flex: 1; min-width: 0; height: auto !important; padding: 4px !important; }
.agent-field-picker select option { padding: 5px 8px; border-radius: 4px; }
.agent-field-picker button { flex-shrink: 0; white-space: nowrap; margin-bottom: 0; height: auto; }
.agent-permissions-hint { margin-top: 0; margin-bottom: 8px; }
.agent-permissions-wrap { max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.agent-permissions-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.agent-permissions-table th {
  text-align: left; font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint);
  padding: 9px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card-bg);
}
.agent-permissions-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.agent-permissions-table tr:last-child td { border-bottom: none; }
.agent-permissions-connector { color: var(--text-muted); white-space: nowrap; }
.agent-permissions-field { font-family: var(--font-mono); font-size: 12px; }
.agent-permissions-remove { border: none; background: none; color: var(--text-faint); font-size: 16px; cursor: pointer; }
.agent-permissions-remove:hover { color: var(--accent-text); }

/* Eigene SQL je Connector (PROJ-17) */
.connector-custom-sql-block { margin-top: 16px; }
.connector-custom-sql-block textarea { font-family: var(--font-mono); font-size: 12.5px; }
.connector-sql-generate-row { display: flex; gap: 8px; margin: 10px 0; }
.connector-sql-generate-row input { flex: 1; min-width: 0; }
.connector-sql-generate-row button { flex-shrink: 0; white-space: nowrap; height: auto; margin-bottom: 0; }
.connector-sql-result {
  margin: 8px 0 0; padding: 12px 14px; border-radius: 10px; white-space: pre-wrap;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
  background: var(--bg-alt); border: 1px solid var(--border); max-height: 220px; overflow-y: auto;
}
.connector-sql-result-error { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent-soft); }
.connector-sql-result-warning { color: var(--text); background: var(--bg-alt); border-color: var(--brand-orange); border-left-width: 3px; }

/* System-Prompt generieren im Agenten-Editor (PROJ-18) - Ergebnisbox teilt sich .connector-sql-result*
   mit PROJ-17 (identische Optik fuer Fehler-/Ergebnisanzeige), kein neuer Klassensatz noetig. */
.agent-generate-prompt-block { margin: 4px 0 16px; }

/* Hinweis "Antwort durch Token-Limit abgeschnitten" (Modell-Antwort ggf. unvollstaendig) -
   bei Agenten-Laeufen unter dem Ergebnistext, siehe handleAgentRunEvent. */
.agent-run-truncated-hint {
  margin-top: 8px; padding: 8px 12px; border-radius: 8px; font-size: 12.5px; line-height: 1.5;
  background: var(--bg-alt); border: 1px solid var(--brand-orange); border-left-width: 3px; color: var(--text-muted);
}

/* RIB 4.0-Clerk-Zuordnung (PROJ-23) - Hinweisbanner im Datenbank-Chat fuer Member mit aktiver
   Zuordnung, ein-/ausgeblendet je Modus wie .suggestion-cards (siehe setActiveModeLabel/
   showConfigPlaceholder/showAgentModeView in app.js). Gleiche "Achtung, keine harte
   Sperre"-Optik wie .agent-run-truncated-hint, nur als volle Kopfzeile statt Inline-Hinweis. */
.clerk-scope-banner {
  flex-shrink: 0; display: flex; align-items: center; gap: 10px;
  padding: 10px 24px; font-size: 12.5px; line-height: 1.5; color: var(--text-muted);
  background: var(--bg-alt); border-bottom: 1px solid var(--border); border-left: 3px solid var(--brand-orange);
}
.clerk-scope-banner .icon { color: var(--brand-orange); }

/* Account-Editor: Abschnitt "RIB 4.0-Nutzer" (PROJ-23, nur Rolle Member) */
.account-clerk-scope-box {
  padding: 10px 12px; border-radius: 8px; margin-bottom: 10px;
  background: var(--bg-alt); border: 1px solid var(--border); font-size: 13px; line-height: 1.6;
}
.account-clerk-scope-box .account-clerk-label { font-weight: 600; color: var(--text); }
.account-clerk-scope-box .account-clerk-updated { color: var(--text-faint); font-size: 12px; }
.account-clerk-orphaned-note { margin-top: 8px; color: var(--brand-orange); font-size: 12px; font-weight: 600; }
.account-clerk-candidate-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.account-clerk-candidate {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-alt); font-size: 13.5px;
}
.account-clerk-candidate button { flex-shrink: 0; white-space: nowrap; margin-bottom: 0; height: auto; }
.account-clerk-search-error { color: var(--accent-text); }
.account-clerk-disclaimer {
  margin: 10px 0 0; padding: 8px 12px; border-radius: 8px; font-size: 12px; line-height: 1.5;
  background: var(--bg-alt); border: 1px solid var(--brand-orange); border-left-width: 3px; color: var(--text-muted);
}

/* Agent-Modus (PROJ-14, Refine 2026-09-09: dritter Modus statt eigenem Sidebar-Bereich) */
.agent-mode-view { flex: 1; overflow-y: auto; padding: 28px 24px; }
/* Mittig wie die Chat-Startseite (.welcome): eine zentrierte Spalte statt eines an den linken
   Rand gedrueckten Rasters, das auf breiten Bildschirmen im Leeren stand. */
.agent-mode-view > * { max-width: 880px; margin-left: auto; margin-right: auto; }
.agent-mode-title {
  font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1.2;
  text-align: center; margin-top: 40px; margin-bottom: 24px;
}
.agent-mode-view > .history-empty { text-align: center; }
.agent-run-schedules-btn { display: block; margin-top: 4px; margin-bottom: 20px; }
.agent-run-overview {
  max-width: 640px; margin-bottom: 22px; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-alt);
}
.agent-run-overview-head { display: flex; align-items: center; gap: 12px; }

/* Agenten-Laeufe (PROJ-14) */
/* Refine 2026-09-14 ("Zielbild v2"): Raster statt Liste - fuellt zuerst bis zu 4 Spalten
   in der Breite, waechst erst danach nach unten (siehe Decision Log/Tech Design). */
.agent-run-picker {
  /* Flex statt Raster: eine unvollstaendige letzte Reihe steht mittig statt links. */
  display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 12px;
  max-width: 880px; margin-bottom: 20px;
}
.agent-run-picker .agent-chip {
  flex: 0 1 calc((100% - 36px) / 4); width: auto;
  flex-direction: column; justify-content: center; text-align: center; gap: 8px;
  padding: 18px 10px; min-height: 112px; border: 1px solid var(--border); border-radius: var(--radius-md);
  font-size: 13.5px;
}
.agent-run-picker .agent-chip > span:first-child { width: 42px; height: 42px; font-size: 20px; }
.agent-run-picker .agent-chip.selected { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
/* Ab 640px Breite (max-width des Rasters) passen keine 4 Spalten mehr nebeneinander -
   auf schmalen Fenstern (siehe Responsive-Vorgabe) 2 Spalten statt Umbruch auf 1. */
@media (max-width: 640px) {
  .agent-run-picker .agent-chip { flex-basis: calc((100% - 12px) / 2); }
}

/* Agentenspezifische Laeufe/Zeitplaene direkt in der Uebersicht (Refine 2026-09-14,
   "Zielbild v2") - ZUSAETZLICH zum agentenuebergreifenden "Verlauf"/"Meine Zeitplaene",
   nicht als Ersatz (siehe Decision Log). Gleiche Breite/Abstand wie .agent-run-overview. */
.agent-run-subsection { max-width: 640px; margin-bottom: 22px; }
.agent-run-subsection h4 {
  font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-faint); margin: 0 0 10px;
}
.agent-run-subsection .agent-list { grid-template-columns: 1fr; gap: 10px; }
.agent-run-input-fields { display: flex; flex-direction: column; max-width: 420px; }
.agent-file-field { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.agent-file-field-hint { font-size: 11.5px; color: var(--text-faint); }
.agent-file-field-status { font-size: 12.5px; color: var(--ok-text); }
/* Erklaerung unter einem Eingabefeld im Lauf-Formular - gedaempft wie jeder Hinweistext,
   damit sie das Feld selbst nicht ueberdeckt. */
/* Ursprungseingaben im Antwort-Formular: bei einer Rueckfrage zugeklappt, damit sie die
   eigentliche Frage nicht zudecken. */
.agent-run-reply-original { margin-bottom: 10px; }
.agent-run-reply-original > summary {
  cursor: pointer; font-size: 12.5px; color: var(--text-muted); padding: 4px 0;
}
.agent-run-reply-original > summary:hover { color: var(--text); }
.agent-run-reply-original[open] > summary { margin-bottom: 6px; }
.agent-field-hint {
  display: block; margin-top: 4px; font-size: 12px; line-height: 1.45;
  color: var(--text-muted); font-weight: 400;
}
.agent-file-field-status.error { color: var(--accent-text); }
.agent-file-field-status:empty { display: none; }
.agent-run-schedule-form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.agent-run-schedule-form label { margin-bottom: 0; min-width: 130px; }
.agent-run-schedule-form input, .agent-run-schedule-form select { width: auto; min-width: 130px; }
/* PROJ-30: Abbrechen-Zeile im Lauf-Fenster. Bewusst zurueckhaltend - der Knopf soll
   erreichbar sein, aber nicht mit der Bestaetigungs-Box um Aufmerksamkeit konkurrieren. */
.agent-run-cancel-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.agent-run-cancel-row .reject-btn:disabled { opacity: 0.55; cursor: default; }
.agent-run-cancel-hint { font-size: 12.5px; color: var(--text-muted); }

/* PROJ-31: aufgezeichnetes Vorgehen im Agenten-Editor + Probelauf-Kennzeichnung.
   Nur Tokens, damit beide Themes ohne eigene Regeln stimmen. */
.agent-procedure-steps { margin: 6px 0 10px; padding-left: 22px; font-size: 13.5px; line-height: 1.6; }
.agent-procedure-step { margin: 0 0 6px; }
.agent-procedure-step.exploration { color: var(--text-muted); }
.agent-procedure-step .technical-detail { margin: 0 0 2px; }
.agent-chip.unreleased { border: 1px dashed var(--warn-border); }
.agent-chip-tag {
  margin-left: auto; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  color: var(--warn-text); background: var(--warn-soft); border: 1px solid var(--warn-border);
}

.agent-run-steps { font-size: 13.5px; color: var(--text-muted); line-height: 1.7; white-space: pre-wrap; margin: 4px 0 14px; }
.agent-run-final { font-size: 14.5px; line-height: 1.6; padding: 14px 16px; background: var(--bg-alt); border-radius: 10px; }
.agent-run-reply-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.agent-run-status-badge {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  padding: 3px 9px; border-radius: 999px; background: var(--tile); color: var(--text-muted);
}
.agent-run-status-badge.status-running, .agent-run-status-badge.status-wartet_auf_bestaetigung { background: var(--accent-soft); color: var(--accent-text); }
.agent-run-status-badge.status-abgeschlossen { background: var(--ok-soft); color: var(--ok-text); }
.agent-run-status-badge.status-fehlgeschlagen, .agent-run-status-badge.status-abgebrochen { background: var(--accent-soft); color: var(--accent-text); }
.agent-run-input-summary { font-size: 12.5px; color: var(--text-muted); margin: 6px 0 0; }
#agent-permissions-empty, #connector-permissions-empty { padding: 14px; text-align: center; margin: 0; }
.perm-badge { display: inline-flex; align-items: center; gap: 4px; border: none; border-radius: 999px; padding: 4px 10px; font-size: 11.5px; font-weight: 600; }
.perm-badge.perm-read { background: var(--accent-soft); color: var(--accent-text); }
.perm-badge.perm-write { background: #fef3c7; color: #b45309; }
.perm-badge.perm-hidden { background: var(--tile); color: var(--text-muted); }
[data-theme="dark"] .perm-badge.perm-write { background: #3b2a10; color: #fcd34d; }

/* --------------------------------------------------------------- Login */
/* zoom skaliert px/em, aber nicht vh (das bezieht sich immer auf den echten
   Viewport) - deshalb hier durch den Zoom-Faktor teilen, sonst waere die Seite
   nach dem 125%-Zoom vertikal scrollbar. */
.login-body { display: grid; grid-template-columns: 1fr 1fr; min-height: calc(100vh / 1.25); background: var(--bg); zoom: 1.25; overflow: hidden; }
html:has(.login-body) { overflow: hidden; }
.login-hero {
  position: relative; overflow: hidden; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; padding: 60px 56px;
}
/* Dekoratives Kreispfeil-Zeichen des 5D Instituts, als SVG nachgezeichnet (siehe
   logo-circular-arrow.svg) - das Original-PNG ist nur 261x238px und wuerde hier unscharf. */
.login-hero-mark {
  position: absolute; right: -150px; bottom: -160px; width: 680px; height: 620px;
  background: url("/static/logo-circular-arrow.svg") no-repeat center / contain;
  opacity: 0.18; pointer-events: none; user-select: none;
}
.login-hero-inner { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 28px; max-width: 420px; }
/* Rotes KAI-Logo auf weißer Kachel – nie invertiert. Blinzelt ab und zu kurz zur
   "cute"-Variante (logo-blink.svg), siehe .login-logo-blink weiter unten. */
.login-hero-logo { height: 50px; width: auto; object-fit: contain; }
.login-hero-logo-tile {
  align-self: flex-start; width: 96px; height: 96px; border-radius: 26px; background: #fff;
  display: grid; place-items: center;
  box-shadow: 0 0 0 9px rgba(255, 255, 255, 0.12), 0 12px 32px rgba(0, 0, 0, 0.18);
}
/* Blinzel-Effekt (generisch, genutzt bei Login-Hero, Login-Karte und Sidebar-Brand - beim
   Chat-Avatar bewusst NICHT eingesetzt, da das Logo dort nur 21px gross ist und der
   Blinzel-Unterschied bei der Groesse nicht wahrnehmbar waere, siehe Login-Refine 2026-09-10).
   Standard-Logo liegt fest in der Box, die "cute"-Variante (leicht geschlossene Augen) wird
   per Opacity-Crossfade kurz eingeblendet - Groesse bleibt in beiden Faellen exakt gleich, da
   beide SVGs dieselbe viewBox teilen und die Overlay-Variante die Box des Grundbilds per
   inset:0 exakt ausfuellt. */
.logo-blink-wrap { position: relative; display: inline-flex; }
.logo-blink-wrap .logo-blink-overlay {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  opacity: 0; pointer-events: none; animation: kai-logo-blink 6.5s ease-in-out infinite;
}
.logo-blink-delay-a .logo-blink-overlay { animation-delay: 2.2s; }
.logo-blink-delay-b .logo-blink-overlay { animation-delay: 4.1s; }
@keyframes kai-logo-blink {
  0%, 80%, 100% { opacity: 0; }
  83%, 94% { opacity: 1; }
  97% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .logo-blink-wrap .logo-blink-overlay { animation: none; }
}
.login-hero-rule { width: 60px; height: 1px; background: rgba(255, 255, 255, 0.35); }
.login-hero h1 { margin: 0; font-family: var(--font-display); font-size: clamp(30px, 3vw, 42px); line-height: 1.12; font-weight: 700; letter-spacing: -0.01em; }
.login-hero h1 em { font-style: italic; font-weight: 400; color: rgba(255, 255, 255, 0.75); }
.login-hero p { margin: 0; font-size: 14px; font-weight: 300; line-height: 1.7; color: rgba(255, 255, 255, 0.72); text-wrap: pretty; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 60px 56px; background: var(--white); }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 24px; }
.login-card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.login-logo { height: 36px; width: auto; object-fit: contain; }
.login-card h1 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 700; line-height: 1.2; }
.login-subtitle { color: var(--text-muted); font-size: 12px; margin: 2px 0 0; }
.login-field { display: flex; flex-direction: column; gap: 8px; }
.login-label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.login-error { color: var(--accent-text); background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; margin: 0; }
.login-card input[type="text"], .login-card input[type="password"] {
  padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--grey-300);
  background: var(--grey-50); font-size: 14px; outline: none;
}
.login-card input[type="text"]:focus, .login-card input[type="password"]:focus { border-color: var(--accent); background: var(--white); box-shadow: 0 0 0 3px rgba(155,2,48,0.18); }
.login-card button[type="submit"] {
  padding: 14px 20px; border: none; border-radius: var(--radius-sm); margin-top: 6px;
  background: var(--accent); color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 14px; letter-spacing: 0.04em;
}
.login-card button[type="submit"]:hover { background: var(--accent-hover); }
.login-role-switch { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--sidebar-bg); }
.login-role-btn { flex: 1; border: none; border-radius: 7px; padding: 10px; background: transparent; color: var(--text-muted); font-size: 14px; font-weight: 500; }
.login-role-btn.active { background: var(--card-bg); color: var(--accent-text); font-weight: 600; box-shadow: 0 1px 2px rgba(28, 25, 23, 0.08); }
.login-rule { height: 1px; background: var(--border); margin-top: 6px; }
.login-footnote { margin: 0; text-align: center; font-size: 12px; line-height: 1.6; color: var(--text-muted); padding-top: 8px; border-top: 1px solid var(--grey-100); text-wrap: pretty; }
@media (max-width: 900px) {
  .login-body { grid-template-columns: 1fr; }
  .login-hero { min-height: 280px; padding: 48px 32px; }
  .login-hero-inner { gap: 16px; }
  .login-hero-logo { height: 40px; }
  .login-hero-logo-tile { width: 72px; height: 72px; border-radius: 20px; box-shadow: 0 0 0 7px rgba(255,255,255,0.12); }
  .login-hero-logo { height: 38px; }
  .login-hero p, .login-hero-rule { display: none; }
  .login-hero-mark { width: 330px; height: 300px; right: -90px; bottom: -90px; }
}

/* --------------------------------------------------- Handy/Tablet (Haupt-App) */
/* Unter 900px wird die feste 280px-Sidebar zu einem Overlay-Drawer (sonst bliebe auf einem
   Handy kaum noch Platz fuer den eigentlichen Chat) - umgeschaltet ueber #sidebar-toggle-btn
   (nur hier sichtbar) + .sidebar.open, siehe app.js (closeSidebar/hideAllModeViews). Auf dem
   Desktop bleiben Sidebar-Toggle/Backdrop unsichtbar, an der bisherigen Flex-Sidebar aendert
   sich dort nichts. */
.topbar-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sidebar-toggle-btn {
  display: none; width: 34px; height: 34px; flex-shrink: 0; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg); color: var(--text-2); padding: 0;
}
.sidebar-toggle-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 55; background: rgba(17, 17, 17, 0.45); }

@media (max-width: 900px) {
  .sidebar-toggle-btn { display: flex; }
  .layout { position: relative; overflow: hidden; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: min(var(--sidebar-width), 84vw);
    transform: translateX(-100%); transition: transform .2s ease-out; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop:not(.hidden) { display: block; }

  .topbar { padding: 0 14px; flex-wrap: wrap; height: auto; min-height: 56.4px; row-gap: 6px; padding-block: 8px; }
  .topbar-chat-name { max-width: 34vw; }
  .usage-badge { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .chat-scroll { padding: 18px 14px 10px; }
  .welcome { margin-top: 24px; }
  .welcome h1 { font-size: 30px; }
  .welcome-sub { font-size: 13.5px; }
  .suggestion-cards { grid-template-columns: 1fr; }

  .msg-bubble { max-width: 90%; }
  .msg-chart { margin-left: 0; max-width: 100%; }

  .chat-input-bar { padding: 10px 12px 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .mode-bar { row-gap: 6px; }
  #send-btn { padding: 0 14px; }

  .config-view, .agent-mode-view { padding: 20px 14px; }
  .config-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .agent-list { grid-template-columns: 1fr; }
  .agent-run-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .settings-modal { width: 94vw; max-width: 94vw; padding: 18px 16px 20px; }
  .playbook-modal, .wide-modal { width: 94vw; }
  .confirm-modal { width: 94vw; padding: 18px 16px; }

  .usage-stats { grid-template-columns: repeat(2, 1fr); }
  .agent-input-field-form { flex-direction: column; align-items: stretch; }
  .agent-input-field-form select { flex: 1 1 auto; }
  .connector-sql-generate-row { flex-wrap: wrap; }
  .agent-run-schedule-form label { min-width: 0; flex: 1 1 45%; }
  .agent-run-schedule-form input, .agent-run-schedule-form select { min-width: 0; width: 100%; }
}

@media (max-width: 480px) {
  .send-btn-label { display: none; }
  #send-btn { padding: 0 14px; }
  .mode-switch .mode-switch-btn { padding: 5px 9px; font-size: 12px; }
  .topbar-chat-name { display: none; }
  .agent-run-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ------------------------------------------- Werkzeug-Freigabe (PROJ-24) */
/* Liste im Einstellungsdialog: was der MCP-Server anbietet und was davon der KI
   angeboten wird. Nicht freigegebene Eintraege stehen oben (serverseitig sortiert)
   und sind gedaempft, damit der handlungsrelevante Teil zuerst ins Auge faellt. */
.tool-policy-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 320px; overflow-y: auto;
  padding: 4px; margin-top: 4px;
}
.tool-policy-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); padding: 8px 10px;
}
.tool-policy-item.is-inactive { background: var(--bg-alt); }
.tool-policy-row { display: flex; align-items: center; gap: 8px; }
.tool-policy-toggle { margin-right: 0; flex: 0 0 auto; }
.tool-policy-name {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--text);
  overflow-wrap: anywhere;
}
.tool-policy-where {
  margin-left: auto; flex: 0 0 auto;
  font-size: 11px; color: var(--text-muted); white-space: nowrap;
}
.tool-policy-badge {
  flex: 0 0 auto; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); background: var(--tile);
  border-radius: 99px; padding: 2px 8px;
}
.tool-policy-note,
.tool-policy-meta { margin: 6px 0 0; font-size: 12px; line-height: 1.45; color: var(--text-muted); }
.tool-policy-warn {
  margin: 6px 0 0; font-size: 12px; line-height: 1.45;
  color: var(--warn-text); background: var(--warn-soft);
  border: 1px solid var(--warn-border); border-radius: var(--radius-sm);
  padding: 6px 8px;
}
@media (max-width: 900px) {
  .tool-policy-row { flex-wrap: wrap; }
  .tool-policy-where { margin-left: 0; width: 100%; }
}

/* ------------------------------------- API-Vorgaenge im Connector (PROJ-26) */
/* Zwei Listen im selben Abschnitt: oben die freigegebenen Vorgaenge, unten die
   Suchtreffer. Beide nutzen dieselbe Zeilenform, damit der Admin sie als dasselbe
   Ding wiedererkennt. */
.api-endpoint-selected,
.api-endpoint-results { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.api-endpoint-results { max-height: 340px; overflow-y: auto; padding: 2px; }
.api-endpoint-row {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); padding: 8px 10px;
}
.api-endpoint-row.is-selected { background: var(--bg-alt); }
.api-endpoint-row.is-missing-name { border-color: var(--warn-border); }
.api-endpoint-head { display: flex; align-items: center; gap: 8px; }
.api-endpoint-method {
  flex: 0 0 auto; font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: .03em; color: var(--text-muted); background: var(--tile);
  border-radius: 4px; padding: 2px 6px;
}
.api-endpoint-method.is-write { color: var(--warn-text); background: var(--warn-soft); }
.api-endpoint-path {
  font-family: var(--font-mono); font-size: 12px; color: var(--text-2);
  overflow-wrap: anywhere; min-width: 0;
}
.api-endpoint-add { flex: 0 0 auto; margin-left: auto; }
.api-endpoint-desc,
.api-endpoint-params,
.api-endpoint-name-label { display: block; margin-bottom: 8px; }
@media (max-width: 900px) {
  .api-endpoint-head { flex-wrap: wrap; }
  .api-endpoint-add { margin-left: 0; }
}

/* ------------------------------- Technische Details (PROJ-29) */
/* Klartext steht immer da, der technische Teil klappt darunter auf. Kommt nur bei
   Admin/5D-Admin ueberhaupt an - fuer einen Member sendet der Server ihn nicht mit,
   das Element entsteht dann gar nicht erst. */
.agent-run-step { margin-bottom: 2px; }
.technical-detail { margin: 4px 0 8px; }
.technical-detail > summary {
  cursor: pointer; font-size: 12px; color: var(--text-muted);
  list-style: none; display: inline-flex; align-items: center; gap: 4px;
}
.technical-detail > summary::-webkit-details-marker { display: none; }
.technical-detail > summary::before {
  content: "▸"; font-size: 10px; transition: transform .12s ease;
}
.technical-detail[open] > summary::before { transform: rotate(90deg); }
.technical-detail > summary:hover { color: var(--text-2); }
.technical-detail > pre {
  margin: 6px 0 0; padding: 8px 10px;
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.5; color: var(--text-2);
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow-y: auto;
}

/* Vom Code gepflegte Agenten/Connectoren (app/agent_blueprints.py): nur ansehen. Die
   Sperre per pointer-events erfasst auch die dynamisch gezeichneten Checklisten; der
   Server lehnt Aenderungen unabhaengig davon ab. */
#agent-form.code-managed .code-lock,
#connector-form.code-managed > label,
#connector-form.code-managed fieldset { pointer-events: none; opacity: .7; }
#agent-form.code-managed .code-lock-text textarea { background: var(--sidebar-bg); }
#agent-form.code-managed .code-lock-hide,
#agent-form.code-managed #agent-delete-btn,
#connector-form.code-managed .settings-actions { display: none !important; }
.agent-card-code-badge {
  font-size: 11px; font-weight: 600; color: var(--text-muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}

/* ---------------------------------------------------------------- PROJ-35
   Laeufe-Leiste (Status, Zaehler, Filter, Ungelesen), Verlaufssuche mit Datumsgruppen,
   Lauf-Fenster mit Start-/Lauf-Phase und eingeklapptem Protokoll. */
.sidebar-search { padding: 12px 14px 0; flex-shrink: 0; }
.sidebar-search input {
  width: 100%; padding: 8px 11px; font: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text);
}
.sidebar-search input:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-focus); }

.history-section-head { display: flex; align-items: center; gap: 6px; flex-shrink: 0; padding-right: 14px; }
.history-section-head .history-section-toggle { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; }
.history-section-counter { text-transform: none; letter-spacing: 0; font-weight: 700; color: var(--info-text); white-space: nowrap; margin-left: -2px; }
.history-section-counter.is-waiting { color: var(--warn-text); }
.history-section-filter {
  max-width: 112px; margin-top: 8px; padding: 3px 6px; font: inherit; font-size: 11.5px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text-muted);
}
.history-group-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-faint); margin: 10px 8px 4px; flex-shrink: 0;
}
.history-item.has-snippet { align-items: flex-start; white-space: normal; }
.history-item-label { display: flex; flex-direction: column; gap: 2px; white-space: nowrap; }
.history-item-snippet {
  font-size: 12px; font-weight: 400; color: var(--text-muted); white-space: normal;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.history-more-btn {
  margin: 4px 8px 8px; padding: 4px 0; border: none; background: none; text-align: left;
  font: inherit; font-size: 12.5px; color: var(--text-muted); cursor: pointer; flex-shrink: 0;
}
.history-more-btn:hover { color: var(--accent-text); }

.run-item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.run-item-name { overflow: hidden; text-overflow: ellipsis; }
.run-item-time { font-size: 11.5px; font-weight: 400; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; }
.run-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.run-chip {
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.02em;
  padding: 2px 8px; border-radius: 999px; background: var(--tile); color: var(--text-muted);
}
.run-chip-running { background: var(--info-soft); color: var(--info-text); }
.run-chip-running::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  animation: run-pulse 1.4s ease-in-out infinite;
}
.run-chip-input { background: var(--warn-soft); color: var(--warn-text); }
.run-chip-done { background: var(--ok-soft); color: var(--ok-text); }
.run-chip-failed { background: var(--accent-soft); color: var(--accent-text); }
.run-chip-cancelled { background: var(--tile); color: var(--text-muted); }
@keyframes run-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .run-chip-running::before { animation: none; } }

#agent-run-overlay .settings-header h2 { flex: 0 1 auto; min-width: 0; }
#agent-run-overlay-status { margin: 0 auto 0 12px; }
.agent-run-steps-box { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 10px; }
.agent-run-steps-box summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.agent-run-steps-box[open] summary { margin-bottom: 8px; }
#agent-run-cancel-row { flex-wrap: wrap; }


/* ---------------------------------------------------------------- PROJ-34 Report im Lauf-Fenster
   Gleiches Bild wie Seite 1 des PDF: Kennzahlen, Diagramm-Karten, Ampel-Uebersicht. Ampeln:
   Rot handeln, Orange beobachten, Gruen in Ordnung, Grau keine Daten. */
.report-view { margin: 0 0 16px; display: flex; flex-direction: column; gap: 12px; }
.rv-meta { font-size: 12px; color: var(--text-muted); margin: 0; }
.rv-hinweis { font-size: 12.5px; color: var(--warn-text); margin: 0; }
.rv-fehler { font-size: 12.5px; color: var(--accent-text); font-weight: 600; margin: 0; }
.rv-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-md); }
.rv-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.rv-kpi { padding: 10px 12px 10px 14px; border-left-width: 4px; }
.rv-kpi-titel { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.rv-kpi-wert { font-size: 26px; font-weight: 700; line-height: 1.2; margin: 2px 0; }
.rv-kpi-unter { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-kpi.rv-rot { border-left-color: var(--accent); } .rv-kpi.rv-rot .rv-kpi-wert { color: var(--accent-text); }
.rv-kpi.rv-orange { border-left-color: var(--brand-orange); } .rv-kpi.rv-orange .rv-kpi-wert { color: var(--warn-text); }
.rv-kpi.rv-gruen { border-left-color: var(--ok); } .rv-kpi.rv-gruen .rv-kpi-wert { color: var(--ok-text); }
.rv-kpi.rv-grau { border-left-color: var(--text-faint); } .rv-kpi.rv-grau .rv-kpi-wert { color: var(--text-muted); }
.rv-charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rv-chart { padding: 12px 14px; display: flex; flex-direction: column; min-height: 230px; }
.rv-chart-titel { font-weight: 700; font-size: 13.5px; }
.rv-chart-unter { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); margin: 2px 0 10px; }
.rv-chart-body { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.rv-leer { text-align: center; color: var(--text-muted); font-size: 13px; }
.rv-gruen-text { color: var(--ok-text); font-weight: 600; }
.rv-rot-text { color: var(--accent-text); font-weight: 600; }
.rv-ring { position: relative; width: 130px; height: 130px; margin: 0 auto 8px; }
.rv-ring canvas { width: 130px !important; height: 130px !important; }
.rv-ring-mitte { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.rv-ring-mitte strong { font-size: 22px; line-height: 1.1; }
.rv-ring-mitte span { font-size: 10.5px; color: var(--text-muted); }
.rv-legende { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.rv-legende li { display: flex; align-items: center; gap: 7px; padding: 1.5px 0; }
.rv-legende i { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.rv-legende span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-rest { font-size: 11px; color: var(--text-muted); }
.rv-saeulen { display: flex; align-items: flex-end; gap: 10px; height: 160px; }
.rv-saeule { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; font-size: 11px; color: var(--text-muted); }
.rv-saeule b { font-size: 13px; color: var(--text); margin-bottom: 3px; }
.rv-saeule-spur { flex: 1; width: 62%; display: flex; align-items: flex-end; border-bottom: 1px solid var(--border); }
.rv-saeule-bar { width: 100%; border-radius: 4px 4px 0 0; }
.rv-saeule span { margin-top: 4px; white-space: nowrap; }
.rv-balken { display: flex; flex-direction: column; gap: 9px; }
.rv-balken-kopf { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; margin-bottom: 3px; }
.rv-balken-kopf span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-balken-kopf b { white-space: nowrap; }
.rv-balken-spur { height: 9px; border-radius: 5px; background: var(--tile); overflow: hidden; }
.rv-balken-bar { height: 100%; border-radius: 5px; }
.rv-fussnote { font-size: 11.5px; margin-top: 8px; color: var(--text-muted); }
.rv-tabelle { padding: 10px 14px; }
.rv-tabelle summary { cursor: pointer; font-weight: 700; font-size: 13.5px; margin-bottom: 8px; }
.rv-tabelle-scroll { overflow-x: auto; }
.rv-tabelle table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rv-tabelle th { text-align: center; font-size: 11px; color: var(--text-muted); font-weight: 700; padding: 6px; background: var(--bg-alt); }
.rv-tabelle th:first-child { text-align: left; }
.rv-tabelle td { padding: 6px; border-top: 1px solid var(--border); }
.rv-firma td { font-weight: 700; color: var(--text-muted); font-size: 11.5px; }
.rv-zelle { text-align: center; }
.rv-zelle.rv-rot { background: var(--accent-soft); color: var(--accent-text); font-weight: 700; }
.rv-zelle.rv-orange { background: var(--warn-soft); color: var(--warn-text); }
.rv-zelle.rv-gruen { background: var(--ok-soft); color: var(--ok-text); }
.rv-zelle.rv-grau { color: var(--text-muted); }
@media (max-width: 900px) {
  .rv-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rv-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .rv-charts { grid-template-columns: 1fr; }
}
.settings-modal.report-modal { width: 1040px; max-width: 94vw; }
.rv-fussnote.rv-gruen-text { color: var(--ok-text); font-weight: 600; }
.rv-fussnote.rv-rot-text { color: var(--accent-text); font-weight: 600; }
