.chat-page {
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: var(--sans);
}

.chat-page *, .chat-page *::before, .chat-page *::after { box-sizing: border-box; }
.chat-page a { color: inherit; text-decoration: none; }
.chat-page :where(button, textarea) { font: inherit; }
.chat-page :where(button, a, label) { -webkit-tap-highlight-color: transparent; }

.chat-sr-only, .chat-nav-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.chat-skip {
  position: fixed;
  top: .5rem;
  left: .5rem;
  z-index: 4;
  padding: .6rem .8rem;
  background: var(--surface-raised);
  transform: translateY(-160%);
}
.chat-skip:focus { transform: none; }
.chat-page :focus-visible, .chat-nav-toggle:focus-visible ~ .chat-topbar .chat-nav-trigger {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}
.chat-icon {
  display: block;
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chat-topbar {
  flex: none;
  min-height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .45rem;
  padding: .55rem clamp(.75rem, 3.5vw, 2rem);
  border-bottom: 1px solid var(--line);
}
.chat-brand { display: inline-flex; align-items: center; min-height: 2.75rem; gap: .5rem; white-space: nowrap; font-size: 1.16rem; font-weight: 650; letter-spacing: -.045em; }
.chat-brand img { display: block; width: 1.8rem; height: 1.8rem; }
.chat-toolbar { display: flex; align-items: center; gap: .375rem; }
.chat-new, .chat-nav-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .4rem .65rem;
  gap: .4rem;
  font-size: .875rem;
  font-weight: 550;
  border-radius: 2px;
  cursor: pointer;
}
.chat-new { border: 1px solid var(--line); white-space: nowrap; }
/* A guest: a clear Sign in in the top bar. On the phone it takes New chat's place (a guest cannot ask yet). */
.chat-page .chat-signin {
  display: inline-flex; align-items: center; min-height: 2.75rem; padding: .4rem .8rem; border: 1px solid var(--mint);
  border-radius: 2px; background: var(--mint); color: var(--bg); font-size: .875rem; font-weight: 650; white-space: nowrap;
}
.chat-page .chat-signin:hover { filter: brightness(1.08); }
@media (max-width: 37.99rem) { :root[data-qg-state="guest"] .chat-new { display: none; } }
.chat-new:hover, .chat-nav-trigger:hover, .chat-nav-toggle:checked ~ .chat-topbar .chat-nav-trigger { background: var(--surface-raised); }
.chat-layout { flex: 1; min-height: 0; display: flex; position: relative; }
.chat-nav {
  display: none;
  position: absolute;
  z-index: 2;
  inset: 0 auto 0 0;
  width: min(19rem, 100%);
  padding: 1.5rem 1rem;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.chat-nav-toggle:checked ~ .chat-layout .chat-nav { display: block; }
.chat-nav h2, .chat-kicker, .chat-example h2 {
  margin: 0;
  font: 600 .79rem/1.5 var(--sans);
  letter-spacing: .075em;
  text-transform: uppercase;
  color: var(--muted);
}
.chat-nav h2 { margin: 0 .65rem .6rem; }
.chat-project-link, .chat-history-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 2.75rem;
  padding: .5rem .65rem;
  border: 1px solid transparent;
  border-radius: 2px;
  line-height: 1.45;
  font-size: .9375rem;
}
.chat-project-link .chat-icon, .chat-history-link .chat-icon { color: var(--muted); }
.chat-project-link:hover, .chat-history-link:hover { background: var(--surface-raised); }
.chat-nav [aria-current="page"] { background: var(--surface-raised); border-color: var(--line); }
.chat-nav [aria-current="page"] .chat-icon { color: var(--mint); }
.chat-beta {
  display: inline-block;
  vertical-align: middle;
  padding: .12rem .36rem;
  color: var(--mint);
  border: 1px solid var(--line);
  border-radius: 2px;
  font: 600 .75rem/1.2 var(--sans);
  letter-spacing: .01em;
}
.chat-recents { margin-top: 1.65rem; border-top: 1px solid var(--line); padding-top: 1.5rem; }
.chat-recent-list { padding: 0; margin: 0; list-style: none; }
.chat-history-link span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-about { display: inline-block; margin: 1.75rem .65rem 0; padding-block: .5rem; font-size: .875rem; color: var(--muted) !important; }
.chat-about:hover { text-decoration: underline; }
.chat-credit { margin: .6rem .65rem 0; font-size: .8125rem; color: var(--muted); line-height: 1.5; }
.chat-credit strong { color: var(--text); font-weight: 550; }
.chat-main { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
}
.chat-stream, .chat-compose-area {
  width: min(100%, 48rem);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}
