/* ============================================================
   DSGVO-KI-Assistent — Stylesheet (modernisiert, Chat-Stil)
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* Border radius scale */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 24px;

  /* Layout */
  --sidebar-w: 280px;
  --content-w: 760px;
  --topbar-h: 56px;

  /* Light palette */
  --bg: #fafaf9;
  --bg-elev: #ffffff;
  --bg-subtle: #f5f5f4;
  --bg-sidebar: #f7f7f6;
  --bg-hover: rgba(15, 23, 42, 0.04);
  --bg-active: rgba(15, 23, 42, 0.07);

  --text: #18181b;
  --text-muted: #71717a;
  --text-subtle: #a1a1aa;

  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-fg: #ffffff;
  --accent-soft: rgba(37, 99, 235, 0.10);
  --accent-ring: rgba(37, 99, 235, 0.22);

  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.10);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.10);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.14);

  /* Type */
  --font-sans: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Consolas", "SF Mono", monospace;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f0f10;
  --bg-elev: #1a1a1c;
  --bg-subtle: #161618;
  --bg-sidebar: #131315;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(255, 255, 255, 0.08);

  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-subtle: #71717a;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-fg: #ffffff;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --accent-ring: rgba(59, 130, 246, 0.3);

  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.14);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.6);

  color-scheme: dark;
}

/* ---------- Reset / Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { user-select: none; cursor: pointer; }
.hidden { display: none !important; }

::selection { background: var(--accent-ring); }

/* Scrollbars — cross-browser */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); background-clip: padding-box; }

/* ---------- Icons ---------- */
.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
.icon.caret { width: 14px; height: 14px; opacity: 0.6; }

/* ---------- App Shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-head {
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.brand-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}
.brand-text { min-width: 0; }
.sidebar-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.eyebrow {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 2px;
}

.brand-mark {
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.02em;
  flex: 0 0 auto;
  box-shadow: var(--shadow-sm);
}
.brand-mark.has-logo { background: transparent !important; box-shadow: none; }
.small-mark { width: 32px; height: 32px; font-size: 12px; border-radius: var(--r-sm); }

/* New conversation button */
.new-conv-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: var(--sp-3) var(--sp-3) var(--sp-2);
  padding: 10px var(--sp-3);
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 13.5px;
  transition: background 0.15s, border-color 0.15s;
}
.new-conv-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.new-conv-btn .icon { color: var(--accent); }

/* Conversation search */
.conv-search-wrap {
  position: relative;
  margin: 0 var(--sp-3) var(--sp-2);
}
/* v3.3.2: Spezifität verschärft — vorher gewann gelegentlich die generische .icon-Regel
 * (18×18px) und schob den Lupen-Kreis nach rechts in den Text. Plus !important auf width/height
 * um auf Nummer sicher zu gehen. */
.conv-search-wrap svg.icon.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px !important;
  height: 16px !important;
  flex-shrink: 0;
}
.conv-search-wrap input[type="search"],
.conv-search-wrap input {
  width: 100%;
  padding: 8px 10px 8px 34px;
  font-size: 13px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  box-sizing: border-box;
  /* native search-Field-UI in Webkit deaktivieren, sonst greift padding-left nicht
   * konsistent und der Placeholder kann unter dem Lupensymbol erscheinen. */
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.conv-search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.conv-search-wrap input::-webkit-search-cancel-button { cursor: pointer; }

/* Conversations list */
.conversations {
  overflow: auto;
  padding: 0 var(--sp-2) var(--sp-2);
  flex: 1;
  min-height: 80px;
}
.conv {
  padding: 9px var(--sp-3);
  margin: 2px 0;
  border-radius: var(--r-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s;
  /* v3.2 (C6): Layout für Title-Block + Action-Buttons */
  display: flex;
  align-items: center;
  gap: 6px;
}
.conv:hover { background: var(--bg-hover); }
.conv.active { background: var(--accent-soft); }
.conv.pinned .conv-title { color: var(--accent); }
.conv-main { flex: 1; min-width: 0; }
.conv-title {
  font-weight: 550;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-pin-mark { color: var(--accent); }
.conv-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
/* v3.2: Action-Buttons rechts in Conv-Einträgen — nur bei Hover sichtbar */
.conv-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s;
}
.conv:hover .conv-actions,
.conv.pinned .conv-actions { opacity: 1; }
.conv-action {
  background: none;
  border: none;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}
.conv-action:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Side tools (collapsed by default) */
.side-tools {
  border-top: 1px solid var(--border);
  margin-top: auto;
  background: var(--bg-sidebar);
}
.tools-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 12px var(--sp-4);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  transition: color 0.15s, background 0.15s;
}
.tools-toggle:hover { color: var(--text); background: var(--bg-hover); }
.tools-toggle > span { flex: 1; text-align: left; }
.tools-chevron { transition: transform 0.2s; }
.tools-toggle[aria-expanded="true"] .tools-chevron { transform: rotate(180deg); }

.tools-nav {
  padding: var(--sp-1) var(--sp-2) var(--sp-3);
  display: grid;
  gap: 1px;
  max-height: 56vh;
  overflow: auto;
}
.tools-sep {
  height: 1px;
  background: var(--border);
  margin: var(--sp-1) var(--sp-2);
}

.side-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: var(--r-sm);
  text-align: left;
  font-size: 13px;
  width: 100%;
  transition: background 0.12s;
}
.side-action:hover, .side-action:focus-visible {
  background: var(--bg-hover);
  outline: none;
}
.side-action .icon { color: var(--text-muted); }
.side-action:hover .icon { color: var(--accent); }

/* ---------- Main / Topbar ---------- */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg);
  position: relative; /* v4.1.2 (Feature 9): Anker für schwebenden „Neueste"-Button */
}

