/* Chat Appslidar — minimal landing + focused chat */

:root {
  --chat-bg: #f4f6fb;
  --chat-sidebar: #ffffff;
  --chat-border: #e2e8f0;
  --chat-accent: #bf0000;
  --chat-accent-soft: rgba(191, 0, 0, 0.12);
  --chat-user-bg: #bf0000;
  --chat-ai-bg: #ffffff;
  --chat-text: #0f172a;
  --chat-muted: #64748b;
  --chat-composer: #ffffff;
  --chat-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 28px rgba(15, 23, 42, 0.06);
}

html.dark {
  --chat-bg: #0a0e17;
  --chat-sidebar: #111827;
  --chat-border: #1f2937;
  --chat-accent: #bf0000;
  --chat-accent-soft: rgba(191, 0, 0, 0.14);
  --chat-user-bg: #bf0000;
  --chat-ai-bg: #151c2c;
  --chat-text: #f1f5f9;
  --chat-muted: #94a3b8;
  --chat-composer: #121a2b;
  --chat-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.28);
}

/* Prevent the document from scrolling while a thread is open */
html:has(.chat-shell.has-messages),
body:has(.chat-shell.has-messages) {
  height: 100%;
  overflow: hidden;
}

.chat-shell {
  position: relative;
  min-height: 100dvh;
  background:
    radial-gradient(900px 480px at 50% -8%, rgba(191, 0, 0, 0.16), transparent 55%),
    radial-gradient(700px 420px at 100% 100%, rgba(14, 165, 233, 0.07), transparent 50%),
    var(--chat-bg);
  color: var(--chat-text);
}

/* Active thread: lock the viewport and pin the composer */
.chat-shell.has-messages {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.chat-topbar {
  border-bottom: 1px solid transparent;
  flex-shrink: 0;
}

.chat-shell.has-messages .chat-topbar {
  border-bottom-color: var(--chat-border);
}

/* Fallback sun/moon visibility before JS paints data-theme-icon state */
html:not(.dark) [data-theme-icon="moon"] { display: block !important; }
html:not(.dark) [data-theme-icon="sun"] { display: none !important; }
html.dark [data-theme-icon="sun"] { display: block !important; }
html.dark [data-theme-icon="moon"] { display: none !important; }

/* Overlay sidebar — collapsed by default on all viewports */
.chat-scrim {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 22, 0.48);
  backdrop-filter: blur(2px);
  z-index: 60;
}

.chat-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(18.5rem, 88vw);
  z-index: 70;
  background: var(--chat-sidebar);
  border-right: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  transform: translateX(-105%);
  transition: transform 0.22s ease;
  box-shadow: var(--chat-shadow);
}

.chat-sidebar.open {
  transform: translateX(0);
}

