/*
  AgentChat Komponenten
  Baut nur auf tokens.css auf. Keine festen Farben außer in Ausnahmen mit Kommentar.
  Reihenfolge: Basis, Layout, Typo, Buttons, Formulare, Karten, Badges und Status,
  Tabellen, Alerts, Navigation, Code, Leerzustand, Modal, Statistik, Chat, Hilfsklassen.
  Wichtig: keine Gedankenstriche in dieser Datei, sie wird in Server-Seiten eingebettet.
*/

/* ---------- Basis ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--type-body);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 { margin: 0; color: var(--text); }
h1, h2, h3 { font-family: var(--font-display); }
h1 { font-size: var(--type-h1); font-weight: var(--weight-semibold); line-height: var(--leading-tight); letter-spacing: var(--tracking-heading); }
h2 { font-size: var(--type-h2); font-weight: var(--weight-semibold); line-height: var(--leading-tight); letter-spacing: var(--tracking-heading); }
h3 { font-size: var(--type-h3); font-weight: var(--weight-semibold); line-height: var(--leading-snug); letter-spacing: var(--tracking-tight); }
h4 { font-size: var(--type-h4); font-weight: var(--weight-semibold); line-height: var(--leading-snug); }
p { margin: 0; }
small { font-size: var(--type-small); }
b, strong { font-weight: var(--weight-semibold); }

a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); }

img, svg { max-width: 100%; }

:focus-visible { outline: var(--focus-width) solid var(--focus-color); outline-offset: var(--focus-offset); border-radius: var(--radius-xs); }

::selection { background: var(--accent-soft-strong); }

hr { border: 0; border-top: var(--border-width) solid var(--border); margin: var(--space-8) 0; }

.display {
  font-family: var(--font-display);
  font-size: var(--type-display);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-display);
  letter-spacing: var(--tracking-display);
}
.text-lg { font-size: var(--type-body-lg); }
.text-sm { font-size: var(--type-small); line-height: var(--leading-small); }
.text-xs { font-size: var(--text-xs); line-height: var(--leading-small); }
.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Fließtext auf Rechtsseiten und in Hilfetexten */
.prose { max-width: var(--measure); }
.prose h2 { margin: var(--space-10) 0 var(--space-3); font-size: var(--text-xl); }
.prose h3 { margin: var(--space-6) 0 var(--space-2); font-size: var(--text-md); }
.prose p, .prose ul, .prose ol { margin: 0 0 var(--space-3); }
.prose li { margin: 0 0 var(--space-1); }
.prose ul, .prose ol { padding-left: var(--space-6); }

