:root {
  --bg-dark: #0f111a;
  --bg-card: #161824;
  --bg-card-hover: #1f2333;
  --bg-sidebar: #12141e;
  --bg-input: #151824;
  --bg-popover: #181b28;
  --bg-code: #10121c;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(139, 92, 246, 0.4);
  --border-hover: rgba(255, 255, 255, 0.16);
  
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --primary-glow: rgba(139, 92, 246, 0.25);
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  
  --font-sans: 'Inter', 'Roboto', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.15);
}

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

html, body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100%;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  width: 100%;
  overflow: hidden;
  position: fixed;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* APP CONTAINER */
.app-container {
  display: flex;
  height: 100%;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  width: 100vw;
  overflow: hidden;
}

/* ==================== 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%;
  z-index: 10;
  user-select: none;
}

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

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

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.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);
}

/* UPLOAD SECTION */
.upload-section {
  padding: 14px 18px;
}

.dropzone {
  border: 1px dashed rgba(139, 92, 246, 0.35);
  border-radius: var(--radius-md);
  padding: 14px;
  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: 20px;
  color: var(--primary);
  margin-bottom: 4px;
}

.dropzone-content p {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-main);
}

.dropzone-content span {
  font-size: 11px;
  color: var(--text-muted);
}

/* GDRIVE SIDEBAR BUTTON */
.btn-gdrive-sidebar {
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  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: 12px;
  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;
}
.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);
}
.gdrive-toolbar {
  padding: 10px 20px;
  background: rgba(18, 20, 29, 0.6);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.gdrive-search-box {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-dim);
}
.gdrive-search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 12.5px;
  width: 100%;
}
.btn-clear-search {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
}
.gdrive-filters {
  display: flex;
  gap: 4px;
}
.gdrive-filter-pill {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 11px;
  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-breadcrumbs {
  padding: 8px 20px;
  background: rgba(22, 25, 36, 0.4);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-dim);
  overflow-x: auto;
}
.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: 10px;
}
.gdrive-file-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 16px;
}
.gdrive-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 12.5px;
}
.gdrive-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  border: 1px solid transparent;
}
.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: 18px;
  width: 24px;
  text-align: center;
}
.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: 13px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gdrive-item-meta {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
}
.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 */
.sources-header {
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.sources-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.count-badge {
  background-color: var(--bg-card);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-size: 10px;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.sources-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.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 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.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;
}

.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;
}

.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;
}

.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: 12.5px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-meta {
  font-size: 10.5px;
  color: var(--text-dim);
  display: flex;
  gap: 6px;
}

.source-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* 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);
}

/* ==================== MAIN CHAT AREA ==================== */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--bg-dark);
  position: relative;
}

/* TOP NAV (MINIMALIST) */
.top-nav {
  height: 54px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background-color: rgba(15, 17, 26, 0.85);
  backdrop-filter: blur(12px);
  z-index: 5;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* SESSION PILL */
.session-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  max-width: 280px;
}

.session-pill:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}

.session-icon {
  font-size: 13px;
  color: var(--primary);
}

.session-title-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-chevron {
  font-size: 10px;
  color: var(--text-dim);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* CHAT CONTAINER */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16% 10px;
  display: flex;
  flex-direction: column;
}

@media (max-width: 1200px) {
  .chat-container { padding: 16px 8% 10px; }
}

/* WELCOME SCREEN */
.welcome-screen {
  margin: auto;
  max-width: 680px;
  text-align: center;
  padding: 40px 20px;
}

.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: rgba(139, 92, 246, 0.12);
  color: var(--primary);
  border: 1px solid rgba(139, 92, 246, 0.25);
  margin-bottom: 16px;
}

.welcome-screen h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

.welcome-screen p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 30px;
}

.feature-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  text-align: left;
}

.f-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.f-icon {
  font-size: 18px;
  color: var(--primary);
  margin-bottom: 8px;
}

.f-card h3 {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 4px;
}

.f-card p {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.4;
}

