/* Active chat: the header and composer get their own rows. Only the transcript
   scrolls, so a growing composer or a shorter viewport can't cover messages. */
#main.chat-open { min-height: 0; }
#main.chat-open > .topbar { position: relative; inset: auto; flex: none; }
#main.chat-open > .scroller { min-height: 0; scroll-behavior: auto; overflow-anchor: none; }
#main.chat-open .hero.chatting { padding: 12px 16px 8px; }
#main.chat-open > .composer {
  position: relative; inset: auto; transform: none; flex: none; align-self: center;
  margin: 10px 0 6px; padding-bottom: 10px;
}
#main.chat-open > .composer::before { height: 6px; }

@media (max-width: 900px) {
  /* Keep the exposed page canvas and native overscroll background dark. */
  html { background: var(--bg, #0b0b0c); color-scheme: dark; }
  html, body { overscroll-behavior: none; }
  /* The keyboard on mobile Safari can shrink only the visual viewport. */
  #app.chat-viewport {
    position: absolute; inset-inline: 0; top: var(--chat-viewport-top, 0px);
    height: var(--chat-viewport-height); background: var(--bg);
  }
  #app { --chat-safe-bottom: env(safe-area-inset-bottom, 0px); }
  #app.chat-keyboard { --chat-safe-bottom: 0px; }
  #main.chat-open > .composer { margin-bottom: max(6px, var(--chat-safe-bottom)); }
  #main .composer textarea { display: block; max-height: min(220px, calc(var(--chat-viewport-height, 100dvh) * .28)); }
  #main .composer .c-files { max-height: min(84px, calc(var(--chat-viewport-height, 100dvh) * .2)); overflow-y: auto; }

  /* Focusing an empty chat keeps the same textarea mounted (important for
     the iOS keyboard). Collapse the welcome content while the user types. */
  #main.chat-drafting:not(.chat-open) > .topbar { position: relative; inset: auto; flex: none; }
  #main.chat-drafting:not(.chat-open) > .scroller { min-height: 0; scroll-behavior: auto; }
  #main.chat-drafting:not(.chat-open) .hero { padding: 8px 14px max(8px, var(--chat-safe-bottom)); }
  #main.chat-drafting:not(.chat-open) :is(.hero-top, .starters, .fineprint, .explore-btn, #explore) { display: none; }
}

@media (max-width: 600px) {
  #main.chat-open .hero.chatting { padding-inline: 14px; }
  #main.chat-open > .composer { width: calc(100% - 16px); }
}
