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

:root {
  --saffron: #FF9933;
  --deep-saffron: #e07000;
  --green: #138808;
  --navy: #000080;
  --cream: #FFF8EE;
  --card-bg: #ffffff;
  --card-bg-rgb: 255, 255, 255;
  --chat-bg: #f5f0e8;
  --border: #e8dcc8;
  --text: #1a1a2e;
  --muted: #7a6f5e;
  --ai-bubble: #ffffff;
  --user-bubble: #000080;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
  --sidebar-width: 280px;
  --transition: all 0.3s ease;
  --red: #e53e3e;
}

/* Dark Mode Variables */
body.dark-mode {
  --saffron: #FFB366;
  --deep-saffron: #ff8800;
  --green: #2ccf1f;
  --navy: #1a1a40;
  --accent: #66b2ff;
  /* New variable for dark mode visibility */
  --cream: #1a1a2e;
  --card-bg: #161625;
  --card-bg-rgb: 22, 22, 37;
  --chat-bg: #050510;
  --border: #2a2a45;
  --text: #f0f0f5;
  --muted: #a0a0b0;
  --ai-bubble: rgba(255, 255, 255, 0.08);
  --user-bubble: #333399;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --link-color: var(--saffron);
  --link-hover-color: var(--deep-saffron);
  --red: #ff4d4d;
}

body {
  font-family: 'Noto Sans', sans-serif;
  background: var(--chat-bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  display: flex;
  overflow: hidden;
  max-width: 100vw;
}

/* ══════════════════════════════════════════════════════════════════
   ── SIDEBAR OVERLAY (mobile backdrop) ──
   ══════════════════════════════════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ══════════════════════════════════════════════════════════════════
   ── SIDEBAR ──
   ══════════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(rgb(2, 2, 46) 0%, rgb(3, 3, 74) 100%);
  color: white;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
  z-index: 100;
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  transform: translateX(0);
}

/* Universal Sidebar Push Logic */
.sidebar:not(.hidden)~.main-content {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
}

body.dark-mode .sidebar {
  background: linear-gradient(rgb(2, 2, 46) 0%, rgb(3, 3, 74) 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}


.sidebar.hidden {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}

.sidebar-header {
  padding: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.new-chat-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 12px;
  border-radius: 8px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.new-chat-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.close-sidebar-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  opacity: 0.7;
  padding: 8px;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item {
  position: relative;
  padding: 10px 12px;
  padding-right: 30px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
}

.history-item .chat-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.history-item.active {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-weight: 500;
}

.history-menu-btn {
  position: absolute;
  right: 6px;
  width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
  opacity: 0.6;
}

.history-item:hover .history-menu-btn {
  display: flex;
}

.history-menu-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  opacity: 1;
}

.history-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: #202123;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  min-width: 120px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 2000;
  display: none;
  flex-direction: column;
  padding: 4px;
  margin-top: 4px;
}

.history-dropdown.active {
  display: flex;
}

.history-dropdown-item {
  padding: 8px 12px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.history-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.history-dropdown-item.delete {
  color: #ff4d4d;
}

.history-dropdown-item.delete:hover {
  background: rgba(255, 77, 77, 0.1);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.user-profile:hover {
  background: rgba(255, 255, 255, 0.1);
}

.user-avatar {
  font-size: 20px;
}

#username-display {
  font-size: 13px;
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════════
   ── MAIN CONTENT ──
   ══════════════════════════════════════════════════════════════════ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  width: 100%;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ══════════════════════════════════════════════════════════════════
   ── HEADER ──
   ══════════════════════════════════════════════════════════════════ */
header {
  background: linear-gradient(135deg, #000080 0%, #0a0a6e 60%, #FF9933 150%);
  color: white;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 2px 20px rgba(0, 0, 128, 0.3);
  position: relative;
  z-index: 50;
}

header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #FF9933 33%, #ffffff 33% 66%, #138808 66%);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sidebar-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

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

.flag-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}

.brand-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  display: block;
  min-width: 0;
}

.brand-text {
  font-family: 'Rajdhani', sans-serif;
}

.brand-text h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1;
  white-space: nowrap;
}

.brand-text span {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.8;
  letter-spacing: 2px;
  text-transform: uppercase;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-shrink: 0;
}

/* Theme Toggle */
.theme-toggle {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 18px;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(15deg);
}

.lang-selector {
  display: flex;
  gap: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 3px;
}

.lang-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}