/* v4.1.2 (Feature 6): Schriftgröße/Anzeigedichte — skaliert die zentralen Arbeitsflächen.
   zoom wirkt in Chromium (WebView2) sauber; ohne Unterstützung wird es ignoriert (1:1). */
.messages, .composer { zoom: var(--font-scale, 1); }

.topbar {
  display: grid;
  grid-template-columns: auto 1fr minmax(0, auto);
  grid-template-rows: auto auto;
  align-items: center;
  gap: 4px var(--sp-4);
  padding: var(--sp-3) var(--sp-6);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  min-height: var(--topbar-h);
}
.topbar-brand {
  grid-row: 1;
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.topbar h1 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.topbar-logo { max-height: 24px; width: auto; border-radius: 4px; }
.version-pill {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  letter-spacing: 0;
}
.topbar-subtitle {
  grid-row: 2;
  grid-column: 1 / -1;
  margin: 0;
  font-size: 12px;
  color: var(--text-subtle);
  line-height: 1.4;
  /* Branding can override; default is empty so the row collapses. */
}
.topbar-subtitle:empty { display: none; }

.controls {
  grid-row: 1;
  grid-column: 3;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}
.select-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.select-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-left: 2px;
}
.controls select {
  padding: 6px 28px 6px 10px;
  min-width: 130px;
  max-width: 200px;
  height: 32px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.controls select:hover { border-color: var(--border-strong); }
.controls select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 12px;
  height: 32px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  align-self: flex-end;
  transition: border-color 0.15s, background 0.15s;
}
.toggle-chip:hover { border-color: var(--border-strong); }
.toggle-chip input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.toggle-chip:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.browser-hint {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 var(--sp-2);
}

/* ---------- Messages ---------- */
.messages {
  flex: 1;
  overflow: auto;
  padding: var(--sp-8) var(--sp-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-5);
  scroll-behavior: smooth;
}
.messages > .msg,
.messages > .welcome {
  width: 100%;
  max-width: var(--content-w);
}

/* Welcome */
.welcome {
  text-align: center;
  padding: var(--sp-10) var(--sp-4);
  color: var(--text-muted);
}
.welcome-icon {
  width: 32px;
  height: 32px;
  color: var(--accent);
  margin: 0 auto var(--sp-3);
  display: block;
}
.welcome h2 {
  color: var(--text);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0 0 var(--sp-3);
}
.welcome p {
  margin: 0 auto;
  max-width: 520px;
  line-height: 1.55;
  font-size: 14px;
}

/* Messages */
.msg {
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-lg);
  line-height: 1.6;
  white-space: pre-wrap;
  font-size: 14.5px;
  position: relative;
}
.msg.user {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.ai {
  background: transparent;
  color: var(--text);
  padding-left: 0;
  padding-right: 0;
  /* v3.2 (C5): white-space normal weil Markdown-Rendering eigene Block-Tags erzeugt;
     pre-wrap würde HTML-Layout zerschießen. Nur User-Messages bleiben pre-wrap. */
  white-space: normal;
}
/* v3.2 (C5): Markdown-Render-Styles für AI-Messages */
.msg.ai p { margin: 0 0 0.7em 0; }
.msg.ai p:last-child { margin-bottom: 0; }
.msg.ai h1, .msg.ai h2, .msg.ai h3, .msg.ai h4, .msg.ai h5, .msg.ai h6 {
  margin: 1em 0 0.4em 0; font-weight: 600; line-height: 1.3;
}
.msg.ai h1 { font-size: 1.5em; }
.msg.ai h2 { font-size: 1.3em; }
.msg.ai h3 { font-size: 1.15em; }
.msg.ai h4, .msg.ai h5, .msg.ai h6 { font-size: 1em; }
.msg.ai h1:first-child, .msg.ai h2:first-child, .msg.ai h3:first-child { margin-top: 0; }
.msg.ai ul, .msg.ai ol { margin: 0.4em 0 0.7em 0; padding-left: 1.6em; }
.msg.ai li { margin: 0.2em 0; }
.msg.ai code {
  background: var(--bg-surface-2, rgba(127, 127, 127, 0.12));
  padding: 1px 5px; border-radius: 4px; font-size: 0.92em;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
.msg.ai pre {
  background: var(--bg-surface-2, rgba(127, 127, 127, 0.12));
  border: 1px solid var(--border);
  padding: 12px 14px; border-radius: 8px;
  overflow-x: auto;
  margin: 0.6em 0;
  font-size: 13px;
  line-height: 1.5;
}
.msg.ai pre code {
  background: none; padding: 0; border-radius: 0; font-size: inherit;
}
.msg.ai blockquote {
  border-left: 3px solid var(--accent);
  margin: 0.5em 0; padding: 0.2em 0 0.2em 0.9em;
  color: var(--text-muted);
}
.msg.ai a { color: var(--accent); text-decoration: underline; }
.msg.ai a:hover { text-decoration: none; }
.msg.ai table {
  border-collapse: collapse; margin: 0.6em 0;
  font-size: 13.5px;
}
.msg.ai th, .msg.ai td {
  border: 1px solid var(--border);
  padding: 5px 9px;
  text-align: left;
}
.msg.ai th { background: var(--bg-surface-2, rgba(127, 127, 127, 0.08)); font-weight: 600; }
.msg.ai hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }
.msg.ai strong { font-weight: 600; }
.msg.ai em { font-style: italic; }
.msg.ai del { text-decoration: line-through; color: var(--text-muted); }
.msg .meta {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.msg.user .meta {
  color: rgba(255, 255, 255, 0.78);
  border-top-color: rgba(255, 255, 255, 0.22);
}
.kb-attribution {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elev);
  padding: 8px 10px;
  font-size: 12.5px;
}
.kb-attribution summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}
.kb-attribution-item {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}
.kb-attribution-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--text-muted);
}
.kb-attribution-head b { color: var(--text); }
.kb-attribution-text {
  margin-top: 5px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* User messages: right-aligned within the centered 760px content column.
   width:fit-content + margin-left:auto overrides the flex align-items:center
   and the .messages > .msg width:100% rule above, while staying within --content-w. */
.messages > .msg.user {
  width: fit-content;
  max-width: calc(var(--content-w) * 0.82);
  margin-left: auto;
}

/* ---------- Composer ---------- */
.composer {
  padding: var(--sp-2) var(--sp-4) var(--sp-4);
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.composer > * { width: 100%; max-width: var(--content-w); }

.attachment {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  padding: 8px 12px;
  background: var(--success-soft);
  border: 1px solid rgba(22, 163, 74, 0.25);
  border-radius: var(--r-md);
  font-size: 13px;
}
.attachment .icon { color: var(--success); }
.attachment span { flex: 1; }
.attachment-remove {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--r-sm);
  padding: 0;
}
.attachment-remove:hover { background: rgba(0, 0, 0, 0.06); color: var(--text); }

/* The composer box (textarea + bar in one rounded container, ChatGPT-style) */
.composer-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  transition: border-color 0.15s, box-shadow 0.15s;
  overflow: hidden;
}
.composer-box:focus-within {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md), 0 0 0 3px var(--accent-ring);
}
.composer-box textarea {
  width: 100%;
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
  border: none;
  background: transparent;
  color: var(--text);
  resize: none;
  outline: none;
  line-height: 1.55;
  font-size: 15px;
  max-height: 220px;
  display: block;
}
.composer-box textarea::placeholder { color: var(--text-subtle); }

