.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:where(.eb-chat, .eb-chat-launcher) {
  --eb-blue: #2338e8;
  --eb-ink: #16181d;
  --eb-night: #12141c;
  --eb-surface: #f7f7f4;
  --eb-muted: #5d6068;
  --eb-line: #dddedf;
  font-family: "Hanken Grotesk", system-ui, sans-serif;
}

.eb-chat-launcher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 99990;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  border: 0;
  border-radius: 2px;
  padding: .9rem 1.1rem;
  color: #fff;
  background: var(--eb-blue);
  box-shadow: 0 12px 34px rgba(18, 20, 28, .22);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* Textzeilen + Cursorblock statt Sprechblase (behauptet einen Menschen) oder
   Sparkle (das Buzzword-Klischee, das der Hero durchstreicht). Der Cursor ist
   dasselbe Motiv, das die Antwort beim Schreiben zeigt. */
.eb-chat-launcher__icon {
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
}

/* Schreib-Idle: die Balken schreiben kurz, das Icon fuehrt also vor, was der Button
   tut. Bewusst KEINE Dauerschleife - der Ausloeser ist begrenzt (siehe Widget-JS).
   Endlose Bewegung in der Peripherie lenkt ab und nutzt sich zugleich ab: Nach ein
   paar Durchlaeufen filtert das Auge sie weg, die Stoerung bleibt. */
.eb-chat-launcher__icon rect { transform-box: fill-box; transform-origin: left center; }
.eb-chat-launcher.is-writing .eb-chat-launcher__icon rect:nth-child(1) { animation: eb-launcher-write .9s ease-in-out; }
.eb-chat-launcher.is-writing .eb-chat-launcher__icon rect:nth-child(2) { animation: eb-launcher-write .9s ease-in-out .12s; }
.eb-chat-launcher.is-writing .eb-chat-launcher__icon rect:nth-child(3) { animation: eb-launcher-blink .9s ease-in-out; }
@keyframes eb-launcher-write {
  0%, 100% { transform: scaleX(1); }
  25% { transform: scaleX(.45); }
  50% { transform: scaleX(1); }
  75% { transform: scaleX(.45); }
}
@keyframes eb-launcher-blink {
  0%, 100% { opacity: 1; }
  25% { opacity: .25; }
  50% { opacity: 1; }
  75% { opacity: .25; }
}

.eb-chat-launcher:hover,
.eb-chat-launcher:focus-visible,
.eb-chat__submit:hover,
.eb-chat__submit:focus-visible {
  background: var(--eb-night);
}

.eb-chat {
  position: fixed;
  inset: 0;
  z-index: 99991;
  display: grid;
  place-items: end end;
  padding: 1.25rem;
  background: rgba(0, 0, 0, .4);
}

.eb-chat[hidden] { display: none; }

.eb-chat__panel {
  display: flex;
  width: min(100%, 30rem);
  max-height: min(46rem, calc(100vh - 2.5rem));
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--eb-line);
  border-radius: 2px;
  color: var(--eb-ink);
  background: var(--eb-surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .34);
}

.eb-chat__header,
.eb-chat__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 1rem 1.1rem;
}