.chat-sidebar-scroll {
  overflow-y: auto;
  flex: 1;
  padding: 0.4rem;
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.chat-shell.has-messages .chat-main {
  height: 100%;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.5rem 1rem 1.25rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.chat-messages-inner {
  max-width: 46rem;
  margin: 0 auto;
  width: 100%;
}

/* Gemini-style empty landing: hero + composer centered */
.chat-landing {
  position: relative;
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem 1rem 4.5rem;
  min-height: calc(100dvh - 4rem);
  animation: chat-fade-up 0.4s ease-out both;
}

.chat-landing-inner {
  position: relative;
  z-index: 1;
  width: min(100%, 42rem);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Multi-shape aurora behind first prompt (light + dark) */
.chat-landing-aurora {
  display: block;
  position: absolute;
  inset: -20% -10%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.chat-landing-aurora::before {
  content: "";
  position: absolute;
  inset: 12% 4% 22%;
  background:
    radial-gradient(closest-side at 50% 45%, rgba(191, 0, 0, 0.42), transparent 72%),
    radial-gradient(closest-side at 38% 55%, rgba(168, 85, 247, 0.32), transparent 70%),
    radial-gradient(closest-side at 62% 50%, rgba(56, 189, 248, 0.28), transparent 68%);
  filter: blur(42px);
  opacity: 1;
  animation: chat-aurora-breathe 7s ease-in-out infinite;
}

.chat-landing-aurora span {
  position: absolute;
  border-radius: 50%;
  filter: blur(58px);
  will-change: transform, opacity;
  mix-blend-mode: multiply;
  opacity: 0.9;
}

.chat-landing-aurora span:nth-child(1) {
  width: min(70vmin, 32rem);
  height: min(70vmin, 32rem);
  top: 6%;
  left: 8%;
  background: radial-gradient(circle, rgba(191, 0, 0, 0.55) 0%, transparent 68%);
  animation: chat-aurora-drift-a 10s ease-in-out infinite;
}

.chat-landing-aurora span:nth-child(2) {
  width: min(60vmin, 28rem);
  height: min(60vmin, 28rem);
  top: 24%;
  right: 2%;
  background: radial-gradient(circle, rgba(192, 132, 252, 0.48) 0%, transparent 70%);
  animation: chat-aurora-drift-b 12s ease-in-out infinite;
}

.chat-landing-aurora span:nth-child(3) {
  width: min(56vmin, 26rem);
  height: min(56vmin, 26rem);
  bottom: 8%;
  left: 28%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.42) 0%, transparent 68%);
  animation: chat-aurora-drift-c 9s ease-in-out infinite;
}

/* Dark: brighter screen-blended purple glow */
html.dark .chat-landing-aurora::before {
  background:
    radial-gradient(closest-side at 50% 45%, rgba(191, 0, 0, 0.7), transparent 72%),
    radial-gradient(closest-side at 38% 55%, rgba(168, 85, 247, 0.58), transparent 70%),
    radial-gradient(closest-side at 62% 50%, rgba(192, 132, 252, 0.48), transparent 68%);
  filter: blur(40px);
}

html.dark .chat-landing-aurora span {
  filter: blur(56px);
  mix-blend-mode: screen;
  opacity: 0.95;
}

html.dark .chat-landing-aurora span:nth-child(1) {
  background: radial-gradient(circle, rgba(191, 0, 0, 0.85) 0%, transparent 68%);
}

html.dark .chat-landing-aurora span:nth-child(2) {
  background: radial-gradient(circle, rgba(168, 85, 247, 0.72) 0%, transparent 70%);
}

html.dark .chat-landing-aurora span:nth-child(3) {
  background: radial-gradient(circle, rgba(191, 0, 0, 0.7) 0%, transparent 68%);
}

@keyframes chat-aurora-breathe {
  0%, 100% { opacity: 0.75; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.12); }
}

@keyframes chat-aurora-drift-a {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(22%, -16%) scale(1.18); }
  66% { transform: translate(-16%, 18%) scale(0.88); }
}

@keyframes chat-aurora-drift-b {
  0%, 100% { transform: translate(0, 0) scale(1.05); }
  40% { transform: translate(-24%, 16%) scale(0.86); }
  70% { transform: translate(18%, -20%) scale(1.2); }
}

@keyframes chat-aurora-drift-c {
  0%, 100% { transform: translate(0, 0) scale(0.94); }
  50% { transform: translate(20%, -22%) scale(1.16); }
}

@media (prefers-reduced-motion: reduce) {
  .chat-landing-aurora::before,
  .chat-landing-aurora span {
    animation: none;
  }
}

.chat-brand-hero {
  font-size: clamp(1.65rem, 4.2vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.12;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chat-brand-hero-ask {
  margin-top: 0.45rem;
  font-weight: 400;
  letter-spacing: -0.02em;
}

html:not(.dark) .chat-brand-hero {
  color: #334155; /* slate-700 — solid dark grey */
}

.chat-tagline {
  margin-top: 0.65rem;
  font-size: 1.05rem;
  color: var(--chat-muted);
  max-width: 26rem;
}

.chat-landing .chat-composer-wrap {
  width: 100%;
  margin-top: 1.75rem;
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
}

.chat-prompt-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 1.35rem;
}

.chat-prompt-chip {
  text-align: left;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--chat-border);
  background: color-mix(in srgb, var(--chat-sidebar) 70%, transparent);
  color: var(--chat-muted);
  font-size: 0.8rem;
  line-height: 1.3;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.chat-prompt-chip:hover:not(:disabled) {
  border-color: var(--chat-accent);
  color: var(--chat-text);
  background: var(--chat-accent-soft);
}

.chat-prompt-chip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Contextual follow-ups under the latest assistant reply */
.chat-followups-slot {
  margin-top: 0.85rem;
  min-height: 1.5rem;
}
.chat-followups {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  max-width: min(100%, 40rem);
}
.chat-followups-loader {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.35rem 0.15rem;
  min-height: 1.5rem;
}
.chat-followups-loader span {
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 999px;
  background: var(--chat-muted);
  animation: chat-followup-bounce 1.05s ease-in-out infinite;
}
.chat-followups-loader span:nth-child(2) {
  animation-delay: 0.14s;
}
.chat-followups-loader span:nth-child(3) {
  animation-delay: 0.28s;
}
@keyframes chat-followup-bounce {
  0%,
  70%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  35% {
    transform: translateY(-6px);
    opacity: 1;
  }
}
.chat-followup-chip {
  text-align: left;
  max-width: 100%;
  padding: 0.55rem 0.85rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--chat-text);
  background: color-mix(in srgb, var(--chat-sidebar) 82%, transparent);
  border-color: color-mix(in srgb, var(--chat-accent) 28%, var(--chat-border));
  animation: chat-followup-in 0.34s ease-out both;
  animation-delay: var(--fu-delay, 0ms);
  cursor: pointer;
}
.chat-followup-chip:hover:not(:disabled) {
  border-color: var(--chat-accent);
  background: var(--chat-accent-soft);
  color: var(--chat-text);
}
.chat-followup-chip:focus-visible {
  outline: 2px solid var(--chat-accent);
  outline-offset: 2px;
}
/* Opacity-only: translating the chip moves the hit target and eats first taps. */
@keyframes chat-followup-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .chat-followup-chip {
    animation: none;
  }
  .chat-msg-toolbar {
    animation: none;
  }
  .chat-followups-loader span {
    animation: none;
    opacity: 0.7;
  }
}

