/* ===========================
   MoA Platform — Design System
   =========================== */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Palette — warm charcoal neutrals, tinted toward the gold brand hue.
     (The previous ramp drifted cool/violet — blue was the strongest channel —
     which quietly fought the warm gold accent.) */
  --bg: #0c0a09;
  --surface: #12100e;
  --surface-2: #191512;
  --surface-3: #221d17;
  --border: #2e2820;
  --border-subtle: #221d17;

  /* Text — warm paper tones, no purple cast */
  --text: #f2ede3;
  --text-secondary: #9d9482;
  --text-tertiary: #8f8674;

  /* Accent — warm gold, used for primary actions */
  --accent: #e0a63f;
  --accent-dim: #cf9636;
  --accent-subtle: rgba(224, 166, 63, 0.12);
  --accent-border: rgba(224, 166, 63, 0.3);

  /* Semantic */
  --success: #3dd68c;
  --warning: #f0b429;
  --error: #ef5757;

  /* Spacing (4px base rhythm) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;

  /* Type scale (1.25 major second ratio, base 16px) */
  --text-xs: 0.75rem; /* 12px — captions, timestamps */
  --text-sm: 0.8125rem; /* 13px — secondary labels */
  --text-base: 1rem; /* 16px — body text */
  --text-md: 1.0625rem; /* 17px — emphasized body */
  --text-lg: 1.25rem; /* 20px — subheadings */
  --text-xl: 1.5rem; /* 24px — section headings */
  --text-2xl: 1.875rem; /* 30px — page headings */

  /* Radii */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 9999px;

  /* Layout */
  --sidebar-width: 260px;

  /* Z-index scale */
  --z-header: 10;
  --z-fab: 20;
  --z-overlay: 100;
  --z-sidebar: 110;
  --z-modal: 150;
  --z-skip: 200;

  /* Model provider colors */
  --model-gpt: rgba(74, 222, 128, 0.05);
  --model-gpt-border: rgba(74, 222, 128, 0.12);
  --model-gpt-text: #8fbfa8;
  --model-claude: rgba(217, 119, 87, 0.05);
  --model-claude-border: rgba(217, 119, 87, 0.12);
  --model-claude-text: #c4a08b;
  --model-gemini: rgba(96, 165, 250, 0.05);
  --model-gemini-border: rgba(96, 165, 250, 0.12);
  --model-gemini-text: #92aed0;
  --model-deepseek: rgba(77, 107, 254, 0.05);
  --model-deepseek-border: rgba(77, 107, 254, 0.12);
  --model-deepseek-text: #95a3d4;
  --model-grok: rgba(239, 87, 87, 0.05);
  --model-grok-border: rgba(239, 87, 87, 0.12);
  --model-grok-text: #c99090;

  /* Model dot brand colors */
  --dot-openai: #4a9e84;
  --dot-anthropic: #be8a74;
  --dot-google: #6a9be0;
  --dot-deepseek: #6f86d9;
  --dot-xai: #c96a6a;

  /* Typography */
  --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-mono: "Fira Code", ui-monospace, monospace;

  /* Easing */
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

  /* Transitions */
  --transition-fast: 120ms var(--ease-out);
  --transition-base: 200ms var(--ease-out);
  --transition-slow: 350ms var(--ease-out-expo);
}

/* ===========================
   Selection
   =========================== */
::selection {
  background: rgba(224, 166, 63, 0.25);
  color: #fff;
}

/* ===========================
   Base
   =========================== */
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-size: var(--text-base);
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  z-index: var(--z-skip);
  text-decoration: none;
}
.skip-link:focus {
  top: var(--space-4);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===========================
   Focus indicators (a11y)
   =========================== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

textarea:focus-visible {
  outline: none; /* handled by .input-wrapper:focus-within */
}

/* ===========================
   Layout
   =========================== */
.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  /* hidden still permits programmatic/focus-reveal scrolling (mobile keyboards
     can wedge the shell upward and leave a void under the composer); clip
     forbids scrolling entirely. Older browsers ignore this and keep hidden. */
  overflow: clip;
}

.app {
  display: flex;
  flex-direction: column;
  /* Fill .app-layout rather than the raw viewport. fixMobileViewport() pins
     .app-layout to visualViewport.height when the iOS keyboard opens; an
     explicit 100dvh here ignored that, so .app stayed full-height and its
     bottom (the composer) was clipped behind the keyboard — you couldn't see
     what you were typing. 100% tracks the JS-pinned parent. */
  height: 100%;
  min-height: 0;
  flex: 1;
  min-width: 0;
  max-width: 900px;
  margin: 0 auto;
  position: relative;
}

