/* ============================================================
   ALGOMARK · Chat — Redesigned May 2026
   Extends /vault/style-v2.css. Tokens come from there — no new
   colors, fonts, or spacing primitives are introduced here.
   ============================================================ */

[x-cloak] { display: none !important; }

/* Local extensions to the design tokens — for cursor glow and
   conic gradient angles. Colors/fonts/space all reuse vault tokens. */
:root {
  --mx: 50%;
  --my: 50%;
  --cmx: 50%;
  --cmy: 50%;
}
@property --angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }

.chat-body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  height: 100dvh;
  overflow: hidden;
  display: block;
  min-height: 0;
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1, 'ss01' 1;
}

/* Paper texture — same as homepage */
.chat-body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  mix-blend-mode: multiply;
  z-index: 0;
  opacity: 0.55;
}

/* ============================================================
   SHARED — eyebrow, brand mark, dot pulse
   ============================================================ */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.28em;
  color: var(--accent);
  font-weight: 500;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--accent-tint);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  position: relative;
  z-index: 1;
}
.eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 2.4s var(--ease) infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(123, 31, 31, 0.45); }
  50%      { box-shadow: 0 0 0 6px rgba(123, 31, 31, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .eyebrow-dot { animation: none; }
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}
.brand-wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.18em;
  color: var(--ink);
}
.brand-divider {
  display: inline-block;
  width: 1px;
  height: 14px;
  background: var(--line-strong);
}
.brand-edition {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: var(--text-sm);
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-muted);
}
.brand-status {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.18em;
  color: var(--ink-muted);
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.brand-status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(123, 31, 31, 0.45);
  animation: pulse-dot 2.4s var(--ease) infinite;
}

/* ============================================================
   AUTH GATE — premium, kinetic, persuasive
   ============================================================ */
.auth-gate {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--paper);
  position: relative;
  overflow: hidden;
}

/* Cursor-tracking ambient glow */
.auth-gate::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(620px circle at var(--mx) var(--my),
      rgba(123, 31, 31, 0.08) 0%,
      rgba(123, 31, 31, 0.03) 30%,
      transparent 65%);
  pointer-events: none;
  z-index: 0;
  transition: background 80ms linear;
}

/* Subtle grid scaffolding */
.auth-gate::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(22,22,26,0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(22,22,26,0.025) 1px, transparent 1px);
  background-size: clamp(48px, 6vw, 80px) clamp(48px, 6vw, 80px);
  mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black, transparent 80%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
}

@media (prefers-reduced-motion: reduce) {
  .auth-gate::before { background: none; }
}

.auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-4) clamp(var(--space-4), 4vw, var(--space-7));
  border-bottom: 1px solid var(--line);
  background: rgba(250, 249, 246, 0.85);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  position: relative;
  z-index: 5;
}

.auth-nav {
  display: inline-flex;
  align-items: center;
  gap: clamp(1rem, 2vw, 2rem);
}
.auth-nav-link {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-muted);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
.auth-nav-link:hover { color: var(--ink); }
.auth-nav-link.is-secondary {
  color: var(--paper);
  padding: 0.45rem 1rem;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 4px;
  transition: all var(--t-norm) var(--ease);
}
.auth-nav-link.is-secondary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

@media (max-width: 720px) {
  .brand-status { display: none; }
  .auth-nav-link:not(.is-secondary) { display: none; }
}

.auth-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  align-content: center;
  justify-items: center;
  gap: clamp(2.5rem, 5vw, 4.5rem);
  padding: clamp(2.5rem, 5vw, 5rem) clamp(1.25rem, 4vw, 2.5rem);
  max-width: 1240px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  z-index: 1;
}
@media (min-width: 980px) {
  .auth-main {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    align-items: center;
    column-gap: clamp(2.5rem, 4vw, 5rem);
  }
}

.auth-text {
  position: relative;
  z-index: 1;
  max-width: 580px;
  width: 100%;
}

.auth-headline {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.4rem, 1.5rem + 4vw, 4.75rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 1.5rem;
  font-feature-settings: 'ss01' 1, 'ss02' 1;
  font-optical-sizing: auto;
}
.auth-headline .morph {
  position: relative;
  display: inline-block;
  color: var(--accent);
  font-style: italic;
  font-weight: 500;
  vertical-align: baseline;
  min-height: 1em;
}
.auth-headline .morph-word {
  display: inline-block;
  transition: opacity 360ms var(--ease), transform 360ms var(--ease), filter 360ms var(--ease);
}
.auth-headline .morph-word.is-out {
  opacity: 0;
  transform: translateY(-12px);
  filter: blur(6px);
}
.auth-headline .morph-word.is-in {
  opacity: 0;
  transform: translateY(12px);
  filter: blur(6px);
}
.auth-headline .morph-word.is-active {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

.auth-sub {
  font-family: var(--sans);
  font-weight: 400;
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.1875rem);
  color: var(--ink-body);
  max-width: 52ch;
  margin: 0 0 clamp(2rem, 3vw, 2.5rem);
  line-height: 1.7;
}
.auth-sub strong {
  font-weight: 500;
  color: var(--ink);
}

.auth-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-3);
  align-items: stretch;
  margin-bottom: var(--space-3);
  max-width: 520px;
}
@media (max-width: 540px) {
  .auth-form { grid-template-columns: 1fr; }
}

.auth-field {
  position: relative;
  display: block;
}
.auth-field-label {
  position: absolute;
  top: 8px;
  left: 16px;
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  pointer-events: none;
}
.auth-input {
  background: var(--paper-raised);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--text-md);
  padding: 28px 16px 12px;
  border-radius: var(--r-md);
  width: 100%;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.auth-input::placeholder { color: var(--ink-faint); }
.auth-input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: var(--shadow-focus);
}
.auth-input:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.9375rem;
  padding: 1rem 1.5rem;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  will-change: transform;
  letter-spacing: 0.005em;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 6px 18px -6px rgba(22, 22, 26, 0.35);
  transition: background var(--t-norm) var(--ease), border-color var(--t-norm) var(--ease), box-shadow 240ms var(--ease);
}
.auth-submit:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 12px 28px -8px rgba(123, 31, 31, 0.45);
}
.auth-submit:disabled { opacity: 0.45; cursor: not-allowed; }
.auth-submit .arrow {
  font-family: var(--mono);
  transition: transform 220ms var(--ease);
}
.auth-submit:hover:not(:disabled) .arrow { transform: translateX(4px); }

