/* ================================================================
   ai-chat.css — Language Lab AI Chat  ·  v3  ·  Reference Match
   ----------------------------------------------------------------
   Font      : Inter (loaded in HTML head)
   Prefix    : ll-ai-  — zero conflicts with navbar / dashboard
   Dark mode : html.dark  (set by theme.js on <html>)
   Tokens    : scoped to .ll-ai-wrapper — never pollutes :root
   ----------------------------------------------------------------
   ⚠  Every ID, class and data-* used by ai-chat.js / navbar.js
      is preserved EXACTLY.  Zero JS / logic changes.
================================================================ */


/* ════════════════════════════════════════════════════════════════
   §0  FONT + BOX-SIZING SCOPE
════════════════════════════════════════════════════════════════ */
.ll-ai-wrapper,
.ll-ai-wrapper * {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont,
    'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  box-sizing: border-box;
}


/* ════════════════════════════════════════════════════════════════
   §1  DESIGN TOKENS  (scoped — never pollutes :root)
════════════════════════════════════════════════════════════════ */
.ll-ai-wrapper {

  /* Palette — DARK (matches reference image) */
  --c-bg: #070c1a;
  --c-panel: rgba(14, 19, 40, 0.84);
  --c-panel-top: rgba(17, 22, 48, 0.90);
  --c-input-field: rgba(17, 22, 46, 0.88);
  --c-border: rgba(255, 255, 255, 0.07);
  --c-border-focus: rgba(139, 92, 246, 0.45);

  --c-text-1: #ffffff;
  --c-text-2: rgba(255, 255, 255, 0.55);
  --c-text-3: rgba(255, 255, 255, 0.28);

  --c-accent: #8b5cf6;
  --c-accent-2: #a855f7;
  --c-accent-soft: rgba(139, 92, 246, 0.10);
  --c-accent-glow: rgba(139, 92, 246, 0.22);
  --c-accent-ring: rgba(139, 92, 246, 0.12);

  --c-green: #4ade80;
  --c-green-bg: rgba(34, 197, 94, 0.12);
  --c-green-border: rgba(34, 197, 94, 0.25);

  /* Shadows */
  --sh-panel: 0 4px 24px rgba(0, 0, 0, 0.38), 0 1px 4px rgba(0, 0, 0, 0.22);
  --sh-topbar: 0 4px 20px rgba(0, 0, 0, 0.32), 0 1px 3px rgba(0, 0, 0, 0.18);
  --sh-sm: 0 2px 8px rgba(0, 0, 0, 0.24);
  --sh-send: 0 4px 20px rgba(139, 92, 246, 0.45);

  /* Radii */
  --r-panel: 16px;
  --r-topbar: 14px;
  --r-input: 14px;
  --r-send: 14px;
  --r-btn: 11px;
  --r-chip: 999px;
  --r-item: 10px;
}

/* Light-mode token overrides */
html:not(.dark) .ll-ai-wrapper {
  --c-bg: #edeef8;
  --c-panel: rgba(255, 255, 255, 0.88);
  --c-panel-top: rgba(248, 248, 255, 0.95);
  --c-input-field: rgba(255, 255, 255, 0.92);
  --c-border: rgba(0, 0, 0, 0.07);
  --c-border-focus: rgba(123, 63, 242, 0.40);

  --c-text-1: #0f0f1a;
  --c-text-2: #5a5a72;
  --c-text-3: #9898ae;

  --c-accent: #7b3ff2;
  --c-accent-2: #8b5cf6;
  --c-accent-soft: rgba(123, 63, 242, 0.08);
  --c-accent-glow: rgba(123, 63, 242, 0.20);
  --c-accent-ring: rgba(123, 63, 242, 0.10);

  --c-green: #16a34a;
  --c-green-bg: rgba(22, 163, 74, 0.08);
  --c-green-border: rgba(22, 163, 74, 0.22);

  --sh-panel: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.05);
  --sh-topbar: 0 4px 16px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.04);
  --sh-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --sh-send: 0 4px 16px rgba(123, 63, 242, 0.30);
}


