:root {
  --live-chat-page-rail: max(var(--space-4), calc((100% - var(--size-1060)) / 2));
  --live-chat-header-clearance: var(--size-64);
  --live-chat-padding: var(--space-6) var(--space-2);
  --live-chat-jump-inset: var(--space-3);
  --live-chat-model-width: var(--size-300);
  --live-chat-provider-padding: var(--space-2);
  --live-chat-input-font: var(--font-type-body-large);
  --live-chat-dock-height: var(--size-60dvh);
  --live-chat-composer-bottom: max(var(--space-2), env(safe-area-inset-bottom));
}

.application-shell:has(.live-chat) { --shell-rail: var(--live-chat-page-rail); }
.shell-content:has(.live-chat) {
  display: flex;
  flex-direction: column;
  min-block-size: 100dvh;
  background: var(--color-background);
}
.live-chat .transcript-event { scroll-margin-block-start: var(--live-chat-header-clearance); }
.live-chat .jump-latest[hidden] { display: none; }
.live-chat__jump {
  position: relative;
  display: flex;
  justify-content: center;
  flex: none;
  block-size: 0;
}
.live-chat__jump .jump-latest {
  position: absolute;
  inset-block-end: var(--live-chat-jump-inset);
  max-inline-size: 100%;
  margin: 0;
}
#page-content:has(> .live-chat) {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding-block: 0;
}
.live-chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: var(--transcript-width);
  color: var(--color-foreground);
  background: var(--color-background);
  font: var(--transcript-font);
}
.live-chat > .transcript {
  flex: 1;
  display: block;
  margin: 0;
  padding: var(--live-chat-padding);
  overflow-anchor: none;
}
/* Sticky overlays history but keeps its natural height at the document's end,
   so the latest message can always scroll above the composer. */
.live-chat__dock {
  position: sticky;
  inset-block-end: 0;
  z-index: 1;
  pointer-events: none;
}
.live-chat__dock > * { pointer-events: auto; }
.live-chat .transcript-event:has(> .live-chat__failure) {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: var(--space-2);
}
.live-chat .transcript-event:has(> .live-chat__failure) > .chat-message {
  min-inline-size: 0;
  inline-size: auto;
}
.live-chat__failure {
  order: -1;
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  align-self: flex-start;
  background: var(--color-surface);
}
.live-chat__failure form { margin: 0; }
.live-chat__failure .live-chat__retry,
.live-chat__failure .flyout__trigger {
  --button-foreground: var(--color-error);
  --button-hover-foreground: var(--color-error);
}
.live-chat__dock > [role=status]:empty { display: none; }
.live-chat__notice { font: var(--transcript-note-font); color: var(--color-muted-foreground); }
.live-chat__dock > .live-chat__notice:not(:empty),
.live-chat__composer .message-composer__help,
.live-chat__composer .message-composer__status:not(:empty) { background: var(--color-surface); }
.live-chat__composer {
  --composer-width: var(--transcript-width);
  max-block-size: var(--live-chat-dock-height);
  overflow-y: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  margin: 0 0 var(--live-chat-composer-bottom);
  background: var(--transcript-clear-background);
}
.live-chat__composer .message-composer__input {
  --textarea-border: 0;
  --textarea-padding: 0;
  --textarea-radius: 0;
  --textarea-font: var(--live-chat-input-font);
}
.live-chat__files { align-items: flex-start; }
.live-chat__files:empty, .live-chat__composer .message-composer__status:empty { display: none; }
.live-chat__model { inline-size: var(--live-chat-model-width); max-inline-size: 100%; }
.live-chat__provider { padding: 0; border: 0; }
.live-chat__provider > summary { padding: var(--live-chat-provider-padding); color: var(--color-accent-foreground); font: var(--transcript-note-font); }
.live-chat__provider[open] { flex-basis: 100%; }
.live-chat__provider .select-field { max-inline-size: var(--live-chat-model-width); }
.live-chat__composer [data-upload-card] { display: block; }

@media (max-width: 60rem) {
  .live-chat__model { flex: 1 1 var(--live-chat-model-width); }
}