/* ===========================
   Sidebar
   =========================== */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  contain: layout style;
}

.sidebar-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
}

.sidebar-title {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.new-chat-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
  font-family: inherit;
  min-height: 44px;
}
.new-chat-btn:hover {
  background: var(--surface-3);
  border-color: var(--accent-border);
}
.new-chat-btn:active {
  transform: scale(0.98);
}

.sidebar-conversations {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}
.sidebar-conversations::-webkit-scrollbar {
  width: 4px;
}
.sidebar-conversations::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-conversations::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 2px;
}

.sidebar-empty {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.sidebar-group-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--space-4) var(--space-3) var(--space-1);
}

.conversation-item {
  position: relative;
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text);
  transition: background var(--transition-fast);
  margin-bottom: 1px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.conversation-item:hover {
  background: var(--surface-2);
}
.conversation-item.active {
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
}

.conv-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: var(--space-6);
  min-width: 0;
}

.conv-time {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.conv-delete {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: var(--text-md);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  display: none;
  align-items: center;
  justify-content: center;
}
.conv-delete:hover {
  color: var(--error);
  background: rgba(239, 87, 87, 0.08);
}
.conv-delete.confirm {
  color: var(--error);
  font-weight: 700;
}
.conversation-item:hover .conv-delete {
  display: flex;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: var(--z-overlay);
}
.sidebar-overlay.visible {
  display: block;
}

.hamburger-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}
.hamburger-btn:hover {
  background: var(--surface-2);
}

/* ===========================
   Header
   =========================== */
.header {
  padding: var(--space-4) var(--space-6) var(--space-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  position: relative;
  z-index: var(--z-header);
  border-bottom: 1px solid rgba(224, 166, 63, 0.28);
}

.header-text {
  cursor: pointer;
  transition: opacity var(--transition-fast);
  text-align: center;
}
.header-text:hover {
  opacity: 0.75;
}

.logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
}

.moa-logo {
  opacity: 0.85;
}

.header h1 {
  font-family: var(--font-display);
  font-size: 1.625rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--text);
  font-style: italic;
}

/* ===========================
   Chat Container
   =========================== */
.chat-container {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: var(--space-6);
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}
.chat-container::-webkit-scrollbar {
  width: 6px;
}
.chat-container::-webkit-scrollbar-track {
  background: transparent;
}
.chat-container::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 3px;
}

/* ===========================
   Welcome Screen
   =========================== */
.welcome-message {
  text-align: left;
  padding: 80px var(--space-6) var(--space-8);
  max-width: 640px;
  animation: fadeIn 0.5s var(--ease-out);
}

.welcome-message h2 {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 400;
  margin-bottom: var(--space-5);
  letter-spacing: 0.03em;
  line-height: 1.15;
  color: var(--text);
  overflow-wrap: break-word;
}

.welcome-message h2 .welcome-accent {
  font-style: italic;
  color: var(--accent);
}

.welcome-message > p {
  color: var(--text-tertiary);
  max-width: 380px;
  margin: 0 0 var(--space-5);
  line-height: 1.6;
  font-size: var(--text-base);
  letter-spacing: 0.01em;
}

/* Provider identity row — the five frontier models, always visible */
.provider-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  margin: 0 0 var(--space-7);
  animation: fadeIn 0.4s var(--ease-out) 0.1s backwards;
}
.provider {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}
.provider-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot, var(--accent));
  flex: none;
}

/* ===========================
   First-Visit Intro (swipeable popup)
   =========================== */
.intro-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity var(--transition-base);
}
.intro-overlay.visible {
  opacity: 1;
}
.intro-overlay[hidden] {
  display: none;
}

.intro-modal {
  position: relative;
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-6) var(--space-5);
  transform: translateY(8px) scale(0.985);
  transition: transform var(--transition-slow);
}
.intro-overlay.visible .intro-modal {
  transform: none;
}

.intro-skip {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  font-family: inherit;
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  min-height: 44px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
  z-index: 1;
}
.intro-skip:hover {
  color: var(--text);
}

.intro-viewport {
  overflow: hidden;
  margin: 0 calc(-1 * var(--space-2));
}
.intro-track {
  display: flex;
  transition: transform 350ms var(--ease-out-expo);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.intro-track.dragging {
  transition: none;
  cursor: grabbing;
}

.intro-slide {
  flex: 0 0 100%;
  min-width: 0;
  padding: var(--space-5) var(--space-2) var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 280px;
}

.intro-visual {
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-5);
  color: var(--accent);
}