.lang-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.15);
}

.lang-btn.active {
  background: white;
  color: var(--navy);
}

/* ══════════════════════════════════════════════════════════════════
   ── MODALS ──
   ══════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-overlay.active {
  display: flex;
}

.modal-content.glass {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  width: 100%;
  max-width: 500px;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  padding: 32px;
  position: relative;
  overflow-y: auto;
  max-height: 90vh;
  max-height: 90dvh;
}

.modal-tabs {
  display: flex;
  background: var(--chat-bg);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  border: none;
  padding: 10px;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  transition: all 0.2s;
  color: var(--text);
  opacity: 0.6;
}

.tab-btn.active {
  background: var(--card-bg);
  box-shadow: var(--shadow);
  opacity: 1;
}

.auth-form-container {
  display: none;
}

.auth-form-container.active {
  display: block;
}

.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
  /* Prevent zoom on iOS */
  font-size: 16px;
  background: var(--cream);
  color: var(--text);
}

.form-group input:focus {
  border-color: var(--saffron);
  box-shadow: 0 0 0 3px rgba(255, 153, 51, 0.15);
}

.divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.divider span {
  padding: 0 10px;
}

.btn-primary {
  width: 100%;
  background: var(--navy);
  color: white;
  border: none;
  padding: 14px;
  border-radius: 12px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 10px;
}

.btn-primary:hover {
  background: var(--deep-saffron);
}

/* ══════════════════════════════════════════════════════════════════
   ── SUGGESTIONS BAR ──
   ══════════════════════════════════════════════════════════════════ */
.suggestions-bar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  justify-content: center;
  gap: 8px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.suggestions-bar::-webkit-scrollbar {
  display: none;
}

.chip {
  white-space: nowrap;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Noto Sans', sans-serif;
  flex-shrink: 0;
}

.chip:hover {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}

/* ══════════════════════════════════════════════════════════════════
   ── CHAT AREA ──
   ══════════════════════════════════════════════════════════════════ */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Welcome */
.welcome-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  max-width: 560px;
  margin: 20px auto 0;
  width: 100%;
  transition: var(--transition);
}

