:root {
  --bg-dark: #0a0a0c;
  --sidebar-bg: #0f0f12;
  --accent-purple: #8b5cf6;
  --accent-purple-glow: rgba(139, 92, 246, 0.3);
  --accent-green: #10b981;
  --accent-yellow: #f59e0b;
  --text-main: #ffffff;
  --text-dim: #94a3b8;
  --border-color: rgba(255, 255, 255, 0.08);
  --glass-bg: rgba(255, 255, 255, 0.03);
  --input-bg: #16161a;
  --danger: #ef4444;
}

/* ============================================================================
   LOGIN OVERLAY
   ============================================================================ */

.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  background: radial-gradient(circle at 50% 30%, #1a1033 0%, #0a0a0c 50%);
}

.login-container {
  width: 540px;
  max-width: 90vw;
  padding: 60px 50px;
  background: var(--sidebar-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.login-orb {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--accent-purple-glow) 0%, transparent 70%);
  opacity: 0.5;
  pointer-events: none;
}

.login-logo {
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}

.login-logo-img {
  height: 40px;
  width: auto;
  filter: brightness(0) invert(1);
}

.login-title {
  font-size: 1.5rem;
  color: var(--text-main);
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 30px;
  position: relative;
  z-index: 1;
}

.login-field {
  display: flex;
  align-items: center;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0 15px;
  margin-bottom: 14px;
  transition: border-color 0.2s;
}

.login-field:focus-within {
  border-color: var(--accent-purple);
}

.login-field i {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-right: 12px;
}

.login-field input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.95rem;
  padding: 14px 0;
}

.login-field input::placeholder {
  color: var(--text-dim);
}