.chat-row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 1.15rem;
  animation: chat-fade-up 0.28s ease-out both;
}

.chat-row.user,
.chat-row.is-user {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: min(88%, 40rem);
  padding: 0.85rem 1rem;
  border-radius: 1.1rem;
  font-size: 0.95rem;
  line-height: 1.55;
}

.chat-bubble.user,
.chat-bubble--user {
  display: block;
  width: fit-content;
  max-width: min(85%, 28rem);
  height: auto;
  min-height: 0;
  padding: 0.5rem 0.85rem;
  line-height: 1.4;
  background: linear-gradient(135deg, #bf0000 0%, #545454 100%);
  color: #fff;
  border-radius: 1.1rem;
  border-bottom-right-radius: 0.35rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: var(--chat-shadow);
  align-self: flex-end;
  flex: 0 0 auto;
}

.chat-bubble.assistant,
.chat-bubble--assistant {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: var(--chat-text);
  max-width: 100%;
  width: 100%;
  height: auto;
  min-height: 0;
  box-shadow: none;
}

.chat-bubble.assistant .md p,
.chat-bubble--assistant .md p { margin: 0.35em 0; }
.chat-bubble.assistant .md p:first-child,
.chat-bubble--assistant .md p:first-child { margin-top: 0; }
.chat-bubble.assistant .md p:last-child,
.chat-bubble--assistant .md p:last-child { margin-bottom: 0; }
.chat-bubble.assistant .md ul,
.chat-bubble.assistant .md ol,
.chat-bubble--assistant .md ul,
.chat-bubble--assistant .md ol { margin: 0.35em 0; padding-left: 1.25rem; }
.chat-bubble.assistant .md li,
.chat-bubble--assistant .md li { margin: 0.15em 0; }
.chat-bubble.assistant .md .chat-inline-link,
.chat-bubble--assistant .md .chat-inline-link {
  color: #bf0000;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  font-weight: 500;
}
html:not(.dark) .chat-bubble.assistant .md .chat-inline-link,
html:not(.dark) .chat-bubble--assistant .md .chat-inline-link {
  color: #bf0000;
}
.chat-bubble.assistant .md .chat-inline-link:hover,
.chat-bubble--assistant .md .chat-inline-link:hover {
  opacity: 0.88;
}

/* ChatGPT-style message toolbar: icon actions + overlapping source circles */
.chat-msg-toolbar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.55rem;
  min-height: 1.75rem;
  animation: chat-toolbar-in 0.32s ease-out both;
}
@keyframes chat-toolbar-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.chat-icon-btn {
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s ease, background 0.15s ease;
}
.chat-icon-btn:hover {
  color: var(--chat-text);
  background: var(--chat-accent-soft);
}
.chat-icon-btn-svg {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
}
.chat-msg-sources {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

/* Overlapping source favicons + "Sources" label */
.chat-sources {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  border: none;
}
.chat-sources-avatars {
  display: flex;
  align-items: center;
  direction: ltr;
}
.chat-source-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-left: -0.35rem;
  border-radius: 999px;
  overflow: hidden;
  text-decoration: none !important;
  background: var(--chip-color, #64748b);
  border: 1.5px solid var(--chat-bg);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--chat-border) 70%, transparent);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.chat-source-chip:first-child {
  margin-left: 0;
}
.chat-source-chip:hover {
  transform: translateY(-1px) scale(1.08);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--chip-color, #bf0000) 50%, transparent);
  z-index: 20 !important;
}
.chat-source-letter {
  position: relative;
  z-index: 0;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
}
.chat-source-favicon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #fff;
  z-index: 1;
}
/* Missing/broken icons and Google's default globe (flagged in JS) → letter shows through */
.chat-source-favicon.is-broken {
  display: none;
}
.chat-sources-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--chat-muted);
  line-height: 1;
  white-space: nowrap;
  user-select: none;
}