/* ---------- Layout ---------- */

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--space-5); }
.container-app { max-width: var(--container-app); }
.container-text { max-width: var(--container-text); }
.stack > * + * { margin-top: var(--space-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.form-grid { display: grid; gap: 0 var(--space-4); grid-template-columns: 1fr; }
.section { margin-top: var(--space-12); }
.section > h2 { margin-bottom: var(--space-4); }
.section-title { font-size: var(--text-xl); margin-bottom: var(--space-4); }

@media (min-width: 640px) {
  .container { padding: 0 var(--space-8); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Buttons ---------- */

.btn {
  --btn-bg: var(--accent);
  --btn-fg: var(--on-accent);
  --btn-border: transparent;
  --btn-bg-hover: var(--accent-hover);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  position: relative;
  min-height: 44px; padding: 0 var(--space-5);
  font: inherit; font-size: var(--text-base); font-weight: var(--weight-semibold); line-height: 1.2;
  color: var(--btn-fg); background: var(--btn-bg);
  border: var(--border-width) solid var(--btn-border); border-radius: var(--radius-control);
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), transform var(--duration-instant) var(--ease-out);
}
.btn:hover { background: var(--btn-bg-hover); color: var(--btn-fg); }
.btn:focus-visible { outline: var(--focus-width) solid var(--focus-color); outline-offset: var(--focus-offset); border-radius: var(--radius-control); }

.btn-primary { --btn-bg: var(--accent); --btn-fg: var(--on-accent); --btn-bg-hover: var(--accent-hover); }
.btn-secondary { --btn-bg: transparent; --btn-fg: var(--text); --btn-border: var(--border-strong); --btn-bg-hover: var(--surface-2); }
.btn-ghost { --btn-bg: transparent; --btn-fg: var(--link); --btn-bg-hover: var(--accent-soft); }
.btn-danger { --btn-bg: transparent; --btn-fg: var(--danger-text); --btn-border: var(--danger-border); --btn-bg-hover: var(--danger-surface); }
.btn-danger-solid { --btn-bg: var(--danger-solid); --btn-fg: var(--on-danger); --btn-bg-hover: var(--danger-solid); }
/* Umgekehrt: für Buttons auf einer Akzent-Fläche */
.btn-inverse { --btn-bg: var(--on-accent); --btn-fg: var(--accent); --btn-bg-hover: var(--surface-2); }

.btn-sm { min-height: 34px; padding: 0 var(--space-3); font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.btn-lg { min-height: 52px; padding: 0 var(--space-7); font-size: 1.0625rem; }
.btn-block { width: 100%; }

.btn:disabled, .btn[aria-disabled="true"], .btn.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* Ladezustand: Text bleibt für Screenreader, sichtbar ist der Kreisel */
.btn.is-loading, .btn[aria-busy="true"] { color: transparent; pointer-events: none; }
.btn.is-loading::after, .btn[aria-busy="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 1.1em; height: 1.1em; border-radius: 50%;
  border: 2px solid var(--btn-fg); border-right-color: transparent;
  animation: ac-spin 0.7s linear infinite;
}
@keyframes ac-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn.is-loading::after, .btn[aria-busy="true"]::after { animation-duration: 2.4s; }
}

.text-link { color: var(--text-muted); font-weight: var(--weight-medium); text-underline-offset: 4px; }
.text-link:hover { color: var(--text); }

form.inline { display: inline; margin: 0; }

/* ---------- Formulare ---------- */

.field { margin: 0 0 var(--space-4); }

label, .label {
  display: block;
  margin: var(--space-4) 0 6px;
  font-size: var(--text-sm); font-weight: var(--weight-semibold); line-height: var(--leading-snug);
  color: var(--text);
}
.field > label, .field > .label { margin-top: 0; }

.hint { margin-top: var(--space-1); font-size: var(--text-sm); line-height: var(--leading-small); color: var(--text-muted); }
.error-text { margin-top: var(--space-1); font-size: var(--text-sm); line-height: var(--leading-small); color: var(--danger-text); font-weight: var(--weight-medium); }

.input, .select, .textarea {
  display: block; width: 100%; min-height: 44px;
  padding: var(--space-2) var(--space-3);
  font: inherit; font-size: var(--text-base); line-height: 1.4;
  color: var(--text); background-color: var(--field-bg);
  border: var(--border-width) solid var(--border-strong); border-radius: var(--radius-control);
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--text-placeholder); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft-strong); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: var(--focus-width) solid var(--focus-color); outline-offset: 1px; border-radius: var(--radius-control); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: 0.55; cursor: not-allowed; }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"], .is-invalid { border-color: var(--danger-text); }
.textarea { min-height: 96px; resize: vertical; }
.input-file { padding: var(--space-2); }
.input-file::file-selector-button {
  margin-right: var(--space-3); padding: var(--space-1) var(--space-3);
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-semibold);
  color: var(--text); background: var(--surface-2); border: var(--border-width) solid var(--border); border-radius: var(--radius-pill); cursor: pointer;
}
.input-inline { display: inline-block; width: auto; min-width: 5.5rem; }

