/* ==================== FRONTEND/CSS/LAYOUT.CSS ==================== */

/* ==================== LEFT SIDEBAR ==================== */

.sidebar {
  width: 320px;
  min-width: 300px;
  max-width: 360px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100vh;
  min-height: 0;
  overflow: hidden;
  z-index: 10;
  user-select: none;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, transform 0.25s ease;
}

.sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  padding: 0 !important;
  border-right: none !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.sidebar-header {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #6366F1 0%, #38BDF8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.38);
}

.brand-text h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-free {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #ec4899, #8b5cf6);
  color: #fff;
  letter-spacing: 0.5px;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* ==================== PROJECT WORKSPACE SELECTOR ==================== */
.project-workspace-selector {
  position: relative;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(14, 18, 28, 0.45);
}

.project-selector-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.project-selector-btn:hover {
  background: rgba(255, 255, 255, 0.065);
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.project-selector-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.project-icon-badge {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  flex-shrink: 0;
}

.project-title-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.project-subtitle {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--accent-cyan);
  text-transform: uppercase;
}

.project-current-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 145px;
}

.project-selector-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.project-doc-badge {
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.project-arrow {
  font-size: 9px;
  color: var(--text-dim);
  transition: transform 0.2s ease;
}

.project-dropdown-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 12px;
  right: 12px;
  background: rgba(18, 22, 34, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65);
  z-index: 100;
  overflow: hidden;
  animation: popoverFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.project-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.25);
}

.btn-create-project-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn-create-project-mini:hover {
  opacity: 0.9;
}

.project-dropdown-list {
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  cursor: pointer;
}

.project-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.project-dropdown-item.active-project {
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.28);
}

.project-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.project-item-icon {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  flex-shrink: 0;
}

