/* =====================================================================
   Lumi – Design-System
   Keine externen Fonts/Assets (CSP self). Alle Maße über Token:
   Abstände 4er-Raster · Radien verschachtelt (außen = innen + Innenabstand)
   · Bedienelemente in drei Höhen · Farben mit WCAG-AA-Kontrast.
   ===================================================================== */
:root {
  /* Flächen */
  --bg: #ffffff;
  --bg-sidebar: #f8f8f9;
  --bg-elev: #ffffff;
  --surface: #f4f4f5;
  --surface-2: #ececee;
  --hover: rgba(15, 15, 20, .045);
  --active: rgba(15, 15, 20, .075);
  --border: #e6e6e9;
  --border-strong: #d4d4d9;
  /* Text (Kontrast auf Weiß: text 17:1, text-2 9:1, muted 5,3:1) */
  --text: #17171c;
  --text-2: #45454d;
  --muted: #6a6a74;
  /* Akzent & Status */
  --accent: #3f5bd8;
  --accent-hover: #3249bd;
  --accent-soft: #eef1fd;
  --accent-text: #ffffff;
  --btn-primary: #17171c;
  --btn-primary-hover: #2e2e35;
  --btn-primary-text: #ffffff;
  --danger: #c4282d;
  --danger-soft: #fdf0f0;
  --warn: #a35200;
  --warn-soft: #fdf5e7;
  --ok: #217a3a;
  --ok-soft: #ecf8ef;
  --code-bg: #f7f7f8;
  --scrim: rgba(10, 10, 14, .42);
  /* Schatten */
  --shadow-xs: 0 1px 2px rgba(16, 16, 24, .05);
  --shadow: 0 1px 2px rgba(16, 16, 24, .04), 0 2px 8px rgba(16, 16, 24, .04);
  --shadow-md: 0 2px 6px rgba(16, 16, 24, .05), 0 8px 24px rgba(16, 16, 24, .07);
  --shadow-lg: 0 4px 12px rgba(16, 16, 24, .06), 0 16px 48px rgba(16, 16, 24, .14);
  /* Abstände */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  /* Radien */
  --r-xs: 6px; --r-sm: 8px; --r-md: 10px; --r-lg: 14px; --r-xl: 18px; --r-2xl: 24px; --r-pill: 999px;
  /* Höhen */
  --h-xs: 28px; --h-sm: 32px; --h-md: 38px; --h-lg: 44px;
  --topbar-h: 56px;
  --sidebar-w: 264px;
  --drawer-w: 368px;
  --content-w: 768px;
  /* Typografie */
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: .75rem; --fs-sm: .8125rem; --fs-md: .875rem; --fs-base: .9375rem; --fs-lg: 1.0625rem;
  --tok-kw: #8b2bb9; --tok-str: #237330; --tok-num: #a65300; --tok-com: #7a7a84; --tok-fn: #1f5fbf;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c20; --bg-sidebar: #151518; --bg-elev: #26262b; --surface: #2a2a30; --surface-2: #34343a;
    --hover: rgba(255, 255, 255, .055); --active: rgba(255, 255, 255, .09);
    --border: #303036; --border-strong: #43434b; --text: #ededf1; --text-2: #c3c3cb; --muted: #9c9ca7;
    --accent: #8197ff; --accent-hover: #9aabff; --accent-soft: #252c4d; --btn-primary: #ededf1; --btn-primary-hover: #d6d6dc; --btn-primary-text: #17171c;
    --danger: #ff8a8a; --danger-soft: #3a2224; --warn: #ffc27a; --warn-soft: #382c1b; --ok: #85e09a; --ok-soft: #1b3122;
    --code-bg: #161619; --scrim: rgba(0, 0, 0, .6);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .2);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3); --shadow-lg: 0 4px 12px rgba(0, 0, 0, .35), 0 16px 48px rgba(0, 0, 0, .5);
    --tok-kw: #d0a2f7; --tok-str: #9fdc8f; --tok-num: #ffb86b; --tok-com: #80808b; --tok-fn: #8cb8ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1c20; --bg-sidebar: #151518; --bg-elev: #26262b; --surface: #2a2a30; --surface-2: #34343a;
  --hover: rgba(255, 255, 255, .055); --active: rgba(255, 255, 255, .09);
  --border: #303036; --border-strong: #43434b; --text: #ededf1; --text-2: #c3c3cb; --muted: #9c9ca7;
  --accent: #8197ff; --accent-hover: #9aabff; --accent-soft: #252c4d; --btn-primary: #ededf1; --btn-primary-hover: #d6d6dc; --btn-primary-text: #17171c;
  --danger: #ff8a8a; --danger-soft: #3a2224; --warn: #ffc27a; --warn-soft: #382c1b; --ok: #85e09a; --ok-soft: #1b3122;
  --code-bg: #161619; --scrim: rgba(0, 0, 0, .6);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .2);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3); --shadow-lg: 0 4px 12px rgba(0, 0, 0, .35), 0 16px 48px rgba(0, 0, 0, .5);
  --tok-kw: #d0a2f7; --tok-str: #9fdc8f; --tok-num: #ffb86b; --tok-com: #80808b; --tok-fn: #8cb8ff;
  color-scheme: dark;
}

/* ---------- Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: var(--fs-base); line-height: 1.55; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; font-feature-settings: "cv11", "ss01"; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--sp-3); font-weight: 650; letter-spacing: -.012em; color: var(--text); }
h1 { font-size: 1.625rem; letter-spacing: -.02em; } h2 { font-size: 1.0625rem; } h3 { font-size: .9375rem; }
p { margin: 0 0 var(--sp-3); }
code, pre, kbd { font-family: var(--mono); font-size: .875em; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
svg { width: 1.125em; height: 1.125em; flex: none; vertical-align: middle; }
/* Icon-Hüllen (span mit SVG) in Flex-Elementen exakt zentrieren */
span:has(> svg:only-child) { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }
.clamp-2 { max-width: 64ch; min-width: 24ch; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mono { font-family: var(--mono); }
.grow { flex: 1; }
.row { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.spacer { height: var(--sp-4); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); height: var(--h-md); padding: 0 var(--sp-4); border-radius: var(--r-pill); border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text); font: inherit; font-size: var(--fs-md); font-weight: 550; line-height: 1; cursor: pointer; white-space: nowrap; text-decoration: none; box-shadow: var(--shadow-xs); transition: background .15s var(--ease), border-color .15s var(--ease), color .15s, box-shadow .15s, transform .08s; }
.btn:hover { background: var(--surface); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--btn-primary); color: var(--btn-primary-text); border-color: transparent; }
.btn-primary:hover { background: var(--btn-primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, var(--border-strong)); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--hover); }
.btn-sm { height: var(--h-sm); padding: 0 var(--sp-3); font-size: var(--fs-sm); gap: 6px; }
.btn-sm svg { width: 15px; height: 15px; }
.icon-btn { width: 34px; height: 34px; padding: 0; border-radius: var(--r-md); border: 0; background: transparent; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.sm { width: var(--h-xs); height: var(--h-xs); border-radius: var(--r-sm); }
.icon-btn.sm svg { width: 16px; height: 16px; }

/* ---------- Formulare ---------- */
label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field { margin-bottom: var(--sp-5); min-width: 0; }
.field .hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 6px; line-height: 1.45; }
input[type=text], input[type=email], input[type=number], input[type=password], input[type=search], input[type=url], input[type=date], select, textarea {
  width: 100%; min-height: var(--h-md); font: inherit; font-size: var(--fs-base); color: var(--text); background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 8px 12px; box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
select { appearance: none; -webkit-appearance: none; padding-right: 36px; text-overflow: ellipsis; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a94' stroke-width='2' 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 12px center; background-size: 16px; }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--border-strong) 70%, var(--text)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; cursor: pointer; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; color: var(--text); font-size: var(--fs-md); margin: 0 0 var(--sp-2); cursor: pointer; line-height: 1.45; }
.checkbox input { margin-top: 2px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-1) var(--sp-4); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-md); max-height: 280px; overflow: auto; background: var(--bg); }
/* Raster: Felder einer Zeile richten Label, Eingabe und Hinweis aneinander aus (Subgrid) */
.grid-2, .grid-3 { display: grid; gap: 0 var(--sp-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@supports (grid-template-rows: subgrid) {
  .grid-2 > .field, .grid-3 > .field { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; align-content: start; }
  .grid-2 > .field > label:not(.checkbox), .grid-3 > .field > label:not(.checkbox) { align-self: end; }
  .grid-2 > .field > .checkbox, .grid-3 > .field > .checkbox { grid-row: 2; align-self: center; margin: 0; }
}

/* ---------- Hinweise, Badges ---------- */
.alert { display: block; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); font-size: var(--fs-md); line-height: 1.5; margin-bottom: var(--sp-4); border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.alert-info { background: var(--accent-soft); color: var(--text); border-color: color-mix(in srgb, var(--accent) 18%, transparent); }
.alert .btn { margin-left: var(--sp-2); vertical-align: middle; }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; line-height: 1; background: var(--surface); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- Schlichtes Layout (Login, Fehler) ---------- */
.plain { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: var(--sp-6); background: var(--bg-sidebar); }
.auth-card { width: 100%; max-width: 408px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-2xl); padding: var(--sp-10) var(--sp-8); box-shadow: var(--shadow-md); }
.auth-brand { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-8); }
.auth-card .logo { display: flex; align-items: center; gap: var(--sp-3); font-weight: 650; font-size: var(--fs-lg); }
/* Kundenlogo anstelle des Produktzeichens (Seitenleiste, Anmeldekarten) */
.brand-logo { display: block; flex: none; height: 26px; width: auto; max-width: 110px; object-fit: contain; }
.auth-brand .brand-logo { height: 34px; max-width: 150px; }
/* Kundenlogos sind meist für hellen Grund gestaltet – im Dunkelmodus Helligkeit umkehren, Farbtöne erhalten */
:root[data-theme="dark"] .customer-logo { filter: invert(1) hue-rotate(180deg); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .customer-logo { filter: invert(1) hue-rotate(180deg); } }
.auth-card h1 { font-size: 1.375rem; margin-bottom: var(--sp-2); }
.auth-card > p { line-height: 1.55; }
.auth-card form, .auth-card > .btn { margin-top: var(--sp-6); }
.auth-card .stack { gap: var(--sp-5); }
.auth-card label { margin-bottom: var(--sp-2); }
.auth-foot { margin: var(--sp-8) 0 0; padding-top: var(--sp-5); border-top: 1px solid var(--border); color: var(--muted); font-size: var(--fs-sm); line-height: 1.55; }
.auth-card .btn { width: 100%; height: auto; min-height: var(--h-lg); padding: 10px var(--sp-5); font-size: var(--fs-base); line-height: 1.3; white-space: normal; text-align: center; }
.logo-mark { width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--btn-primary); color: var(--btn-primary-text); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.logo-mark svg { width: 16px; height: 16px; }