.select {
  appearance: none; -webkit-appearance: none;
  padding-right: var(--space-10);
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* Checkbox mit Text daneben */
.check {
  display: flex; gap: var(--space-3); align-items: flex-start;
  margin: var(--space-3) 0 0;
  font-weight: var(--weight-regular); font-size: var(--text-base); line-height: var(--leading-small);
  cursor: pointer;
}
.check input[type="checkbox"], .check input[type="radio"], .checkbox {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 20px; height: 20px; margin: 1px 0 0;
  background: var(--field-bg); border: var(--border-width-strong) solid var(--border-strong); border-radius: var(--radius-xs);
  display: inline-grid; place-content: center; cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}
.check input[type="radio"] { border-radius: 50%; }
.check input[type="checkbox"]::before, .checkbox::before {
  content: ""; width: 10px; height: 6px; margin-top: -2px;
  border: solid var(--on-accent); border-width: 0 0 2px 2px; transform: rotate(-45deg) scale(0);
  transition: transform var(--duration-fast) var(--ease-spring);
}
.check input[type="checkbox"]:checked, .checkbox:checked { background: var(--accent); border-color: var(--accent); }
.check input[type="checkbox"]:checked::before, .checkbox:checked::before { transform: rotate(-45deg) scale(1); }
.check input:focus-visible, .checkbox:focus-visible { outline: var(--focus-width) solid var(--focus-color); outline-offset: var(--focus-offset); }

/* Schalter: <label class="toggle"><input type="checkbox" role="switch"><span>Text</span></label> */
.toggle { display: inline-flex; gap: var(--space-3); align-items: center; margin: var(--space-3) 0 0; font-weight: var(--weight-regular); font-size: var(--text-base); cursor: pointer; }
.toggle input {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0;
  width: 44px; height: 26px; border-radius: var(--radius-pill);
  background: var(--surface-2); border: var(--border-width) solid var(--border-strong); cursor: pointer;
  transition: background-color var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out);
}
.toggle input::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--duration-base) var(--ease-spring), background-color var(--duration-base) var(--ease-out);
}
.toggle input:checked { background: var(--accent); border-color: var(--accent); }
.toggle input:checked::before { transform: translateX(18px); background: var(--on-accent); }
.toggle input:focus-visible { outline: var(--focus-width) solid var(--focus-color); outline-offset: var(--focus-offset); }
.toggle input:disabled { opacity: 0.5; cursor: not-allowed; }