/* ════════════════════════════════════════════════════════════════
   §2  WRAPPER
   — background shows around glass panels
   — padding creates the visible gap (like the reference)
════════════════════════════════════════════════════════════════ */
.ll-ai-wrapper {
  display: flex;
  height: calc(100vh - 72px);
  height: calc(100dvh - 72px);
  overflow: hidden;
  position: relative;
  padding: 12px;
  gap: 10px;

  /* Dark: deep navy base + atmospheric purple-left, orange-right */
  background-color: var(--c-bg);
  background-image:
    radial-gradient(ellipse 62% 70% at 14% 58%,
      rgba(100, 28, 210, 0.42) 0%, transparent 60%),
    radial-gradient(ellipse 55% 55% at 88% 32%,
      rgba(210, 90, 25, 0.26) 0%, transparent 55%),
    radial-gradient(ellipse 38% 38% at 52% 78%,
      rgba(80, 20, 160, 0.14) 0%, transparent 55%);
  transition: background-color 0.3s ease;
}

/* Light mode: calm no-gradient bg */
html:not(.dark) .ll-ai-wrapper {
  background-image: none;
}


/* ════════════════════════════════════════════════════════════════
   §3  SIDEBAR — floating glass card
════════════════════════════════════════════════════════════════ */
.ll-ai-sidebar {
  width: 264px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-panel);
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  box-shadow: var(--sh-panel);
  overflow: hidden;
  z-index: 50;

  /* backdrop-filter for glass */
  backdrop-filter: blur(22px) saturate(1.5);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);

  /* Slide transition (JS toggles .ll-ai-sidebar-on) */
  transition: transform 0.30s cubic-bezier(0.4, 0, 0.2, 1);
}


/* ── §3a  Sidebar header ──────────────────────────────────── */
.ll-ai-sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

/* New Chat button — solid gradient fill (reference: prominent purple) */
.ll-ai-new-chat-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 16px;
  border-radius: var(--r-btn);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(135deg,
      #6d28d9 0%, #7c3aed 45%, #9d67ff 100%);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: -0.01em;
  cursor: pointer;

  transition:
    opacity 0.20s ease,
    transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.20s ease;
}

.ll-ai-new-chat-btn i {
  font-size: 11px;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ll-ai-new-chat-btn:hover {
  opacity: 0.90;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(109, 40, 217, 0.44);
}

.ll-ai-new-chat-btn:hover i {
  transform: rotate(90deg) scale(1.1);
}

.ll-ai-new-chat-btn:active {
  transform: scale(0.97);
  opacity: 0.85;
}

/* Light mode */
html:not(.dark) .ll-ai-new-chat-btn {
  border-color: rgba(123, 63, 242, 0.20);
}

/* Sidebar close — shown on mobile only */
.ll-ai-sidebar-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--c-text-3);
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  transition: background 0.16s ease, color 0.16s ease, transform 0.22s ease;
}

.ll-ai-sidebar-close:hover {
  background: rgba(239, 68, 68, 0.10);
  color: #ef4444;
  transform: rotate(90deg);
}


/* ── §3b  Section label ───────────────────────────────────── */
.ll-ai-sidebar-label {
  padding: 16px 14px 5px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-text-3);
  flex-shrink: 0;
}


/* ── §3c  History list ────────────────────────────────────── */
.ll-ai-history {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 92, 246, 0.18) transparent;
}

.ll-ai-history::-webkit-scrollbar {
  width: 3px;
}

.ll-ai-history::-webkit-scrollbar-track {
  background: transparent;
}

.ll-ai-history::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.20);
  border-radius: 3px;
}

/* Empty state */
.ll-ai-history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 44px 16px;
  color: var(--c-text-3);
  font-size: 12.5px;
  text-align: center;
}

.ll-ai-history-empty i {
  font-size: 26px;
}

/* History item */
.ll-ai-history-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: var(--r-item);
  cursor: pointer;
  color: var(--c-text-2);
  margin-bottom: 2px;
  position: relative;
  font-size: 13px;
  font-weight: 400;

  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.20s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ll-ai-history-item:hover {
  background: var(--c-accent-soft);
  color: var(--c-accent);
  transform: translateX(3px);
}

/* Active item — left bar indicator */
.ll-ai-history-item.ll-ai-active {
  background: var(--c-accent-soft);
  color: var(--c-accent);
  font-weight: 500;
}

.ll-ai-history-item.ll-ai-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 52%;
  border-radius: 0 3px 3px 0;
  background: var(--c-accent);
}

