/* ──────────────────────────────────────────────────────────────
   Groyper Quant — UI layer
   Loaded after chat.css. Adds the branding, footer, mode control,
   toasts and accessibility polish, and overrides the base sheet
   where the layout changed.
   ────────────────────────────────────────────────────────────── */

:root {
  --af-navy: #16233d;
  --af-red: #c8102e;
  --ring: 0 0 0 2px rgba(123, 97, 255, 0.55), 0 0 0 4px rgba(0, 204, 177, 0.22);
  --footer-fg: #8b8b90;
}

/* ── Global affordances ── */

/* Several base components set `display` on a class, which outranks the UA
   [hidden] rule — so toggling `hidden` from JS silently did nothing. */
[hidden] {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 100;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  padding: 0.6rem 0.95rem;
  border-radius: 0.7rem;
  background: #fff;
  color: #000;
  font-weight: 700;
  font-size: 0.85rem;
}

:where(button, a, select, textarea, input, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 8px;
}

/* The composer already shows focus on its container — no nested ring. */
#landing-input:focus-visible,
#query-input:focus-visible,
.stage:focus-visible {
  box-shadow: none;
}

::selection {
  background: rgba(123, 97, 255, 0.35);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.26);
  background-clip: content-box;
}

kbd {
  font-family: var(--font);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.2em 0.4em;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #d4d4d8;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .stage {
    scroll-behavior: auto;
  }
}

/* ── Sidebar ── */

.sidebar {
  padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
}

.sidebar-brand {
  text-transform: none;
  letter-spacing: 0;
  align-items: center;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0 -0.15rem;
  padding: 0 0.15rem;
}

/* Without flex-shrink: 0 these compress below their content in a short window and
   the text of one block prints over the heading of the next, because flex shrinking
   happens before the parent's overflow would ever scroll. */
.side-block {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex-shrink: 0;
}

.side-block-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0.4rem 0.65rem 0.35rem;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  cursor: pointer;
  text-align: left;
}

.side-block-head:hover {
  color: var(--muted);
}

.side-block-chevron {
  width: 0.55rem;
  height: 0.55rem;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.16s ease;
  flex-shrink: 0;
}

.side-block.is-collapsed .side-block-chevron {
  transform: rotate(-45deg);
}

.side-block.is-collapsed .side-block-body {
  display: none;
}

.notes-tools {
  padding-bottom: 0.35rem;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-top {
  flex-shrink: 0;
}

.creator-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(200, 16, 46, 0.07), rgba(22, 35, 61, 0.35));
}

.creator-af {
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}

.hero-af-lockup img,
.site-footer-brand img {
  border-radius: 50%;
  object-fit: cover;
}

.creator-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.creator-line {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}

.creator-handle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
}

.creator-handle:hover {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.sidebar-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 0.7rem;
  padding: 0 0.15rem;
}

.sidebar-legal a {
  font-size: 0.7rem;
  color: var(--faint);
  text-decoration: none;
}