.composer-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 10px 8px;
}
.composer-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.composer-send {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
}

/* Square icon button (composer + modal) */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover, .icon-btn:focus-visible {
  background: var(--bg-hover);
  color: var(--text);
  outline: none;
}
.icon-btn:active { background: var(--bg-active); }
.icon-btn.file-btn { position: relative; cursor: pointer; }
.icon-btn.file-btn input[type="file"] { position: absolute; opacity: 0; pointer-events: none; }
.card > .file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin: 6px 8px 6px 0;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.card > .file-btn.ghost {
  background: var(--bg-elev);
  color: var(--text);
}

/* Icon-button with caret (dropdown trigger) — slightly wider */
.composer-tools .dropdown .icon-btn { width: auto; padding: 0 8px; gap: 2px; min-width: 36px; }

/* Composer footer (status text) */
.composer-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  margin-top: 6px;
  min-height: 16px;
  padding: 0 4px;
}
.status {
  font-size: 11.5px;
  color: var(--text-subtle);
}
.status.busy { color: var(--accent); }
/* v3.3: Token-Counter — dezent rechts, wird bei ~80% Kontext-Limit orange, bei >100% rot. */
.token-counter {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.token-counter.warn { color: var(--warning, #d97706); font-weight: 600; }
.token-counter.over { color: var(--error, #dc2626); font-weight: 700; }

/* ---------- Buttons (generic) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  text-decoration: none;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }

.btn.danger {
  color: var(--danger);
  border-color: var(--danger-soft);
  background: transparent;
}
.btn.danger:hover { background: var(--danger-soft); }

.btn.small { padding: 4px 9px; font-size: 12px; border-radius: var(--r-sm); }
.full { width: 100%; }

/* Send button — circular, prominent */
.send-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
}
.send-btn .icon { width: 18px; height: 18px; }

/* ---------- Dropdowns ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 1000;
  min-width: 240px;
  max-height: min(420px, 50vh);
  overflow: auto;
  padding: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.menu-item:hover { background: var(--bg-hover); }
.menu-item .icon { color: var(--text-muted); flex-shrink: 0; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }

/* ---------- Inputs (generic) ---------- */
input[type="text"], input[type="password"], input[type="search"], input[type="email"],
input[type="number"], input[type="url"], textarea, select, .settings-textarea {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 11px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus, .settings-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* ---------- Lockscreen ---------- */
.lockscreen {
  height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  background:
    radial-gradient(circle at 22% 0%, var(--accent-soft), transparent 38%),
    radial-gradient(circle at 80% 100%, var(--accent-soft), transparent 36%),
    var(--bg);
}
.lock-card {
  width: min(440px, calc(100vw - 32px));
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  padding: var(--sp-8);
  box-shadow: var(--shadow-lg);
}
.lock-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.lock-brand .brand-mark { width: 44px; height: 44px; font-size: 14px; border-radius: var(--r-md); }
.lock-card h1 {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.015em;
}
.lock-info {
  margin: 0 0 var(--sp-4);
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.55;
}
.form-stack { display: grid; gap: var(--sp-2); }
.form-stack input {
  padding: 10px 12px;
  font-size: 14px;
  border-radius: var(--r-md);
}
.form-stack .btn.primary { margin-top: 4px; padding: 10px var(--sp-4); }
.lock-links {
  margin-top: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.link-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 0;
  text-align: left;
  font-size: 12.5px;
  cursor: pointer;
  transition: color 0.12s;
}
.link-btn:hover { color: var(--text); }
.link-btn.danger { color: var(--danger); opacity: 0.85; }
.link-btn.danger:hover { opacity: 1; }
.error {
  color: var(--danger);
  font-size: 13px;
  min-height: 20px;
  margin-top: var(--sp-2);
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 100;
  padding: var(--sp-4);
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(4px);
}
[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, 0.55); }

.modal-card {
  position: relative;
  width: min(1180px, calc(100vw - 32px));
  height: min(800px, 88vh);
  max-width: 96vw;
  max-height: 92vh;
  min-width: 520px;
  min-height: 360px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  resize: both;
  transform: translate(var(--mx, 0), var(--my, 0));
}
.modal-card.maximized {
  width: 96vw !important;
  height: 94vh !important;
  transform: translate(0, 0) !important;
}
.modal-card.wizard-modal,
.modal-card.wide-modal {
  width: min(1380px, calc(100vw - 24px)) !important;
  height: min(900px, 94vh) !important;
}
/* Resize-grip indicator */
.modal-card::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 12px;
  height: 12px;
  background:
    linear-gradient(135deg, transparent 0%, transparent 50%, var(--border-strong) 50%, var(--border-strong) 60%,
                          transparent 60%, transparent 80%, var(--border-strong) 80%, var(--border-strong) 90%, transparent 90%);
  pointer-events: none;
  opacity: 0.6;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  cursor: move;
  user-select: none;
}
.modal-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  cursor: default;
}
.modal-actions { display: flex; gap: 4px; cursor: default; }
.modal-actions .icon-btn { width: 32px; height: 32px; }
.modal-actions .icon-btn .icon { width: 16px; height: 16px; }

.modal-body {
  padding: var(--sp-4) var(--sp-5);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  flex: 1 1 auto;
  min-height: 0;
  scrollbar-gutter: stable;
}
.modal-foot {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}
.modal-foot:empty { display: none; }

/* ---------- Card / Grid layouts inside modals ---------- */
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  padding: var(--sp-3) var(--sp-4);
}
.card h3 {
  margin: 0 0 var(--sp-2);
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.subcard {
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin-top: var(--sp-3);
  background: var(--accent-soft);
}
.subcard h4 { margin: 0 0 var(--sp-2); }

/* Modal labels — vertical stacked field labels */
.modal-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.modal-card label.check,
.controls label.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 550;
  color: var(--text);
}
.modal-card label.check input[type="checkbox"],
.controls label.check input[type="checkbox"],
.check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.review-box {
  white-space: pre-wrap;
  max-height: 360px;
  overflow: auto;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
}
.review-textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  font-family: var(--font-mono);
}
.sent-box { border-color: var(--accent); background: var(--accent-soft); }
.review-warning {
  border-color: rgba(220, 38, 38, 0.28);
  background: var(--danger-soft);
}