.form-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin-top: var(--space-6); margin-bottom: var(--space-4); }
.form-inline { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.form-inline label { margin: 0; }

/* ---------- Karten ---------- */

.card {
  background: var(--surface);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin: 0 0 var(--space-4);
  min-width: 0;
}
.card > :first-child { margin-top: 0; }
.card-title { font-family: var(--font-display); font-size: var(--text-md); font-weight: var(--weight-semibold); margin: 0 0 var(--space-3); }
.card-accent { border-color: var(--accent); }
.card-flat { background: transparent; }
.card-grid { display: grid; gap: var(--space-4); grid-template-columns: 1fr; margin: 0 0 var(--space-4); }
.card-grid > .card { margin: 0; }
@media (min-width: 640px) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Badges und Status ---------- */

/* Badge: Etikett ohne Zustand (Tags, Webhook-Felder, Optionen) */
.badge {
  display: inline-block; max-width: 100%; padding: 1px var(--space-2); margin: 0 var(--space-1) var(--space-1) 0;
  font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: 1.6;
  color: var(--neutral-text); background: var(--neutral-surface);
  border: var(--border-width) solid var(--neutral-border); border-radius: var(--radius-pill);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.badge-accent { color: var(--accent-text); background: var(--accent-surface); border-color: var(--accent-border); }

/* Sticker: Kommentar-Wort und Neu-Marke. Neutrale graue Fläche, Graphit-Text, kein Farbakzent. */
.sticker {
  display: inline-block; padding: 0 var(--space-2);
  font-family: var(--font-mono); font-size: 0.875em; font-weight: var(--weight-regular); line-height: 1.6;
  color: var(--accent-text); background: var(--accent-surface);
  border: var(--border-width) solid var(--accent-border); border-radius: var(--radius-xs);
}
.sticker-flat { font-family: var(--font-body); border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: var(--weight-semibold); padding: 0 10px; }

/* Status-Pille: Zustand mit Punkt. Farbe nach Bedeutung, nicht nach Wort. */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 1px var(--space-2) 1px 7px; margin: 0 var(--space-1) var(--space-1) 0;
  font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: 1.6;
  color: var(--neutral-text); background: var(--neutral-surface);
  border: var(--border-width) solid var(--neutral-border); border-radius: var(--radius-pill);
  white-space: nowrap; vertical-align: 1px;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.status-success { color: var(--success-text); background: var(--success-surface); border-color: var(--success-border); }
.status-warning { color: var(--warning-text); background: var(--warning-surface); border-color: var(--warning-border); }
.status-danger { color: var(--danger-text); background: var(--danger-surface); border-color: var(--danger-border); }
.status-info { color: var(--info-text); background: var(--info-surface); border-color: var(--info-border); }
.status-accent { color: var(--accent-text); background: var(--accent-surface); border-color: var(--accent-border); }
.status-neutral { color: var(--neutral-text); background: var(--neutral-surface); border-color: var(--neutral-border); }

/* ---------- Tabellen ---------- */

.table-wrap {
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: 0 0 var(--space-5);
  background: var(--surface);
  border: var(--border-width) solid var(--border); border-radius: var(--radius-md);
}
.table-wrap:focus-visible { outline: var(--focus-width) solid var(--focus-color); outline-offset: var(--focus-offset); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); line-height: var(--leading-small); }
.table th, .table td { padding: var(--space-3) var(--space-4); text-align: left; vertical-align: top; border-top: var(--border-width) solid var(--border); overflow-wrap: break-word; }
.table tr:first-child > th, .table tr:first-child > td, .table thead + tbody tr:first-child > * { border-top: 0; }
.table thead th { border-bottom: var(--border-width) solid var(--border); }
.table th { color: var(--text-muted); font-weight: var(--weight-semibold); }
.table thead th { font-size: var(--text-xs); white-space: nowrap; overflow-wrap: normal; }
.table tbody tr:hover > td { background: var(--accent-soft); }
.table .num { text-align: right; white-space: nowrap; overflow-wrap: normal; }
.table tr.muted td, .table tr.muted td a { color: var(--text-muted); }
.table td > b:first-child { color: var(--text); }
.table-wrap > .table:not(.table-kv) { min-width: 560px; }
.table-wide, .table-wrap > .table-wide { min-width: 760px; }
.table-wide td:first-child { min-width: 220px; max-width: 360px; }
.table td .badge { max-width: 26ch; }
/* Schlüssel-Wert-Tabelle: erste Spalte als Beschriftung */
.table-kv th { width: 38%; color: var(--text-muted); }
.table-kv td { color: var(--text); }
.table-kv td.num { text-align: left; white-space: normal; overflow-wrap: break-word; }
.card .table th, .card .table td { padding-left: 0; padding-right: var(--space-3); }
.card .table td.num { padding-right: 0; }
.table .table-empty { color: var(--text-muted); text-align: left; padding: var(--space-6) var(--space-4); }

/* ---------- Alerts / Flash ---------- */

.alert, .flash {
  display: block;
  margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4) var(--space-3) var(--space-10);
  position: relative;
  font-size: var(--text-sm); line-height: var(--leading-small);
  color: var(--info-text); background: var(--info-surface);
  border: var(--border-width) solid var(--info-border); border-radius: var(--radius-control);
}
.alert::before, .flash::before {
  content: ""; position: absolute; left: var(--space-4); top: calc(var(--space-3) + 0.3em);
  width: 10px; height: 10px; border-radius: 50%; background: currentColor;
}
.alert a, .flash a { color: inherit; font-weight: var(--weight-semibold); }
.alert-title { display: block; font-weight: var(--weight-bold); margin-bottom: 2px; }
.alert-success, .flash.ok { color: var(--success-text); background: var(--success-surface); border-color: var(--success-border); }
.alert-warning { color: var(--warning-text); background: var(--warning-surface); border-color: var(--warning-border); }
.alert-danger, .flash.err { color: var(--danger-text); background: var(--danger-surface); border-color: var(--danger-border); }
.alert-info { color: var(--info-text); background: var(--info-surface); border-color: var(--info-border); }