.project-item-texts {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.project-item-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-item-meta {
  font-size: 9.5px;
  color: var(--text-dim);
}

.project-item-check {
  font-size: 10px;
  margin-right: 4px;
}

.project-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.project-dropdown-item:hover .project-item-actions {
  opacity: 1;
}

.btn-delete-project:hover {
  color: var(--accent-red) !important;
}

/* ==================== SIDEBAR SEGMENTED TABS (AI STUDIO VIBE) ==================== */
.sidebar-tab-row {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px;
  border-bottom: 1px solid var(--border-color);
  gap: 4px;
}

.sidebar-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-tab.active {
  background: var(--bg-card);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sidebar-tab.active i {
  color: var(--accent-cyan, #38bdf8);
}

.sidebar-tab#tabSidebarHistory.active i {
  color: var(--primary, #8b5cf6);
}

.sidebar-tab .tab-badge {
  font-size: 9.5px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  padding: 1px 5px;
  border-radius: var(--radius-full);
}

.sidebar-tab.active .tab-badge {
  background: var(--primary);
  color: #fff;
}

.sidebar-tab-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sidebar-tab-content.hidden {
  display: none !important;
}

/* PLAYGROUND TOP BANNER & RESET ACTION */
.playground-top-banner {
  padding: 8px 14px 2px;
}

.btn-clean-playground {
  width: 100%;
  padding: 6px 10px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-sm);
  color: var(--accent-cyan, #38bdf8);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-clean-playground:hover {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent-cyan, #38bdf8);
  color: #fff;
  transform: translateY(-1px);
}

/* HISTORY SIDEBAR CONTROLS & LIST */
.history-sidebar-controls {
  padding: 10px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.btn-history-new-chat {
  width: 100%;
  padding: 7px 12px;
  background: var(--primary-glow, rgba(139, 92, 246, 0.15));
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-history-new-chat:hover {
  background: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.history-search-box {
  margin: 0 !important;
  flex-shrink: 0;
}

.sidebar-history-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.sidebar-history-list::-webkit-scrollbar {
  width: 5px;
}

.sidebar-history-list::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 4px;
}

.sidebar-history-list::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.45);
}

.sidebar-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 8px;
}

.sidebar-history-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.sidebar-history-item.active {
  background: rgba(139, 92, 246, 0.14);
  border-color: rgba(139, 92, 246, 0.4);
  border-left: 3px solid var(--primary);
}

.sidebar-history-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-history-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-history-item.active .sidebar-history-title {
  color: #fff;
  font-weight: 600;
}

.sidebar-history-meta {
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 5px;
}

.sidebar-history-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.sidebar-history-item:hover .sidebar-history-actions,
.sidebar-history-item.active .sidebar-history-actions {
  opacity: 1;
}

.btn-history-action {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 10.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-history-action:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

.btn-history-action.btn-del:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

/* UPLOAD SECTION */
.upload-section {
  padding: 10px 14px 6px;
}

.dropzone {
  border: 1px dashed rgba(139, 92, 246, 0.35);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  background-color: rgba(22, 25, 36, 0.5);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background-color: rgba(139, 92, 246, 0.08);
  transform: translateY(-1px);
}

.drop-icon {
  font-size: 16px;
  color: var(--primary);
  margin-bottom: 2px;
}

.dropzone-content p {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 1px;
}

.dropzone-content span {
  font-size: 10px;
  color: var(--text-muted);
}

/* GDRIVE SIDEBAR BUTTON */
.btn-gdrive-sidebar {
  width: 100%;
  margin-top: 6px;
  padding: 6px 10px;
  background: rgba(66, 133, 244, 0.08);
  border: 1px solid rgba(66, 133, 244, 0.25);
  border-radius: var(--radius-sm);
  color: #8ab4f8;
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-gdrive-sidebar:hover {
  background: rgba(66, 133, 244, 0.18);
  border-color: #4285f4;
  color: #fff;
  transform: translateY(-1px);
}

/* GDRIVE CHAT INPUT PILL */
.btn-gdrive-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #8ab4f8 !important;
}

/* SIDEBAR DOCUMENTS SEARCH BOX */
.sidebar-search-box {
  position: relative;
  display: flex;
  align-items: center;
  margin: 10px 14px 4px;
}

.sidebar-search-box .search-icon {
  position: absolute;
  left: 10px;
  font-size: 12px;
  color: var(--text-dim);
  pointer-events: none;
}

.sidebar-search-box input {
  width: 100%;
  background: rgba(11, 13, 20, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 6px 30px 6px 30px;
  color: var(--text-main);
  font-size: 12px;
  outline: none;
  transition: all 0.2s ease;
}

.sidebar-search-box input:focus {
  border-color: var(--primary);
  background: rgba(16, 18, 28, 0.95);
  box-shadow: 0 0 10px var(--primary-glow);
}

.sidebar-search-box .btn-clear-search {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 11px;
}

.sidebar-search-box .btn-clear-search:hover {
  color: var(--text-main);
}
.btn-gdrive-pill:hover {
  background: rgba(66, 133, 244, 0.15) !important;
  color: #fff !important;
}
.btn-gdrive-text {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-main);
}

/* MODAL GOOGLE DRIVE PICKER */
.modal-gdrive {
  width: 680px;
  max-width: 95vw;
  height: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.gdrive-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.gdrive-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.gdrive-brand-icon {
  font-size: 24px;
  color: #4285f4;
}
.gdrive-header-title h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}
.gdrive-user-badge {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.modal-card.modal-gdrive {
  width: 660px !important;
  max-width: 95vw !important;
  height: 85vh !important;
  max-height: 740px !important;
  display: flex !important;
  flex-direction: column !important;
}

.gdrive-compact-toolbar {
  display: flex;
  flex-direction: column;
  background: rgba(18, 20, 29, 0.7);
  border-bottom: 1px solid var(--border-color);
}

.gdrive-toolbar-row1 {
  padding: 8px 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.gdrive-search-box {
  flex: 1;
  min-width: 160px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  color: var(--text-dim);
}

.gdrive-search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 12px;
  width: 100%;
}

.btn-clear-search {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
}

.gdrive-quick-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-gdrive-upload {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.btn-gdrive-upload:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--primary);
}

.gdrive-sort-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px 6px;
}

.gdrive-sort-icon {
  font-size: 10.5px;
  color: var(--text-dim, #64748b);
}

.gdrive-sort-select {
  background: transparent;
  border: none;
  color: var(--text-main, #f8fafc);
  font-size: 10.5px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  padding: 3px 0;
}

.gdrive-sort-select option {
  background: #0f172a;
  color: #f8fafc;
}

.gdrive-toolbar-row2 {
  padding: 6px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(22, 25, 36, 0.4);
}

.gdrive-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-dim);
  overflow-x: auto;
  white-space: nowrap;
}

.breadcrumb-item {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.breadcrumb-item:hover {
  color: #8ab4f8;
  text-decoration: underline;
}

.breadcrumb-sep {
  color: var(--text-muted);
  font-size: 9px;
}

.gdrive-filter-pills {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.gdrive-filter-pill {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  font-size: 10.5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.gdrive-filter-pill:hover, .gdrive-filter-pill.active {
  background: rgba(66, 133, 244, 0.15);
  border-color: #4285f4;
  color: #8ab4f8;
}

.gdrive-file-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 12px;
}

.gdrive-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  height: 42px;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  border: 1px solid transparent;
  margin-bottom: 2px;
}

.gdrive-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.gdrive-item.selected {
  background: rgba(66, 133, 244, 0.12);
  border-color: rgba(66, 133, 244, 0.4);
}

.gdrive-item-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.icon-folder { color: #fbbc04; }
.icon-doc { color: #4285f4; }
.icon-sheet { color: #0f9d58; }
.icon-slide { color: #f4b400; }
.icon-pdf { color: #ea4335; }
.icon-image { color: #ab47bc; }
.icon-other { color: #9aa0a6; }

.gdrive-item-info {
  flex: 1;
  min-width: 0;
}

.gdrive-item-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.gdrive-item-meta {
  font-size: 10.5px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
  line-height: 1.2;
}
.gdrive-modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
}
.gdrive-selection-info {
  font-size: 12px;
  color: var(--text-dim);
}
.gdrive-footer-buttons {
  display: flex;
  gap: 8px;
}

.upload-progress {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--primary);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(139, 92, 246, 0.3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* SOURCES LIST HEADER (MODERN COMPACT TOOLBAR) */
.sources-header {
  padding: 10px 14px 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.sources-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sources-header-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim, #888888);
  letter-spacing: 0.8px;
}

.sources-count-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: rgba(0, 120, 212, 0.12);
  color: var(--primary, #0078D4);
  border: 1px solid rgba(0, 120, 212, 0.25);
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}

.sources-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.btn-sources-quick {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color, #333333);
  color: var(--text-muted, #999999);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sources-quick:hover {
  background: rgba(0, 120, 212, 0.15);
  border-color: var(--primary, #0078D4);
  color: var(--primary, #0078D4);
}

.text-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.text-link:hover {
  text-decoration: underline;
}

.sep { color: var(--text-dim); }

/* SOURCES LIST ITEMS */
.sources-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-gutter: stable;
}

.empty-sources {
  padding: 30px 10px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

.source-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  gap: 8px;
}

.source-item:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.source-item.active-source {
  border-left: 3px solid var(--primary);
}

.source-item.inactive-source {
  opacity: 0.45;
}

.source-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.source-checkbox {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex-shrink: 0;
}

.file-ext-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background-color: rgba(255, 255, 255, 0.1);
  font-family: var(--font-mono);
  color: #fff;
  flex-shrink: 0;
}

.file-ext-badge.pdf { background-color: #dc2626; }
.file-ext-badge.md { background-color: #2563eb; }
.file-ext-badge.txt { background-color: #4b5563; }
.file-ext-badge.docx { background-color: #1d4ed8; }

.source-info {
  flex: 1;
  min-width: 0;
}

.source-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.35;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 2.7em;
}

.source-meta {
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.source-controls {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  margin-left: 2px;
}

.source-controls .icon-btn {
  width: 24px;
  height: 24px;
  font-size: 11px;
  color: var(--text-dim);
  border-radius: 4px;
  transition: all 0.15s ease;
}

.source-controls .icon-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.source-controls .btn-delete-doc:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}

/* SIDEBAR FOOTER */
.sidebar-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gcp-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background-color: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
}



/* ==================== BOTTOM INTERACTION BAR (OPENROUTER PRECISION) ==================== */

.bottom-bar {
  padding: 10px 20px 16px;
  background: linear-gradient(to top, var(--bg-dark) 85%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  position: relative;
}

/* BOTTOM MODE TABS ROW */
.bottom-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0;
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

.mode-tabs {
  display: flex;
  background-color: rgba(16, 21, 34, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-full);
  padding: 3px;
  border: 1px solid var(--border-color);
  border-top: 1px solid var(--border-glass-specular);
  position: relative;
  z-index: 15;
}

.mode-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  outline: none;
}

/* Make child elements of all buttons pass through clicks to the button itself */
button * {
  pointer-events: none;
}

.mode-tab:hover {
  color: var(--text-bright);
  background-color: rgba(255, 255, 255, 0.06);
}

.mode-tab.active {
  background: linear-gradient(135deg, #6366F1, #4F46E5) !important;
  color: #fff !important;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.45);
}

.input-context-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

.context-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-green);
  transition: all 0.2s ease;
  display: inline-block;
  flex-shrink: 0;
}

.context-indicator.online {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.context-indicator.warning {
  background-color: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
  animation: pulse-amber 1.8s infinite ease-in-out;
}

.context-indicator.dim {
  background-color: #6b7280;
  box-shadow: none;
  opacity: 0.7;
}

@keyframes pulse-amber {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

/* INPUT BOX WRAPPER (AMBIENT OBSIDIAN FLOATING CARD - 1000PX) */
.input-wrapper {
  background-color: rgba(16, 21, 34, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-top: 1px solid var(--border-glass-specular);
  border-radius: var(--radius-lg);
  padding: 12px 14px 10px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 30;
  width: 100%;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

.input-wrapper:focus-within {
  border-color: var(--primary);
  border-top-color: var(--accent-cyan);
  box-shadow: 0 0 0 1px var(--primary), 0 12px 38px rgba(0, 0, 0, 0.65), 0 0 20px var(--primary-glow);
}

#chatInput {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  min-height: 24px;
  max-height: 140px;
}

/* BOTTOM CONTROLS ROW INSIDE INPUT */
.input-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  height: 36px;
  box-sizing: border-box;
}

.input-controls-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.control-trigger-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.btn-control-icon {
  height: 30px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-top: 1px solid var(--border-glass-specular);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  padding: 0 10px;
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-sizing: border-box;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-control-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-bright);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-control-icon.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: var(--primary);
  color: #c4b5fd;
}

.btn-control-icon.btn-voice {
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0;
  border-radius: var(--radius-sm, 6px);
}

.btn-model-pill {
  border-color: rgba(99, 102, 241, 0.35);
  color: #e5e7eb;
}

.icon-model-bolt {
  color: var(--accent-cyan);
}

.nav-chevron-sm {
  font-size: 9px;
  color: var(--text-dim);
  margin-left: 2px;
}

.tools-active-badge {
  background: var(--accent-green);
  color: #000;
  font-size: 9px;
  font-weight: 700;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-send {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: var(--radius-sm, 6px);
  background: linear-gradient(135deg, #6366F1, #4F46E5);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
  font-size: 12px;
  box-sizing: border-box;
}

.btn-send:hover:not(:disabled) {
  background: linear-gradient(135deg, #4F46E5, #4338CA);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.5);
  transform: translateY(-0.5px);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-send.btn-stop-generating {
  background: #ef4444 !important;
  color: #fff !important;
  animation: pulseStopBtn 1.5s infinite;
}

.btn-send.btn-stop-generating:hover {
  background: #dc2626 !important;
  transform: scale(1.05);
}

@keyframes pulseStopBtn {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.chat-error-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 12.5px;
  line-height: 1.45;
  margin: 6px 0;
}

.chat-error-card strong {
  color: #ef4444;
  display: block;
  margin-bottom: 2px;
}



/* ==================== UPWARD POPOVER MENUS ==================== */

.popover-menu {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  background-color: var(--bg-popover);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), 0 0 24px rgba(139, 92, 246, 0.18);
  width: 320px;
  z-index: 1000;
  animation: popoverSlideUp 0.18s ease-out;
  overflow: hidden;
  pointer-events: auto;
}

.popover-menu.popover-tools { width: 340px; }
.popover-menu.popover-si { width: 440px; }
.popover-menu.popover-params { width: 350px; }

@keyframes popoverSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.popover-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.popover-body {
  padding: 10px 14px;
  max-height: 320px;
  overflow-y: auto;
}

.popover-list {
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.popover-item {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s ease;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
}

.popover-item:hover {
  background-color: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.3);
}

.popover-item.active {
  background-color: rgba(139, 92, 246, 0.2);
  border-color: var(--primary);
}

.model-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-item-name {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.model-item-desc {
  font-size: 10.5px;
  color: var(--text-dim);
}

.popover-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 6px;
}

.popover-input {
  flex: 1;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 11.5px;
  padding: 5px 8px;
  outline: none;
}

.btn-popover-sm {
  background-color: var(--primary);
  color: #fff;
  border: none;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

/* TOOL SWITCH ROWS IN POPOVER & RUN SETTINGS */
.tool-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm, 6px);
  gap: 12px;
  box-sizing: border-box;
}

.tool-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tool-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-bright);
  display: flex;
  align-items: center;
  gap: 7px;
}

.tool-desc {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* TOGGLE SWITCH */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .2s;
  border-radius: 18px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--accent-green);
}

input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

.url-inline-box {
  margin-top: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.url-inline-status {
  font-size: 11px;
  color: var(--accent-green);
  margin-top: 4px;
}

/* SI POPOVER STYLING */
.si-controls-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.popover-select {
  flex: 1;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: rgba(18, 24, 38, 0.95);
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2214%22%20height%3D%2214%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%2394A3B8%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm, 6px);
  color: #F1F5F9;
  padding: 8px 30px 8px 12px;
  font-size: 12px;
  font-weight: 500;
  outline: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.popover-select:hover {
  background-color: rgba(26, 34, 52, 0.98);
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.2);
}

.popover-select:focus {
  background-color: rgba(18, 24, 38, 0.98);
  border-color: var(--primary);
  border-top-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3), 0 6px 18px rgba(0, 0, 0, 0.5);
}

.popover-select option {
  background-color: #111522;
  color: #E2E8F0;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 500;
}

.si-actions-mini {
  display: flex;
  gap: 3px;
}

.icon-btn-sm {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
}

.icon-btn-sm:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.popover-textarea {
  width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  padding: 8px;
  resize: vertical;
  outline: none;
}

.saved-badge-sm {
  font-size: 10px;
  color: var(--accent-green);
  background: rgba(16, 185, 129, 0.1);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
}

/* PARAMS POPOVER STYLING */
.params-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.param-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.param-label {
  font-size: 11px;
  color: var(--text-muted);
}

.param-slider-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.slider-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.slider-val-sm {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-cyan);
}

.form-range-sm {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  margin: 4px 0 2px;
}

.form-range-sm::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid var(--primary, #6366F1);
  box-shadow: 0 0 6px rgba(99, 102, 241, 0.6);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.form-range-sm::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid var(--primary, #6366F1);
  box-shadow: 0 0 6px rgba(99, 102, 241, 0.6);
  cursor: pointer;
}

.form-range-sm:hover::-webkit-slider-thumb {
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.85);
}

.form-range-sm:hover::-moz-range-thumb {
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.85);
}

.text-link-sm {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.text-link-sm:hover { text-decoration: underline; }

.text-link-danger {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.15s ease;
}

.text-link-danger:hover {
  opacity: 0.8;
  text-decoration: underline;
}



/* ==================== BUTTONS & CONTROLS ==================== */

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 12px var(--primary-glow);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-nav-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-top: 1px solid var(--border-glass-specular);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-nav-home:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
  transform: translateY(-0.5px);
}

.btn-nav-new-chat {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #6366F1, #4F46E5);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 769px) {
  /* Hide + New Chat in top nav on desktop, since left sidebar has prominent + New Chat button */
  .btn-nav-new-chat {
    display: none !important;
  }
}

@media (max-width: 768px) {
  /* Show + New Chat in top nav on mobile */
  .btn-nav-new-chat {
    display: inline-flex !important;
  }
}

.btn-nav-new-chat:hover {
  background: linear-gradient(135deg, #4F46E5, #4338CA);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.5);
  transform: translateY(-0.5px);
}

.btn-nav-export-toggle {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-top: 1px solid var(--border-glass-specular);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-nav-export-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-bright);
}

.btn-nav-tuning-toggle {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  color: #C7D2FE;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-nav-tuning-toggle:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 10px var(--primary-glow);
  transform: translateY(-0.5px);
}



/* ==================== SEAMLESS EXPANDABLE NAVBAR CHAT SEARCH ==================== */

.nav-chat-search-capsule {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 32px;
  width: 160px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-top: 1px solid var(--border-glass-specular);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
  transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.18s ease,
              border-color 0.18s ease,
              box-shadow 0.18s ease;
  user-select: none;
  flex-shrink: 0;
  box-sizing: border-box;
}

.nav-chat-search-capsule:hover:not(.is-expanded) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.nav-chat-search-capsule.is-expanded {
  width: 360px;
  background: var(--bg-popover);
  border-color: var(--primary);
  border-top-color: var(--accent-cyan);
  box-shadow: 0 0 0 1px var(--primary), 0 8px 28px rgba(0, 0, 0, 0.65), 0 0 16px var(--primary-glow);
}

/* TRIGGER BUTTON (COLLAPSED STATE) */
.btn-nav-search-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  padding: 0 8px 0 10px;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  outline: none;
  box-sizing: border-box;
}

.btn-nav-search-toggle i {
  font-size: 11.5px;
  color: var(--text-muted);
  transition: color 0.15s ease;
  flex-shrink: 0;
}

.nav-chat-search-capsule:hover .btn-nav-search-toggle i {
  color: var(--text-bright);
}

.nav-search-label {
  font-size: 12px;
  color: var(--text-main);
  font-weight: 500;
  line-height: 1;
}

.nav-search-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-family: var(--font-sans);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 3px;
  padding: 0 4px;
  height: 16px;
  line-height: 16px;
  color: var(--text-muted);
  margin-left: auto;
  font-weight: 500;
  flex-shrink: 0;
  letter-spacing: 0.2px;
}

.nav-chat-search-capsule.is-expanded .btn-nav-search-toggle {
  display: none !important;
}

/* EXPANDED CONTENT CONTAINER */
.nav-chat-search-expanded {
  display: none;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 0 4px 0 10px;
  gap: 6px;
  box-sizing: border-box;
}

.nav-chat-search-capsule.is-expanded .nav-chat-search-expanded {
  display: flex;
  animation: navSearchFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes navSearchFadeIn {
  from { opacity: 0; transform: translateX(4px); }
  to { opacity: 1; transform: translateX(0); }
}

.nav-search-icon {
  font-size: 12px;
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.nav-chat-search-expanded input {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-bright);
  font-size: 12.5px;
  padding: 0 2px;
}

.nav-chat-search-expanded input::placeholder {
  color: var(--text-dim);
  font-size: 12px;
}

.chat-search-counter {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.2;
  user-select: none;
}

.nav-search-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.btn-nav-search-nav {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  cursor: pointer;
  transition: all 0.12s ease;
  padding: 0;
  outline: none;
}

.btn-nav-search-nav:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-bright);
}

.btn-nav-search-close:hover {
  background: rgba(248, 81, 73, 0.18) !important;
  color: var(--accent-red) !important;
}

/* CHAT HIGHLIGHT MATCHES (ANTIGRAVITY THEME) */
.chat-search-match {
  background: rgba(187, 128, 9, 0.35) !important;
  color: #CCCCCC !important;
  border-radius: 2px;
  padding: 1px 4px;
}

.chat-search-match.current {
  background: #9E6A03 !important;
  color: #FFFFFF !important;
  font-weight: 600;
  outline: 1px solid #BB8009;
  border-radius: 2px;
}

.message-wrapper.search-focused-msg {
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 2px var(--primary), 0 0 14px var(--primary-glow) !important;
  transition: all 0.2s ease;
}

@keyframes tuningFadeIn {
  from { opacity: 0; transform: scale(0.96) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.tuning-modal-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: rgba(22, 25, 38, 0.7);
}

.tuning-modal-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tuning-icon-circle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  box-shadow: 0 0 16px var(--primary-glow);
}

.tuning-modal-title h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  letter-spacing: -0.2px;
}

.tuning-sub {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  margin-top: 1px;
}

/* TUNING TAB BAR */
.tuning-tabs {
  display: flex;
  background: #0f111c;
  border-bottom: 1px solid var(--border-color);
  padding: 6px 12px;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tuning-tabs::-webkit-scrollbar {
  display: none;
}

.tuning-tab {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 6px);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tuning-tab:hover {
  color: var(--text-bright);
  background: rgba(255, 255, 255, 0.05);
}

.tuning-tab.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

.tuning-sidebar {
  width: 360px;
  min-width: 320px;
  max-width: 420px;
  background-color: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 10;
  user-select: none;
  animation: slideInRight 0.2s ease-out;
}

.tuning-body {
  padding: 14px 16px;
  overflow-y: auto;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  max-height: none !important;
}

.tuning-pane {
  display: block;
  animation: tabFadeIn 0.2s ease-out;
}

.tuning-pane.hidden {
  display: none;
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}



/* ==================== MOBILE RESPONSIVE OPTIMIZATIONS ==================== */

.nav-brand-title-mobile {
  display: none !important;
}

@media (max-width: 768px) {
  /* TOP NAV */
  .top-nav {
    padding: 6px 10px;
    gap: 6px;
    min-height: 48px;
    align-items: center;
  }

  .nav-left {
    gap: 6px;
    flex: 1;
    min-width: 0;
    align-items: center;
  }

  body:not(.is-in-chat) #btnNavHomeHub,
  body.is-home-hub #btnNavHomeHub {
    display: none !important;
  }
  body:not(.is-in-chat) #sessionTitleNavWrap,
  body.is-home-hub #sessionTitleNavWrap {
    display: none !important;
  }
  body:not(.is-in-chat) #navChatSearchCapsule,
  body.is-home-hub #navChatSearchCapsule {
    display: none !important;
  }
  body:not(.is-in-chat) .nav-brand-title-mobile,
  body.is-home-hub .nav-brand-title-mobile {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    color: var(--text-main, #f8fafc) !important;
    letter-spacing: -0.01em !important;
  }

  body.is-in-chat .nav-brand-title-mobile {
    display: none !important;
  }
  body.is-in-chat #btnNavHomeHub {
    display: inline-flex !important;
  }
  body.is-in-chat #sessionTitleNavWrap {
    display: inline-flex !important;
  }
  body.is-in-chat #navChatSearchCapsule {
    display: inline-flex !important;
  }

  .btn-nav-home {
    display: inline-flex !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    padding: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: var(--radius-sm, 8px) !important;
    flex-shrink: 0 !important;
  }
  .btn-nav-home span,
  .btn-nav-home .btn-nav-text {
    display: none !important;
  }

  #btnNavTuningHub,
  .btn-nav-tuning-hub {
    display: none !important;
  }

  .session-title-wrap,
  .session-pill {
    max-width: 180px;
    padding: 4px 8px;
    gap: 6px;
    height: 32px;
    flex: 1;
    min-width: 0;
  }

  .session-title-icon,
  .session-icon {
    font-size: 12px;
  }

  .session-title-label {
    font-size: 12px;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-chevron {
    font-size: 9px;
  }

  @media (max-width: 600px) {
    .nav-token-widget-wrap {
      display: none !important;
    }
    .session-title-wrap {
      max-width: 160px !important;
    }
  }

  /* TOP NAV RIGHT: ULTRA-COMPACT 32px ICON BUTTONS */
  .nav-right {
    gap: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
  }

  .nav-right > button,
  .nav-right > .nav-dropdown-wrapper > button.btn-nav-export-toggle {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: var(--radius-sm) !important;
    font-size: 13px !important;
    position: relative !important;
    flex-shrink: 0 !important;
  }

  .nav-right > .nav-chat-search-capsule:not(.is-expanded) {
    width: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    padding: 0 !important;
  }

  .nav-right > .nav-chat-search-capsule:not(.is-expanded) .btn-nav-search-toggle {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    justify-content: center !important;
  }

  .nav-right > .nav-chat-search-capsule:not(.is-expanded) .btn-nav-search-toggle .nav-search-label,
  .nav-right > .nav-chat-search-capsule:not(.is-expanded) .btn-nav-search-toggle .nav-search-kbd {
    display: none !important;
  }

  .nav-right > .nav-chat-search-capsule.is-expanded {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    left: 8px !important;
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    z-index: 1200 !important;
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--primary) !important;
  }

  .nav-right > button > span:not(.notes-count-badge),
  .nav-right > .nav-dropdown-wrapper > button.btn-nav-export-toggle > span,
  .nav-right > .nav-dropdown-wrapper > button.btn-nav-export-toggle > .nav-dropdown-arrow {
    display: none !important;
  }

  .btn-notes-toggle .notes-count-badge {
    position: absolute !important;
    top: -3px !important;
    right: -3px !important;
    padding: 1px 4px !important;
    font-size: 8.5px !important;
    min-width: 14px !important;
    height: 14px !important;
    border-radius: var(--radius-full) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    background: var(--primary) !important;
    border: 1px solid var(--bg-dark) !important;
  }

  /* EXPORT POPOVER ON MOBILE */
  .nav-export-popover {
    position: absolute !important;
    top: calc(100% + 6px) !important;
    right: 0 !important;
    width: 250px !important;
    max-width: calc(100vw - 20px) !important;
    z-index: 1000 !important;
    padding: 6px !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6) !important;
  }

  .nav-export-popover .export-popover-item {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    height: auto !important;
    min-height: 44px !important;
    padding: 8px 10px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    background: transparent !important;
    border: none !important;
    border-radius: var(--radius-sm) !important;
    text-align: left !important;
    box-sizing: border-box !important;
  }

  .nav-export-popover .export-popover-item:hover,
  .nav-export-popover .export-popover-item:active {
    background: rgba(255, 255, 255, 0.08) !important;
  }

  .nav-export-popover .export-item-texts {
    display: flex !important;
    flex-direction: column !important;
    gap: 1px !important;
    flex: 1 !important;
  }

  .nav-export-popover .export-item-texts span,
  .nav-export-popover .export-item-title,
  .nav-export-popover .export-item-sub {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .nav-export-popover .export-item-title {
    font-size: 12px !important;
    font-weight: 600 !important;
    color: var(--text-main) !important;
    line-height: 1.3 !important;
  }

  .nav-export-popover .export-item-sub {
    font-size: 10px !important;
    color: var(--text-dim) !important;
    line-height: 1.2 !important;
  }

  /* MAIN AREA & PINNED BOTTOM BAR (ANTI-ADDRESS BAR OVERLAP) */
  .main-area {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  .chat-container {
    flex: 1 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    scroll-behavior: smooth !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 12px 18px 8px !important;
  }

  .messages-list {
    padding-bottom: 11rem !important; /* ~176px - 180px safe clearance above floating input bar */
  }

  .bottom-bar {
    padding: 8px 18px max(12px, env(safe-area-inset-bottom)) !important;
    flex-shrink: 0 !important;
    background: var(--bg-dark) !important;
    position: relative !important;
    z-index: 30 !important;
  }

  /* MODERN BALANCED MOBILE WELCOME SCREEN */
  .welcome-screen {
    padding: 24px 10px 14px !important;
    margin: auto 0 !important;
    max-width: 100% !important;
  }

  .welcome-badge {
    margin-bottom: 8px !important;
    font-size: 10.5px !important;
    padding: 3px 9px !important;
  }

  .welcome-screen h1 {
    font-size: 19px !important;
    font-weight: 700 !important;
    margin-bottom: 6px !important;
    line-height: 1.3 !important;
    letter-spacing: -0.3px !important;
  }

  .welcome-screen p {
    font-size: 12px !important;
    color: var(--text-muted) !important;
    margin-bottom: 18px !important;
    line-height: 1.45 !important;
    max-width: 480px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .feature-cards {
    grid-template-columns: 1fr !important;
    gap: 9px !important;
    max-width: 480px !important;
    margin: 0 auto !important;
  }

  .f-card {
    padding: 12px 14px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
    background: rgba(255, 255, 255, 0.025) !important;
    backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: var(--radius-md) !important;
    text-align: left !important;
    box-sizing: border-box !important;
  }

  .f-icon {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    border-radius: 8px !important;
    background: rgba(139, 92, 246, 0.12) !important;
    border: 1px solid rgba(139, 92, 246, 0.25) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 15px !important;
    color: var(--primary) !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
  }

  .f-text {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    flex: 1 !important;
    min-width: 0 !important;
  }

  .f-card h3 {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: var(--text-main) !important;
    margin: 0 !important;
    line-height: 1.3 !important;
  }

  .f-card p {
    font-size: 11px !important;
    color: var(--text-dim) !important;
    line-height: 1.35 !important;
    margin: 0 !important;
  }

  .message-content {
    font-size: 13.5px;
    line-height: 1.6;
  }

  .message-content ul,
  .message-content ol {
    padding-left: 18px !important;
    margin: 0 0 8px 0 !important;
  }

  .message-content li > ul,
  .message-content li > ol {
    padding-left: 14px !important;
  }

  .message-content blockquote {
    padding: 6px 10px !important;
    margin: 6px 0 !important;
    border-left-width: 2px !important;
  }

  .message-content blockquote blockquote {
    padding-left: 8px !important;
    margin: 4px 0 !important;
  }

  .message-content blockquote ul,
  .message-content blockquote ol {
    padding-left: 14px !important;
  }

  /* BOTTOM MODE ROW */
  .bottom-mode-row {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin-bottom: 5px;
  }

  .mode-tabs {
    width: 100%;
    display: flex;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 3px;
    box-sizing: border-box;
  }

  .mode-tab {
    flex: 1;
    justify-content: center;
    font-size: 11px;
    padding: 5px 6px;
    gap: 5px;
    border-radius: var(--radius-full);
  }

  .input-context-info {
    font-size: 10px;
    color: var(--text-dim);
    justify-content: center;
    padding-top: 1px;
  }

  .input-wrapper {
    padding: 6px 8px 5px;
    border-radius: var(--radius-md);
    overflow: visible !important;
  }

  #chatInput {
    font-size: 13.5px;
    min-height: 22px;
  }

  .input-bottom-bar {
    margin-top: 4px;
    padding-top: 4px;
    height: 36px;
  }

  .input-controls-left {
    overflow: visible !important;
    white-space: normal;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    display: flex;
  }

  .plus-action-popover,
  .quick-model-popover {
    z-index: 2500 !important;
  }

  .modal-tuning-hub {
    width: 95vw !important;
    max-width: 95vw !important;
  }

  .tuning-tabs {
    padding: 4px 6px !important;
    gap: 4px !important;
    overflow-x: auto !important;
  }

  .tuning-tab {
    min-width: 0 !important;
    padding: 7px 6px !important;
    font-size: 11px !important;
    gap: 4px !important;
  }

  /* POPOVERS TO BOTTOM SHEET */
  .popover-menu {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 80vh !important;
    z-index: 1000 !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.85) !important;
    animation: bottomSheetSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  @keyframes bottomSheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* MODALS & TUNING HUB ON MOBILE (BOTTOM SHEET DRAWER) */
  .modal-card, .modal-auth-card, .modal-gdrive {
    width: 95% !important;
    max-width: 95% !important;
    padding: 18px 14px !important;
  }

  .tuning-sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    right: 0 !important;
    left: auto !important;
    width: 85% !important;
    max-width: 360px !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    z-index: 1500 !important;
    background-color: var(--bg-sidebar) !important;
    border-left: 1px solid var(--border-color) !important;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.8) !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .tuning-sidebar.hidden {
    display: none !important;
  }

  .tuning-body {
    padding: 12px 14px !important;
    overflow-y: auto !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    max-height: none !important;
  }

  .btn-tuning-hub {
    padding: 0 8px !important;
    height: 30px !important;
    font-size: 11.5px !important;
  }

  /* SIDEBAR AS SLIDE-OUT DRAWER ON MOBILE */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 85% !important;
    max-width: 320px !important;
    z-index: 1000 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-shadow: none !important;
  }

  .sidebar.open {
    transform: translateX(0) !important;
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.85) !important;
  }

  /* NOTES SIDEBAR AS RIGHT SLIDE-OUT DRAWER ON MOBILE */
  .notes-sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    right: 0 !important;
    width: 90% !important;
    max-width: 360px !important;
    z-index: 1000 !important;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.85) !important;
  }
}