/* MESSAGES LIST */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-bottom: 20px;
}

.message-wrapper {
  display: flex;
  gap: 12px;
  animation: fadeIn 0.2s ease-out;
  position: relative;
}

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

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.user-msg .message-avatar {
  background: #3b82f6;
}

.ai-msg .message-avatar {
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.message-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* BUBBLE ACTION BAR */
.bubble-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.5;
  transition: opacity 0.15s ease;
}

.message-wrapper:hover .bubble-actions {
  opacity: 1;
}

.btn-bubble-copy {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-bubble-copy:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.message-content {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-main);
  word-break: break-word;
}

.message-content p { margin-bottom: 12px; }
.message-content p:last-child { margin-bottom: 0; }

.message-content h1, .message-content h2, .message-content h3 {
  margin-top: 18px;
  margin-bottom: 8px;
  color: #fff;
  font-weight: 700;
}

.message-content hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  margin: 18px 0;
}

.message-content ul, .message-content ol {
  margin-left: 20px;
  margin-bottom: 12px;
}

.message-content blockquote {
  border-left: 3px solid var(--primary);
  padding: 6px 12px;
  margin: 12px 0;
  background: rgba(139, 92, 246, 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: #d1d5db;
}

.message-content code:not(pre code) {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12.5px;
  color: #f472b6;
}

/* ==================== CODEBLOCK CONTAINER ==================== */
.code-block-container {
  margin: 14px 0;
  border-radius: var(--radius-md);
  background-color: var(--bg-code);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: all 0.2s ease;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background-color: #171a26;
  border-bottom: 1px solid var(--border-color);
  user-select: none;
}

.code-lang-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-cyan);
  text-transform: lowercase;
}

.code-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-code-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  width: 28px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-code-action:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.code-block-container pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  background: transparent;
  border: none;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}

.code-block-container pre code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  color: #e5e7eb;
}

.code-block-container.collapsed pre {
  max-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  opacity: 0;
  overflow: hidden;
}

.code-block-container.collapsed .code-block-header {
  border-bottom: none;
}

/* GROUNDED CITATION BADGES */
.citation-badges-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.citation-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
}

.citation-badge:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--primary);
}

/* SEARCH GROUNDING WEB LINKS */
.search-links-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.search-link-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.25);
  color: #67e8f9;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-decoration: none;
  transition: all 0.15s ease;
}

.search-link-pill:hover {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--accent-cyan);
}

/* MESSAGE FOOTER */
.message-meta {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.token-pill {
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.msg-actions {
  display: flex;
  gap: 4px;
}

/* ==================== BOTTOM INTERACTION BAR (OPENROUTER PRECISION) ==================== */
.bottom-bar {
  padding: 10px 16% 18px;
  background: linear-gradient(to top, var(--bg-dark) 85%, transparent);
}

@media (max-width: 1200px) {
  .bottom-bar { padding: 8px 8% 14px; }
}

/* BOTTOM MODE TABS ROW */
.bottom-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 4px;
  position: relative;
  z-index: 10;
}

.mode-tabs {
  display: flex;
  background-color: var(--bg-card);
  border-radius: var(--radius-full);
  padding: 3px;
  border: 1px solid var(--border-color);
  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.15s ease;
  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-main);
  background-color: rgba(255, 255, 255, 0.05);
}

.mode-tab.active {
  background: var(--primary) !important;
  color: #fff !important;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

.input-context-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

.context-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-green);
}

/* INPUT BOX WRAPPER (OPENROUTER FLOATING CARD) */
.input-wrapper {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 14px 10px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 30;
}

.input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 16px 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);
}

.input-controls-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.control-trigger-wrapper {
  position: relative;
}

.btn-control-icon {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

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

.btn-control-icon.active {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--primary);
  color: #c4b5fd;
}

.btn-model-pill {
  border-color: rgba(139, 92, 246, 0.35);
  color: #e5e7eb;
}

.icon-model-bolt {
  color: var(--primary);
}