.auth-status {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-body);
  background: var(--paper-sunk);
  border: 1px solid var(--line);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-md);
  font-family: var(--sans);
}
.auth-status-error {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-tint);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-6) 0 var(--space-4);
  color: var(--ink-faint);
  font-size: var(--text-xs);
  letter-spacing: var(--ls-loose);
  text-transform: uppercase;
  font-family: var(--mono);
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-google {
  width: 100%;
  max-width: 520px;
  background: var(--paper-raised);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-md);
  cursor: pointer;
  margin-bottom: var(--space-4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.auth-google:hover {
  border-color: var(--ink);
  background: var(--paper);
}
.auth-google:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-google-icon { width: 18px; height: 18px; display: block; }

.auth-fineprint {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: var(--space-3);
  margin-bottom: var(--space-6);
  max-width: 480px;
}

.auth-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  max-width: 580px;
}
.auth-meta strong { color: var(--ink); font-weight: 500; }
.auth-meta-sep { color: var(--ink-faint); }

/* -------- Auth gate live chat preview -------- */
.chat-preview {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 540px;
  justify-self: stretch;
  align-self: center;
  padding: 1.25rem;
  border-radius: 12px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px -20px rgba(22, 22, 26, 0.16), 0 0 0 1px rgba(22, 22, 26, 0.05);
}
@media (min-width: 980px) {
  .chat-preview { justify-self: end; }
}
/* Conic-gradient outer ring */
.chat-preview::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 13px;
  padding: 1px;
  background: conic-gradient(from var(--angle),
    transparent 0deg,
    var(--accent-line) 50deg,
    transparent 110deg,
    transparent 250deg,
    var(--accent-line) 310deg,
    transparent 360deg);
  mask: linear-gradient(black, black) content-box, linear-gradient(black, black);
  -webkit-mask: linear-gradient(black, black) content-box, linear-gradient(black, black);
  mask-composite: exclude;
  -webkit-mask-composite: xor;
  animation: spin-ring 9s linear infinite;
  pointer-events: none;
  opacity: 0.7;
}
@keyframes spin-ring { to { --angle: 360deg; } }
@media (prefers-reduced-motion: reduce) { .chat-preview::before { animation: none; } }

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 1rem;
}
.chat-head-label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.chat-head-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 2.4s var(--ease) infinite;
}
.chat-head-meta {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.chat-q {
  font-family: var(--serif);
  font-size: clamp(1rem, 0.92rem + 0.5vw, 1.25rem);
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
  letter-spacing: -0.01em;
  padding: 0.85rem 0;
  min-height: 2.4em;
  display: flex;
  align-items: center;
}
.chat-q::before {
  content: '\203A';
  font-family: var(--mono);
  color: var(--accent);
  margin-right: 0.65rem;
  font-weight: 400;
  font-size: 1.4em;
  line-height: 0.7;
}
.typing-caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: -0.18em;
  animation: caret-blink 0.95s steps(1, end) infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .typing-caret { animation: none; opacity: 0; } }

.chat-a-wrap {
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
}
.chat-a-label {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.chat-a-label .label-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.chat-a {
  font-family: var(--serif);
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--ink-body);
  letter-spacing: -0.003em;
  min-height: 4.4em;
}
.chat-a .cite {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7em;
  color: var(--accent);
  vertical-align: 0.35em;
  padding: 0 0.18em;
  font-weight: 500;
  transform: translateY(2px);
  opacity: 0;
  transition: opacity 240ms var(--ease), transform 240ms var(--ease);
}
.chat-a .cite.is-shown { transform: translateY(0); opacity: 1; }

.chat-sources {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 0.55rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 360ms var(--ease), transform 360ms var(--ease);
}
.chat-sources.is-shown { opacity: 1; transform: translateY(0); }
.chat-sources .source {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  line-height: 1.4;
}
.chat-sources .source-num { color: var(--accent); font-weight: 500; flex-shrink: 0; }
.chat-sources .source-name {
  color: var(--ink-body);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-sources .source-time { color: var(--ink-faint); flex-shrink: 0; }

.chat-foot {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.chat-foot-mark { color: var(--accent); font-weight: 500; }

/* ============================================================
   SIGNED-IN SHELL
   ============================================================ */
.chat-shell {
  display: grid;
  grid-template-columns: 296px 1fr;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
@media (max-width: 800px) {
  .chat-shell { grid-template-columns: 1fr; }
  .chat-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    transform: translateX(-100%);
    transition: transform var(--t-norm) var(--ease);
    z-index: 100;
    box-shadow: var(--shadow-md);
  }
  .chat-shell.sidebar-open .chat-sidebar { transform: translateX(0); }
  .chat-shell.sidebar-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(22, 22, 26, 0.32);
    z-index: 50;
  }
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.chat-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--paper-sunk);
  border-right: 1px solid var(--line);
  height: 100dvh;
  overflow: hidden;
  z-index: 200;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
  min-height: 64px;
  flex-shrink: 0;
}
.sidebar-close {
  display: none;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: var(--text-md);
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  cursor: pointer;
  line-height: 1;
}
@media (max-width: 800px) {
  .sidebar-close { display: inline-flex; align-items: center; justify-content: center; }
}

/* New conversation — primary CTA, magnetic */
.sidebar-new {
  margin: var(--space-4) var(--space-4) var(--space-3);
  background: var(--ink);
  border: 1px solid var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 0.7rem 0.95rem;
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: left;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  position: relative;
  will-change: transform;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 4px 12px -4px rgba(22, 22, 26, 0.25);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.sidebar-new:hover {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 8px 22px -6px rgba(123, 31, 31, 0.45);
}
.sidebar-new-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}
.sidebar-new-shortcut {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 400;
}