.chat-bubble.assistant .md code,
.chat-bubble--assistant .md code {
  font-size: 0.85em;
  background: var(--chat-accent-soft);
  padding: 0.1em 0.35em;
  border-radius: 0.35rem;
}
.chat-bubble.assistant .md pre,
.chat-bubble--assistant .md pre {
  overflow-x: auto;
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  margin: 0.65rem 0;
  font-size: 0.82rem;
}
.chat-bubble.assistant .md pre code,
.chat-bubble--assistant .md pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}
.chat-bubble.assistant .md table,
.chat-bubble--assistant .md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0.65rem 0;
}
.chat-bubble.assistant .md th,
.chat-bubble.assistant .md td,
.chat-bubble--assistant .md th,
.chat-bubble--assistant .md td {
  border: 1px solid var(--chat-border);
  padding: 0.4rem 0.55rem;
  text-align: left;
}

/* Active chat: composer pinned to bottom */
.chat-composer-dock {
  flex-shrink: 0;
  padding: 0.65rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--chat-border);
  background: color-mix(in srgb, var(--chat-bg) 86%, transparent);
  backdrop-filter: blur(12px);
}

.chat-active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.chat-shell.has-messages .chat-active {
  height: 100%;
}

.chat-composer {
  max-width: 46rem;
  margin: 0 auto;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: var(--chat-composer);
  border: 1px solid color-mix(in srgb, var(--chat-accent) 35%, var(--chat-border));
  border-radius: 1.35rem;
  padding: 0.45rem 0.5rem 0.45rem 1rem;
  box-shadow: var(--chat-shadow);
  min-height: 3.25rem;
}

html.dark .chat-composer {
  border-color: rgba(191, 0, 0, 0.45);
  background: #151c2c;
}

/* First-message landing composer only: circulating border colors (not fill / page bg) */
@property --chat-landing-border-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.chat-landing .chat-composer {
  max-width: none;
  width: 100%;
  border: 1.5px solid transparent;
  background:
    linear-gradient(var(--chat-composer), var(--chat-composer)) padding-box,
    conic-gradient(
      from var(--chat-landing-border-angle),
      #bf0000 0%,
      #545454 22%,
      #ffffff 42%,
      #545454 62%,
      #545454 78%,
      #ffffff 90%,
      #bf0000 100%
    ) border-box;
  animation: chat-landing-border-circulate 7.5s linear infinite;
}

html.dark .chat-landing .chat-composer {
  background:
    linear-gradient(#151c2c, #151c2c) padding-box,
    conic-gradient(
      from var(--chat-landing-border-angle),
      #bf0000 0%,
      #a78bfa 20%,
      #ffffff 40%,
      #545454 60%,
      #c084fc 76%,
      #ffffff 90%,
      #bf0000 100%
    ) border-box;
}

/* Uneven keyframe spacing → clockwise motion at variable angular speed */
@keyframes chat-landing-border-circulate {
  0%   { --chat-landing-border-angle: 0deg; }
  10%  { --chat-landing-border-angle: 22deg; }
  26%  { --chat-landing-border-angle: 118deg; }
  38%  { --chat-landing-border-angle: 152deg; }
  54%  { --chat-landing-border-angle: 248deg; }
  68%  { --chat-landing-border-angle: 286deg; }
  86%  { --chat-landing-border-angle: 348deg; }
  100% { --chat-landing-border-angle: 360deg; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-landing .chat-composer {
    animation: none;
    --chat-landing-border-angle: 35deg;
  }
}

.chat-composer textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--chat-text);
  font-size: 1rem;
  line-height: 1.45;
  max-height: 10rem;
  min-height: 1.45rem;
  height: 1.45rem;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  vertical-align: middle;
}

