/* ==========================================================================
   Reset & Base
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Define theme variables */
:root {
  --bg-primary: linear-gradient(to bottom, #05100a, #0a2b17); /* Dark gradient */
  --bg-secondary: radial-gradient(circle at top right, #0a2b17, #05100a); /* Dark radial for landing */
  --bg-overlay: rgba(0,0,0,0.3); /* Dark semi-transparent */
  --bg-overlay-light: rgba(255,255,255,0.1); /* Light semi-transparent */
  --bg-overlay-hover: rgba(255,255,255,0.2);
  --text-primary: #8d8989;; /* Light text for dark bg */
  --text-secondary: #2b2b2b; /* Dark text for light elements */
  --bubble-bg-incoming: #f5f5f5; /* Light bubble for incoming */
  --bubble-bg-outgoing: linear-gradient(135deg, #ff6ec7, #7873f5); /* Outgoing gradient */
  --bubble-arrow-incoming: #f5f5f5;
  --bubble-arrow-outgoing: #7873f5;
  --button-bg: #A3E635; /* Green buttons */
  --button-bg-danger: #ff4d4d; /* Red for clear history */
  --button-hover: #C6F6D5;
  --button-hover-danger: #ff6666;
  --link-color: #A3E635;
  --link-hover: #C6F6D5;
  --shadow: transparent;
  --input-bg: #f5f5f5; /* Light input on dark */
  --chip-bg: #4CAF50;
  --chip-hover: #45a049;
  --border-color: rgba(255,255,255,0.2);
  --name-color-incoming: #3498db;
  --name-color-outgoing: #2ecc71;
  --timestamp-color: #999;
  --history-bg: rgba(0,0,0,0.5);
  --history-text: rgba(255,255,255,0.7);
}

/* Light mode overrides */
body.light-mode {
  --bg-primary: linear-gradient(to bottom, #aaaaaa, #ffffff); /* Stronger gray-to-white for visibility */
  --bg-secondary: radial-gradient(circle at top right, #ffffff, #aaaaaa);
  --bg-overlay: rgba(255,255,255,0.3);
  --bg-overlay-light: rgba(0,0,0,0.1);
  --bg-overlay-hover: rgba(0,0,0,0.2);
  --text-primary: #333333;
  --text-secondary: rgba(0,0,0,0.7); /* Dark for visibility */
  --bubble-bg-incoming: #e0e0e0;
  --bubble-bg-outgoing: linear-gradient(135deg, #ff9ed7, #a0a0ff);
  --bubble-arrow-incoming: #e0e0e0;
  --bubble-arrow-outgoing: #a0a0ff;
  --button-bg: #4CAF50;
  --button-bg-danger: #d32f2f;
  --button-hover: #66BB6A;
  --button-hover-danger: #e57373;
  --link-color: #4CAF50;
  --link-hover: #66BB6A;
  --shadow: rgba(0,0,0,0.1);
  --input-bg: #ffffff;
  --chip-bg: #A3E635;
  --chip-hover: #C6F6D5;
  --border-color: rgba(0,0,0,0.2);
  --name-color-incoming: #1976d2;
  --name-color-outgoing: #388e3c;
  --timestamp-color: #666;
  --history-bg: rgba(255,255,255,0.5);
  --history-text: rgba(0,0,0,0.7);
}

html, body {
  width: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: sans-serif;
  color: var(--text-primary);
  background: var(--bg-primary);
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.3s ease, color 0.3s ease; /* Smooth transition */
}

/* ==========================================================================
   Starfield Canvas
   ========================================================================== */
#starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100dvh;
  z-index: 0;
  pointer-events: none;
  display: none; /* Hidden by default, shown only on landing */
}

/* ==========================================================================
   LANDING VIEW
   ========================================================================== */
#landing {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100dvh;
  z-index: 1;
  text-align: center;
  padding: 1rem;
  background: var(--bg-secondary);
}
#landing #starfield {
  display: block; /* Show starfield only on landing page */
}
.landing-container {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
.top-links {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}
.link-block {
  flex: 1;
  padding: 0.75rem;
  background: var(--bg-overlay-light);
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: bold;
  transition: background .2s;
}
.link-block:hover {
  background: var(--bg-overlay-hover);
}
.bot-placeholder img {
  width: clamp(100px, 25vw, 150px);
  border-radius: 50%;
  box-shadow: 0 0 20px var(--shadow);
}
.recent-chats {
  background: var(--bg-overlay);
  padding: 1rem;
  border-radius: 8px;
  width: 100%;
}
.recent-chats .recent-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.recent-chats .recent-header h2 {
  margin: 0;
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  color: var(--text-primary);
}
.recent-chats .see-all {
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--link-color);
  transition: color 0.2s;
}
.recent-chats .see-all:hover {
  color: var(--link-hover);
}
#recentList {
  list-style: none;
  padding: 0;
  margin: 0;
}
#recentList li {
  position: relative;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(0.85rem, 2.5vw, 0.95rem);
  cursor: pointer;
  color: var(--text-primary);
}
#recentList li:hover {
  background: var(--bg-overlay-hover);
}
#startChat {
  font-size: clamp(1rem, 4vw, 1.25rem);
  padding: 0.75rem 1.5rem;
  background: var(--bg-overlay-light);
  border: 2px solid var(--border-color);
  border-radius: 40px;
  cursor: pointer;
  transition: background .2s, transform .2s;
  color: var(--text-primary);
}
#startChat:hover {
  background: var(--bg-overlay-hover);
  transform: scale(1.05);
}
@media (max-width: 360px) {
  #startChat { width: 100%; }
}