.intro-model-cloud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
  max-width: 300px;
}
.intro-model {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.intro-capability-icons {
  display: flex;
  gap: var(--space-6);
  color: var(--accent);
}

.intro-heading {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: var(--space-3);
}
.intro-body {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.65;
  max-width: 40ch;
}

.intro-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-4);
}
.intro-dots {
  display: flex;
  gap: var(--space-2);
}
.intro-dot {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.intro-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface-3);
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.intro-dot:hover::before {
  background: var(--text-tertiary);
}
.intro-dot.active::before {
  background: var(--accent);
  transform: scale(1.2);
}

.intro-next {
  background: var(--accent);
  border: none;
  color: var(--bg);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: var(--space-2) var(--space-5);
  min-height: 44px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity var(--transition-fast), transform 80ms ease;
}
.intro-next:hover {
  opacity: 0.85;
}
.intro-next:active {
  transform: scale(0.97);
}

/* Suggestion prompts — ghost text, premium feel */
.suggestion-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 380px;
}

.suggestion-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-2);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  color: var(--text-tertiary);
  font-size: var(--text-base);
  font-family: inherit;
  letter-spacing: inherit;
  transition: color var(--transition-fast), background var(--transition-fast);
  min-height: 44px;
}
.suggestion-card:hover {
  color: var(--text);
  background: var(--surface-2);
}
.suggestion-card:active {
  transform: scale(0.99);
}
.suggestion-card {
  animation: fadeIn 0.4s var(--ease-out) backwards;
}
.suggestion-card:nth-child(1) {
  animation-delay: 0.15s;
}
.suggestion-card:nth-child(2) {
  animation-delay: 0.25s;
}
.suggestion-card:nth-child(3) {
  animation-delay: 0.35s;
}
.suggestion-card:nth-child(4) {
  animation-delay: 0.45s;
}

.suggestion-icon {
  font-size: var(--text-sm);
  flex-shrink: 0;
  color: var(--accent);
  opacity: 1;
}

.suggestion-text {
  line-height: 1.4;
}

/* ===========================
   Messages
   =========================== */
.messages {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.message {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  animation: messageSlideUp 0.35s var(--ease-out);
  content-visibility: auto;
  contain-intrinsic-size: auto 120px;
}

@keyframes messageSlideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.message-user {
  align-items: flex-end;
}

.message-user .message-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-lg) var(--radius-lg) var(--space-1) var(--radius-lg);
  max-width: 70%;
}

.message-ai {
  position: relative;
}

.message-ai .message-bubble {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--space-1);
  max-width: min(85%, 72ch);
  position: relative;
}

/* While generating, exactly one element speaks: status bar, agent panel, or
   skeleton. The bubble appears only once it has content; the footer (chips +
   actions) waits for completion. */
.message-ai .message-bubble:empty {
  display: none;
}
.message-ai.generating .message-footer {
  display: none;
}
.message-ai .message-footer {
  animation: contentIn 0.25s var(--ease-out-expo);
}

@keyframes contentIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.message-bubble {
  padding: var(--space-3) var(--space-4);
  line-height: 1.75;
  overflow-wrap: anywhere;
  word-break: break-word; /* fallback */
  font-size: var(--text-base);
  min-width: 0;
}

.message-bubble.raw-text {
  white-space: pre-wrap;
}

.message-bubble.rendering {
  animation: crossFade 0.2s ease-out;
}

@keyframes crossFade {
  from {
    opacity: 0.7;
  }
  to {
    opacity: 1;
  }
}

/* Markdown typography */
.message-bubble p {
  margin: 0 0 var(--space-3);
}
.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble h1,
.message-bubble h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: normal;
  margin: var(--space-6) 0 var(--space-3);
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: var(--text);
}
.message-bubble h3,
.message-bubble h4 {
  margin: var(--space-5) 0 var(--space-2);
  line-height: 1.3;
  letter-spacing: 0;
  font-weight: 600;
}
.message-bubble h1 {
  font-size: 1.5em;
}
.message-bubble h2 {
  font-size: 1.25em;
}
.message-bubble h3 {
  font-size: 1.1em;
}
.message-bubble h4 {
  font-size: 1em;
}

.message-bubble h1:first-child,
.message-bubble h2:first-child,
.message-bubble h3:first-child {
  margin-top: 0;
}

