:root {
  /* Sampurna Logo Colors */
  --primary-pink: #FF3366;
  --primary-blue: #3D5A99;
  --accent-pink: #FF4D7A;
  --accent-blue: #4B6BB5;
  --dark-bg: #1a1a2e;
  --light-bg: #f8f9fa;
  
  /* Updated color scheme */
  --bg0: #f8f9fa;
  --bg1: #ffe6ed;
  --card: rgba(255, 255, 255, 0.95);
  --border: rgba(61, 90, 153, 0.15);
  --text: #1a1a2e;
  --accent: #FF3366;
  --accent2: #3D5A99;
  --accentSoft: rgba(255, 51, 102, 0.1);
  --pink: #FF3366;
  --blue: #3D5A99;
  --good: #10b981;
  --bad: #ef4444;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --shadow: 0 4px 20px rgba(255, 51, 102, 0.15);
  --radius-lg: 22px;
  --radius-md: 18px;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font);
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

/* ✅ APP - FULL SCREEN */
.app {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: white;
  overflow: hidden;
}

/* ✅ LAYOUT - FULL SCREEN */
.layout {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

/* ⚠️ SIDEBAR - COMPLETELY DESTROYED */
.sidebar,
#sidebar,
aside.sidebar,
[class*="sidebar"],
.sbTop, .sbBrand, .sbLogo, .sbTitle, .sbSub,
.sbIconBtn, .sbSearchWrap, .sbSearch, .sbList,
.q-item, .sbFooter, .sbBtn, .sbHint,
[class*="sb-"], [id*="sb-"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  position: absolute !important;
  pointer-events: none !important;
  z-index: -9999 !important;
}

/* ✅ MAIN CHAT - FULL WIDTH */
.mainChat,
#mainChat {
  flex: 1;
  min-width: 0;
  height: 100% !important;
  display: flex;
  flex-direction: column;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden;
  background: linear-gradient(135deg, #3d0d19, #0f1e3f, #000000);
}

/* ✅ TOPBAR - FULL WIDTH */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: linear-gradient(135deg, #FF3366, #3D5A99);
  color: white;
  flex-shrink: 0;
  width: 100%;
  box-shadow: 0 4px 12px rgba(255, 51, 102, 0.2);
  animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.2);
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.2);
  }
  50% {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(255,255,255,0.4);
  }
}

.title {
  font-weight: 600;
  font-size: 18px;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ✅ TOP ACTIONS CONTAINER */
.topActions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ✅ LOGOUT BUTTON */
#logout {
  padding: 8px 20px !important;
  border-radius: 40px !important;
  border: 1px solid rgba(255,255,255,0.2) !important;
  background: rgba(255,255,255,0.1) !important;
  color: white !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  display: inline-flex;
  visibility: visible;
  opacity: 1 !important;
  position: relative !important;
  width: auto !important;
  height: auto !important;
  pointer-events: auto !important;
  z-index: 9999 !important;
  text-decoration: none !important;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

/* ✅ SWITCH CHATBOT BUTTON */
#switchChatbot {
  padding: 8px 20px !important;
  border-radius: 40px !important;
  border: 1px solid rgba(255,255,255,0.2) !important;
  background: rgba(255,255,255,0.1) !important;
  color: white !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  display: inline-flex;
  visibility: visible;
  opacity: 1 !important;
  position: relative !important;
  width: auto !important;
  height: auto !important;
  pointer-events: auto !important;
  z-index: 9999 !important;
  text-decoration: none !important;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

/* JS দিয়ে hide করার জন্য — CSS override করবে */
#logout.hidden-by-js,
#switchChatbot.hidden-by-js {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#logout:hover,
#switchChatbot:hover {
  background: rgba(255, 51, 102, 0.2) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 12px rgba(255, 51, 102, 0.3);
  border-color: rgba(255,255,255,0.4) !important;
}

#logout:active,
#switchChatbot:active {
  transform: translateY(0px) !important;
}