/* ==========================================================================
   CHAT VIEW
   ========================================================================== */
#chatApp {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1;
}
.chatBot {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  position: relative;
}
.chatbox {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: clamp(60px, 5vw, 80px) clamp(15px, 2vw, 20px);
  list-style: none;
  max-height: calc(100vh - 120px); /* Adjust for fixed header and input */
  min-height: 200px; /* Prevent zero height on empty chat */
  box-sizing: border-box;
}
.chat-input {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  padding: clamp(0.5rem, 2vw, 1rem);
  background: var(--bg-overlay);
  padding-bottom: env(safe-area-inset-bottom, 0.5rem);
  box-shadow: 0 -2px 10px var(--shadow);
}
.chat-input textarea {
  flex: 1;
  width: 100%;
  min-height: 2rem;
  max-height: 8rem;
  margin-right: 0.15rem;
  padding: 0.6rem 1rem;
  border-radius: 20px 20px 20px 20px;
  border: none;
  background: var(--input-bg);
  color: var(--text-primary); /* Use primary for visibility */
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  resize: vertical;
  box-sizing: border-box;
  transition: min-height 0.2s ease;
}
.chat-input textarea:focus {
  outline: none;
  box-shadow: 0 0 5px rgba(163, 230, 53, 0.5);
  min-height: 2.5rem;
}
.send-button img,
.mic-button img, .menu-trigger img {
  width: 80%;  /* Adjust this percentage (e.g., 50-80%) based on your SVG's aspect ratio and desired fit */
  height: auto;  /* Maintains aspect ratio; use '60%' if you want square scaling */
  display: block;  /* Ensures no extra inline spacing */
  margin: 0 auto;  /* Centers the image horizontally inside the button */
  object-fit: contain;  /* Prevents distortion if the SVG doesn't match the button's aspect ratio */
}
.send-mic-wrapper {
  display: flex;
  gap: 0;
  margin-left: 0;
  flex:0 0 10%;
}
.send-button, .mic-button, .theme-toggle, .menu-trigger {
  padding: clamp(0.5rem, 2vw, 0.8rem);
  min-width: 48px;
  min-height: 48px;
  margin-right: 0.15rem;
  border: none;
  background: var(--button-bg);
  color: var(--text-secondary);
  border-radius: 20px 20px 20px 20px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  border-left: 1px solid var(--border-color);
}
.send-button:hover, .mic-button:hover, .theme-toggle:hover {
  background: var(--button-hover);
  transform: scale(1.05);
}
.chatBot header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 10px 20px;
  background: var(--bg-primary);  /* Fix: Use solid primary gradient (opaque) instead of overlay */
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
  padding-top: env(safe-area-inset-top, 10px);
  box-shadow: 0 2px 10px var(--shadow);  /* Optional: Add shadow for depth when scrolling */
}
.change-settings-btn, .tts-toggle, .theme-toggle {
  background: var(--button-bg);
  color: var(--text-secondary);
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: clamp(12px, 2.5vw, 14px);
}
.tts-toggle {
  background: none;
  color: var(--text-primary);
  font-size: clamp(20px, 5vw, 24px);
  padding: 5px 10px;
}
.tts-toggle:hover {
  background: var(--bg-overlay-hover);
}
.tts-toggle.muted {
  opacity: 0.5;
}
.change-settings-btn:hover, .theme-toggle:hover {
  background: var(--button-hover);
}