/* Search */
.sidebar-search {
  position: relative;
  margin: 0 var(--space-4) var(--space-3);
  display: flex;
  align-items: center;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0 var(--space-3);
  transition: border-color var(--t-fast) var(--ease);
}
.sidebar-search.is-active,
.sidebar-search:focus-within {
  border-color: var(--ink-faint);
  background: var(--paper);
}
.sidebar-search-icon {
  flex-shrink: 0;
  color: var(--ink-faint);
}
.sidebar-search-input {
  flex: 1;
  background: transparent;
  border: none;
  font-family: var(--sans);
  font-size: var(--text-sm);
  color: var(--ink);
  padding: 0.5rem 0.5rem 0.5rem 0.55rem;
  outline: none;
  -webkit-appearance: none;
}
.sidebar-search-input::placeholder { color: var(--ink-faint); }
.sidebar-search-input::-webkit-search-cancel-button { display: none; }
.sidebar-search-clear {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0 var(--space-1);
  cursor: pointer;
}
.sidebar-search-clear:hover { color: var(--accent); }

/* Group label */
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-3) var(--space-4);
  scrollbar-width: thin;
}
.sidebar-empty,
.sidebar-loading {
  padding: var(--space-5) var(--space-4);
  color: var(--ink-faint);
  font-size: var(--text-sm);
  font-family: var(--serif);
  font-style: italic;
}
.sidebar-empty-fine {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  display: block;
  margin-top: 4px;
}
.sidebar-loading::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--ink-faint);
  animation: sidebar-loading-pulse 1.4s ease-in-out infinite;
}
@keyframes sidebar-loading-pulse {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar-loading::after { animation: none; opacity: 0.6; }
}

.sidebar-group { margin-bottom: var(--space-3); }
.sidebar-group-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: var(--space-3) var(--space-3) var(--space-2);
  font-weight: 500;
  position: sticky;
  top: 0;
  background: linear-gradient(to bottom, var(--paper-sunk) 80%, transparent);
  z-index: 1;
}

.sidebar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: var(--space-2) var(--space-3);
  margin-bottom: 1px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--ink-body);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  position: relative;
}
.sidebar-row:hover { background: var(--paper-raised); color: var(--ink); }
.sidebar-row.is-active {
  background: var(--paper-raised);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-soft);
}
.sidebar-row.is-active::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.row-mark {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex-shrink: 0;
  transition: background var(--t-fast) var(--ease);
}
.sidebar-row:hover .row-mark,
.sidebar-row.is-active .row-mark { background: var(--accent); }

.row-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: var(--space-2);
}
.row-delete {
  background: transparent;
  border: none;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 4px;
  opacity: 0;
  line-height: 0;
  border-radius: var(--r-xs);
  transition: opacity var(--t-fast) var(--ease), color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.sidebar-row:hover .row-delete,
.sidebar-row.is-active .row-delete { opacity: 1; }
.row-delete:hover {
  color: var(--accent);
  background: var(--accent-tint);
}

@media (hover: none) {
  .row-delete { opacity: 0.55; }
}

/* Sidebar foot — quota meter + account */
.sidebar-foot {
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-top: 1px solid var(--line);
  background: var(--paper-sunk);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex-shrink: 0;
}

.quota-meter {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.quota-meter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.quota-meter-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}
.tier-label {
  display: inline-block;
  padding: 2px 7px;
  background: var(--accent-tint);
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-xs);
  font-weight: 600;
  font-size: 0.625rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: var(--sans);
}
.quota-meter-bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.quota-meter-fill {
  height: 100%;
  background: linear-gradient(to right, var(--accent-soft), var(--accent));
  transition: width 360ms var(--ease), box-shadow 360ms var(--ease);
}
/* Near-limit — Free user past 80% (4 of 5 used) — oxblood glow on meter */
.quota-meter.is-near-limit .quota-meter-fill {
  background: linear-gradient(to right, var(--accent), var(--accent-deep));
  box-shadow: 0 0 0 1px var(--accent-line), 0 0 10px -1px rgba(123, 31, 31, 0.45);
}
.quota-meter.is-at-limit .quota-meter-fill {
  background: var(--accent-deep);
  box-shadow: 0 0 0 1px var(--accent), 0 0 14px -2px rgba(123, 31, 31, 0.55);
  animation: quota-pulse 2s ease-in-out infinite;
}
@keyframes quota-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}
@media (prefers-reduced-motion: reduce) {
  .quota-meter.is-at-limit .quota-meter-fill { animation: none; }
}

/* Tier pill — paid tier gets a stronger oxblood treatment */
.tier-label.is-paid {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}

/* ----------------------------------------------------------
   Subscription state pill (cancelled-at-period-end / past-due)
   Only renders when we have something to say beyond plain active.
   ---------------------------------------------------------- */
.sub-state {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--paper);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
}
.sub-state-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-muted);
}
.sub-state-cancelled {
  border-color: var(--accent-line);
  color: var(--accent);
  background: var(--accent-tint);
}
.sub-state-cancelled .sub-state-dot { background: var(--accent); }
.sub-state-past-due {
  border-color: var(--accent);
  color: var(--paper);
  background: var(--accent);
}
.sub-state-past-due .sub-state-dot {
  background: var(--paper);
  animation: pulse-dot 1.6s var(--ease) infinite;
}
@media (prefers-reduced-motion: reduce) {
  .sub-state-past-due .sub-state-dot { animation: none; }
}

/* ----------------------------------------------------------
   Upgrade CTA — sidebar foot, Free tier only
   ---------------------------------------------------------- */