.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: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  font-size: 13px;
}

.btn-send:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ==================== 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 */
.tool-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tool-switch-row:last-child { border-bottom: none; }

.tool-info { flex: 1; }

.tool-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-desc {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* 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;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
}

.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 {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
  height: 4px;
}

.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);
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

/* ==================== SESSION SWITCHER PALETTE MODAL ==================== */
.modal-palette {
  max-width: 540px;
  background-color: #141722;
  border: 1px solid rgba(139, 92, 246, 0.3);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 24px rgba(139, 92, 246, 0.15);
}

.palette-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.search-palette-icon {
  color: var(--text-muted);
  font-size: 14px;
}

.palette-header input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13.5px;
  color: var(--text-main);
  font-family: var(--font-sans);
}

.palette-body {
  padding: 12px 16px;
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.palette-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.palette-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.palette-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.session-items-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.session-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.session-list-item:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.25);
}

.session-list-item.active {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--primary);
}

.session-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.session-item-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item-meta {
  font-size: 10.5px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
}

.session-item-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.btn-session-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  opacity: 0.6;
}

.btn-session-action:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  opacity: 1;
}

/* ==================== MODAL STYLING ==================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s ease-out;
}

.modal-overlay.hidden { display: none; }

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 540px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-card.modal-lg { max-width: 760px; }

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

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.form-control {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 7px 10px;
  font-size: 12.5px;
  outline: none;
  width: 100%;
}

.inline-input { display: flex; gap: 6px; }

.doc-reader-body {
  font-size: 13.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  background: var(--bg-input);
  padding: 16px;
  border-radius: var(--radius-sm);
}

.citation-meta {
  font-size: 11.5px;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  margin-bottom: 8px;
}

.citation-snippet {
  background: var(--bg-input);
  padding: 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 380px;
  overflow-y: auto;
}

/* UTILITY */
.hidden { display: none !important; }
.mobile-only { display: none; }

@media (max-width: 768px) {
  .sidebar { position: fixed; left: -320px; transition: left 0.3s ease; }
  .sidebar.open { left: 0; }
  .mobile-only { display: flex; }
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

/* ATTACHMENT PREVIEW STRIP */
.attach-preview-strip {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  overflow-x: auto;
  flex-wrap: wrap;
}

.attach-preview-item {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  max-width: 220px;
  transition: border-color 0.15s ease;
}

.attach-preview-item:hover {
  border-color: var(--primary);
}

.attach-preview-item .attach-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.attach-preview-item .attach-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--primary-rgb), 0.12);
  border-radius: 4px;
  color: var(--primary);
  font-size: 16px;
  flex-shrink: 0;
}

.attach-preview-item .attach-info {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.attach-preview-item .attach-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
  font-weight: 500;
  color: var(--text-main);
  font-size: 11px;
}

.attach-preview-item .attach-size {
  font-size: 10px;
  color: var(--text-dim);
}

.attach-preview-item .btn-remove-attach {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent-red, #ef4444);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.attach-preview-item:hover .btn-remove-attach {
  opacity: 1;
}

#btnAttachFile:hover {
  color: var(--primary);
}

/* Attachment images in chat messages */
.msg-attachment-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.msg-attachment-strip img {
  max-width: 200px;
  max-height: 150px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.msg-attachment-strip img:hover {
  transform: scale(1.02);
}

.msg-attach-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(var(--primary-rgb), 0.08);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-dim);
}

/* ==================== RIGHT SIDEBAR: NOTES STUDIO ==================== */
.btn-notes-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.btn-notes-toggle.active {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 12px var(--primary-glow);
}

.notes-count-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.notes-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;
}

@keyframes slideInRight {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

.notes-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-main);
}

.notes-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.notes-search-box {
  padding: 10px 14px;
  position: relative;
  border-bottom: 1px solid var(--border-color);
}

.notes-search-box input {
  width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px 6px 30px;
  font-size: 12px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}