/* ==========================================================================
   Speech Bubbles
   ========================================================================== */
.chat-bubble {
  display: flex;
  align-items: flex-start;
  position: relative;
  margin-bottom: 1rem;
  width: 100%;
  gap: 0.5rem;
}
.chat-image {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.5rem;
}
.chat-incoming .chat-image {
  order: 0;
}
.chat-outgoing .chat-image {
  order: 2;
}
.speech-wrapper {
  position: relative;
  flex-grow: 1;
  min-width: 0;
  padding: 0.5rem;
  border-radius: 4px;
  /* box-shadow: 0 2px 5px var(--shadow);
  background: var(--bg-overlay-light); */
}
/* .chat-outgoing .speech-wrapper {
  background: var(--bg-overlay);
} */
.bubble {
  max-width: 100%;
  background: var(--bubble-bg-incoming);
  border-radius: 4px;
  box-shadow: 2px 8px 5px var(--shadow);
  position: relative;
  padding: 0.5rem;
}
.bubble.alt {
  margin-left: auto;
  background: var(--bubble-bg-outgoing);
  color: var(--text-primary);
}
.bubble-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid var(--bubble-arrow-incoming);
  bottom: -10px;
  left: 15px;
}
.bubble-arrow.alt {
  border-top-color: var(--bubble-arrow-outgoing);
  left: auto;
  right: 15px;
}
.bubble .txt {
  padding: 8px 14px 28px 14px;
  position: relative;
}
.name {
  font-weight: 600;
  font-size: clamp(10px, 2vw, 12px);
  margin-bottom: 4px;
  color: var(--name-color-incoming);
}
.name.alt {
  color: var(--name-color-outgoing);
}
.message {
  font-size: clamp(10px, 2vw, 12px);
  margin: 0;
  color: var(--text-secondary);
}
.bubble.alt .message {
  color: var(--text-primary);
}
.timestamp {
  font-size: clamp(9px, 1.5vw, 11px);
  position: absolute;
  bottom: 8px;
  right: 10px;
  text-transform: uppercase;
  color: var(--timestamp-color);
}
.chip {
  display: inline-block;
  padding: clamp(6px, 1.5vw, 8px) clamp(12px, 3vw, 16px);
  margin: 4px;
  background-color: var(--chip-bg);
  color: var(--text-secondary);
  border-radius: 16px;
  cursor: pointer;
  font-size: clamp(12px, 2.5vw, 14px);
  transition: background-color 0.3s;
}
.chip:hover {
  background-color: var(--chip-hover);
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 768px) {
  .chat-bubble {
    margin-bottom: 0.8rem;
  }
  .chat-image {
    width: 28px;
    height: 28px;
  }
  .speech-wrapper {
    padding: 0.4rem;
  }
  .chat-input textarea {
    min-height: 1.8rem;
  }
}
@media (max-width: 480px) {
  .chat-bubble {
    margin-bottom: 0.6rem;
  }
  .chat-image {
    width: 24px;
    height: 24px;
    margin-top: 0.3rem;
  }
  .speech-wrapper {
    padding: 0.3rem;
  }
  .bubble {
    max-width: 90%;
  }
  .chat-input textarea {
    min-height: 1.6rem;
    padding: 0.5rem 0.8rem;
  }
  .send-button, .mic-button, .theme-toggle {
    padding: clamp(0.4rem, 1.5vw, 0.6rem);
    min-width: 40px;
    min-height: 40px;
  }
  .send-button img,
  .mic-button img {
    width: 70%;  /* Slightly larger relative size for smaller buttons */
  }
}