.login-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--danger);
  font-size: 0.85rem;
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent-purple);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.login-btn:hover {
  background: #7c3aed;
  transform: translateY(-1px);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.login-footer {
  margin-top: 25px;
  font-size: 0.75rem;
  color: var(--text-dim);
  position: relative;
  z-index: 1;
}

/* Logout Button */
.logout-btn {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  color: var(--danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  margin-top: 8px;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

.app-container {
  display: flex;
  width: 100%;
  height: 100%;
}

/* ============================================================================
   SIDEBAR
   ============================================================================ */

.sidebar {
  width: 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition:
    width 0.3s ease,
    transform 0.3s ease;
}

.sidebar.collapsed {
  width: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 15px;
  display: flex;
  justify-content: space-between; /* This spaces out Icon, Logo, and Buttons */
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-branding {
  display: contents; /* Allows children to be part of the header flexbox */
}

.sidebar-branding i.chat-icon {
  font-size: 1.2rem;
  color: #ffffff;
  width: 24px; /* Fixed width to balance the layout */
}

.sidebar-logo {
  height: 28px;
  width: auto;
  filter: brightness(0) invert(1);
}




/* Hide header logo when sidebar is open */
.sidebar:not(.collapsed) ~ .main-content .chat-header .model-selector {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-15px);
}





.new-chat-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-purple);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.new-chat-btn:hover {
  background: #7c3aed;
  transform: scale(1.05);
}

.header-btns {
  display: flex;
  gap: 8px;
  align-items: center;
}

.close-sidebar-mobile {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.close-sidebar-mobile:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  transform: scale(1.05);
}

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.session-item {
  padding: 12px 15px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  transition: all 0.2s;
}

.session-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.session-item.active {
  background: var(--accent-purple-glow);
  border: 1px solid var(--accent-purple);
}

.session-info {
  flex: 1;
  overflow: hidden;
}

.session-title {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 3px;
}

.session-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 5px;
  transition: all 0.2s;
}

.session-item:hover .session-delete,
.session-item.active .session-delete {
  opacity: 1;
}

@media (max-width: 768px) {
  .session-delete {
    opacity: 1; /* Always show delete on mobile/touch devices */
  }
}

.session-delete:hover {
  color: var(--danger);
}

.sidebar-footer {
  padding: 15px;
  border-top: 1px solid var(--border-color);
}

.cache-info-btn {
  width: 100%;
  padding: 10px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.cache-info-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

/* ============================================================================
   MAIN CONTENT
   ============================================================================ */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: radial-gradient(circle at 50% 10%, #1a1033 0%, #0a0a0c 40%);
  min-width: 0; /* Important for flex items with wide children */
  overflow: hidden; /* Prevent horizontal scroll on desktop */
}

.chat-header {
  height: 70px;
  padding: 0 20px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
}

.toggle-sidebar-btn {
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.toggle-sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Hide toggle button when sidebar is OPEN (Desktop & Mobile) */
.sidebar:not(.collapsed) ~ .main-content .toggle-sidebar-btn {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s, visibility 0.2s;
}

.model-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: transparent;
  position: relative;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-logo {
  height: 30px; /* Reduced as requested */
  width: auto;
  filter: brightness(0) invert(1);
  display: block;
  transition: transform 0.3s ease;
}


.model-selector:hover .nav-logo {
  transform: scale(1.15);
}















.welcome-logo {
  height: 100px;
  width: auto;
  margin-bottom: 25px;
  filter: brightness(0) invert(1);
}

.header-actions {
  display: flex;
  gap: 8px;
  margin-left: auto; /* Push to far right */
}

.btn-secondary {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  cursor: pointer;
}

.btn-secondary:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.3);
  color: var(--text-main);
  transform: scale(1.05);
}

.btn-secondary span {
  display: none; /* Force minimal icons-only on desktop too for unique look */
}

.btn-secondary {
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* ============================================================================
   CHAT DISPLAY
   ============================================================================ */

.chat-display {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: transparent;
}

.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.welcome-orb {
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  border-radius: 50%;
  filter: blur(25px);
  opacity: 0.8;
  margin-bottom: 30px;
  animation: pulse 3s infinite alternate;
  box-shadow: 0 0 40px var(--accent-purple-glow);
}

@keyframes pulse {
  from {
    transform: scale(0.9);
    opacity: 0.6;
  }

  to {
    transform: scale(1.1);
    opacity: 1;
  }
}

.welcome-screen h1 {
  font-size: 2.5rem;
  margin-bottom: 15px;
  letter-spacing: -1px;
}

.welcome-subtitle {
  color: var(--text-dim);
  font-size: 1rem;
}

/* ============================================================================
   MESSAGES
   ============================================================================ */

.message {
  max-width: 65%; /* Reduced for better desktop hierarchy */
  padding: 18px 22px; /* Slightly more padding for premium feel */
  border-radius: 18px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: normal;
  animation: fadeIn 0.3s ease-out;
  position: relative;
  font-size: 0.95rem;
  margin-bottom: 24px;
  display: block; 
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }

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

.message.bot {
  align-self: flex-start;
  background-color: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
  margin-right: 20px; /* Leave space on the right */
  width: fit-content;
  min-width: 200px;
}



.message.user {
  align-self: flex-end;
  background: var(--accent-purple);
  color: white;
  border-bottom-right-radius: 4px;
  margin-left: auto;
  width: fit-content; /* Make bubble only as wide as the text */
}

/* ============================================================================
   STREAMING STATUS
   ============================================================================ */

.stream-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: statusPulse 1.5s infinite;
}

.status-dot.active {
  background: var(--accent-purple);
}

.status-dot.cached {
  background: var(--accent-green);
  animation: none;
}

@keyframes statusPulse {
  0%,
  100% {
    opacity: 0.4;
  }

  50% {
    opacity: 1;
  }
}

.stream-content {
  min-height: 20px;
}

.stopped-indicator {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 10px;
  font-style: italic;
}

/* ============================================================================
   TYPING INDICATOR
   ============================================================================ */

.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 10px 0;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-purple);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

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

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

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

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(-8px);
  }
}

/* ============================================================================
   TABLES IN MESSAGES
   ============================================================================ */

.message table {
  width: 100%;
  border-collapse: collapse;
  margin: 5px 0;
  font-size: 0.85rem;
  table-layout: auto;
}

.message th,
.message td {
  padding: 12px 14px;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.1);
  vertical-align: top;
}

.message th {
  background: rgba(139, 92, 246, 0.2);
  font-weight: 600;
  white-space: nowrap; /* Prevent header squashing */
  color: #fff;
}

.message td {
  color: #e2e8f0;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word; /* Safe breaking */
}

