/* ==========================================================================
   MDA Intelligent Document Search & RAG System - Modern UI Theme v2.2
   ========================================================================== */

:root {
  --primary-navy: #0b1120;
  --primary-blue: #0284c7;
  --accent-cyan: #00b4d8;
  --accent-cyan-light: #90e0ef;
  --accent-gold: #f59e0b;
  --bg-page: #0b1120;
  --bg-card: rgba(15, 23, 42, 0.90);
  --bg-card-hover: rgba(30, 41, 59, 0.95);
  --bg-sidebar: rgba(11, 17, 32, 0.96);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  --border-color: rgba(51, 65, 85, 0.65);
  --border-focus: #00b4d8;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition-fast: 0.18s ease;
}

[data-theme="light"] {
  --bg-page: #f4f7fb;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: #ffffff;
  --bg-sidebar: rgba(14, 30, 56, 0.96);
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Background overlay with MDA Mississippi outline */
.bg-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url('/static/img/mississippi-outline.png.jpg.jpg');
  background-size: cover;
  background-position: center;
  opacity: 0.16;
  pointer-events: none;
  z-index: 0;
}

/* ==========================================================================
   Sidebar Navigation & History
   ========================================================================== */
.sidebar {
  width: 320px;
  height: 100vh;
  background: var(--bg-sidebar);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  color: var(--text-inverse);
  position: relative;
  z-index: 10;
  transition: transform var(--transition-fast);
}

.sidebar-header {
  padding: 20px 18px 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-seal {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.brand-text h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #ffffff;
}

.brand-text p {
  font-size: 11px;
  color: var(--accent-cyan-light);
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.version-badge {
  background: rgba(0, 180, 216, 0.18);
  color: var(--accent-cyan);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

.sidebar-stats {
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.65);
  font-size: 11.5px;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-radius: 8px;
  margin: 12px 14px 8px 14px;
  border: 1px solid rgba(51, 65, 85, 0.4);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: #94a3b8;
}

.stat-row span.val {
  color: var(--accent-cyan);
  font-weight: 600;
}

.sidebar-action-wrap {
  padding: 0 14px 8px 14px;
}

.sidebar-action-link {
  color: #38bdf8;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.sidebar-action-link:hover {
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.45);
  text-decoration: none;
}

/* Sidebar Navigation Items */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 14px 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: #cbd5e1;
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  text-decoration: none;
}

.nav-item.active {
  background: rgba(0, 180, 216, 0.18);
  color: #38bdf8;
  font-weight: 600;
}

.nav-item i {
  font-size: 13px;
  width: 16px;
  text-align: center;
  color: #94a3b8;
}

.nav-item.active i {
  color: #38bdf8;
}

.sidebar-search-box {
  padding: 10px 14px;
}

.sidebar-search-box input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: #f1f5f9;
  font-size: 12px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.sidebar-search-box input:focus {
  border-color: var(--accent-cyan);
}

.sidebar-tabs {
  display: flex;
  padding: 0 14px 8px 14px;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tab-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.tab-btn.active {
  color: #fff;
  background: rgba(0, 180, 216, 0.2);
}

.sidebar-history {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 8px 14px;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.history-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #94a3b8;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-list,
.history-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 189, 248, 0.35) rgba(15, 23, 42, 0.5);
}

.history-item {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
  position: relative;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.07);
  border-left-color: var(--accent-cyan);
}

.history-item.active {
  background: rgba(0, 180, 216, 0.15);
  border-left-color: var(--accent-cyan);
}

.history-item .h-title {
  font-size: 12.5px;
  font-weight: 500;
  color: #f1f5f9;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 22px;
}

.history-item .h-meta {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
}

.h-pin-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 12px;
  transition: color var(--transition-fast);
}

.h-pin-btn.pinned {
  color: var(--accent-gold);
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-footer a, .sidebar-footer button {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: #cbd5e1;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-footer a:hover, .sidebar-footer button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* ==========================================================================
   Main Content Layout & Smooth Scrollbars
   ========================================================================== */
.main-content,
.main-wrapper {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  scroll-behavior: smooth;
}

/* Custom Visible Scrollbars for High Readability */
.main-content::-webkit-scrollbar,
.main-wrapper::-webkit-scrollbar,
.history-container::-webkit-scrollbar,
.history-list::-webkit-scrollbar,
#historyList::-webkit-scrollbar,
.results-container-panel::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.main-content::-webkit-scrollbar-track,
.main-wrapper::-webkit-scrollbar-track,
.history-container::-webkit-scrollbar-track,
.history-list::-webkit-scrollbar-track,
#historyList::-webkit-scrollbar-track {
  background: rgba(11, 17, 32, 0.4);
}

.main-content::-webkit-scrollbar-thumb,
.main-wrapper::-webkit-scrollbar-thumb,
.history-container::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb,
#historyList::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.35);
  border-radius: 5px;
  border: 1px solid rgba(11, 17, 32, 0.4);
}