/* ==========================================================================
   History Page
   ========================================================================== */
.history-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
  background: var(--history-bg);
  border-radius: 8px;
  box-sizing: border-box;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 1rem);
}
.history-container header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.history-container .nav-buttons {
  display: flex;
  gap: 1rem;
  margin-left: auto;
}
.back-button, .clear-history-btn, .landing-button {
  background: var(--button-bg);
  color: var(--text-secondary);
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: clamp(12px, 2vw, 14px);
}
.clear-history-btn {
  background: var(--button-bg-danger);
}
.back-button:hover, .landing-button:hover {
  background: var(--button-hover);
}
.clear-history-btn:hover {
  background: var(--button-hover-danger);
}
.history-list {
  max-height: calc(100dvh - 6rem - env(safe-area-inset-bottom, 0));
  overflow-y: auto;
  padding-right: 0.5rem;
}
.date-separator {
  margin: 1rem 0 0.5rem;
  font-weight: bold;
  color: var(--text-primary);
  text-align: center;
}
.history-chip {
  display: inline-block;
  background: var(--bg-overlay-light);
  color: var(--text-primary);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  margin-right: 0.5rem;
  font-size: clamp(0.75rem, 2vw, 0.85rem);
}
.history-message {
  margin: 0.5rem 0;
  padding: 0.75rem;
  border-radius: 8px;
  max-width: 85%;
  font-size: clamp(0.8rem, 2vw, 0.9rem);
}
.history-message.incoming {
  background: var(--bg-overlay-light);
  align-self: flex-start;
}
.history-message.outgoing {
  background: var(--bg-overlay);
  align-self: flex-end;
}
.no-history {
  text-align: center;
  font-style: italic;
  color: var(--history-text);
  margin-top: 2rem;
}

/* ==========================================================================
   Misc
   ========================================================================== */
#micButton.listening {
  opacity: 0.7;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.1); }
}

.chatbox, .chat-input { display: block; }
#chatInputContainer { display: none; }
#initialConversationGreeting { display: none; }

/* ==========================================================================
   Button System (Uniform Design)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px; /* Pill shape */
  padding: clamp(8px, 2vw, 12px) clamp(16px, 4vw, 24px);
  font-size: clamp(14px, 3vw, 16px);
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
  border: none;
  color: var(--text-secondary);
}

.btn:hover {
  transform: scale(1.05);
  background: var(--button-hover);
}

.btn-primary {
  background: var(--button-bg);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--button-bg);
  color: var(--button-bg);
}

.btn-icon {
  padding: 0;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%; /* Circular for icons */
}

.btn-icon img {
  width: 60%;
  height: auto;
  object-fit: contain;
}

.btn-danger {
  background: var(--button-bg-danger);
}

.btn-danger:hover {
  background: var(--button-hover-danger);
}
.menu-item {
  color: #000; 
  background-color: #2ecc71;
}

/* ==========================================================================
   Chat Header and Menu
   ========================================================================== */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;  /* Start from left */
  padding: 0.5rem 1rem;  /* Slightly smaller padding */
  background: var(--bg-overlay);
  position: sticky;
  top: 0;
  z-index: 2;
  gap: 0.5rem;  /* Space between elements */
}

.header-title {
  flex: 1;
  text-align: center;
  font-size: clamp(1rem, 3vw, 1.2rem);  /* Smaller font */
  margin: 0;
  color: var(--text-primary);
}