/* ⚠️ ONLY HIDE TOGGLE/HISTORY BUTTONS - NOT LOGOUT OR SWITCH */
#toggleSidebar,
.toggleBtn,
button[id*="toggle"]:not(#switchChatbot):not(#logout),
button[class*="toggle"]:not(#switchChatbot):not(#logout),
button[aria-label*="History"],
button[aria-label*="history"],
button[aria-label*="Toggle"],
button[aria-label*="toggle"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  position: absolute !important;
  pointer-events: none !important;
  z-index: -9999 !important;
}

/* ✅ HIDE OTHER UNWANTED ELEMENTS */
.controls,
.left-controls,
.right-controls,
.badge,
#healthText,
#sessionLine,
#sbCollapse,
#sbClear,
#sbSearch,
#sbMeta,
#sbList,
.sbSearchWrap,
.sbFooter {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  position: absolute !important;
  pointer-events: none !important;
}

/* ✅ CHAT SHELL */
.chatShell {
  flex: 1;
  overflow: hidden;
  background: linear-gradient(135deg, #3d0d19, #0f1e3f, #000000);
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* ✅ CHATBOX - FULL WIDTH */
.chatbox {
  height: 100%;
  width: 100% !important;
  max-width: 100% !important;
  padding: 24px 28px 20px 28px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* ✅ MESSAGE BUBBLES */
.row {
  display: flex;
  margin: 16px 0;
  animation: slideUp 0.25s ease;
  width: 100%;
}

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

.row.user {
  justify-content: flex-end;
}

.row.system {
  justify-content: flex-start;
}

.bubble {
  max-width: 80%;
  padding: 12px 18px;
  border-radius: 20px;
  line-height: 1.5;
  font-size: 15px;
  word-break: break-word;
}

.bubble.user {
  background: linear-gradient(135deg, rgba(255, 51, 102, 0.15), rgba(255, 77, 122, 0.12));
  border-radius: 20px 20px 4px 20px;
  color: var(--text);
  border: 1px solid rgba(255, 51, 102, 0.2);
  transition: all 0.3s ease;
  color: white;
}

.bubble.user:hover {
  background: linear-gradient(135deg, rgba(255, 51, 102, 0.2), rgba(255, 77, 122, 0.18));
  box-shadow: 0 4px 12px rgba(255, 51, 102, 0.15);
  transform: translateY(-1px);
}

.bubble.system .systemCard {
  background: linear-gradient(135deg, rgba(118, 56, 143, 0.568), rgba(66, 22, 117, 0.555));
  border-radius: 18px;
  padding: 16px 20px;
  box-shadow: 0 2px 8px rgba(97, 15, 151, 0.671);
  border: 1px solid rgba(184, 59, 144, 0.849);
  color: white;
}

.sysAvatar {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #7251e9;
  border: 1px solid rgba(49, 6, 73, 0.993);
  margin-right: 8px;
  flex-shrink: 0;
}

.sysAvatar svg {
  width: 14px;
  height: 14px;
  fill: rgba(49, 6, 73, 0.993);
}

.meta {
  font-size: 11px;
  color: #d1d7df;
  margin-top: 6px;
  opacity: 0.7;
}

/* ✅ LINKS - PERFECT STYLING */
.systemCard a {
  color: #2563eb !important;
  text-decoration: underline !important;
  font-weight: 500;
  word-break: break-all;
  transition: all 0.2s ease;
  display: inline-block;
  cursor: pointer !important;
}

.systemCard a:hover {
  color: #1d4ed8 !important;
  text-decoration: none !important;
  background: rgba(37, 99, 235, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
  transform: translateY(-1px);
}

/* ✅ GOOGLE DRIVE LINKS - SPECIAL STYLING */
.systemCard a[href*="drive.google.com"],
.systemCard a[href*="docs.google.com"] {
  background: rgba(37, 99, 235, 0.1);
  padding: 4px 12px !important;
  border-radius: 30px !important;
  display: inline-block;
  margin: 4px 0;
  border: 1px solid rgba(37, 99, 235, 0.2);
  font-weight: 500;
  text-decoration: none !important;
}

.systemCard a[href*="drive.google.com"]:hover,
.systemCard a[href*="docs.google.com"]:hover {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.1);
}

/* ✅ EXTERNAL LINK ICON */
.systemCard a[target="_blank"]::after {
  content: " ↗";
  font-size: 12px;
  display: inline-block;
  margin-left: 2px;
}

/* ✅ CODE BLOCKS */
.systemCard code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.9em;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #0f172a;
}

/* ✅ LISTS */
.systemCard ol,
.systemCard ul {
  margin: 12px 0 12px 24px;
  padding-left: 8px;
}

.systemCard li {
  margin: 6px 0;
  line-height: 1.6;
}

/* ✅ THINKING BUBBLE */
.row.thinking {
  justify-content: flex-start;
}

.systemCard.thinkingCard {
  background: linear-gradient(135deg, rgba(255, 51, 102, 0.08), rgba(61, 90, 153, 0.06));
  border: 1px solid rgba(255, 51, 102, 0.2);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

.thinkingText {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #FF3366;
  font-weight: 600;
}

.thinkingDots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.thinkingDots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #FF3366;
  opacity: 0.3;
  animation: thinkingPulse 1.2s infinite;
}

.thinkingDots span:nth-child(2) {
  animation-delay: 0.2s;
}

.thinkingDots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes thinkingPulse {
  0%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* ✅ PARTIAL BUBBLE */
.row.partial {
  justify-content: flex-end;
  opacity: 0.7;
}

.bubble.partial {
  background: #f8fafc;
  border: 1px dashed #94a3b8;
  border-radius: 24px;
  color: #475569;
}

/* ✅ FOOTER - FULL WIDTH */
.footer {
  width: 100%;
  padding: 0 28px 24px 28px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #0b001d, #0f1e3f, #000000);
}

/* ✅ INPUT ROW - FULL WIDTH */
.inputRow {
  display: flex;
  gap: 10px;
  align-items: center;
  background:  linear-gradient(135deg, #770d28, #2c0a64);
  border-radius: 50px;
  padding: 6px 6px 6px 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.04);
  border: 1px solid #e2e8f0;
  width: 100%;
  transition: all 0.2s ease;
}

.inputRow:focus-within {
  box-shadow: 0 6px 24px rgba(255, 51, 102, 0.2);
  border-color: #FF3366;
  transform: translateY(-1px);
}

/* ✅ TEXT INPUT - TAKES ALL SPACE */
.textInput {
  flex: 1;
  border: none;
  padding: 14px 0;
  font-size: 15px;
  background: transparent;
  outline: none;
  min-width: 0;
  width: 100%;
  color: white;
}

.textInput::placeholder {
  color: #ffffff;
  font-weight: normal;
}

/* ✅ ICON BUTTONS */
.iconBtn {
  width: 48px;
  height: 48px;
  border-radius: 24px;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.iconBtn .icon {
  width: 20px;
  height: 20px;
  fill: #FF3366;
  transition: all 0.2s ease;
}

.iconBtn:hover {
  background: #f1f5f9;
}

.iconBtn:hover .icon {
  fill: #FF3366;
}

/* ✅ MIC BUTTON */
.micBtn {
  background: linear-gradient(135deg, #FF3366, #3D5A99);
  box-shadow: 0 4px 12px rgba(255, 51, 102, 0.3);
}

.micBtn .icon {
  fill: white !important;
}

.micBtn:hover {
  transform: scale(1.05);
  background: linear-gradient(135deg, #FF4D7A, #4B6BB5);
  box-shadow: 0 6px 16px rgba(255, 51, 102, 0.4);
}

/* ✅ SEND BUTTON */
.sendBtn {
  background: linear-gradient(135deg, #FF3366, #3D5A99);
  box-shadow: 0 2px 8px rgba(255, 51, 102, 0.25);
}

.sendBtn .icon {
  fill: white !important;
}

.sendBtn:hover {
  transform: scale(1.05);
  background: linear-gradient(135deg, #FF4D7A, #4B6BB5);
  box-shadow: 0 4px 12px rgba(255, 51, 102, 0.35);
}

/* ✅ ATTACH BUTTON */
.attachBtn {
  background: transparent;
}

/* ✅ LISTENING ANIMATION */
@keyframes micPulse {
  0% {
    box-shadow: 0 4px 12px rgba(255, 51, 102, 0.3), 0 0 0 0 rgba(255, 51, 102, 0.5);
  }
  70% {
    box-shadow: 0 4px 12px rgba(255, 51, 102, 0.3), 0 0 0 12px rgba(255, 51, 102, 0);
  }
  100% {
    box-shadow: 0 4px 12px rgba(255, 51, 102, 0.3), 0 0 0 0 rgba(255, 51, 102, 0);
  }
}

.micBtn.listening {
  animation: micPulse 1.5s ease-out infinite;
}

/* ✅ CONNECTING ANIMATION */
@keyframes micConnecting {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.92); }
}

.micBtn.connecting {
  animation: micConnecting 0.8s ease-in-out infinite;
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4) !important;
  cursor: wait !important;
}

/* ✅ IMAGE IN MESSAGE */
.bubble.user.hasImage {
  border-radius: 18px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(255, 51, 102, 0.15), rgba(255, 77, 122, 0.12));
  color: var(--text);
  border: 1px solid rgba(255, 51, 102, 0.2);
  transition: all 0.3s ease;
}

.bubble.user.hasImage img {
  display: block;
  margin: 0;
  border-radius: 12px;
  max-width: 260px;
  max-height: 220px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.2);
  transition: transform 0.2s ease;
}

.bubble.user.hasImage img:hover {
  transform: scale(1.02);
}

.bubble.user.hasImage .imgText {
  margin-top: 10px;
  white-space: pre-wrap;
  color: white;
}

/* ✅ IMAGE PREVIEW */
.imagePreviewHost {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0 0 12px 0;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  width: fit-content;
  animation: slideUp 0.2s ease;
}

.imagePreviewHost img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid #e2e8f0;
}

.imagePreviewName {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.imagePreviewHint {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.imagePreviewX {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: white;
  color: #64748b;
  cursor: pointer;
  display: grid;
  place-items: center;
  margin-left: 8px;
  transition: all 0.2s ease;
}

.imagePreviewX:hover {
  background: #f1f5f9;
  color: #ef4444;
  border-color: #ef4444;
}

/* ===== COMPLETE MOBILE FIX ===== */
@media (max-width: 768px) {
  /* Topbar */
  .topbar {
    padding: 8px 12px !important;
    min-height: auto !important;
    overflow: hidden;
  }
  
  .brand {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
  }
  
  .title {
    font-size: 14px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: none;
    display: block;
  }
  
  /* Hide desktop actions on mobile */
  #topActionsDesktop {
    display: none !important;
  }

  /* Mobile menu button — shrinks to fit content, never grows */
  #mobileMenuBtn {
    flex: 0 0 auto !important;
  }
  
  .topActions {
    gap: 4px !important;
    max-width: 60%;
    display: flex;
    align-items: center;
  }
  
  /* Quota Display - Vertical Stack */
  #quotaDisplay {
    display: flex !important;
    flex-direction: column !important;
    gap: 3px !important;
    padding: 4px 8px !important;
    margin-right: 4px !important;
    background: rgba(255,255,255,0.15);
    border-radius: 14px !important;
    min-width: 65px;
  }
  
  #sttDisplay, #ttsDisplay {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 4px !important;
    padding: 2px 6px !important;
    background: rgba(255,255,255,0.1);
    border-radius: 12px !important;
    width: 100%;
  }
  
  #sttDisplay span:first-child, 
  #ttsDisplay span:first-child {
    font-size: 12px !important;
  }
  
  #sttValue, #ttsValue {
    font-size: 10px !important;
    padding: 2px 6px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    font-weight: 600;
  }
  
  /* Buttons */
  #switchChatbot,
  #logout {
    padding: 5px 10px !important;
    font-size: 11px !important;
    height: 30px !important;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 6px 8px !important;
  }
  
  .brand {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
  }
  
  .title {
    font-size: 12px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: none;
  }
  
  .topActions {
    max-width: 65%;
  }
  
  #quotaDisplay {
    padding: 3px 6px !important;
    min-width: 58px;
  }
  
  #sttDisplay, #ttsDisplay {
    padding: 2px 4px !important;
  }
  
  #sttDisplay span:first-child, 
  #ttsDisplay span:first-child {
    font-size: 11px !important;
  }
  
  #sttValue, #ttsValue {
    font-size: 9px !important;
    padding: 1px 4px;
  }
  
  #switchChatbot,
  #logout {
    padding: 4px 8px !important;
    font-size: 10px !important;
    height: 28px !important;
  }
}