.message-bubble blockquote {
  /* Logical property: the bubble is dir="auto", so Arabic answers mirror
     the accent rule to the right edge automatically. */
  border-inline-start: 2px solid var(--accent-dim);
  padding: var(--space-1) var(--space-4);
  margin: var(--space-3) 0;
  color: var(--text-secondary);
  font-style: italic;
}
.message-bubble blockquote p:last-child {
  margin-bottom: 0;
}

.message-bubble ul,
.message-bubble ol {
  margin: var(--space-2) 0;
  padding-inline-start: var(--space-6);
}
.message-bubble li {
  margin: var(--space-1) 0;
}

/* Code is Latin-script by nature: inside an RTL (Arabic) bubble it must
   still lay out left-to-right or indentation and operators scramble. */
.message-bubble pre,
.message-bubble pre code {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

.message-bubble hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-4) 0;
}

.message-bubble .inline-code {
  background: var(--surface-2);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 0.84em;
  border: 1px solid var(--border);
}

/* Message footer — holds metadata chips + action buttons */
.message-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 28px;
}

/* Action bar on AI messages */
.msg-actions {
  display: none;
  gap: var(--space-1);
  flex-shrink: 0;
  margin-left: auto;
}
.message-ai:hover .msg-actions {
  display: flex;
}
.message-ai:last-child .msg-actions {
  display: flex;
  opacity: 0.5;
}
.message-ai:last-child:hover .msg-actions {
  opacity: 1;
}

.msg-action-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast), border-color
    var(--transition-fast);
  font-family: inherit;
  letter-spacing: inherit;
  min-height: 44px;
}
.msg-action-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--accent-border);
}
.msg-action-btn.copied-action {
  border-color: rgba(61, 214, 140, 0.3);
  color: var(--success);
}

/* ===========================
   Code Artifacts
   =========================== */
.code-artifact {
  background: color-mix(in srgb, var(--bg) 80%, black);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  margin: var(--space-3) 0;
  overflow: hidden;
  min-width: 0;
}

.artifact-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
}

.artifact-lang {
  color: var(--text-tertiary);
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  text-transform: lowercase;
}

.artifact-copy {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-xs);
  font-family: inherit;
  letter-spacing: inherit;
  transition: color var(--transition-fast), background var(--transition-fast), border-color
    var(--transition-fast);
  min-height: 44px;
}
.artifact-copy:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.artifact-copy.copied {
  border-color: rgba(61, 214, 140, 0.3);
  color: var(--success);
  animation: copyPop 0.2s ease-out;
}

@keyframes copyPop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

.code-artifact pre {
  margin: 0;
  padding: var(--space-4);
  overflow-x: auto;
  border: none;
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.code-artifact pre:hover {
  scrollbar-color: var(--border-subtle) transparent;
}
.code-artifact pre::-webkit-scrollbar {
  height: 5px;
}
.code-artifact pre::-webkit-scrollbar-track {
  background: transparent;
}
.code-artifact pre::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
}
.code-artifact pre:hover::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
}

.code-artifact pre code {
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.65;
  background: transparent;
  padding: 0;
  white-space: pre;
  word-break: normal;
  word-wrap: normal;
}

/* ===========================
   Generated Images
   =========================== */
.image-container {
  margin: var(--space-2) 0;
  max-width: 85%;
}

.generated-image {
  max-width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: block;
  transition: border-color var(--transition-fast);
}
.generated-image:hover {
  border-color: var(--accent-border);
  cursor: pointer;
}
.generated-image,
.user-attached-image {
  cursor: zoom-in;
}

/* ===========================
   Image Lightbox (tap to enlarge)
   =========================== */
/* iOS Safari refuses to navigate to a data: URI, so the old
   window.open(img.src) gave testers a black screen. An in-page overlay shows
   the image inline instead — works for data:, blob:, and http(s) sources. */
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(var(--space-4), env(safe-area-inset-top, 0px)) var(--space-4)
    max(var(--space-4), env(safe-area-inset-bottom, 0px));
  background: rgba(8, 7, 6, 0.92);
  opacity: 0;
  transition: opacity var(--transition-base);
  -webkit-tap-highlight-color: transparent;
  cursor: zoom-out;
}
.image-lightbox.visible {
  opacity: 1;
}
.image-lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: max(var(--space-3), env(safe-area-inset-top, 0px));
  right: var(--space-3);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.lightbox-close:hover {
  background: var(--surface-3);
  border-color: var(--accent-border);
}

/* ===========================
   Status / Agent Panel
   =========================== */
.status-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: var(--space-2) 0;
}