.main-content::-webkit-scrollbar-thumb:hover,
.main-wrapper::-webkit-scrollbar-thumb:hover,
.history-container::-webkit-scrollbar-thumb:hover,
.history-list::-webkit-scrollbar-thumb:hover,
#historyList::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

.top-nav,
.top-navbar {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
}

.nav-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-brand h1 {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.2px;
}

.nav-brand p {
  font-size: 11.5px;
  color: var(--text-muted);
}

.nav-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-indicator.live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2ec4b6;
  box-shadow: 0 0 8px #2ec4b6;
}

.status-text {
  font-size: 12px;
  color: #2ec4b6;
  font-weight: 600;
}

.status-pill {
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.status-pill:hover {
  border-color: var(--accent-gold);
}

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

.navbar-brand img {
  height: 48px;
  object-fit: contain;
}

.navbar-title h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-title span.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(0, 180, 216, 0.15);
  color: var(--accent-cyan);
}

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

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

/* ==========================================================================
   Search Input Area
   ========================================================================== */
.content-container {
  max-width: 1050px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px 60px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.search-hero {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  position: relative;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  background: var(--bg-page);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 8px 6px 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

.search-input-wrapper:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.2);
}

.search-input-wrapper i.search-icon {
  position: static;
  color: var(--text-muted);
  font-size: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.search-input-wrapper input {
  flex: 1;
  min-width: 0;
  width: auto;
  padding: 10px 4px;
  font-size: 15.5px;
  border: none;
  background: transparent;
  color: var(--text-main);
  outline: none;
  box-shadow: none;
}

.search-input-wrapper input:focus {
  border: none;
  outline: none;
  box-shadow: none;
}

.search-btn {
  position: static;
  flex-shrink: 0;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0 22px;
  height: 42px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: opacity var(--transition-fast), transform 0.1s;
  box-sizing: border-box;
}

.search-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

/* Action Toolbar below search input */
.search-sub-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.enhance-btn {
  position: static;
  flex-shrink: 0;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--accent-gold);
  border-radius: 6px;
  padding: 7px 14px;
  height: 34px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

.enhance-btn:hover {
  background: var(--accent-gold);
  color: #0b1120;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
}

.search-tip-badge {
  font-size: 11.5px;
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.search-tip-badge code {
  background: rgba(0, 180, 216, 0.15);
  color: var(--accent-cyan);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

/* Structured 4-Column Filter Grid */
.search-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

@media (max-width: 900px) {
  .search-filter-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 550px) {
  .search-filter-grid {
    grid-template-columns: 1fr;
  }
}

.filter-card {
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color var(--transition-fast);
}

.filter-card:focus-within {
  border-color: var(--accent-cyan);
}

.filter-label {
  font-size: 10.5px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-label i {
  color: var(--accent-cyan);
}

.filter-select {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  padding: 2px 0;
}

.filter-select option {
  background: #0f172a;
  color: #f8fafc;
}

/* Welcome Status Card */
.welcome-status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 52px 32px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.welcome-icon-wrap {
  font-size: 44px;
  color: var(--accent-cyan);
  opacity: 0.85;
  margin-bottom: 16px;
}

.welcome-status-card h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 10px;
}

.welcome-subtitle {
  font-size: 14.5px;
  color: #cbd5e1;
  max-width: 620px;
  margin: 0 auto;
  line-height: 1.65;
}

.mode-switches {
  display: flex;
  gap: 16px;
}

.mode-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* Auto Suggestions Dropdown */
.suggestions-dropdown {
  position: absolute;
  top: calc(100% - 10px);
  left: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 30;
  max-height: 280px;
  overflow-y: auto;
  display: none;
}

.suggestions-dropdown.show {
  display: block;
}

.suggestion-item {
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.suggestion-item:hover {
  background: rgba(0, 180, 216, 0.08);
  color: var(--accent-cyan);
}

/* Clean list reset to prevent stray floating bullets */
ul, ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ==========================================================================
   Results & Answer Display
   ========================================================================== */
.results-container-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 400px;
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  box-sizing: border-box;
}

.results-area {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.answer-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-md);
}

.answer-content ul {
  list-style: disc inside !important;
  margin: 12px 0 16px 0 !important;
  padding-left: 8px !important;
}

.answer-content ol {
  list-style: decimal inside !important;
  margin: 12px 0 16px 0 !important;
  padding-left: 8px !important;
}

.answer-content li {
  margin-bottom: 8px !important;
  line-height: 1.6 !important;
  color: var(--text-main) !important;
}

/* Error State Alert */
.error-state-card {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.error-state-header {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f87171;
  font-size: 16px;
  font-weight: 700;
}

.error-state-body {
  color: #fca5a5;
  font-size: 13.5px;
  line-height: 1.5;
}

.error-retry-btn {
  align-self: flex-start;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.error-retry-btn:hover {
  background: #ef4444;
  color: #ffffff;
}

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

.answer-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.answer-header h3 i {
  color: var(--accent-cyan);
}

.answer-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.action-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.answer-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Markdown formatting inside answer */
.answer-content strong {
  font-weight: 700;
  color: var(--accent-cyan);
}

.answer-content p {
  margin-bottom: 12px;
}

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

/* Citation Pill Badges */
.citation-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 180, 216, 0.12);
  color: #0284c7;
  border: 1px solid rgba(0, 180, 216, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  margin: 0 3px;
  transition: all var(--transition-fast);
}

[data-theme="dark"] .citation-pill {
  background: rgba(0, 180, 216, 0.2);
  color: var(--accent-cyan-light);
}

.citation-pill:hover {
  background: var(--accent-cyan);
  color: #ffffff;
  border-color: var(--accent-cyan);
}

/* Sources & Used Chunks Section */
.sources-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.sources-card h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-main);
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.source-item-card {
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.source-item-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
}

.source-info {
  overflow: hidden;
}

.source-info .src-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.source-info .src-size {
  font-size: 11px;
  color: var(--text-muted);
}

.source-actions {
  display: flex;
  gap: 6px;
}

.btn-src {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-src:hover {
  background: var(--accent-cyan);
  color: #fff;
  border-color: var(--accent-cyan);
}

/* Modal Popup for Excerpts */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-backdrop.show {
  display: flex;
}

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

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

.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-main);
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Spinner & Shimmer Loading */
.loading-skeleton {
  padding: 30px;
  text-align: center;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 180, 216, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px auto;
}

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

/* ==========================================================================
   Live Search Activity Timeline & Telemetry
   ========================================================================== */
.telemetry-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.telemetry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.telemetry-header h4 {
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.telemetry-header .live-pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: pulse-dot 1.2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.5); opacity: 1; }
}