/* ---------- Navigation ---------- */

.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: var(--surface-overlay);
  border-bottom: var(--border-width) solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: var(--topbar-height); }
.topbar-nav { display: flex; align-items: center; gap: var(--space-6); }
.topbar-nav a:not(.btn) { color: var(--text-muted); text-decoration: none; font-size: var(--text-sm); font-weight: var(--weight-medium); }
.topbar-nav a:not(.btn):hover { color: var(--text); }

.brand {
  display: inline-flex; align-items: center; gap: 10px; flex: none;
  color: var(--text); text-decoration: none;
  font-family: var(--font-display); font-weight: var(--weight-semibold); font-size: 1.125rem; letter-spacing: var(--tracking-heading);
}
.brand:hover { color: var(--text); }
.brand-mark { width: 26px; height: 26px; flex: none; }
.brand-sub { font-family: var(--font-body); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-muted); letter-spacing: 0; }

/* Tabs: auf schmalen Bildschirmen seitlich wischbar, ohne die Seite zu verbreitern */
.tabs {
  display: flex; gap: var(--space-1);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  border-bottom: var(--border-width) solid var(--border);
  margin: 0 0 var(--space-6);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; position: relative;
  padding: var(--space-3) var(--space-3);
  color: var(--text-muted); text-decoration: none;
  font-size: var(--text-sm); font-weight: var(--weight-semibold); white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-current="page"], .tab.is-active { color: var(--text); }
.tab[aria-current="page"]::after, .tab.is-active::after {
  content: ""; position: absolute; left: var(--space-3); right: var(--space-3); bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px;
}
.tab:focus-visible { outline-offset: -3px; }

.breadcrumb { margin: 0 0 var(--space-4); font-size: var(--text-sm); }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }

/* ---------- Code und Kopierfeld ---------- */

code, kbd, samp { font-family: var(--font-mono); font-size: var(--type-mono); }
:not(pre) > code {
  padding: 1px 6px; border-radius: var(--radius-xs);
  background: var(--surface-2); color: var(--text);
  overflow-wrap: anywhere;
}
pre, .code-block {
  margin: 0 0 var(--space-4); padding: var(--space-4);
  font-family: var(--font-mono); font-size: var(--text-sm); line-height: 1.55;
  color: var(--text); background: var(--surface-sunken);
  border: var(--border-width) solid var(--border); border-radius: var(--radius-control);
  overflow-x: auto; max-width: 100%;
}
pre code { padding: 0; background: none; font-size: inherit; }

.copy {
  display: flex; align-items: stretch; gap: var(--space-2);
  margin: 0 0 var(--space-3); min-width: 0;
}
.copy > code, .copy .copy-value {
  flex: 1; min-width: 0;
  display: flex; align-items: center;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono); font-size: var(--text-sm);
  color: var(--text); background: var(--surface-sunken);
  border: var(--border-width) solid var(--border); border-radius: var(--radius-control);
  white-space: nowrap; overflow-x: auto; overflow-wrap: normal; scrollbar-width: thin;
}
.copy > .input { flex: 1; min-width: 0; }
.copy > .btn { flex: none; }

/* ---------- Leerzustand ---------- */