.welcome-card .wheel {
  font-size: 40px;
  margin-bottom: 12px;
  display: block;
  animation: spin 8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.welcome-card h2 {
  font-family: 'Rajdhani', sans-serif;
  font-size: 22px;
  color: var(--saffron);
  margin-bottom: 8px;
}

.welcome-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

body.dark-mode .welcome-card p {
  color: var(--text);
  opacity: 0.8;
}

/* Message row */
.msg-row {
  display: flex;
  gap: 10px;
  max-width: 820px;
  width: 100%;
  animation: fadeUp 0.25s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

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

.msg-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-row.ai {
  align-self: flex-start;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 2px;
}

.avatar.ai {
  background: linear-gradient(135deg, #000080, #4444cc);
  color: white;
}

.avatar.user {
  background: var(--saffron);
  color: white;
}

.bubble {
  border-radius: 14px;
  padding: 12px 16px;
  max-width: calc(100% - 50px);
  font-size: 14px;
  line-height: 1.65;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.bubble.ai {
  background: var(--ai-bubble);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  border-top-left-radius: 4px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.bubble.user {
  background: var(--user-bubble);
  color: white;
  border-top-right-radius: 4px;
}

/* ══════════════════════════════════════════════════════════════════
   ── SCHEME CARDS ──
   ══════════════════════════════════════════════════════════════════ */
.schemes-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.scheme-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
  transition: var(--transition);
}

.scheme-card-header {
  background: linear-gradient(135deg, #000080, #2020aa);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.scheme-number {
  background: rgba(255, 255, 255, 0.2);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.scheme-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
}

.scheme-state-badge {
  margin-left: auto;
  background: var(--saffron);
  color: white;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.scheme-body {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.scheme-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.scheme-field.full {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--saffron);
  font-weight: 700;
  font-family: 'Rajdhani', sans-serif;
}

.field-value {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.link-value {
  color: var(--navy);
  text-decoration: none;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px dashed var(--navy);
  word-break: break-all;
}

body.dark-mode .link-value {
  color: var(--link-color, var(--saffron));
  border-bottom-color: var(--link-color, var(--saffron));
}

.link-value:hover {
  color: var(--deep-saffron);
  border-color: var(--deep-saffron);
}

body.dark-mode .link-value:hover {
  color: var(--link-hover-color, var(--deep-saffron));
  border-bottom-color: var(--link-hover-color, var(--deep-saffron));
}

.divider {
  height: 1px;
  background: var(--border);
  grid-column: 1 / -1;
}

.category-badge {
  display: inline-block;
  background: #EEF2FF;
  color: #3730a3;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
}

body.dark-mode .category-badge {
  background: rgba(102, 178, 255, 0.15);
  color: #66b2ff;
}

/* ══════════════════════════════════════════════════════════════════
   ── TYPING INDICATOR ──
   ══════════════════════════════════════════════════════════════════ */
.typing-row {
  align-self: flex-start;
}

.typing-dots {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
  background: var(--ai-bubble);
  border: 1px solid var(--border);
  border-radius: 14px;
  border-top-left-radius: 4px;
  backdrop-filter: blur(8px);
}

.typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

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

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

@keyframes bounce {

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

  30% {
    transform: translateY(-6px);
  }
}

/* ══════════════════════════════════════════════════════════════════
   ── INPUT BAR ──
   ══════════════════════════════════════════════════════════════════ */
.input-area {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  flex-shrink: 0;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  position: relative;
  z-index: 50;
}

.input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column-reverse;
}

/* ══════════════════════════════════════════════════════════════════
   ── SUGGESTION BOX ──
   ══════════════════════════════════════════════════════════════════ */
.suggestion-box {
  position: absolute;
  bottom: calc(100% - 1.5px);
  left: 0;
  width: 100%;
  background: rgba(var(--card-bg-rgb), 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1.5px solid var(--border);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 150px;
  overflow-y: auto;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: translateY(0);
  z-index: 1001;
}

body.dark-mode .suggestion-box {
  background: rgba(var(--card-bg-rgb), 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-bottom: none;
}

.suggestion-box.hidden {
  max-height: 0;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  border-color: transparent;
}

.suggestion-box.disabled {
  pointer-events: none;
  opacity: 0.7;
  cursor: not-allowed;
}

.suggestion-box.disabled .suggestion-item {
  cursor: not-allowed;
}

.suggestion-item {
  padding: 7px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
  border-bottom: 1px solid rgba(var(--card-bg-rgb), 0.05);
  font-size: 13.5px;
  color: var(--text);
}

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

.suggestion-item:hover,
.suggestion-item.selected {
  background: rgba(var(--card-bg-rgb), 0.5);
  padding-left: 22px;
  color: var(--navy);
  background: var(--cream);
}

body.dark-mode .suggestion-item:hover,
body.dark-mode .suggestion-item.selected {
  background: rgba(255, 255, 255, 0.08);
  color: var(--saffron);
}

.suggestion-box:not(.hidden)+#question-input {
  border-top-left-radius: 0 !important;
  border-top-right-radius: 0 !important;
}

.suggestion-item .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.suggestion-item .text {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-item .type-label {
  font-size: 10px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.04);
  padding: 3px 10px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  opacity: 0.8;
}

body.dark-mode .suggestion-item .type-label {
  background: rgba(255, 255, 255, 0.12);
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 820px;
  margin: 0 auto;
}

#question-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 16px;
  font-family: 'Noto Sans', sans-serif;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  transition: all 0.2s;
  background: var(--cream);
  color: var(--text);
  min-width: 0;
}

#question-input:focus {
  border-color: var(--saffron);
  box-shadow: 0 0 0 3px rgba(255, 153, 51, 0.2);
}

#question-input::placeholder {
  color: var(--muted);
}

.send-btn,
.mic-btn {
  background: var(--navy);
  color: white;
  border: none;
  border-radius: 12px;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  font-size: 18px;
}

body.dark-mode .send-btn {
  background: var(--saffron);
  color: var(--card-bg);
}

.send-btn:hover,
.mic-btn:hover {
  background: var(--deep-saffron);
  transform: scale(1.05);
}

.mic-btn.listening {
  background: #ff4b2b !important;
  color: white !important;
  animation: pulse-red 1.5s infinite;
}

body.dark-mode .mic-btn.listening {
  background: #ff3b30 !important;
  color: white !important;
  animation: pulse-red-dark 1.5s infinite;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

@keyframes pulse-red {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 75, 43, 0.7);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 10px rgba(255, 75, 43, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 75, 43, 0);
  }
}

@keyframes pulse-red-dark {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.5);
  }

  70% {
    transform: scale(1.02);
    box-shadow: 0 0 15px 12px rgba(255, 59, 48, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0);
  }
}

.send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.input-hint {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

/* Scrollbar */
.chat-container::-webkit-scrollbar {
  width: 6px;
}

.chat-container::-webkit-scrollbar-track {
  background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 3px;
}


/* ══════════════════════════════════════════════════════════════════
   ── AUTO-READ TOGGLE ──
   ══════════════════════════════════════════════════════════════════ */
.auto-read-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  padding: 5px 12px 5px 8px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.auto-read-toggle:hover {
  background: rgba(255, 255, 255, 0.22);
}

.auto-read-toggle.on {
  background: rgba(255, 153, 51, 0.25);
  border-color: var(--saffron);
}

.toggle-track {
  position: relative;
  width: 30px;
  height: 17px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 9px;
  transition: background 0.25s;
  flex-shrink: 0;
}

.auto-read-toggle.on .toggle-track {
  background: var(--saffron);
}

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  background: white;
  border-radius: 50%;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.auto-read-toggle.on .toggle-knob {
  transform: translateX(13px);
}

.auto-read-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: white;
}

/* ══════════════════════════════════════════════════════════════════
   ── MIC BUTTON ──
   ══════════════════════════════════════════════════════════════════ */
.mic-btn {
  background: var(--cream);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  font-size: 18px;
  color: var(--text);
}

.mic-btn:hover {
  background: var(--ai-bubble);
  border-color: var(--saffron);
}

.mic-btn.listening {
  background: #fff0f0;
  border-color: #e53e3e;
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.3);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(229, 62, 62, 0);
  }
}