/* Three-dot thinking animation */
.thinking-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}
.thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: dotPulse 1.4s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}
.thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes dotPulse {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: scale(0.85);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Orbit working animation — the three-circle logo, spinning (canvas 8b, row A).
   Reduced-motion users get the static thinking-dots markup instead (app.js). */
.status-orbit {
  width: 38px;
  height: 38px;
  position: relative;
  flex: none;
  animation: idSpin 2.8s linear infinite;
}
.status-orbit span {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-orbit span:nth-child(1) {
  left: 15px;
  top: 0;
  background: #e0a63f;
}
.status-orbit span:nth-child(2) {
  left: 3px;
  top: 25px;
  background: #cf9636;
}
.status-orbit span:nth-child(3) {
  left: 27px;
  top: 25px;
  background: #b8882e;
}

@keyframes idSpin {
  to {
    transform: rotate(360deg);
  }
}

/* Answer footer — one quiet line inside the bubble (canvas 8d).
   Shows lane label + contributing models + duration. Never cost, category,
   or complexity (explicitly rejected by the product owner). */
.answer-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
  margin-top: 14px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.answer-footer-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  flex: none;
}
.answer-footer-model {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.answer-footer-model.chip-gpt {
  color: var(--model-gpt-text);
}
.answer-footer-model.chip-claude {
  color: var(--model-claude-text);
}
.answer-footer-model.chip-gemini {
  color: var(--model-gemini-text);
}
.answer-footer-model.chip-deepseek {
  color: var(--model-deepseek-text);
}
.answer-footer-model.chip-grok {
  color: var(--model-grok-text);
}
.answer-footer-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
  flex: none;
}
.answer-footer-dot.dot-openai {
  background: var(--dot-openai);
}
.answer-footer-dot.dot-anthropic {
  background: var(--dot-anthropic);
}
.answer-footer-dot.dot-google {
  background: var(--dot-google);
}
.answer-footer-dot.dot-deepseek {
  background: var(--dot-deepseek);
}
.answer-footer-dot.dot-xai {
  background: var(--dot-xai);
}
.answer-footer-duration {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
}

/* Agent Panel — channel strips on a page-dark chassis (canvas 8c) */
.agent-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-1) 0 var(--space-2);
  max-width: 85%;
  cursor: pointer;
  transition: max-height var(--transition-slow), padding var(--transition-base), opacity
    var(--transition-base);
  overflow: hidden;
}

.agent-panel.collapsed {
  max-height: 28px;
  padding: var(--space-1) var(--space-4);
  opacity: 0.5;
}
.agent-panel.collapsed .agent-grid {
  display: none;
}
.agent-panel.collapsed .agent-panel-header {
  font-size: var(--text-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0;
}
.agent-panel.collapsed .agent-panel-header .thinking-dots {
  display: none;
}

.agent-panel-header {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.agent-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Channel strip: single line — dot · role · model (fills) · live status.
   The streaming preview wraps to its own row via flex-basis. */
.agent-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px var(--space-3);
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  transition: border-color var(--transition-base);
  min-height: 44px;
}

.agent-card .agent-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background var(--transition-base);
}

.agent-card.agent-pending .agent-status-dot {
  background: var(--text-tertiary);
}
.agent-card.agent-waiting .agent-status-dot {
  background: var(--warning);
  animation: statusPulse 1.5s ease-in-out infinite;
}
.agent-card.agent-generating .agent-status-dot {
  background: var(--accent);
  animation: statusPulse 1s ease-in-out infinite;
}
.agent-card.agent-done .agent-status-dot {
  background: var(--success);
}

.agent-card.agent-generating {
  border-color: var(--accent-border);
}
.agent-card.agent-done {
  border-color: rgba(61, 214, 140, 0.15);
}

.agent-action {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  flex: none;
}
.agent-model-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex: none;
}
.agent-card.agent-generating .agent-status {
  color: var(--accent);
}

@keyframes statusPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* ===========================
   Image Upload Preview
   =========================== */
.image-preview {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  margin-bottom: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.image-preview img {
  max-height: 80px;
  max-width: 120px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}
.image-preview button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color var(--transition-fast), background var(--transition-fast), border-color
    var(--transition-fast);
}
.image-preview button:hover {
  background: rgba(239, 87, 87, 0.08);
  border-color: var(--error);
  color: var(--error);
}

.user-image-container {
  max-width: 70%;
  align-self: flex-end;
}
.user-attached-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-lg) var(--radius-lg) var(--space-1) var(--radius-lg);
  border: 1px solid var(--accent-border);
  display: block;
  object-fit: contain;
}