/* ---------- App-Shell ---------- */
.shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar { width: var(--sidebar-w); flex: none; background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; transition: margin-left .22s var(--ease); }
.shell.sidebar-collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
/* Einheitliche linke Kante: Seitenleiste 12 px + Element 10 px */
.sidebar-top { padding: 0 var(--sp-3) var(--sp-2); display: flex; flex-direction: column; gap: 2px; }
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; padding: 0 2px 0 10px; margin-bottom: 2px; }
.sidebar-brand a { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; font-size: var(--fs-base); letter-spacing: -.01em; text-decoration: none; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--r-md); color: var(--text); font: inherit; font-size: var(--fs-md); font-weight: 500; text-decoration: none; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; transition: background .12s; }
.nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item.active { background: var(--active); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; color: var(--text-2); }
.nav-label { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); padding: var(--sp-4) 10px var(--sp-1); }
.sidebar-search { padding: var(--sp-2) var(--sp-3) var(--sp-1); }
.sidebar-search input { min-height: 34px; height: 34px; padding: 0 10px; font-size: var(--fs-md); border-radius: var(--r-md); background: var(--bg); box-shadow: none; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 0 var(--sp-3) var(--sp-3); min-height: 0; }
.chat-group-title { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); padding: var(--sp-4) 10px 6px; }
.chat-link { position: relative; display: flex; align-items: center; gap: var(--sp-2); height: 34px; padding: 0 10px; border-radius: var(--r-md); color: var(--text); font-size: var(--fs-md); text-decoration: none; transition: background .12s; }
.chat-link:hover { background: var(--hover); text-decoration: none; }
.chat-link.active { background: var(--active); font-weight: 550; }
.chat-link .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-link .shared-icon { color: var(--muted); width: 14px; height: 14px; flex: none; }
/* Chat-Eintrag mit Aktionsmenü (Anpinnen, Archivieren …) – Abstand zwischen Einträgen auf Nutzerwunsch */
.chat-busy { flex: none; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--text-2); animation: chat-spin .8s linear infinite; }
@keyframes chat-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .chat-busy { animation: none; border-color: var(--text-2); } }
.chat-row { position: relative; margin-bottom: 3px; }
.chat-row .chat-link { padding-right: 36px; }
.chat-row .chat-more { position: absolute; right: var(--sp-1); top: 50%; transform: translateY(-50%); opacity: 0; transition: opacity .12s; }
.chat-row:hover .chat-more, .chat-row.menu-open .chat-more, .chat-row .chat-more:focus-visible, .chat-row:has(.chat-link.active) .chat-more { opacity: 1; }
.chat-row.menu-open .chat-link { background: var(--hover); }
@media (hover: none) { .chat-row .chat-more { opacity: 1; } }
.chat-group-toggle { display: flex; align-items: center; gap: var(--sp-1); width: 100%; border: 0; background: none; font: inherit; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-align: left; cursor: pointer; border-radius: var(--r-sm); }
.chat-group-toggle:hover { color: var(--text); }
.chat-group-toggle span { width: 14px; height: 14px; }
.chat-group-toggle svg { width: 14px; height: 14px; }
.sidebar-bottom { border-top: 1px solid var(--border); padding: var(--sp-2) var(--sp-3); }
.user-chip { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 10px; border-radius: var(--r-md); cursor: pointer; width: 100%; background: none; border: 0; font: inherit; color: var(--text); text-align: left; transition: background .12s; }
.user-chip:hover { background: var(--hover); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #a855f7)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 650; font-size: .6875rem; letter-spacing: .02em; flex: none; }
.user-chip .n { flex: 1; font-size: var(--fs-md); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; background: var(--bg); }
.topbar { height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-3); }
.topbar > .row { flex-wrap: nowrap; gap: 6px; }
.topbar .title { font-weight: 600; font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: var(--fs-md); color: var(--muted); min-width: 0; padding-left: var(--sp-2); }
.crumbs .sep { color: var(--border-strong); }
.crumbs .cur { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page { flex: 1; overflow-y: auto; }
.page-inner { max-width: 1040px; margin: 0 auto; padding: var(--sp-2) var(--sp-8) var(--sp-10); }
.page-inner.narrow { max-width: 780px; }

/* ---------- Menüs / Popover ---------- */
.menu-wrap { position: relative; }
.menu { position: absolute; z-index: 50; min-width: 240px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 6px; animation: pop .14s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.985); } to { opacity: 1; transform: none; } }
.menu.up { bottom: calc(100% + 6px); left: 0; right: 0; }
.menu.down { top: calc(100% + 6px); left: 0; }
.menu.down.right { left: auto; right: 0; }
.menu.floating { z-index: 150; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 7px 10px; border-radius: var(--r-sm); background: none; border: 0; color: var(--text); font: inherit; font-size: var(--fs-md); line-height: 1.35; text-align: left; cursor: pointer; text-decoration: none; transition: background .1s; }
.menu-item:hover { background: var(--hover); text-decoration: none; }
.menu-item:disabled { opacity: .45; cursor: not-allowed; }
.menu-item > svg, .menu-item > span:has(> svg:only-child) { width: 16px; height: 16px; color: var(--text-2); }
.menu-item > span:has(> svg:only-child) svg { width: 16px; height: 16px; }
.menu-item:has(.sub) { align-items: flex-start; }
.menu-item .sub { display: block; font-size: var(--fs-xs); color: var(--muted); margin-top: 1px; }
.menu-item .check { margin-left: auto; color: var(--accent); }
.menu-item[aria-checked="true"]::after { content: ""; width: 16px; height: 16px; margin-left: auto; flex: none; background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; padding: 8px 10px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Topbar: Modellwahl & Chips ---------- */
.model-btn { display: inline-flex; align-items: center; gap: var(--sp-2); height: var(--h-md); padding: 0 10px 0 12px; border-radius: var(--r-md); border: 0; background: transparent; color: var(--text); font: inherit; font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.01em; cursor: pointer; white-space: nowrap; max-width: 46vw; overflow: hidden; transition: background .12s; }
.model-btn:hover { background: var(--hover); }
.model-btn .prov { font-weight: 450; color: var(--muted); font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; }
.model-btn svg { width: 16px; height: 16px; color: var(--muted); }
/* Teamkontext-Chip und kleine Buttons der Topbar teilen Höhe, Rahmen und Typo */
.ctx-chip { display: inline-flex; align-items: center; gap: 6px; height: var(--h-sm); padding: 0 var(--sp-3); border-radius: var(--r-pill); font: inherit; font-size: var(--fs-sm); font-weight: 550; line-height: 1; color: var(--text-2); border: 1px solid var(--border-strong); background: var(--bg-elev); box-shadow: var(--shadow-xs); cursor: pointer; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; transition: background .15s; }
.ctx-chip:hover { background: var(--surface); color: var(--text); }
.ctx-chip svg { width: 15px; height: 15px; }
.ctx-chip .lbl { overflow: hidden; text-overflow: ellipsis; }

/* ---------- Chat ---------- */
.chat-layout { flex: 1; display: flex; min-height: 0; position: relative; }
.chat-col { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-col.drop-active::after { content: attr(data-drop-label); position: absolute; inset: var(--sp-3); z-index: 20; display: flex; align-items: center; justify-content: center; border: 2px dashed var(--accent); border-radius: var(--r-2xl); background: var(--accent-soft); color: var(--accent); font-weight: 600; pointer-events: none; }
#app-root { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-scroll { flex: 1; overflow-y: auto; scroll-behavior: auto; }
.thread { max-width: var(--content-w); margin: 0 auto; padding: var(--sp-6) var(--sp-6) var(--sp-8); }
.msg { margin: 0 0 var(--sp-8); }
.msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.msg-user .bubble { background: var(--surface); padding: 10px var(--sp-4); border-radius: var(--r-2xl); border-bottom-right-radius: var(--r-sm); max-width: 78%; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; line-height: 1.55; }
.msg-user .author { font-size: var(--fs-xs); color: var(--muted); margin: 0 var(--sp-2) var(--sp-1); }
.msg-assistant .content { overflow-wrap: anywhere; line-height: 1.65; }
.msg-meta { display: flex; align-items: center; gap: 2px; margin-top: var(--sp-2); color: var(--muted); font-size: var(--fs-xs); min-height: var(--h-xs); opacity: 0; transition: opacity .15s; }
.msg-user .msg-meta { justify-content: flex-end; }
.msg:hover .msg-meta, .msg-meta.always, .msg:focus-within .msg-meta { opacity: 1; }
.msg-meta .label { margin: 0 var(--sp-2) 0 var(--sp-1); }
.branch-nav { display: inline-flex; align-items: center; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.attachments { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 6px; max-width: 78%; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; height: var(--h-sm); padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-md); font-size: var(--fs-sm); background: var(--bg-elev); color: var(--text); text-decoration: none; max-width: 240px; cursor: pointer; box-shadow: var(--shadow-xs); }
.att-chip:hover { border-color: var(--border-strong); text-decoration: none; }
.att-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-chip svg { width: 14px; height: 14px; color: var(--muted); }
.att-chip button { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin-right: -4px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 1rem; line-height: 1; }
.att-chip button:hover { background: var(--hover); color: var(--text); }
.chat-event { display: flex; align-items: center; gap: var(--sp-3); color: var(--muted); font-size: var(--fs-xs); margin: 0 0 var(--sp-6); text-align: center; }
.chat-event::before, .chat-event::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.edit-box textarea { min-height: 80px; border-radius: var(--r-xl); }
.edit-box .row { justify-content: flex-end; margin-top: var(--sp-2); }
.empty-state { max-width: 680px; margin: 0 auto; padding: 14vh var(--sp-6) var(--sp-5); text-align: center; }
.empty-state h1 { font-size: 1.75rem; font-weight: 600; letter-spacing: -.025em; margin-bottom: var(--sp-4); }
.empty-state .alert { margin-top: var(--sp-5); display: inline-block; }
.chat-layout.new-chat .chat-col { justify-content: center; padding-bottom: 12vh; }
.chat-layout.new-chat .chat-scroll { flex: none; overflow: visible; }
.chat-layout.new-chat .empty-state { padding-top: 0; }
.cursor-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--text); margin-left: 3px; vertical-align: middle; animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
/* Statusmeldung während der Verarbeitung (vor bzw. zwischen Antworttext) */
.stream-status { display: flex; align-items: center; gap: var(--sp-2); color: var(--muted); font-size: var(--fs-md); margin-top: 6px; min-height: 22px; }
.stream-spinner { flex: none; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--text-2); animation: chat-spin .8s linear infinite; }
.stream-status-text { background: linear-gradient(90deg, var(--muted) 0%, var(--text) 50%, var(--muted) 100%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: status-shimmer 2s linear infinite; }
.stream-elapsed { font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
@keyframes status-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .stream-spinner, .stream-status-text { animation: none; } .stream-status-text { color: var(--muted); background: none; } }
.msg-error { color: var(--danger); background: var(--danger-soft); padding: 10px var(--sp-3); border-radius: var(--r-md); font-size: var(--fs-md); margin-top: var(--sp-2); }
.msg-notice { color: var(--muted); font-size: var(--fs-md); font-style: italic; margin-top: 6px; }
.msg-system { margin: calc(-1 * var(--sp-4)) 0 var(--sp-6); }
.sys-note { display: inline-flex; align-items: center; gap: var(--sp-2); height: 28px; font-size: var(--fs-sm); color: var(--text-2); background: var(--surface); border-radius: var(--r-pill); padding: 0 var(--sp-3); }
.sys-note svg { width: 14px; height: 14px; color: var(--ok); }
.sys-preview { margin-top: var(--sp-2); }

/* Werkzeugkarten */
.tool-card { border: 1px solid var(--border); border-radius: var(--r-lg); margin: var(--sp-3) 0; font-size: var(--fs-md); background: var(--bg-elev); overflow: hidden; }
.tool-card summary { min-height: 40px; padding: var(--sp-2) var(--sp-3); cursor: pointer; display: flex; align-items: center; gap: var(--sp-2); color: var(--text-2); list-style: none; transition: background .12s; }
.tool-card summary:hover { background: var(--hover); }
.tool-card summary::-webkit-details-marker { display: none; }
.tool-card summary svg { width: 15px; height: 15px; }
.tool-card[open] > summary { border-bottom: 1px solid var(--border); }
.tool-card .tool-body { padding: var(--sp-3); }
.tool-card .tool-body > :last-child { margin-bottom: 0; }
.tool-card pre { max-height: 260px; overflow: auto; margin: 0; }
.tool-card.err summary { color: var(--danger); }
.tool-card details summary.small { padding: 6px 0; min-height: 0; }

/* ---------- Markdown ---------- */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 var(--sp-4); }
.md h1, .md h2, .md h3, .md h4 { margin: var(--sp-6) 0 var(--sp-3); }
.md h1 { font-size: 1.375rem; } .md h2 { font-size: 1.1875rem; } .md h3 { font-size: 1.0625rem; } .md h4 { font-size: 1rem; }
.md ul, .md ol { padding-left: 1.4em; margin: 0 0 var(--sp-4); }
.md li { margin: var(--sp-1) 0; padding-left: 2px; }
.md li::marker { color: var(--muted); }
.md li > p { margin: 0; }
.md blockquote { margin: 0 0 var(--sp-4); padding: 2px var(--sp-4); border-left: 3px solid var(--border-strong); color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-6) 0; }
.md :not(pre) > code { background: var(--surface); border: 1px solid var(--border); padding: .1em .4em; border-radius: var(--r-xs); font-size: .84em; }
.md a { word-break: break-word; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.md a:hover { text-decoration-color: currentColor; }
/* Code und Tabellen: gemeinsame Kopfleiste */
.codeblock, .table-wrap { margin: 0 0 var(--sp-4); border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--border); }
.codeblock { background: var(--code-bg); }
.table-wrap { background: var(--bg-elev); }
.cb-head, .table-tools { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); height: 36px; padding: 0 var(--sp-1) 0 var(--sp-3); font-family: var(--font); font-size: var(--fs-xs); font-weight: 550; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--surface); }
.table-tools .tt-actions, .cb-head .tt-actions { display: flex; gap: 2px; }
.codeblock pre { margin: 0; padding: var(--sp-3) var(--sp-4); overflow-x: auto; line-height: 1.6; }
.codeblock code { font-size: .8125rem; }
.tok-kw { color: var(--tok-kw); } .tok-str { color: var(--tok-str); } .tok-num { color: var(--tok-num); } .tok-com { color: var(--tok-com); font-style: italic; } .tok-fn { color: var(--tok-fn); }
.table-scroll { overflow-x: auto; }
.md table, table.data { border-collapse: collapse; width: 100%; font-size: var(--fs-md); }
.md th, .md td, table.data th, table.data td { border-bottom: 1px solid var(--border); padding: 9px var(--sp-4); text-align: left; vertical-align: top; white-space: nowrap; }
.md th, table.data th { font-weight: 600; font-size: var(--fs-sm); color: var(--text-2); background: var(--bg-elev); position: sticky; top: 0; }
.md tbody tr:last-child td, table.data tbody tr:last-child td { border-bottom: 0; }
.md tbody tr:hover td, table.data tbody tr:hover td { background: var(--hover); }
.md td.num, .md th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Composer ---------- */
.composer-wrap { flex: none; padding: 0 var(--sp-6) var(--sp-3); }
.composer { max-width: var(--content-w); margin: 0 auto; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--r-2xl); padding: var(--sp-2); box-shadow: var(--shadow-md); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: color-mix(in srgb, var(--border-strong) 50%, var(--text)); }
.composer textarea { display: block; width: 100%; min-height: 28px; max-height: 260px; border: 0; background: transparent; resize: none; padding: var(--sp-2) 10px var(--sp-1); font-size: var(--fs-base); line-height: 1.5; box-shadow: none; border-radius: 0; }
.composer textarea:hover { border: 0; }
.composer textarea:focus { box-shadow: none; }
.composer textarea[readonly] { color: var(--text-2); }
.composer-row { display: flex; align-items: center; gap: var(--sp-1); }
.composer .pending { display: flex; gap: 6px; flex-wrap: wrap; padding: var(--sp-1) var(--sp-1) var(--sp-2); }
.send-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--btn-primary); color: var(--btn-primary-text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; margin-left: auto; transition: background .15s, opacity .15s, transform .08s; }
.send-btn:hover { background: var(--btn-primary-hover); }
.send-btn:active { transform: scale(.96); }
.send-btn:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; transform: none; }
.send-btn svg { width: 18px; height: 18px; }
.composer-hint { text-align: center; font-size: var(--fs-xs); color: var(--muted); padding-top: 10px; }
.dict-status { margin-left: var(--sp-1); font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn.recording { color: #fff; background: var(--danger); animation: pulse-rec 1.4s infinite; }
@keyframes pulse-rec { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 45%, transparent); } 50% { box-shadow: 0 0 0 6px transparent; } }