.telemetry-body {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.telemetry-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 12.5px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}

.telemetry-step.active {
  border-color: var(--accent-cyan);
  background: rgba(0, 180, 216, 0.06);
  box-shadow: 0 0 12px rgba(0, 180, 216, 0.15);
  animation: step-active-pulse 1.5s infinite ease-in-out;
}

.telemetry-step.completed {
  border-color: rgba(46, 196, 182, 0.3);
}

@keyframes step-active-pulse {
  0%, 100% { border-color: rgba(0, 180, 216, 0.5); }
  50% { border-color: var(--accent-cyan); box-shadow: 0 0 16px rgba(0, 180, 216, 0.25); }
}

.step-num-badge {
  background: rgba(0, 180, 216, 0.15);
  color: var(--accent-cyan);
  font-weight: 700;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 12px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.telemetry-step.active .step-num-badge {
  background: var(--accent-cyan);
  color: #ffffff;
}

.telemetry-step.completed .step-num-badge {
  background: rgba(46, 196, 182, 0.15);
  color: #2ec4b6;
}

.step-content {
  flex: 1;
}

.step-title {
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.step-detail {
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.4;
}

/* ==========================================================================
   Prompt Enhancer & Banner Styles
   ========================================================================== */
.enhance-btn {
  position: static;
  flex-shrink: 0;
  background: rgba(255, 183, 3, 0.12);
  border: 1px solid rgba(255, 183, 3, 0.35);
  color: var(--accent-gold);
  border-radius: 6px;
  padding: 8px 14px;
  height: 38px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

.enhance-btn:hover {
  background: var(--accent-gold);
  color: #121212;
  box-shadow: 0 0 10px rgba(255, 183, 3, 0.3);
}

.prompt-enhance-banner {
  margin-top: 10px;
  background: var(--bg-card);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: 0 4px 16px rgba(255, 183, 3, 0.1);
  animation: fadeIn 0.2s ease-out;
}

.enhance-banner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.enhance-banner-title {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
}

.btn-close-enhance {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}

.enhance-banner-body {
  font-size: 13px;
  color: var(--text-main);
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  line-height: 1.5;
  font-weight: 500;
}

.enhance-banner-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: italic;
}

.enhance-banner-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-apply-enhance {
  background: linear-gradient(135deg, var(--accent-gold), #e0a500);
  color: #121212;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-apply-text {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-apply-text:hover {
  background: rgba(255, 255, 255, 0.05);
}

.typing-cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--accent-cyan);
  vertical-align: middle;
  margin-left: 3px;
  animation: blink 0.8s infinite;
}

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

.candidate-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.candidate-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.candidate-chip.clickable {
  cursor: pointer;
  user-select: none;
}

.candidate-chip.clickable:hover {
  border-color: var(--accent-cyan);
  background: rgba(0, 180, 216, 0.12);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 180, 216, 0.25);
}