.ll-ai-history-item>i {
  font-size: 12px;
  flex-shrink: 0;
  opacity: 0.40;
}

.ll-ai-history-item-title {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Delete button (revealed on hover) */
.ll-ai-history-del {
  opacity: 0;
  background: none;
  border: none;
  color: var(--c-text-3);
  cursor: pointer;
  font-size: 11px;
  padding: 4px 5px;
  border-radius: 5px;
  flex-shrink: 0;
  font-family: inherit;
  transition: opacity 0.14s ease, color 0.14s ease, background 0.14s ease;
}

.ll-ai-history-item:hover .ll-ai-history-del {
  opacity: 1;
}

.ll-ai-history-del:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.10);
}


/* ── §3d  Sidebar footer ──────────────────────────────────── */
.ll-ai-sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}

.ll-ai-user-pill {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ll-ai-user-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-accent, #8b5cf6), #c084fc);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(139, 92, 246, 0.28);
}

.ll-ai-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ll-ai-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.ll-ai-user-role {
  font-size: 11px;
  color: var(--c-text-3);
  font-weight: 400;
}

/* Trash / clear-all button */
.ll-ai-trash-btn {
  background: none;
  border: none;
  color: var(--c-text-3);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  flex-shrink: 0;
  transition: color 0.15s ease, background 0.15s ease;
}

.ll-ai-trash-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.10);
}


/* ════════════════════════════════════════════════════════════════
   §4  MAIN AREA
   — transparent: shows wrapper background (atmospheric gradients)
   — individual children (topbar, input) get their own glass
════════════════════════════════════════════════════════════════ */
.ll-ai-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;

  /* Transparent — background shows through from wrapper */
  background: transparent;
}


/* ── §4a  TOPBAR — floating glass card ───────────────────── */
.ll-ai-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  flex-shrink: 0;
  min-height: 68px;

  /* Glass card — has its OWN border-radius */
  background: var(--c-panel-top);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid var(--c-border);
  border-radius: var(--r-topbar);
  box-shadow: var(--sh-topbar);
}

/* Hamburger (mobile) */
.ll-ai-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 16px;
  color: var(--c-text-2);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
  font-family: inherit;
}

.ll-ai-menu-btn:hover {
  color: var(--c-accent);
  background: var(--c-accent-soft);
}

/* Bot identity block */
.ll-ai-topbar-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Topbar avatar — colorful rounded-square (matches reference "AI" icon) */
.ll-ai-topbar-avatar {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  /* rounded square, NOT circle */
  background: linear-gradient(135deg,
      #6d28d9 0%, #7c3aed 30%, #9333ea 60%, #c026d3 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow:
    0 3px 14px rgba(109, 40, 217, 0.50),
    0 0 0 1px rgba(255, 255, 255, 0.10) inset;
  position: relative;

  /* No ring pulse — reference is clean/minimal */
}

.ll-ai-topbar-text {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* "Language Lab Assistant" — gradient text: purple → white */
.ll-ai-topbar-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;

  background: linear-gradient(90deg,
      #a78bfa 0%,
      #c4b5fd 28%,
      #ffffff 60%,
      #ffffff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

html:not(.dark) .ll-ai-topbar-name {
  background: linear-gradient(90deg,
      #7c3aed 0%, #9d67ff 35%, #0f0f1a 70%);
  -webkit-background-clip: text;
  background-clip: text;
}

/* "● Online" — styled as pill badge (matches reference exactly) */
.ll-ai-topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px 4px 8px;
  border-radius: 999px;
  background: var(--c-green-bg);
  border: 1px solid var(--c-green-border);
  color: var(--c-green);
  font-size: 12px;
  font-weight: 500;
  width: fit-content;
}

/* Pulsing green dot */
.ll-ai-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-green);
  flex-shrink: 0;
  animation: ll-ai-status-ping 2.6s ease-in-out infinite;
}

/* Compose / new-chat button (top-right) */
.ll-ai-compose-btn {
  background: none;
  border: 1px solid var(--c-border);
  font-size: 15px;
  color: var(--c-text-2);
  cursor: pointer;
  padding: 9px 10px;
  border-radius: 9px;
  font-family: inherit;
  transition:
    color 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    transform 0.22s ease;
}

.ll-ai-compose-btn:hover {
  color: var(--c-accent);
  background: var(--c-accent-soft);
  border-color: var(--c-border-focus);
  transform: scale(1.08);
}


/* ── §4b  Message feed — transparent ─────────────────────── */
.ll-ai-feed {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 92, 246, 0.16) transparent;
}