/* ---------- Dateibibliothek ---------- */
.drawer { width: var(--drawer-w); flex: none; border-left: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; min-height: 0; }
.drawer-head { height: var(--topbar-h); flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 var(--sp-2) 0 var(--sp-5); border-bottom: 1px solid var(--border); font-weight: 600; font-size: var(--fs-base); }
.drawer-title { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.drawer-sub { font-size: var(--fs-xs); font-weight: 450; color: var(--muted); }
.btn-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-2); font-size: var(--fs-xs); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.btn.is-active { background: var(--surface); }
.file-item.is-excluded .file-icon, .file-item.is-excluded .fn { opacity: .5; }
.file-item.is-excluded .fn { text-decoration: line-through; text-decoration-color: var(--muted); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-4); }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); padding: var(--sp-5) var(--sp-4); text-align: center; color: var(--text-2); font-size: var(--fs-md); line-height: 1.5; cursor: pointer; margin-bottom: var(--sp-4); transition: border-color .15s, background .15s, color .15s; }
.dropzone .small { display: inline-block; margin-top: var(--sp-1); color: var(--muted); font-size: var(--fs-xs); }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.file-item { position: relative; display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-2); border-radius: var(--r-md); transition: background .12s; }
.file-item:hover { background: var(--hover); }
.file-item.is-version { margin-left: var(--sp-5); }
.file-item.is-version::before { content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 2px; border-radius: 1px; background: var(--border); }
.file-icon { width: 36px; height: 36px; border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-2); flex: none; font-size: .625rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.file-icon.k-csv, .file-icon.k-spreadsheet { background: #e7f6ec; color: #1f7a38; }
.file-icon.k-pdf { background: #fdecec; color: #b42328; }
.file-icon.k-docx { background: #e9efff; color: #3149c4; }
.file-icon.k-pptx { background: #fff0e6; color: #c2410c; }
.file-icon.k-image { background: #f4ebff; color: #7a2a91; }
.file-icon.k-svg { background: #e3f8f1; color: #08765a; }
.file-icon.k-ai { background: #fff3e2; color: #c2500a; }
.file-meta { flex: 1; min-width: 0; }
.file-meta .fn { font-size: var(--fs-md); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta .fs { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-actions { display: flex; gap: 0; opacity: .55; transition: opacity .12s; }
.file-item:hover .file-actions, .file-item:focus-within .file-actions { opacity: 1; }

/* ---------- Dialoge ---------- */
.modal-backdrop { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); z-index: 100; display: flex; align-items: center; justify-content: center; padding: var(--sp-5); animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column; animation: pop .16s var(--ease); }
.modal.wide { max-width: 1000px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-3) var(--sp-2) var(--sp-6); }
.modal-head h2 { margin: 0; font-size: var(--fs-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: var(--sp-2) var(--sp-6) var(--sp-6); overflow-y: auto; }
.modal-body > :last-child { margin-bottom: 0; }
.modal-body h3 { margin: var(--sp-5) 0 var(--sp-2); }
.modal-foot { padding: var(--sp-4) var(--sp-6); display: flex; justify-content: flex-end; gap: var(--sp-2); border-top: 1px solid var(--border); }
.modal-foot:empty { display: none; }
.modal .list-table td { padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
.modal .list-table td:first-child { padding-left: 0; }
.modal .list-table td:last-child { padding-right: 0; text-align: right; }
.preview-text { white-space: pre-wrap; font-family: var(--mono); font-size: var(--fs-sm); background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-4); max-height: 60vh; overflow: auto; }
.preview-img { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; border-radius: var(--r-md); }
.preview-frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--r-md); }

/* ---------- Toast & Fortschritt ---------- */
.toast-wrap { position: fixed; bottom: var(--sp-6); left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: var(--sp-2); align-items: center; pointer-events: none; }
.toast { background: var(--btn-primary); color: var(--btn-primary-text); padding: 10px var(--sp-4); border-radius: var(--r-md); font-size: var(--fs-md); font-weight: 500; box-shadow: var(--shadow-lg); max-width: min(520px, calc(100vw - 32px)); animation: pop .16s var(--ease); pointer-events: auto; }
.toast.err { background: var(--danger); color: #fff; }
.upload-progress { position: fixed; left: 50%; bottom: var(--sp-6); transform: translateX(-50%); z-index: 90; width: min(420px, calc(100vw - 32px)); background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: var(--sp-3) var(--sp-4); }
.upload-progress .up-label { font-size: var(--fs-md); margin-bottom: var(--sp-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-progress .up-track { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.upload-progress .up-bar { height: 100%; width: 2%; border-radius: 3px; background: var(--accent); transition: width .25s var(--ease); }

/* ---------- Seiten (Admin, Prompts) ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin: var(--sp-4) 0 var(--sp-6); flex-wrap: wrap; min-height: var(--h-md); }
.page-head h1 { margin: 0; display: flex; align-items: center; gap: var(--sp-3); }
.page-head + p, .page-head + .muted { margin-top: calc(-1 * var(--sp-3)); margin-bottom: var(--sp-5); }
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--sp-6); margin-bottom: var(--sp-5); box-shadow: var(--shadow); }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card h2 { font-size: var(--fs-lg); margin-bottom: var(--sp-4); display: flex; align-items: center; gap: var(--sp-2); }
.card h2 + p.small, .card h2 + p.muted { margin-top: calc(-1 * var(--sp-2)); }
.card h3 { margin-top: var(--sp-5); }
.card > :last-child { margin-bottom: 0; }
.card form > :last-child { margin-bottom: 0; }
/* Tabellen in Karten laufen bis zum Kartenrand; Titel und Zellen teilen die Innenkante */
.table-card { padding: 0; overflow-x: auto; }
.table-card > h2, .table-card > h3 { padding: var(--sp-5) var(--sp-6) var(--sp-2); margin: 0; }
.table-card > p { padding: 0 var(--sp-6); }
.list-table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.list-table th { text-align: left; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; letter-spacing: .01em; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); white-space: nowrap; }
.list-table td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); vertical-align: middle; line-height: 1.45; }
.list-table tr:last-child td { border-bottom: 0; }
.list-table tbody tr { transition: background .1s; }
.list-table tbody tr:hover td { background: var(--hover); }
.table-card .list-table th:first-child, .table-card .list-table td:first-child { padding-left: var(--sp-6); }
.table-card .list-table th:last-child, .table-card .list-table td:last-child { padding-right: var(--sp-6); }
.list-table td.num, .list-table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list-table td:first-child, .list-table td:has(> .badge:only-child), .list-table td:has(> .btn) { white-space: nowrap; }
.list-table td a { font-weight: 550; }
.list-table td .row { flex-wrap: nowrap; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.stat { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--sp-5); box-shadow: var(--shadow); }
.stat .v { font-size: 1.625rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .l { font-size: var(--fs-sm); color: var(--muted); margin-top: var(--sp-1); }
.policy-select { width: auto; min-height: var(--h-sm); padding: 4px 32px 4px 10px; font-size: var(--fs-sm); background-position: right 10px center; }
.policy-ALLOWED { color: var(--ok); } .policy-WARNING { color: var(--warn); } .policy-FORBIDDEN { color: var(--danger); }
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-5); overflow-x: auto; }
.tab { display: inline-flex; align-items: center; height: 40px; padding: 0 var(--sp-3); border: 0; background: none; font: inherit; font-size: var(--fs-md); font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; white-space: nowrap; transition: color .12s, border-color .12s; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.page-head .tabs { border-bottom: 0; margin: 0; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; height: var(--h-md); border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border); flex: none; }
.seg { display: inline-flex; align-items: center; padding: 0 var(--sp-3); border: 0; border-radius: var(--r-pill); background: none; font: inherit; font-size: var(--fs-sm); font-weight: 550; color: var(--muted); cursor: pointer; white-space: nowrap; transition: background .12s, color .12s, box-shadow .12s; }
.seg:hover { color: var(--text); }
.seg.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-xs); }
.seg:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.filter-bar { margin-bottom: var(--sp-5); flex-wrap: nowrap; }
.filter-bar .grow { min-width: 0; }
.tag-filter:not(:empty) { margin: calc(-1 * var(--sp-2)) 0 var(--sp-4); }
@media (max-width: 640px) { .filter-bar { flex-wrap: wrap; } .filter-bar .grow { flex-basis: 100%; } }
.prompt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: var(--sp-4); }
.prompt-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--sp-5); cursor: pointer; display: flex; flex-direction: column; gap: var(--sp-2); box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s, transform .15s var(--ease); text-align: left; font: inherit; color: var(--text); }
.prompt-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.prompt-card .pt { font-weight: 650; font-size: var(--fs-base); }
.prompt-card .pd { font-size: var(--fs-md); color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tag { display: inline-flex; align-items: center; height: 22px; font-size: var(--fs-xs); font-weight: 500; padding: 0 var(--sp-2); border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-2); margin: 0 var(--sp-1) var(--sp-1) 0; cursor: pointer; border: 0; font-family: inherit; transition: background .12s; }
.tag:hover { background: var(--active); }
.tag.active { background: var(--accent); color: var(--accent-text); }
.prompt-body { white-space: pre-wrap; background: var(--surface); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); font-size: var(--fs-md); max-height: 300px; overflow: auto; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-md); margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.page ul.plain-list, .card ul { padding-left: 1.2em; margin: 0 0 var(--sp-3); }
.card li { margin: 6px 0; }
.card li .badge { margin-right: 6px; }