/* ✅ RESPONSIVE */
@media (max-width: 768px) {
  .topbar {
    padding: 12px 20px;
  }

  .chatbox {
    padding: 20px 20px 16px 20px;
  }

  .footer {
    padding: 0 20px 20px 20px;
  }

  .bubble {
    max-width: 85%;
  }

  #switchChatbot,
  #logout {
    padding: 6px 16px !important;
    font-size: 13px !important;
  }
}

@media (max-width: 768px) and (orientation: portrait) {
  .app, .layout, .mainChat {
    height: 100dvh !important; /* dynamic viewport height */
  }
  
  .topbar {
    padding: 8px 16px;
    min-height: 56px;
  }
  
  .title {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
  }
  
  .dot {
    width: 8px;
    height: 8px;
  }
  
  #switchChatbot {
    padding: 5px 10px !important;
    font-size: 12px !important;
    height: 32px !important;
    min-width: auto !important;
  }
  
  #logout {
    padding: 5px 10px !important;
    font-size: 12px !important;
    height: 32px !important;
    min-width: auto !important;
  }
  
  .chatShell {
    height: calc(100dvh - 56px - 80px); /* topbar - footer */
  }
  
  .chatbox {
    padding: 12px 16px;
  }
  
  .bubble {
    max-width: 85%;
    font-size: 14px;
    padding: 10px 14px;
  }
  
  .systemCard {
    padding: 12px 14px;
  }
  
  .footer {
    padding: 8px 16px 12px 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
  }
  
  .inputRow {
    padding: 2px 2px 2px 14px;
    border-radius: 30px;
  }
  
  .textInput {
    padding: 8px 0;
    font-size: 14px;
  }
  
  .iconBtn {
    width: 38px;
    height: 38px;
  }
  
  .iconBtn .icon {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 480px) and (orientation: portrait) {
  .topbar {
    padding: 6px 12px;
  }
  
  .brand {
    gap: 6px;
  }
  
  .title {
    font-size: 13px;
    max-width: 120px;
  }
  
  .dot {
    width: 6px;
    height: 6px;
  }
  
  .topActions {
    gap: 4px;
  }
  
  #switchChatbot {
    padding: 4px 8px !important;
    font-size: 11px !important;
    height: 28px !important;
  }
  
  #logout {
    padding: 4px 8px !important;
    font-size: 11px !important;
    height: 28px !important;
  }
  
  .chatShell {
    height: calc(100dvh - 50px - 70px);
  }
  
  .chatbox {
    padding: 10px 12px;
  }
  
  .bubble {
    max-width: 90%;
    font-size: 13px;
    padding: 8px 12px;
  }
  
  .footer {
    padding: 6px 12px 10px 12px;
  }
  
  .inputRow {
    padding: 2px 2px 2px 10px;
  }
  
  .textInput {
    padding: 6px 0;
    font-size: 13px;
  }
  
  .textInput::placeholder {
    font-size: 12px;
  }
  
  .iconBtn {
    width: 34px;
    height: 34px;
  }
  
  .iconBtn .icon {
    width: 16px;
    height: 16px;
  }
}
@media (max-width: 900px) and (orientation: landscape) {
  .topbar {
    padding: 4px 16px;
    min-height: 48px;
  }
  
  .chatShell {
    height: calc(100vh - 48px - 70px);
  }
  
  .bubble {
    max-width: 60%;
  }
  
  .footer {
    padding: 4px 16px 8px 16px;
  }
  
  .inputRow {
    padding: 2px 2px 2px 14px;
  }
  
  .textInput {
    padding: 6px 0;
  }
  
  .iconBtn {
    width: 36px;
    height: 36px;
  }
}