/* Feature 2: Restbefund-Warnbox (deutlich rot, oben im Review). */
.residual-warning {
  border-color: rgba(220, 38, 38, 0.55);
  background: var(--danger-soft);
}
.residual-warning h3 { color: var(--danger); }
.residual-list { margin: 8px 0 0; padding-left: 18px; }
.residual-list li { margin: 2px 0; }
.residual-ack {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
}

/* Feature 8: Schlanke „alles sauber“-Bestätigung im Review. */
.review-clean {
  border-color: rgba(22, 163, 74, 0.4);
  background: var(--success-soft);
}
.review-clean-head { color: var(--success); }

/* ---------- Tables ---------- */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.table th, .table td {
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.table th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-hover); }
.table .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.row-actions .btn { padding: 6px 9px; font-size: 12px; border-radius: var(--r-sm); }

/* ---------- Dashboard / metric cards ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-2);
}
.dash-grid.compact { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.metric-card {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: var(--r-md);
  padding: var(--sp-3);
}
.metric-card span {
  display: block;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.metric-card b {
  display: block;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
  word-break: break-word;
}
.metric-card p {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}
.metric-card small {
  display: block;
  margin-top: 6px;
  color: var(--text-subtle);
  font-size: 11.5px;
  line-height: 1.4;
}
.metric-card.ok { border-color: rgba(22, 163, 74, 0.35); background: var(--success-soft); }
.metric-card.warn { border-color: rgba(217, 119, 6, 0.35); background: var(--warning-soft); }
.metric-card.danger { border-color: rgba(220, 38, 38, 0.35); background: var(--danger-soft); }

/* Cockpit hero */
.cockpit-hero {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-4);
  background: var(--bg-elev);
}
.cockpit-hero h3 {
  font-size: 20px;
  line-height: 1.1;
  margin: 4px 0 4px;
  letter-spacing: -0.02em;
}
.cockpit-hero p { margin: 0; color: var(--text-muted); font-size: 12.5px; }
.cockpit-hero .eyebrow { font-size: 10px; margin-bottom: 0; }
.cockpit-hero.ok { border-color: rgba(22, 163, 74, 0.4); background: var(--success-soft); }
.cockpit-hero.warn { border-color: rgba(217, 119, 6, 0.4); background: var(--warning-soft); }
.cockpit-hero.danger { border-color: rgba(220, 38, 38, 0.4); background: var(--danger-soft); }
.hero-number {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
  white-space: nowrap;
}

/* Status dots */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--text-subtle);
  margin-right: 6px;
  vertical-align: middle;
}
.status-dot.ok { background: var(--success); }
.status-dot.warn { background: var(--warning); }
.status-dot.danger { background: var(--danger); }

/* Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 650;
  border: 1px solid transparent;
}
.danger-pill { background: var(--danger-soft); color: var(--danger); }

/* Progress */
progress {
  width: 100%;
  height: 8px;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-subtle);
}
progress::-webkit-progress-bar { background: var(--bg-subtle); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }

/* Code/pre */
pre, code { font-family: var(--font-mono); font-size: 12.5px; }
pre { white-space: pre-wrap; margin: 0; }

/* ---------- PII summary, glossary, KB preview (modal-internal) ---------- */
.pii-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-2);
  margin: var(--sp-2) 0;
}
.pii-summary-card {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pii-summary-head { display: flex; justify-content: space-between; align-items: center; }
.pii-summary-count {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 600;
}

.manual-row {
  display: grid;
  grid-template-columns: 170px 1fr auto auto;
  gap: var(--sp-2);
  align-items: center;
}
.manual-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
}
.manual-remove {
  border: none;
  background: transparent;
  color: var(--danger);
  font-weight: 800;
  cursor: pointer;
  padding: 0 4px;
}
.manual-pii-card {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.quick-pii-row {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin: var(--sp-2) 0 var(--sp-3);
}

.glossary-form {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin: var(--sp-2) 0;
}
.glossary-form-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--sp-3);
  margin-bottom: 4px;
}