/* Modellauswahl */
.model-pick .nowrap-row { flex-wrap: nowrap; gap: var(--sp-1); }
.model-pick .nowrap-row select { flex: 1; min-width: 0; }
.model-pick .nowrap-row .icon-btn { height: var(--h-md); width: var(--h-md); }
.model-pick .nowrap-row:has(select:not(.hidden)) + input { margin-top: var(--sp-2); }
.model-pick .nowrap-row:has(select.hidden) { display: none; }
.grid-2 > .field.model-pick, .grid-3 > .field.model-pick { display: block; }

/* Mein Unternehmen */
.row.space-between { justify-content: space-between; }
.row.space-between > h2 { margin: 0; }
.form-actions { justify-content: flex-end; margin: calc(-1 * var(--sp-1)) 0 var(--sp-6); }
.brand-row { display: flex; gap: var(--sp-5); align-items: flex-start; }
.logo-preview { flex: none; width: 200px; height: 96px; display: flex; align-items: center; justify-content: center; padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-md); background: repeating-conic-gradient(var(--surface) 0% 25%, var(--bg-elev) 0% 50%) 50% / 16px 16px; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview.empty { background: var(--surface); color: var(--muted); font-size: var(--fs-sm); }
input[type=file] { font: inherit; font-size: var(--fs-md); color: var(--text-2); max-width: 100%; }
input[type=file]::file-selector-button { font: inherit; font-size: var(--fs-sm); font-weight: 550; height: var(--h-sm); padding: 0 var(--sp-3); margin-right: var(--sp-3); border-radius: var(--r-pill); border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text); cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--surface); }
input[type=color] { width: 56px; height: var(--h-md); padding: 3px; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--bg-elev); cursor: pointer; flex: none; }
.color-field .row { flex-wrap: nowrap; gap: var(--sp-3); }
.color-field .hint { margin: 0; }
.mail-preview { display: block; width: 100%; height: 760px; border: 1px solid var(--border); border-radius: var(--r-md); background: #f3f3f5; margin-bottom: var(--sp-3); }
@media (max-width: 600px) { .brand-row { flex-direction: column; } .logo-preview { width: 100%; } }

/* Bestätigungskarten */
.confirm-card { border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-soft); border-radius: var(--r-lg); padding: var(--sp-4); margin: var(--sp-3) 0; display: flex; flex-direction: column; gap: var(--sp-3); color: var(--text); }
.confirm-card.status-executed { border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: var(--ok-soft); }
.confirm-card.status-rejected, .confirm-card.status-failed, .confirm-card.status-expired { border-color: var(--border-strong); background: var(--surface); }
.confirm-head { display: flex; align-items: center; gap: var(--sp-2); font-weight: 600; }
.confirm-card .table-wrap { margin: 0; }
.confirm-card .row { justify-content: flex-end; }