.ll-ai-feed::-webkit-scrollbar {
  width: 4px;
}

.ll-ai-feed::-webkit-scrollbar-track {
  background: transparent;
}

.ll-ai-feed::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.20);
  border-radius: 4px;
}


/* ════════════════════════════════════════════════════════════════
   §5  WELCOME SCREEN
════════════════════════════════════════════════════════════════ */
.ll-ai-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  gap: 18px;
  padding: 40px 24px;
  animation: ll-ai-fadein 0.45s ease both;
}

/* Robot icon — large, softly glowing */
.ll-ai-welcome-icon {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(145deg,
      rgba(109, 40, 217, 0.28) 0%,
      rgba(168, 85, 247, 0.18) 100%);
  border: 1px solid rgba(139, 92, 246, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c4b5fd;
  font-size: 42px;
  box-shadow:
    0 0 40px rgba(109, 40, 217, 0.28),
    0 0 80px rgba(109, 40, 217, 0.12);
  animation: ll-ai-float 5s ease-in-out infinite;
}

html:not(.dark) .ll-ai-welcome-icon {
  background: linear-gradient(145deg, rgba(123, 63, 242, 0.12), rgba(167, 139, 250, 0.08));
  border-color: rgba(123, 63, 242, 0.18);
  color: #7b3ff2;
  box-shadow: 0 4px 24px rgba(123, 63, 242, 0.14);
}

/* Welcome title — large, bold, white */
.ll-ai-welcome-title {
  font-size: 32px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.05em;
  line-height: 1.1;
  color: var(--c-text-1);
}

html:not(.dark) .ll-ai-welcome-title {
  color: #0f0f1a;
}

.ll-ai-welcome-sub {
  font-size: 15px;
  font-weight: 400;
  color: var(--c-text-2);
  max-width: 420px;
  line-height: 1.72;
  margin: 0;
}

/* ── Suggestion chips — dark pill buttons (reference style) ── */
.ll-ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 700px;
  margin-top: 6px;
}

.ll-ai-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--r-chip);

  /* Dark glass pill — matches reference exactly */
  background: rgba(22, 28, 58, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  color: rgba(255, 255, 255, 0.72);
  font-size: 13.5px;
  font-weight: 400;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: -0.01em;

  transition:
    color 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html:not(.dark) .ll-ai-chip {
  background: rgba(255, 255, 255, 0.80);
  border-color: rgba(0, 0, 0, 0.08);
  color: #3a3a5a;
  backdrop-filter: blur(8px);
}

.ll-ai-chip:hover {
  color: #ffffff;
  border-color: rgba(139, 92, 246, 0.50);
  background: rgba(139, 92, 246, 0.14);
  transform: translateY(-2px);
}

html:not(.dark) .ll-ai-chip:hover {
  color: #7b3ff2;
  border-color: rgba(123, 63, 242, 0.35);
  background: rgba(123, 63, 242, 0.06);
}

.ll-ai-chip:active {
  transform: translateY(0) scale(0.98);
}

.ll-ai-chip i {
  font-size: 12px;
  opacity: 0.55;
}


/* ════════════════════════════════════════════════════════════════
   §6  MESSAGE ROWS
════════════════════════════════════════════════════════════════ */
.ll-ai-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 100%;
  animation: ll-ai-msg-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.ll-ai-row.ll-ai-row-user {
  flex-direction: row-reverse;
}


/* ── Avatars ── */
.ll-ai-row-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-bottom: 2px;
  overflow: hidden;
}

.ll-ai-row-bot .ll-ai-row-avatar {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.32);
}

.ll-ai-row-user .ll-ai-row-avatar {
  background: rgba(139, 92, 246, 0.15);
  color: rgba(196, 181, 253, 0.80);
  border: 1px solid rgba(139, 92, 246, 0.18);
}

html:not(.dark) .ll-ai-row-user .ll-ai-row-avatar {
  background: #e8e4f5;
  color: #7b3ff2;
}


