/* ══════════════════════════════════════════
   RESET & GRUNDLAYOUT
   ══════════════════════════════════════════ */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f0f4ff;
  background-image:
    radial-gradient(circle at 15% 25%, #ffe8f0 0%, transparent 40%),
    radial-gradient(circle at 85% 75%, #e8f4ff 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, #fff5e6 0%, transparent 50%);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  padding: 16px;
  color: #3a3a5c;
}

/* (e) Textfenster +150px.
   Rechnung: vorher 1000px App − 210px Sidebar = 790px Chat-Spalte.
   Die Sidebar wächst wegen der neuen Anzeigen auf 226px, also
   1166px − 226px = 940px = 790px + 150px. */
.app {
  width: 1166px;
  max-width: 98vw;
  height: calc(100vh - 32px);
  height: calc(100dvh - 32px);
  min-height: 420px;
  background: #ffffff;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    0 4px 24px rgba(100, 120, 200, 0.12),
    0 1px 4px rgba(100, 120, 200, 0.08);
  border: 2px solid #e4e8f4;
}

/* ══════════════════════════════════════════
   TOP BAR – API-Konfiguration + Systemprompt
   ══════════════════════════════════════════ */
.top-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 16px;
  background: #f8f9fe;
  border-bottom: 2px solid #e4e8f4;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.top-bar label {
  font-size: 11px;
  font-weight: 700;
  color: #7a82a6;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.top-bar input,
.top-bar select {
  padding: 7px 12px;
  border-radius: 10px;
  border: 2px solid #e4e8f4;
  background: #ffffff;
  color: #3a3a5c;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.top-bar input:focus,
.top-bar select:focus {
  border-color: #ff9b44;
}

.top-bar input::placeholder {
  color: #b0b8d4;
}

/* Spezifische Breiten für bessere Optik */
#modelSelect { min-width: 260px; }

/* ══════════════════════════════════════════
   POPUPS (Overlay)
   ══════════════════════════════════════════ */
.popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(100, 110, 160, 0.3);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.popup-overlay.visible { display: flex; }

.popup {
  background: #ffffff;
  border-radius: 20px;
  box-shadow:
    0 12px 48px rgba(100, 120, 200, 0.2),
    0 2px 8px rgba(100, 120, 200, 0.1);
  border: 2px solid #e4e8f4;
  width: 520px;
  max-width: 92vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popupIn 0.25s ease-out;
}

@keyframes popupIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .popup { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

.popup-header {
  padding: 16px 20px;
  border-bottom: 2px solid #e4e8f4;
  display: flex;
  align-items: center;
  gap: 10px;
}

.popup-header .popup-icon { font-size: 22px; }
.popup-header h2 {
  font-size: 16px;
  font-weight: 800;
  color: #3a3a5c;
  flex: 1;
}

.popup-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: #f0f2fa;
  color: #7a82a6;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.popup-close:hover {
  background: #ffe4e4;
  color: #e05050;
}

.popup-body {
  padding: 16px 20px;
  flex: 1;
  overflow-y: auto;
}

.popup-body textarea {
  width: 100%;
  height: 180px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid #e4e8f4;
  background: #fafbff;
  color: #3a3a5c;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.popup-body textarea:focus { border-color: #a78bfa; }
.popup-body textarea::placeholder { color: #b0b8d4; }

.popup-hint {
  font-size: 12px;
  color: #9aa0c0;
  margin-top: 8px;
  line-height: 1.4;
}

.popup-warn {
  font-size: 12px;
  color: #a86a20;
  background: #fff8ec;
  border: 2px solid #ffe0b8;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 12px;
  line-height: 1.5;
}

.popup-footer {
  padding: 12px 20px;
  border-top: 2px solid #e4e8f4;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.popup-btn {
  padding: 8px 20px;
  border-radius: 10px;
  border: 2px solid transparent;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.popup-btn-reset {
  background: #fff0f0;
  color: #e05050;
  border-color: #ffd4d4;
}
.popup-btn-reset:hover { background: #ffe0e0; }

.popup-btn-ok {
  background: #7c3aed;
  color: #fff;
}
.popup-btn-ok:hover { background: #6d28d9; }

.popup-btn-neutral {
  background: #f0f2fa;
  color: #5a60a0;
  border-color: #e4e8f4;
}
.popup-btn-neutral:hover { background: #e6eaf6; }

/* ══════════════════════════════════════════
   HAUPTBEREICH
   ══════════════════════════════════════════ */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.chat-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ══════════════════════════════════════════
   NACHRICHTEN-BEREICH
   ══════════════════════════════════════════ */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: #d4d8ea; border-radius: 3px; }

/* ── Nachrichten-Bubbles ── */
.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #ff9b44, #ff7b54);
  color: #fff;
  border-bottom-right-radius: 6px;
  white-space: pre-wrap;
  box-shadow: 0 2px 8px rgba(255, 123, 84, 0.25);
}

.msg.assistant {
  align-self: flex-start;
  background: #f4f6fc;
  color: #3a3a5c;
  border-bottom-left-radius: 6px;
  border: 2px solid #e4e8f4;
}

.msg.system {
  align-self: center;
  background: #f0f8ff;
  color: #6a8ccc;
  border: 2px dashed #c8d8f0;
  font-size: 12px;
  max-width: 90%;
  border-radius: 12px;
}

.msg.error {
  align-self: center;
  background: #fff4f4;
  color: #d05050;
  border: 2px solid #ffd4d4;
  font-size: 13px;
  border-radius: 12px;
  max-width: 88%;
}
.msg.error ul { margin: 7px 0 0 1.1em; }
.msg.error li { margin: 3px 0; line-height: 1.5; }

/* ══════════════════════════════════════════
   MARKDOWN, KATEX & CODE-BLOCKS
   ══════════════════════════════════════════ */
.msg.assistant p { margin: 0.4em 0; }
.msg.assistant p:first-child { margin-top: 0; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant ul, .msg.assistant ol { margin: 0.4em 0 0.4em 1.4em; }
.msg.assistant li { margin: 0.2em 0; }
.msg.assistant strong { color: #5a3a8c; }

.msg.assistant code {
  background: #eef0fa;
  padding: 1px 5px;
  border-radius: 6px;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 0.9em;
  color: #c06020;
}

.msg.assistant pre {
  position: relative;
  background: #1e1e2e;
  padding: 14px 12px 12px 12px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 0.5em 0;
  border: 2px solid #3a3a5c;
}

.msg.assistant pre code {
  background: none;
  padding: 0;
  color: #e0e0e0;
  font-size: 13px;
  display: block;
}

/* Copy-Button für Code-Blöcke */
.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #3a3a5c;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0.85;
  z-index: 5;
  font-family: inherit;
}

.copy-btn:hover {
  background: #ff9b44;
  opacity: 1;
  transform: translateY(-1px);
}

.copy-btn.copied {
  background: #40a060;
}

.msg.assistant blockquote {
  border-left: 3px solid #ff9b44;
  padding-left: 10px;
  margin: 0.5em 0;
  color: #7a82a6;
}

.msg.assistant table {
  border-collapse: collapse;
  margin: 0.5em 0;
  font-size: 13px;
  width: 100%;
}

.msg.assistant th,
.msg.assistant td {
  border: 2px solid #e4e8f4;
  padding: 4px 8px;
  text-align: left;
}

.msg.assistant th {
  background: #f4f6fc;
  color: #7a82a6;
}

.msg.assistant .katex-display {
  margin: 0.6em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* ══════════════════════════════════════════
   TIPP-INDIKATOR
   ══════════════════════════════════════════ */
.typing-indicator {
  align-self: flex-start;
  padding: 10px 14px;
  margin: 0 16px;
  background: #f4f6fc;
  border-radius: 16px;
  border-bottom-left-radius: 6px;
  border: 2px solid #e4e8f4;
  display: none;
}

.typing-indicator span {
  display: inline-block;
  width: 7px; height: 7px;
  background: #a0a8cc;
  border-radius: 50%;
  margin: 0 2px;
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ══════════════════════════════════════════
   EINGABE-LEISTE
   ══════════════════════════════════════════ */
.input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #f8f9fe;
  border-top: 2px solid #e4e8f4;
  flex-shrink: 0;
  align-items: flex-end;
}

.input-bar textarea {
  flex: 1;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid #e4e8f4;
  background: #ffffff;
  color: #3a3a5c;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  height: 42px;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.2s;
}

.input-bar textarea:focus { border-color: #ff9b44; }
.input-bar textarea::placeholder { color: #b0b8d4; }

.btn {
  padding: 0 16px;
  height: 42px;
  border-radius: 12px;
  border: none;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-send {
  background: linear-gradient(135deg, #ff9b44, #ff7b54);
  color: #fff;
  min-width: 70px;
  box-shadow: 0 2px 8px rgba(255, 123, 84, 0.25);
}
.btn-send:hover { background: linear-gradient(135deg, #ff8a30, #ff6a40); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.btn-file {
  background: #f0f2fa;
  color: #7a82a6;
  min-width: 42px;
  font-size: 16px;
  border: 2px solid #e4e8f4;
  position: relative;
}
.btn-file:hover { background: #e8ecf8; color: #5a60a0; }
.btn-file.has-file { background: #e8f8ee; color: #40a060; border-color: #c0e8cc; }

.file-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #40a060;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid #f8f9fe;
}
.btn-file.has-file .file-count { display: flex; }

.btn-reset {
  background: #f0f2fa;
  color: #7a82a6;
  min-width: 42px;
  font-size: 18px;
  border: 2px solid #e4e8f4;
}
.btn-reset:hover { background: #e8ecf8; color: #5a60a0; }

#fileInput { display: none; }

/* Sichtbarer Tastaturfokus */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #ffb37a;
  outline-offset: 2px;
}

/* ══════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════ */
.sidebar {
  width: 226px;
  background: #f8f9fe;
  border-left: 2px solid #e4e8f4;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #d4d8ea; border-radius: 3px; }

.sidebar h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #7a82a6;
  font-weight: 800;
  margin-bottom: 8px;
}

.setting-group { display: flex; flex-direction: column; flex-shrink: 0; }

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-row input[type="range"] {
  flex: 1;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: #e4e8f4;
  border-radius: 3px;
  outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff9b44, #ff7b54);
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(255,123,84,0.3);
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #ff7b54;
  cursor: pointer;
  border: 3px solid #fff;
}

.slider-val {
  font-size: 14px;
  font-weight: 800;
  color: #ff7b54;
  min-width: 32px;
  text-align: right;
  font-family: monospace;
}

/* (a) Kontext-Limit: Slider + exakte Eingabe */
.ctx-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.ctx-head h3 { margin-bottom: 0; }
.ctx-value {
  font-size: 13px;
  font-weight: 800;
  color: #ff7b54;
  font-family: Consolas, monospace;
}
.ctx-exact-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.ctx-exact-row input[type="number"] {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border-radius: 8px;
  border: 2px solid #e4e8f4;
  background: #fff;
  color: #3a3a5c;
  font-size: 12px;
  font-family: Consolas, monospace;
  outline: none;
}
.ctx-exact-row input[type="number"]:focus { border-color: #ff9b44; }
.ctx-exact-row span { font-size: 11px; color: #9aa0c0; font-weight: 700; }
/* Skalenbeschriftung: absolut positioniert, weil der Regler logarithmisch
   ist – gleichmäßig verteilte Labels wären schlicht falsch. */
.ctx-scale {
  position: relative;
  height: 12px;
  margin-top: 3px;
  font-size: 9px;
  color: #b0b8d4;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.ctx-scale span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}
.ctx-scale span:first-child { transform: translateX(0); }
.ctx-scale span:last-child  { transform: translateX(-100%); }

/* (b) Token-Zähler */
.tok-block {
  background: #ffffff;
  border: 2px solid #e4e8f4;
  border-radius: 12px;
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.tok-row { display: flex; flex-direction: column; gap: 4px; }

.tok-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 10px;
  font-weight: 700;
  color: #7a82a6;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.tok-label .pct {
  font-family: Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  color: #5a60a0;
  text-transform: none;
  letter-spacing: 0;
}

.tok-bar {
  height: 7px;
  background: #eef0fa;
  border-radius: 4px;
  overflow: hidden;
}
.tok-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, #6ec1a0, #40a060);
  transition: width 0.3s ease;
}
.tok-fill.warn { background: linear-gradient(90deg, #ffc470, #ff9b44); }
.tok-fill.crit { background: linear-gradient(90deg, #ff8a80, #e05050); }
.tok-fill.session { background: linear-gradient(90deg, #9db6f0, #6a8ccc); }

.tok-detail {
  font-size: 11px;
  color: #7a82a6;
  font-family: Consolas, monospace;
  line-height: 1.6;
}
.tok-detail b { color: #3a3a5c; font-weight: 700; }
.tok-detail .in  { color: #c06020; font-weight: 700; }
.tok-detail .out { color: #4a7ab0; font-weight: 700; }

.tok-note {
  font-size: 10px;
  color: #a8afd0;
  line-height: 1.45;
  border-top: 1px dashed #e4e8f4;
  padding-top: 7px;
}
.tok-note b { color: #7a82a6; }

/* (c) Anhänge-Liste */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
}
.file-list::-webkit-scrollbar { width: 5px; }
.file-list::-webkit-scrollbar-thumb { background: #d4d8ea; border-radius: 3px; }

.file-item {
  font-size: 11px;
  color: #7a82a6;
  line-height: 1.45;
  padding: 7px 9px;
  background: #ffffff;
  border-radius: 10px;
  border: 2px solid #e4e8f4;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.file-item .kind {
  font-size: 12px;
  flex-shrink: 0;
  line-height: 1.2;
}
.file-item .meta { flex: 1; min-width: 0; }
.file-item .filename {
  color: #40a060;
  font-weight: 700;
  word-break: break-all;
  display: block;
}
.file-item .size { font-family: Consolas, monospace; font-size: 10px; }
.file-item .remove-file {
  color: #d0b0b0;
  cursor: pointer;
  font-weight: 800;
  flex-shrink: 0;
  padding: 0 2px;
  background: none;
  border: none;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.2;
}
.file-item .remove-file:hover { color: #e05050; }

.file-clear {
  font-size: 11px;
  color: #e05050;
  background: none;
  border: none;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  align-self: flex-start;
  margin-top: 6px;
  padding: 0;
}
.file-clear:hover { color: #c03030; }

.model-badge {
  margin-top: auto;
  padding: 9px 11px;
  background: #ffffff;
  border-radius: 12px;
  border: 2px solid #e4e8f4;
  text-align: center;
  font-size: 11px;
  color: #7a82a6;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.model-badge strong {
  display: block;
  font-size: 12px;
  color: #5a60a0;
  margin-top: 2px;
  font-weight: 800;
  word-break: break-all;
}

/* ── Leerzustand ── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #a0a8cc;
  gap: 8px;
  padding: 40px;
  text-align: center;
}
.empty-state .icon { font-size: 36px; opacity: 0.7; }
.empty-state p { font-size: 14px; line-height: 1.5; }
.empty-state strong { color: #5a60a0; }

/* ══════════════════════════════════════════
   AGENTENWERKSTATT – ERGÄNZUNGEN
   ══════════════════════════════════════════ */

.app-title {
  font-size: 15px;
  font-weight: 800;
  color: #3a3a5c;
  margin-right: 8px;
  align-self: center;
  white-space: nowrap;
}

/* ── Registerkarten ── */
.tabs {
  display: flex;
  gap: 4px;
  align-self: stretch;
  align-items: flex-end;
  flex: 1;
  flex-wrap: wrap;
}
.tab {
  padding: 7px 14px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: transparent;
  color: #7a82a6;
  font-size: 13px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
}
.tab:hover { background: #eef0fa; color: #5a60a0; }
.tab[aria-selected="true"] {
  background: #ffffff;
  border-color: #e4e8f4;
  color: #7c3aed;
}
.model-group { display: flex; align-items: center; gap: 8px; }

.panel { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.panel[hidden] { display: none; }

.placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: #7a82a6;
  padding: 40px;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
}
.placeholder h2 { font-size: 18px; color: #3a3a5c; }

/* ── Statuszeile im Chat: aktiver Skill + aktive Tools ── */
.status-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 16px;
  border-bottom: 2px solid #e4e8f4;
  background: #ffffff;
  font-size: 12px;
  flex-shrink: 0;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 2px solid #e4e8f4;
  background: #fafbff;
  color: #5a60a0;
}
.chip b { color: #3a3a5c; }
.chip.skill { border-color: #d9ccfb; background: #f5f0ff; }
.chip.tools { border-color: #c8e4d2; background: #f0faf4; }

/* ── Abbrechen-Knopf ── */
.btn-stop {
  background: #fff0f0;
  color: #d05050;
  border: 2px solid #ffd4d4;
  min-width: 100px;
}
.btn-stop:hover { background: #ffe0e0; }
.btn-stop[hidden] { display: none; }

/* Links in Modellantworten öffnen in neuem Tab (siehe render.js) */
.msg.assistant a { color: #6d28d9; }

/* Nur für Screenreader sichtbar */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ── Schaltfläche in der Statuszeile ── */
.chip-btn {
  margin-left: auto;
  padding: 3px 12px;
  border-radius: 999px;
  border: 2px solid #e4e8f4;
  background: #ffffff;
  color: #5a60a0;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.chip-btn:hover { border-color: #a78bfa; color: #7c3aed; }
.chip-btn[aria-expanded="true"] { background: #ede9fe; border-color: #a78bfa; color: #7c3aed; }

.sidebar[hidden], .trace-panel[hidden] { display: none; }

/* ── Toolaufrufe im Chat (FR-CHAT-009) ── */
.tool-line {
  align-self: flex-start;
  max-width: 88%;
  border: 2px solid #e4e8f4;
  border-left-width: 5px;
  border-radius: 10px;
  background: #fbfcff;
  font-size: 12.5px;
  color: #3a3a5c;
}
.tool-line summary {
  padding: 6px 10px;
  cursor: pointer;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.tool-line summary code {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 11.5px;
  background: #eef0fa;
  padding: 1px 5px;
  border-radius: 5px;
}
.tool-line .tool-status { font-weight: 800; white-space: nowrap; }
.tool-line .tool-result { color: #5a60a0; }
.tool-line.running { border-left-color: #a0a8cc; }
.tool-line.ok { border-left-color: #40a060; }
.tool-line.ok .tool-status { color: #2d7a48; }
.tool-line.error { border-left-color: #d05050; }
.tool-line.error .tool-status { color: #b03a3a; }
.tool-line.skipped { border-left-color: #d0a040; }
.tool-line.skipped .tool-status { color: #8a6410; }
.tool-line-body { padding: 0 10px 10px; }
.tool-line-title {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #7a82a6;
  margin: 8px 0 3px;
}
.tool-line-body pre {
  background: #1e1e2e;
  color: #e0e0e0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow: auto;
}

/* ── Zwischentext des Modells (FR-CHAT-010) ── */
.msg.assistant.intermediate {
  background: #fffdf5;
  border-style: dashed;
  border-color: #eadfb8;
  font-size: 13px;
}
.intermediate-label {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #a08a40;
  margin-bottom: 4px;
}

/* ── Hinweise (z. B. Schrittgrenze) ── */
.msg.notice {
  align-self: center;
  background: #fff8ec;
  color: #7a4d10;
  border: 2px solid #ffe0b8;
  font-size: 13px;
  border-radius: 12px;
  max-width: 88%;
  font-weight: 700;
}

/* ── Verworfener Durchlauf (Abbruch/Fehler) ── */
.discarded { opacity: 0.5; }
.msg.user.discarded { text-decoration: line-through; }
.discarded-label {
  align-self: flex-end;
  font-size: 11.5px;
  color: #9a6060;
  font-style: italic;
  margin-top: -6px;
}

/* ── Ablaufprotokoll ── */
.trace-panel {
  width: 380px;
  flex-shrink: 0;
  background: #f8f9fe;
  border-left: 2px solid #e4e8f4;
  padding: 14px;
  overflow-y: auto;
  font-size: 12.5px;
}
.trace-head { display: flex; justify-content: space-between; align-items: baseline; }
.trace-head h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #7a82a6;
  font-weight: 800;
}
.trace-head .file-clear { margin-top: 0; }
.trace-hint { font-size: 11px; color: #9aa0c0; margin: 4px 0 10px; }
.trace-empty { color: #9aa0c0; font-style: italic; }
.trace-item {
  background: #ffffff;
  border: 2px solid #e4e8f4;
  border-radius: 10px;
  margin-bottom: 8px;
}
.trace-item > summary { padding: 7px 10px; cursor: pointer; font-weight: 700; overflow-wrap: anywhere; }
.trace-item.status-error, .trace-item.status-cancelled { border-color: #ffd4d4; }
.trace-item.status-step_limit_reached { border-color: #ffe0b8; }
.trace-meta { padding: 0 10px 6px; color: #7a82a6; font-size: 11.5px; }
.trace-steps { margin: 0 10px 10px 30px; }
.trace-step { margin: 5px 0; line-height: 1.45; overflow-wrap: anywhere; }
.trace-step-status { font-weight: 800; font-size: 11.5px; }
.trace-step.status-ok .trace-step-status { color: #2d7a48; }
.trace-step.status-error .trace-step-status { color: #b03a3a; }
.trace-step.status-not_executed .trace-step-status { color: #8a6410; }

/* ── Tool-Labor (Vorstufe) ── */
.tool-lab { padding: 20px; overflow-y: auto; flex: 1; }
.lab-intro { color: #7a82a6; font-size: 13px; margin-bottom: 14px; }
.tool-card {
  border: 2px solid #e4e8f4;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: #fafbff;
  font-size: 13px;
}
.tool-card.enabled { border-color: #b5dcc3; background: #f3fbf6; }
.tool-card p { margin: 6px 0; color: #5a60a0; }
.tool-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; }
.tool-toggle input { width: 16px; height: 16px; accent-color: #40a060; }
.tool-card pre {
  background: #1e1e2e; color: #e0e0e0; padding: 10px; border-radius: 8px;
  font-size: 12px; white-space: pre-wrap; margin-top: 6px;
}
.tool-card summary { cursor: pointer; color: #7a82a6; font-weight: 700; font-size: 12px; }

/* ── Tool-Anzeige im Chat als Knopf ── */
.chip-link { cursor: pointer; font-family: inherit; font-size: 12px; }
.chip-link:hover { border-color: #40a060; }
.chip.tools.none { border-color: #ffc98a; background: #fff6ea; color: #8a5a10; }
.chip.tools.none b { color: #8a5a10; }
.chip.tools.invalid { border-color: #f0a0a0; background: #fff0f0; }

/* ── Tool-Labor ── */
.lab-head { margin-bottom: 16px; }
.lab-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 6px; }
.lab-btn {
  padding: 7px 14px;
  border-radius: 10px;
  border: 2px solid #7c3aed;
  background: #7c3aed;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.lab-btn:hover { background: #6d28d9; }
.lab-btn.secondary { background: #fff; color: #7c3aed; }
.lab-btn.secondary:hover { background: #f5f0ff; }
.lab-btn:disabled { opacity: .45; cursor: not-allowed; }
.lab-status { font-size: 13px; color: #5a60a0; font-weight: 700; }
.lab-status.warn { color: #9a5a10; }
.lab-import-msg { font-size: 13px; margin-top: 6px; }
.lab-import-msg.ok { color: #2d7a48; }
.lab-import-msg.error { color: #b03a3a; }
.lab-import-msg ul { margin: 4px 0 0 20px; }

.tool-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tool-card-head h3 { font-size: 16px; color: #3a3a5c; font-family: Consolas, 'Courier New', monospace; }
.tool-card-head .tool-toggle { margin-left: auto; font-weight: 700; }
.badge { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; }
.badge.modified { background: #fff1d6; color: #8a5a10; border: 1px solid #f0cf90; }
.badge[hidden] { display: none; }
.tool-id { font-size: 11.5px; color: #9aa0c0; margin: 2px 0 8px; }

.tool-edit { border: 2px dashed #d9ccfb; border-radius: 10px; padding: 8px 12px 12px; margin: 8px 0; background: #fff; }
.tool-edit legend { font-size: 11px; font-weight: 800; color: #7c3aed; text-transform: uppercase; letter-spacing: .4px; padding: 0 4px; }
.field { margin: 8px 0; }
.field label, .lab-test label { display: block; font-size: 12px; font-weight: 800; color: #5a60a0; margin-bottom: 3px; }
.field input, .field textarea, .lab-test textarea {
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  border: 2px solid #e4e8f4;
  font-family: inherit;
  font-size: 13px;
  color: #3a3a5c;
  resize: vertical;
}
.field input { font-family: Consolas, 'Courier New', monospace; }
.field input:focus, .field textarea:focus, .lab-test textarea:focus { border-color: #a78bfa; outline: none; }
.field [aria-invalid="true"] { border-color: #e08080; background: #fff6f6; }
.field-hint { font-size: 11.5px; color: #9aa0c0; margin: 2px 0 4px; }
.field-error { font-size: 12px; color: #b03a3a; font-weight: 700; min-height: 0; }
textarea.mono { font-family: Consolas, 'Courier New', monospace; font-size: 12.5px; }

.lab-details { margin-top: 8px; }
.lab-details > summary { padding: 4px 0; }
.lab-test .lab-btn { margin-top: 6px; }
.lab-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.lab-chip {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #d9ccfb;
  background: #f8f5ff;
  color: #5a3a8c;
  cursor: pointer;
}
.test-out { margin-top: 8px; font-size: 13px; }
.test-out .good { color: #2d7a48; font-weight: 700; }
.test-out .bad { color: #b03a3a; font-weight: 700; }
.test-out ul { margin: 4px 0 0 20px; color: #b03a3a; }
.lab-call { border-top: 1px dashed #e4e8f4; padding: 6px 0; font-size: 12.5px; }
.lab-call code { font-size: 12px; display: block; color: #5a3a8c; overflow-wrap: anywhere; }

/* ── Ablaufprotokoll: Detailansichten (Schritt 10) ── */
.trace-panel { width: 420px; }
.trace-sub { margin: 4px 0 2px; }
.trace-sub > summary {
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
  color: #7c3aed;
  padding: 2px 0;
}
.trace-item > .trace-sub { margin: 2px 10px; }
.trace-step-desc { color: #3a3a5c; }
.trace-detail-title {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #7a82a6;
  margin: 8px 0 3px;
}
.trace-detail-hint { font-size: 11px; color: #9aa0c0; margin-bottom: 3px; }
.trace-pre {
  background: #1e1e2e;
  color: #e0e0e0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}

/* ── Skill-Designer ── */
.skill-designer { display: flex; flex: 1; min-height: 0; }
.skill-sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 2px solid #e4e8f4;
  background: #f8f9fe;
  padding: 16px 14px;
  overflow-y: auto;
}
.skill-sidebar h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: #7a82a6; font-weight: 800; }
.skill-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.skill-item {
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid #e4e8f4;
  background: #fff;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.skill-item:hover { border-color: #d9ccfb; }
.skill-item.selected { border-color: #a78bfa; background: #f5f0ff; }
.skill-item-name { font-size: 13px; font-weight: 700; color: #3a3a5c; }
.skill-item-tags { font-size: 11px; color: #9aa0c0; }
.skill-item.active .skill-item-tags { color: #2d7a48; font-weight: 700; }
.skill-editor { flex: 1; overflow-y: auto; padding: 18px 22px; min-width: 0; }
.skill-title { font-size: 18px; color: #3a3a5c; margin-bottom: 4px; }
.skill-status { font-size: 13px; color: #2d7a48; font-weight: 700; margin-bottom: 8px; }
.skill-status.warn { color: #9a5a10; }
.skill-readonly-note { font-size: 13px; color: #7a82a6; background: #f4f6fc; border-radius: 10px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.skill-mode { border: none; margin: 10px 0; display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: #5a60a0; }
.skill-mode legend { font-size: 12px; font-weight: 800; color: #5a60a0; margin-bottom: 4px; }
.skill-mode label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.skill-structured[hidden], .skill-free[hidden] { display: none; }
.field input[readonly], .field textarea[readonly] { background: #f6f7fb; color: #5a60a0; }
.skill-preview-box { margin: 14px 0 6px; }
.skill-preview-box h3 { font-size: 12px; font-weight: 800; color: #7c3aed; text-transform: uppercase; letter-spacing: .4px; }
.skill-preview {
  background: #1e1e2e; color: #e0e0e0; padding: 12px; border-radius: 10px;
  font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow: auto; margin-top: 4px;
}
.lab-btn.danger { color: #b03a3a; border-color: #e0a0a0; }
.lab-btn.danger:hover { background: #fff0f0; }
.lab-btn[hidden] { display: none; }
.trace-skill-change { margin: 0 10px 4px; font-size: 11.5px; font-weight: 700; color: #7c3aed; }

/* ── Hilfeseite ── */
.help-page { display: flex; flex: 1; min-height: 0; }
.help-toc {
  width: 230px;
  flex-shrink: 0;
  border-right: 2px solid #e4e8f4;
  background: #f8f9fe;
  padding: 16px 12px;
  overflow-y: auto;
}
.help-toc h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: #7a82a6; font-weight: 800; margin-bottom: 8px; }
.help-toc ul { list-style: none; }
.help-toc-link {
  display: block; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 700; color: #5a60a0;
  padding: 4px 6px; border-radius: 6px;
}
.help-toc-link:hover { background: #eef0fa; color: #7c3aed; }
.help-toc-link.sub { font-weight: 600; font-size: 12px; padding-left: 16px; color: #7a82a6; }
.help-content { flex: 1; overflow-y: auto; padding: 20px 28px 40px; min-width: 0; font-size: 14px; line-height: 1.6; color: #3a3a5c; }
.help-intro h1 { font-size: 22px; margin-bottom: 6px; }
.help-intro p { color: #5a60a0; max-width: 760px; }
.help-section { margin-top: 26px; max-width: 820px; }
.help-section > h2 { font-size: 18px; border-bottom: 2px solid #e4e8f4; padding-bottom: 4px; margin-bottom: 10px; }
.help-section:focus, .help-topic:focus, .help-card:focus { outline: none; }
.help-topic { margin: 14px 0 18px; }
.help-topic h3, .help-card h3 { font-size: 15px; margin-bottom: 4px; color: #3a3a5c; }
.help-content p { margin: 6px 0; }
.help-content ul, .help-content ol { margin: 6px 0 6px 22px; }
.help-content li { margin: 3px 0; }
.help-content code {
  font-family: Consolas, 'Courier New', monospace; font-size: 0.9em;
  background: #eef0fa; color: #5a3a8c; padding: 1px 5px; border-radius: 5px;
}
.help-tips { background: #f5f0ff; border-radius: 10px; padding: 10px 14px 10px 30px; font-size: 13px; }
.help-card {
  border: 2px solid #e4e8f4; border-radius: 12px; background: #fafbff;
  padding: 12px 16px; margin: 12px 0;
}
.help-goal { color: #5a60a0; }
.help-sub { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; color: #7a82a6; margin-top: 8px; }
.help-prompts { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.help-prompt { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.help-prompt code { font-size: 13px; }
.lab-btn.small { padding: 3px 10px; font-size: 12px; }
.help-observe { background: #fff8ec; border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.help-search-label { display: block; font-size: 12px; font-weight: 800; color: #5a60a0; margin: 8px 0 3px; }
.help-section input[type="search"] {
  width: 100%; max-width: 360px; padding: 7px 10px; border-radius: 8px;
  border: 2px solid #e4e8f4; font-family: inherit; font-size: 13px;
}
.help-section input[type="search"]:focus { border-color: #a78bfa; outline: none; }
.help-glossary dt { font-weight: 800; margin-top: 10px; color: #3a3a5c; }
.help-glossary dd { margin: 2px 0 0 0; color: #3a3a5c; }
.help-aliases { color: #9aa0c0; font-size: 12px; }

/* ── Skill-Katalog (Spec 10.7) ── */
.skill-catalog { margin-top: 18px; border-top: 2px solid #e4e8f4; padding-top: 12px; }
.skill-catalog h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: #7a82a6; font-weight: 800; }
.skill-catalog-list { list-style: none; margin: 6px 0; font-size: 13px; }
.skill-catalog-list li { padding: 3px 0; font-weight: 700; color: #5a3a8c; }
.skill-catalog-list li::before { content: '🎭 '; }
.skill-catalog-list li.field-hint::before { content: ''; }
.skill-catalog .skill-preview { font-size: 11.5px; max-height: 260px; }
.skill-catalog-toggle { border: 2px dashed #d9ccfb; border-radius: 10px; padding: 6px 12px 8px; margin: 8px 0; }
.skill-catalog-toggle legend { font-size: 11px; font-weight: 800; color: #7c3aed; text-transform: uppercase; letter-spacing: .4px; padding: 0 4px; }
.skill-catalog-toggle label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: #3a3a5c; cursor: pointer; }
.skill-catalog-toggle input:disabled + * { opacity: .5; }