/* ══════════════════════════════════════════════════════════════════
   ── TTS WORD HIGHLIGHT ──
   ══════════════════════════════════════════════════════════════════ */
.tts-word {
  border-radius: 3px;
  transition: background 0.1s, color 0.1s;
}

.tts-word.active {
  background: var(--saffron);
  color: #fff;
  border-radius: 3px;
  padding: 0 1px;
}

/* ── TTS speak button on AI bubbles ── */
.speak-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}

body.dark-mode .speak-btn {
  color: var(--text);
}

.speak-btn:hover {
  border-color: var(--navy);
  color: var(--navy);
}

body.dark-mode .speak-btn:hover {
  border-color: var(--saffron);
  color: var(--saffron);
}

.speak-btn.speaking {
  color: var(--green);
  border-color: var(--green);
}

/* ── Word-by-word TTS Highlighting ── */
.tts-word {
  display: inline-block;
  border-radius: 4px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
  padding: 0 1px;
}

/* ── Pulse Glow for Reading State ── */
.reading-active {
  position: relative;
  z-index: 5;
  border-color: var(--saffron) !important;
  animation: pulse-glow 2s infinite ease-in-out;
  transition: all 0.4s ease;
}

.bubble.ai.reading-active {
  background: var(--card-bg) !important;
  box-shadow: 0 0 25px rgba(255, 153, 51, 0.35) !important;
}