/* ✅ SCROLLBAR STYLING */
.chatbox::-webkit-scrollbar {
  width: 6px;
}

.chatbox::-webkit-scrollbar-track {
  background: transparent;
}

.chatbox::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

.chatbox::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ===== MOBILE CHATBOX ALIGNMENT FIX ===== */
@media (max-width: 768px) {
  .chatbox {
    padding: 12px 12px !important;
  }
  
  .bubble {
    max-width: 85%;
  }
  
  .row.user {
    justify-content: flex-end !important;
  }
  
  .row.system {
    justify-content: flex-start !important;
  }
  
  .bubble.user {
    margin-right: 0 !important;
    margin-left: auto !important;
  }
  
  .bubble.system {
    margin-left: 0 !important;
    margin-right: auto !important;
  }
}

@media (max-width: 480px) {
  .chatbox {
    padding: 10px 8px !important;
  }
  
  .bubble {
    max-width: 90%;
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .systemCard {
    padding: 10px 12px !important;
  }
  
  .meta {
    font-size: 9px !important;
  }
}

/* ===== EXTRA SMALL DEVICES (NOKIA, 240-360px WIDTH) ===== */
@media (max-width: 360px) {
  /* Topbar extreme small */
  .topbar {
    padding: 4px 6px !important;
    min-height: 40px !important;
  }
  
  .brand {
    flex: 1 1 0;
    max-width: none !important;
    gap: 2px !important;
    overflow: hidden !important;
    min-width: 0;
  }
  
  .dot {
    width: 4px !important;
    height: 4px !important;
    display: none !important;
  }
  
  .title {
    font-size: 11px !important;
    max-width: none !important;
    white-space: nowrap;
    overflow: hidden !important;
    text-overflow: ellipsis;
  }
  
  .topActions {
    max-width: 70% !important;
    gap: 2px !important;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
  
  /* Quota display - super compact */
  #quotaDisplay {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    padding: 2px 4px !important;
    margin-right: 2px !important;
    border-radius: 8px !important;
    min-width: 45px !important;
    background: rgba(255,255,255,0.12);
  }
  
  #sttDisplay, #ttsDisplay {
    padding: 1px 3px !important;
    gap: 2px !important;
    border-radius: 6px !important;
    font-size: 8px !important;
  }
  
  #sttDisplay span:first-child, 
  #ttsDisplay span:first-child {
    font-size: 8px !important;
  }
  
  #sttValue, #ttsValue {
    font-size: 7px !important;
    padding: 1px 3px !important;
    border-radius: 4px !important;
    background: rgba(0,0,0,0.3);
  }
  
  /* Buttons - smallest possible */
  #switchChatbot,
  #logout {
    padding: 3px 5px !important;
    font-size: 9px !important;
    height: 24px !important;
    border-radius: 20px !important;
    min-width: 40px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50px;
  }
  
  #switchChatbot {
    max-width: 45px;
  }
  
  #logout {
    max-width: 40px;
  }
  
  /* Chatbox adjustments */
  .chatbox {
    padding: 6px 4px !important;
  }
  
  .bubble {
    max-width: 95% !important;
    padding: 6px 8px !important;
    font-size: 11px !important;
  }
  
  .systemCard {
    padding: 6px 8px !important;
  }
  
  .sysAvatar {
    width: 16px !important;
    height: 16px !important;
  }
  
  .meta {
    font-size: 7px !important;
    margin-top: 2px !important;
  }
  
  /* Footer */
  .footer {
    padding: 2px 6px 6px 6px !important;
  }
  
  .inputRow {
    padding: 2px 2px 2px 8px !important;
    gap: 4px !important;
    border-radius: 40px !important;
  }
  
  .textInput {
    padding: 4px 0 !important;
    font-size: 11px !important;
  }
  
  .textInput::placeholder {
    font-size: 10px !important;
  }
  
  .iconBtn {
    width: 28px !important;
    height: 28px !important;
  }
  
  .iconBtn .icon {
    width: 14px !important;
    height: 14px !important;
  }
  
  /* Thinking indicator */
  .thinkingDots span {
    width: 4px !important;
    height: 4px !important;
  }
  
  .thinkingText {
    font-size: 11px !important;
    gap: 4px !important;
  }
  
  /* Image preview */
  .imagePreviewHost {
    padding: 4px 8px !important;
    gap: 6px !important;
  }
  
  .imagePreviewHost img {
    width: 30px !important;
    height: 30px !important;
  }
  
  .imagePreviewName {
    font-size: 9px !important;
    max-width: 120px;
  }
  
  .imagePreviewHint {
    font-size: 8px !important;
  }
  
  .imagePreviewX {
    width: 20px !important;
    height: 20px !important;
    font-size: 10px !important;
  }
}

