/* ═══════════════════════════════════════════════════════════
   ChatBox2 Web — 2026 Modern Aesthetic & Design System
   Design System: Rooted Warmth (Material You + Glassmorphism)
   ═══════════════════════════════════════════════════════════ */

:root {
  --primary: #4a7c59;
  --primary-hover: #3d6749;
  --primary-active: #32553c;
  --on-primary: #ffffff;
  --primary-container: #b7f3bd;
  --on-primary-container: #002107;
  --primary-fixed: #b7f3bd;
  --primary-fixed-dim: #9cce9c;
  --secondary: #516350;
  --on-secondary: #ffffff;
  --secondary-container: #d4e8d1;
  --tertiary: #39656c;
  --error: #ba1a1a;
  --on-error: #ffffff;
  --error-container: #ffdad6;
  --outline: #72796f;
  --outline-variant: #c2c9bd;
  --background: #fcfdf7;
  --on-background: #1a1c19;
  --surface: #fcfdf7;
  --on-surface: #1a1c19;
  --surface-variant: #dee5d9;
  --on-surface-variant: #424940;
  --surface-container-highest: #e1e4dc;
  --surface-container-high: #e7eae1;
  --surface-container: #edefe6;
  --surface-container-low: #f4f6ee;
  --surface-container-lowest: #ffffff;
  --surface-dim: #d9dbd5;
}

/* ── Base Reset & Global Styles ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

button, input, textarea, select, a {
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
a {
  text-decoration: none;
}



html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--on-surface);
  background-color: var(--surface-container-low);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Material Symbols / Icons Font ── */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined', sans-serif;
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}

/* ── Core Flex & Grid Layout Utilities ── */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-start { justify-content: flex-start; }
.grid { display: grid; }

/* ── Visibility Rules (Strict Priority) ── */
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }

/* ── Sizing & Dimensions ── */
.w-full { width: 100%; }
.h-full { height: 100%; }
.h-screen { height: 100vh; }
.h-14 { height: 3.5rem; }
.w-8 { width: 2rem; }
.h-8 { height: 2rem; }
.w-9 { width: 2.25rem; }
.h-9 { height: 2.25rem; }
.w-12 { width: 3rem; }
.h-12 { height: 3rem; }
.w-16 { width: 4rem; }
.h-16 { height: 4rem; }
.w-64 { width: 16.5rem; }
.min-h-\[56px\] { min-height: 56px; }
.max-w-\[800px\] { max-width: 820px; }
.max-w-\[500px\] { max-width: 520px; }
.max-w-md { max-width: 28rem; }
.max-w-sm { max-width: 24rem; }
.max-w-\[85\%\] { max-width: 85%; }
.max-w-\[90\%\] { max-width: 90%; }
.mx-auto { margin-left: auto; margin-right: auto; }
.mx-4 { margin-left: 1rem; margin-right: 1rem; }