.kb-preview-head {
  padding: 0 0 var(--sp-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-3);
}
.kb-preview-body {
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding-right: 4px;
}
.kb-preview-chunk {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
  background: var(--bg-elev);
}
.kb-preview-chunk-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  margin-bottom: 8px;
}
.kb-preview-chunk-text {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

.onnx-panel {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin-top: var(--sp-3);
  background: var(--bg-elev);
}
.onnx-panel h4 { margin: 0 0 var(--sp-2); font-size: 13.5px; }
.onnx-panel-files { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 var(--sp-3); }
.onnx-panel-file {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(230px, 2fr) auto auto;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.onnx-panel-file-name { font-family: var(--font-mono); font-size: 12.5px; }
.onnx-panel-status-ok { color: var(--success); }
.onnx-panel-status-missing { color: var(--danger); }
.onnx-panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.onnx-warning {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  padding: 8px 10px;
  font-size: 12.5px;
}
@media (max-width: 720px) {
  .onnx-panel-file { grid-template-columns: 1fr; }
}

/* Outlook-mail-picker table */
.om-check-col { width: 54px; text-align: center; }
.om-table td:first-child, .om-table th:first-child { text-align: center; vertical-align: middle; }
.om-table td { padding-top: 11px; padding-bottom: 11px; }
.om-table td:nth-child(2) { font-size: 14px; line-height: 1.45; }
.om-table td:nth-child(2) b { font-size: 14.5px; }
.om-help {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.om-sel-count {
  font-weight: 600;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  font-size: 12px;
}
.table input[type="checkbox"], .om-chk, #om-chk-all {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- Provider card (settings) ---------- */
.provider-card .small { margin: 8px 0 10px; }
.small { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .topbar { grid-template-columns: 1fr; }
  .topbar-brand { grid-column: 1; }
  .topbar-subtitle { grid-column: 1; }
  .controls { grid-row: 3; grid-column: 1; justify-content: flex-start; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 1fr; }
  /* v4.1.2 (Feature 2): Sidebar wird zum overlay-baren Slide-in-Panel statt komplett ausgeblendet. */
  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 220;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
    will-change: transform;
  }
  .sidebar.open { transform: translateX(0); }
  /* Höhere Spezifität, damit die (später im Stylesheet stehende) Default-Regel
     `.sidebar-toggle { display:none }` unter 900px nicht gewinnt. */
  .topbar-brand .sidebar-toggle { display: inline-grid; }
  .grid2 { grid-template-columns: 1fr; }
  .modal-card { width: calc(100vw - 16px); max-height: 94vh; min-width: 0; }
  .manual-row { grid-template-columns: 1fr; }
  .manual-row .btn { width: 100%; }
  .msg.user { max-width: 92%; }
  .messages { padding: var(--sp-4); }
  .composer { padding: 6px var(--sp-3) var(--sp-3); }
  .topbar { padding: var(--sp-3); }
  .cockpit-hero { align-items: flex-start; flex-direction: column; }
  .row-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .row-actions .btn { width: 100%; }
}

/* ---------- Subtle entrance animation for messages ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg { animation: fadeUp 0.22s ease-out; }

/* ---------- Focus visibility (a11y) ---------- */
:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
button:focus-visible, .icon-btn:focus-visible { box-shadow: 0 0 0 3px var(--accent-ring); }

/* ============================================================================
 * v3.3: Styles für Profile-Picker, PII-Testmodus, Audit-Dashboard
 * ========================================================================= */

/* Profile-Badge an Konversation in Sidebar */
.conv-profile-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
}

/* v3.6.0: Tag-Chips in der Konversations-Sidebar */
.conv-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.conv-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.10);
  color: #4338ca;
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-tag-more {
  background: rgba(107, 114, 128, 0.12);
  color: #4b5563;
  cursor: help;
}