.eb-chat__header { border-bottom: 1px solid var(--eb-line); }
.eb-chat__title { margin: 0; font-family: "Archivo Expanded", "Hanken Grotesk", sans-serif; font-size: 1.1rem; }
.eb-chat__close,
.eb-chat__erase,
.eb-chat__suggestion {
  border: 0;
  color: var(--eb-blue);
  background: transparent;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.eb-chat__notice {
  margin: .85rem 1.1rem 0;
  color: var(--eb-muted);
  font-size: .78rem;
  line-height: 1.4;
}

.eb-chat__messages {
  display: flex;
  min-height: 10rem;
  flex: 1;
  flex-direction: column;
  gap: .65rem;
  overflow-y: auto;
  padding: 1rem 1.1rem;
}

.eb-chat__message {
  max-width: 88%;
  border-radius: .8rem;
  padding: .7rem .8rem;
  line-height: 1.48;
}
.eb-chat__message--assistant { align-self: flex-start; border: 1px solid var(--eb-line); background: #fff; }
.eb-chat__message--user { align-self: flex-end; color: #fff; background: var(--eb-blue); }
.eb-chat__message-text { margin: 0; white-space: pre-wrap; }
.eb-chat__message.is-streaming .eb-chat__message-text::after { content: "▋"; animation: eb-chat-cursor 1s steps(2, start) infinite; }
@keyframes eb-chat-cursor { 50% { opacity: 0; } }

/* Wartezustand, bis das erste Wort steht. */
.eb-chat__typing { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem 0; }
.eb-chat__typing i {
  width: .4rem;
  height: .4rem;
  border-radius: 50%;
  background: var(--eb-muted);
  animation: eb-chat-typing 1.25s ease-in-out infinite;
}
.eb-chat__typing i:nth-child(2) { animation-delay: .16s; }
.eb-chat__typing i:nth-child(3) { animation-delay: .32s; }
@keyframes eb-chat-typing {
  0%, 65%, 100% { opacity: .28; transform: translateY(0); }
  32% { opacity: 1; transform: translateY(-2px); }
}

/* Jedes Wort blendet einzeln weich ein. Weil neue Woerter (~47–173ms Abstand) meist
   schneller kommen als die Einblendung dauert (260ms), ueberlappen sie zu einer
   weichen Welle an der Schreibkante — fliessend statt satzweise. Takt/Tempo im JS
   (REVEAL_SPEED). */
.eb-chat__word { animation: eb-chat-word .26s ease-out both; }
@keyframes eb-chat-word { from { opacity: 0; } to { opacity: 1; } }

.eb-chat__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: 0 1.1rem .85rem;
}
.eb-chat__suggestion {
  border: 1px solid #b8baff;
  border-radius: 2px;
  padding: .35rem .6rem;
  color: var(--eb-blue);
  text-align: left;
  text-decoration: none;
  font-size: .78rem;
}

.eb-chat__form { display: grid; grid-template-columns: 1fr auto; gap: .6rem; padding: 0 1.1rem 1rem; }
.eb-chat__input { min-height: 2.9rem; resize: vertical; border: 1px solid #989ba3; border-radius: 2px; padding: .65rem; color: var(--eb-ink); background: #fff; font: inherit; }
.eb-chat__input:focus-visible, .eb-chat button:focus-visible, .eb-chat a:focus-visible, .eb-chat-launcher:focus-visible { outline: 3px solid var(--eb-blue); outline-offset: 2px; }
.eb-chat__submit { align-self: end; border: 0; border-radius: 2px; padding: .7rem .85rem; color: #fff; background: var(--eb-blue); font: inherit; font-weight: 700; cursor: pointer; }
.eb-chat__form.is-busy .eb-chat__submit { opacity: .65; cursor: progress; }
.eb-chat__status { min-height: 1.1rem; margin: 0 1.1rem .5rem; color: var(--eb-muted); font-size: .8rem; }

.eb-chat__sources { margin: .2rem 0 .65rem; }
.eb-chat__sources-title { margin: 0 0 .35rem; font-size: .8rem; font-weight: 700; }
.eb-chat__source-list { margin: 0; padding-left: 1.15rem; font-size: .85rem; }
.eb-chat__source-link, .eb-chat__link { color: var(--eb-blue); text-underline-offset: .16em; }
.eb-chat__footer { flex-wrap: wrap; border-top: 1px solid var(--eb-line); font-size: .78rem; }
.eb-chat__links { display: flex; flex-wrap: wrap; gap: .65rem; }
.eb-chat__erase { margin-left: auto; color: #8c3023; }

.eb-chat-launcher.is-menu-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 600px) {
  .eb-chat { padding: 0; place-items: end stretch; }
  .eb-chat__panel { width: 100%; max-height: 88vh; border-radius: 2px 2px 0 0; }
  .eb-chat-launcher {
    right: .75rem;
    bottom: calc(.75rem + env(safe-area-inset-bottom));
    width: 3rem;
    height: 3rem;
    justify-content: center;
    padding: 0;
  }
  .eb-chat-launcher__label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .eb-chat__message.is-streaming .eb-chat__message-text::after { animation: none; }
  .eb-chat__typing i { animation: none; opacity: .5; }
  .eb-chat__word { animation: none; }
  .eb-chat-launcher.is-writing .eb-chat-launcher__icon rect { animation: none; }
}