/* ===== SUPER EXTREME (240px and below) ===== */
@media (max-width: 280px) {
  .topbar {
    padding: 2px 4px !important;
  }
  
  .brand {
    max-width: 25% !important;
  }
  
  .title {
    font-size: 8px !important;
    max-width: 50px !important;
  }
  
  .topActions {
    max-width: 75% !important;
    gap: 1px !important;
  }
  
  #quotaDisplay {
    min-width: 38px !important;
    padding: 1px 2px !important;
  }
  
  #sttDisplay, #ttsDisplay {
    padding: 1px 2px !important;
  }
  
  #sttValue, #ttsValue {
    font-size: 6px !important;
    padding: 1px 2px !important;
  }
  
  #switchChatbot,
  #logout {
    padding: 2px 3px !important;
    font-size: 7px !important;
    height: 20px !important;
    min-width: 30px !important;
    max-width: 35px;
  }
  
  .bubble {
    padding: 4px 6px !important;
    font-size: 9px !important;
  }
  
  .systemCard {
    padding: 4px 6px !important;
  }
  
  .meta {
    font-size: 6px !important;
  }
  
  .textInput {
    font-size: 9px !important;
  }
  
  .textInput::placeholder {
    font-size: 8px !important;
  }
  
  .iconBtn {
    width: 24px !important;
    height: 24px !important;
  }
  
  .iconBtn .icon {
    width: 12px !important;
    height: 12px !important;
  }
}