.candidate-chip.clickable:hover .chip-name {
  color: var(--accent-cyan-light);
  text-decoration: underline;
}

.candidate-chip .chip-type {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-cyan);
}

.candidate-chip .chip-score {
  font-size: 10px;
  color: var(--accent-gold);
  font-weight: 600;
}

.candidate-chip .chip-name {
  color: var(--text-main);
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Live Telemetry HUD (Tokens In/Out, Speed, Context Window)
   ========================================================================== */
.telemetry-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: 12px;
}

.hud-metric {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.hud-metric i {
  color: var(--accent-cyan);
}

.hud-metric .hud-val {
  font-weight: 700;
  color: var(--text-main);
  font-family: monospace;
}

.hud-progress-wrap {
  flex: 1;
  min-width: 160px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-info-btn {
  background: none;
  border: none;
  color: var(--accent-cyan);
  cursor: pointer;
  padding: 2px 4px;
  margin: 0;
  font-size: 11.5px;
  opacity: 0.85;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.hud-info-btn:hover {
  opacity: 1;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  transform: scale(1.15);
}

.hud-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-page);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.hud-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), #48cae4);
  width: 0%;
  transition: width 0.3s ease, background 0.3s ease;
}

/* ==========================================================================
   Live Model Reasoning & Evidence Findings
   ========================================================================== */
.reasoning-card {
  background: rgba(0, 180, 216, 0.04);
  border: 1px dashed rgba(0, 180, 216, 0.3);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 12.5px;
}

.reasoning-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  color: var(--accent-cyan);
  margin-bottom: 6px;
}

.reasoning-content {
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 160px;
  overflow-y: auto;
}

/* ==========================================================================
   High-Fidelity Prose & Markdown Typography
   ========================================================================== */
.prose-content {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-main);
}

.prose-content p {
  margin-bottom: 14px;
}

.prose-content h1,
.prose-content h2,
.prose-content h3,
.prose-content h4 {
  color: var(--text-main);
  font-weight: 700;
  margin-top: 22px;
  margin-bottom: 10px;
  line-height: 1.35;
}

.prose-content h2 {
  font-size: 18px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}

.prose-content h3 {
  font-size: 15.5px;
  color: var(--accent-cyan);
}

.prose-content h4 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.prose-content ul,
.prose-content ol {
  padding-left: 24px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prose-content li {
  line-height: 1.65;
}

.prose-content strong {
  font-weight: 700;
  color: var(--text-main);
}

.prose-content blockquote {
  border-left: 3px solid var(--accent-cyan);
  background: rgba(0, 180, 216, 0.05);
  padding: 10px 16px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 14px 0;
  color: var(--text-muted);
  font-style: italic;
}

/* Markdown Tables */
.prose-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.prose-content th {
  background: rgba(0, 180, 216, 0.1);
  color: var(--text-main);
  font-weight: 700;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border-color);
}

.prose-content td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.prose-content tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.prose-content tr:hover td {
  background: rgba(0, 180, 216, 0.04);
}

/* Inline Code & Code Blocks */
.prose-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--accent-cyan);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

[data-theme="dark"] .prose-content code {
  background: rgba(255, 255, 255, 0.08);
}

.prose-content pre {
  position: relative;
  background: #0d1117 !important;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 16px 0;
  overflow-x: auto;
}

.prose-content pre code {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  color: #e6edf3 !important;
  font-size: 13px;
  line-height: 1.5;
}

/* Task Lists */
.prose-content input[type="checkbox"] {
  accent-color: var(--accent-cyan);
  margin-right: 6px;
}

/* Nav Menubar Bridge Popover */
.nav-bridge-wrapper {
  position: relative;
}

.nav-bridge-popover {
  animation: popoverFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes popoverFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