/* ── Positioning ── */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-0 { top: 0; }
.left-0 { left: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.bottom-44 { bottom: 11rem; }
.left-1\/2 { left: 50%; }
.-translate-x-1\/2 { transform: translateX(-50%); }
.z-0 { z-index: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-50 { z-index: 50; }
.z-\[60\] { z-index: 60; }
.z-100 { z-index: 100; }
.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }

/* ── Overflow ── */
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-auto { overflow-x: auto; }

/* ── Gaps & Spacing ── */
.gap-0 { gap: 0; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-stack-gap { gap: 18px; }

/* ── Padding & Margins ── */
.p-0\.5 { padding: 0.125rem; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.px-1 { padding-left: 0.25rem; padding-right: 0.25rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-16 { padding-top: 4rem; padding-bottom: 4rem; }
.px-gutter { padding-left: 28px; padding-right: 28px; }
.py-stack-gap { padding-top: 20px; padding-bottom: 20px; }
.px-margin-mobile { padding-left: 18px; padding-right: 18px; }
.py-margin-desktop { padding-top: 36px; padding-bottom: 36px; }
.pb-48 { padding-bottom: 13rem; }
.pt-12 { padding-top: 3rem; }
.pb-6 { padding-bottom: 1.5rem; }
.pt-4 { padding-top: 1rem; }
.pt-5 { padding-top: 1.25rem; }
.pb-3 { padding-bottom: 0.75rem; }
.pb-4 { padding-bottom: 1rem; }
.pt-2 { padding-top: 0.5rem; }
.pl-1 { padding-left: 0.25rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-auto { margin-top: auto; }

/* ── Colors & Backgrounds ── */
.bg-surface-container-lowest { background-color: var(--surface-container-lowest); }
.bg-surface-container-lowest\/80 { background-color: rgba(255, 255, 255, 0.88); }
.bg-surface-container-lowest\/50 { background-color: rgba(255, 255, 255, 0.72); }
.bg-surface-container-low { background-color: var(--surface-container-low); }
.bg-surface-container { background-color: var(--surface-container); }
.bg-surface-container-high { background-color: var(--surface-container-high); }
.bg-surface-container-highest { background-color: var(--surface-container-highest); }
.bg-primary { background-color: var(--primary); }
.bg-primary\/10 { background-color: rgba(74, 124, 89, 0.1); }
.bg-primary-container { background-color: var(--primary-container); }
.bg-error { background-color: var(--error); }
.bg-transparent { background-color: transparent; }
.bg-gradient-to-br { background-image: linear-gradient(135deg, #b7f3bd 0%, #4a7c59 100%); }
.bg-gradient-to-t { background-image: linear-gradient(to top, var(--surface-container-low) 0%, rgba(244, 246, 238, 0.95) 75%, transparent 100%); }

.text-on-surface { color: var(--on-surface); }
.text-on-surface-variant { color: var(--on-surface-variant); }
.text-on-primary { color: var(--on-primary); }
.text-on-primary-container { color: var(--on-primary-container); }
.text-primary { color: var(--primary); }
.text-error { color: var(--error); }

/* ── Borders & Radii ── */
.border { border-width: 1px; border-style: solid; border-color: rgba(194, 201, 189, 0.4); }
.border-b { border-bottom-width: 1px; border-bottom-style: solid; border-color: rgba(194, 201, 189, 0.3); }
.border-t { border-top-width: 1px; border-top-style: solid; border-color: rgba(194, 201, 189, 0.3); }
.border-r { border-right-width: 1px; border-right-style: solid; border-color: rgba(194, 201, 189, 0.3); }
.border-none { border: none !important; }
.border-outline-variant\/20 { border-color: rgba(194, 201, 189, 0.25); }
.border-outline-variant\/30 { border-color: rgba(194, 201, 189, 0.38); }
.border-primary { border-color: var(--primary); }

.rounded-full { border-radius: 9999px; }
.rounded-xl { border-radius: 0.875rem; }
.rounded-2xl { border-radius: 1.25rem; }
.rounded-\[12px\] { border-radius: 14px; }
.rounded-\[16px\] { border-radius: 18px; }
.rounded-\[18px\] { border-radius: 18px; }
.rounded-md { border-radius: 8px; }
.rounded-lg { border-radius: 10px; }
.rounded-tl-sm { border-top-left-radius: 4px; }
.rounded-tr-sm { border-top-right-radius: 4px; }

/* ── Typography & Text ── */
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-normal { font-weight: 400; }
.font-mono { font-family: 'Fira Code', 'Consolas', monospace; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.text-\[10px\] { font-size: 10px; }
.text-\[11px\] { font-size: 11px; }
.text-\[12px\] { font-size: 12px; }
.text-\[13px\] { font-size: 13px; }
.text-\[14px\] { font-size: 14px; }
.text-\[16px\] { font-size: 16px; }
.text-\[18px\] { font-size: 18px; }
.text-\[20px\] { font-size: 20px; }
.uppercase { text-transform: uppercase; }
.tracking-tight { letter-spacing: -0.02em; }
.tracking-wider { letter-spacing: 0.05em; }
.tracking-widest { letter-spacing: 0.12em; }
.leading-none { line-height: 1; }
.leading-relaxed { line-height: 1.65; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-center { text-align: center; }
.opacity-50 { opacity: 0.5; }
.opacity-60 { opacity: 0.6; }
.opacity-70 { opacity: 0.7; }
.opacity-80 { opacity: 0.8; }
.opacity-100 { opacity: 1; }

/* ── Shadows & Glassmorphism ── */
.shadow-sm { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02); }
.shadow-md { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.02); }
.shadow-lg { box-shadow: 0 12px 36px -6px rgba(0, 0, 0, 0.08), 0 4px 12px -2px rgba(0, 0, 0, 0.04); }
.shadow-xl { box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.14), 0 8px 16px -4px rgba(0, 0, 0, 0.05); }
.shadow-2xl { box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.22); }
.backdrop-blur-sm { backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.backdrop-blur-md { backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.backdrop-blur-xl { backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }
.cursor-pointer { cursor: pointer; }
.resize-none { resize: none; }
.outline-none { outline: none; }

/* ── Transitions & Interactive ── */
.transition-all { transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
.transition-colors { transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease; }
.transition-transform { transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
.transition-opacity { transition: opacity 0.15s ease; }
.duration-200 { transition-duration: 200ms; }
.duration-300 { transition-duration: 300ms; }

.hover\:scale-105:hover { transform: scale(1.05); }
.hover\:scale-110:hover { transform: scale(1.1); }
.hover\:bg-surface-container:hover { background-color: var(--surface-container); }
.hover\:text-on-surface:hover { color: var(--on-surface); }
.hover\:text-primary:hover { color: var(--primary); }
.group:hover .group-hover\:opacity-100 { opacity: 1; }
.group:hover .group-hover\:opacity-60 { opacity: 0.6; }

/* ── Custom Scrollbars ── */
.chat-scroll::-webkit-scrollbar { width: 6px; }
.chat-scroll::-webkit-scrollbar-track { background: transparent; }
.chat-scroll::-webkit-scrollbar-thumb {
  background: rgba(66, 73, 64, 0.18);
  border-radius: 4px;
}
.chat-scroll::-webkit-scrollbar-thumb:hover { background: rgba(66, 73, 64, 0.35); }

.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(66, 73, 64, 0.12);
  border-radius: 2px;
}

/* ── Mobile Sidebar Overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 18, 0.4);
  z-index: 15;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.sidebar-overlay.active { display: block; }

@media (max-width: 767px) {
  .sidebar-mobile {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 25;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    width: 290px;
    box-shadow: 6px 0 30px rgba(0, 0, 0, 0.15);
  }
  .sidebar-mobile.open {
    transform: translateX(0) !important;
  }
  .md\:hidden { display: flex !important; }
}

@media (min-width: 768px) {
  .md\:hidden { display: none !important; }
  .md\:\!translate-x-0 { transform: translateX(0) !important; }
}

/* ═══════════════════════════════════════════════════════════
   2026 UI COMPONENTS SPECIFICS
   ═══════════════════════════════════════════════════════════ */

/* ── Welcome Screen & Cards ── */
.welcome-container {
  animation: fade-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.welcome-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  max-width: 620px;
  width: 100%;
}

.welcome-card {
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid rgba(194, 201, 189, 0.45);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.welcome-card:hover {
  border-color: rgba(74, 124, 89, 0.45);
  background: rgba(255, 255, 255, 0.98);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(74, 124, 89, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
}

.welcome-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(74, 124, 89, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.welcome-card:hover .welcome-card-icon {
  transform: scale(1.08);
  background: rgba(74, 124, 89, 0.15);
}

/* ── Floating Input Box ── */
.focus-within\:border-primary\/50:focus-within {
  border-color: rgba(74, 124, 89, 0.5) !important;
}

.focus-within\:shadow-\[0_4px_20px_rgba\(74\,124\,89\,0\.1\)\]:focus-within {
  box-shadow: 0 12px 36px -4px rgba(74, 124, 89, 0.18), 0 0 0 2px rgba(74, 124, 89, 0.1) !important;
}

/* ── Toolbar Buttons ── */
.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: #72796f;
  cursor: pointer;
  transition: all 0.15s ease;
}
.toolbar-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #1a1c19;
  transform: scale(1.05);
}
.toolbar-btn.active {
  color: #4a7c59;
  background: rgba(74, 124, 89, 0.14);
}

/* ── Model Selector ── */
#model-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 20px;
  background: rgba(74, 124, 89, 0.06);
  border: 1px solid rgba(74, 124, 89, 0.2);
  font-size: 12px;
  font-weight: 600;
  color: #386245;
  transition: all 0.2s ease;
}
#model-selector:hover {
  background: rgba(74, 124, 89, 0.12);
  border-color: rgba(74, 124, 89, 0.35);
}

.model-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: #ffffff;
  border: 1px solid rgba(194, 201, 189, 0.4);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
  padding: 6px;
  min-width: 260px;
  z-index: 100;
  animation: fade-in 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.model-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
  font-size: 13.5px;
  color: #1a1c19;
}
.model-option:hover { background: #f3f5ec; }
.model-option.active {
  background: rgba(74, 124, 89, 0.12);
  color: #326342;
  font-weight: 600;
}
.model-price {
  font-size: 11px;
  color: #72796f;
  font-weight: 500;
}

/* ── MODALS (Fixed Overlay & Floating Card) ── */
#auth-modal,
#topup-modal {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;
  background: rgba(15, 23, 18, 0.45) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
}

#auth-modal.hidden,
#topup-modal.hidden {
  display: none !important;
}

#auth-modal.flex,
#topup-modal.flex {
  display: flex !important;
}

/* Modal Inner Card */
#auth-modal > div,
#topup-modal > div {
  background: var(--surface-container-lowest);
  border: 1px solid rgba(194, 201, 189, 0.45);
  border-radius: 24px;
  box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.9);
  animation: modal-pop 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  max-width: 440px;
  width: 100%;
}

@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.auth-tabs-container {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.05);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.auth-tab-btn {
  flex: 1;
  padding: 9px 16px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: #72796f;
  border-radius: 9px;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.auth-tab-btn:hover {
  color: #1a1c19;
  background: rgba(255, 255, 255, 0.6);
}
.auth-tab-btn.active {
  color: #4a7c59;
  background: #ffffff;
  font-weight: 700;
  border-color: rgba(0, 0, 0, 0.06);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
}
.auth-tab-btn:active {
  transform: scale(0.975);
}

#auth-submit-btn {
  border: none !important;
  outline: none !important;
  cursor: pointer;
}

#auth-submit-btn:focus,
#auth-submit-btn:focus-visible {
  outline: none !important;
  border: none !important;
  box-shadow: 0 0 0 2px rgba(74, 124, 89, 0.35) !important;
}

.topup-preset-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid rgba(194, 201, 189, 0.5);
  background: transparent;
  color: #1a1c19;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.topup-preset-btn:hover {
  background: rgba(74, 124, 89, 0.08);
  border-color: #4a7c59;
  color: #4a7c59;
}
.topup-preset-btn.selected {
  background: #4a7c59;
  border-color: #4a7c59;
  color: #fff;
  box-shadow: 0 3px 10px rgba(74, 124, 89, 0.25);
}