/* Nutzungsdiagramm, Folienvorschau */
.usage-chart { width: 100%; height: auto; display: block; }
.usage-chart .bar { fill: var(--accent); }
.usage-chart .bar:hover { fill: var(--text); }
.usage-chart .axis { stroke: var(--border-strong); }
.usage-chart .lbl { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.slide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-3); }
.slide-card { aspect-ratio: 16 / 9; border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); background: var(--bg-elev); box-shadow: var(--shadow); overflow: auto; font-size: var(--fs-sm); }
.slide-card ul { margin: 6px 0 0 16px; padding: 0; }
.slide-no { font-size: .6875rem; color: var(--muted); }
.slide-title { font-weight: 650; font-size: var(--fs-base); }
.slide-notes { margin-top: 6px; font-size: var(--fs-xs); color: var(--muted); font-style: italic; }

/* ---------- Responsiv ---------- */
.mobile-only { display: none; }
@media (max-width: 1100px) {
  .drawer { position: absolute; right: 0; top: 0; bottom: 0; z-index: 40; box-shadow: var(--shadow-lg); }
}
@media (max-width: 1000px) {
  .model-btn .prov { display: none; }
}
@media (max-width: 820px) {
  .mobile-only { display: inline-flex; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; box-shadow: var(--shadow-lg); }
  .shell:not(.sidebar-open) .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
  .shell.sidebar-open::after { content: ""; position: fixed; inset: 0; background: var(--scrim); z-index: 55; }
  .drawer { width: 100%; }
  .thread { padding: var(--sp-4) var(--sp-4) var(--sp-5); }
  .composer-wrap { padding: 0 var(--sp-3) var(--sp-3); }
  .msg-user .bubble, .attachments { max-width: 90%; }
  .page-inner { padding: var(--sp-2) var(--sp-4) var(--sp-8); }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: var(--sp-2); }
  .msg-meta { opacity: 1; }
  .card { padding: var(--sp-5); }
  .table-card > h2, .table-card > h3 { padding: var(--sp-4) var(--sp-5) var(--sp-2); }
  .table-card .list-table th:first-child, .table-card .list-table td:first-child { padding-left: var(--sp-5); }
  .table-card .list-table th:last-child, .table-card .list-table td:last-child { padding-right: var(--sp-5); }
  .file-actions { opacity: 1; }
}
@media (max-width: 600px) {
  .ctx-chip { max-width: 110px; }
  .topbar .lbl { display: none; }
  .topbar { padding: 0 6px; gap: var(--sp-1); }
  .model-btn { max-width: 52vw; padding: 0 6px; font-size: var(--fs-base); }
  .composer-hint { display: none; }
  .crumbs .parent, .crumbs .sep { display: none; }
  .modal-backdrop { padding: var(--sp-3); align-items: flex-end; }
  .modal { max-height: 92vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Bilderzeugung & -bearbeitung ---------- */
.img-results { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); margin: var(--sp-3) 0; max-width: 480px; }
.img-results.multi { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 720px; }
.img-result { margin: 0; }
.img-open { display: block; width: 100%; padding: 0; border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); overflow: hidden; cursor: zoom-in; }
.img-open img { display: block; width: 100%; height: auto; }
.img-open:hover { border-color: var(--border-strong); }
.img-actions { display: flex; align-items: center; gap: 2px; margin-top: var(--sp-1); min-height: var(--h-xs); }
.img-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-skeleton { aspect-ratio: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2); border-radius: var(--r-xl); color: var(--muted); font-size: var(--fs-sm);
  background: linear-gradient(110deg, var(--surface) 30%, color-mix(in srgb, var(--surface) 60%, var(--bg-elev)) 50%, var(--surface) 70%); background-size: 200% 100%; animation: img-shimmer 1.6s linear infinite; }
