/* V-018 · LaiZY-Seitenbereich: angedockt rechts wie das Seitenpanel in Chrome (Desktop 380 px, schiebt die
   Dokumentfläche zur Seite statt sie zu verdecken), Handy ≤ 600 px als Unterblatt. Office hell: Rahmen-Grau,
   weiße Karte, Segoe UI, Fluent-Grautöne; Petrol nur für Hauptknopf und Auswahl. Farben über die Token des
   Rahmens (app-shell.css). Arbeitsrand: Attribut data-wt-work an .wtx-ki-card (Regeln in work-edge.css). */
.app-shell { --wtx-ki-width: 380px; }

/* Knopf in der Titelleiste (ersetzt einen Hilfe-/Support-Knopf; die Hilfe-Seite bleibt im Menüband) */
.wtx-ki-toggle[hidden] { display: none !important; }
.app-topbar .wtx-ki-toggle {
  height: 32px; min-height: 32px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--app-radius, 4px); color: var(--app-text); background: transparent;
  font: 600 13px/1 var(--app-font); white-space: nowrap; cursor: pointer; box-shadow: none;
}
.app-topbar .wtx-ki-toggle .ti { color: var(--app-teal); font-size: 18px; }
.app-topbar .wtx-ki-toggle:hover { background: rgba(0, 0, 0, .05); }
.app-topbar .wtx-ki-toggle[aria-expanded="true"] { color: var(--app-petrol); background: var(--app-brand-tint); }
.app-topbar .wtx-ki-toggle:focus-visible { outline: 2px solid var(--app-teal); outline-offset: 2px; }