/* ===========================
   Input Area
   =========================== */
.input-area {
  padding: var(--space-4) var(--space-6) var(--space-5);
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-subtle);
}

#uploadBtn {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color var(--transition-fast), background var(--transition-fast);
}
#uploadBtn:hover {
  color: var(--accent);
  background: var(--accent-subtle);
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

textarea {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: var(--text-base);
  font-family: inherit;
  letter-spacing: inherit;
  resize: none;
  outline: none;
  max-height: 200px;
  line-height: 1.5;
  align-self: center;
  padding: 0;
  margin: 0;
}
textarea::placeholder {
  color: var(--text-tertiary);
}

#sendBtn {
  background: var(--accent);
  border: none;
  color: var(--bg);
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity var(--transition-fast), transform 80ms ease;
}
#sendBtn:hover {
  opacity: 0.85;
}
#sendBtn:active {
  transform: scale(0.94);
}
#sendBtn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
/* While generating, the same button becomes Stop — outlined, not filled, so
   the destructive-ish action never looks like the primary send affordance */
#sendBtn.stop-mode {
  background: var(--surface-2);
  border: 1px solid var(--accent-border);
  color: var(--accent);
}
#sendBtn.stop-mode:hover {
  opacity: 1;
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.input-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  padding: var(--space-1) var(--space-1) 0;
  min-height: 18px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  text-align: right;
}
.input-wrapper:focus-within ~ .input-hint {
  opacity: 1;
}

/* ===========================
   Scroll-to-bottom FAB
   =========================== */
.scroll-fab {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-fab);
  transition: opacity var(--transition-base), transform var(--transition-base), background
    var(--transition-fast);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.scroll-fab:hover {
  background: var(--surface-3);
  color: var(--text);
}
.scroll-fab.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(6px);
}

.scroll-fab-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.scroll-fab-dot.hidden {
  display: none;
}

/* ===========================
   Markdown Tables
   =========================== */
.table-wrapper {
  overflow-x: auto;
  margin: var(--space-3) 0;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
}
.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table-wrapper th {
  background: var(--surface-2);
  padding: var(--space-2) var(--space-4);
  text-align: start; /* mirrors for RTL (Arabic) tables */
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table-wrapper td {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
  /* Undo .message-bubble's overflow-wrap:anywhere — it lets narrow viewports
     shred cell text letter-by-letter instead of triggering the wrapper's
     horizontal scroll. min-width keeps prose columns readable. */
  overflow-wrap: normal;
  word-break: normal;
  min-width: 140px;
}
.table-wrapper tr:last-child td {
  border-bottom: none;
}
.table-wrapper tr:hover td {
  background: rgba(224, 166, 63, 0.03);
}

/* ===========================
   Agent Stream Preview
   =========================== */
.agent-preview {
  display: block;
  flex-basis: 100%;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}
.agent-preview:empty {
  display: none;
}
.agent-card.agent-done .agent-preview {
  opacity: 0.4;
}
.agent-card.agent-generating .agent-preview {
  -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

/* ===========================
   Fast Track Status
   =========================== */
.fast-track-status {
  animation: fastTrackPulse 2s ease-in-out infinite;
}
.fast-track-status .spark-icon {
  color: var(--warning);
  flex-shrink: 0;
}
@keyframes fastTrackPulse {
  0%,
  100% {
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
}

/* ===========================
   Synthesizing Status
   =========================== */
.synth-status {
  animation: none;
}
.synth-glow {
  color: var(--accent);
  font-weight: 500;
  animation: synthPulse 2s ease-in-out infinite;
}
.synth-dots span {
  background: var(--accent);
}

@keyframes synthPulse {
  0%,
  100% {
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
}

/* ===========================
   Skeleton Shimmers
   =========================== */
.image-skeleton {
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  margin: var(--space-2) 0;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-skeleton-label {
  padding: var(--space-2);
  text-align: center;
}
.image-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(212, 160, 74, 0.04) 30%,
    rgba(212, 160, 74, 0.08) 50%,
    rgba(212, 160, 74, 0.04) 70%,
    transparent 100%
  );
  animation: shimmer 1.8s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ===========================
   Video Generation
   =========================== */
.video-skeleton {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

/* Estimated progress: thin gold bar + elapsed clock under the status label */
.video-progress {
  width: 56%;
  height: 3px;
  border-radius: 2px;
  background: var(--accent-subtle);
  overflow: hidden;
  z-index: 1;
}
.video-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.9s linear;
}
.video-skeleton-meta {
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  z-index: 1;
  font-variant-numeric: tabular-nums;
}

/* All video sources failed — actionable message instead of a dead rectangle */
.video-fallback {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.video-download-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.video-skeleton::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 25%,
    rgba(212, 160, 74, 0.04) 37%,
    transparent 63%
  );
  background-size: 200% 100%;
  animation: videoShimmer 1.8s ease-in-out infinite;
}
.video-skeleton-label {
  padding: var(--space-2);
}

@keyframes videoShimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.video-player {
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  background: var(--surface-2);
  animation: contentIn 0.25s var(--ease-out-expo);
}

/* Document (PDF) generation — skeleton is a ghost of the final card, so the
   loading state morphs into the result instead of swapping shapes */
.doc-skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
  max-width: 420px;
}
.doc-skeleton-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  min-width: 280px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}
.doc-skeleton-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 25%,
    rgba(212, 160, 74, 0.05) 37%,
    transparent 63%
  );
  background-size: 200% 100%;
  animation: videoShimmer 1.8s ease-in-out infinite;
}
.dsk-icon {
  flex: none;
  width: 42px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
}
.dsk-lines {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dsk-line {
  height: 10px;
  border-radius: 5px;
  background: var(--surface-3);
}
.dsk-line-title {
  width: 70%;
}
.dsk-line-meta {
  width: 38%;
  height: 8px;
}
.dsk-btn {
  flex: none;
  width: 96px;
  height: 30px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--surface);
}

