/* ============================================================
   AILAB-ASSIST - HAUT fuer das schwebende Nova-Fenster (ORDER 250)
   Form = ASSIST 2 (Winchester 16.10. 08:56): Glasfenster AUF der
   Seite, verschiebbar, KEIN Bottom-Sheet, nur Dark.
   Geltung: ausschliesslich unter .alab-assist[data-form=float].
   Farben: nur Tokens aus css/app.css (:root) + Tints als
   color-mix()/opacity auf diesen Tokens. Keine neuen Hexwerte.
   Kern (Zustand/Nachrichten/Kontext) = kisuke T1/T2, diese Datei
   enthaelt NUR Optik + Geometrie.
   ============================================================ */

.alab-assist[data-form=float] {
  position: fixed;
  right: 24px;
  bottom: 112px; /* 24 px Rand + 64 px Nova-Orb + 24 px Luft (Orb unten rechts bleibt frei) */
  width: 360px;
  height: 520px;
  min-width: 320px;
  min-height: 400px;
  max-width: 480px;
  max-height: 720px;
  /* Kurzes Fenster (geteilt, Browserzoom): nie hoeher als der Viewport minus
     bottom 112 px + 24 px Luft ueber dem Kopf, sonst liegen Griff und Schliessen
     oberhalb des Bildschirms. Ab 656 px Viewporthoehe bleibt es bei 360x520.
     min-height 400 / max-height 720 oben = Rueckfall ohne dvh/min(). */
  min-height: min(400px, calc(100dvh - 136px));
  max-height: min(720px, calc(100dvh - 136px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);            /* Rueckfall: volle Deckung */
  border: 1px solid var(--line);       /* weiss 7 % */
  border-radius: var(--radius);        /* 18 px */
  box-shadow: 0 18px 48px color-mix(in srgb, var(--bg) 62%, transparent),
              0 4px 14px color-mix(in srgb, var(--bg) 55%, transparent);
  color: var(--ink);
  font-family: 'Outfit', var(--font);
  font-size: 14px;
  z-index: 60;
  touch-action: none;                  /* Pointer-Drag ohne Scroll-Klau */
}

/* Glas: Panel mit ~92 % Deckung + blur(18px), nur wo beides kann. */
@supports (background: color-mix(in srgb, red 50%, transparent)) and
          ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .alab-assist[data-form=float] {
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
}

.alab-assist[data-form=float][hidden] { display: none; }

/* ---------- Kopf (Drag-Griff) ---------- */
.alab-assist[data-form=float] .alab-assist__head {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 8px 12px 16px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.alab-assist[data-form=float] .alab-assist__head:active { cursor: grabbing; }

/* Griffleiste oben (kleiner Balken) */
.alab-assist[data-form=float] .alab-assist__head::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 22%, transparent);
}

.alab-assist[data-form=float] .alab-assist__head:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.alab-assist[data-form=float] .alab-assist__avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--panel-2);
  box-shadow: 0 0 0 1px var(--line);
}

.alab-assist[data-form=float] .alab-assist__name {
  font-family: 'Outfit', var(--font);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink);
}

.alab-assist[data-form=float] .alab-assist__dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 8px color-mix(in srgb, var(--mint) 55%, transparent);
}
.alab-assist[data-form=float] .alab-assist__dot[data-state="thinking"] {
  animation: alabAssistPulse 1.2s ease-in-out infinite;
}
@keyframes alabAssistPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .45; transform: scale(.78); }
}
@media (prefers-reduced-motion: reduce) {
  .alab-assist[data-form=float] .alab-assist__dot[data-state="thinking"] { animation: none; }
}

.alab-assist[data-form=float] .alab-assist__close {
  flex: none;
  margin-left: auto;
  width: 48px;                 /* Bedienflaeche 48 px */
  height: 48px;
  margin-top: -6px;
  margin-right: -4px;
  margin-bottom: -6px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--muted);
  transition: color 130ms, background 130ms;
}
.alab-assist[data-form=float] .alab-assist__close:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 7%, transparent);
}