.sidebar-legal a:hover {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.sidebar-disclaimer {
  margin: 0;
  padding: 0 0.15rem;
  font-size: 0.65rem;
  line-height: 1.45;
  color: #5f5f66;
}

/* ── Topbar ── */

.topbar {
  gap: 0.6rem;
  padding-top: max(0px, env(safe-area-inset-top));
  z-index: 5;
  transition: background 0.2s, border-color 0.2s;
}

/* Without this the hero headline shears off against the stage's top edge as it
   scrolls past the header. */
.topbar.is-scrolled {
  background: rgba(10, 10, 14, 0.82);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border-bottom-color: var(--border);
}

/* Content dissolves into the header instead of shearing mid-glyph on the scroll
   container's top edge. */
.stage {
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 1.5rem);
  mask-image: linear-gradient(to bottom, transparent 0, #000 1.5rem);
}

.topbar-right {
  flex-wrap: nowrap;
}

.topbar-title {
  white-space: nowrap;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.icon-btn:hover {
  color: var(--fg);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
}

.usage-meter {
  font-variant-numeric: tabular-nums;
  transition: color 0.2s, border-color 0.2s;
}

.usage-meter.is-low {
  color: #fcd34d;
  border-color: rgba(252, 211, 77, 0.4);
}

.plan-pill:hover {
  border-color: var(--border-strong);
}

.plan-pill.is-pro:hover,
.plan-pill.is-ultra:hover {
  border: none;
  filter: brightness(1.08);
}

/* The segmented control below the composer is always on screen, so the topbar
   pill and the inline hint would just repeat it. Both stay in the DOM because
   chat.js writes their text; the hint becomes the live region that announces a
   mode change to screen readers. */
.mode-pill {
  display: none;
}

/* ── Landing ── */

.welcome {
  justify-content: center;
  padding-top: clamp(1.5rem, 6vh, 3.5rem);
  gap: 1.35rem;
}

.welcome-hero {
  max-width: 38rem;
  text-align: center;
}

.welcome-af-badge {
  display: block;
  width: 5.5rem;
  height: 5.5rem;
  margin: 0 auto 1.15rem;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.45);
}

.welcome-title {
  font-size: clamp(1.7rem, 4.6vw, 2.55rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.12;
}

.welcome-title-em {
  display: block;
  margin-top: 0.15em;
  background: linear-gradient(90deg, #f5f5f5 0%, #c8102e 55%, #f5f5f5 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.welcome-sub {
  max-width: 30rem;
  margin-inline: auto;
}

/* America First Plus — topbar (left of main frame, right of sidebar) */
.topbar-afplus {
  -webkit-tap-highlight-color: transparent;
}

.topbar-afplus-wordmark {
  opacity: 0.96;
}

/* ── Composer meta + mode segmented control ── */

.research-mode.is-collapsed {
  display: none;
}

.composer-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
  margin-top: 0.65rem;
}

.composer-meta .mode-hint {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.composer-meta-chat {
  margin-top: 0.5rem;
}

.composer-keys {
  margin: 0;
  font-size: 0.68rem;
  color: var(--faint);
}

@media (max-width: 620px) {
  .composer-keys {
    display: none;
  }
}

.mode-seg {
  display: inline-flex;
  padding: 0.22rem;
  gap: 0.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.03);
}

.mode-seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 0;
  border-radius: var(--radius-pill);
  padding: 0.4rem 1.05rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.12s;
}

.mode-seg-btn:hover:not(.is-active):not(.is-locked) {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.05);
}

.mode-seg-btn.is-active {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(123, 97, 255, 0.28);
}

.mode-seg-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.mode-seg-btn.is-locked {
  cursor: pointer;
  color: var(--faint);
}

.mode-seg-lock {
  position: absolute;
  top: -0.45rem;
  right: -0.25rem;
  padding: 0.08rem 0.35rem;
  border-radius: var(--radius-pill);
  background: var(--gradient);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

@media (max-width: 520px) {
  .composer-actions {
    width: auto;
    padding-left: 0;
  }
}

/* ── Suggestions ── */

.suggest-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  width: min(100%, 44rem);
}

.suggest-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem;
  max-width: 100%;
}

@media (max-width: 560px) {
  .suggest-tabs {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 0.15rem;
  }

  .suggest-tabs::-webkit-scrollbar {
    display: none;
  }

  .suggest-tab {
    flex: 0 0 auto;
  }
}

.suggest-tab {
  border: 0;
  border-radius: var(--radius-pill);
  padding: 0.28rem 0.7rem;
  background: transparent;
  color: var(--faint);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.suggest-tab:hover {
  color: var(--fg);
}

.suggest-tab.is-active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
}

.suggestions {
  max-width: 44rem;
}

.pill.suggestion {
  font-size: 0.8rem;
}

/* ── How it works ── */

.how-it-works {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  width: min(100%, 44rem);
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.how-it-works li {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}

.how-step {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-bottom: 0.2rem;
  border-radius: 50%;
  background: var(--gradient-soft);
  border: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--fg);
}

.how-it-works strong {
  font-size: 0.85rem;
  font-weight: 700;
}

.how-it-works span:not(.how-step) {
  font-size: 0.77rem;
  line-height: 1.45;
  color: var(--muted);
}

@media (max-width: 720px) {
  .how-it-works {
    grid-template-columns: 1fr;
  }
}

/* ── Landing footer ── */

.site-footer {
  width: min(100%, 46rem);
  margin-top: auto;
  padding-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  border-top: 1px solid var(--border);
  text-align: left;
}