/* For 280px and below */
@media (max-width: 280px) {
  #switchChatbot::before {
    content: "⇄";
    margin-right: 0;
  }
  
  #switchChatbot span,
  #switchChatbot .text {
    display: none !important;
  }
  
  #switchChatbot {
    font-size: 0 !important; /* text hide */
    padding: 4px !important;
    width: 30px !important;
    min-width: 30px !important;
  }
  
  #switchChatbot::after {
    content: "⇄";
    font-size: 14px !important;
    display: inline-block;
  }
  
  #logout::before {
    content: "➜";
    margin-right: 0;
  }
  
  #logout span,
  #logout .text {
    display: none !important;
  }
  
  #logout {
    font-size: 0 !important;
    padding: 4px !important;
    width: 30px !important;
    min-width: 30px !important;
  }
  
  #logout::after {
    content: "➜";
    font-size: 14px !important;
    display: inline-block;
  }
}

/* ===== SAMSUNG S8+ (360×740) & IPHONE SE (375×667) ===== */
@media (min-width: 360px) and (max-width: 380px) {
  
  /* ---------- TOPBAR ---------- */
  .topbar {
    padding: 6px 10px !important;
    min-height: 48px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  
  .brand {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    max-width: 35% !important;
    flex-shrink: 0 !important;
  }
  
  .dot {
    width: 6px !important;
    height: 6px !important;
    flex-shrink: 0 !important;
  }
  
  .title {
    font-size: 12px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 110px !important;
  }
  
  .topActions {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    max-width: 65% !important;
    justify-content: flex-end !important;
  }
  
  /* ---------- QUOTA DISPLAY (COMPACT) ---------- */
  #quotaDisplay {
    display: flex !important;
    flex-direction: column !important;  /* vertical stack */
    gap: 3px !important;
    padding: 4px 8px !important;
    background: rgba(255,255,255,0.15) !important;
    border-radius: 14px !important;
    border: 1px solid rgba(255,255,255,0.2) !important;
    margin-right: 4px !important;
    min-width: 65px !important;
    backdrop-filter: blur(4px) !important;
  }
  
  #sttDisplay, #ttsDisplay {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 4px !important;
    padding: 2px 6px !important;
    background: rgba(255,255,255,0.1) !important;
    border-radius: 12px !important;
    width: 100% !important;
  }
  
  #sttDisplay span:first-child, 
  #ttsDisplay span:first-child {
    font-size: 12px !important;
  }
  
  #sttValue, #ttsValue {
    font-size: 10px !important;
    font-weight: 600 !important;
    background: rgba(0,0,0,0.3) !important;
    padding: 2px 6px !important;
    border-radius: 10px !important;
  }
  
  /* Low quota warning */
  #sttValue[data-low="true"], 
  #ttsValue[data-low="true"] {
    color: #ff9999 !important;
    background: rgba(255,0,0,0.2) !important;
  }
  
  /* ---------- BUTTONS ---------- */
  #switchChatbot,
  #logout {
    padding: 5px 10px !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    height: 32px !important;
    min-width: auto !important;
    white-space: nowrap !important;
    border-radius: 30px !important;
    background: rgba(255,255,255,0.1) !important;
    border: 1px solid rgba(255,255,255,0.2) !important;
    color: white !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  #switchChatbot {
    padding: 5px 8px !important;
  }
  
  #logout {
    padding: 5px 10px !important;
  }
  
  /* ---------- CHATBOX ---------- */
  .chatbox {
    padding: 10px 8px !important;
  }
  
  .row {
    margin: 10px 0 !important;
  }
  
  .bubble {
    max-width: 85% !important;
    padding: 10px 14px !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
  }
  
  /* User bubble - right side */
  .row.user {
    justify-content: flex-end !important;
  }
  
  .row.user .bubble {
    margin-left: auto !important;
    margin-right: 0 !important;
    background: linear-gradient(135deg, rgba(255,51,102,0.2), rgba(255,77,122,0.15)) !important;
  }
  
  /* System bubble - left side */
  .row.system {
    justify-content: flex-start !important;
  }
  
  .row.system .bubble {
    margin-left: 0 !important;
    margin-right: auto !important;
  }
  
  .systemCard {
    padding: 12px 16px !important;
    display: flex !important;
    gap: 8px !important;
    align-items: flex-start !important;
  }
  
  .sysAvatar {
    width: 22px !important;
    height: 22px !important;
    margin-right: 6px !important;
  }
  
  .sysAvatar svg {
    width: 12px !important;
    height: 12px !important;
  }
  
  .meta {
    font-size: 9px !important;
    margin-top: 4px !important;
    opacity: 0.6 !important;
  }
  
  /* ---------- FOOTER ---------- */
  .footer {
    padding: 0 8px 12px 8px !important;
  }
  
  .inputRow {
    padding: 3px 3px 3px 14px !important;
    gap: 6px !important;
    border-radius: 40px !important;
    background: linear-gradient(135deg, #770d28, #2c0a64) !important;
  }
  
  .textInput {
    padding: 8px 0 !important;
    font-size: 13px !important;
  }
  
  .textInput::placeholder {
    font-size: 12px !important;
    color: rgba(255,255,255,0.6) !important;
  }
  
  .iconBtn {
    width: 36px !important;
    height: 36px !important;
  }
  
  .iconBtn .icon {
    width: 18px !important;
    height: 18px !important;
  }
  
  .micBtn {
    background: linear-gradient(135deg, #FF3366, #3D5A99) !important;
  }
  
  .sendBtn {
    background: linear-gradient(135deg, #FF3366, #3D5A99) !important;
  }
  
  /* ---------- THINKING INDICATOR ---------- */
  .thinkingDots span {
    width: 5px !important;
    height: 5px !important;
  }
  
  .thinkingText {
    font-size: 13px !important;
    gap: 6px !important;
  }
  
  /* ---------- IMAGE PREVIEW ---------- */
  .imagePreviewHost {
    padding: 6px 10px !important;
    margin: 0 0 8px 0 !important;
    gap: 8px !important;
    border-radius: 16px !important;
  }
  
  .imagePreviewHost img {
    width: 36px !important;
    height: 36px !important;
  }
  
  .imagePreviewName {
    font-size: 11px !important;
    max-width: 160px !important;
  }
  
  .imagePreviewHint {
    font-size: 9px !important;
  }
  
  .imagePreviewX {
    width: 24px !important;
    height: 24px !important;
    font-size: 12px !important;
  }
}

/* ===== TOPBAR 1 LINE + QUOTA BREAK + AUTO SCALING ===== */

/* Default (360-380px) */
@media (min-width: 360px) and (max-width: 380px) {
  
  /* Topbar ek line e */
  .topbar {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 6px 8px !important;
    min-height: 48px !important;
    background: linear-gradient(135deg, #FF3366, #3D5A99) !important;
    width: 100% !important;
    box-sizing: border-box !important;
    flex-wrap: nowrap !important; /* No wrap */
  }
  
  /* Brand (dot + title) */
  .brand {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    flex-shrink: 0 !important;
    max-width: 25% !important;
    min-width: 70px !important;
  }
  
  .dot {
    width: 5px !important;
    height: 5px !important;
    flex-shrink: 0 !important;
  }
  
  .title {
    font-size: 11px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 60px !important;
  }
  
  /* Top actions container */
  .topActions {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    flex-shrink: 0 !important;
    max-width: 75% !important;
    justify-content: flex-end !important;
  }
  
  /* QUOTA BREAK - vertical stack */
  #quotaDisplay {
    display: flex !important;
    flex-direction: column !important;  /* vertical stack */
    gap: 2px !important;
    padding: 3px 5px !important;
    background: rgba(255,255,255,0.15) !important;
    border-radius: 12px !important;
    min-width: 55px !important;
    max-width: 60px !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
  }
  
  #sttDisplay, #ttsDisplay {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    padding: 2px 5px !important;
    background: rgba(255,255,255,0.1) !important;
    border-radius: 10px !important;
    font-size: 9px !important;
  }
  
  #sttDisplay span:first-child, 
  #ttsDisplay span:first-child {
    font-size: 10px !important;
  }
  
  #sttValue, #ttsValue {
    font-size: 8px !important;
    font-weight: 700 !important;
    background: rgba(0,0,0,0.3) !important;
    padding: 1px 4px !important;
    border-radius: 8px !important;
    min-width: 28px !important;
    text-align: center !important;
  }
  
  /* Buttons */
  #switchChatbot, #logout {
    padding: 4px 6px !important;
    font-size: 10px !important;
    height: 28px !important;
    border-radius: 20px !important;
    background: rgba(255,255,255,0.1) !important;
    border: 1px solid rgba(255,255,255,0.2) !important;
    color: white !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
  
  #switchChatbot {
    padding: 4px 5px !important;
  }
  
  #logout {
    padding: 4px 8px !important;
  }
}

