* { margin: 0; padding: 0; box-sizing: border-box; }
/* WICHTIG: `hidden`-Attribut gewinnt IMMER – auch gegen display:flex/grid.
   (Ohne diese Regel blieben „versteckte“ Elemente wie das Neu-Menü sichtbar,
   weil ihre display-Eigenschaft das Browser-Standard-Verstecken übermalt.) */
[hidden] { display: none !important; }
:root {
  --navy: #253876; --teal: #3fa4a9; --teal-subtle: #d9edee; --teal-faint: #eef7f8;
  --steel: #5578aa; --cyan: #87d7dc; --ink: #1c1c1c; --gray: #5f5f5f; --gray-mid: #bebebe;
  --line: #e4e9ec; --grad: linear-gradient(60deg, #5578aa 0%, #3fa4a9 55%, #87d7dc 100%);
}
html, body { height: 100%; }
body {
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  background: #f6f9fa; color: var(--ink); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }
.brandline { height: 4px; background: var(--grad); }
.app { display: flex; height: calc(100vh - 4px); }

/* ============ SEITENLEISTE (links) ============ */
.panel {
  width: 300px; flex: none; background: #fff; border-right: 1px solid #e8edef;
  display: flex; flex-direction: column;
}
.panel.collapsed { display: none; }
.panel-brand { display: flex; align-items: center; gap: 12px; padding: 16px 18px 12px 18px; }
.panel-brand svg.logo { height: 30px; width: auto; display: block; }
.panel-brand .sep { width: 1px; height: 24px; background: var(--line); }
.panel-brand .app-name {
  font-family: "Roboto Slab", serif; font-weight: 600; font-size: 15px; color: var(--navy);
}
.panel-top { padding: 4px 16px 0 16px; }
.new-chat {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; border-radius: 12px; background: linear-gradient(60deg, #253876 0%, #3fa4a9 100%);
  color: #fff; font-weight: 500; font-size: 13.5px; box-shadow: 0 3px 10px rgba(37, 56, 118, .22);
  border: none; cursor: pointer; width: 100%;
}
.new-chat:hover { filter: brightness(1.05); }
.search {
  margin-top: 12px; display: flex; align-items: center; gap: 8px;
  height: 36px; border: 1px solid var(--line); border-radius: 12px; padding: 0 10px;
  color: #9aa4ad; font-size: 13px; background: #fafcfc;
}
.search input {
  flex: 1; border: none; outline: none; background: transparent; font: inherit;
  font-size: 13px; color: var(--ink); min-width: 0;
}
.search input::placeholder { color: #9aa4ad; }
.tabs { margin-top: 12px; display: flex; background: #f0f4f6; border-radius: 12px; padding: 3px; }
.tab {
  flex: 1; text-align: center; font-size: 12.5px; padding: 7px 0; border-radius: 9px;
  color: #68737d; font-weight: 500; cursor: pointer; border: none; background: none;
}
.tab.active { background: #fff; color: var(--navy); font-weight: 600; box-shadow: 0 1px 3px rgba(37, 56, 118, .12); }
/* ★-Reiter (Favoriten): schmal, damit die drei Text-Reiter Platz behalten. */
.tab[data-tab="favs"] { flex: 0 0 34px; font-size: 15px; padding: 5px 0; }
.tab[data-tab="favs"].active { color: #d99a1b; }

.chat-list { flex: 1; overflow-y: auto; padding: 6px 8px 0 8px; margin-top: 6px; }
.group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: #a8b0b8;
  padding: 10px 10px 5px 10px; font-weight: 600;
}
.chat-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 10px;
  color: #3d4650; font-size: 13px; cursor: pointer; position: relative;
}
.chat-item svg { flex: none; color: #8fb9bd; }
.chat-item .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.active { background: var(--teal-subtle); color: #17335c; font-weight: 500; }
.chat-item.active svg { color: var(--navy); }
.chat-item:hover:not(.active) { background: #f3f7f8; }
.chat-item .row-del, .chat-item .row-star {
  display: none; border: none; background: none; cursor: pointer; color: #a8b0b8;
  padding: 2px; border-radius: 6px; flex: none;
}
.chat-item:hover .row-del, .chat-item:hover .row-star { display: grid; place-items: center; }
.chat-item .row-star.on { display: grid; place-items: center; color: #d99a1b; }
.chat-item .row-star:hover { color: #d99a1b; background: #fdf4e3; }
.chat-item .row-del:hover { color: #b23b2e; background: #fbecea; }
.retention-note { font-size: 11px; color: #a8b0b8; padding: 12px 12px 14px; line-height: 1.4; }

.tab-count {
  display: inline-block; min-width: 16px; padding: 0 4px; margin-left: 2px;
  font-size: 10px; font-weight: 600; line-height: 16px; text-align: center;
  color: #68737d; background: #e4ebee; border-radius: 99px;
}
.tab.active .tab-count { color: var(--navy); background: var(--teal-subtle); }
.list-note { font-size: 12.5px; color: #9aa4ad; padding: 14px 12px; }
.list-add {
  display: flex; align-items: center; gap: 8px; width: calc(100% - 4px); margin: 6px 2px;
  padding: 8px 10px; border: 1px dashed #c6d6da; border-radius: 10px; background: none;
  color: #4d8f94; font-size: 12.5px; cursor: pointer;
}
.list-add:hover { background: var(--teal-faint); }
.list-sub { font-size: 11px; color: #a8b0b8; }
/* Routing-Übersicht in der Administration (Reiter KI & Kosten) */
.route-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 4px 0 10px 0; }
.route-table td { border: 1px solid var(--line); padding: 7px 9px; vertical-align: top; }
.route-table td:first-child { white-space: nowrap; background: #f8fafb; color: var(--navy); }
/* Nummern der Anklick-Reihenfolge im Werkzeug-Fenster */
.wz-nr { color: var(--teal); font-weight: 700; font-size: 11px; }
/* Zwei-Faktor-Einrichtung in den Einstellungen */
.zf-status { font-weight: 600; margin: 4px 0; }
.zf-status.ok { color: #1f7a4d; }
.zf-step { font-size: 12.5px; color: var(--gray); margin: 8px 0 4px 0; }
.zf-secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px;
  letter-spacing: .04em; background: var(--teal-faint); border: 1px solid #cde4e7;
  border-radius: 8px; padding: 10px 12px; margin: 4px 0 8px 0; user-select: all;
  word-break: break-all; line-height: 1.7;
}
/* Rechner-Fenster */
.rechner { margin: 4px 0 10px 0; }
.re-anzeige {
  width: 100%; font-size: 22px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: right; padding: 12px 14px !important; border: 1px solid var(--line) !important;
  border-radius: 10px; background: #fff;
}
.re-ergebnis {
  text-align: right; font-size: 15px; font-weight: 600; color: var(--navy);
  min-height: 22px; padding: 6px 4px 2px 0;
}
.re-ergebnis.fehler { color: #b23b2e; font-weight: 500; font-size: 12.5px; }
.re-funktionen { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.re-fn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer;
  padding: 6px 11px; font: inherit; font-size: 12.5px; color: #48525c;
}
.re-fn:hover { border-color: #b5dce0; background: var(--teal-faint); color: #1d5f66; }
.re-tasten { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.re-taste {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; cursor: pointer;
  padding: 13px 0; font: inherit; font-size: 16px; color: var(--ink);
  transition: background .1s, border-color .1s;
}
.re-taste:hover { background: #f5f9fa; border-color: #cfdde0; }
.re-taste.op { color: #1d5f66; background: #fafcfc; }
.re-taste.gleich { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 600; }
.re-taste.gleich:hover { filter: brightness(1.12); background: var(--navy); }
.re-verlauf { margin-top: 10px; max-height: 110px; overflow-y: auto; }
.re-zeile {
  font-size: 12px; color: #7c868f; padding: 3px 0; border-bottom: 1px solid #f2f5f6;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
/* Erzeugte Datei als Karte in der Antwort */
.datei-karte {
  display: flex; align-items: center; gap: 12px; text-decoration: none;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  padding: 12px 14px; margin: 10px 0 4px 0; max-width: 460px;
  box-shadow: 0 1px 3px rgba(37, 56, 118, .06); transition: border-color .12s, box-shadow .12s;
}
.datei-karte:hover { border-color: #b5dce0; box-shadow: 0 3px 10px rgba(63, 164, 169, .14); }
.datei-karte .dk-symbol { font-size: 24px; line-height: 1; flex: none; }
.datei-karte .dk-text { flex: 1; min-width: 0; }
.datei-karte .dk-name {
  display: block; font-size: 13.5px; font-weight: 600; color: var(--navy);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.datei-karte .dk-sub {
  display: block; font-size: 11.5px; color: #98a3ac; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Schmale Fenster: Knopf rutscht unter den Namen statt zu quetschen */
@media (max-width: 560px) {
  .datei-karte { flex-wrap: wrap; }
  .datei-karte .dk-text { min-width: 60%; }
  .datei-karte .dk-knopf { margin-left: 36px; }
}
.datei-karte .dk-knopf {
  flex: none; font-size: 12px; font-weight: 600; color: #20666c;
  background: var(--teal-faint); border: 1px solid #cde4e7;
  border-radius: 99px; padding: 5px 12px;
}
/* Interaktive Ansicht direkt in der Antwort (Sandkasten-Rahmen) */
.art-embed {
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: #fff; margin: 10px 0 4px 0;
  box-shadow: 0 1px 3px rgba(37, 56, 118, .06);
}
.art-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: #fafcfc; border-bottom: 1px solid var(--line);
}
.art-head .art-titel { font-size: 12.5px; font-weight: 600; color: var(--navy); flex: 1; }
.art-head .art-btns { display: flex; gap: 6px; }
.art-embed .art-frame {
  width: 100%; height: 620px; border: none; display: block; background: #f6f9fa;
  transition: height .18s ease;
}
.art-embed.gross .art-frame { height: 85vh; }
.art-head .art-hinweis { font-size: 11px; color: #98a3ac; margin-right: 8px; }
/* Freigabeprinzip: Karte, wenn die KI auf Bibliotheks-Dateien zugreifen will */
.consent-card {
  border: 1px solid #e7d9a8; background: #fdf8e7; border-radius: 12px;
  padding: 10px 12px; margin: 4px 0 10px 0; font-size: 13px; color: #6a5620;
}
.consent-card .consent-actions { display: flex; gap: 8px; margin-top: 9px; }
.consent-card .consent-status { margin-top: 7px; font-weight: 600; }
.consent-card.ok { border-color: #bfe0cd; background: #eaf6ef; color: #1f6b45; }
.consent-card.denied { border-color: #e5c2bd; background: #faeeec; color: #93463c; }
/* Wissens-Bibliothek: Team-Abzeichen + Admin-Schalter in der Datei-Unterzeile */
.team-tag { color: var(--teal); font-weight: 700; }
.sub-link {
  background: none; border: none; padding: 0; cursor: pointer;
  font-size: 11px; color: #a8b0b8; text-decoration: underline;
}
.sub-link:hover { color: var(--teal); }

.panel-menu { border-top: 1px solid #eef1f3; padding: 8px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  color: #48525c; font-size: 13px; cursor: pointer;
}
.menu-item:hover { background: #f3f7f8; }
.menu-item svg { color: #8fa9b4; flex: none; }
.menu-item.sub { padding-left: 32px; font-size: 12.5px; color: #5b6672; }
.mini-on {
  margin-left: auto; font-size: 10px; font-weight: 600; color: #1f7a4d;
  background: #e3f3ea; border-radius: 99px; padding: 2px 8px;
}
.mini-on.off { color: #8a5a1f; background: #f9edda; }

.panel-bottom {
  border-top: 1px solid #eef1f3; padding: 12px 16px; display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.who { flex: 1; line-height: 1.25; min-width: 0; }
.who .n { display: flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: #2b3138; }
.who .r { font-size: 11px; color: #9aa4ad; }
.badge-shield { width: 14px; height: 14px; border-radius: 4px; background: var(--teal-subtle); display: grid; place-items: center; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  color: #9aa4ad; background: none; border: none; cursor: pointer; flex: none;
}
.icon-btn:hover { background: #f1f5f6; color: #647079; }
.panel-bottom .icon-btn { width: 28px; height: 28px; }

/* ============ HAUPTBEREICH ============ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 32px 6px 32px; }
/* Aktionsgruppe rechts: EIN zusammenhängendes Kästchen statt drei Einzelknöpfe */
.top-actions.gruppe {
  display: inline-flex; align-items: stretch;
  background: var(--teal-faint); border: 1px solid #cfe6e8; border-radius: 12px;
  padding: 3px; gap: 3px;
}
.top-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid transparent; background: none; border-radius: 9px;
  padding: 7px 13px; font: inherit; font-size: 13px; color: #3d6a70; cursor: pointer;
  transition: background .12s, color .12s;
}
.top-btn:hover { background: #fff; color: #1d5f66; }
.top-btn.accent { background: #fff; border-color: #bcdfe2; color: #1d5f66; font-weight: 600; }
.top-btn.accent:hover { background: #fff; box-shadow: 0 1px 4px rgba(63, 164, 169, .18); }

/* Aktualisieren-Knopf dreht sich kurz beim Klick – sichtbares Feedback */
.icon-btn.dreht svg { animation: drehen .45s ease; }
@keyframes drehen { to { transform: rotate(360deg); } }
/* Seitenleisten-Griff: sitzt mittig am Rand der Leiste, klappt sie ein/aus */
.panel-griff {
  position: fixed; top: 50%; left: 300px; transform: translate(-50%, -50%); z-index: 40;
  width: 22px; height: 46px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: #90a0aa; cursor: pointer; display: grid; place-items: center;
  box-shadow: 0 1px 4px rgba(37, 56, 118, .10); transition: left .16s, color .12s, box-shadow .12s;
}
.panel-griff:hover { color: var(--teal); box-shadow: 0 2px 8px rgba(63, 164, 169, .22); }
.panel-griff svg { transition: transform .16s; }
/* Eingeklappt: Griff wandert an den linken Rand, Pfeil dreht sich um */
body.panel-zu .panel-griff { left: 12px; }
body.panel-zu .panel-griff svg { transform: rotate(180deg); }
.neu-wrap { position: relative; }
.neu-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 36;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(16, 30, 60, .16); padding: 6px; min-width: 190px;
  display: flex; flex-direction: column;
}
.neu-item {
  text-align: left; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 13px; color: #2b3138; padding: 8px 10px; border-radius: 8px;
}
.neu-item:hover { background: var(--teal-faint); color: #1d5f66; }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-title {
  font-size: 14px; font-weight: 600; color: #3d4650; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; border-radius: 8px; padding: 3px 8px; cursor: text;
}
.chat-title:hover { background: #eef3f4; }
.chat-title:focus { outline: 2px solid var(--teal); background: #fff; }

.chat-scroll { flex: 1; display: flex; justify-content: center; overflow-y: auto; }
.chat-col { width: 900px; max-width: 100%; padding: 16px 16px 8px 16px; display: flex; flex-direction: column; gap: 26px; }

/* Leerzustand */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 40px 16px; }
.empty .spark { width: 56px; height: 56px; border-radius: 16px; background: var(--grad); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(63, 164, 169, .3); margin-bottom: 14px; }
.empty h2 { font-family: "Roboto Slab", serif; font-weight: 600; font-size: 22px; color: #22303f; }
.empty p { color: #7c8791; font-size: 14px; max-width: 440px; }

.day-divider { display: flex; align-items: center; gap: 14px; }
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 1px; background: #e3ebed; }
.day-divider span { font-size: 11.5px; color: #4d8f94; background: var(--teal-faint); padding: 3px 12px; border-radius: 99px; font-weight: 500; }

.msg-user { align-self: flex-end; max-width: 78%; }
.msg-user .bubble { background: var(--teal-subtle); color: #1d3050; border-radius: 18px 18px 6px 18px; padding: 12px 16px; font-size: 14.5px; white-space: pre-wrap; overflow-wrap: break-word; }
.msg-user .meta { text-align: right; margin-top: 6px; font-size: 11px; color: #a8b0b8; }
.msg-user .file-chip { margin-top: 6px; justify-content: flex-end; }

.msg-ai { display: flex; gap: 14px; max-width: 92%; }
.ai-avatar { width: 30px; height: 30px; border-radius: 10px; flex: none; margin-top: 2px; background: var(--grad); display: grid; place-items: center; box-shadow: 0 2px 6px rgba(63, 164, 169, .35); }
.msg-ai .body { font-size: 14.5px; color: #2b3138; min-width: 0; overflow-wrap: break-word; }
.msg-ai .body p + p, .msg-ai .body p + ul, .msg-ai .body ul + p { margin-top: 10px; }
.msg-ai .body ul { margin-left: 18px; }
.msg-ai .body li + li { margin-top: 5px; }
.msg-ai .body strong { font-weight: 600; color: var(--ink); }
.msg-ai .meta { margin-top: 8px; font-size: 11px; color: #a8b0b8; display: flex; gap: 12px; align-items: center; }
.exp-actions { display: inline-flex; gap: 6px; }
.act-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 7px; cursor: pointer;
  font-size: 10.5px; font-weight: 600; color: #68737d; padding: 2px 8px;
}
.act-btn:hover { color: #20666c; border-color: #bcdfe2; background: var(--teal-faint); }
.act-btn:disabled { opacity: .5; cursor: default; }
.msg-ai .ai-col { min-width: 0; flex: 1; }
.cursor::after { content: "▍"; color: var(--teal); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Ansichten: Tabellen, Überschriften, Code */
.body .md-h { font-family: "Roboto Slab", serif; color: var(--navy); font-weight: 600; margin: 14px 0 6px; }
.body h3.md-h { font-size: 16px; }
.body h4.md-h { font-size: 14.5px; }
.body h5.md-h { font-size: 13.5px; }
.table-wrap { overflow-x: auto; margin: 10px 0; border: 1px solid #dfe7ea; border-radius: 12px; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.table-wrap th {
  text-align: left; font-weight: 600; color: var(--navy); background: var(--teal-faint);
  padding: 9px 12px; border-bottom: 1px solid #d5e4e7; white-space: nowrap;
}
.table-wrap td { padding: 8px 12px; border-bottom: 1px solid #eef3f4; color: #2b3138; vertical-align: top; }
.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tr:nth-child(even) td { background: #fafcfc; }
.body pre.code {
  background: #f4f7f8; border: 1px solid #e4ebee; border-radius: 10px; padding: 10px 12px;
  font-family: SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; overflow-x: auto;
  margin: 8px 0; white-space: pre;
}
.body code {
  background: #f0f5f6; border-radius: 5px; padding: 1px 5px;
  font-family: SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px;
}
.body a { color: var(--teal); text-decoration: underline; text-underline-offset: 2px; }
.body a:hover { color: #20666c; }

/* Werkzeug- und Datei-Chips über der Antwort */
.tool-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.run-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500;
  color: #4d6a8f; background: #eef2f8; border: 1px solid #dbe4f0; border-radius: 99px; padding: 3px 10px;
}
.run-chip.file { color: #20666c; background: var(--teal-faint); border-color: #cde4e7; text-decoration: none; }
.run-chip.file:hover { background: var(--teal-subtle); }

/* ============ EINGABEFELD ============ */
.composer-wrap { display: flex; flex-direction: column; align-items: center; padding: 10px 16px 12px 16px; }
.composer { width: 900px; max-width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 1px 2px rgba(37, 56, 118, .05), 0 10px 30px rgba(37, 56, 118, .07); padding: 6px 8px 8px 8px; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; padding: 4px 6px; }
.composer textarea {
  flex: 1; border: none; outline: none; resize: none; font: inherit; font-size: 14.5px;
  color: #1c1c1c; padding: 8px 4px; max-height: 180px; background: transparent; line-height: 1.5;
}
.composer textarea::placeholder { color: #9aa4ad; }
.send-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--navy); display: grid; place-items: center; flex: none; border: none; cursor: pointer; box-shadow: 0 3px 8px rgba(37, 56, 118, .3); }
.rec-btn.recording { color: #fff; background: #d64545; animation: recpulse 1.4s ease-in-out infinite; }
.rec-btn.recording:hover { background: #c23b3b; color: #fff; }
.rec-btn.busy { color: var(--teal); animation: recpulse 1.4s ease-in-out infinite; }
@keyframes recpulse { 50% { opacity: .55; } }
.send-btn:disabled { opacity: .45; cursor: default; }
/* Silben: jede Pill ist so breit wie ihr sichtbarer Text (misst app.js, weil
   ein <select> sich sonst nach seiner LÄNGSTEN Option richtet). Die Zeile ist
   so breit wie das Eingabefeld und bricht bei schmalem Bildschirm um. */
.composer-tools { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px 2px 8px; }
.pill-select {
  appearance: none; -webkit-appearance: none;
  border: 1px solid #d9e9eb; border-radius: 99px; background-color: #f4fafb;
  color: #33565c; font: inherit; font-size: 12px; letter-spacing: .01em;
  padding: 5px 24px 5px 12px; cursor: pointer;
  white-space: nowrap; flex: none;
  box-shadow: 0 1px 2px rgba(37, 56, 118, .05);
  transition: border-color .12s, background .12s, box-shadow .12s, color .12s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M1 1l3 3 3-3' fill='none' stroke='%239aa4ad' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
button.pill-select { background-image: none; padding-right: 16px; }
.pill-select:hover { border-color: #b5dce0; color: #1d4f56; box-shadow: 0 2px 6px rgba(63, 164, 169, .14); background-color: var(--teal-faint); }
.pill-select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(63, 164, 169, .12); }
.pill-select.set {
  color: #17606a; border-color: #b5dce0; background-color: var(--teal-faint); font-weight: 600;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M1 1l3 3 3-3' fill='none' stroke='%233fa4a9' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* Schmale Bildschirme: Pillen kompakter, damit maximal zwei Zeilen entstehen. */
@media (max-width: 700px) {
  .pill-select { font-size: 11px; padding: 4px 20px 4px 10px; background-position: right 7px center; }
  button.pill-select { padding-right: 12px; }
}
.disclaimer { margin-top: 9px; font-size: 11px; color: #aab4bb; text-align: center; }

.attach-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px 0 8px; }
.file-chip {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: #20666c;
  background: var(--teal-faint); border: 1px solid #cde4e7; border-radius: 99px; padding: 4px 10px;
  max-width: 100%;
}
.file-chip .fn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.file-chip button { border: none; background: none; cursor: pointer; color: #6d9aa0; display: grid; place-items: center; padding: 0; }
.file-chip button:hover { color: #b23b2e; }
.file-chip.quiet { color: #68737d; background: #f3f6f7; border-color: #e2e9eb; }
.file-chip.warn { color: #7a5410; background: #fdf5e3; border-color: #efdcb0; }
.file-chip .warn-note { font-size: 11px; font-weight: 600; }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(28, 40, 58, .35); display: grid;
  place-items: center; z-index: 40; padding: 16px;
}
/* Wichtig: `display: grid` würde das hidden-Attribut sonst aushebeln –
   dann läge das (leere) Modal unsichtbar über der ganzen Seite und
   blockierte alle Klicks. */
.modal-overlay[hidden] { display: none; }
.modal {
  width: 520px; max-width: 100%; max-height: calc(100vh - 64px); overflow-y: auto;
  background: #fff; border-radius: 18px; padding: 24px;
  box-shadow: 0 20px 60px rgba(16, 30, 60, .25);
}
.modal h3 { font-family: "Roboto Slab", serif; font-weight: 600; font-size: 17px; color: var(--navy); margin-bottom: 4px; }
.modal .m-sub { font-size: 12.5px; color: #7c8791; margin-bottom: 14px; }
.modal h4 { font-size: 13px; font-weight: 600; color: #3d4650; margin: 18px 0 6px; }
.modal label { display: block; font-size: 12px; font-weight: 500; color: #5b6672; margin: 12px 0 4px; }
.modal input[type="text"], .modal input[type="password"], .modal textarea, .modal select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  font: inherit; font-size: 13.5px; background: #fafcfc;
}
.modal textarea { min-height: 110px; resize: vertical; }
.modal input:focus, .modal textarea:focus, .modal select:focus { outline: none; border-color: var(--teal); background: #fff; }
.m-actions { display: flex; gap: 8px; margin-top: 18px; justify-content: flex-end; }
.btn {
  border: none; border-radius: 10px; padding: 9px 16px; font-size: 13px; font-weight: 500; cursor: pointer;
}
.btn.primary { background: var(--navy); color: #fff; box-shadow: 0 2px 6px rgba(37, 56, 118, .25); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: #fff; color: #48525c; border: 1px solid var(--line); }
.btn.ghost:hover { background: #f5f8f9; }
.btn.danger-ghost { background: #fff; color: #b23b2e; border: 1px solid #eccfcb; }
.m-feedback { font-size: 12.5px; margin-top: 10px; min-height: 16px; }
.m-feedback.ok { color: #1f7a4d; }
.m-feedback.err { color: #b23b2e; }

.user-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid #eef1f3;
  border-radius: 10px; margin-top: 6px; font-size: 13px;
}
.user-row .u-name { flex: 1; min-width: 0; }
.user-row .u-name .un { font-weight: 500; color: #2b3138; }
.user-row .u-name .us { font-size: 11.5px; color: #9aa4ad; }
.user-row .u-tag { font-size: 10.5px; font-weight: 600; border-radius: 99px; padding: 2px 8px; }
.user-row .u-tag.admin { color: #20666c; background: var(--teal-subtle); }
.user-row .u-tag.inactive { color: #8a5a1f; background: #f9edda; }
.user-row .mini-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; font-size: 11.5px;
  padding: 4px 8px; cursor: pointer; color: #48525c;
}
.user-row .mini-btn:hover { background: #f5f8f9; }

/* Audit-Protokoll */
.audit-list { max-height: 220px; overflow-y: auto; border: 1px solid #eef1f3; border-radius: 10px; padding: 4px 0; }
.audit-row {
  display: flex; gap: 10px; align-items: baseline; padding: 5px 12px; font-size: 12px;
  border-bottom: 1px solid #f4f6f8;
}
.audit-row:last-child { border-bottom: none; }
.audit-row .a-ts { color: #9aa4ad; flex: none; width: 82px; }
.audit-row .a-us { color: #2b3138; font-weight: 500; flex: none; width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-row .a-ac { color: #3d4650; flex: none; }
.audit-row .a-dt { color: #7c8791; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Hilfe: Anleitung + Quiz */
.guide h4 { font-family: "Roboto Slab", serif; font-size: 14px; font-weight: 600; color: var(--navy); margin: 16px 0 4px; }
.guide h4:first-child { margin-top: 0; }
.guide p { font-size: 13px; color: #3d4650; line-height: 1.55; }
.guide .guide-foot { margin-top: 16px; color: #7c8791; font-size: 12px; }
.quiz-q { border: 1px solid #eef1f3; border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.quiz-q.ok { border-color: #b7dfc8; background: #f4fbf6; }
.quiz-q.err { border-color: #eccfcb; background: #fdf7f6; }
.qq-title { font-size: 13.5px; font-weight: 600; color: #2b3138; margin-bottom: 8px; }
.qq-opt { display: flex; align-items: flex-start; gap: 8px; padding: 5px 2px; font-size: 13px; color: #3d4650; cursor: pointer; }
.qq-opt input { margin-top: 3px; accent-color: var(--teal); }
.quiz-q.ok .qq-opt.is-correct span, .quiz-q.err .qq-opt.is-correct span { color: #1f7a4d; font-weight: 600; }
.qq-why { margin-top: 8px; font-size: 12px; color: #5b6672; background: #f4f7f8; border-radius: 8px; padding: 8px 10px; line-height: 1.5; }
.quiz-result { font-size: 13.5px; font-weight: 600; color: var(--navy); padding: 10px 2px 0; }

/* Status-Pille (Admin) + Aufbewahrungs-Auswahl */
.status-pill {
  display: inline-block; font-size: 10px; font-weight: 600; border-radius: 99px;
  padding: 2px 8px; margin-left: 6px; color: #8a5a1f; background: #f9edda; vertical-align: 1px;
}
.status-pill.ok { color: #1f7a4d; background: #e3f3ea; }
.retention-wrap { display: flex; align-items: center; gap: 6px; flex: none; font-size: 13px; color: #5b6672; }
.retention-inp {
  width: 72px; border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font: inherit;
  font-size: 13px; background: #fafcfc; text-align: right;
}
.retention-inp:focus { outline: none; border-color: var(--teal); background: #fff; }

/* Auffälliges globales Suchfeld */
.search.global {
  background: var(--teal-faint); border-color: #c3dde5; color: #4d8f94; height: 38px;
}
.search.global input { color: var(--ink); }
.search.global input::placeholder { color: #6fa0a6; }
.search.global:focus-within { border-color: var(--teal); background: #fff; box-shadow: 0 0 0 3px rgba(63, 164, 169, .15); }

/* Chats-Block direkt unter der Suche */
.chats-block { padding: 4px 8px 0 8px; border-bottom: 1px solid #eef1f3; margin-bottom: 2px; }
.chats-block .retention-note { padding: 6px 10px 10px; }

/* Chat-Assistent (Roboter-Knopf, frei verschiebbar) */
.robot-btn {
  position: fixed; left: 0; top: 0; z-index: 30; /* Position setzt app.js */
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: none; background: none; cursor: grab; touch-action: none; user-select: none;
}
.robot-btn:active { cursor: grabbing; }

/* Mini-Chat-Fenster des Assistenten */
.robot-panel {
  position: fixed; width: 330px; height: 420px; z-index: 34;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 16px 48px rgba(16, 30, 60, .22);
  display: flex; flex-direction: column; overflow: hidden;
}
.rp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px 10px 14px; border-bottom: 1px solid #eef1f3;
  font-family: "Roboto Slab", serif; font-weight: 600; font-size: 14px; color: var(--navy);
  background: var(--teal-faint);
}
.rp-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.rp-msg { font-size: 13px; line-height: 1.5; max-width: 92%; overflow-wrap: break-word; }
.rp-msg.user { align-self: flex-end; background: var(--teal-subtle); color: #1d3050; border-radius: 13px 13px 4px 13px; padding: 8px 11px; }
.rp-msg.ai { align-self: flex-start; color: #2b3138; }
.rp-msg.ai .table-wrap { font-size: 12px; }
.rp-input { display: flex; gap: 6px; padding: 10px; border-top: 1px solid #eef1f3; }
.rp-input input {
  flex: 1; border: 1px solid var(--line); border-radius: 99px; padding: 8px 13px;
  font: inherit; font-size: 13px; background: #fafcfc; outline: none; min-width: 0;
}
.rp-input input:focus { border-color: var(--teal); background: #fff; }
.send-btn.rp-send { width: 32px; height: 32px; }
.robot-btn svg {
  width: 52px; height: 52px; padding: 12px; border-radius: 18px;
  background: var(--grad); box-shadow: 0 6px 18px rgba(63, 164, 169, .4);
  transition: transform .15s;
}
.robot-btn:hover svg { transform: scale(1.08) rotate(-3deg); }
.robot-label {
  font-size: 10.5px; font-weight: 600; color: #20666c; background: #fff;
  border: 1px solid #cde4e7; border-radius: 99px; padding: 2px 9px;
  box-shadow: 0 2px 6px rgba(16, 30, 60, .08);
}

/* Admin-Fenster mit Reitern */
.modal.wide { width: 640px; }
.admin-tabs { margin-bottom: 14px; }
.admin-tabs .tab { font-size: 12px; padding: 6px 0; }
.tab-expl { font-size: 12.5px; color: #5b6672; line-height: 1.5; margin: 4px 0 10px; }
.check-row {
  display: flex; align-items: flex-start; gap: 9px; padding: 6px 2px; font-size: 13px;
  color: #2b3138; cursor: pointer;
}
.check-row input { margin-top: 3px; accent-color: var(--teal); }
.check-row.tool { border-bottom: 1px solid #f2f5f6; padding: 8px 2px; }
.check-sub { font-size: 11.5px; color: #8a95a0; line-height: 1.4; }
.all-chats-list { max-height: 320px; overflow-y: auto; }

/* Darstellung: Schriftgröße und -stil (Einstellungen, pro Gerät) */
html[data-fontsize="klein"] body { font-size: 13px; }
html[data-fontsize="klein"] .msg-ai .body, html[data-fontsize="klein"] .msg-user .bubble { font-size: 13px; }
html[data-fontsize="gross"] body { font-size: 15px; }
html[data-fontsize="gross"] .msg-ai .body, html[data-fontsize="gross"] .msg-user .bubble { font-size: 16px; }
html[data-fontstyle="serif"] .msg-ai .body, html[data-fontstyle="serif"] .msg-user .bubble {
  font-family: Georgia, "Times New Roman", serif;
}

/* Umschalter */
.switch-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.switch-row .s-text { flex: 1; }
.switch-row .s-title { font-size: 13.5px; font-weight: 500; color: #2b3138; }
.switch-row .s-sub { font-size: 12px; color: #7c8791; }
.switch { position: relative; width: 40px; height: 22px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: #cfd8db; border-radius: 99px; transition: background .15s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .15s;
}
.switch input:checked + .slider { background: var(--teal); }
.switch input:checked + .slider::before { transform: translateX(18px); }

@media (max-width: 720px) {
  .panel { position: fixed; inset: 4px 60px 0 0; z-index: 30; box-shadow: 20px 0 50px rgba(16,30,60,.2); }
  .panel.collapsed { display: none; }
}