/* One shared voice for in-flight skeleton labels */
.doc-skeleton-label,
.video-skeleton-label,
.image-skeleton-label {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.doc-skeleton-label::before,
.video-skeleton-label::before,
.image-skeleton-label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: genPulse 1.4s ease-in-out infinite;
}
.doc-skeleton-label {
  padding-left: var(--space-1);
}

@keyframes genPulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.document-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  min-width: 280px;
  max-width: 420px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  animation: contentIn 0.25s var(--ease-out-expo);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.document-card:hover {
  border-color: var(--accent-border);
  background: var(--surface-3);
}
.doc-card-icon {
  flex: none;
  width: 42px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-subtle);
  border-radius: var(--radius-sm);
  color: var(--accent);
}
.doc-card-info {
  flex: 1;
  min-width: 0;
}
.doc-card-title {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text);
  /* Two-line clamp instead of single-line ellipsis — at phone widths the
     Download button leaves ~12 visible chars, hiding most real titles */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: normal;
  word-break: normal;
}
.doc-card-meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}
.doc-card-download {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: inherit;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.doc-card-download:hover {
  background: var(--accent);
  color: var(--bg);
}

/* Agent panel fade-out after synthesis */
.agent-panel.fade-out {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

/* Model avatar color dots */
.agent-status-dot.dot-openai {
  background: var(--dot-openai);
}
.agent-status-dot.dot-anthropic {
  background: var(--dot-anthropic);
}
.agent-status-dot.dot-google {
  background: var(--dot-google);
}
.agent-status-dot.dot-deepseek {
  background: var(--dot-deepseek);
}
.agent-status-dot.dot-xai {
  background: var(--dot-xai);
}

/* Boot failure banner — shown when a CDN library never loads */
.boot-error {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2, #1c1a20);
  border: 1px solid var(--error, #e5484d);
  border-radius: var(--radius-md, 8px);
  color: var(--error, #e5484d);
  font-size: var(--text-sm, 0.875rem);
  z-index: 1000;
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: var(--z-sidebar);
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    box-shadow: none;
    will-change: transform;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.35);
  }

  .hamburger-btn {
    display: flex;
  }
  .app {
    max-width: 100%;
  }
  .header {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    padding: var(--space-3) var(--space-4) var(--space-3);
    gap: 0;
  }
  .header-text {
    justify-self: center;
  }
  .chat-container {
    padding: var(--space-4);
  }

  .input-area {
    flex-shrink: 0;
    padding: var(--space-3) var(--space-4) var(--space-4);
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    z-index: var(--z-header);
  }

  .message-user .message-bubble {
    max-width: 85%;
  }
  .message-ai .message-bubble {
    max-width: 95%;
  }

  .answer-footer {
    flex-wrap: wrap;
    gap: 6px 14px;
    white-space: normal;
  }

  .welcome-message {
    padding: var(--space-7) var(--space-4) var(--space-5);
  }
  .welcome-message h2 {
    font-size: 2.25rem;
    margin-bottom: var(--space-3);
  }
  .welcome-message > p {
    margin-bottom: var(--space-4);
  }
  .provider-row {
    gap: var(--space-2) var(--space-4);
    margin-bottom: var(--space-5);
  }

  .suggestion-grid {
    gap: var(--space-1);
  }
  .suggestion-card {
    padding: var(--space-3);
    font-size: var(--text-sm);
  }

  .artifact-copy {
    opacity: 1;
  }
  .message-ai .msg-actions {
    display: flex;
    opacity: 0.5;
  }
  .message-ai:last-child .msg-actions {
    opacity: 0.7;
  }
  .conversation-item .conv-delete {
    display: flex;
  }

  .agent-preview {
    display: none;
  }
  .agent-panel-header {
    min-height: 44px;
  }
  .agent-card {
    min-height: 44px;
  }

  .image-skeleton {
    max-width: 280px;
  }
  .video-skeleton {
    max-width: 280px;
  }

  .doc-skeleton-card,
  .document-card {
    min-width: 0;
    max-width: 100%;
  }

  .input-hint {
    display: none;
  }
  .scroll-fab {
    bottom: 85px;
  }
  .user-image-container {
    max-width: 85%;
  }
  .agent-panel {
    max-width: 100%;
  }
}

/* Landscape mobile — constrained height */
@media (max-width: 768px) and (orientation: landscape) {
  .welcome-message {
    padding: var(--space-4) var(--space-4) var(--space-3);
  }
  .welcome-message h2 {
    font-size: var(--text-xl);
  }
  .welcome-message > p {
    margin-bottom: var(--space-3);
  }
  .suggestion-card:nth-child(n + 3) {
    display: none;
  }
}

/* Wide screens — prevent excessive empty space */
@media (min-width: 1400px) {
  .app {
    max-width: 960px;
  }
}

/* ===========================
   Access Gate
   =========================== */
.access-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  text-align: center;
  padding: var(--space-6);
}
.gate-logo {
  margin-bottom: var(--space-6);
  opacity: 0.7;
}
.gate-heading {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 400;
  margin-bottom: var(--space-2);
  letter-spacing: 0.03em;
}
.gate-description {
  color: var(--text-secondary);
  max-width: 340px;
  line-height: 1.6;
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
}
.gate-link {
  color: var(--accent);
  font-size: var(--text-sm);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-border);
  padding-bottom: 2px;
  transition: border-color var(--transition-fast);
}
.gate-link:hover {
  border-color: var(--accent);
}