/* Panel */
.wtx-ki {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 45; width: var(--wtx-ki-width, 380px); max-width: 100vw;
  box-sizing: border-box; display: flex; flex-direction: column; padding: 8px;
  color: var(--app-text); background: var(--app-chrome); border-left: 1px solid var(--app-line);
  font-family: var(--app-font); font-size: 14px; line-height: 1.45;
}
.wtx-ki[hidden], .wtx-ki-scrim[hidden] { display: none; }
.wtx-ki *, .wtx-ki *::before, .wtx-ki *::after { box-sizing: border-box; }
/* Karte = Träger des Arbeitsrands: kein overflow:hidden, der Rand liegt 3 px außerhalb auf dem Rahmen-Grau. */
.wtx-ki-card {
  position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  border-radius: var(--app-radius-panel, 8px); background: var(--app-surface); box-shadow: var(--app-shadow);
}
.wtx-ki-head { display: flex; align-items: flex-start; gap: 10px; padding: 12px 8px 10px 14px; border-bottom: 1px solid var(--app-line); }
.wtx-ki-mark { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 6px; color: var(--app-petrol); background: var(--app-brand-tint); font-size: 17px; }
.wtx-ki-titles { min-width: 0; flex: 1 1 auto; }
.wtx-ki-titles h2 { margin: 0; color: var(--app-text); font-size: 14px; font-weight: 600; line-height: 1.3; letter-spacing: 0; }
.wtx-ki-titles h2:focus { outline: none; }
.wtx-ki-titles h2:focus-visible { outline: 2px solid var(--app-teal); outline-offset: 2px; }
.wtx-ki-context { margin: 2px 0 0; overflow: hidden; color: var(--app-muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.wtx-ki .wtx-ki-close {
  width: 32px; height: 32px; min-height: 32px; flex: none; margin: 0; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: var(--app-radius, 4px); color: var(--app-muted); background: transparent; font-size: 18px; cursor: pointer; box-shadow: none;
}
.wtx-ki .wtx-ki-close:hover { color: var(--app-text); background: var(--app-hover); }
.wtx-ki .wtx-ki-close:focus-visible { outline: 2px solid var(--app-teal); outline-offset: 1px; }

.wtx-ki-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 14px; }
.wtx-ki-log { margin: 0; padding: 0; display: grid; gap: 14px; list-style: none; }
.wtx-ki-log[hidden] { display: none; }
.wtx-ki-turn { display: grid; gap: 6px; }
.wtx-ki-q { justify-self: end; max-width: 90%; padding: 8px 10px; border-radius: 8px 8px 2px 8px; background: var(--app-brand-tint); }
.wtx-ki-a { justify-self: start; max-width: 100%; padding: 8px 10px; border: 1px solid var(--app-line); border-radius: 8px 8px 8px 2px; background: var(--app-surface); }
.wtx-ki-who { display: block; margin-bottom: 2px; color: var(--app-muted); font-size: 12px; }
.wtx-ki-text { margin: 0; color: var(--app-text); font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.wtx-ki-turn.is-pending .wtx-ki-a .wtx-ki-text { color: var(--app-muted); }
.wtx-ki-dots span { animation: wtx-ki-blink 1.2s ease-in-out infinite; }
.wtx-ki-dots span:nth-child(2) { animation-delay: .2s; }
.wtx-ki-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes wtx-ki-blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

.wtx-ki-empty { display: grid; gap: 8px; color: var(--app-muted); font-size: 13px; }
.wtx-ki-empty[hidden] { display: none; }
.wtx-ki-empty p { margin: 0; }
.wtx-ki-empty .wtx-ki-empty-title { color: var(--app-text); font-size: 14px; font-weight: 600; }
.wtx-ki-link { justify-self: start; color: var(--app-teal); font-weight: 600; text-decoration: none; }
.wtx-ki-link:hover { text-decoration: underline; }
.wtx-ki-link:focus-visible { outline: 2px solid var(--app-teal); outline-offset: 2px; border-radius: 2px; }
.wtx-ki-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wtx-ki .wtx-ki-chip {
  min-height: 28px; margin: 0; padding: 0 10px; border: 1px solid var(--app-line-strong); border-radius: 14px;
  color: var(--app-text); background: var(--app-surface); font: 400 12.5px/1 var(--app-font); cursor: pointer; box-shadow: none;
}
.wtx-ki .wtx-ki-chip:hover { border-color: var(--app-teal); background: var(--app-brand-tint-hover, var(--app-hover)); }
.wtx-ki .wtx-ki-chip:focus-visible { outline: 2px solid var(--app-teal); outline-offset: 1px; }

.wtx-ki-status { min-height: 22px; margin: 0; padding: 4px 14px 0; color: var(--app-muted); font-size: 12px; }
.wtx-ki-status:empty { min-height: 0; padding-top: 0; }
.wtx-ki-status.is-error { color: var(--wt-work-error-text, #a4262c); font-weight: 600; }
.wtx-ki-form { display: flex; align-items: flex-end; gap: 8px; padding: 8px 14px 6px; }
.wtx-ki-form textarea {
  flex: 1 1 auto; min-width: 0; height: 40px; min-height: 40px; max-height: 140px; margin: 0; padding: 8px 10px;
  border: 1px solid var(--app-line-strong); border-bottom-color: var(--app-muted); border-radius: var(--app-radius, 4px);
  color: var(--app-text); background: var(--app-surface); font: 400 14px/1.4 var(--app-font); resize: none;
}
.wtx-ki-form textarea::placeholder { color: var(--app-muted); opacity: 1; }
.wtx-ki-form textarea:focus-visible { outline: 2px solid var(--app-teal); outline-offset: 1px; }
.wtx-ki-form textarea:disabled { background: var(--app-surface-soft); cursor: not-allowed; }
.wtx-ki .wtx-ki-send {
  height: 40px; min-height: 40px; min-width: 40px; margin: 0; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--app-teal); border-radius: var(--app-radius, 4px); color: var(--app-surface); background: var(--app-teal);
  font: 600 13px/1 var(--app-font); cursor: pointer; box-shadow: none;
}
.wtx-ki .wtx-ki-send:hover:not(:disabled) { border-color: var(--app-brand-hover); background: var(--app-brand-hover); }
.wtx-ki .wtx-ki-send:disabled { border-color: var(--app-line-strong); color: var(--app-muted); background: var(--app-pressed); cursor: default; }
.wtx-ki .wtx-ki-send:focus-visible { outline: 2px solid var(--app-teal); outline-offset: 2px; }
.wtx-ki-note { margin: 0; padding: 2px 14px 12px; display: flex; align-items: flex-start; gap: 6px; color: var(--app-muted); font-size: 12px; line-height: 1.4; }
.wtx-ki-note .ti { flex: none; margin-top: 1px; font-size: 14px; }
.wtx-ki-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Desktop breit: angedockt, die Dokumentfläche wird schmaler (wie Chrome), nichts wird verdeckt. */
@media (min-width: 1280px) {
  .app-shell.is-ki-docked > .app-frame { margin-right: var(--wtx-ki-width, 380px); }
  /* R-248: angedockt ist die Arbeitsflaeche ~380 px schmaler als das Fenster; die Titelleiste folgt aber der Fensterbreite.
     Wie im Bereich 768-1180 px Tastenkuerzel und Statustext ausblenden, sonst ueberdeckt die Suche den Status (Live 23.10.). */
  .app-shell.is-ki-docked .app-topbar .app-search kbd,
  .app-shell.is-ki-docked .app-topbar .app-status { display: none; }
}
/* Schmaler Desktop/Tablet: Panel liegt über der Fläche, mit Schatten. */
@media (min-width: 601px) and (max-width: 1279px) {
  .wtx-ki { width: min(var(--wtx-ki-width, 380px), calc(100vw - 48px)); box-shadow: var(--app-shadow-raised); }
}
/* Handy: Unterblatt im Daumenbereich, Eingabe unten, Ziele ≥ 44 px, 16 px Schrift (kein Zoom beim Tippen). */
@media (max-width: 600px) {
  .app-topbar .wtx-ki-toggle { min-width: 44px; height: 44px; padding: 0 10px; justify-content: center; }
  .app-topbar .wtx-ki-toggle span { display: none; }
  .wtx-ki {
    top: auto; left: 0; width: auto; height: min(86dvh, 680px); z-index: 60;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-left: 0; border-top: 1px solid var(--app-line);
    border-radius: 12px 12px 0 0; box-shadow: var(--app-shadow-raised);
  }
  .wtx-ki-scrim { position: fixed; inset: 0; z-index: 59; background: rgba(0, 0, 0, .32); }
  .wtx-ki .wtx-ki-close, .wtx-ki .wtx-ki-send { width: auto; min-width: 44px; height: 44px; min-height: 44px; }
  .wtx-ki .wtx-ki-chip { min-height: 44px; border-radius: 22px; }
  .wtx-ki-form textarea { height: 44px; min-height: 44px; font-size: 16px; }
  .wtx-ki-send span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .wtx-ki-dots span { animation: none !important; opacity: 1; }
}
@media (forced-colors: active) {
  .wtx-ki { border-left: 1px solid CanvasText; }
  .wtx-ki-q, .wtx-ki-a, .wtx-ki-card { border: 1px solid CanvasText; }
  .wtx-ki .wtx-ki-send { border: 1px solid ButtonText; }
}
@media print {
  .wtx-ki, .wtx-ki-scrim, .wtx-ki-toggle { display: none !important; }
  .app-shell.is-ki-docked > .app-frame { margin-right: 0 !important; }
}
