/* KI-Assistent (Sidebar) — AP-B
   PS1/N64-Retro wie style.css: harte Kanten, Hard-Shadows, Pixelfont für Labels,
   Farben nur über Tokens, KEINE Gradients. */

/* ============ Rahmen & Layout ============ */
.ai-side {
  --ai-pad: 12px;
  position: fixed; z-index: 55;              /* unter Modals (60), Toast (80), Galerie (90) */
  top: var(--ai-top, 0px); right: 0; bottom: 0;
  width: var(--ai-w, 400px);
  display: none; flex-direction: column;
  background: var(--surface);
  border-left: 3px solid var(--line);
  box-shadow: -4px 0 0 var(--shadow-c);
  color: var(--text);
}
.ai-side.open { display: flex; animation: ai-in .14s steps(4, end); }
@keyframes ai-in { from { transform: translateX(40px); opacity: .4; } }
#app.hidden ~ .ai-side { display: none !important; }   /* Login-Screen: keine Sidebar */

/* Desktop: Inhalt rückt zur Seite und bleibt bedienbar */
@media (min-width: 900px) {
  body.ai-open .view,
  body.ai-open .bottombar { margin-right: var(--ai-w, 400px); }
}
/* Mobil: Vollbild-Overlay */
@media (max-width: 899px) {
  .ai-side {
    top: 0; left: 0; width: auto;
    border-left: 0; box-shadow: none;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .ai-side.open { animation: ai-up .14s steps(4, end); }
  .ai-resize, .ai-hint { display: none !important; }
}
@keyframes ai-up { from { transform: translateY(30px); opacity: .4; } }

/* Breite ziehen */
.ai-resize {
  position: absolute; left: -6px; top: 0; bottom: 0; width: 10px;
  cursor: ew-resize; z-index: 3; touch-action: none;
}
.ai-resize:hover, .ai-side.resizing .ai-resize { background: var(--accent); opacity: .55; }
.ai-side.resizing { user-select: none; }

/* ============ Kopf ============ */
.ai-head {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px var(--ai-pad);
  background: var(--surface-2);
  border-bottom: 2px solid var(--line);
}
.ai-title { font-family: var(--px); font-weight: 700; font-size: .8rem; white-space: nowrap; }
.ai-model {
  flex: 0 1 auto; min-width: 0; max-width: 45%;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border: 2px solid var(--line); background: var(--surface);
  box-shadow: 2px 2px 0 var(--shadow-c);
  font-family: var(--px); font-size: .55rem; font-weight: 700; color: var(--muted);
  cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.ai-model:hover { color: var(--text); border-color: var(--accent); }
.ai-model:active { transform: translate(2px, 2px); box-shadow: none; }
.ai-dot { flex: none; width: 8px; height: 8px; background: var(--muted); border: 1px solid var(--line); }
.ai-dot.ok { background: var(--ok); }
.ai-hbtns { margin-left: auto; display: flex; gap: 4px; flex: none; }
.ai-hbtn {
  width: 32px; height: 32px; padding: 0;
  border: 2px solid transparent; background: transparent;
  font-size: .95rem; line-height: 1; cursor: pointer;
  font-family: var(--px); font-weight: 700;
}
.ai-hbtn:hover { border-color: var(--line); background: var(--surface); box-shadow: 2px 2px 0 var(--shadow-c); }
.ai-hbtn:active { transform: translate(2px, 2px); box-shadow: none; }

/* ============ Verlauf ============ */
.ai-body { position: relative; flex: 1; min-height: 0; display: flex; }
.ai-log {
  flex: 1; min-width: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: var(--ai-pad);
  display: flex; flex-direction: column; gap: 10px;
  background-color: var(--bg);
  background-image: var(--dither);
  background-size: 4px 4px;
}
.ai-jump {
  position: absolute; right: 14px; bottom: 10px; z-index: 2;
  padding: 5px 10px;
  border: 2px solid var(--line); background: var(--accent); color: #fff;
  box-shadow: 3px 3px 0 var(--shadow-c);
  font-family: var(--px); font-size: .6rem; font-weight: 700; cursor: pointer;
}

/* Blasen */
.ai-msg { display: flex; flex-direction: column; max-width: 92%; animation: pop .15s steps(3, end); }
.ai-u { align-self: flex-end; align-items: flex-end; }
.ai-a { align-self: flex-start; align-items: flex-start; }
.ai-bub {
  padding: 9px 12px;
  border: 2px solid var(--line);
  box-shadow: 3px 3px 0 var(--shadow-c);
  font-size: .92rem; line-height: 1.45;
  overflow-wrap: anywhere;
}
.ai-u .ai-bub { background: var(--accent-soft); white-space: pre-wrap; }
.ai-a .ai-bub { background: var(--surface); }
.ai-meta {
  display: flex; align-items: center; gap: 6px;
  margin-top: 4px; padding: 0 2px;
  font-family: var(--px); font-size: .5rem; color: var(--muted);
}
.ai-copy-btn {
  border: 0; background: transparent; padding: 0 2px; cursor: pointer;
  font-size: .8rem; opacity: .55;
}
.ai-copy-btn:hover { opacity: 1; }
.ai-msg:not(:hover) .ai-copy-btn { opacity: .3; }

/* Mini-Markdown */
.ai-md > :first-child { margin-top: 0; }
.ai-md > :last-child { margin-bottom: 0; }
.ai-md p { margin: 0 0 .55em; }
.ai-md ul, .ai-md ol { margin: .2em 0 .6em; padding-left: 1.3em; }
.ai-md li { margin: .15em 0; }
.ai-md li.sub { margin-left: 1.1em; list-style-type: square; }
.ai-md li::marker { color: var(--accent); }
.ai-md .ai-h {
  font-family: var(--px); font-weight: 700; font-size: .72rem;
  margin: .8em 0 .4em; color: var(--accent);
}
.ai-md .ai-h1 { font-size: .8rem; }
.ai-md code {
  font-family: var(--mono); font-size: .85em;
  background: var(--surface-2); border: 1px solid var(--border); padding: 0 4px;
}
.ai-md pre {
  margin: .4em 0 .6em; padding: 8px; overflow-x: auto;
  background: var(--surface-2); border: 2px solid var(--border);
  font-size: .8rem; white-space: pre;
}
.ai-md pre code { border: 0; padding: 0; background: none; }
.ai-md blockquote { margin: .3em 0; padding: 2px 10px; border-left: 3px solid var(--accent); color: var(--muted); }
.ai-md hr { border: 0; border-top: 2px dashed var(--border); margin: .8em 0; }
.ai-md a { text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.ai-md a.ai-in, .ai-tres a.ai-in {
  text-decoration: none;
  padding: 0 4px;
  border: 1px solid var(--accent); background: var(--accent-soft);
  color: var(--text); font-weight: 600;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.ai-md a.ai-in::after { content: ' ›'; color: var(--accent); }
.ai-md a.ai-in:hover { background: var(--accent); color: #fff; }
.ai-tbl { overflow-x: auto; margin: .3em 0 .7em; }
.ai-md table { border-collapse: collapse; font-size: .82rem; min-width: 100%; }
.ai-md th, .ai-md td { border: 1px solid var(--border); padding: 4px 7px; text-align: left; vertical-align: top; }
.ai-md th { background: var(--surface-2); font-family: var(--px); font-size: .55rem; }

/* Fotos */
.ai-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; justify-content: flex-end; }
.ai-thumbs img {
  width: 64px; height: 64px; object-fit: cover; cursor: zoom-in;
  border: 2px solid var(--line); box-shadow: 2px 2px 0 var(--shadow-c);
  background: var(--surface-2);
}
.ai-thumbs.sm { display: inline-flex; margin: 0; justify-content: flex-start; }
.ai-thumbs.sm img { width: 40px; height: 40px; cursor: default; }

/* Werkzeug-Zeilen */
.ai-tool {
  align-self: stretch;
  border: 2px solid var(--border); border-left: 4px solid var(--accent);
  background: var(--surface-2);
  font-size: .8rem;
}
.ai-tool.ok.wrote { border-left-color: var(--ok); }
.ai-tool.err { border-left-color: var(--danger); }
.ai-tool.deny { border-left-color: var(--muted); opacity: .8; }
.ai-tool.amb { border-left-style: dashed; border-left-color: var(--accent); }
.ai-tool summary {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; cursor: pointer; list-style: none; user-select: none;
}
.ai-tool summary::-webkit-details-marker { display: none; }
.ai-tool summary::before { content: '▸'; color: var(--muted); font-size: .7rem; }
.ai-tool[open] summary::before { content: '▾'; }
.ai-tl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-ts { flex: none; font-weight: 700; }
.ai-tool.ok .ai-ts { color: var(--ok); }
.ai-tool.err .ai-ts { color: var(--danger); }
.ai-chip-ok {
  flex: none; padding: 1px 6px;
  border: 2px solid var(--line); background: var(--ok); color: #fff;
  font-family: var(--px); font-size: .5rem; font-weight: 700;
  animation: ai-stamp .3s steps(3, end);
}
@keyframes ai-stamp { 0% { transform: scale(1.6); opacity: 0; } 60% { transform: scale(.9); opacity: 1; } }
.ai-tres { padding: 4px 10px 8px 22px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; color: var(--muted); }
.ai-tres pre {
  align-self: stretch; margin: 0; max-height: 220px; overflow: auto;
  padding: 6px; background: var(--surface); border: 1px solid var(--border);
  font-family: var(--mono); font-size: .7rem; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text);
}

/* Karten (Einrichtung, Bestätigung, Fehler) */
.ai-card {
  align-self: stretch;
  background: var(--surface);
  border: 2px solid var(--line);
  box-shadow: 4px 4px 0 var(--shadow-c);
  padding: 12px;
  font-size: .88rem; line-height: 1.45;
  animation: pop .15s steps(3, end);
}
.ai-card h3 { color: var(--text); text-transform: none; font-size: .8rem; margin: 4px 0 8px; }
.ai-card p { margin: 0 0 8px; }
.ai-card ol, .ai-card ul { margin: 0 0 10px; padding-left: 1.3em; }
.ai-card code { font-family: var(--mono); font-size: .85em; background: var(--surface-2); padding: 0 4px; }
.ai-cbtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ai-cbtns .btn { flex: 1 1 auto; padding: 8px 10px; font-size: .68rem; }

.ai-setup { text-align: left; margin-top: 8px; }
.ai-wbig { font-size: 2.2rem; line-height: 1; margin-bottom: 6px; }
.ai-trouble { margin-top: 12px; border-top: 2px dashed var(--border); padding-top: 8px; font-size: .82rem; }
.ai-trouble summary { cursor: pointer; font-family: var(--px); font-size: .6rem; font-weight: 700; color: var(--muted); }
.ai-trouble ul { margin-top: 8px; }
.ai-trouble li { margin-bottom: 6px; }

.ai-confirm { border: 3px solid var(--accent); box-shadow: 4px 4px 0 var(--shadow-c); }
.ai-confirm.danger { border-color: var(--danger); }
.ai-ch { font-family: var(--px); font-size: .68rem; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.ai-confirm.danger .ai-ch { color: var(--danger); }
.ai-cl { font-weight: 700; margin-bottom: 8px; }
.ai-kvs { display: flex; flex-direction: column; gap: 3px; border-top: 2px solid var(--border); padding-top: 6px; }
.ai-kv { display: grid; grid-template-columns: minmax(78px, 30%) 1fr; gap: 8px; font-size: .84rem; }
.ai-kv > span:first-child { color: var(--muted); font-family: var(--px); font-size: .55rem; font-weight: 700; padding-top: 3px; }
.ai-kv > span:last-child { overflow-wrap: anywhere; }
.ai-pre { white-space: pre-wrap; }
.ai-sw { display: inline-block; width: 12px; height: 12px; border: 1px solid var(--line); vertical-align: -1px; }
.ai-noask {
  display: flex; align-items: center; gap: 8px; margin: 10px 0 0;
  font-family: var(--font); font-weight: 400; font-size: .8rem; color: var(--muted);
}
.ai-noask input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.ai-cnote { margin-top: 8px; font-size: .78rem; color: var(--muted); }

.ai-errc { border-color: var(--danger); }
.ai-errt { font-weight: 600; overflow-wrap: anywhere; }
.ai-errh { margin-top: 6px; font-size: .8rem; color: var(--muted); }
/* Nur der jüngste Fehler bietet „Nochmal" an */
.ai-errc:has(~ .ai-msg, ~ .ai-errc, ~ .ai-tool, ~ .ai-note) .ai-retry { display: none; }
.ai-note {
  align-self: center; padding: 2px 10px;
  font-family: var(--px); font-size: .55rem; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--border);
}

/* Leerer Chat */
.ai-welcome { margin: auto 0 0; padding: 14px 4px 4px; text-align: center; color: var(--text); font-size: .9rem; line-height: 1.5; }
.ai-welcome p { margin: 0 0 8px; }
.ai-wsub { color: var(--muted); font-size: .8rem; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-bottom: 4px; }
.ai-chip {
  padding: 7px 10px;
  border: 2px solid var(--line); background: var(--surface);
  box-shadow: 3px 3px 0 var(--shadow-c);
  font-family: var(--px); font-size: .58rem; font-weight: 700; color: var(--text);
  cursor: pointer; text-align: left;
}
.ai-chip:hover { background: var(--accent-soft); border-color: var(--accent); }
.ai-chip:active { transform: translate(3px, 3px); box-shadow: none; }

/* ============ Fortschritt ============ */
.ai-run {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 7px 8px 7px var(--ai-pad);
  border-top: 2px solid var(--line);
  background: var(--accent-soft);
  font-size: .8rem;
}
.ai-run-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-run-s { flex: none; font-family: var(--px); font-size: .55rem; color: var(--muted); min-width: 3.5em; text-align: right; }
.ai-stop { flex: none; padding: 5px 10px; font-size: .6rem; color: var(--danger); }
/* Pixel-Ladeanzeige: drei Blöcke, die reihum aufleuchten */
.ai-pix { flex: none; display: inline-flex; gap: 3px; }
.ai-pix i { width: 7px; height: 7px; background: var(--accent); border: 1px solid var(--line); animation: ai-blink 1.05s steps(1, end) infinite; opacity: .25; }
.ai-pix i:nth-child(2) { animation-delay: .35s; }
.ai-pix i:nth-child(3) { animation-delay: .7s; }
@keyframes ai-blink { 0% { opacity: 1; } 33% { opacity: .25; } }

/* ============ Eingabe ============ */
.ai-compose {
  flex: none; position: relative;
  padding: 8px var(--ai-pad) 8px;
  border-top: 2px solid var(--line);
  background: var(--surface);
}
.ai-side.ai-unready .ai-compose { display: none; }
.ai-inrow { display: flex; align-items: flex-end; gap: 8px; }
.ai-input {
  flex: 1; min-width: 0;
  resize: none; max-height: 180px; min-height: 42px; height: 42px;
  overflow-y: hidden;
  padding: 9px 10px; line-height: 1.35;
  font-size: .95rem;
}
.ai-cam, .ai-send { flex: none; height: 42px; min-width: 42px; padding: 0 10px; font-size: 1rem; }
.ai-input.scroll { overflow-y: auto; }
.ai-input::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-send:disabled { opacity: .6; cursor: wait; }
.ai-hint { margin-top: 5px; font-family: var(--px); font-size: .48rem; color: var(--muted); }
.ai-atts { display: none; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.ai-atts.has { display: flex; }
.ai-att { position: relative; width: 58px; height: 58px; border: 2px solid var(--line); box-shadow: 2px 2px 0 var(--shadow-c); background: var(--surface-2); }
.ai-att img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ai-att.up img { opacity: .45; }
.ai-att.err { border-color: var(--danger); }
.ai-att-s { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; pointer-events: none; }
.ai-att.up .ai-att-s { animation: ai-blink 1s steps(1, end) infinite; }
.ai-att button {
  position: absolute; top: -8px; right: -8px;
  width: 20px; height: 20px; padding: 0;
  border: 2px solid var(--line); background: var(--surface); color: var(--text);
  font-size: .6rem; line-height: 1; cursor: pointer;
}
.ai-att button:hover { background: var(--danger); color: #fff; }

/* Drag & Drop */
.ai-drop {
  position: absolute; inset: 0; z-index: 4;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent-soft) 88%, transparent);
  border: 3px dashed var(--accent);
  font-family: var(--px); font-size: .8rem; font-weight: 700; color: var(--text);
  pointer-events: none;
}

/* ============ Topbar-Knopf 🤖 ============ */
#ai-btn.ai-on { background: var(--accent-soft); border-color: var(--accent); }
#ai-btn { position: relative; }
#ai-btn.ai-busy { animation: ai-busy 1s steps(2, end) infinite; }
@keyframes ai-busy { 50% { border-color: var(--accent); background: var(--accent-soft); } }
#ai-btn.ai-ping::after, #ai-btn.ai-ask::after {
  content: ''; position: absolute; top: -5px; right: -5px;
  width: 10px; height: 10px;
  background: var(--accent); border: 2px solid var(--line);
}
#ai-btn.ai-ask::after { background: var(--danger); animation: ai-blink 1s steps(1, end) infinite; }

/* ============ KI-Einstellungen (Modals aus ai.js) ============ */
.ai-help { color: var(--muted); font-size: .85rem; line-height: 1.5; margin: 0 0 12px; }
.ai-err { color: var(--danger); }
.ai-test:not(:empty) {
  margin: 10px 0 0; padding: 8px 10px;
  border: 2px dashed var(--border); background: var(--surface-2);
  font-size: .82rem; line-height: 1.45; overflow-wrap: anywhere;
}
#ai-form input[type=url], #ai-form input[type=number],
#ais-form input[type=url], #ais-form input[type=number],
.modal input.ai-copy {
  width: 100%;
  border: 2px solid var(--line); background: var(--surface);
  border-radius: 0; padding: 10px 12px; outline: none;
}
#ai-form input[type=url]:focus, #ai-form input[type=number]:focus,
#ais-form input[type=url]:focus, #ais-form input[type=number]:focus {
  border-color: var(--accent); box-shadow: 3px 3px 0 var(--accent-soft);
}
.ai-more, .ai-task {
  margin: 4px 0 12px; border: 2px solid var(--border); background: var(--surface-2); padding: 0 10px;
}
.ai-more > summary, .ai-task > summary {
  cursor: pointer; padding: 9px 0; list-style: none;
  font-family: var(--px); font-size: .62rem; font-weight: 700; color: var(--muted);
}
.ai-more > summary::-webkit-details-marker, .ai-task > summary::-webkit-details-marker { display: none; }
.ai-more > summary::before, .ai-task > summary::before { content: '▸ '; }
.ai-more[open] > summary::before, .ai-task[open] > summary::before { content: '▾ '; }
.ai-task > summary small { font-family: var(--font); font-weight: 400; margin-left: 6px; }
.ai-task textarea { font-family: var(--mono); font-size: .78rem; margin-bottom: 8px; }
.ai-task .btn { margin-bottom: 8px; }
label.chk {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font); font-weight: 400; font-size: .88rem; color: var(--text);
}
label.chk input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.ai-snippet { font-family: var(--mono); font-size: .75rem; }
.ai-tokens { margin: 8px 0; }