/* ---------- "Nova sees"-Kachel ---------- */
.alab-assist[data-form=float] .alab-assist__sees {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 14px 10px;
  padding: 8px 10px;
  background: var(--panel-2);          /* #232537 */
  border-radius: var(--radius-s);      /* 12 px */
}
.alab-assist[data-form=float] .alab-assist__sees-thumb {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--input);
}
.alab-assist[data-form=float] .alab-assist__sees-text {
  min-width: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

/* ---------- Verlauf (eigener Scrollbereich) ---------- */
.alab-assist[data-form=float] .alab-assist__log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 14px 12px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent;
}
.alab-assist[data-form=float] .alab-assist__log::-webkit-scrollbar { width: 8px; }
.alab-assist[data-form=float] .alab-assist__log::-webkit-scrollbar-track { background: transparent; }
.alab-assist[data-form=float] .alab-assist__log::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 42%, transparent);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.alab-assist[data-form=float] .alab-assist__msg {
  max-width: 84%;
  padding: 10px 12px;
  border-radius: var(--radius-s);      /* 12 px */
  font-size: 13.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.alab-assist[data-form=float] .alab-assist__msg[data-role="agent"] {
  align-self: flex-start;
  background: var(--panel-2);
  color: var(--ink);
}
.alab-assist[data-form=float] .alab-assist__msg[data-role="user"] {
  align-self: flex-end;
  background: color-mix(in srgb, var(--teal) 20%, transparent);
  color: var(--ink);
}
.alab-assist[data-form=float] .alab-assist__msg-img {
  display: block;
  max-width: 100%;
  margin-top: 8px;
  border-radius: 8px;
}

/* ---------- Aktions-Chips ---------- */
.alab-assist[data-form=float] .alab-assist__actions {
  flex: none;
  display: flex;
  gap: 10px;
  padding: 2px 14px 12px;
}
.alab-assist[data-form=float] .alab-assist__chip {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--mint);             /* Mint-Fuellung */
  color: var(--bg);                    /* dunkler Text */
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: filter 130ms, background 130ms;
}
.alab-assist[data-form=float] .alab-assist__chip:hover { filter: brightness(1.07); }
.alab-assist[data-form=float] .alab-assist__chip--ghost {
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  box-shadow: inset 0 0 0 1px var(--line);
}
.alab-assist[data-form=float] .alab-assist__chip--ghost:hover {
  filter: none;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}

/* ---------- Eingabe-Pille ---------- */
.alab-assist[data-form=float] .alab-assist__input {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-height: 48px;                    /* Bedienhoehe 48 px */
  margin: 0 12px 12px;
  padding: 4px 5px 4px 16px;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.alab-assist[data-form=float] .alab-assist__input:focus-within {
  border-color: color-mix(in srgb, var(--teal) 55%, transparent);
}
.alab-assist[data-form=float] .alab-assist__field {
  flex: 1 1 auto;
  min-width: 0;
  align-self: center;
  max-height: 96px;
  padding: 6px 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.4;
}
.alab-assist[data-form=float] .alab-assist__mic,
.alab-assist[data-form=float] .alab-assist__send {
  flex: none;
  width: 38px;
  height: 38px;
  min-width: 0;                        /* Schutz gegen Kern-Basisregeln (.alab-assist button) */
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  transition: color 130ms, background 130ms, filter 130ms;
}
.alab-assist[data-form=float] .alab-assist__mic:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 7%, transparent);
}
.alab-assist[data-form=float] .alab-assist__send {
  background: var(--mint);
  color: var(--bg);
}
.alab-assist[data-form=float] .alab-assist__send:hover { filter: brightness(1.07); }
.alab-assist[data-form=float] .alab-assist__close svg { width: 16px; height: 16px; }
.alab-assist[data-form=float] .alab-assist__mic svg { width: 17px; height: 17px; }
.alab-assist[data-form=float] .alab-assist__send svg { width: 16px; height: 16px; }

/* Fokus-Ringe auf allen Bedienflaechen sichtbar */
.alab-assist[data-form=float] :is(.alab-assist__close, .alab-assist__chip, .alab-assist__mic, .alab-assist__send):focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.alab-assist[data-form=float] .alab-assist__field:focus-visible {
  outline: none; /* Ring traegt die Pille ueber :focus-within */
}

/* ---------- 390 / schmal: schwebend, KEIN Bottom-Sheet ---------- */
@media (max-width: 640px) {
  .alab-assist[data-form=float] {
    left: 8px;
    right: 8px;
    width: calc(100vw - 16px);
    max-width: none;
    min-width: 0;
    bottom: 12px;                      /* Standard unten mit 12 px Rand */
    height: 60vh;
    min-height: 0;
    max-height: none;
    border-radius: var(--radius);      /* bleibt schwebend, KEIN Bottom-Sheet */
  }
}