.img-skeleton svg { width: 28px; height: 28px; }
@keyframes img-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .img-skeleton { animation: none; } }
.img-edit-chip img { width: 20px; height: 20px; object-fit: cover; border-radius: 4px; margin-left: -4px; }
.imgedit-stage { position: relative; display: block; width: fit-content; max-width: 100%; margin: 0 auto var(--sp-3); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.imgedit-stage.is-loading { min-height: 200px; min-width: 200px; }
.imgedit-img { display: block; max-width: 100%; max-height: 50vh; user-select: none; -webkit-user-select: none; }
.imgedit-canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .55; cursor: crosshair; touch-action: none; }
.imgedit-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.imgedit-size { display: inline-flex; align-items: center; gap: var(--sp-2); }
.imgedit-size input { width: 120px; }
.imgedit-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--sp-2); }
.chip { height: var(--h-xs); padding: 0 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-elev); color: var(--text-2); font-size: var(--fs-xs); cursor: pointer; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
@media (max-width: 640px) { .img-results.multi { grid-template-columns: minmax(0, 1fr); } }

/* ---------------------------------------------------------------------
   Projekte, Websuche-Quellen, Templates, Wissen
   --------------------------------------------------------------------- */
.sidebar-projects { padding: 0 var(--sp-2); }
.sidebar-projects:empty { display: none; }
.project-head { display: flex; align-items: center; justify-content: space-between; }
.project-head .chat-group-toggle { flex: 1; }
.project-link { height: 32px; font-weight: 450; }
.project-link .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-link .shared-icon svg { width: 14px; height: 14px; }
.project-grid { align-items: start; }
.project-grid textarea { width: 100%; }
.project-chat { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2); border-radius: var(--r-md); color: var(--text); text-decoration: none; }
.project-chat:hover { background: var(--hover); text-decoration: none; }
.project-chat svg { width: 16px; height: 16px; color: var(--text-2); }
.ctx-chip .chip-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 0 0 4px; }
.ctx-chip .chip-x:hover { color: var(--text); }
a.ctx-chip { text-decoration: none; }