.notes-search-box input:focus {
  border-color: var(--primary);
}

.search-notes-icon {
  position: absolute;
  left: 23px;
  top: 19px;
  font-size: 11px;
  color: var(--text-dim);
}

.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-notes {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-dim);
}

.empty-notes-icon {
  font-size: 32px;
  margin-bottom: 12px;
  color: var(--text-dim);
  opacity: 0.5;
}

.empty-notes p {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.empty-notes span {
  font-size: 11px;
  line-height: 1.5;
  display: block;
}

/* NOTE CARD STYLING */
.note-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.note-card:hover {
  background-color: var(--bg-card-hover);
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.note-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.note-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
  word-break: break-word;
}

.note-card-badge {
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(139, 92, 246, 0.15);
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.note-card-badge.manual {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
}

.note-card-content {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  max-height: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.note-card-date {
  font-size: 10px;
  color: var(--text-dim);
}

.note-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-note-action {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 11.5px;
  padding: 3px 5px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-note-action:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-note-action.btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red, #ef4444);
}

.btn-bubble-save-note {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  padding: 3px 5px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-bubble-save-note:hover {
  color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
}

/* ==================== AUTH & ACCESS KEY LOCK SCREEN ==================== */
.modal-auth-card {
  max-width: 420px;
  width: 90%;
  padding: 32px 28px;
  background: #141724;
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(139, 92, 246, 0.15);
  text-align: center;
  animation: authFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.auth-header {
  margin-bottom: 24px;
}

.auth-icon-circle {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.15));
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--primary);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}

.auth-header h3 {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.auth-header p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-input-group {
  position: relative;
  display: flex;
  align-items: center;
  background: #0f111a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.auth-input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.auth-input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-dim);
  font-size: 14px;
}

.auth-input-group input {
  width: 100%;
  background: transparent;
  border: none;
  padding: 13px 40px 13px 40px;
  color: var(--text-main);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
}

.btn-toggle-key {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  font-size: 14px;
  transition: color 0.15s;
}

.btn-toggle-key:hover {
  color: var(--text-main);
}

.btn-auth-submit {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  justify-content: center;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}

.btn-auth-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.auth-error-msg {
  font-size: 12.5px;
  color: #f87171;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-align: left;
}

.auth-footer-note {
  margin-top: 20px;
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ==================== UNIFIED AI TUNING HUB MODAL & DRAWER ==================== */
.btn-tuning-hub {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.btn-tuning-hub:hover {
  background: rgba(139, 92, 246, 0.22);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 14px var(--primary-glow);
  transform: translateY(-1px);
}

.tuning-model-badge {
  font-size: 11px;
  font-weight: 600;
  color: #e5e7eb;
  letter-spacing: -0.2px;
}

.tuning-active-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

/* VOICE INPUT BUTTON */
.btn-voice {
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.btn-voice:hover {
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.4);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.25);
}

.btn-voice.recording {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: #ef4444 !important;
  color: #ef4444 !important;
  animation: voicePulse 1.2s infinite ease-in-out;
}

@keyframes voicePulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  50% { transform: scale(1.08); box-shadow: 0 0 14px 4px rgba(239, 68, 68, 0.4); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
}

/* SLASH COMMANDS MENU */
.slash-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  max-width: 480px;
  background: #141624;
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85), 0 0 20px rgba(139, 92, 246, 0.15);
  z-index: 100;
  overflow: hidden;
  animation: slashFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.slash-header {
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--primary);
  background: rgba(139, 92, 246, 0.1);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 6px;
}

.slash-item {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: all 0.15s ease;
}

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

.slash-item:hover, .slash-item.active {
  background: rgba(139, 92, 246, 0.18);
}

.slash-item-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.slash-cmd {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--accent-cyan);
}

.slash-desc {
  font-size: 11.5px;
  color: var(--text-muted);
}

.slash-item i {
  color: var(--text-dim);
  font-size: 11px;
}

/* COST PILL & SPEAKER TTS */
.cost-pill {
  background: rgba(234, 179, 8, 0.12) !important;
  border: 1px solid rgba(234, 179, 8, 0.3) !important;
  color: #fef08a !important;
}

.cost-pill i {
  color: #eab308;
}

.btn-bubble-speak {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 12px;
}

.btn-bubble-speak:hover {
  color: var(--accent-cyan);
  background: rgba(255, 255, 255, 0.05);
}

.btn-bubble-speak.speaking {
  color: #ef4444 !important;
  animation: speakPulse 1s infinite alternate;
}

@keyframes speakPulse {
  from { transform: scale(1); }
  to { transform: scale(1.18); }
}

/* ==================== NUMBERED MICRO-PILLS CITATION ==================== */
.citation-badges-container {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.06);
}