/* ── Markdown Content Styling ── */
.md-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--on-surface);
}
.md-content h1, .md-content h2, .md-content h3 {
  margin-top: 1.1em;
  margin-bottom: 0.5em;
  font-weight: 700;
  color: #1a1c19;
  letter-spacing: -0.01em;
}
.md-content h1 { font-size: 1.45em; }
.md-content h2 { font-size: 1.25em; }
.md-content h3 { font-size: 1.1em; }
.md-content p { margin-bottom: 0.75em; line-height: 1.7; }
.md-content p:last-child { margin-bottom: 0; }
.md-content ul, .md-content ol { margin: 0.6em 0; padding-left: 1.5em; }
.md-content li { margin-bottom: 0.3em; line-height: 1.6; }
.md-content code {
  background: #edefe6;
  color: #2f4534;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.9em;
  font-family: 'Fira Code', 'Consolas', monospace;
}
.md-content pre {
  background: #191c19;
  color: #f0f1ec;
  border-radius: 14px;
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0.85em 0;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.md-content pre code { background: transparent; padding: 0; color: inherit; font-size: 0.88em; }
.md-content blockquote {
  border-left: 3px solid #4a7c59;
  padding: 8px 16px;
  margin: 0.75em 0;
  background: rgba(74, 124, 89, 0.05);
  border-radius: 0 10px 10px 0;
}
.md-content strong { color: #1a1c19; font-weight: 600; }
.md-content a { color: #4a7c59; text-decoration: underline; text-underline-offset: 2px; }

/* ── Code Copy Button ── */
.code-copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  color: #d4e8d1;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.code-copy-btn:hover {
  background: rgba(255,255,255,0.22);
  color: #fff;
}

/* ── Message Actions ── */
.msg-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #72796f;
  cursor: pointer;
  transition: all 0.15s ease;
}
.msg-action-btn:hover {
  background: rgba(0,0,0,0.06);
  color: #1a1c19;
  transform: scale(1.08);
}
.msg-action-btn.msg-action-danger:hover {
  background: rgba(186, 26, 26, 0.1);
  color: #ba1a1a;
}

/* ── Message "More" Dropdown Menu ── */
.msg-more-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0px;
  min-width: 170px;
  background: #ffffff;
  border: 1px solid rgba(194, 201, 189, 0.5);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.06);
  padding: 4px;
  z-index: 100;
  animation: fade-in 0.15s ease-out;
}
.msg-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 12px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #1a1c19;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.msg-menu-item:hover {
  background: rgba(0,0,0,0.05);
}
.msg-menu-item.msg-menu-danger {
  color: #ba1a1a;
}
.msg-menu-item.msg-menu-danger:hover {
  background: rgba(186, 26, 26, 0.08);
}
.msg-menu-divider {
  border: none;
  border-top: 1px solid rgba(194, 201, 189, 0.3);
  margin: 4px 8px;
}