.upgrade-cta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.85rem;
  background: var(--paper);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-sm);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  transition: background 200ms var(--ease), border-color 200ms var(--ease), transform 200ms var(--ease), box-shadow 200ms var(--ease);
  text-align: left;
  width: 100%;
}
.upgrade-cta:hover:not(:disabled) {
  background: var(--accent-tint);
  border-color: var(--accent);
  box-shadow: 0 6px 18px -10px rgba(123, 31, 31, 0.45);
}
.upgrade-cta:disabled {
  opacity: 0.7;
  cursor: progress;
}
.upgrade-cta.is-primary {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
  box-shadow: 0 8px 22px -10px rgba(123, 31, 31, 0.55);
}
.upgrade-cta.is-primary:hover:not(:disabled) {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  box-shadow: 0 12px 28px -10px rgba(123, 31, 31, 0.65);
}
.upgrade-cta-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
  flex-shrink: 0;
}
.upgrade-cta.is-primary .upgrade-cta-mark {
  background: rgba(255, 255, 255, 0.18);
  color: var(--paper);
}
.upgrade-cta-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upgrade-cta-meta {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  white-space: nowrap;
}
.upgrade-cta.is-primary .upgrade-cta-meta {
  color: rgba(255, 255, 255, 0.78);
}

/* ----------------------------------------------------------
   Manage subscription — Operator tier
   ---------------------------------------------------------- */
.manage-sub-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.55rem 0.7rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 160ms var(--ease), border-color 160ms var(--ease), background 160ms var(--ease);
  text-align: left;
  width: 100%;
}
.manage-sub-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-tint);
}
.manage-sub-btn:disabled {
  opacity: 0.7;
  cursor: progress;
}
/* Dunning state — payment failed, attention required */
.manage-sub-btn.is-dunning {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-tint);
}
.manage-sub-btn.is-dunning:hover:not(:disabled) {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}
.manage-sub-text {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.manage-sub-meta {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  text-transform: lowercase;
}
.manage-sub-btn:hover:not(:disabled) .manage-sub-meta {
  color: var(--accent);
}
.manage-sub-btn.is-dunning .manage-sub-meta {
  color: var(--accent);
}
.manage-sub-btn.is-dunning:hover:not(:disabled) .manage-sub-meta {
  color: var(--paper);
}
.manage-sub-arrow {
  font-family: var(--serif);
  font-style: italic;
  transition: transform 160ms var(--ease);
}
.manage-sub-btn:hover:not(:disabled) .manage-sub-arrow {
  transform: translateX(2px);
}

.sidebar-account {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}
.account-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
  letter-spacing: 0;
}
.account-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.account-name {
  font-family: var(--sans);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.signout-btn {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 0;
  text-align: left;
  margin-top: 2px;
}
.signout-btn:hover { color: var(--accent); }

/* ============================================================
   CHAT MAIN COLUMN
   ============================================================ */
.chat-main {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

.chat-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--line);
  background: rgba(250, 249, 246, 0.85);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  min-height: 64px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.sidebar-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
@media (max-width: 800px) { .sidebar-toggle { display: inline-flex; } }

.chat-bar-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-title-eyebrow {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 500;
}
.chat-title {
  font-family: var(--serif);
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.005em;
}

.chat-bar-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.bar-btn:hover {
  color: var(--ink);
  border-color: var(--ink-faint);
  background: var(--paper-sunk);
}
.bar-btn-kbd {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0;
  color: inherit;
  background: var(--paper-sunk);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: 500;
}
@media (max-width: 540px) {
  .bar-btn span { display: none; }
}

.chat-meter {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--accent);
  background: var(--accent-tint);
  border: 1px solid var(--accent-line);
  padding: 4px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(2rem, 5vw, 5rem) clamp(1.25rem, 4vw, 2.5rem);
  width: 100%;
  overflow-y: auto;
  position: relative;
}
.chat-empty::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(620px circle at var(--mx) var(--my),
      rgba(123, 31, 31, 0.06) 0%,
      rgba(123, 31, 31, 0.02) 30%,
      transparent 65%);
  pointer-events: none;
  transition: background 80ms linear;
  z-index: 0;
}
@media (prefers-reduced-motion: reduce) { .chat-empty::before { background: none; } }

.chat-empty-inner {
  position: relative;
  z-index: 1;
  max-width: 880px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.chat-empty-headline {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.4rem, 1.5rem + 4vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 1.25rem;
  font-feature-settings: 'ss01' 1, 'ss02' 1;
  font-optical-sizing: auto;
}
.empty-headline-em {
  display: inline-block;
  color: var(--accent);
  font-style: italic;
  font-weight: 500;
}
.chat-empty-sub {
  font-family: var(--sans);
  font-weight: 400;
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.1875rem);
  color: var(--ink-body);
  max-width: 56ch;
  margin: 0 auto clamp(2rem, 3vw, 2.5rem);
  line-height: 1.7;
}

.starter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--paper-raised);
  width: 100%;
  max-width: 880px;
}
.starter-card {
  position: relative;
  padding: clamp(1.25rem, 2.2vw, 1.85rem);
  background: var(--paper-raised);
  border: none;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 600ms var(--ease), transform 600ms var(--ease), background 240ms var(--ease);
  --cx: 50%;
  --cy: 50%;
}
.starter-card.is-in {
  opacity: 1;
  transform: translateY(0);
}
@media (max-width: 720px) {
  .starter-card { transform: translateY(0); opacity: 1; }
}
.starter-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(280px circle at var(--cx) var(--cy),
    rgba(123, 31, 31, 0.07),
    transparent 65%);
  opacity: 0;
  transition: opacity 240ms var(--ease);
  pointer-events: none;
  z-index: 0;
}
.starter-card:hover::before { opacity: 1; }
.starter-card:hover { background: var(--paper); }
.starter-card > * { position: relative; z-index: 1; }

.starter-card:nth-child(3n) { border-right: none; }
@media (max-width: 720px) {
  .starter-card { border-right: none; }
}

.starter-num {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.starter-num-text { color: var(--ink-faint); }
.starter-tag {
  color: var(--accent);
  font-weight: 500;
}
.starter-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1rem, 0.94rem + 0.4vw, 1.1875rem);
  line-height: 1.35;
  letter-spacing: -0.012em;
  color: var(--ink);
  flex: 1;
}
.starter-title::before {
  content: '\203A';
  color: var(--accent);
  margin-right: 0.4rem;
  font-family: var(--mono);
}
.starter-arrow {
  align-self: flex-end;
  color: var(--ink-faint);
  transition: color var(--t-norm) var(--ease), transform var(--t-norm) var(--ease);
}
.starter-card:hover .starter-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