.message tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.table-wrapper {
  overflow-x: auto;
  margin: 15px 0;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 100%;
  display: block;
}

.message p, .message li {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* ============================================================================
   INPUT AREA
   ============================================================================ */

.chat-input-container {
  padding: 20px 40px 30px;
}

.input-wrapper {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 12px;
}

/* Constrain width on Desktop for minimal look */
@media (min-width: 1025px) {
  .input-wrapper {
    width: 65%; /* Reduced from 75% for more focus */
    margin: 0 auto;
  }
}

.input-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-wrapper input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
  padding: 8px 12px;
}

.input-wrapper input::placeholder {
  color: var(--text-dim);
}

.input-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-purple);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.send-btn:hover {
  background: #7c3aed;
  transform: scale(1.05);
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px 0;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.powered-by {
  text-align: center;
  margin-top: 15px;
  font-size: 0.7rem;
  color: var(--text-dim);
  opacity: 0.4;
  font-weight: 500;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}



.cache-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--accent-green);
}

.session-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
}

.session-indicator i {
  font-size: 6px;
  color: var(--accent-green);
}

/* ============================================================================
   MODAL
   ============================================================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000; /* Higher than sidebar (9999) */
}

.modal-content {
  background: var(--sidebar-bg);
  border-radius: 20px;
  width: 90%;
  max-width: 500px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-note {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 15px;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
  border-radius: 8px;
  border-left: 2px solid var(--accent-purple);
}

.modal-header {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.stat-item:last-child {
  border-bottom: none;
}

.stat-label {
  color: var(--text-dim);
}

.stat-value {
  font-weight: 600;
}

.modal-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
}

.btn-danger {
  width: 100%;
  padding: 12px;
  background: var(--danger);
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: #dc2626;
}

/* ============================================================================
   MARKDOWN STYLES
   ============================================================================ */

.message h1,
.message h2,
.message h3 {
  margin: 1.2rem 0 0.8rem;
  font-weight: 700;
  line-height: 1.3;
}

.message h1 { font-size: 1.35rem; }
.message h2 { font-size: 1.2rem; }
.message h3 { font-size: 1.05rem; }

.message p {
  margin: 0.8rem 0;
  color: var(--text-main);
  opacity: 0.95;
}

.message ul,
.message ol {
  margin: 0.8rem 0;
  padding-left: 1.5rem;
}

.message li {
  margin: 0.4rem 0;
  line-height: 1.5;
}

/* Bullet markers customization */
.message ul > li {
  list-style-type: disc;
}

.message ul ul {
  margin: 0.3rem 0;
  list-style-type: circle;
}

.message code {
  background: rgba(139, 92, 246, 0.15);
  color: #e2e8f0;
  padding: 0.2rem 0.5rem;
  margin: 0 3px; /* Add spacing between sticky clips */
  border-radius: 6px;
  display: inline-block; /* Helps with spacing and wrapping */
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.88em;
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.message pre {
  background: #0d0d0f;
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1.2rem;
  border-radius: 12px;
  overflow-x: auto;
  margin: 1rem 0;
}

.message pre code {
  background: none;
  padding: 0;
}

.message strong {
  color: var(--accent-purple);
}

.message a {
  color: var(--accent-purple);
  text-decoration: none;
}

.message a:hover {
  text-decoration: underline;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

/* Tablet & Mobile (Up to 768px) */
/* ============================================================================
   RESPONSIVE DESIGN SYSTEM
   ============================================================================ */

/* 1. Large Screens (max-width: 1440px) */
@media (max-width: 1440px) {
  .chat-display {
    padding: 30px 60px;
  }
}

/* 2. Small Desktop / Laptop (max-width: 1024px) */
@media (max-width: 1024px) {
  .sidebar {
    width: 260px;
  }

  .chat-display {
    padding: 25px 30px;
  }

  .message {
    max-width: 90%;
  }
}

/* 3. Tablets (max-width: 768px) */
@media (max-width: 768px) {
  body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .app-container {
    position: relative;
    overflow: hidden;
  }

  /* Sidebar transformation for mobile - Start Hidden */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 9999;
    width: min(300px, 85vw);
    background: var(--sidebar-bg);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    transform: translateX(0); /* Base state is visible if NO collapsed class */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Show sidebar when it's NOT collapsed */
  .sidebar:not(.collapsed) {
    transform: translateX(0);
  }

  /* When collapsed, hide off-screen */
  .sidebar.collapsed {
    transform: translateX(-100%);
    box-shadow: none;
  }

  /* Overlay Visibility */
  .sidebar-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  /* Mobile Close Button Settings */
  .close-sidebar-mobile {
    display: flex !important;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color) !important;
    background: rgba(255, 255, 255, 0.05) !important;
    color: var(--text-main) !important;
  }

  /* Main Content Adjustments */
  .main-content {
    width: 100%;
  }

  .chat-header {
    height: 60px;
    padding: 0 15px;
  }

  .chat-display {
    padding: 20px 15px;
  }

  .chat-input-container {
    padding: 10px 15px 20px;
  }

  .message {
    max-width: 95%;
    padding: 12px 16px;
  }

  .welcome-screen h1 {
    font-size: 2rem;
  }

  .welcome-orb {
    width: 80px;
    height: 80px;
    filter: blur(15px);
    opacity: 0.9;
  }
}

/* 4. Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
  .sidebar-header .header-btns {
    display: flex;
    gap: 6px;
    align-items: center;
  }

  .chat-header {
    padding: 0 10px;
    gap: 10px;
    height: 60px;
  }

  .chat-header {
    padding: 0 6px;
    gap: 5px;
  }

  .model-selector {
    position: relative;
    left: 0;
    transform: none;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
  }

  .nav-logo {
    height: 24px; /* Even smaller for mobile */
    filter: brightness(0) invert(1);
  }

  .header-actions {
    gap: 4px;
  }

  .btn-secondary span {
    display: none;
  }

  .toggle-sidebar-btn {
    width: 38px;
    height: 38px;
  }



  .btn-secondary span {
    display: none;
  }

  .btn-secondary {
    padding: 0;
    width: 38px;
    height: 38px;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
  }

  .header-actions {
    gap: 6px;
  }

  .welcome-screen h1 {
    font-size: 1.5rem;
    padding: 0 20px;
  }

  .welcome-orb {
    width: 50px;
    height: 50px;
    margin-bottom: 20px;
  }

  .input-wrapper {
    padding: 6px 10px;
    border-radius: 15px;
  }

  .input-wrapper input {
    font-size: 15px;
    padding: 8px 5px;
  }

  .send-btn {
    width: 38px;
    height: 38px;
  }

  /* Modal responsiveness */
  .modal-content {
    width: 85%; /* More compact */
    max-height: 85vh;
    border-radius: 15px;
  }

  .modal-header {
    padding: 12px 15px; /* Thinner header */
  }

  .modal-body {
    padding: 15px; /* Less space */
  }

  .modal-footer {
    padding: 12px 15px;
    flex-direction: row; /* Buttons side-by-side for less height */
    gap: 8px;
  }

  .btn-danger, .btn-secondary {
    padding: 10px !important;
    font-size: 0.8rem !important;
    min-height: auto !important;
    height: auto !important;
    width: auto !important;
    flex: 1;
  }

  .stat-item {
    font-size: 0.8rem;
    padding: 10px 0;
  }

  .message {
    max-width: 92%; /* Slightly wider for better readability */
    padding: 12px 14px;
    font-size: 0.88rem;
    border-radius: 12px;
  }
  
  .message.bot {
    margin-right: 15px; /* Ensure bubble doesn't hit edge */
  }

  .message .table-wrapper table {
    min-width: 600px; /* More space for tables on tiny phones */
  }
}

/* 5. Ultra Small Screens (max-width: 320px) */
@media (max-width: 320px) {
  .model-selector {
    display: none;
  }
  
  .chat-header {
    justify-content: space-between;
  }
  
  .sidebar-header h2 span {
    display: none; /* Hide 'Chats' text if really small */
  }
}

/* 6. Landscape Orientation on Mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .welcome-orb {
    display: none;
  }
  
  .welcome-screen {
    justify-content: center;
    padding-top: 10px;
  }
  
  .chat-header {
    height: 50px;
  }
}