.chat-stream {
  flex: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding-block: clamp(1.5rem, 5vw, 3.25rem);
}
.chat-intro { margin-block: auto; padding-block: 1rem 2rem; }
.chat-intro h1 {
  font: 500 clamp(2.8rem, 7.7vw, 5.25rem)/.99 var(--sans);
  letter-spacing: -.065em;
  margin: .85rem 0 1.8rem;
}
.chat-intro em { font-family: var(--serif); color: var(--mint); font-weight: 400; letter-spacing: -.06em; }
.chat-starters { display: flex; flex-wrap: wrap; gap: .45rem; }
.chat-starters a { display: inline-flex; align-items: center; gap: .45rem; min-height: 2.75rem; padding: .55rem .75rem; background: var(--surface); border: 1px solid var(--line); border-radius: 2px; font-size: .875rem; }
.chat-starters a:hover { background: var(--surface-raised); border-color: var(--mint); }
.chat-starters .chat-icon { color: var(--mint); }
.chat-project { display: none; scroll-margin-block: 1.25rem; }
.chat-project:target, .chat-project:has(.chat-example:target) { display: block; }
.chat-project:target ~ .chat-intro, .chat-project:has(.chat-example:target) ~ .chat-intro,
.chat-main[data-has-messages] .chat-intro { display: none; }
.chat-project-head { display: flex; align-items: center; gap: .9rem; padding-bottom: 1.3rem; border-bottom: 1px solid var(--line); }
.chat-project-symbol { display: grid; place-items: center; width: 2.85rem; height: 2.85rem; background: var(--surface); border: 1px solid var(--line); color: var(--mint); border-radius: 2px; }
.chat-project-symbol .chat-icon { width: 1.4rem; height: 1.4rem; }
.chat-project-head p { margin: 0 0 .1rem; font-size: .875rem; color: var(--muted); }
.chat-project-head h1 { margin: 0; font: 550 clamp(1.5rem, 4vw, 2.2rem)/1.2 var(--sans); letter-spacing: -.045em; }
.chat-project-head h1 .chat-beta { margin-left: .2rem; }
.chat-example { padding-block: 1.5rem .5rem; scroll-margin-top: 8rem; }
.chat-example h2 { margin-bottom: 1rem; letter-spacing: .05em; }
.chat-question, .chat-local-message p {
  margin: 0 0 0 auto;
  max-width: min(92%, 35rem);
  width: fit-content;
  padding: .75rem 1rem;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.chat-answer { margin: 1.5rem 0 .75rem; line-height: 1.65; }
.chat-answer > strong, .chat-local-message strong { display: block; margin: 0 0 .45rem; font: 650 .8125rem/1.35 var(--sans); color: var(--mint); }
.chat-answer p { max-width: 60ch; margin: .5rem 0; font-size: 1rem; }
.chat-answer pre, .chat-ledger { padding: .75rem; border-radius: 2px; border: 1px solid var(--line); background: var(--surface); }
.chat-answer pre { overflow-x: auto; }
.chat-ledger { display: flex; justify-content: space-between; gap: .5rem; align-items: center; max-width: 23rem; }
.chat-local-heading { display: none; }
.chat-main[data-local-thread] .chat-local-heading { display: block; border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
.chat-local-tip { margin: .5rem 0 0; color: var(--muted); font-size: .9rem; }
.chat-local-heading h1 { margin: .4rem 0 0; font: 550 clamp(1.5rem, 4vw, 2.2rem)/1.2 var(--sans); letter-spacing: -.045em; }
.chat-local-message { margin-top: 1rem; }
.chat-local-message strong { text-align: right; color: var(--muted); }
.chat-compose-area { flex: none; padding-block: .6rem max(.75rem, env(safe-area-inset-bottom)); }
.chat-compose { display: flex; align-items: flex-end; gap: .5rem; padding: .65rem; background: var(--surface); border: 1px solid var(--line); border-radius: 2px; }
.chat-compose:focus-within { border-color: var(--mint); }
.chat-compose textarea { flex: 1; min-width: 0; margin: 0; padding: .2rem .25rem; background: transparent; color: var(--text); border: 0; border-radius: 2px; resize: none; outline: none; line-height: 1.45; font-size: 1rem; }
.chat-compose textarea:focus-visible { outline: none; }
.chat-compose textarea::placeholder { color: var(--muted); }
.chat-compose button { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; background: var(--mint); color: var(--bg); border: 0; border-radius: 2px; cursor: pointer; }
.chat-compose button:disabled { opacity: .5; cursor: default; }
.chat-caption { margin: .55rem 0 0; text-align: center; color: var(--muted); font-size: .8125rem; line-height: 1.4; }
@media (min-width: 52rem) {
  .chat-nav-toggle, .chat-nav-trigger { display: none; }
  .chat-nav { display: block; position: static; width: clamp(15rem, 21vw, 19rem); flex: none; }
  .chat-topbar { padding-inline: 1.65rem; }
  .chat-compose-area { padding-bottom: 1.2rem; }
}
@media (max-width: 23rem) {
  .chat-new, .chat-nav-trigger { padding-inline: .45rem; }
  .chat-brand { font-size: 1.03rem; gap: .35rem; }
}

/* Live answers (sign-in H): QuantyGPT's reply, the waiting dots, a note line. 2px corners at most. */
.chat-reply { margin-top: 1rem; }
.chat-reply p { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-reply pre { margin: .6rem 0; padding: .75rem; overflow-x: auto; border: 1px solid var(--line); border-radius: 2px; background: var(--surface); }
.chat-reply pre code { font: .85rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; }
.chat-waiting { display: flex; gap: .3rem; align-items: center; margin-top: 1rem; min-height: 1.5rem; }
.chat-waiting i { width: .4rem; height: .4rem; background: var(--mint); border-radius: 1px; animation: chat-dot 1s infinite ease-in-out; }
.chat-waiting i:nth-child(3) { animation-delay: .15s; }
.chat-waiting i:nth-child(4) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat-waiting i { animation: none; opacity: .7; } }
.chat-note { margin: 1rem 0 0; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 2px; color: var(--text); background: var(--surface); font-size: .9rem; }
.chat-note a, .chat-guest a { color: var(--mint); text-decoration: underline; }
.qg-support { margin: 1rem 0 0; padding: .65rem .75rem; border: 1px solid var(--mint); border-radius: 2px; color: var(--text); background: var(--surface); font-size: .95rem; }
.qg-support-title { margin: 0 0 .4rem; font-weight: 700; }
.qg-support ul { margin: 0; padding-left: 1.1rem; }
.qg-support li { margin: .3rem 0; overflow-wrap: anywhere; }
.qg-support a { color: var(--mint); text-decoration: underline; }
.chat-theme { min-width: 2.75rem; min-height: 2.75rem; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 2px; cursor: pointer; }