/* Smaller screens (340-359px) */
@media (min-width: 340px) and (max-width: 359px) {
  
  .topbar {
    padding: 5px 6px !important;
    min-height: 44px !important;
  }
  
  .brand {
    min-width: 60px !important;
  }
  
  .dot {
    width: 4px !important;
    height: 4px !important;
  }
  
  .title {
    font-size: 10px !important;
    max-width: 50px !important;
  }
  
  #quotaDisplay {
    min-width: 50px !important;
    padding: 2px 4px !important;
  }
  
  #sttDisplay, #ttsDisplay {
    padding: 1px 4px !important;
    font-size: 8px !important;
  }
  
  #sttDisplay span:first-child, 
  #ttsDisplay span:first-child {
    font-size: 9px !important;
  }
  
  #sttValue, #ttsValue {
    font-size: 7px !important;
    min-width: 24px !important;
    padding: 1px 3px !important;
  }
  
  #switchChatbot, #logout {
    padding: 3px 5px !important;
    font-size: 9px !important;
    height: 26px !important;
  }
}

/* Very small screens (320-339px) */
@media (min-width: 320px) and (max-width: 339px) {
  
  .topbar {
    padding: 4px 5px !important;
    min-height: 42px !important;
  }
  
  .brand {
    min-width: 55px !important;
    gap: 3px !important;
  }
  
  .dot {
    width: 3px !important;
    height: 3px !important;
  }
  
  .title {
    font-size: 9px !important;
    max-width: 45px !important;
  }
  
  #quotaDisplay {
    min-width: 45px !important;
    padding: 2px 3px !important;
    gap: 1px !important;
  }
  
  #sttDisplay, #ttsDisplay {
    padding: 1px 3px !important;
    font-size: 7px !important;
  }
  
  #sttDisplay span:first-child, 
  #ttsDisplay span:first-child {
    font-size: 8px !important;
  }
  
  #sttValue, #ttsValue {
    font-size: 6px !important;
    min-width: 22px !important;
    padding: 1px 2px !important;
  }
  
  #switchChatbot, #logout {
    padding: 3px 4px !important;
    font-size: 8px !important;
    height: 24px !important;
  }
  
  #switchChatbot {
    max-width: 45px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}