/* ── Content wrapper ── */
.ll-ai-row-content {
  max-width: min(560px, 78%);
  display: flex;
  flex-direction: column;
  gap: 4px;
}


/* ── Bubbles ── */
.ll-ai-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.72;
  letter-spacing: -0.01em;
  word-break: break-word;
}

/* Bot bubble — dark glass card */
.ll-ai-row-bot .ll-ai-bubble {
  background: rgba(17, 22, 46, 0.82);
  color: rgba(255, 255, 255, 0.88);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: var(--sh-sm);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

html:not(.dark) .ll-ai-row-bot .ll-ai-bubble {
  background: rgba(255, 255, 255, 0.88);
  color: #0f0f1a;
  border-color: rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(8px);
}

/* User bubble — accent gradient */
.ll-ai-row-user .ll-ai-bubble {
  background: linear-gradient(145deg, #6d28d9 0%, #7c3aed 50%, #9d67ff 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 18px rgba(109, 40, 217, 0.36);
}


/* ── Timestamp ── */
.ll-ai-msg-ts {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--c-text-3);
  padding: 0 4px;
}

.ll-ai-row-user .ll-ai-msg-ts {
  text-align: right;
}


/* ════════════════════════════════════════════════════════════════
   §7  MARKDOWN  (inside .ll-ai-bubble)
════════════════════════════════════════════════════════════════ */
.ll-ai-bubble p {
  margin: 0 0 8px;
}

.ll-ai-bubble p:last-child {
  margin-bottom: 0;
}

.ll-ai-bubble strong {
  font-weight: 600;
}

.ll-ai-bubble em {
  font-style: italic;
}

.ll-ai-bubble code {
  background: rgba(139, 92, 246, 0.14);
  color: #c4b5fd;
  padding: 2px 6px;
  border-radius: 5px;
  font-family: 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
  font-size: 12.5px;
}

html:not(.dark) .ll-ai-bubble code {
  background: rgba(123, 63, 242, 0.09);
  color: #7b3ff2;
}

.ll-ai-row-user .ll-ai-bubble code {
  background: rgba(255, 255, 255, 0.20);
  color: #fff;
}

.ll-ai-bubble pre {
  background: #0d1117;
  color: #e6edf3;
  padding: 14px 16px;
  border-radius: 11px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 12.5px;
  line-height: 1.65;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.ll-ai-bubble pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

.ll-ai-bubble ul,
.ll-ai-bubble ol {
  padding-left: 20px;
  margin: 6px 0;
}

.ll-ai-bubble li {
  margin-bottom: 5px;
}

.ll-ai-bubble h1 {
  font-size: 17px;
  font-weight: 700;
  margin: 12px 0 5px;
  letter-spacing: -0.03em;
}

.ll-ai-bubble h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 10px 0 4px;
  letter-spacing: -0.02em;
}

.ll-ai-bubble h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 8px 0 4px;
}

.ll-ai-bubble blockquote {
  border-left: 3px solid var(--c-accent);
  padding-left: 12px;
  margin: 8px 0;
  font-style: italic;
  opacity: 0.78;
}

.ll-ai-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}

.ll-ai-bubble th,
.ll-ai-bubble td {
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 7px 11px;
  text-align: left;
}

html:not(.dark) .ll-ai-bubble th,
html:not(.dark) .ll-ai-bubble td {
  border-color: rgba(0, 0, 0, 0.08);
}

.ll-ai-bubble th {
  background: var(--c-accent-soft);
  font-weight: 600;
}


/* ════════════════════════════════════════════════════════════════
   §8  TYPING INDICATOR
   IDs/classes used by JS: #ll-ai-typing, .ll-ai-typing,
   .ll-ai-typing-avatar, .ll-ai-typing-bubble, .ll-ai-typing-dot
════════════════════════════════════════════════════════════════ */
.ll-ai-typing {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  animation: ll-ai-fadein 0.22s ease both;
}

.ll-ai-typing-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.32);
}