.scheme-card.reading-active {
  background: var(--card-bg) !important;
  box-shadow: 0 0 35px rgba(255, 153, 51, 0.45) !important;
  transform: scale(1.01);
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 15px rgba(255, 153, 51, 0.2);
    border-color: rgba(255, 153, 51, 0.3);
  }

  50% {
    box-shadow: 0 0 30px rgba(255, 153, 51, 0.5);
    border-color: rgba(255, 153, 51, 0.8);
  }

  100% {
    box-shadow: 0 0 15px rgba(255, 153, 51, 0.2);
    border-color: rgba(255, 153, 51, 0.3);
  }
}

.tts-word.active {
  /* No longer adding yellow background per user request */
  color: var(--navy);
  font-weight: 600;
}

body.dark-mode .tts-word.active {
  color: var(--saffron);
}

/* ══════════════════════════════════════════════════════════════════
   ── STRUCTURED LISTS ──
   ══════════════════════════════════════════════════════════════════ */
.structured-list {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-item {
  position: relative;
  padding: 8px 12px;
  background: var(--ai-bubble);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.list-item.step {
  border-left: 4px solid var(--saffron);
}

.list-item.bullet {
  border-left: 4px solid #138808;
}

.step-marker {
  font-weight: 700;
  color: var(--saffron);
  margin-right: 6px;
  font-family: 'Rajdhani', sans-serif;
}

.bullet-marker {
  color: var(--green);
  font-weight: 900;
  margin-right: 8px;
}

/* ══════════════════════════════════════════════════════════════════
   ── NOTIFICATION BELL ──
   ══════════════════════════════════════════════════════════════════ */
.notif-bell {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
  color: white;
  z-index: 51;
}

.notif-bell:hover {
  background: rgba(255, 255, 255, 0.1);
}

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  background: #ff3300;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 8px rgba(255, 51, 0, 0.6);
  display: none;
}

.notif-badge.active {
  display: block;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 51, 0, 0.7);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(255, 51, 0, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 51, 0, 0);
  }
}

.notif-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 320px;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: none;
  flex-direction: column;
  z-index: 2000;
  margin-top: 12px;
  overflow: hidden;
  animation: slideDown 0.3s ease;
}

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

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

.notif-dropdown.active {
  display: flex;
}

.notif-header {
  padding: 14px 18px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--saffron);
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.01);
}

.notif-list {
  max-height: 400px;
  overflow-y: auto;
}

.notif-item {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
  cursor: default;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.notif-item:hover {
  background: rgba(0, 0, 0, 0.03);
}

body.dark-mode .notif-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.notif-content {
  flex: 1;
  min-width: 0;
}

.notif-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}