.empty {
  padding: var(--space-8) var(--space-6);
  border: var(--border-width) dashed var(--border-strong); border-radius: var(--radius-md);
  color: var(--text-muted);
}
.empty-title { font-family: var(--font-display); font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text); margin: 0 0 var(--space-1); }
.empty p { max-width: 46ch; }
.empty .btn { margin-top: var(--space-4); }

/* ---------- Modal / Bestätigung ---------- */

.modal {
  width: min(460px, calc(100vw - 32px)); padding: 0;
  color: var(--text); background: var(--surface);
  border: var(--border-width) solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: var(--scrim); }
.modal[open] { animation: ac-pop var(--duration-base) var(--ease-out); }
@keyframes ac-pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-body { padding: var(--space-6) var(--space-6) var(--space-2); }
.modal-title { font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-heading); margin: 0 0 var(--space-2); }
.modal-text { color: var(--text-muted); }
.modal-actions { display: flex; flex-wrap: wrap-reverse; justify-content: flex-end; gap: var(--space-3); padding: var(--space-4) var(--space-6) var(--space-6); }
/* Vorschau ohne <dialog>, zum Beispiel im Styleguide */
.modal-static { display: block; position: static; margin: 0; }

/* ---------- Statistik-Kacheln ---------- */

.stats {
  display: grid; gap: var(--space-px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--border); border: var(--border-width) solid var(--border); border-radius: var(--radius-md);
  overflow: hidden; margin: 0 0 var(--space-6);
}
.stat { background: var(--surface); padding: var(--space-4) var(--space-5) var(--space-5); min-width: 0; }
.stat-label { font-size: var(--text-sm); color: var(--text-muted); }
.stat-value {
  display: block; margin-top: var(--space-1);
  font-family: var(--font-display); font-size: var(--text-2xl); font-weight: var(--weight-semibold);
  line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--text);
}
.stat-meta { margin-top: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ---------- Chat (Demos) ---------- */

.chat {
  background: var(--bg); border: var(--border-width) solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  border-bottom: var(--border-width) solid var(--border); background: var(--surface);
  font-weight: var(--weight-semibold); font-size: var(--text-sm);
}
.chat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; }
.chat-live { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-weight: var(--weight-medium); font-size: var(--text-xs); color: var(--success-text); }
.chat-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success-solid); }
.chat-body { display: flex; flex-direction: column; gap: 14px; padding: var(--space-5) var(--space-4) var(--space-6); }

.bubble { max-width: 92%; padding: 12px 16px; border-radius: var(--radius-bubble); font-size: var(--text-base); line-height: 1.5; }
.bubble-user { align-self: flex-end; background: var(--accent); color: var(--on-accent); }
.bubble-agent { align-self: flex-start; background: var(--surface); color: var(--text); border: var(--border-width) solid var(--border); }

.tool-call {
  align-self: flex-start; display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 6px 12px; border: var(--border-width) dashed var(--border-strong); border-radius: var(--radius-pill);
  color: var(--text-muted); font-size: var(--text-xs);
}
.tool-call svg { width: 14px; height: 14px; color: var(--success-text); flex: none; }
.tool-call code { padding: 0; background: none; font-size: var(--text-xs); color: var(--text-muted); }

.result-list { margin: var(--space-3) 0 0; display: grid; gap: var(--space-px); background: var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.result-list > div { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-3); background: var(--surface-raised); font-size: var(--text-sm); }
.result-list dt { color: var(--text-muted); }
.result-list dd { margin: 0; text-align: right; font-weight: var(--weight-semibold); }

/* ---------- App-Rahmen der Server-Seiten ---------- */