.empty-foot {
  margin-top: clamp(2rem, 3vw, 2.5rem);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 1rem;
}
.empty-foot strong { color: var(--ink); font-weight: 500; }
.empty-foot-sep { color: var(--ink-faint); }

/* ============================================================
   MESSAGE THREAD
   ============================================================ */
.message-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  padding: var(--space-6) clamp(var(--space-4), 4vw, var(--space-7)) clamp(var(--space-7), 8vw, 6rem);
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
  scrollbar-width: thin;
}

.message-row {
  margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
  position: relative;
}
.message-row.role-user .message-bubble {
  background: var(--paper-sunk);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--space-4) var(--space-5);
  margin-left: clamp(0px, 12vw, 96px);
}
.message-row.role-assistant .message-bubble {
  padding: 0 0 0 calc(28px + var(--space-3));
  position: relative;
}

.message-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.message-row.role-assistant .message-head {
  margin-left: calc(-1 * (28px + var(--space-3)));
}

/* Avatar — small round mark with Fraunces "A". Sits next to header. */
.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--paper-raised);
  border: 1px solid var(--accent-line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  box-shadow: inset 0 0 0 1px var(--paper-raised), 0 1px 0 rgba(22,22,26,0.04);
}
.message-avatar-glyph {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
  line-height: 1;
  letter-spacing: 0;
  font-feature-settings: 'ss01' 1;
}

.message-role {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.message-row.role-user .message-role { color: var(--ink-muted); }

.message-time {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-left: auto;
}

.message-status {
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--text-sm);
  color: var(--ink-muted);
  margin-left: auto;
}

.message-content {
  font-family: var(--serif);
  font-size: var(--text-md);
  line-height: var(--lh-prose);
  color: var(--ink);
  letter-spacing: -0.003em;
  font-feature-settings: 'ss01' 1, 'tnum' 0;
  font-optical-sizing: auto;
}
.message-content p { margin-bottom: var(--space-3); }
.message-content p:last-child { margin-bottom: 0; }
.message-content code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--paper-sunk);
  padding: 1px var(--space-1);
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
}
.message-content pre {
  background: var(--paper-sunk);
  border: 1px solid var(--line);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-md);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: var(--text-sm);
  margin: var(--space-3) 0;
  line-height: 1.55;
}
.message-content pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: inherit;
}
.message-content blockquote {
  border-left: 2px solid var(--accent);
  padding-left: var(--space-4);
  margin: var(--space-3) 0;
  color: var(--ink-soft);
  font-style: italic;
}
.message-content ul,
.message-content ol {
  padding-left: var(--space-5);
  margin: var(--space-3) 0;
}
.message-content li { margin-bottom: var(--space-2); }
.message-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: text-decoration-thickness var(--t-fast) var(--ease);
}
.message-content a:hover {
  color: var(--accent-deep);
  text-decoration-thickness: 2px;
}
.message-content hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: var(--space-4) 0;
}
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: var(--ls-display);
  color: var(--ink);
  margin: var(--space-5) 0 var(--space-3);
  line-height: var(--lh-tight);
}
.message-content h1 { font-size: var(--text-xl); }
.message-content h2 { font-size: var(--text-lg); }
.message-content h3 { font-size: var(--text-md); font-weight: 600; }
.message-content h4 { font-size: var(--text-md); font-weight: 500; font-style: italic; }

.message-retry {
  margin-top: var(--space-3);
  background: transparent;
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-family: var(--sans);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.message-retry:hover { background: var(--accent-tint); }

/* Hover-reveal action row */
.message-actions {
  display: flex;
  gap: 6px;
  margin-top: var(--space-3);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity var(--t-norm) var(--ease), transform var(--t-norm) var(--ease);
}
.message-actions.role-user { justify-content: flex-end; }
.message-row:hover .message-actions,
.message-row:focus-within .message-actions {
  opacity: 1;
  transform: translateY(0);
}
.msg-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.msg-action:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-tint);
}
.msg-action:disabled { opacity: 0.4; cursor: not-allowed; }

@media (hover: none) {
  .message-actions { opacity: 1; }
}

/* Streaming row */
.message-row.is-streaming { animation: stream-fade-in 240ms var(--ease) both; }
@keyframes stream-fade-in {
  from { opacity: 0.4; }
  to   { opacity: 1; }
}

/* Trailing-edge fade on the actively-streaming message content.
   New text appears under a soft gradient at the bottom edge and becomes
   fully opaque as more lines push it up. Combined with the buffered
   reveal in chat.js (rAF-paced char drip), the effect is a smooth fade-in
   of incoming text rather than a clunky burst on each SSE chunk. */
.message-row.is-streaming .message-content {
  -webkit-mask-image: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 1) calc(100% - 1.8em),
    rgba(0, 0, 0, 0.35) 100%
  );
  mask-image: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 1) calc(100% - 1.8em),
    rgba(0, 0, 0, 0.35) 100%
  );
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  /* Smooth re-layout of the mask edge as text grows */
  transition: -webkit-mask-position 80ms linear, mask-position 80ms linear;
}
@media (prefers-reduced-motion: reduce) {
  .message-row.is-streaming .message-content {
    -webkit-mask-image: none;
    mask-image: none;
  }
}

.thinking-indicator {
  display: inline-flex;
  gap: 6px;
  padding: var(--space-2) 0;
  margin-top: 4px;
}
.thinking-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: thinking-pulse 1.2s ease-in-out infinite;
}
.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinking-pulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40%           { opacity: 1; transform: scale(1.1); }
}
@media (prefers-reduced-motion: reduce) {
  .thinking-dot { animation: none; opacity: 0.6; }
}

.stream-cursor {
  display: inline-block;
  width: 7px;
  height: 1.05em;
  background: var(--accent);
  border-radius: 1px;
  vertical-align: text-bottom;
  margin-left: 2px;
  opacity: 0.85;
  animation: stream-cursor-pulse 1.1s ease-in-out infinite;
  /* Soft halo so the cursor feels like a glow, not a slab */
  box-shadow: 0 0 6px 1px rgba(123, 31, 31, 0.35);
}
@keyframes stream-cursor-pulse {
  0%, 100% { opacity: 0.35; transform: scaleY(0.92); }
  50%      { opacity: 0.95; transform: scaleY(1); }
}
@media (prefers-reduced-motion: reduce) {
  .stream-cursor { animation: none; opacity: 1; }
}