/* When menu overflows bottom — open above the button */
.msg-more-menu--above {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 4px;
}


/* ══════════════════════════════════════════
   Chat Sidebar Tree — Redesigned
   ══════════════════════════════════════════ */

/* ── Tree root container ── */
.chat-tree-root {
  position: relative;
}

/* ── Root Chat Item ── */
.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  color: var(--on-surface-variant);
  cursor: pointer;
  position: relative;
  transition: background 0.2s, color 0.2s;
  text-decoration: none;
  min-height: 40px;
}
.chat-item:hover {
  background: var(--surface-container);
  color: var(--on-surface);
}
.chat-item--active {
  background: rgba(74, 124, 89, 0.12);
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.chat-item--active::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 16px;
  border-radius: 4px;
  background: var(--primary);
}

.chat-item__icon {
  font-size: 20px;
  opacity: 0.65;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.chat-item:hover .chat-item__icon,
.chat-item--active .chat-item__icon {
  opacity: 1;
}

.chat-item__title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.3;
}

/* ── Chevron (expand/collapse) ── */
.chat-item__chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  opacity: 0.5;
  flex-shrink: 0;
  transition: opacity 0.2s, background 0.2s;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
}
.chat-item__chevron:hover {
  opacity: 1;
  background: var(--surface-container);
}
.expand-chevron {
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.expand-chevron.collapsed {
  transform: rotate(-90deg);
}

/* ── Hover action buttons ── */
.chat-item__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}
.chat-item:hover .chat-item__actions,
.chat-branch-item:hover .chat-item__actions {
  opacity: 1;
}