.site-footer-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.site-footer-title {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.site-footer-by {
  margin: 0.1rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.site-footer-by a {
  color: var(--fg);
  font-weight: 700;
  text-decoration: none;
}

.site-footer-by a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
}

.site-footer-links a {
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
}

.site-footer-links a:hover {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.site-footer-note,
.site-footer-disclaimer {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.55;
  color: var(--footer-fg);
}

.site-footer-disclaimer {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  color: #7a7a80;
}

.site-footer-disclaimer strong {
  color: #d4d4d8;
}

.site-footer-disclaimer a,
.site-footer-note a {
  color: #b8b8bf;
}

.status-line.queue-line {
  color: #fcd34d;
}

/* ── Answer body ── */

/* Prose supplies the space before a chip; a trailing margin would only show up as
   a gap in front of the sentence's period. */
.bubble .cite {
  margin: 0 0 0 0.12rem;
}

.bubble .ans-list {
  display: block;
  margin: 0.5rem 0;
  padding-left: 1.2rem;
}

.bubble .ans-list li {
  margin: 0.25rem 0;
  padding-left: 0.1rem;
}

.bubble .ans-list li::marker {
  color: var(--cite);
}

/* ── Chat composer footer ── */

.composer-wrap {
  padding-bottom: max(1.1rem, calc(env(safe-area-inset-bottom) + 0.35rem));
}

.composer-foot {
  line-height: 1.5;
  color: var(--faint);
}

.composer-foot a {
  color: var(--muted);
  text-decoration: none;
}

.composer-foot a:hover {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

/* ── Scroll to latest ── */

.scroll-bottom {
  position: absolute;
  right: 1.35rem;
  bottom: calc(var(--composer-h) + 1.35rem);
  z-index: 30;
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: blur(10px);
  color: var(--fg);
  cursor: pointer;
  box-shadow: var(--shadow);
  animation: fade-up 0.2s ease;
}

.scroll-bottom[hidden] {
  display: none;
}

.scroll-bottom:hover {
  border-color: rgba(255, 255, 255, 0.32);
}

/* ── Answer actions ── */

.answer-actions {
  gap: 0.35rem;
}

.answer-action {
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.answer-action:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* ── Modals ── */

.modal {
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
}

/* Cards scroll internally so tall dialogs never clip against grid centering. */
.modal-card {
  max-height: min(88dvh, 52rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-kicker {
  margin: 0 0 0.3rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.modal-title {
  letter-spacing: -0.02em;
}

.modal-note a,
.modal-sub a {
  color: var(--muted);
}

.auth-consent {
  margin: 0.9rem 0 0;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--faint);
}

.auth-consent a {
  color: var(--muted);
}

.billing-consent {
  margin: 1rem 0 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--muted);
  text-align: left;
}

.billing-consent a {
  color: var(--fg);
}

/* .modal-card is declared after .plans-card in the base sheet, so the wide
   dialogs need the extra class to win the tie. */
.modal-card.plans-card {
  width: min(52rem, calc(100vw - 2rem));
  max-width: none;
}

.modal-card.help-card {
  width: min(34rem, calc(100vw - 2rem));
  max-width: none;
}

.modal-card.share-card {
  width: min(34rem, calc(100vw - 2rem));
}

.share-preview-wrap {
  margin: 0.85rem 0 1rem;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.35);
  min-height: 9rem;
  display: grid;
  place-items: center;
}

.share-card-preview {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
}

.share-card-status {
  margin: 0;
  padding: 1.5rem 1rem;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
}

.share-btn.is-primary {
  border-color: rgba(0, 204, 177, 0.45);
  background: linear-gradient(135deg, rgba(0, 204, 177, 0.16), rgba(123, 97, 255, 0.14));
}

.save-tag {
  margin-left: 0.35rem;
  padding: 0.08rem 0.35rem;
  border-radius: var(--radius-pill);
  background: rgba(0, 204, 177, 0.16);
  color: #5eead4;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.plan-tile {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.15s, transform 0.12s;
}

.plan-tile:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.plan-tile.is-current {
  border-color: rgba(0, 204, 177, 0.5);
  background: rgba(0, 204, 177, 0.05);
}

.plan-tile ul {
  flex: 1;
  list-style: none;
  padding-left: 0;
}

.plan-tile ul li {
  position: relative;
  padding-left: 1.05rem;
  margin: 0.25rem 0;
}

.plan-tile ul li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 800;
}

.plan-tile ul li.is-off {
  color: var(--faint);
}

.plan-tile ul li.is-off::before {
  content: "—";
  color: var(--faint);
}

.plan-tile {
  position: relative;
}

.plan-badge {
  position: absolute;
  top: -0.6rem;
  right: 0.85rem;
  padding: 0.14rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--gradient);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.plan-badge.is-current-badge {
  background: rgba(0, 204, 177, 0.9);
  color: #04211d;
}

.plan-sub {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  color: var(--faint);
}

.plan-blurb {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.share-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.share-btn:hover {
  border-color: transparent;
  background: var(--gradient-soft);
  transform: translateY(-1px);
}

.share-ico {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  font-size: 0.8rem;
}

.help-card {
  max-width: 34rem;
  width: min(34rem, calc(100vw - 2rem));
  text-align: left;
}

.help-card .modal-title {
  margin: 0 0 0.9rem;
  font-size: 1.25rem;
}

.help-list {
  margin: 0 0 1.1rem;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.help-list strong {
  color: var(--fg);
}

/* ── Signed-in account modal ── */

.auth-signed-in {
  margin: 0.35rem 0 0.85rem;
  text-align: left;
}

.auth-signed-in-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(0, 204, 177, 0.45);
  border-radius: 14px;
  background: linear-gradient(
    135deg,
    rgba(0, 204, 177, 0.1),
    rgba(123, 97, 255, 0.12)
  );
}

.auth-modal-avatar {
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1rem;
}

.auth-signed-in-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.auth-signed-in-copy strong {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-signed-in-copy small {
  color: var(--muted);
  font-size: 0.78rem;
}

.auth-logout {
  width: 100%;
  margin-top: 0.85rem;
  min-height: 2.75rem;
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: var(--radius-pill);
  background: rgba(248, 113, 113, 0.08);
  color: #fecaca;
  font-weight: 700;
  cursor: pointer;
}

.auth-logout:hover {
  background: rgba(248, 113, 113, 0.14);
}

/* ── Account & data panel ── */

.account-panel {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  text-align: left;
}

.account-panel-label {
  margin: 0 0 0.55rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.account-btn {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.9rem;
  background: transparent;
  color: var(--fg);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.account-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.account-btn.is-danger {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.42);
}

.account-btn.is-danger:hover {
  background: rgba(248, 113, 113, 0.12);
  color: #fecaca;
}

.account-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.account-status {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.account-status.is-ok {
  color: #86efac;
}

.account-status.is-err {
  color: #fca5a5;
}

.account-note {
  margin: 0.6rem 0 0;
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--faint);
}

.account-note a {
  color: var(--muted);
}

/* ── Toasts ── */

.toast-host {
  position: fixed;
  left: 50%;
  /* Clears the composer so a toast never sits on top of the send button. */
  bottom: max(6rem, calc(env(safe-area-inset-bottom) + 6rem));
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  pointer-events: none;
  width: min(28rem, calc(100vw - 2rem));
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  max-width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--bg-elevated) 94%, transparent);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  color: var(--fg);
  font-size: 0.83rem;
  font-weight: 600;
  animation: toast-in 0.18s ease;
}

.toast.is-out {
  animation: toast-out 0.22s ease forwards;
}

.toast.is-err {
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

.toast.is-ok .toast-dot {
  background: var(--accent);
}

.toast-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

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

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ── Empty states ── */

.side-empty {
  margin: 0;
  padding: 0.35rem 0.75rem 0.6rem;
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--faint);
}

/* ── Mobile ── */

@media (max-width: 860px) {
  .topbar-right {
    gap: 0.3rem;
  }

  .usage-meter {
    padding: 0.26rem 0.5rem;
    font-size: 0.68rem;
  }

  .welcome {
    padding-inline: 1rem;
    min-height: auto;
  }

  .welcome-title {
    font-size: clamp(1.45rem, 6.5vw, 2.1rem);
  }

  .welcome-af-badge {
    width: 4.75rem;
    height: 4.75rem;
  }

  .composer-meta {
    gap: 0.45rem;
  }

  .site-footer {
    padding-top: 1.5rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }

  .scroll-bottom {
    right: 0.9rem;
    bottom: calc(5.5rem + env(safe-area-inset-bottom));
  }

  .billing-consent {
    font-size: 0.82rem;
    text-align: left;
  }

  .toast-stack {
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
    width: auto;
  }

  /* Beat base .modal / .modal-card.plans-card rules from this file */
  .modal {
    place-items: end center;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .modal-card,
  .modal-card.plans-card,
  .modal-card.help-card,
  .modal-card.share-card {
    width: 100%;
    max-width: none;
    max-height: min(92dvh, 100%);
    border-radius: 18px 18px 0 0;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
  }
}

@media (max-width: 560px) {
  .topbar-title {
    display: none;
  }

  .mode-seg {
    width: 100%;
    justify-content: stretch;
  }

  .mode-opt {
    flex: 1;
    justify-content: center;
    min-height: 2.5rem;
  }
}

@media (max-width: 420px) {
  .welcome-af-badge,
  .welcome-mark {
    width: 3.75rem;
    height: 3.75rem;
  }

  .site-footer-links a {
    font-size: 0.74rem;
  }

  .usage-meters .usage-meter:nth-child(2) {
    display: none;
  }
}