.app-main { padding: var(--space-8) 0 var(--space-16); overflow-wrap: break-word; }
.page-header { margin: 0 0 var(--space-6); }
.page-header h1 { font-size: var(--type-h2); }
.page-header p { margin-top: var(--space-2); color: var(--text-muted); }
.app-main h2 { font-size: var(--text-xl); margin: var(--space-10) 0 var(--space-3); }
.app-main h3 { font-size: var(--text-md); margin: var(--space-6) 0 var(--space-2); }
.app-main .card h3:first-child, .app-main .card > h2:first-child { margin-top: 0; }
.app-main p, .app-main ul, .app-main ol { margin: 0 0 var(--space-3); }
.app-main ul, .app-main ol { padding-left: var(--space-6); }
.app-main li { margin: 0 0 var(--space-1); }
.app-main .lang { margin-top: var(--space-12); padding-top: var(--space-4); border-top: var(--border-width) solid var(--border); }
.app-main .ok { color: var(--success-text); }
.app-footer { padding: var(--space-6) 0 var(--space-10); border-top: var(--border-width) solid var(--border-subtle); font-size: var(--text-sm); color: var(--text-muted); }
.app-footer nav { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.app-footer a { color: var(--text-muted); }
.app-footer a:hover { color: var(--text); }

.profile { display: flex; gap: var(--space-4); align-items: center; margin: 0 0 var(--space-5); min-width: 0; }
.profile img, .avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--border-strong); }
.profile > div { min-width: 0; overflow-wrap: anywhere; }

.plan-price { font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); margin: var(--space-1) 0 var(--space-1); }

.list-links, .app-main .list-links { list-style: none; padding: 0; margin: 0 0 var(--space-4); border: var(--border-width) solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }
.list-links li, .app-main .list-links li { margin: 0; padding: var(--space-3) var(--space-4); border-top: var(--border-width) solid var(--border); overflow-wrap: anywhere; }
.list-links li:first-child { border-top: 0; }
.list-links li.is-active { background: var(--accent-soft); }
.list-links li.is-active a { color: var(--text); font-weight: var(--weight-semibold); }

@media (max-width: 639px) {
  .brand-sub { display: none; }
}

/* Formular-Karten: das erste Label bringt schon Abstand mit */
form.card { padding-top: var(--space-1); padding-bottom: var(--space-6); }
.table .btn-sm { margin: var(--space-1) var(--space-1) 0 0; }
.table td > .status:only-child, .table td > .status:first-child { margin-top: 1px; }
.cluster > form.inline { display: contents; }
.cluster .btn-sm { margin: 0; }
.app-main .cluster { margin-bottom: var(--space-4); }

/* ---------- Schlüssel (MCP-Link) ---------- */

/* Einmal-Anzeige: Warnhinweis über den Kopierfeldern */
.key-once { margin-top: var(--space-2); }

/* Gekürzter Schlüssel nach der Einmal-Anzeige: nur die letzten Zeichen, Schloss davor */
.key-masked {
  display: flex; align-items: center; gap: var(--space-3);
  margin: 0 0 var(--space-3); padding: var(--space-2) var(--space-3); min-width: 0;
  background: var(--surface-sunken);
  border: var(--border-width) dashed var(--border-strong); border-radius: var(--radius-control);
}
.key-masked::before {
  content: ""; flex: none; width: 16px; height: 16px; background: var(--text-muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect x='3' y='7' width='10' height='7' rx='1.5' fill='%23000'/%3E%3Cpath d='M5.5 7V5a2.5 2.5 0 0 1 5 0v2' fill='none' stroke='%23000' stroke-width='1.6'/%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 16 16'%3E%3Crect x='3' y='7' width='10' height='7' rx='1.5' fill='%23000'/%3E%3Cpath d='M5.5 7V5a2.5 2.5 0 0 1 5 0v2' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.key-masked code { padding: 0; background: none; color: var(--text-muted); font-size: var(--text-sm); white-space: nowrap; overflow-x: auto; overflow-wrap: normal; min-width: 0; }
.empty form { margin: 0; }

/* Kopierzeile mit Umbruch für längere Prompts */
.copy-umbruch > code { white-space: normal; overflow-wrap: anywhere; align-items: flex-start; }
.copy-umbruch > .btn { align-self: flex-start; }