.citation-badge-micro {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.citation-badge-micro:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-1px) scale(1.08);
  box-shadow: 0 0 10px var(--primary-glow);
}

/* ==================== CITATION SOURCE INSPECTOR ==================== */
.modal-citation-card {
  width: 640px;
  max-width: 95vw;
}

.citation-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.citation-snippet-box {
  background: rgba(11, 13, 20, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.snippet-header {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
}

.citation-snippet-content {
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-main);
  max-height: 340px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.citation-snippet-content mark {
  background: rgba(234, 179, 8, 0.28);
  color: #fef08a;
  border-bottom: 2px solid #eab308;
  padding: 1px 3px;
  border-radius: 3px;
  font-weight: 600;
}

/* ==================== INTERACTIVE CODE SANDBOX RUNNER ==================== */
.btn-code-run {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 6px;
  transition: all 0.2s ease;
}

.btn-code-run:hover {
  background: #22c55e;
  color: #000;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

.code-output-terminal {
  background: #090a10;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-top: none;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: #a7f3d0;
  overflow-x: auto;
  animation: slashFadeIn 0.2s ease;
}

.code-output-terminal.error-output {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
}

/* ==================== AUDIO PODCAST PLAYER ==================== */
.modal-podcast-card {
  width: 520px;
  max-width: 95vw;
  background: #121422;
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 30px rgba(139, 92, 246, 0.2);
}

.hosts-container {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 20px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.host-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0.6;
}

.host-card.active-host {
  opacity: 1;
  transform: scale(1.08);
}

.host-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 8px;
  position: relative;
  transition: all 0.3s ease;
}

.host-alex {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  border: 2px solid rgba(59, 130, 246, 0.5);
}

.host-card.active-host .host-alex {
  box-shadow: 0 0 24px rgba(59, 130, 246, 0.7);
  border-color: #60a5fa;
}

.host-maya {
  background: linear-gradient(135deg, #ec4899, #be185d);
  color: #fff;
  border: 2px solid rgba(236, 72, 153, 0.5);
}

.host-card.active-host .host-maya {
  box-shadow: 0 0 24px rgba(236, 72, 153, 0.7);
  border-color: #f472b6;
}

.host-name {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text-main);
}

.host-role {
  font-size: 10px;
  color: var(--text-muted);
}

.podcast-vs {
  font-size: 20px;
  color: var(--text-dim);
}

.host-wave {
  display: none;
  gap: 3px;
  margin-top: 6px;
  height: 10px;
  align-items: center;
}

.host-card.active-host .host-wave {
  display: flex;
}

.host-wave span {
  width: 3px;
  height: 100%;
  background: var(--accent-cyan);
  border-radius: 2px;
  animation: waveBar 0.8s infinite ease-in-out alternate;
}

.host-wave span:nth-child(2) { animation-delay: 0.2s; }
.host-wave span:nth-child(3) { animation-delay: 0.4s; }

@keyframes waveBar {
  0% { height: 3px; }
  100% { height: 12px; }
}

.podcast-dialogue-box {
  background: rgba(11, 13, 20, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-bottom: 16px;
}

.active-speaker-tag {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  margin-bottom: 4px;
}

.active-speaker-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-main);
}

.podcast-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.btn-podcast-main {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  color: #fff;
  border: none;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 20px var(--primary-glow);
  transition: all 0.2s ease;
}

.btn-podcast-main:hover {
  transform: scale(1.08);
}

/* STUDIO GENERATORS BAR */
.studio-generators-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-color);
}