/* Wave 22a: Jump-to-latest pill — anchored bottom-center above composer */
.scroll-to-bottom {
  position: absolute;
  bottom: 122px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 0.95rem 0.5rem 1rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  z-index: 5;
  box-shadow:
    0 12px 32px -10px rgba(22, 22, 26, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    background 160ms var(--ease),
    border-color 160ms var(--ease),
    box-shadow 240ms var(--ease),
    transform 160ms var(--ease);
}
.scroll-to-bottom .scroll-to-bottom-label {
  font-feature-settings: 'kern' 1, 'ss01' 1;
}
.scroll-to-bottom:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateX(-50%) translateY(-2px);
}

/* Streaming variant — soft oxblood glow + breathing ring to signal
   "fresh output is appending below". Quiet, never alarming. */
.scroll-to-bottom.is-streaming {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow:
    0 12px 32px -10px rgba(123, 31, 31, 0.50),
    0 0 0 6px rgba(123, 31, 31, 0.10),
    0 0 0 1px rgba(255, 255, 255, 0.10) inset;
  animation: scroll-bottom-pulse 2.2s ease-in-out infinite;
}
@keyframes scroll-bottom-pulse {
  0%, 100% { box-shadow:
    0 12px 32px -10px rgba(123, 31, 31, 0.50),
    0 0 0 6px rgba(123, 31, 31, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.10) inset; }
  50%      { box-shadow:
    0 12px 32px -10px rgba(123, 31, 31, 0.55),
    0 0 0 14px rgba(123, 31, 31, 0.00),
    0 0 0 1px rgba(255, 255, 255, 0.10) inset; }
}
@media (prefers-reduced-motion: reduce) {
  .scroll-to-bottom.is-streaming { animation: none; }
}

/* Enter transition — slide up from below */
.scroll-to-bottom-enter {
  transition:
    opacity 240ms var(--ease),
    transform 280ms var(--ease);
}
.scroll-to-bottom-enter-start {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
}
.scroll-to-bottom-enter-end {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   COMPOSER
   ============================================================ */
.composer-wrap {
  flex-shrink: 0;
  background: linear-gradient(to bottom,
    rgba(250, 249, 246, 0) 0%,
    rgba(250, 249, 246, 0.7) 30%,
    rgba(250, 249, 246, 0.95) 100%);
  padding-top: var(--space-5);
}

.composer-edit-banner {
  max-width: 820px;
  margin: 0 auto;
  padding: var(--space-2) clamp(var(--space-4), 4vw, var(--space-7));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--accent-tint);
  border-top: 1px solid var(--accent-line);
  border-bottom: 1px solid var(--accent-line);
}
.composer-edit-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.composer-edit-cancel {
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: var(--sans);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: 0;
}
.composer-edit-cancel:hover { color: var(--accent-deep); text-decoration: underline; }

.composer {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 clamp(var(--space-4), 4vw, var(--space-7)) calc(var(--space-4) + env(safe-area-inset-bottom));
}

.composer-shell {
  position: relative;
  background: var(--paper-raised);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.composer-shell:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(123, 31, 31, 0.12);
}
.composer.is-editing .composer-shell {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(123, 31, 31, 0.10);
}

.composer-input {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  resize: none;
  font-family: var(--sans);
  font-size: var(--text-md);
  line-height: var(--lh-base);
  color: var(--ink);
  padding: var(--space-4) var(--space-5) var(--space-2);
  min-height: 56px;
  max-height: 200px;
  outline: none;
}
.composer-input::placeholder { color: var(--ink-faint); }
.composer-input:disabled { opacity: 0.55; cursor: not-allowed; }

.composer-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3) var(--space-3);
}
.composer-counter {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}
.composer-counter.is-warning { color: var(--accent); }

.composer-send {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  font-family: var(--sans);
  font-weight: 500;
  font-size: var(--text-sm);
  letter-spacing: 0.005em;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--t-norm) var(--ease), border-color var(--t-norm) var(--ease), box-shadow var(--t-norm) var(--ease);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset;
}
.composer-send:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 8px 22px -6px rgba(123, 31, 31, 0.45);
}
.composer-send:hover:not(:disabled) .arrow { transform: translateX(3px); }
.composer-send:disabled { opacity: 0.4; cursor: not-allowed; }
.composer-send .arrow { font-family: var(--mono); transition: transform 220ms var(--ease); }

.composer-stop {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--paper-sunk);
  color: var(--accent);
  border: 1px solid var(--accent-line);
  font-family: var(--sans);
  font-weight: 500;
  font-size: var(--text-sm);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.composer-stop:hover {
  background: var(--accent-tint);
  border-color: var(--accent);
}

.composer-foot {
  text-align: center;
  margin-top: var(--space-2);
  font-family: var(--sans);
  font-size: 0.7rem;
  color: var(--ink-faint);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.3rem 0.65rem;
  letter-spacing: 0.005em;
}
.composer-foot kbd {
  font-family: var(--mono);
  font-size: 0.7rem;
  background: var(--paper-sunk);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 2px;
  color: var(--ink-muted);
  font-weight: 500;
}
.composer-foot-sep { color: var(--ink-faint); }
@media (max-width: 540px) {
  .composer-foot { font-size: 0.65rem; gap: 0.2rem 0.4rem; }
  .composer-foot-sep:nth-of-type(n+2),
  .composer-foot kbd:nth-of-type(n+3),
  .composer-foot span:nth-of-type(n+4) { display: none; }
}

/* ============================================================
   SOURCE PREVIEW POPOVER
   ============================================================ */