/* v3.6.1: Streaming-Cursor und unfertige Zeile während Live-Markdown-Render */
.streaming-line {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.streaming-code {
  margin: 8px 0;
  padding: 8px 10px;
  background: #1f2937;
  color: #f9fafb;
  border-radius: 6px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12.5px;
  overflow-x: auto;
}
.stream-cursor {
  display: inline-block;
  margin-left: 1px;
  animation: stream-blink 1s steps(2, start) infinite;
  color: var(--accent, #3b82f6);
  font-weight: 400;
}
@keyframes stream-blink {
  to { visibility: hidden; }
}

/* v3.6.2: Schnell-Aktionen-Toolbar unter AI-Antworten */
.msg-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.msg:hover .msg-quick-actions {
  opacity: 1;
}
.msg.ai .msg-quick-actions {
  /* Auf Touch-Geräten ist :hover unzuverlässig — dauerhaft anzeigen bei Touch-Optimierung
     wäre noch besser, aber 50% Opacity reicht als sichtbarer Hinweis. */
}
.msg-quick-action {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.1s ease;
}
.msg-quick-action:hover {
  background: var(--accent-soft, rgba(59, 130, 246, 0.12));
  color: var(--accent, #3b82f6);
  border-color: var(--accent, #3b82f6);
}

/* v3.6.2: Multi-Select-Toolbar + Checkboxen in Sidebar */
.conv-select-bar {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.conv-select-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.conv-select-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
}
.conv-select-toggle:hover {
  background: var(--bg-elev);
  color: var(--text);
}
.conv-select-toggle.active {
  background: var(--accent-soft, rgba(59, 130, 246, 0.12));
  color: var(--accent, #3b82f6);
  border-color: var(--accent, #3b82f6);
}
.conv-select-icon {
  font-size: 14px;
  line-height: 1;
}
.conv-select-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.conv-select-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  flex: 1;
  min-width: 0;
}
.btn.small {
  padding: 3px 8px;
  font-size: 11px;
}
.conv-checkbox {
  font-size: 16px;
  padding: 0 8px;
  color: var(--accent, #3b82f6);
  display: flex;
  align-items: center;
}
.conv.selected {
  background: var(--accent-soft, rgba(59, 130, 246, 0.12));
}

/* Profile-Picker */
.profile-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.profile-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.profile-option:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.profile-option.selected { border-color: var(--accent); background: var(--accent-soft); }
.profile-option input[type="radio"] { margin-top: 4px; }
.profile-name { font-weight: 600; font-size: 13.5px; }
.profile-desc { color: var(--text-muted); }
.pii-required { color: var(--accent); font-weight: 600; }
.profile-override {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.profile-override summary { cursor: pointer; font-weight: 550; padding: 6px 0; }
.profile-override textarea {
  width: 100%; margin-top: 8px;
  padding: 8px 10px; font-family: inherit; font-size: 13px;
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-md);
  outline: none;
  box-sizing: border-box;
  resize: vertical;
}

/* PII-Testmodus */
.pii-highlight-box {
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  line-height: 1.7;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
}
.pii-highlight-box mark {
  font-weight: 500;
}
.pii-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.pii-legend-item {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: #1f2937;
  border: 1px solid rgba(0,0,0,0.08);
}

/* Audit-Dashboard */
.audit-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 8px 0;
}
.stat-card {
  padding: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.stat-card.stat-wide { grid-column: 1 / -1; }
.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}
.stat-val { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat-val.small { font-size: 13.5px; font-weight: 500; }
.stat-hint { margin-top: 2px; color: var(--text-muted); }
.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-top: 4px;
}
.audit-table th {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.audit-table td {
  padding: 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.audit-table code { font-family: ui-monospace, monospace; font-size: 11.5px; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge.ok { background: #d1fae5; color: #065f46; }
.badge.err { background: #fee2e2; color: #991b1b; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.small { font-size: 10px; padding: 1px 5px; }

/* ============================================================================
 * v3.3.2: Styles für Message-Actions (Fork/Edit), Audit-Filter, Custom-Patterns,
 * Tastenkürzel-Modal
 * ========================================================================= */

/* Hover-Actions auf einzelnen Nachrichten — sichtbar nur beim Hover, klein und dezent */
.msg { position: relative; }
.msg-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.msg:hover .msg-actions { opacity: 1; }
.msg-action {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.msg-action:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Audit-Log-Filter-Bar */
.audit-filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.audit-filter-bar input[type="search"],
.audit-filter-bar select {
  padding: 6px 10px;
  font-size: 13px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  box-sizing: border-box;
}
.audit-filter-bar input[type="search"] {
  flex: 1;
  min-width: 200px;
}
.audit-filter-bar select { min-width: 160px; }
.audit-filter-bar input[type="search"]:focus,
.audit-filter-bar select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Tastenkürzel-Modal: kbd-Element wie auf MDN/GitHub */
kbd {
  display: inline-block;
  padding: 2px 7px;
  font-family: ui-monospace, 'Segoe UI Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--text);
  line-height: 1.2;
}

/* Custom-Pattern-Tabelle: kleinere Inputs in Action-Spalte */
.btn.small {
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 500;
}

/* Badge-Größenvariante für Pattern-Liste */
.audit-log-table .badge { padding: 1px 6px; font-size: 11px; }

/* v3.3.3 (Stufe 2): Recovery-Wizard mit Schritt-Anzeige */
.wizard-step { padding: 4px 0; }
.wizard-stepper { display: flex; align-items: center; gap: 0; margin-bottom: 8px; }
.wizard-dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-elev); border: 2px solid var(--border);
  color: var(--text-muted); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.wizard-dot.active { background: var(--accent); border-color: var(--accent); color: white; }
.wizard-dot.done { background: var(--success, #16a34a); border-color: var(--success, #16a34a); color: white; }
.wizard-line { flex: 1; height: 2px; background: var(--border); margin: 0 4px; }
.wizard-line.done { background: var(--success, #16a34a); }
.wizard-warning {
  margin: 12px 0; padding: 12px 14px;
  background: rgba(212, 160, 23, 0.1); border-left: 3px solid #d4a017;
  border-radius: 0 var(--r-md) var(--r-md) 0; font-size: 13.5px;
}
.wizard-checklist { margin-top: 18px; padding: 12px 14px; background: var(--bg-elev); border-radius: var(--r-md); }
.wizard-checklist label { display: block; margin: 6px 0; cursor: pointer; font-size: 13.5px; }
.wizard-checklist label input { margin-right: 8px; }
.recovery-codes-box {
  margin: 12px 0; padding: 14px 16px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md);
  font-family: ui-monospace, 'Segoe UI Mono', monospace;
}
.recovery-codes-box table { width: 100%; border-collapse: collapse; }
.recovery-codes-box td { padding: 4px 0; border-bottom: 1px dotted var(--border); }
.recovery-codes-box h4 { font-family: var(--font-sans, system-ui); }

/* v3.3.22: Drag&Drop-Feedback für KB-Card. Beim Hover über die Card mit gezogener Datei
   wird ein deutlich sichtbarer Rahmen gezeigt, damit der User weiß: hier loslassen. */
.drag-active {
  outline: 2px dashed var(--accent, #4a90e2);
  outline-offset: -4px;
  background: var(--accent-bg, rgba(74, 144, 226, 0.06));
}

/* v3.3.23: Bulk-Action-Bar für KB-Multi-Select. Erscheint sobald Checkboxen markiert sind. */
.kb-bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin: 10px 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.kb-bulk-bar #kb-bulk-count {
  font-weight: 600;
  margin-right: 8px;
}

/* v3.3.24: Session-Countdown-Badge in der Topbar. Klassen-States:
   - default (>2 min Rest): neutral
   - warn (≤2 min): orange/Akzent
   - critical (≤30 s): rot, pulsiert dezent */
.session-pill {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text-muted);
  border: 1px solid var(--border);
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}
.session-pill.warn {
  background: rgba(255, 165, 0, 0.12);
  border-color: rgba(255, 165, 0, 0.4);
  color: #cc6600;
}
.session-pill.critical {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.5);
  color: #b91c1c;
  animation: session-pulse 1.4s ease-in-out infinite;
}
@keyframes session-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* v3.3.28: Inline-Download-Progress-Balken in der Komponenten-Card.
   Ersetzt einen Install-Button während der laufende Download Fortschritt zeigt. */
.dl-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}
.dl-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.dl-progress-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
}
.dl-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-elev, #f3f4f6);
  border-radius: 999px;
  overflow: hidden;
}
.dl-progress-fill {
  height: 100%;
  background: var(--accent, #3b82f6);
  transition: width 0.25s ease;
  border-radius: 999px;
}
.dl-progress-fill.done {
  background: var(--success, #16a34a);
}
.dl-cancel {
  font-size: 10px !important;
  padding: 2px 6px !important;
}

/* ============================================================================
 * v4.1.1 — UX-Verbesserungen (Feature 1-13)
 * ========================================================================= */

/* Feature 1: Anbieter-Risiko-Badge in der Kopfzeile */
.provider-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.provider-risk {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}
.provider-risk.risk-local    { background: #dcfce7; color: #166534; border-color: #86efac; }
.provider-risk.risk-external { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.provider-risk.risk-browser  { background: #ffedd5; color: #9a3412; border-color: #fdba74; }
.provider-risk.risk-unknown  { background: var(--bg-elev); color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .provider-risk.risk-local    { background: rgba(22,163,74,.22); color: #86efac; border-color: rgba(134,239,172,.4); }
[data-theme="dark"] .provider-risk.risk-external { background: rgba(220,38,38,.22); color: #fca5a5; border-color: rgba(252,165,165,.4); }
[data-theme="dark"] .provider-risk.risk-browser  { background: rgba(154,52,18,.28); color: #fdba74; border-color: rgba(253,186,116,.4); }

/* Feature 8: Modell-Empfehlung — dezenter Info-Marker */
.model-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
}

/* Feature 3: Werkzeuge-Menü-Gruppen */
.tools-group { display: grid; gap: 1px; }
.tools-group + .tools-group { margin-top: var(--sp-2); }
.tools-group-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 4px 10px 2px;
  user-select: none;
}

/* Feature 2: Kommandopalette */
.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
}
[data-theme="dark"] .cmd-palette-overlay { background: rgba(0, 0, 0, 0.5); }
.cmd-palette {
  width: min(560px, calc(100vw - 32px));
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: fadeUp 0.14s ease-out;
}
.cmd-palette-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  font-size: 15px;
  background: transparent;
  color: var(--text);
  outline: none;
}
.cmd-palette-list {
  max-height: 50vh;
  overflow-y: auto;
  padding: 6px;
}
.cmd-palette-item {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
}
.cmd-palette-item.active { background: var(--accent-soft); color: var(--accent); }
.cmd-palette-empty { padding: 14px 12px; color: var(--text-muted); font-size: 13px; text-align: center; }

/* Feature 6: PII-Risiko-Badges + Zusammenfassung */
.pii-risk-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
}
.pii-risk-hoch   { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.pii-risk-mittel { background: #ffedd5; color: #9a3412; border-color: #fdba74; }
.pii-risk-normal { background: var(--bg-elev); color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .pii-risk-hoch   { background: rgba(220,38,38,.22); color: #fca5a5; }
[data-theme="dark"] .pii-risk-mittel { background: rgba(154,52,18,.28); color: #fdba74; }
[data-theme="dark"] .pii-risk-normal { background: rgba(255,255,255,.06); color: var(--text-muted); }
.pii-risk-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.pii-risk-hint { font-size: 12px; color: var(--text-muted); }

/* Feature 5: Vorher/Nachher-Diff im PII-Review */
.pii-diff-grid { margin-top: 6px; }
.pii-diff-head { margin: 0 0 6px; font-size: 12.5px; color: var(--text-muted); }
.pii-diff-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.pii-diff-sent { background: var(--success-soft); }
.pii-hl-original {
  background: #fde68a;
  color: #713f12;
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 600;
}
.pii-hl-pseudonym {
  background: #bfdbfe;
  color: #1e3a8a;
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 600;
}
[data-theme="dark"] .pii-hl-original  { background: rgba(253,230,138,.28); color: #fde68a; }
[data-theme="dark"] .pii-hl-pseudonym { background: rgba(191,219,254,.24); color: #bfdbfe; }

/* Feature 10: Vorlagen-Favoriten + Kategorie-Filter */
.tpl-fav-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  padding: 2px 4px;
  border-radius: 6px;
}
.tpl-fav-btn.active { color: #f59e0b; }
.tpl-fav-btn:hover { background: var(--bg-hover); }
.tpl-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.tpl-cat-filter {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
}

/* Feature 13: Barrierefreiheit — kräftigerer, nicht abschneidbarer Fokusrahmen */
a:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
.side-action:focus-visible,
.cmd-palette-item:focus-visible,
.tpl-fav-btn:focus-visible,
.model-hint:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .cmd-palette, .msg { animation: none; }
  .thinking-dots span, .sidebar { animation: none; transition: none; }
}

/* ============================================================================
 * v4.1.2 — UX-Ausbau (Features 1,2,5,6,7,9,10,11)
 * ========================================================================= */

/* Feature 2: Hamburger + Backdrop. Hamburger nur unter 900px sichtbar (Media-Query oben). */
.sidebar-toggle { display: none; }
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(1px);
}
.sidebar-backdrop.hidden { display: none !important; }
@media (min-width: 901px) {
  /* Auf breiten Fenstern nie ein Overlay — Sidebar ist ohnehin fest sichtbar. */
  .sidebar-backdrop { display: none !important; }
}

/* Feature 1: Copy-Button an Code-Blöcken */
.msg.ai pre.code-block { position: relative; }
.code-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.code-copy-btn::before { content: "⧉"; }
.code-copy-btn.copied::before { content: "✓"; }
.msg.ai pre.code-block:hover .code-copy-btn,
.code-copy-btn:focus-visible { opacity: 1; }
.code-copy-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.code-copy-btn.copied { color: var(--success); border-color: var(--success); opacity: 1; }

/* Feature 5: klickbarer Tag-Filter */
.conv-tag-filter { cursor: pointer; }
.conv-tag-filter:hover { background: rgba(99, 102, 241, 0.22); }
.tag-filter-active {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 8px 8px;
  padding: 5px 6px 5px 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 12px;
  color: var(--accent);
}
.tag-filter-clear {
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 999px;
}
.tag-filter-clear:hover { background: rgba(37, 99, 235, 0.16); }

/* Feature 4 + 6: Fußzeilen-Buttons (Enter-Umschalter, Schriftgröße) */
.composer-foot { flex-wrap: wrap; }
.composer-foot-spacer { flex: 1 1 20px; }
.font-scale-group { display: inline-flex; gap: 2px; }
.foot-btn {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  line-height: 1.6;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.foot-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.font-scale-group .foot-btn { min-width: 28px; text-align: center; }
.enter-mode-toggle.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Feature 7: Starter-Kacheln im Willkommens-Zustand */
.starter-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
  width: 100%;
  max-width: 560px;
  text-align: left;
}
.starter-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s, transform 0.12s;
}
.starter-tile:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.starter-tile-icon { font-size: 20px; line-height: 1; flex-shrink: 0; }
.starter-tile-label { font-weight: 500; }
@media (max-width: 640px) {
  .starter-tiles { grid-template-columns: 1fr; }
}

/* Feature 9: schwebender „Neueste"-Button */
.scroll-latest {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  animation: fadeUp 0.18s ease-out;
}
.scroll-latest:hover { border-color: var(--accent); color: var(--accent); }
.scroll-latest .icon { width: 15px; height: 15px; }
.scroll-latest.hidden { display: none !important; }

/* Feature 10: Anhänge als Chip-Liste */
.attachment { flex-wrap: wrap; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
/* flex:0 0 auto überschreibt das ältere `.attachment span { flex:1 }`, sonst würden Chips strecken. */
.attachment-list .attachment-chip { flex: 0 0 auto; }
.attachment-list .attachment-chip-label { flex: 0 1 auto; }
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 10px;
  background: var(--bg-elev);
  border: 1px solid rgba(22, 163, 74, 0.35);
  border-radius: 999px;
  font-size: 12.5px;
  max-width: 100%;
}
.attachment-chip .icon { color: var(--success); width: 15px; height: 15px; }
.attachment-chip-label {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip .attachment-remove { width: 20px; height: 20px; }
.attachment-chip .attachment-remove .icon { color: var(--text-muted); width: 13px; height: 13px; }

/* Feature 11: „Denkt …"-Indikator */
.thinking-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 2px 0;
}
.thinking-dots { display: inline-flex; gap: 4px; }
.thinking-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
  animation: thinking-bounce 1.2s infinite ease-in-out both;
}
.thinking-dots span:nth-child(1) { animation-delay: -0.24s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.12s; }
.thinking-dots span:nth-child(3) { animation-delay: 0s; }
@keyframes thinking-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* v4.1.5: Toast-/Hinweis-System (nicht-blockierende Rückmeldung mit optionalem Aktions-Button) */
#toast-host {
  position: fixed;
  top: calc(var(--topbar-h, 56px) + 12px);
  right: 16px;
  z-index: 4000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md, 12px);
  background: var(--bg-elev, #fff);
  color: var(--text, #18181b);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.toast-in { opacity: 1; transform: translateX(0); }
.toast.toast-out { opacity: 0; transform: translateX(24px); }
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast-msg { flex: 1 1 auto; white-space: pre-wrap; line-height: 1.4; }
.toast-action {
  flex: none;
  background: var(--accent-soft);
  border: 1px solid transparent;
  color: var(--accent);
  border-radius: var(--r-sm, 8px);
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.toast-action:hover { background: var(--accent); color: var(--accent-fg); }
.toast-close {
  flex: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.toast-close:hover { color: var(--text); }

/* v4.1.5: Eigenständiges Bestätigungs-Overlay (confirmModal) — liegt über allem, auch über #modal */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.42);
  opacity: 0;
  transition: opacity .15s ease;
}
.confirm-overlay.confirm-in { opacity: 1; }
.confirm-card {
  width: min(94vw, 440px);
  background: var(--bg-elev, #fff);
  color: var(--text, #18181b);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 16px);
  box-shadow: var(--shadow-lg);
  padding: 20px 22px;
  transform: translateY(8px) scale(0.98);
  transition: transform .15s ease;
}
.confirm-overlay.confirm-in .confirm-card { transform: translateY(0) scale(1); }
.confirm-title { margin: 0 0 8px; font-size: 17px; font-weight: 650; }
.confirm-msg { margin: 0 0 18px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; color: var(--text-muted); }
.confirm-foot { display: flex; justify-content: flex-end; gap: 10px; }

/* v4.1.5: Drag&Drop-Overlay auf dem Chat-Bereich (.main ist position:relative) */
.drop-overlay {
  position: absolute;
  inset: 8px;
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border: 3px dashed var(--accent);
  border-radius: var(--r-lg, 16px);
  pointer-events: none;
  backdrop-filter: blur(1px);
}
.drop-overlay.drop-overlay-visible { display: flex; }
.drop-overlay-inner {
  font-size: 18px;
  font-weight: 650;
  color: var(--accent);
  background: var(--bg-elev);
  padding: 16px 24px;
  border-radius: var(--r-md, 12px);
  box-shadow: var(--shadow-lg);
}