.btn-studio-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.btn-studio-pill:hover {
  color: #fff;
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.15);
}

/* ==================== DOCUMENT PREVIEW READER ==================== */
.doc-reader-body {
  padding: 20px 24px;
  max-height: 75vh;
  overflow-y: auto;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.8;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(11, 13, 20, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin: 16px 20px 20px;
}

/* CITATION FOCUS HIGHLIGHT IN FULL DOC (NOTEBOOKLM GLOW) */
.citation-in-doc-highlight {
  background: rgba(234, 179, 8, 0.28) !important;
  color: #fef08a !important;
  border: 1px solid rgba(234, 179, 8, 0.6) !important;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  display: inline;
  box-shadow: 0 0 16px rgba(234, 179, 8, 0.4);
  animation: citationTargetPulse 2s infinite ease-in-out;
}

@keyframes citationTargetPulse {
  0%, 100% {
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.3);
    border-color: rgba(234, 179, 8, 0.5);
  }
  50% {
    box-shadow: 0 0 24px rgba(234, 179, 8, 0.8), 0 0 8px #fef08a;
    border-color: #facc15;
  }
}

/* ==================== DOCUMENT STUDIO EDITOR & AI REWRITER ==================== */
.modal-doc-editor {
  width: 820px;
  max-width: 96vw;
  height: 90vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: #10121d;
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.95), 0 0 35px rgba(139, 92, 246, 0.2);
  overflow: hidden;
}

.doc-editor-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.doc-editor-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  min-height: 0;
  gap: 12px;
}

.editor-ai-toolbar {
  background: rgba(20, 23, 36, 0.95);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-toolbar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-copilot-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}

.ai-preset-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.ai-preset-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.ai-preset-chip:hover {
  background: rgba(139, 92, 246, 0.2);
  color: #fff;
  border-color: var(--primary);
}

.ai-instruction-input-row {
  display: flex;
  gap: 8px;
}