.ll-ai-typing-bubble {
  background: rgba(17, 22, 46, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 13px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

html:not(.dark) .ll-ai-typing-bubble {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(0, 0, 0, 0.06);
}

.ll-ai-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a855f7;
  opacity: 0.36;
  animation: ll-ai-bounce 1.4s infinite ease-in-out;
}

html:not(.dark) .ll-ai-typing-dot {
  background: #7b3ff2;
}

.ll-ai-typing-dot:nth-child(1) {
  animation-delay: 0.00s;
}

.ll-ai-typing-dot:nth-child(2) {
  animation-delay: 0.18s;
}

.ll-ai-typing-dot:nth-child(3) {
  animation-delay: 0.36s;
}


/* ════════════════════════════════════════════════════════════════
   §9  ERROR TOAST
════════════════════════════════════════════════════════════════ */
.ll-ai-error-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  border-radius: 11px;
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.22);
  color: #f87171;
  font-size: 13px;
  max-width: 440px;
  align-self: flex-start;
  margin-left: 42px;
  animation: ll-ai-fadein 0.22s ease both;
}

html:not(.dark) .ll-ai-error-toast {
  background: rgba(239, 68, 68, 0.06);
  color: #dc2626;
}


/* ════════════════════════════════════════════════════════════════
   §10  INPUT AREA
   ─────────────────────────────────────────────────────────────
   KEY DESIGN: .ll-ai-input-box is a transparent flex container.
   The textarea gets its OWN glass background.
   The send button is a SEPARATE large standalone element.
   This matches the reference image exactly.
════════════════════════════════════════════════════════════════ */
.ll-ai-input-wrap {
  padding: 10px 0 10px;
  flex-shrink: 0;
  background: transparent;
  border-top: none;
  /* no divider — feed bleeds into input naturally */
}

/* ── Transparent container ── */
.ll-ai-input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;

  /* Reset all visual styles — children handle their own look */
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  outline: none !important;
}

/* Focus-within: forward glow to the textarea, NOT the container */
.ll-ai-input-box:focus-within .ll-ai-textarea {
  border-color: var(--c-border-focus);
  box-shadow:
    0 0 0 3px var(--c-accent-ring),
    0 4px 20px var(--c-accent-glow);
}

/* ── Textarea: its own glass element ── */
.ll-ai-textarea {
  flex: 1;
  background: var(--c-input-field);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-input);
  padding: 18px 22px;
  min-height: 80px;
  /* taller — matches reference */
  max-height: 200px;
  overflow-y: auto;

  font-size: 14.5px;
  font-weight: 400;
  font-family: inherit;
  line-height: 1.65;
  letter-spacing: -0.01em;
  color: rgba(255, 255, 255, 0.85);

  resize: none;
  outline: none !important;
  -webkit-appearance: none;

  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.28);

  /* Smooth border + shadow transition */
  transition:
    border-color 0.22s ease,
    box-shadow 0.22s ease;

  scrollbar-width: thin;
  scrollbar-color: rgba(139, 92, 246, 0.18) transparent;
}

html:not(.dark) .ll-ai-textarea {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.07);
  color: #0f0f1a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ll-ai-textarea::placeholder {
  color: var(--c-text-3);
  font-size: 14.5px;
  font-weight: 400;
}

html:not(.dark) .ll-ai-textarea::placeholder {
  color: #9898ae;
}

.ll-ai-textarea::-webkit-scrollbar {
  width: 3px;
}

.ll-ai-textarea::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.18);
  border-radius: 2px;
}

/* ── Send button — large standalone square (matches reference) ── */
.ll-ai-send-btn {
  width: 84px;
  min-height: 80px;
  align-self: stretch;
  flex-shrink: 0;

  border: none;
  border-radius: var(--r-send);
  background: linear-gradient(145deg,
      #7c3aed 0%, #9333ea 50%, #c084fc 100%);
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  box-shadow: var(--sh-send);
  position: relative;
  overflow: hidden;

  transition:
    transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.20s ease,
    opacity 0.18s ease;
}

/* Icon transition */
.ll-ai-send-btn i {
  position: relative;
  z-index: 1;
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Shimmer fill on hover */
.ll-ai-send-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, #9333ea 0%, #7c3aed 60%, #6d28d9 100%);
  opacity: 0;
  transition: opacity 0.20s ease;
  border-radius: inherit;
}

.ll-ai-send-btn:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 8px 28px rgba(139, 92, 246, 0.55);
}

.ll-ai-send-btn:hover:not(:disabled)::after {
  opacity: 1;
}

.ll-ai-send-btn:hover:not(:disabled) i {
  transform: rotate(-14deg) scale(1.1);
}