.notif-text {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.notif-delete {
  font-size: 16px;
  color: var(--muted);
  opacity: 0.4;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: all 0.2s;
  flex-shrink: 0;
  margin-top: -4px;
}

.notif-delete:hover {
  background: rgba(255, 77, 77, 0.15);
  color: #ff4d4d;
  opacity: 1;
}

.notif-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.notif-footer {
  padding: 14px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  cursor: pointer;
  background: rgba(19, 136, 8, 0.06);
  border-top: 1px solid var(--border);
  transition: all 0.2s;
  font-family: 'Rajdhani', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.notif-footer:hover {
  background: rgba(19, 136, 8, 0.12);
  letter-spacing: 1px;
}

/* ══════════════════════════════════════════════════════════════════
   ── PROFILE DROPDOWN ──
   ══════════════════════════════════════════════════════════════════ */
.profile-dropdown {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  padding: 6px;
}

.profile-dropdown.active {
  display: flex;
}

.dropdown-item {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s;
}

.dropdown-item span {
  font-size: 16px;
}

.dropdown-item:hover {
  background: rgba(0, 0, 128, 0.05);
}

.dropdown-item.logout {
  color: var(--red);
  margin-top: 4px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
}

body.dark-mode .profile-dropdown {
  background: rgba(22, 22, 37, 0.95);
}

body.dark-mode .dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.dropdown-item.logout:hover {
  background: rgba(200, 0, 0, 0.05);
}

/* ══════════════════════════════════════════════════════════════════════════════
   ═══════════════════ RESPONSIVE BREAKPOINTS ═══════════════════════════════════
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Large Desktop (1400px+) ── */
@media (min-width: 1400px) {
  .chat-container {
    padding: 32px 40px;
  }

  .msg-row {
    max-width: 900px;
  }

  .input-row {
    max-width: 900px;
  }

  .welcome-card {
    max-width: 640px;
    padding: 40px;
  }
}

/* ── Tablet & Small Laptops (below 900px) ── */
@media (max-width: 900px) {
  .welcome-card {
    max-width: 90%;
    margin: 20px auto 0;
    padding: 24px;
  }

  .msg-row {
    max-width: 100%;
  }

  .auto-read-label {
    display: none;
  }
}

/* ── Mobile Devices (below 600px) ── */
@media (max-width: 600px) {

  /* Header */
  header {
    padding: 0 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    height: 54px;
  }

  .flag-icon {
    font-size: 22px;
  }

  .brand-text h1 {
    font-size: 15px;
  }

  .brand-text span {
    font-size: 8px;
    letter-spacing: 1px;
  }

  .header-actions {
    gap: 4px;
  }

  .header-left {
    gap: 8px;
  }

  .auto-read-label {
    display: none;
  }

  .auto-read-toggle {
    padding: 4px 6px;
    gap: 4px;
  }

  .lang-btn {
    padding: 3px 6px;
    font-size: 11px;
  }

  .btn-ghost {
    padding: 4px 8px;
    font-size: 10px;
  }

  /* Sidebar — full width on mobile */
  .sidebar {
    width: 280px;
  }

  /* Suggestions Bar */
  .suggestions-bar {
    padding: 6px 10px;
    gap: 6px;
    justify-content: flex-start;
  }

  .chip {
    padding: 5px 12px;
    font-size: 11px;
  }

  /* Chat Area */
  .chat-container {
    padding: 12px 10px;
    gap: 10px;
  }

  .welcome-card {
    max-width: 95%;
    margin: 15px auto 0;
    padding: 20px 16px;
  }

  .welcome-card .wheel {
    font-size: 32px;
    margin-bottom: 8px;
  }

  .welcome-card h2 {
    font-size: 18px;
  }

  .welcome-card p {
    font-size: 13px;
    line-height: 1.5;
  }

  /* Messages */
  .msg-row {
    max-width: 100%;
  }

  .bubble {
    max-width: 88%;
    font-size: 13px;
    padding: 10px 12px;
  }

  .avatar {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  /* Scheme Cards */
  .scheme-body {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 8px;
  }

  .scheme-card-header {
    padding: 10px 12px;
    gap: 8px;
  }

  .scheme-title {
    font-size: 13px;
  }

  .scheme-state-badge {
    font-size: 10px;
    padding: 1px 8px;
  }

  /* Input Area */
  .input-area {
    padding: 10px 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .input-row {
    gap: 6px;
  }

  #question-input {
    padding: 10px 12px;
    font-size: 16px;
    border-radius: 10px;
  }

  .send-btn,
  .mic-btn {
    width: 42px;
    height: 42px;
    font-size: 16px;
    border-radius: 10px;
  }

  .input-hint {
    font-size: 10px;
    margin-top: 4px;
  }

  /* Lists */
  .list-item {
    padding: 6px 10px;
    font-size: 12px;
  }

  .speak-btn {
    font-size: 10px;
    padding: 2px 8px;
  }

  /* Modals — full-screen friendly */
  .modal-overlay {
    padding: 10px;
    align-items: flex-start;
    padding-top: 20px;
  }

  .modal-content.glass {
    padding: 20px;
    border-radius: 16px;
    max-height: 95vh;
    max-height: 95dvh;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Notification dropdown — mobile friendly */
  .notif-dropdown {
    position: fixed;
    top: 54px;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: 60vh;
    border-radius: 12px;
  }

  .notif-bell {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .sidebar-toggle {
    width: 34px;
    height: 34px;
    font-size: 18px;
  }
}

/* ── Very Small Devices (below 400px) — iPhone SE, Galaxy Fold ── */
@media (max-width: 400px) {

  header {
    height: 50px;
  }

  .header-left {
    gap: 6px;
  }

  .flag-icon {
    display: none;
  }

  .brand-text h1 {
    font-size: 14px;
  }

  .brand-text span {
    display: none;
  }

  .lang-selector {
    gap: 1px;
    padding: 2px;
  }

  .lang-btn {
    padding: 3px 5px;
    min-width: 26px;
    font-size: 10px;
  }

  .btn-ghost {
    padding: 3px 6px;
    font-size: 9px;
  }

  .welcome-card {
    padding: 16px 12px;
  }

  .welcome-card h2 {
    font-size: 16px;
  }

  .welcome-card p {
    font-size: 12px;
  }

  .send-btn,
  .mic-btn {
    width: 38px;
    height: 38px;
    font-size: 15px;
  }

  #question-input {
    padding: 8px 10px;
    font-size: 16px;
  }

  .auto-read-toggle {
    display: none;
  }

  .notif-bell {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .sidebar-toggle {
    width: 30px;
    height: 30px;
    font-size: 16px;
  }

  .bubble {
    max-width: 92%;
    font-size: 12.5px;
    padding: 8px 10px;
  }

  .avatar {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .scheme-title {
    font-size: 12px;
  }

  .chip {
    padding: 4px 10px;
    font-size: 10px;
  }
}

/* ── Ultra-small (below 320px) — Galaxy Fold closed ── */
@media (max-width: 320px) {
  header {
    height: 46px;
    padding: 0 8px;
  }

  .brand-text h1 {
    font-size: 12px;
  }

  .sidebar-toggle {
    width: 28px;
    height: 28px;
    font-size: 14px;
    border-radius: 6px;
  }

  .lang-selector {
    display: none;
  }

  .input-area {
    padding: 6px 6px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }

  .send-btn,
  .mic-btn {
    width: 34px;
    height: 34px;
    font-size: 14px;
    border-radius: 8px;
  }

  #question-input {
    padding: 7px 8px;
    font-size: 16px;
    border-radius: 8px;
  }

  .input-hint {
    display: none;
  }

  .sidebar {
    width: 250px;
  }

  .welcome-card {
    padding: 12px 10px;
  }

  .welcome-card h2 {
    font-size: 14px;
  }

  .welcome-card p {
    font-size: 11px;
  }

  .chat-container {
    padding: 8px 6px;
    gap: 8px;
  }
}

/* ── Landscape Responsiveness (when device is rotated) ── */
@media (max-height: 500px) and (orientation: landscape) {

  header {
    height: 44px;
    padding: 0 12px;
  }

  .brand-text h1 {
    font-size: 15px;
  }

  .brand-text span {
    display: none;
  }

  .suggestions-bar {
    padding: 4px 10px;
  }

  .chip {
    padding: 3px 10px;
    font-size: 11px;
  }

  /* Welcome Card */
  .welcome-card {
    padding: 10px 16px;
    margin: 5px auto 0;
    max-width: 70%;
  }

  .welcome-card .wheel {
    display: none;
  }

  .welcome-card h2 {
    font-size: 15px;
    margin-bottom: 2px;
  }

  .welcome-card p {
    font-size: 11px;
    line-height: 1.4;
  }

  /* Chat */
  .chat-container {
    padding: 8px 10px;
    gap: 6px;
  }

  /* Input */
  .input-area {
    padding: 6px 10px;
  }

  #question-input {
    padding: 6px 10px;
    max-height: 60px;
  }

  .send-btn,
  .mic-btn {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .input-hint {
    display: none;
  }
}

/* ══════════════════════════════════════════════════════════════════
   ── TOUCH DEVICE OPTIMIZATIONS ──
   ══════════════════════════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {

  /* Touch devices: always show history menu buttons */
  .history-menu-btn {
    display: flex;
  }

  /* Bigger touch targets */
  .chip {
    padding: 8px 14px;
    min-height: 36px;
    display: flex;
    align-items: center;
  }

  .history-item {
    padding: 12px 12px;
    padding-right: 34px;
    min-height: 44px;
  }

  .new-chat-btn {
    min-height: 44px;
  }

  .dropdown-item {
    min-height: 44px;
  }

  .notif-item {
    min-height: 48px;
  }
}