/* ===========================
   Sequential Progress Rail
   =========================== */
.sequential-rail {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sequential-rail .agent-card {
  border-left: 3px solid var(--surface-3);
  transition: border-color 0.3s ease, opacity 0.3s ease;
}

.sequential-rail .agent-card[data-status="done"] {
  border-left-color: var(--success);
  opacity: 0.7;
}

.sequential-rail .agent-card[data-status="generating"] {
  border-left-color: var(--accent);
}

.sequential-rail .agent-card[data-status="pending"] {
  opacity: 0.5;
}

.step-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--text-xs);
  margin-left: 0;
  margin-top: 2px;
}

.step-indicator.done {
  color: var(--success);
}
.step-indicator.generating {
  color: var(--accent);
}
.step-indicator.pending {
  color: var(--text-tertiary);
}

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

  .scroll-fab.hidden {
    transition: none;
  }
}

/* ===========================
   File Attachments
   =========================== */
.attachment-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.attach-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-width: 240px;
}
.attach-chip img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}
.attach-icon {
  font: 600 0.65rem var(--font-mono, monospace);
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-soft, rgba(224, 166, 63, 0.15));
  color: var(--accent);
}
.attach-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-chip button {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 4px;
}
.attach-chip button:hover {
  color: var(--error);
}
.attach-error {
  color: var(--error);
  font-size: 0.85rem;
  margin-bottom: var(--space-2);
}
.user-attached-file {
  display: inline-block;
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: var(--space-1);
}
body.dragging::after {
  content: "Drop files to attach";
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(19, 17, 16, 0.85);
  color: var(--accent);
  font-size: 1.2rem;
  border: 2px dashed var(--accent);
  pointer-events: none;
}

/* ===========================
   Toast Notices (error surfacing)
   =========================== */
#toast-host {
  position: fixed;
  bottom: calc(var(--space-8) + 72px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  color: var(--text);
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  max-width: min(420px, 86vw);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-inline-start-color: #b3564e;
}