.chat-item__action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  padding: 0;
}
.chat-item__action:hover {
  opacity: 1;
}
.chat-item__action--fork:hover {
  background: rgba(74, 124, 89, 0.1);
  color: var(--primary);
}
.chat-item__action--delete:hover {
  background: rgba(186, 26, 26, 0.08);
  color: var(--error);
}

/* ── Branch group (collapsible children) ── */
.chat-branch-group {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease;
  opacity: 0;
  margin-left: 16px;
  border-left: 1.5px solid var(--outline-variant);
  overflow: hidden;
}
.chat-branch-group--open {
  grid-template-rows: 1fr;
  opacity: 1;
}
.chat-branch-group > * {
  min-height: 0;
}

/* ── Child (branch) chat item ── */
.chat-branch-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 0;
  margin-left: -1.5px;
  color: var(--on-surface-variant);
  cursor: pointer;
  position: relative;
  transition: background 0.2s, color 0.2s;
  text-decoration: none;
  min-height: 34px;
  border-radius: 0 10px 10px 0;
}
.chat-branch-item:hover {
  background: var(--surface-container);
  color: var(--on-surface);
}
.chat-branch-item--active {
  background: rgba(74, 124, 89, 0.1);
  color: var(--primary);
  font-weight: 600;
}

/* ── Connector line (L-shaped from vertical bar to dot) ── */
.chat-branch-item__connector {
  display: block;
  width: 14px;
  height: 1.5px;
  background: var(--outline-variant);
  flex-shrink: 0;
}