.ai-instruction-input-row input {
  flex: 1;
  background: rgba(11, 13, 20, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.ai-instruction-input-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

.btn-run-rewrite {
  padding: 0 16px;
  white-space: nowrap;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.doc-editor-textarea {
  flex: 1;
  width: 100%;
  background: rgba(11, 13, 20, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.75;
  resize: none;
  outline: none;
  min-height: 250px;
}

.doc-editor-textarea:focus {
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
}

.doc-editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 4px;
}

.doc-editor-footer-left, .doc-editor-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-gdrive-sync {
  background: rgba(66, 133, 244, 0.15);
  border: 1px solid rgba(66, 133, 244, 0.4);
  color: #93c5fd;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-gdrive-sync:hover {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 0 14px rgba(37, 99, 235, 0.4);
}

.btn-gdrive-sync.synced {
  background: rgba(34, 197, 94, 0.2) !important;
  border-color: #22c55e !important;
  color: #86efac !important;
}

/* TUNING MODAL CONTAINER */
.modal-tuning-hub {
  width: 620px;
  max-width: 95vw;
  max-height: 88vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: #141624;
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 30px rgba(139, 92, 246, 0.15);
  overflow: hidden;
  animation: tuningFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@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: 90px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  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-main);
  background: rgba(255, 255, 255, 0.05);
}

.tuning-tab.active {
  background: rgba(139, 92, 246, 0.18);
  border-color: rgba(139, 92, 246, 0.4);
  color: #fff;
  box-shadow: 0 2px 10px rgba(139, 92, 246, 0.25);
}

.tuning-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 280px;
  max-height: 520px;
}

.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 ==================== */
@media (max-width: 768px) {
  /* TOP NAV */
  .top-nav {
    padding: 6px 8px;
    gap: 4px;
    min-height: 48px;
    align-items: center;
  }

  .nav-left {
    gap: 4px;
    flex: 1;
    min-width: 0;
    align-items: center;
  }

  .session-pill {
    max-width: 110px;
    padding: 3px 6px;
    gap: 4px;
    height: 30px;
  }

  .session-icon {
    font-size: 11px;
  }

  .session-title-label {
    font-size: 11px;
    max-width: 70px;
  }

  .nav-chevron {
    font-size: 9px;
  }

  /* TOP NAV RIGHT: ULTRA-COMPACT 32px ICON BUTTONS */
  .nav-right {
    gap: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
  }

  .nav-right button {
    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 button span:not(.notes-count-badge) {
    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;
  }

  /* 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;
    padding: 8px 8px 6px !important;
  }

  .bottom-bar {
    padding: 6px 8px max(10px, env(safe-area-inset-bottom)) !important;
    flex-shrink: 0 !important;
    background: var(--bg-dark) !important;
    position: relative !important;
    z-index: 30 !important;
  }

  /* ULTRA COMPACT WELCOME SCREEN */
  .welcome-screen {
    padding: 10px 4px !important;
    margin: auto 0 !important;
  }

  .welcome-badge {
    margin-bottom: 6px !important;
    font-size: 10px !important;
    padding: 2px 7px !important;
  }

  .welcome-screen h1 {
    font-size: 16px !important;
    margin-bottom: 4px !important;
    line-height: 1.3 !important;
  }

  .welcome-screen p {
    font-size: 11px !important;
    margin-bottom: 10px !important;
    line-height: 1.4 !important;
  }

  .feature-cards {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
  }

  .f-card {
    padding: 7px 10px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .f-icon {
    font-size: 13px !important;
    margin-bottom: 0 !important;
    flex-shrink: 0 !important;
  }

  .f-card h3 {
    font-size: 11.5px !important;
    margin-bottom: 1px !important;
  }

  .f-card p {
    font-size: 10px !important;
    line-height: 1.3 !important;
  }

  .message-content {
    font-size: 13.5px;
    line-height: 1.6;
  }

  /* BOTTOM MODE ROW */
  .bottom-mode-row {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin-bottom: 4px;
  }

  .mode-tabs {
    width: 100%;
    display: flex;
    justify-content: space-between;
  }

  .mode-tab {
    flex: 1;
    justify-content: center;
    font-size: 10.5px;
    padding: 4px 6px;
    gap: 4px;
  }

  .input-context-info {
    font-size: 9.5px;
    justify-content: flex-end;
  }

  .input-wrapper {
    padding: 6px 8px 5px;
    border-radius: var(--radius-md);
  }

  #chatInput {
    font-size: 13.5px;
    min-height: 22px;
  }

  .input-bottom-bar {
    margin-top: 4px;
    padding-top: 4px;
  }

  .input-controls-left {
    overflow-x: auto;
    white-space: nowrap;
    flex-wrap: nowrap;
    gap: 4px;
    max-width: calc(100% - 36px);
    padding-bottom: 2px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
  }

  .input-controls-left::-webkit-scrollbar {
    display: none;
  }

  .btn-control-icon {
    padding: 3px 7px;
    font-size: 10.5px;
    flex-shrink: 0;
  }

  .btn-send-round {
    width: 28px;
    height: 28px;
    font-size: 11.5px;
    flex-shrink: 0;
  }

  /* 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;
  }

  .modal-tuning-hub {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 18px 18px 0 0 !important;
    max-height: 85vh !important;
    z-index: 1000 !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.9) !important;
    animation: tuningSheetSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  @keyframes tuningSheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .tuning-body {
    padding: 12px 14px !important;
    max-height: 60vh !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;
  }
}

/* ==================== GLOBAL MOBILE BACKDROP ==================== */
.mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 950;
  transition: opacity 0.25s ease;
}