.tts-toggle.muted .tts-icon {
  content: url('Speaker Disabled Icon.svg'); /* Swap to muted */
}

/* .menu-trigger {
  margin-left: auto;
} */

.header-menu {
  position: absolute;
  top: 8%;  /* Just below header */
  right: 0;  /* Align to right (under trigger) */
  
  width: auto;  /* Compact, not full-width */
  min-width: 180px;  /* Minimum for text */
  max-width: 80vw;
  /* background: var(--bg-overlay); */
  border-radius: 16px;  /* Rounded dropdown */
  box-shadow: var(--shadow);
  z-index: 1;
  transform: translateY(-10px);  /* Slight offset for hidden */
  transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
  opacity: 0;
  pointer-events: none;
  display: none;
}

.header-menu.open {
  display: block;
  transform: translateY(0);
  opacity: 0.5;
  pointer-events: auto;
}

.menu-list {
  list-style: none;
  padding: 0.5rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;  /* Tighter spacing */
}

.menu-item {
  width: 100%;
  justify-content: flex-start;
  gap: 0.5rem; /* Space between icon and text */
  white-space: normal;
}

.menu-icon {
  width: 20px;
  height: 20px;
}

/* Backdrop for menu (optional, dims content) */
body.menu-open::before {
  content: '';
  position: fixed;
  top: 0;
  right: 0;
  width: 30%;
  height: 30%;
  background: transparent;
  z-index: 0;
  pointer-events: none;
}

/* Update existing .theme-toggle for icon swap */
.theme-toggle .theme-icon {
  content: url('Dark Vector1.svg'); /* Default dark */
}

body.light-mode .theme-toggle .theme-icon {
  content: url('Light Vector.svg'); /* Light mode sun */
}

/* Responsive tweaks */
@media (max-width: 480px) {
  .btn-icon {
    min-width: 40px;
    min-height: 40px;
  }
  .header-title {
    font-size: clamp(1rem, 3vw, 1.2rem);
  }
}
/* Standardize all button icons */
.btn-icon img,
.menu-icon,
.tts-icon,
.theme-icon {
  width: 50%;  /* Start with 50% of button width (e.g., 24px in 48px button); adjust to 40-60% as needed */
  height: auto;  /* Maintain aspect ratio */
  max-width: 24px;  /* Fixed cap to prevent overflow on large SVGs */
  max-height: 24px;
  object-fit: contain;  /* Ensures no distortion/cropping */
  display: block;  /* Removes inline spacing */
  margin: 0 auto;  /* Centers in button */
}

/* For menu items (text + icon), make icons slightly smaller */
.menu-item .menu-icon {
  width: 20px;  /* Fixed for consistency in list */
  height: 20px;
  margin-right: 0.5rem;  /* Space before text */
}

/* TTS muted swap (ensure URLs are local files, not external) */
.tts-toggle.muted .tts-icon {
  content: url('Speaker Disabled Icon.svg'); /* Already have; confirm path */
}

/* Theme swap (similarly local) */
.theme-toggle .theme-icon {
  content: url('Dark Vector1.svg');
}
body.light-mode .theme-toggle .theme-icon {
  content: url('Light Vector.svg');
}

/* Optional: Hover zoom for feedback */
.btn-icon:hover img {
  transform: scale(1.1);  /* Subtle enlargement on hover */
}

/* Media query override for mobile (smaller buttons) */
@media (max-width: 480px) {
  .btn-icon img,
  .menu-icon,
  .tts-icon,
  .theme-icon {
    width: 60%;  /* Slightly larger relative to smaller buttons */
  }
  .menu-item .menu-icon {
    width: 18px;
    height: 18px;
  }
}