/* ── Dot marker for children ── */
.chat-branch-item__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--outline-variant);
  flex-shrink: 0;
  transition: background 0.2s, transform 0.2s;
}
.chat-branch-item:hover .chat-branch-item__dot {
  background: var(--primary);
  transform: scale(1.3);
}
.chat-branch-item--active .chat-branch-item__dot {
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.15);
}

.chat-branch-item__title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  line-height: 1.3;
}

/* ── Balance Widget ── */
.balance-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(74, 124, 89, 0.1);
  font-size: 12px;
  font-weight: 600;
  color: #4a7c59;
  transition: all 0.2s;
}
#balance-display:hover .balance-chip {
  background: rgba(74, 124, 89, 0.2);
  transform: scale(1.02);
}

/* ── Transaction History Rows ── */
.tx-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(194, 201, 189, 0.15);
  font-size: 12px;
}
.tx-row:last-child { border-bottom: none; }
.tx-amount { font-weight: 600; color: #4a7c59; }
.tx-amount.pending { color: #72796f; }
.tx-amount.failed { color: #ba1a1a; }
.tx-date { color: #72796f; }
.tx-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}
.tx-status.success { background: rgba(74, 124, 89, 0.1); color: #4a7c59; }
.tx-status.pending { background: rgba(114, 121, 111, 0.1); color: #72796f; }

/* ── Animations ── */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.msg-enter {
  animation: fade-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 16px;
}
.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4a7c59;
  animation: pulse-dot 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ── Stop Button ── */
.stop-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 24px;
  border: 1px solid rgba(186, 26, 26, 0.3);
  background: #ffffff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  color: #ba1a1a;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.stop-btn:hover {
  background: rgba(186, 26, 26, 0.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(186, 26, 26, 0.15);
}

/* ── New Chat Button ── */
.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 12px 0;
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 700;
  transition: all 0.3s ease;
  background: #4a7c59;
  color: #fff;
  border: none;
  cursor: pointer;
}
.new-chat-btn:hover {
  background: #44654e;
}

/* ── Send Message Button ── */
.send-message-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-primary);
  transition: all 0.3s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  border: none;
  cursor: pointer;
}
.send-message-btn:hover {
  background: #44654e;
}