/* Ultra small (below 320px) - Nokia etc */
@media (max-width: 319px) {
  
  .topbar {
    padding: 3px 4px !important;
    min-height: 38px !important;
  }
  
  .brand {
    min-width: 45px !important;
    gap: 2px !important;
  }
  
  .dot {
    display: none !important; /* Dot hide */
  }
  
  .title {
    font-size: 8px !important;
    max-width: 40px !important;
  }
  
  #quotaDisplay {
    min-width: 40px !important;
    padding: 1px 2px !important;
    gap: 1px !important;
    border-radius: 8px !important;
  }
  
  #sttDisplay, #ttsDisplay {
    padding: 1px 2px !important;
    font-size: 6px !important;
    border-radius: 6px !important;
  }
  
  #sttDisplay span:first-child, 
  #ttsDisplay span:first-child {
    font-size: 7px !important;
  }
  
  #sttValue, #ttsValue {
    font-size: 5px !important;
    min-width: 18px !important;
    padding: 1px 2px !important;
    border-radius: 4px !important;
  }
  
  #switchChatbot, #logout {
    padding: 2px 3px !important;
    font-size: 7px !important;
    height: 22px !important;
    border-radius: 12px !important;
  }
  
  #switchChatbot {
    max-width: 38px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  
  #logout {
    max-width: 35px !important;
  }
}

/* Ultra small - button text shorten */
@media (max-width: 300px) {
  
  #switchChatbot span,
  #switchChatbot .text {
    display: none !important;
  }
  
  #switchChatbot::before {
    content: "⇄" !important;
    font-size: 14px !important;
  }
  
  #logout span,
  #logout .text {
    display: none !important;
  }
  
  #logout::before {
    content: "➜" !important;
    font-size: 14px !important;
  }
  
  #switchChatbot, #logout {
    width: 32px !important;
    min-width: 32px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
}
/* ✅ CHAT LINK - compact on mobile */
@media (max-width: 600px) {
  .chatLink {
    font-size: 0.85em;
    word-break: break-all;
  }
  .systemCard a[href*="drive.google.com"],
  .systemCard a[href*="docs.google.com"] {
    font-size: 0.82em;
    padding: 3px 8px !important;
  }
}

/* ✅ RELATED QUESTIONS - full width on mobile */
@media (max-width: 600px) {
  .relatedQ {
    font-size: 0.78em;
    padding: 6px 10px;
    width: 100%;
    max-width: 100%;
  }
}

/* ✅ MOBILE QUOTA SLOT */
#mobileQuotaSlot {
  display: flex;
  align-items: center;
}

#mobileQuotaDisplay {
  flex-shrink: 0;
}

/* ── Feedback Buttons (👍/👎 below bot responses) ─────────── */
.feedback-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  margin-left: 44px;          /* align with systemCard content (avatar 24 + margin 20) */
  opacity: 0;
  animation: fbFadeIn .3s ease .4s forwards;
}
@keyframes fbFadeIn { to { opacity: 1; } }

.fb-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 14px;
  cursor: pointer;
  color: rgba(255,255,255,0.45);
  transition: all .2s ease;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
}
.fb-btn:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.8);
  border-color: rgba(255,255,255,0.25);
}
.fb-btn.voted {
  pointer-events: none;
}
.fb-btn.voted.up {
  color: #22c55e;
  border-color: rgba(34,197,94,0.4);
  background: rgba(34,197,94,0.1);
}
.fb-btn.voted.down {
  color: #ef4444;
  border-color: rgba(239,68,68,0.4);
  background: rgba(239,68,68,0.1);
}
.fb-btn.dimmed {
  opacity: 0.25;
  pointer-events: none;
}
.fb-thanked {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  margin-left: 6px;
}