.source-preview {
  position: fixed;
  z-index: 500;
  transform: translate(-50%, calc(-100% - 12px));
  pointer-events: none;
  max-width: 420px;
  width: max-content;
  min-width: 240px;
}
.source-preview-inner {
  background: var(--paper-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: 0 24px 60px -20px rgba(22, 22, 26, 0.28), 0 0 0 1px rgba(22, 22, 26, 0.05);
  position: relative;
  font-family: var(--sans);
}
.source-preview-inner::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: var(--paper-raised);
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}
.source-preview-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding-bottom: 6px;
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--line-soft);
}
.source-preview-num {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 600;
}
.source-preview-file {
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--text-sm);
  color: var(--ink);
  overflow-wrap: anywhere;
}
.source-preview-quote {
  font-family: var(--serif);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--ink-body);
  font-style: italic;
}
.source-preview-empty {
  font-family: var(--sans);
  font-size: var(--text-xs);
  color: var(--ink-muted);
}
.source-preview-foot {
  margin-top: var(--space-2);
  padding-top: 6px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}
@media (max-width: 600px) {
  .source-preview { display: none !important; }
}

/* ============================================================
   KEYBOARD SHORTCUTS DIALOG
   ============================================================ */
.shortcuts-overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 22, 26, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 800;
  padding: var(--space-5);
}
.shortcuts-card {
  background: var(--paper-raised);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 32px 80px -20px rgba(22, 22, 26, 0.4);
  position: relative;
}
.shortcuts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.shortcuts-head .eyebrow {
  margin-bottom: 0;
}
.shortcuts-close {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}
.shortcuts-close:hover { color: var(--accent); border-color: var(--accent-line); }
.shortcuts-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: var(--text-2xl);
  letter-spacing: -0.022em;
  color: var(--ink);
  margin-bottom: var(--space-5);
}
.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
}
.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line-soft);
}
.shortcut-row:last-child { border-bottom: none; }
.shortcut-row dt {
  font-family: var(--sans);
  font-size: var(--text-sm);
  color: var(--ink-body);
}
.shortcut-row dd {
  display: inline-flex;
  gap: 4px;
  margin: 0;
}
.shortcut-row kbd,
.shortcuts-foot kbd {
  font-family: var(--mono);
  font-size: 0.75rem;
  background: var(--paper-sunk);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 3px;
  color: var(--ink);
  font-weight: 500;
  min-width: 24px;
  text-align: center;
}
.shortcuts-foot {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  line-height: 1.6;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--r-md);
  box-shadow: 0 16px 40px -12px rgba(22, 22, 26, 0.45);
  z-index: 700;
  pointer-events: none;
}
.toast-error {
  background: var(--accent);
}

/* ============================================================
   CITATIONS
   ============================================================ */
.citation-ref {
  font-family: var(--mono);
  font-size: 0.65em;
  color: var(--accent);
  font-weight: 500;
  vertical-align: super;
  line-height: 0;
  margin-left: 1px;
  padding: 0 1px;
  cursor: pointer;
  text-decoration: none;
  border-radius: var(--r-xs);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  display: inline-block;
  animation: cite-pop 320ms var(--ease) both;
}
@keyframes cite-pop {
  0%   { transform: translateY(2px) scale(0.85); opacity: 0; }
  60%  { transform: translateY(-1px) scale(1.05); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .citation-ref { animation: none; }
}
.citation-ref:hover,
.citation-ref:focus-visible,
.citation-ref.is-highlighted {
  text-decoration: underline;
  text-underline-offset: 2px;
  background: var(--accent-tint);
  color: var(--accent-deep);
  outline: none;
}
.citation-ref + .citation-ref { margin-left: 0; }

/* Source attribution block */
.message-sources {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--line);
  background: var(--paper-sunk);
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  line-height: var(--lh-base);
  color: var(--ink-body);
}
.message-sources-toggle {
  display: none;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--sans);
  font-size: var(--text-xs);
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
  text-align: left;
}
.message-sources-toggle:hover { color: var(--accent); }
.message-sources-label { color: inherit; }
.message-sources-count {
  font-family: var(--mono);
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
  color: var(--ink-faint);
}
.message-sources-chev {
  margin-left: auto;
  font-size: 0.85em;
  transition: transform var(--t-fast) var(--ease);
}
.message-sources.is-expanded .message-sources-chev { transform: rotate(180deg); }

.message-sources-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.message-sources-list li {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--r-xs);
  transition: background var(--t-fast) var(--ease);
  cursor: default;
}
.message-sources-list li.is-highlighted {
  background: var(--accent-tint);
}
.message-sources-num {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--accent);
  font-weight: 500;
  flex-shrink: 0;
  min-width: 2.25em;
}
.message-sources-title {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink);
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.message-sources-sim {
  font-family: var(--mono);
  font-size: 0.75em;
  color: var(--ink-faint);
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .message-sources-toggle { display: inline-flex; }
  .message-sources-list {
    max-height: 0;
    overflow: hidden;
    margin-top: 0;
    transition: max-height var(--t-norm) var(--ease), margin-top var(--t-norm) var(--ease);
  }
  .message-sources.is-expanded .message-sources-list {
    max-height: 80vh;
    margin-top: var(--space-3);
  }
}

/* ============================================================
   SCROLLBARS
   ============================================================ */
.message-thread::-webkit-scrollbar,
.sidebar-list::-webkit-scrollbar,
.chat-empty::-webkit-scrollbar,
.shortcuts-card::-webkit-scrollbar {
  width: 6px;
}
.message-thread::-webkit-scrollbar-thumb,
.sidebar-list::-webkit-scrollbar-thumb,
.chat-empty::-webkit-scrollbar-thumb,
.shortcuts-card::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 3px;
}
.message-thread::-webkit-scrollbar-thumb:hover,
.sidebar-list::-webkit-scrollbar-thumb:hover,
.chat-empty::-webkit-scrollbar-thumb:hover,
.shortcuts-card::-webkit-scrollbar-thumb:hover {
  background: var(--ink-faint);
}

/* ============================================================
   ACCESSIBILITY — keyboard focus rings
   ============================================================ */
.chat-body :is(.sidebar-row, .starter-card, .signout-btn, .row-delete,
                .sidebar-toggle, .sidebar-close, .brand-mark,
                .sidebar-new, .bar-btn, .msg-action, .composer-stop,
                .auth-nav-link, .composer-edit-cancel, .shortcuts-close,
                .auth-google):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.composer-input:focus-visible {
  outline: none;
}

