/* chat: Fenster an der rechten Seite. Ab 1280 px schiebt es die Arbeitsfläche, darunter liegt es darüber, am Handy füllt es den Schirm. */
#chat-open{width:40px;height:40px;min-height:40px;padding:0;border-radius:50%;display:grid;place-items:center;border-color:var(--line);flex-shrink:0}
#chat-open svg{width:21px;height:21px}
#chat-open[aria-expanded=true]{background:var(--surface);border-color:var(--ink)}
#chat{position:fixed;top:64px;right:0;bottom:0;width:var(--chat-w,420px);max-width:100vw;background:#fff;border-left:1px solid var(--line);z-index:6;display:flex;flex-direction:column;box-shadow:-12px 0 32px rgba(50,51,56,.12)}
#chat.resizing,body.resizing{user-select:none}
.ch-zug{position:absolute;left:-6px;top:0;bottom:0;width:12px;cursor:col-resize;touch-action:none;z-index:2}
.ch-zug:after,#rail-zug:after{content:"";position:absolute;left:4px;top:50%;width:4px;height:44px;margin-top:-22px;border-radius:2px;background:#c3c6d4;opacity:0;transition:opacity .15s ease-out}
.ch-zug:hover:after,.ch-zug:focus-visible:after,.resizing .ch-zug:after,#rail-zug:hover:after,#rail-zug:focus-visible:after,body.resizing>#rail-zug:after{opacity:1;background:var(--accent)}
.ch-zug:after{opacity:1}
/* Griff am Menü: liegt als eigenes Stück auf der Kante, weil das Menü selbst scrollt. */
#rail-zug{position:fixed;top:64px;bottom:0;left:calc(var(--rail) - 6px);width:12px;cursor:col-resize;touch-action:none;z-index:3}
body.nav-collapsed #rail-zug{display:none}