.web-sources { margin: var(--sp-2) 0; font-size: var(--fs-sm); color: var(--text-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
details.web-sources { display: block; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg-elev); }
.web-sources svg { width: 15px; height: 15px; flex: none; }
.web-sources summary { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); cursor: pointer; list-style: none; }
.web-sources summary::-webkit-details-marker { display: none; }
.web-sources .ws-q { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.web-sources .ws-list { margin: 0; padding: 0 var(--sp-3) var(--sp-3) calc(var(--sp-3) + 18px); }
.web-sources .ws-list li { margin: 2px 0; overflow-wrap: anywhere; }

.prompt-card .pt { display: flex; align-items: center; gap: 6px; }
.prompt-card .kind-icon svg { width: 16px; height: 16px; color: var(--text-2); }
.prompt-card.is-assistant { border-color: var(--border-strong); }

.ks-sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-2); }
.ks-source { display: flex; align-items: flex-start; gap: var(--sp-2); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg-elev); text-align: left; font: inherit; color: var(--text); cursor: pointer; }
.ks-source svg { width: 18px; height: 18px; color: var(--text-2); flex: none; margin-top: 2px; }
.ks-source .ks-src-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ks-source.active { border-color: var(--accent); background: var(--accent-soft); }
.ks-source.disabled { opacity: .7; cursor: not-allowed; }
.ks-drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: var(--sp-6, 24px) var(--sp-3); }
.ks-drop svg { width: 24px; height: 24px; color: var(--text-2); }
.ks-import { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
.ks-import:last-child { border-bottom: 0; }
.ks-item.is-off { opacity: .6; }
.ks-item-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.ks-map select { width: 100%; min-width: 140px; }
.ks-newtable { border-left: 3px solid var(--border-strong); padding-left: var(--sp-3); margin-bottom: var(--sp-3); }
.ks-newtable .row input.mono { flex: 1; min-width: 0; }
.ks-prev { margin: var(--sp-3) 0; }
@media (max-width: 640px) { .ks-item-head select { width: 100%; } }

/* ---------- Prozesse ---------- */
.text-danger { color: var(--danger); }
.pre { white-space: pre-wrap; }
.proc-h { font-size: var(--fs-base); margin: var(--sp-6) 0 var(--sp-3); }
.proc-runs td:first-child a { font-weight: 550; }
.proc-steps { list-style: none; margin: var(--sp-5) 0; padding: 0; position: relative; }
.proc-steps::before { content: ""; position: absolute; left: 15px; top: 16px; bottom: 16px; width: 2px; background: var(--border); }
.proc-step-item { position: relative; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4) var(--sp-3) 52px; margin-bottom: var(--sp-3); box-shadow: var(--shadow-xs); }
.proc-step-item.is-current { border-color: var(--border-strong); box-shadow: var(--shadow); }
.proc-step-line { display: flex; align-items: center; gap: var(--sp-3); min-height: 32px; }
.proc-dot { position: absolute; left: 4px; top: 12px; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-xs); font-weight: 650; background: var(--surface-2); color: var(--text-2); border: 2px solid var(--bg); }
.proc-dot svg { width: 13px; height: 13px; }
.st-completed .proc-dot { background: var(--ok); color: #fff; }
.st-running .proc-dot { background: var(--accent); color: #fff; animation: proc-pulse 1.2s ease-in-out infinite; }
.st-waiting .proc-dot { background: var(--warn); color: #fff; }
.st-failed .proc-dot, .st-rejected .proc-dot { background: var(--danger); color: #fff; }
.st-skipped .proc-dot, .st-pending .proc-dot { opacity: .75; }
@keyframes proc-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .st-running .proc-dot { animation: none; } }
.proc-step-title { font-weight: 600; }
.proc-step-status { color: var(--muted); white-space: nowrap; }
.st-failed .proc-step-status, .st-rejected .proc-step-status { color: var(--danger); }
.st-waiting .proc-step-status { color: var(--warn); font-weight: 600; }
.proc-msg { margin: var(--sp-3) 0 0; }
.proc-out { margin-top: var(--sp-3); min-width: 0; }
.proc-text { max-height: 420px; overflow: auto; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg); }
.proc-edit { width: 100%; font: inherit; }
.proc-note { margin-top: var(--sp-2); }
.proc-actions { margin-top: var(--sp-3); }
.proc-actions input[type="text"] { flex: 1; min-width: 160px; }
.proc-meta { margin: 0; }
.proc-filter { margin-bottom: var(--sp-4); }
/* Admin-Editor */
.proc-step { position: relative; }
.proc-step-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.proc-step-no { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 650; font-size: var(--fs-sm); }
.proc-step-tools { margin-left: auto; display: inline-flex; gap: 2px; }
.proc-input-row, .proc-endpoint { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr) auto auto; gap: var(--sp-2); align-items: center; margin-bottom: var(--sp-2); }
.proc-endpoint { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) 100px minmax(0, 1.6fr) auto; padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-3); }
.proc-endpoint-desc { grid-column: 1 / -1; }
.proc-input-row .checkbox { margin: 0; }
.proc-sub { margin-left: var(--sp-6); }
.proc-day { margin: 0 var(--sp-2) 0 0; }
.proc-add { margin: var(--sp-2) 0 var(--sp-6); }
.proc-save { gap: var(--sp-4); }
.proc-secret { display: block; margin-top: var(--sp-2); padding: var(--sp-2) var(--sp-3); background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); font-family: var(--mono); font-size: var(--fs-sm); overflow-wrap: anywhere; user-select: all; }
.field .label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
@media (max-width: 820px) {
  .proc-input-row, .proc-endpoint { grid-template-columns: 1fr 1fr; }
  .proc-sub { margin-left: 0; }
  .proc-step-item { padding-left: 44px; }
}

/* ---------- Skills ---------- */
.prompt-card.is-skill .kind-icon { color: var(--accent); }

/* ---------- Prozesse: Hilfsklassen, Autocomplete, Dropzone ---------- */
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.link, .link-btn { color: var(--accent); cursor: pointer; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; text-align: left; }
.link-btn:hover { text-decoration: underline; }
kbd { display: inline-block; padding: 0 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--r-xs); background: var(--bg-elev); font-size: var(--fs-xs); line-height: 1.6; }
.proc-summary { margin: 0 0 var(--sp-3); padding-left: var(--sp-5); }
.proc-summary li { margin-bottom: 2px; }
.ac-wrap { position: relative; }
.ac-list { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% - var(--sp-5) + 4px); margin: 0; padding: var(--sp-1); list-style: none; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; }
.ac-wrap > .ac-list { top: auto; margin-top: 4px; }
.ac-item { display: flex; flex-direction: column; gap: 1px; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); cursor: pointer; }
.ac-item.active, .ac-item:hover { background: var(--hover); }
.ac-label { font-weight: 550; }
.ac-sub, .ac-empty { font-size: var(--fs-xs); color: var(--muted); }
.ac-empty { padding: var(--sp-2) var(--sp-3); }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2); padding: var(--sp-8, 32px) var(--sp-5); border: 2px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface); color: var(--text-2); text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone svg { width: 28px; height: 28px; color: var(--muted); }
.dropzone:hover, .dropzone:focus-visible, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.pf-list { list-style: none; margin: var(--sp-4) 0 0; padding: 0; }
.pf-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
.pf-item svg { width: 16px; height: 16px; color: var(--muted); }
.pf-actions { margin-top: var(--sp-4); }
.pf-actions .checkbox { margin: 0 var(--sp-3) 0 0; }
.grow { flex: 1; min-width: 0; }