.chat-composer textarea::placeholder {
  color: var(--chat-muted);
  opacity: 1;
  line-height: 1.45;
}

.chat-send {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #bf0000 0%, #545454 100%);
  color: white;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.chat-send:disabled { opacity: 0.4; }
.chat-send:not(:disabled):hover { transform: scale(1.04); }

.chat-conv-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  color: var(--chat-muted);
  transition: background 0.12s ease, color 0.12s ease;
}

.chat-conv-item:hover,
.chat-conv-item.active {
  background: var(--chat-accent-soft);
  color: var(--chat-text);
}

.chat-typing {
  display: inline-flex;
  gap: 0.28rem;
  align-items: center;
  padding: 0.35rem 0;
}

.chat-typing span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 999px;
  background: var(--chat-muted);
  animation: chat-bounce 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

.chat-thinking {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.15rem 0;
  min-width: min(18rem, 70vw);
}

.chat-thinking-spin {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.15rem;
  color: var(--chat-accent);
  animation: chat-spin 0.85s linear infinite;
  flex-shrink: 0;
}

.chat-thinking-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--chat-text);
  line-height: 1.35;
}

.chat-thinking-sub {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--chat-muted);
  line-height: 1.35;
}

.chat-bubble-error {
  color: #b91c1c;
}

html.dark .chat-bubble-error {
  color: #fca5a5;
}

.chat-retry-row {
  display: flex;
  justify-content: flex-end;
  max-width: 48rem;
  margin: 0 auto 0.5rem;
  padding: 0 0.15rem;
}

.chat-retry {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.28rem 0.65rem;
  border-radius: 0.55rem;
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #be123c;
  background: transparent;
}

.chat-retry:hover {
  background: rgba(244, 63, 94, 0.08);
}

html.dark .chat-retry {
  color: #fda4af;
  border-color: rgba(253, 164, 175, 0.35);
}

html.dark .chat-retry:hover {
  background: rgba(244, 63, 94, 0.14);
}

.chat-oauth-btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--chat-border);
  background: var(--chat-bg);
  color: var(--chat-fg);
  font-weight: 600;
  font-size: 0.9375rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chat-oauth-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--chat-fg) 4%, var(--chat-bg));
}

.chat-oauth-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.chat-oauth-btn--email {
  background: transparent;
}

.chat-auth-divider {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.35rem 0;
  font-size: 0.75rem;
  color: var(--chat-muted);
}

.chat-auth-divider::before,
.chat-auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--chat-border);
}

.chat-auth-divider span {
  padding: 0 0.65rem;
}

.chat-auth-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid var(--chat-border);
  background: var(--chat-bg);
  color: var(--chat-fg);
  outline: none;
  font-size: 0.9375rem;
}

.chat-auth-input:focus {
  box-shadow: 0 0 0 2px rgba(191, 0, 0, 0.45);
}

.chat-auth-code {
  letter-spacing: 0.35em;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.25rem;
  font-weight: 700;
}

.chat-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  z-index: 80;
}

.chat-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(28rem, calc(100vw - 2rem));
  height: fit-content;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  background: var(--chat-sidebar);
  border: 1px solid var(--chat-border);
  border-radius: 1.25rem;
  padding: 1.5rem;
  z-index: 90;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35);
  animation: chat-modal-in 0.25s ease-out both;
}

@keyframes chat-modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-limit-notice {
  margin: 0 auto 0.65rem;
  max-width: 42rem;
  padding: 0 0.5rem;
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
  color: var(--chat-muted);
}

.chat-limit-notice > span[x-show] + span[x-show] .chat-limit-notice-link:first-child,
.chat-limit-notice .chat-limit-notice-link:first-of-type {
  margin-left: 0.35em;
}

.chat-limit-notice-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-limit-notice-link:hover {
  color: var(--chat-fg);
}

.chat-disclaimer {
  margin-top: 0.65rem;
  font-size: 11px;
  text-align: center;
  color: var(--chat-muted);
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
  padding: 0 0.5rem;
}

/* First-message landing only: pin disclaimer to the bottom of the page */
.chat-disclaimer--landing {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: max(0.85rem, env(safe-area-inset-bottom));
  z-index: 1;
  margin: 0 auto;
  max-width: min(100%, 36rem);
  line-height: 1.45;
  pointer-events: none;
}

@keyframes chat-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes chat-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@keyframes chat-spin {
  to { transform: rotate(360deg); }
}