.ch-kopf{display:flex;align-items:center;gap:6px;padding:10px 12px 10px 16px;border-bottom:1px solid var(--line);min-height:56px}
.ch-titel{flex:1;min-width:0;display:flex;align-items:center;gap:4px;border:0;background:transparent;padding:6px 8px;min-height:36px;font-size:15px;font-weight:600;text-align:left}
.ch-titel span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ch-titel svg{width:16px;height:16px;flex-shrink:0;color:var(--muted)}.ch-titel:disabled{opacity:1}.ch-titel:disabled svg{display:none}
.ch-knopf{width:36px;height:36px;min-height:36px;padding:0;display:grid;place-items:center;border-color:transparent;flex-shrink:0}
.ch-knopf svg{width:19px;height:19px}
.ch-knopf[aria-expanded=true]{background:var(--surface)}
.ch-zurueck{align-self:flex-start;display:flex;align-items:center;gap:4px;border:0;background:transparent;font-weight:400;font-size:13px;color:var(--muted);margin:8px 8px 0;min-height:36px}
.ch-zurueck svg{width:16px;height:16px;transform:rotate(90deg)}.ch-zurueck:hover{color:var(--ink)}
/* Aufklappmenüs (Titel, Regler, +) */
.ch-menue{position:absolute;z-index:5;min-width:200px;background:#fff;border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 10px 30px rgba(50,51,56,.16);padding:6px;display:grid;gap:2px}
.ch-menue button{display:flex;align-items:center;gap:10px;border:0;background:transparent;font-weight:400;text-align:left;min-height:38px;padding:6px 10px;border-radius:var(--radius)}
.ch-menue button:hover,.ch-menue button:focus-visible{background:var(--surface)}.ch-menue svg{width:18px;height:18px;flex-shrink:0}.ch-menue .ch-rot{color:#b3261e}
.ch-seite{flex:1;min-height:0;display:flex;flex-direction:column;position:relative}
.ch-rolle{flex:1;min-height:0;overflow-y:auto;padding:16px}

/* Gespräche */
.ch-verlauf{position:absolute;inset:0;z-index:1;background:#fff;overflow-y:auto;padding:12px}
.ch-verlauf li{display:flex;align-items:center;gap:2px;border-radius:var(--radius)}
.ch-verlauf ul{list-style:none;margin:0;padding:0}
.ch-verlauf li:hover,.ch-verlauf li.ch-aktiv{background:var(--surface)}
.ch-verlauf li.ch-aktiv{background:var(--surface);font-weight:600}
.ch-wahl{flex:1;min-width:0;text-align:left;border:0;background:transparent;font-weight:400;padding:8px 12px}
.ch-wahl strong{display:block;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ch-wahl small{display:block}

/* Nachrichten */
.ch-nachrichten{flex:1;min-height:0;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:14px}
.ch-leer{margin:auto;max-width:300px;text-align:center;color:var(--muted)}
.ch-leer strong{display:block;color:var(--ink);font-size:17px;margin-bottom:6px}
.ch-n{min-width:0;max-width:100%}
.ch-n.ch-user{align-self:flex-end;max-width:88%}
.ch-n.ch-user .ch-text{background:var(--surface);border-radius:var(--radius);padding:9px 15px;white-space:pre-wrap}
.ch-text{overflow-wrap:anywhere;line-height:1.55}
.ch-text p{margin:0 0 10px;max-width:none}.ch-text>:last-child{margin-bottom:0}
.ch-text h3{font-size:17px;margin:16px 0 8px}.ch-text h4{font-size:15px;margin:14px 0 6px}.ch-text h5{font-size:14px;margin:12px 0 6px}
.ch-text>h3:first-child,.ch-text>h4:first-child,.ch-text>h5:first-child{margin-top:0}
.ch-text ul,.ch-text ol{margin:0 0 10px;padding-left:22px}.ch-text li{margin:2px 0}
.ch-text code{font:12.5px/1.5 Consolas,"Cascadia Mono",monospace;background:var(--surface);border-radius:var(--r-klein);padding:1px 5px}
.ch-text blockquote{margin:0 0 10px;padding:2px 0 2px 12px;border-left:3px solid var(--field);color:var(--muted)}
.ch-text hr{border:0;border-top:1px solid var(--line);margin:14px 0}
.ch-text a{color:var(--accent)}
.ch-code{margin:0 0 10px;border:1px solid var(--line);border-radius:var(--radius);overflow:hidden;background:var(--surface)}
.ch-code-kopf{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:2px 4px 2px 12px;border-bottom:1px solid var(--line);font-size:12px;color:var(--muted)}
.ch-code-kopf span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ch-code-kopf button{display:flex;align-items:center;gap:5px;border:0;background:transparent;min-height:30px;padding:2px 8px;font-size:12px;font-weight:400;color:var(--muted)}
.ch-code-kopf button:hover{color:var(--ink)}.ch-code-kopf svg{width:14px;height:14px}
.ch-code pre{margin:0;padding:10px 12px;overflow-x:auto}.ch-code pre code{background:none;padding:0}
.ch-tabelle{margin:0 0 10px;overflow-x:auto}
.ch-tabelle table{border-collapse:collapse;font-size:13px;min-width:100%}
.ch-tabelle th,.ch-tabelle td{border-bottom:1px solid var(--line);padding:6px 10px;text-align:left;vertical-align:top}
.ch-tabelle th{font-weight:600;border-bottom-color:var(--field)}
/* Symbolleiste unter jeder Nachricht; bei eigenen Nachrichten erst beim Überfahren. */
.ch-taten{display:flex;flex-wrap:wrap;align-items:center;gap:0;margin-top:4px;min-height:32px}
.ch-user .ch-taten{justify-content:flex-end}
/* Uhrzeit bleibt sichtbar; die Knöpfe erscheinen erst bei Zeiger oder Fokus. */
.ch-user .ch-taten button{opacity:0;transition:opacity .12s}
.ch-user:hover .ch-taten button,.ch-user:focus-within .ch-taten button{opacity:1}
@media(hover:none){.ch-user .ch-taten button{opacity:1}}
.ch-sym{width:32px;height:32px;min-height:32px;padding:0;display:grid;place-items:center;border:0;background:transparent;border-radius:var(--radius);color:var(--muted)}
.ch-sym svg{width:17px;height:17px}
.ch-sym:hover{background:var(--surface);color:var(--ink)}
.ch-sym[aria-pressed=true]{background:var(--surface);color:var(--accent)}
.ch-wort{display:flex;align-items:center;gap:6px;min-height:32px;padding:2px 8px;border:0;background:transparent;font-size:12px;font-weight:400;color:var(--muted)}
.ch-wort svg{width:15px;height:15px}.ch-wort:hover{color:var(--ink)}
.ch-wer{font-size:11px;color:var(--muted);margin-left:6px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:50%}
.ch-runter{position:absolute;left:50%;transform:translateX(-50%);bottom:var(--ch-eingabe-h,150px);width:36px;height:36px;min-height:36px;padding:0;border-radius:50%;display:grid;place-items:center;background:#fff;box-shadow:0 4px 14px rgba(50,51,56,.16);z-index:1}
.ch-runter svg{width:18px;height:18px}
.ch-fehler{color:#b3261e}
.ch-stumm{color:var(--muted);font-style:italic}
.ch-denkt{display:inline-flex;gap:5px;padding:8px 0}
.ch-denkt i{width:7px;height:7px;border-radius:50%;background:var(--field)}
@media(prefers-reduced-motion:no-preference){
 .ch-denkt i{animation:ch-puls 1.1s ease-in-out infinite}.ch-denkt i:nth-child(2){animation-delay:.18s}.ch-denkt i:nth-child(3){animation-delay:.36s}
 @keyframes ch-puls{0%,80%,100%{opacity:.35;transform:none}40%{opacity:1;transform:translateY(-3px)}}
 #chat:not([hidden]){animation:ch-rein .18s ease-out}@keyframes ch-rein{from{transform:translateX(24px);opacity:.6}}
}

/* Eingabe */
/* Eingabekarte: Text oben, Leiste unten (+ · Modell · Diktat · Senden), Vergrößern oben rechts. */
.ch-eingabe{padding:4px 12px 8px}
.ch-karte{position:relative;border:1px solid var(--field);border-radius:var(--radius);background:#fff;padding:10px 10px 6px 14px;box-shadow:0 2px 10px rgba(50,51,56,.06);cursor:text}
.ch-karte:focus-within{border-color:#9da1b3}
.ch-karte textarea{display:block;border:0;padding:4px 30px 4px 2px;min-height:28px;max-height:none;resize:none;overflow-y:auto;background:transparent;line-height:1.5}
.ch-karte textarea:focus-visible{outline:0}
.ch-gross{position:absolute;top:6px;right:6px}
.ch-leiste{display:flex;align-items:center;gap:4px;margin-top:4px}
.ch-luecke{flex:1}
.ch-leiste select{margin:0;width:auto;max-width:40%;text-align:left;text-align-last:left;min-width:0;min-height:32px;padding:4px 24px 4px 8px;font-size:13px;color:var(--muted);border:0;background-color:transparent;border-radius:var(--radius);cursor:pointer;text-overflow:ellipsis}
.ch-leiste select:hover{background-color:var(--surface);color:var(--ink)}
.ch-senden{width:34px;height:34px;min-height:34px;padding:0;border-radius:50%;display:grid;place-items:center;background:var(--ink);border-color:var(--ink);color:#fff;flex-shrink:0}
.ch-senden:hover{background:#000;border-color:#000}
.ch-senden svg{width:18px;height:18px}
.ch-senden:disabled{background:var(--field);border-color:var(--field);opacity:1}
.ch-hinweis{margin:6px 0 0;font-size:11px;color:var(--muted);text-align:center;max-width:none}
.ch-eingabe.ch-gross-an .ch-hinweis{display:none}
.ch-meldung{margin:0;padding:0 14px 10px;font-size:12px;color:var(--muted)}.ch-meldung:empty{display:none}
.ch-unsichtbar{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.ch-meldung.ch-fehler{color:#b3261e}

/* Gedächtnis und Modelle */
.ch-rolle h3{margin:0 0 6px}.ch-rolle h3:not(:first-child){margin-top:26px}
.ch-rolle>p{font-size:13px;color:var(--muted)}
.ch-liste{list-style:none;margin:0 0 14px;padding:0;border-top:1px solid var(--line)}
.ch-liste>li{padding:10px 0;border-bottom:1px solid var(--line)}
.ch-liste .ch-satz{white-space:pre-wrap;overflow-wrap:anywhere}
.ch-zeile{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}
.ch-zeile strong{overflow-wrap:anywhere}
.ch-zeile small{flex:1;min-width:120px;overflow-wrap:anywhere}
.ch-marke{font-size:12px;border-radius:var(--r-klein);padding:1px 8px;background:var(--surface);color:var(--muted);white-space:nowrap}
.ch-marke.ch-an{background:#d9f7ea;color:#00643b}
.ch-form{display:grid;gap:12px;margin-top:8px}
.ch-form .ch-haken{display:flex;align-items:center;gap:8px;font-weight:400;font-size:13px}
.ch-form .ch-haken input{width:18px;height:18px;min-height:18px;margin:0}
.ch-form-fuss{display:flex;gap:8px;flex-wrap:wrap}
.ch-probe{margin:6px 0 0;font-size:12px}

@media(min-width:1280px){
 #chat{box-shadow:none}
 body.chat-open main,body.chat-open>footer{margin-right:calc(var(--chat-w,420px) + var(--rand,0px))}
 body.chat-open .fp-panel{right:calc(var(--chat-w,420px) + var(--rand,0px))}
}
@media(max-width:760px){
 #chat{top:0;width:100%!important;border-left:0;z-index:20}
 .ch-zug,#rail-zug{display:none}
 .ch-knopf{width:44px;height:44px;min-height:44px}
 .ch-taten button{min-height:36px}
 body.chat-open{overflow:hidden}
}

/* Live: Etappe unter dem entstehenden Text, Gedanken zugeklappt und gedämpft. */
.ch-etappe{display:flex;align-items:center;gap:8px;margin:0;color:var(--muted);font-size:13px}
.ch-live:empty{display:none}
.ch-denken{margin:0 0 8px;color:var(--muted);font-size:13px}
.ch-denken summary{cursor:pointer;min-height:28px;display:flex;align-items:center;list-style-position:inside}
.ch-denken-text{white-space:pre-wrap;max-height:240px;overflow:auto;padding:4px 0 2px;line-height:1.45}
/* Modellknopf links neben „+“: Modell · Denkstufe; das Menü zeigt beides. */
.ch-wahl{display:inline-flex;align-items:center;gap:4px;min-width:0;max-width:70%;min-height:32px;margin:0;padding:4px 6px 4px 8px;border:0;background:transparent;color:var(--muted);font-size:13px;font-weight:400;border-radius:var(--radius);text-align:left}
.ch-wahl span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ch-wahl svg{width:14px;height:14px;flex:none}
.ch-wahl:hover,.ch-wahl[aria-expanded=true]{background:var(--surface);color:var(--ink)}
.ch-modellmenue{width:min(280px,calc(100% - 16px));padding:0;gap:0}
.ch-modelle{overflow-y:auto;padding:6px;display:grid;gap:2px}
.ch-gruppe{margin:6px 10px 2px;font-size:12px;font-weight:600;color:var(--muted)}
.ch-modellmenue .ch-modelle button{justify-content:space-between;min-height:34px}
.ch-modellmenue [aria-checked=false] svg{visibility:hidden}
.ch-stufen{border-top:1px solid var(--line);padding:4px 6px 8px}
.ch-stufen>div{display:flex;flex-wrap:wrap;gap:4px;padding:0 4px}
.ch-modellmenue .ch-stufen button{min-height:30px;padding:2px 10px;font-size:13px;border:1px solid var(--line);border-radius:var(--r-klein)}
.ch-modellmenue .ch-stufen button[aria-pressed=true]{background:var(--ink);border-color:var(--ink);color:#fff}

/* Aktionsvorschlag unter der Antwort: Karte mit Zweck, Ziel, änderbarer Eingabe und Ausführen/Verwerfen. */
.ch-aktion{margin:12px 0 4px;padding:10px 12px;border:1px solid var(--line);border-radius:var(--radius);background:var(--white)}
.ch-aktion[data-stand=rejected]{opacity:.65}
.ch-aktion .ch-zeile>svg{width:16px;height:16px;flex:none;align-self:center}
.ch-aktion .ch-zeile strong{flex:1;min-width:0}
.ch-aktion-art{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;margin:6px 0 0;font-size:13px;color:var(--muted)}
.ch-aktion-art code{overflow-wrap:anywhere}
.ch-aktion-zweck{margin:6px 0 0;font-size:13px;color:var(--muted)}
.ch-aktion details{margin-top:8px;font-size:13px}
.ch-aktion summary{cursor:pointer;min-height:28px;display:flex;align-items:center;list-style-position:inside}
.ch-aktion-eingabe{width:100%;box-sizing:border-box;font:12px/1.45 ui-monospace,Consolas,monospace;resize:vertical}
.ch-aktion-json{margin:4px 0 0;white-space:pre-wrap;overflow-wrap:anywhere;font-size:12px;max-height:240px;overflow:auto}
.ch-aktion .ch-taten{margin-top:10px;gap:8px;opacity:1}
.ch-marke.ch-offen{background:#fff6c2;color:#5c4f00}
.ch-marke.ch-rot{background:#fde4e1;color:#9b1c13}
.ch-aktion .ch-taten button.primary{display:inline-flex;align-items:center;gap:6px;width:auto;height:auto;min-height:36px;padding:6px 14px;font-weight:600}
.ch-aktion .ch-taten button.primary svg{width:16px;height:16px;flex:none}
/* Agent bedient die Seite (agent-bruecke.js): Schrittzeilen, Speichern-Frage, gelbes Aufblinken am Element */
.ch-schritte{list-style:none;margin:0 0 8px;padding:0;display:grid;gap:2px;color:var(--muted);font-size:13px}
.ch-schritte li::before{content:'›';margin-right:6px;color:var(--ink)}
.ch-agentfrage{margin:10px 0;padding:12px 14px;border-radius:var(--radius);background:var(--surface)}
.ch-agentfrage p{margin:0 0 4px}.ch-agentfrage-wo{color:var(--muted);font-size:12px}
.ch-agentfrage-knoepfe{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.agent-blink{outline:3px solid #FFD23A!important;outline-offset:2px;box-shadow:0 0 0 6px rgba(255,210,58,.35)!important;transition:outline-color .2s}
.ch-modus{display:inline-flex;gap:2px;padding:2px;border-radius:var(--radius);background:var(--surface)}
.ch-modus .ch-sym{width:28px;height:28px;min-height:28px}
.ch-modus .ch-sym[aria-pressed=true]{background:var(--white);color:var(--ink);box-shadow:0 1px 2px rgba(15,15,15,.12)}
.ch-alle{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:10px 0;padding:10px 12px;border-radius:var(--radius);background:var(--surface)}
.ch-alle span{flex:1;min-width:120px;color:var(--muted);font-size:13px}
.ch-alle button:focus:not(:focus-visible),.ch-agentfrage button:focus:not(:focus-visible){outline:none}

/* Datumslinie und Uhrzeit (v29) */
.ch-tag{display:flex;align-items:center;gap:10px;margin:14px 0 6px;font-size:12px;color:var(--muted)}
.ch-tag::before,.ch-tag::after{content:"";flex:1;border-top:1px solid var(--line,#e2e2e2)}
.ch-tag time{white-space:nowrap;max-width:80%;overflow:hidden;text-overflow:ellipsis}
.ch-zeit{font-size:11px;color:var(--muted);margin-left:6px;font-variant-numeric:tabular-nums;white-space:nowrap}
.ch-gefunden{background:#FFD23A;box-shadow:0 0 0 6px #FFD23A;border-radius:var(--radius);transition:background .4s,box-shadow .4s}
.ch-aktion-wer{margin:6px 0 0;font-size:12px;color:var(--muted)}
/* Suche im Gesprächsverlauf */
.ch-suche{display:grid;gap:8px;margin-bottom:12px}
.ch-suche input{width:100%;min-height:40px;box-sizing:border-box}
.ch-suche-zeit{display:grid;grid-template-columns:minmax(0,1.6fr) minmax(0,1fr) minmax(0,1fr);gap:6px}
.ch-feld{display:grid;gap:2px;min-width:0}
.ch-feld span{font-size:11px;color:var(--muted)}
.ch-suche-knoepfe{display:flex;gap:8px;align-items:center}
.ch-suche-knoepfe button{min-height:40px}
.ch-treffer{list-style:none;margin:0 0 12px;padding:0}
.ch-treffer .ch-wahl{display:grid;gap:2px;width:100%;max-width:none;text-align:left;padding:8px;border-radius:var(--radius);color:var(--ink)}
.ch-treffer .ch-wahl:hover{background:var(--surface)}
.ch-ausschnitt{font-size:13px;color:var(--ink);overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.ch-verlauf .ch-gruppe{font-size:12px;color:var(--muted);margin:8px 0 4px;font-weight:600}
@media(max-width:400px){.ch-suche-zeit{grid-template-columns:1fr 1fr}.ch-suche-zeit .ch-feld:first-child{grid-column:1/-1}}