/* Reduced motion — disable transitions and large keyframe animations. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 200ms !important;
    scroll-behavior: auto !important;
  }
  .auth-headline .morph-word {
    transition: none;
    opacity: 1;
    transform: none;
    filter: none;
  }
}

/* Print */
@media print {
  .chat-sidebar, .chat-bar, .composer-wrap, .scroll-to-bottom,
  .source-preview, .shortcuts-overlay, .toast,
  .paywall-overlay, .verify-pill { display: none !important; }
  .chat-body { background: white; color: black; height: auto; overflow: visible; }
  .chat-body::before { display: none; }
  .message-thread { max-width: none; padding: 0; overflow: visible; }
  .message-row { break-inside: avoid; }
}

/* ============================================================
   VERIFY PILL — sidebar foot, between sub-state and account.
   "Email unverified · Resend × " — yellow soft, never blocking.
   ============================================================ */
.verify-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  margin-top: 0.65rem;
  background: #FFF8E0;
  border: 1px solid #ECDC9F;
  border-radius: 4px;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6B5A1F;
}
.verify-pill-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #C99F2D;
  flex-shrink: 0;
  animation: verify-pulse 2.4s ease-in-out infinite;
}
@keyframes verify-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}
.verify-pill-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.verify-pill-action {
  background: transparent;
  border: 1px solid #D8B65A;
  color: #6B5A1F;
  padding: 0.22rem 0.55rem;
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.verify-pill-action:hover:not(:disabled) {
  background: #C99F2D;
  color: white;
}
.verify-pill-action:disabled { opacity: 0.55; cursor: wait; }
.verify-pill-close {
  background: transparent;
  border: 0;
  color: #9A8338;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
  border-radius: 3px;
}
.verify-pill-close:hover { color: #6B5A1F; }

/* ============================================================
   ACCOUNT LINKS — Profile · Sign out
   ============================================================ */
.account-links {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.15rem;
}
.account-link {
  font-size: 0.72rem;
  color: var(--ink-muted, #787B81);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: color 140ms ease;
}
.account-link:hover { color: var(--accent, #7B1F1F); }
.account-link-sep {
  font-size: 0.7rem;
  color: var(--ink-faint, #A8AAAE);
}

/* ============================================================
   PAYWALL MODAL — opens on 402 quota_exceeded.
   Tier-aware copy, live HH:MM:SS countdown, oxblood accent CTA.
   ============================================================ */
.paywall-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: rgba(22, 22, 26, 0.55);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}
.paywall-card {
  position: relative;
  max-width: 540px;
  width: 100%;
  background: var(--paper-raised, #FFFFFF);
  border: 1px solid var(--line, #E8E7E2);
  border-top: 3px solid var(--accent, #7B1F1F);
  border-radius: 8px;
  padding: 2.5rem 2.25rem 2rem;
  box-shadow: 0 30px 80px -30px rgba(22, 22, 26, 0.45);
  text-align: center;
}
.paywall-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 0.66rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent, #7B1F1F);
  font-weight: 600;
  margin-bottom: 1.2rem;
}
.paywall-eyebrow-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent, #7B1F1F);
  animation: verify-pulse 1.8s ease-in-out infinite;
}
.paywall-headline {
  font-family: var(--serif, 'Fraunces', Georgia, serif);
  font-weight: 600;
  font-size: clamp(1.7rem, 1.2rem + 1.4vw, 2.2rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  color: var(--ink, #16161A);
}
.paywall-body {
  font-family: var(--serif, 'Fraunces', Georgia, serif);
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--ink-soft, #4A4A52);
  margin: 0 auto 1.7rem;
  max-width: 440px;
}
.paywall-countdown {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1rem 1.4rem;
  background: var(--paper-sunk, #F4F2EC);
  border: 1px solid var(--line, #E8E7E2);
  border-radius: 6px;
  margin-bottom: 1.75rem;
  min-width: 200px;
}
.paywall-countdown-label {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-muted, #787B81);
}
.paywall-countdown-value {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 1.85rem;
  letter-spacing: 0.04em;
  color: var(--accent, #7B1F1F);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.paywall-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}
.paywall-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1rem 1.85rem;
  background: var(--accent, #7B1F1F);
  color: var(--paper, #FAF9F6);
  border: 1px solid var(--accent, #7B1F1F);
  border-radius: 4px;
  font-family: var(--sans, 'Inter', sans-serif);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 180ms ease, transform 180ms ease;
}
.paywall-cta:hover:not(:disabled) {
  background: #5C1717;
  border-color: #5C1717;
}
.paywall-cta:disabled {
  opacity: 0.65;
  cursor: wait;
}
.paywall-cta .arrow {
  font-family: var(--serif, 'Fraunces', Georgia, serif);
  font-style: italic;
  transition: transform 200ms ease;
}
.paywall-cta:hover:not(:disabled) .arrow { transform: translateX(3px); }
.paywall-fineprint {
  font-family: var(--sans, 'Inter', sans-serif);
  font-size: 0.78rem;
  color: var(--ink-muted, #787B81);
  margin: 0;
  line-height: 1.5;
  max-width: 380px;
}
.paywall-fineprint a {
  color: var(--accent, #7B1F1F);
  font-weight: 500;
  border-bottom: 1px solid rgba(123, 31, 31, 0.3);
  transition: border-color 140ms ease;
}
.paywall-fineprint a:hover { border-bottom-color: var(--accent, #7B1F1F); }
.paywall-secondary {
  background: transparent;
  border: 0;
  color: var(--ink-muted, #787B81);
  font-family: var(--sans, 'Inter', sans-serif);
  font-size: 0.82rem;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(120, 123, 129, 0.25);
  text-underline-offset: 4px;
  transition: color 140ms ease, text-decoration-color 140ms ease;
}
.paywall-secondary:hover {
  color: var(--ink, #16161A);
  text-decoration-color: var(--ink, #16161A);
}

@media (max-width: 540px) {
  .paywall-card { padding: 2rem 1.4rem 1.6rem; }
  .paywall-countdown-value { font-size: 1.55rem; }
}