/* ---------- Prozess-Designer ---------- */
.designer { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.designer-loading { padding: var(--sp-6); }
.dz-toolbar { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-4); border-bottom: 1px solid var(--border); background: var(--bg-elev); flex-wrap: nowrap; }
.dz-toolbar > .btn, .dz-toolbar > .icon-btn { flex: none; }
.dz-title { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; }
.dz-title strong { overflow: hidden; text-overflow: ellipsis; }
.dz-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 230px minmax(0, 1fr) minmax(360px, 460px); }
.dz-palette { border-right: 1px solid var(--border); padding: var(--sp-4); overflow-y: auto; background: var(--bg-sidebar); }
.dz-section-title { font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: var(--sp-2) 0 var(--sp-2); }
.dz-section-title:not(:first-child) { margin-top: var(--sp-6); }
.dz-pal-item { display: flex; align-items: flex-start; gap: var(--sp-3); width: 100%; padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-2); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg-elev); color: var(--text); font: inherit; text-align: left; cursor: grab; box-shadow: var(--shadow-xs); }
.dz-pal-item:hover { border-color: var(--border-strong); }
.dz-pal-item > span:last-child { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-sm); line-height: 1.35; }
.dz-keys { list-style: none; padding: 0; margin: 0 0 var(--sp-4); }
.dz-keys li { margin-bottom: 4px; }
.dz-ic { width: 28px; height: 28px; flex: none; border-radius: var(--r-sm); display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-2); }
.dz-ic svg { width: 16px; height: 16px; }
.dz-ic.t-ai { background: var(--accent-soft); color: var(--accent); }
.dz-ic.t-rule { background: var(--warn-soft); color: var(--warn); }
.dz-ic.t-query { background: var(--ok-soft); color: var(--ok); }
.dz-ic.t-approval { background: var(--danger-soft); color: var(--danger); }
.dz-ic.t-start { background: var(--btn-primary); color: var(--btn-primary-text); }
.dz-canvas { overflow: auto; padding: var(--sp-6) var(--sp-6) var(--sp-10, 64px); background: var(--bg); background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 18px 18px; }
.dz-flow-wrap { position: relative; max-width: 560px; margin: 0 auto; padding-right: 90px; }
.dz-flow { position: relative; z-index: 1; }
.dz-arrows { position: absolute; inset: 0; width: 100% !important; height: 100% !important; pointer-events: none; z-index: 2; overflow: visible; }
.dz-arrow { fill: none; stroke: var(--warn); stroke-width: 1.6; stroke-dasharray: 5 4; }
.dz-arrow-head { fill: var(--warn); }
.dz-node { position: relative; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow); cursor: pointer; transition: border-color .12s, box-shadow .12s, opacity .12s; }
.dz-node:hover { border-color: var(--border-strong); }
.dz-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dz-node.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.dz-node.disabled { opacity: .55; }
.dz-node.has-issues { border-left: 3px solid var(--danger); }
.dz-node-head { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.dz-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-grip { color: var(--muted); cursor: grab; display: inline-flex; }
.dz-grip svg { width: 14px; height: 14px; }
.dz-no { font-size: var(--fs-xs); font-weight: 650; color: var(--muted); min-width: 14px; }
.dz-key { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); }
.dz-desc { font-size: var(--fs-sm); color: var(--text-2); margin: 4px 0 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dz-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: var(--sp-2); }
.dz-chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 550; background: var(--surface); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.chip svg { width: 12px; height: 12px; }
.chip-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip-rule, .chip-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip-muted { color: var(--muted); }
.dz-start, .dz-end { cursor: default; }
.dz-start { cursor: pointer; }
.dz-end { display: flex; align-items: center; gap: var(--sp-2); box-shadow: none; background: var(--surface); }
.dz-gap { position: relative; height: 40px; display: flex; align-items: center; justify-content: center; }
.dz-line { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--border-strong); transform: translateX(-1px); }
.dz-add { position: relative; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; opacity: .0; transition: opacity .12s, transform .12s; }
.dz-add svg { width: 14px; height: 14px; }
.dz-gap:hover .dz-add, .dz-add:focus-visible { opacity: 1; }
.dz-flow:not(:has(.dz-step)) .dz-add { opacity: 1; }
.designer.dragging .dz-gap { height: 52px; }
.designer.dragging .dz-gap::after { content: ""; position: absolute; left: 8%; right: 8%; top: 50%; height: 0; border-top: 2px dashed var(--border-strong); }
.dz-gap.over::after { border-color: var(--accent) !important; }
.dz-gap.over .dz-add { opacity: 1; transform: scale(1.15); border-color: var(--accent); color: var(--accent); }
.dz-inspector { border-left: 1px solid var(--border); background: var(--bg-elev); overflow-y: auto; display: flex; flex-direction: column; }
.dz-inspector > * { flex: none; }
.dz-insp-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-4) var(--sp-2); }
.dz-insp-title { font-weight: 650; overflow-wrap: anywhere; }
.dz-insp-body { padding: 0 var(--sp-4) var(--sp-6); }
.dz-insp-body h3 { font-size: var(--fs-md); margin: var(--sp-6) 0 var(--sp-2); }
.dz-tabs { padding: 0 var(--sp-4); margin-bottom: var(--sp-4); }
.dz-issue-box { margin: 0 var(--sp-4) var(--sp-3); font-size: var(--fs-sm); }
.dz-issue-box ul, .dz-issues { margin: 0; padding-left: var(--sp-4); }
.dz-issues li { margin-bottom: var(--sp-2); }
.dz-ref { margin: var(--sp-2) 0 var(--sp-4); }
.dz-list { padding-left: var(--sp-4); margin: 0 0 var(--sp-3); }
.dz-empty { padding: var(--sp-4); border: 1px dashed var(--border-strong); border-radius: var(--r-md); text-align: center; }
.dz-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border); margin-bottom: var(--sp-2); }
.dz-seg-btn { height: 28px; padding: 0 var(--sp-3); border: 0; border-radius: var(--r-pill); background: none; font: inherit; font-size: var(--fs-sm); font-weight: 550; color: var(--muted); cursor: pointer; }
.dz-seg-btn.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-xs); }
.dz-seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dz-tags { border: 1px solid var(--border); border-bottom: 0; border-radius: var(--r-md) var(--r-md) 0 0; background: var(--surface); padding: 6px var(--sp-2); max-height: 150px; overflow-y: auto; }
.dz-tags + textarea, .dz-tags + .dz-code-wrap { border-top-left-radius: 0; border-top-right-radius: 0; }
.dz-tags.compact { max-height: 96px; }
.dz-tag-filter { height: 28px; margin-bottom: 6px; font-size: var(--fs-sm); }
.dz-tag-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 4px; }
.dz-tag-gl { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; margin-right: 2px; }
.vtag { height: 22px; padding: 0 7px; border-radius: var(--r-pill); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); background: var(--accent-soft); color: var(--accent); font-family: var(--mono); font-size: var(--fs-xs); cursor: pointer; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.vtag:hover { border-color: var(--accent); }
.dz-prompt { min-height: 180px; }
.dz-rule { border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-3); margin-bottom: var(--sp-4); background: var(--bg); }
.dz-rule-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: 4px; }
.dz-rule-head > strong { flex-basis: 100%; }
.dz-rule .dz-tags { margin-top: var(--sp-2); }
.dz-code-wrap { display: flex; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--code-bg); overflow: hidden; }
.dz-gutter { flex: none; width: 36px; padding: 9px 6px 9px 0; text-align: right; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; color: var(--muted); overflow: hidden; user-select: none; border-right: 1px solid var(--border); }
.dz-gutter .err { color: var(--danger); font-weight: 700; }
.dz-code { flex: 1; border: 0 !important; border-radius: 0 !important; background: transparent !important; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; white-space: pre; overflow-wrap: normal; overflow-x: auto; tab-size: 2; resize: vertical; box-shadow: none !important; }
.dz-rule-status { margin-top: 6px; }
.dz-code-preview { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3); font-size: 12.5px; max-height: 360px; overflow: auto; white-space: pre; }
.dz-schema-ed { margin-bottom: var(--sp-4); }
.dz-schema { font-size: 12.5px; }
.dz-field-add { display: grid; grid-template-columns: minmax(0, 1.2fr) 100px auto; gap: 6px; align-items: center; margin: var(--sp-2) 0; }
.dz-field-add > input:nth-of-type(2) { grid-column: 1 / 3; }
.dz-field-add .checkbox { margin: 0; }
.dz-field-add input, .dz-field-add select { height: var(--h-sm); font-size: var(--fs-sm); }
.dz-fields { list-style: none; margin: 0 0 var(--sp-2); padding: 0; border: 1px solid var(--border); border-radius: var(--r-md); }
.dz-fields li { display: flex; align-items: center; gap: var(--sp-2); padding: 4px var(--sp-2); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.dz-fields li:last-child { border-bottom: 0; }
.dz-fields li.lvl-1 { padding-left: var(--sp-5); }
.dz-fields li.lvl-2 { padding-left: var(--sp-8, 32px); }
.dz-fields li.lvl-3 { padding-left: 44px; }
.dz-fields .icon-btn { width: 24px; height: 24px; }
.dz-details { margin: var(--sp-2) 0; }
.dz-details summary { cursor: pointer; font-size: var(--fs-sm); color: var(--text-2); margin-bottom: var(--sp-2); }
.dz-test-out { margin-top: var(--sp-4); }
.dz-fn-list { columns: 2; column-gap: var(--sp-6); }
.dz-fn-list li { break-inside: avoid; margin-bottom: 4px; }
.proc-source { margin: 0; }
.proc-json { font-size: 12.5px; max-height: 360px; overflow: auto; white-space: pre-wrap; }
@media (max-width: 1180px) {
  .dz-body { grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); }
  .dz-palette { display: none; }
}
@media (max-width: 820px) {
  .dz-body { grid-template-columns: 1fr; grid-template-rows: minmax(260px, 45%) 1fr; }
  .dz-inspector { border-left: 0; border-top: 1px solid var(--border); }
  .dz-canvas { padding: var(--sp-4); }
  .dz-toolbar { flex-wrap: wrap; }
  .dz-fn-list { columns: 1; }
}
.dz-type-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px var(--sp-3); padding: 0 var(--sp-4) var(--sp-3); }
.dz-type-row > label { font-weight: 600; color: var(--text-2); }
.dz-type-row > .muted { grid-column: 2; }
.dz-type-select { height: var(--h-sm); font-weight: 600; }
.dz-colpick { display: flex; flex-wrap: wrap; gap: 2px var(--sp-4); }
.dz-colpick .checkbox { margin: 0; }
.dz-kv { display: grid; grid-template-columns: minmax(90px, auto) minmax(0, 1fr); gap: 6px var(--sp-2); align-items: center; }
.dz-kv-k { font-family: var(--mono); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.dz-filter { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.dz-filter > select { min-width: 0; flex: 1 1 30%; }
.dz-filter > .dz-op { flex: 0 0 96px; }
.dz-filter > .dz-val { flex: 1 1 40%; min-width: 0; }
.dz-kv input, .dz-filter input, .dz-filter select { height: var(--h-sm); font-size: var(--fs-sm); }
.proc-preview { margin-top: var(--sp-3); }
.proc-preview .kv { grid-template-columns: 120px 1fr; }