/* Kosyn-Bridge im Einstellungsdialog */
.ai-bridges { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.ai-bridge {
  display: flex; align-items: center; gap: 8px; margin: 0;
  padding: 7px 8px; border: 2px solid var(--border); background: var(--surface-2); cursor: pointer;
  font-weight: 400;
}
.ai-bridge.on { border-color: var(--line); }
.ai-bridge:has(input:checked) { border-color: var(--accent); box-shadow: 3px 3px 0 var(--shadow-c); }
.ai-bridge input { width: auto; margin: 0; }
.ai-bdot { flex: none; font-size: .8rem; }
.ai-bname { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ai-bname b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-bname small { color: var(--muted); font-family: var(--font); font-weight: 400; font-size: .76rem; line-height: 1.35; }
.ai-bridge .btn { flex: none; padding: 3px 7px; }
.ai-bsetup { border: 2px dashed var(--line); padding: 10px 12px; margin: 8px 0; }
.ai-steps { margin: 6px 0; padding-left: 1.3em; }
.ai-steps li { margin: 0 0 8px; }
.ai-steps .btn { display: inline-block; padding: 4px 9px; font-size: .62rem; }
.ai-steps code { font-family: var(--mono); font-size: .8rem; background: var(--surface-2); border: 1px solid var(--border); padding: 0 4px; }

/* Bridge-Liste: Gruppen + Verwaltung einer eigenen Bridge-App (⚙️ an der Zeile) */
.ai-bitem { display: flex; flex-direction: column; }
.ai-bgrp { font-family: var(--px); font-size: .58rem; font-weight: 700; color: var(--muted); margin: 6px 0 0; }
.ai-bman {
  display: flex; flex-direction: column; gap: 8px;
  border: 2px solid var(--line); border-top: 0; background: var(--surface); padding: 10px;
}
.ai-bst { padding: 8px 10px; border: 2px solid var(--line); background: var(--surface-2); font-size: .88rem; line-height: 1.4; }
.ai-bst.ok { border-color: var(--ok); }
.ai-bst.warn { border-color: var(--warn, #e8a33a); }
.ai-bst.off { border-style: dashed; color: var(--muted); }
.ai-binfo { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: .84rem; }
.ai-binfo dt { font-family: var(--px); font-size: .56rem; font-weight: 700; color: var(--muted); padding-top: 3px; }
.ai-binfo dd { margin: 0; overflow-wrap: anywhere; }
.ai-binfo small { color: var(--muted); font-family: var(--mono); font-size: .72rem; }
.ai-bup { color: var(--accent); }
.ai-bacts { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-bacts .btn { padding: 6px 9px; font-size: .62rem; }
.ai-bpend { margin: 0; }
.ai-bpend:empty { display: none; }
.ai-bman .ai-more { margin: 0; }
.ai-bcfg { display: flex; flex-direction: column; gap: 8px; padding: 0 0 10px; }
.ai-bcfg label { margin: 0; }
.ai-bcfg .btn { align-self: flex-start; }
.ai-bcfg .ai-help { margin: 0; }
.ai-bcfg .ai-help:empty { display: none; }
.ai-blog {
  margin: 0 0 10px; max-height: 220px; overflow: auto;
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--mono); font-size: .72rem; line-height: 1.45;
  background: var(--bg); color: var(--text); border: 2px solid var(--border); padding: 8px;
}

/* Einrichtung: großer Download-Knopf fürs erkannte System, Terminal-Einzeiler für Linux/macOS */
.ai-bh { margin: 0 0 10px; }
.ai-bnote { border: 2px solid var(--line); background: var(--surface); padding: 8px 10px; font-size: .85rem; line-height: 1.45; margin: 0 0 10px; }
.ai-bmain { margin: 12px 0 6px; }
.ai-bsetup code {
  font-family: var(--mono); font-size: .8rem; background: var(--surface-2);
  border: 1px solid var(--border); padding: 0 4px; overflow-wrap: anywhere;
}
.ai-bsetup .btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn.ai-dlbig { display: block; width: 100%; font-size: .82rem; padding: 15px 16px; }
.ai-dlmeta { display: block; color: var(--muted); font-size: .75rem; margin: 6px 0 4px; }
.ai-dlalt { margin: 4px 0 8px; }
.ai-dlos { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 8px; }
.ai-dlos-l { font-size: .78rem; color: var(--muted); margin-right: 2px; }
.btn.ai-os { padding: 5px 8px; font-size: .56rem; box-shadow: 2px 2px 0 var(--shadow-c); }
.ai-os small { font-family: var(--font); font-weight: 400; font-size: .7rem; }
.btn.ai-os.on { border-color: var(--accent); background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -4px; }
.ai-cmd {
  display: flex; gap: 8px; align-items: center;
  border: 2px solid var(--line); background: var(--bg); box-shadow: 3px 3px 0 var(--shadow-c); padding: 8px 8px 8px 10px;
}
.ai-bsetup .ai-cmd code {
  flex: 1; min-width: 0; background: none; border: 0; padding: 0;
  font-size: .8rem; line-height: 1.45; color: var(--text); user-select: all;
}
.ai-cmd .btn { flex: none; }
.ai-bwait { font-size: .85rem; line-height: 1.45; margin: 10px 0 0; padding: 8px 10px; border: 2px dashed var(--border); }
.ai-bwait i {
  display: inline-block; width: 8px; height: 8px; margin-right: 4px; vertical-align: middle;
  background: var(--accent); border: 1px solid var(--line); animation: ai-blink 1.05s steps(1, end) infinite;
}
.ai-bwait.ok { border-style: solid; border-color: var(--ok); }
.ai-quick { border: 2px solid var(--accent); background: var(--accent-soft); box-shadow: 3px 3px 0 var(--shadow-c); padding: 10px 12px; margin: 8px 0; }
.ai-quick p { margin: 0 0 10px; font-size: .88rem; line-height: 1.45; }
.ai-quick .btn { width: 100%; }
@media (max-width: 520px) {
  .ai-cmd { flex-direction: column; align-items: stretch; }
  .ai-binfo { grid-template-columns: minmax(0, 1fr); }
  .ai-binfo dd { margin-bottom: 4px; }
}

/* Gedächtnis (⚙️ → 🧠) */
.ai-mems { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; max-height: 46vh; overflow: auto; }
.ai-mem { display: flex; align-items: flex-start; gap: 8px; padding: 7px 8px; border: 2px solid var(--border); background: var(--surface-2); }
.ai-mscope { flex: none; }
.ai-mtext { flex: 1; min-width: 0; font-size: .9rem; overflow-wrap: anywhere; }
.ai-mtext small { color: var(--muted); }
.ai-mtext textarea { width: 100%; }
.ai-mbtns { flex: none; display: flex; gap: 2px; }
.ai-mbtns .btn { padding: 2px 6px; }
.ai-memform textarea { width: 100%; }

/* Recherche nicht verfügbar (KI-Import + Sidebar) */
.ai-rbanner {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 8px 0; padding: 8px 10px; font-size: .85rem;
  border: 2px solid #e8a33d; background: var(--surface-2); box-shadow: 3px 3px 0 var(--shadow-c);
}
.ai-rbanner span { flex: 1 1 220px; }
.ai-rbanner .btn { padding: 4px 9px; font-size: .6rem; }
.ai-rbar:empty { display: none; }
.ai-rbar .ai-rbanner { margin: 6px 8px; }
/* 📡 Rückfall auf den Always-On-Host (ai.js routeBanner): unauffällig, aber sichtbar */
.ai-route {
  margin: 6px 0; padding: 4px 8px; font-size: .78rem; color: var(--muted);
  border: 2px dashed var(--line); background: var(--surface-2);
}
.ai-rbar .ai-route { margin: 6px 8px; }
/* ⏳ Warteschlange in der Kopfzeile (ai.js paintQueueChip, Stil von .jp-chip) */
.aiq-chip { cursor: default; }
.aiq-chip:active { transform: none; box-shadow: 2px 2px 0 var(--shadow-c); }

/* ============ ⚙️ KI-Einstellungen: Reiter (openSettings in ai.js) ============
   Handy < 700 px:    einspaltig, fünf aufklappbare Abschnitte (<details class="ais-sec">)
   Tablet 700–1099:   breites Modal, Reiter oben, Inhalt scrollt für sich, Fußleiste fest
   Desktop ≥ 1100:    min(1280px, 96vw), Reiter links, Inhalt in Spalten
   Nur dieses Modal (:has(> #ai-form.ais)) — andere Modals bleiben schmal. Keine Gradients. */
.ais-nav { display: none; }
.ais-sec { margin: 0 0 10px; border: 2px solid var(--line); background: var(--surface); }
.ais-sh {
  cursor: pointer; list-style: none; padding: 11px 12px;
  font-family: var(--px); font-size: .66rem; font-weight: 700; color: var(--text);
  background: var(--surface-2); user-select: none;
}
.ais-sh::-webkit-details-marker { display: none; }
.ais-sh::before { content: '▸ '; color: var(--muted); }
.ais-sec[open] > .ais-sh { border-bottom: 2px solid var(--border); }
.ais-sec[open] > .ais-sh::before { content: '▾ '; }
.ais-in { padding: 12px 12px 2px; }
.ais-box { margin: 0 0 12px; }
.ais-box > label:last-child, .ais-box > .ai-help:last-child { margin-bottom: 0; }
.ais-bh { font-family: var(--px); font-size: .6rem; font-weight: 700; color: var(--muted); text-transform: uppercase; margin: 0 0 10px; }
.ais-acts { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 0; }
.ais-acts .btn { flex: 1 1 auto; }
.ais-profmini { font-size: .82rem; line-height: 1.45; margin: 0 0 12px; padding: 6px 8px; border: 2px dashed var(--border); background: var(--surface-2); }
.ais-profmini:empty { display: none; }
/* Modell-Auswahl (ai.js paintModelSel, js/modellist.js): Dropdown + Textfeld bei „✏️ Anderes"/offline */
#ai-modelsel + #ai-model { margin-top: 6px; }
.ai-modelnote { display: block; margin-top: 4px; font-family: var(--font); font-weight: 400; font-size: .8rem; line-height: 1.4; color: var(--muted); text-transform: none; }
/* ⏱️ Auto-Laden/-Entladen unter der Engine-Karte (ai.js bauto) */
.ai-engwrap { display: flex; flex-direction: column; gap: 8px; }
.ai-engwrap > div:empty { display: none; }
.ai-engauto label { margin: 0; }
.ai-engauto .ai-eng-idle { font-family: var(--font); font-size: .85rem; font-weight: 400; color: var(--text); line-height: 1.9; }
#ai-form .ai-engauto .ai-eng-idle input[type=number] { display: inline-block; width: 5.5em; margin: 0 4px; padding: 3px 6px; }
.ai-engauto .ai-eng-idle small { color: var(--muted); }
.ais-link {
  border: 0; background: none; padding: 0 2px; cursor: pointer;
  font-family: var(--font); font-size: .8rem; font-weight: 700; color: var(--accent); text-decoration: underline;
}
.ais-i { font-family: var(--font); font-weight: 700; color: var(--accent); cursor: help; }
.ais-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; }
.ais-rowt { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ais-rowt b { font-size: .9rem; }
.ais-rowt small { color: var(--muted); font-size: .8rem; line-height: 1.4; }
.ais-row .btn { flex: none; }
.ai-bmans { display: flex; flex-direction: column; gap: 10px; }
.ai-bmhead { cursor: default; }
.ai-bmhead [data-bman][aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); }
.ai-b-nobridge { border: 2px dashed var(--border); padding: 8px 10px; }
.ais-foot {
  position: sticky; bottom: -20px; z-index: 2;
  background: var(--surface); padding: 10px 0; border-top: 2px solid var(--border);
}
/* Werte je Aufgabe */
.ais-ttw { overflow-x: auto; margin: 0 0 12px; }
.ais-tt { width: 100%; border-collapse: collapse; font-size: .8rem; }
.ais-tt caption { text-align: left; font-family: var(--px); font-size: .56rem; font-weight: 700; color: var(--muted); padding: 0 0 6px; }
.ais-tt caption small { font-family: var(--font); font-weight: 400; font-size: .72rem; text-transform: none; }
.ais-tt th, .ais-tt td { border: 1px solid var(--border); padding: 4px 7px; text-align: left; white-space: nowrap; }
.ais-tt thead th { font-family: var(--px); font-size: .52rem; font-weight: 700; color: var(--muted); background: var(--surface-2); }
.ais-tt tbody th { font-weight: 700; color: var(--text); }
.ais-tt td { font-variant-numeric: tabular-nums; }
.ais-na { color: var(--muted); }
/* 🔬 Wirksame Werte je Aufgabe (ai.js mountEffPanel): Zeile = Raster Name | Wert | Herkunft ↺, Hinweise darunter.
   Gruppen einklappbar; Warnung = Randstreifen + Kasten, eigener Wert = Akzent-Hintergrund. Keine Gradients. */
.ais-eff { flex: 1 1 100%; }
.ais-effhead { margin: 0 0 8px; font-size: .88rem; line-height: 1.45; overflow-wrap: anywhere; }
.ais-effhead code { font-family: var(--mono); font-size: .82rem; }
.ais-effhead small { color: var(--muted); }
.ais-efftabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
.ais-efftab {
  border: 2px solid var(--border); background: var(--surface-2); color: var(--muted); cursor: pointer;
  padding: 5px 9px; font-family: var(--px); font-size: .56rem; font-weight: 700;
}
.ais-efftab:hover { color: var(--text); border-color: var(--line); }
.ais-efftab.on { border-color: var(--line); background: var(--accent-soft); color: var(--text); box-shadow: 2px 2px 0 var(--shadow-c); }
.ais-efftab:focus-visible, .ais-erl:focus-visible, .ais-rst:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ais-effnote { margin: 0 0 8px; font-size: .78rem; }
.ais-effg { border: 2px solid var(--border); margin: 0 0 6px; background: var(--surface); }
.ais-effg > summary {
  cursor: pointer; list-style: none; padding: 6px 9px; background: var(--surface-2);
  font-family: var(--px); font-size: .58rem; font-weight: 700; color: var(--text);
}
.ais-effg > summary::-webkit-details-marker { display: none; }
.ais-effg > summary::before { content: '▸ '; color: var(--muted); }
.ais-effg[open] > summary::before { content: '▾ '; }
.ais-effw, .ais-effo { font-family: var(--font); font-size: .78rem; margin-left: 6px; }
.ais-effw { color: var(--warn, #e8a33d); }
.ais-effo { color: var(--accent); }
.ais-er {
  display: grid; grid-template-columns: minmax(8em, 13em) minmax(0, 1fr) auto; align-items: center; gap: 2px 8px;
  padding: 4px 9px; border-top: 1px solid var(--border);
}
.ais-er:first-child { border-top: 0; }
.ais-er.own { background: var(--accent-soft); }
.ais-er.warn { box-shadow: inset 3px 0 0 var(--warn, #e8a33d); }
.ais-erl {
  border: 0; background: none; padding: 0; text-align: left; cursor: help;
  font-family: var(--font); font-size: .82rem; font-weight: 700; color: var(--text);
}
.ais-erv { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; min-width: 0; font-size: .82rem; }
#ai-form .ais-erv input[type=number], #ai-form .ais-erv select { width: auto; max-width: 100%; min-width: 0; margin: 0; padding: 3px 6px; font-size: .82rem; }
#ai-form .ais-erv input[type=number] { width: 6.5em; }
.ais-erx { font-variant-numeric: tabular-nums; }
.ais-erm { color: var(--muted); font-size: .74rem; }
.ais-tg { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-family: var(--font); font-size: .82rem; font-weight: 400; color: var(--text); }
.ais-tg input { width: auto; margin: 0; }
.ais-erb { display: flex; align-items: center; gap: 4px; justify-self: end; }
.ais-src { font-size: .66rem; padding: 1px 5px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; background: var(--surface); }
.ais-src.s-preset { border-color: var(--line); color: var(--text); }
.ais-src.s-cfg, .ais-src.s-tune { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.ais-rst { border: 2px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; padding: 0 5px; font-size: .78rem; line-height: 1.3; }
.ais-rst:hover { border-color: var(--accent); }
.ais-erinfo { display: none; grid-column: 1 / -1; color: var(--muted); font-size: .76rem; line-height: 1.4; }
.ais-er.showinfo .ais-erinfo { display: block; }
.ais-hint { grid-column: 1 / -1; margin: 1px 0; font-size: .76rem; line-height: 1.4; }
.ais-hint.warn { color: var(--text); padding: 2px 6px; border: 1px solid var(--warn, #e8a33d); background: var(--surface-2); }
.ais-hint.warn b { color: var(--warn, #e8a33d); }
.ais-hint.info { color: var(--muted); }
.ais-hint.info b { color: var(--accent); }
.ais-hint small { font-size: .7rem; color: var(--muted); }
.ais-effall { margin: 2px 0 8px; font-size: .56rem; }
.ais-effp { border: 2px dashed var(--border); padding: 6px 9px; margin: 8px 0 0; }
.ais-effp > summary, .ais-effp2 > summary { cursor: pointer; font-weight: 700; font-size: .84rem; }
.ais-effp summary small { font-weight: 400; color: var(--muted); }
.ais-effp2 { margin: 6px 0 0; }
.ais-pbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 4px; }
.ais-pbar small { color: var(--muted); font-size: .74rem; }
.ais-pbar .btn, .ais-effflow .btn { padding: 3px 8px; font-size: .55rem; flex: none; }
.ais-pre {
  margin: 0; max-height: 280px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--mono); font-size: .74rem; line-height: 1.45; padding: 8px;
  border: 2px solid var(--border); background: var(--surface-2); color: var(--text);
}
.ais-effflow { margin: 8px 0 2px; font-size: .8rem; }
@media (max-width: 520px) {
  .ais-er { grid-template-columns: minmax(0, 1fr) auto; }
  .ais-erv { grid-column: 1 / -1; grid-row: 2; }
}

@media (min-width: 700px) {
  .modal:has(> #ai-form.ais) {
    max-width: min(96vw, 1000px);
    height: min(92dvh, 900px); max-height: 94dvh;
    display: flex; flex-direction: column; overflow: hidden; padding: 0;
  }
  .ais-top {
    flex: none; display: flex; align-items: baseline; gap: 14px;
    padding: 12px 18px 10px; background: var(--surface-2); border-bottom: 3px solid var(--line);
  }
  .ais-top h2 { margin: 0; flex: none; }
  .ais-top .ai-help { margin: 0; flex: 1; min-width: 0; }
  .ais {
    flex: 1 1 auto; min-height: 0;
    display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .ais-nav {
    display: flex; flex-wrap: wrap; gap: 4px 6px;
    padding: 10px 18px 0; border-bottom: 2px solid var(--line); background: var(--surface-2);
  }
  .ais-tab {
    border: 2px solid var(--border); border-bottom: 0; margin-bottom: -2px;
    background: var(--surface-2); color: var(--muted); cursor: pointer;
    padding: 8px 12px; font-family: var(--px); font-size: .6rem; font-weight: 700; text-align: left;
  }
  .ais-tab:hover { color: var(--text); border-color: var(--line); }
  .ais-tab.on { background: var(--surface); color: var(--text); border-color: var(--line); border-bottom: 2px solid var(--surface); }
  .ais-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
  .ais-body { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 16px 18px; }
  .ais-sec { display: none; margin: 0; border: 0; background: none; }
  .ais-sec.on { display: block; }
  .ais-sh { display: none; }
  .ais-in { padding: 0; }
  .ais-cols { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; }
  .ais-col { flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
  .ais-box { margin: 0; padding: 12px 14px; border: 2px solid var(--line); background: var(--surface); box-shadow: 3px 3px 0 var(--shadow-c); }
  .ais-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
  .ais-in > .ais-box + #ai-hindsight .hsx { margin-top: 16px; }
  .ais-g2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
  .ais-g2 > label { display: flex; flex-direction: column; justify-content: flex-end; }
  .modal .grid-2.ais-g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2.ais-g3 > label { display: flex; flex-direction: column; justify-content: flex-end; }
  .ais-foot {
    position: static; margin: 0; padding: 10px 18px;
    background: var(--surface-2); border-top: 3px solid var(--line); justify-content: flex-end;
  }
  .ais-foot .btn { flex: 0 0 auto; min-width: 150px; }
  /* lange Hilfetexte einzeilig mit ⓘ — Klick klappt auf, Tooltip zeigt alles */
  .ais-tip { cursor: pointer; }
  .ais-tip::before { content: 'ⓘ '; color: var(--accent); font-weight: 700; }
  .ais-tip:not(.show) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ais-tip:not(.show) br { display: none; }
  .ai-bman .ai-blog { max-height: 260px; }
}

@media (min-width: 1100px) {
  .modal:has(> #ai-form.ais) { max-width: min(1280px, 96vw); }
  .ais { grid-template-columns: 240px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .ais-nav {
    grid-row: 1; grid-column: 1; flex-direction: column; flex-wrap: nowrap; gap: 6px;
    padding: 16px 0 16px 14px; border-bottom: 0; border-right: 2px solid var(--line);
    /* sichtbar statt scrollbar: der aktive Reiter ragt 2 px über die Trennlinie (margin-right -2px), das gab einen
       horizontalen Scrollbalken (Rauchtest B8); vier Reiter passen immer */
    overflow: visible;
  }
  .ais-tab { border: 2px solid var(--border); border-right: 0; margin: 0 -2px 0 0; padding: 11px 12px; font-size: .62rem; }
  .ais-tab.on { border-color: var(--line); border-right: 2px solid var(--surface); box-shadow: -3px 3px 0 var(--shadow-c); }
  .ais-body { grid-row: 1; grid-column: 2; padding: 18px 22px; }
  .ais-foot { grid-column: 1 / -1; }
  /* Engine-Reiter: Verwaltung links, Engine-Karte rechts */
  .ai-bmitem .ai-bman { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 0 14px; align-items: start; }
  .ai-bmitem .ai-bman.hidden { display: none; }
  .ai-bmitem .ai-bman > * { grid-column: 1; margin-bottom: 8px; }
  .ai-bmitem .ai-bman > .ai-engwrap { grid-column: 2; grid-row: 1 / span 8; }
}
@media (max-width: 699px) {
  .ais-tt th, .ais-tt td { padding: 4px 5px; }
}

/* ============ 🤖 Modell & Verbindung (ai.js openSettings, Logik js/aisetup.js) ============
   Wahl oben (🔌 Eigener Endpunkt | 🤖 Kosyn-Agent), darunter nur der gewählte Weg. Agent: links Reihenfolge + gewählter
   Agent mit Modellen, rechts ⚙️ Voreinstellungen (ab 900 px zweispaltig, Handy untereinander). Keine Gradients. */
.aiw-route { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin: 0 0 14px; }
.aiw-rc {
  display: flex; flex-direction: column; gap: 5px; align-items: flex-start; text-align: left; min-width: 0;
  padding: 11px 12px; cursor: pointer; color: var(--text);
  border: 2px solid var(--border); background: var(--surface-2); box-shadow: 3px 3px 0 var(--shadow-c);
}
.aiw-rc:hover { border-color: var(--line); }
.aiw-rc[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 3px 3px 0 var(--accent); }
.aiw-rc:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.aiw-rc:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow-c); }
.aiw-rt { font-family: var(--px); font-size: .7rem; font-weight: 700; }
.aiw-rc[aria-checked="true"] .aiw-rt::after { content: ' ✓'; color: var(--accent); }
.aiw-rc small { font-size: .78rem; line-height: 1.4; color: var(--muted); }
.aiw-seg { display: inline-flex; flex-wrap: wrap; gap: 0; margin: 0 0 10px; border: 2px solid var(--line); }
.aiw-seg.hidden { display: none; }
.aiw-seg button {
  border: 0; background: var(--surface); color: var(--muted); cursor: pointer; padding: 7px 11px;
  font-family: var(--font); font-size: .82rem; font-weight: 700;
}
.aiw-seg button + button { border-left: 2px solid var(--line); }
.aiw-seg button[aria-checked="true"] { background: var(--accent); color: #fff; }
.aiw-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.aiw-lh { font-weight: 400; }
.aiw-key { display: flex; gap: 6px; align-items: stretch; }
.aiw-key input { flex: 1 1 auto; min-width: 0; }
.aiw-key .btn { flex: none; padding: 4px 9px; font-size: .56rem; }
.aiw-eps { margin: 0 0 10px; }
.aiw-epacts { margin: 10px 0 0; }
.aiw-note { margin: 10px 0 0; padding: 7px 10px; font-size: .82rem; line-height: 1.45; border: 2px dashed var(--border); background: var(--surface-2); }
.aiw-vision { margin: 12px 0 0; }
.aiw-vision label { margin: 6px 0 0; }
.aiw-cols { display: flex; flex-direction: column; gap: 12px; }
.aiw-left, .aiw-right { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.aiw-bh { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 6px; }
.aiw-bh .ais-bh { margin: 0; }
.aiw-wiz { flex: none; padding: 4px 9px; font-size: .56rem; }
#ai-bnew { margin-top: 8px; }
/* Agents in Reihenfolge */
.aia-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 0; }
.aia-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px 8px;
  padding: 6px 8px; border: 2px solid var(--border); background: var(--surface);
}
.aia-row.sel { border-color: var(--accent); box-shadow: 3px 3px 0 var(--shadow-c); }
.aia-row.off { opacity: .62; }
.aia-row.act { border-left: 6px solid var(--ok, #3dd68c); }
.aia-row.drag { opacity: .4; }
.aia-n {
  width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; cursor: grab;
  font-family: var(--px); font-size: .56rem; font-weight: 700; color: var(--text); border: 2px solid var(--line); background: var(--surface-2);
}
.aia-main {
  display: flex; align-items: flex-start; gap: 7px; min-width: 0; text-align: left; cursor: pointer;
  border: 0; background: none; padding: 2px 0; color: var(--text); font: inherit;
}
.aia-main:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.aia-main .ai-bname { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.aia-main .ai-bname small { color: var(--muted); font-size: .76rem; line-height: 1.35; overflow-wrap: anywhere; }
.aia-main .ai-bname b { white-space: normal; overflow-wrap: anywhere; }   /* „🆓 Kostenlose Alpha-KI · <Rechner>" umbrechen statt überlaufen */
.aia-act { font-family: var(--px); font-size: .46rem; font-weight: 700; color: var(--ok, #3dd68c); margin-left: 4px; white-space: nowrap; }
.aia-ctl { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.aia-ctl .btn { padding: 3px 7px; font-size: .62rem; }
.aia-mvs { display: inline-flex; gap: 2px; }
.aia-mv { min-width: 28px; }
.aia-on { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-family: var(--font); font-size: .76rem; font-weight: 400; text-transform: none; color: var(--text); cursor: pointer; }
.aia-on input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
/* gewählter Agent */
.aiw-agh { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 6px; }
.aiw-agt { font-family: var(--px); font-size: .66rem; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.aiw-agh .btn { flex: none; padding: 4px 9px; font-size: .56rem; }
.aiw-agent .ai-test:empty { display: none; }
.aiw-agent > div:empty { display: none; }
.aie { margin: 0 0 8px; padding: 7px 9px; border: 2px solid var(--line); background: var(--surface-2); font-size: .8rem; }
.aie.off { border-style: dashed; }
.aie.lan { border-color: var(--warn, #e8a33d); }
.aie-h { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0 0 4px; }
.aie-h small { color: var(--muted); flex: 1 1 200px; line-height: 1.4; }
.aie-h .btn { flex: none; padding: 3px 8px; font-size: .52rem; }
.aie-note { margin: 0 0 8px; }
.aie-more { margin: 6px 0 0; }
.aie-more .ai-eng-acts { margin-top: 6px; }
.aie-auto { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0 0 8px; padding: 6px 9px; border: 2px dashed var(--border); font-size: .82rem; }
.aie-auto label { margin: 0; }
.aie-auto .ai-help { flex: 1 1 100%; margin: 0; }
/* Modelle des Agents */
.aim-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 10px 0 6px; }
.aim-h .ais-bh { margin: 0; }
.aim-h small { color: var(--muted); font-size: .76rem; text-align: right; }
.aim-list { display: flex; flex-direction: column; gap: 5px; }
.aim-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 5px 7px; border: 2px solid var(--border); background: var(--surface); }
.aim-row.sel { border-color: var(--accent); background: var(--accent-soft); }
.aim-row.std { box-shadow: inset 4px 0 0 var(--ok, #3dd68c); }
.aim-name {
  flex: 1 1 200px; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; text-align: left;
  border: 0; background: none; padding: 2px 0; color: var(--text); font: inherit; font-size: .86rem;
}
button.aim-name { cursor: pointer; }
button.aim-name:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.aim-st { flex: 1 1 100%; color: var(--muted); font-size: .76rem; }
.aim-row.s-loaded .aim-st, .aim-row.s-host .aim-st { color: var(--ok, #3dd68c); font-weight: 700; }
.aim-row.s-error .aim-st { color: var(--warn, #e8a33d); }
.aim-row.s-missing { border-style: dashed; }
.aim-edit { margin-left: auto; font-size: .8rem; opacity: .55; }
.aim-row.sel .aim-edit, button.aim-name:hover .aim-edit { opacity: 1; }
.aim-tag { font-size: .66rem; padding: 0 5px; border: 1px solid var(--border); white-space: nowrap; }
.aim-tag.rec { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.aim-tag.std { border-color: var(--ok, #3dd68c); color: var(--ok, #3dd68c); font-weight: 700; }
.aim-tag.cus { color: var(--muted); }
.aim-acts { display: flex; flex-wrap: wrap; gap: 3px; margin-left: auto; }
.aim-acts .btn { padding: 3px 7px; font-size: .52rem; }
.aim-use { border-color: var(--ok, #3dd68c); }
.aim-busy { font-size: .76rem; color: var(--muted); }
.aim-job { flex: 1 1 100%; }
.aim-empty { margin: 0; }
.aim-manual { margin: 8px 0 0; }
.aim-manual input { margin-top: 6px; }
.aim-links { margin: 8px 0 0; }
.aiw-man { margin: 10px 0 0; }
.aiw-man > summary small { font-weight: 400; color: var(--muted); }
.aiw-man .ai-bman { margin-top: 8px; }
/* ⚙️ Voreinstellungen */
.aip { display: flex; flex-direction: column; gap: 8px; }
.aip-h { display: flex; flex-direction: column; gap: 3px; }
.aip-h b { font-family: var(--px); font-size: .64rem; }
.aip-h small { color: var(--muted); font-size: .78rem; }
.aip-lo { border-color: var(--line); }
.aip-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 12px; }
.aip-checks .mc-lock { display: block; margin: 0; line-height: 1.45; font-family: var(--font); font-weight: 400; text-transform: none; color: var(--text); }
.aip-checks .mc-lock input { vertical-align: middle; margin: 0 6px 0 0; }
#ai-form .aip .mc-loc { width: 90px; flex: none; margin: 0; padding: 3px 6px; font-size: .78rem; }
.aip .mc-lorange { flex: 1 1 120px; max-width: 220px; }
.aip-sels { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.aip-sel { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-family: var(--font); font-size: .8rem; font-weight: 700; text-transform: none; color: var(--text); }
#ai-form .aip-sel select { width: auto; margin: 0; padding: 3px 6px; font-size: .8rem; }
.aip .ais-hint { margin: 0; }
.aip-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.aip-acts .btn { flex: 1 1 auto; }
.aip-note { margin: 0; font-size: .76rem; }
.aip-ro { padding: 8px 10px; border: 2px dashed var(--border); }
.aip-ro p { margin: 6px 0 0; }
@media (max-width: 480px) {
  .aiw-rc { padding: 9px; }
  .aiw-rc small { font-size: .72rem; }
  .aia-row { grid-template-columns: auto minmax(0, 1fr); }
  .aia-ctl { grid-column: 1 / -1; justify-content: flex-start; }
  .aim-actl { display: none; }
  .mc-lol { min-width: 100%; }
}
@media (min-width: 900px) {
  .aiw-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: start; gap: 16px; }
  .aiw-right { position: sticky; top: 0; }
}

/* 🆓 Kostenlose Alpha-KI (ai.js alphaBoxHtml/mountAlpha): Schalter in Einstellungen, Wizard und leeren Zuständen */
.ai-alpha {
  margin: 10px 0; padding: 10px 12px; text-align: left;
  border: 2px dashed var(--accent); background: var(--surface-2); box-shadow: 3px 3px 0 var(--shadow-c);
}
.ai-alpha.on { border-style: solid; border-color: var(--ok, #3dd68c); }
.ai-alpha-sw { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: .95rem; margin: 0 0 6px; }
.ai-alpha-sw input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex: none; }
.ai-alpha .ai-help { margin: 0; font-size: .8rem; }
.ai-alpha-st { margin: 6px 0 0; font-size: .8rem; }
.ais-col > .ai-alpha-slot .ai-alpha { margin-top: 0; }
.lw-alpha .ai-alpha { margin: 0 0 12px; }
/* Datenschutz-Hinweis: eigener Dialog über allem (auch über ⚙️) */
.modal-backdrop.ai-consent-bd { z-index: 130; }
.ai-consent { max-width: 560px; }
.ai-consent-lead { margin: 0 0 8px; font-size: .9rem; }
.ai-consent-list { margin: 0 0 10px; padding-left: 20px; font-size: .88rem; line-height: 1.5; }
.ai-consent-list li { margin: 0 0 6px; }