/* ==================== UNIFIED NAVBAR EXPORT POPOVER ==================== */

.nav-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.btn-nav-export-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.nav-dropdown-arrow {
  font-size: 9px;
}

.btn-nav-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-nav-home:hover {
  background: rgba(99, 102, 241, 0.18);
  border-color: var(--primary);
  color: #fff;
  transform: translateX(-1px);
}

/* ==================== USER PROFILE NAVBAR AVATAR & POPOVER ==================== */

.nav-user-dropdown-wrap {
  position: relative;
  display: inline-block;
  margin-left: 2px;
}

.btn-nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border-color);
  background: rgba(255, 255, 255, 0.06);
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: all 0.2s ease;
}

.btn-nav-avatar:hover {
  border-color: var(--primary);
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.nav-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nav-user-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 16px;
  z-index: 2000;
  animation: popoverFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-user-popover.hidden {
  display: none !important;
}

.user-popover-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.popover-avatar-lg {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--border-color);
  background: rgba(255, 255, 255, 0.05);
  object-fit: cover;
  flex-shrink: 0;
}

.user-popover-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.user-popover-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-popover-email {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.user-popover-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.badge-role {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-role-vip {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.badge-role-standard {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  border: 1px solid var(--border-color);
}

.badge-gdrive {
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.badge-gdrive-connected {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-gdrive-disconnected {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.user-popover-divider {
  height: 1px;
  background: var(--border-color);
  margin: 12px 0 10px;
}

.btn-popover-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  color: #f87171;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-popover-logout:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #fff;
  transform: translateY(-1px);
}



/* ==================== TURN 3: DECLUTTERED HISTORY, SCOPE & AT-MENTION ==================== */

.sidebar-history-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.history-filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: var(--radius-sm);
  margin: 4px 12px 6px;
  font-size: 11px;
  color: #c4b5fd;
  animation: fadeIn 0.15s ease-out;
}

.filter-banner-text {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.btn-reset-filter {
  background: transparent;
  border: none;
  color: #f43f5e;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.btn-reset-filter:hover {
  background: rgba(244, 63, 94, 0.15);
}

.session-workspace-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9.5px;
  font-weight: 600;
  color: #818cf8;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  padding: 1px 5px;
  border-radius: 4px;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-readonly-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(30, 27, 75, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-top: 1px solid rgba(129, 140, 248, 0.45);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  margin: 8px auto 14px;
  width: 100%;
  max-width: 1200px;
  box-sizing: border-box;
  gap: 16px;
  animation: fadeIn 0.2s ease-out;
}

.readonly-banner-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.readonly-lock-icon {
  font-size: 18px;
  color: #a78bfa;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(139, 92, 246, 0.15);
  border-radius: 8px;
  border: 1px solid rgba(139, 92, 246, 0.3);
  flex-shrink: 0;
}

.readonly-text-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.readonly-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.2px;
}

.readonly-sub {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.35;
}

.btn-teleport-workspace {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #6366F1, #4F46E5);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  transition: all 0.2s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-teleport-workspace:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.nav-dropdown-arrow {
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.btn-nav-export-toggle.active .nav-dropdown-arrow {
  transform: rotate(180deg);
}

.nav-export-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 250px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  padding: 6px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: fadeInDown 0.15s ease-out;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.export-popover-section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  padding: 6px 8px 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.export-popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
  width: 100%;
}

.export-popover-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.export-popover-item i {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.icon-export-md { color: var(--accent-blue, #60a5fa); }
.icon-export-pdf { color: var(--accent-red, #f87171); }
.icon-export-gdrive-md { color: var(--accent-cyan, #38bdf8); }
.icon-export-gdrive-pdf { color: var(--accent-green, #4ade80); }

.export-item-texts {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.export-item-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.export-item-sub {
  font-size: 10px;
  color: var(--text-dim);
}

.export-popover-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

/* ==================== TOP GLASS NANO LOADING BAR ==================== */
.top-nano-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2.5px;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #38bdf8, #a855f7);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7), 0 0 20px rgba(99, 102, 241, 0.5);
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.top-nano-loading-bar.is-loading {
  opacity: 1;
  width: 75%;
}

.top-nano-loading-bar.is-finishing {
  opacity: 1;
  width: 100%;
}