.header-menu.open {
  display: block;  /* Show on open */
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
/* ==========================================================================
   CHAT BUBBLES (Add this section if not present)
   ========================================================================== */
.chat {
  display: flex;
  align-items: flex-start;
  margin: 0.5rem 0;
  gap: 0.5rem;
}

.chat-incoming {
  flex-direction: row;
}

.chat-outgoing {
  flex-direction: row-reverse;
}

.chat-image {
  width: clamp(30px, 5vw, 40px);
  height: clamp(30px, 5vw, 40px);
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.speech-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}
.chat-incoming .speech-wrapper {
  max-width: 90%;  /* Wider for bot responses to fill more to the right */
}
.chat-outgoing .speech-wrapper {
  max-width: 85%;  /* Wider for user messages to reduce left blank space and hug right border */
  /* margin-left: auto;  Pushes to right edge */
}
.bubble {
  position: relative;
  padding: clamp(0.75rem, 2vw, 1rem);
  border-radius: 16px;
  box-shadow: 0 2px 8px var(--shadow);
}

.bubble-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  top: 50%;
  transform: translateY(-50%);
}

.chat-incoming .bubble {
  background: var(--bubble-bg-incoming);
}

.chat-incoming .bubble-arrow {
  border-right-color: var(--bubble-arrow-incoming);
  left: -16px;
}

.chat-outgoing .bubble {
  background: var(--bubble-bg-outgoing);
}

.chat-outgoing .bubble-arrow {
  border-left-color: var(--bubble-arrow-outgoing);
  right: -16px;
}

.chat .txt {
  color: var(--text-secondary);
}

.chat .txt .name {
  font-weight: bold;
  font-size: clamp(0.8rem, 2vw, 0.9rem);
  margin-bottom: 0.25rem;
  color: var(--name-color-incoming);
}

.chat-outgoing .txt .name {
  color: var(--name-color-outgoing);
}

.chat .txt .name span {
  font-size: 0.75em;
  color: var(--timestamp-color);
  font-weight: normal;
  margin-left: 0.5rem;
}

.chat .txt .message {
  font-size: clamp(1rem, 3vw, 1.2rem);  /* Updated for better readability: min 16px, scales with viewport, max ~19px */
  line-height: 1.4;  /* Improved spacing for legibility */
  margin: 0 0 0.5rem 0;
  color: inherit;
}
.feedback-widget {
  position: relative;  /* Remove from flow to avoid expanding bubble width */
  left: auto;
  display: flex !important;
  justify-content: center !important;  /* Buttons grouped left */
  gap: 0.5rem !important;  /* Space between buttons */
  margin-top: 0.25rem !important;  /* Space above feedback */
  width:100% !important;
  padding: 0 0.5rem;  /* Slight horizontal padding */
  bottom:auto;
  font-size: 1.2rem !important;
}

.feedback-widget span {
  cursor: pointer;
  transition: transform 0.2s;
  font-size: 1.2rem;  /* Keep touch-friendly */
}

.feedback-widget span:hover {
  transform: scale(1.2);
}

.feedback-widget button {
  background: none;
  border: none;  /* Remove any borders; adjust if you want subtle ones */
  cursor: pointer;
  font-size: inherit;  /* Inherit from widget */
  padding: 0.25rem;  /* Small touch area */
  transition: transform 0.2s;
}

.feedback-widget button:hover {
  transform: scale(1.2);
}

.message textarea {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem;
  resize: vertical;
  transition: box-shadow 0.2s;
}

.message textarea:focus {
  box-shadow: 0 0 5px var(--button-bg);
}
.message button {
  background: var(--button-bg);
  color: var(--text-secondary);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  min-width: 80px;  /* Touch-friendly */
  transition: background 0.2s;
}

.message button:hover {
  background: var(--button-hover);
}

.message button:nth-child(1) {  
  background: var(--bg-overlay-light);
  color: var(--text-primary);
}
.history-subject-header {
  text-align: center;
  margin: 1.5rem 0 1rem 0; /* Adds space above and below the chip */
}
/* Optional: Comment out system preference to avoid override during testing */
/* @media (prefers-color-scheme: light) {
  :root:not(.light-mode) {
    /* Disabled to ensure manual toggle controls */
  /* } */
/* } */ 