.ll-ai-send-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.ll-ai-send-btn:disabled {
  opacity: 0.30;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Loading spinner */
.ll-ai-send-btn .ll-ai-spin {
  display: inline-block;
  animation: ll-ai-spin 0.72s linear infinite;
  position: relative;
  z-index: 1;
}

/* ── Char counter + keyboard hint row ── */
.ll-ai-input-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 4px;
}

.ll-ai-char-count {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--c-text-3);
  font-variant-numeric: tabular-nums;
}

.ll-ai-char-count.ll-ai-warn {
  color: #f87171;
}

.ll-ai-hint {
  font-size: 11px;
  color: var(--c-text-3);
}

.ll-ai-hint kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 10px;
  font-family: inherit;
  color: var(--c-text-3);
}

html:not(.dark) .ll-ai-hint kbd {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.09);
}


/* ════════════════════════════════════════════════════════════════
   §11  MOBILE OVERLAY
════════════════════════════════════════════════════════════════ */
.ll-ai-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 40;
  animation: ll-ai-fadein 0.2s ease both;
}

.ll-ai-overlay.ll-ai-overlay-on {
  display: block;
}


/* ════════════════════════════════════════════════════════════════
   §12  AVATAR IMAGE  (injected when profilePhoto set)
════════════════════════════════════════════════════════════════ */
.ll-ai-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}


/* ════════════════════════════════════════════════════════════════
   §13  KEYFRAMES
════════════════════════════════════════════════════════════════ */

/* Fade + lift */
@keyframes ll-ai-fadein {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Message bubble — springy entry */
@keyframes ll-ai-msg-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Typing dots */
@keyframes ll-ai-bounce {

  0%,
  80%,
  100% {
    transform: scale(1) translateY(0);
    opacity: 0.36;
  }

  40% {
    transform: scale(1.6) translateY(-5px);
    opacity: 1;
  }
}

/* Loading spinner */
@keyframes ll-ai-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Status dot ping */
@keyframes ll-ai-status-ping {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.50);
  }

  50% {
    box-shadow: 0 0 0 5px rgba(74, 222, 128, 0);
  }
}

/* Welcome icon float */
@keyframes ll-ai-float {

  0%,
  100% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-10px);
  }
}


/* ════════════════════════════════════════════════════════════════
   §14  RESPONSIVE
════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Wrapper: reduce padding on mobile */
  .ll-ai-wrapper {
    padding: 8px;
    gap: 0;
  }

  /* Sidebar: slides over content (JS adds .ll-ai-sidebar-on) */
  .ll-ai-sidebar {
    position: fixed;
    left: 8px;
    top: 80px;
    height: calc(100vh - 88px);
    height: calc(100dvh - 88px);
    transform: translateX(calc(-100% - 12px));
    border-radius: var(--r-panel);
  }

  .ll-ai-sidebar.ll-ai-sidebar-on {
    transform: translateX(0);
  }

  .ll-ai-sidebar-close {
    display: flex;
  }

  .ll-ai-menu-btn {
    display: flex;
  }

  .ll-ai-row-content {
    max-width: min(280px, 88%);
  }

  .ll-ai-hint {
    display: none;
  }

  .ll-ai-feed {
    padding: 14px 12px;
  }

  .ll-ai-input-wrap {
    padding: 8px 0 8px;
  }

  .ll-ai-topbar {
    border-radius: var(--r-topbar);
  }

  .ll-ai-send-btn {
    width: 68px;
    min-height: 68px;
    font-size: 17px;
  }
}

@media (max-width: 480px) {

  .ll-ai-wrapper {
    padding: 6px;
  }

  .ll-ai-welcome-title {
    font-size: 24px;
  }

  .ll-ai-welcome-icon {
    width: 72px;
    height: 72px;
    font-size: 32px;
  }

  .ll-ai-chips {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
  }

  .ll-ai-chip {
    justify-content: flex-start;
    border-radius: 14px;
  }

  .ll-ai-topbar {
    padding: 10px 12px;
    min-height: 60px;
  }

  .ll-ai-topbar-name {
    font-size: 16px;
  }

  .ll-ai-textarea {
    min-height: 64px;
    padding: 14px 16px;
  }

  .ll-ai-send-btn {
    width: 60px;
    min-height: 60px;
    font-size: 16px;
  }
}