/* ═══════════════════════════════════════════════════
   components.css — UI components
   ═══════════════════════════════════════════════════ */

/* ── Document Viewer Styles (Smart Formatted Reader) ── */
.doc-viewer-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* Reading Progress Bar */
.doc-reading-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 30;
  transition: width 0.1s ease-out;
}

/* Sticky Toolbar */
.doc-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(21, 21, 21, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 25;
  gap: 12px;
  flex-shrink: 0;
}

.doc-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.doc-toolbar-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.doc-toolbar-btn:hover {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border);
}

.doc-toolbar-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.doc-toolbar-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.doc-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* In-Doc Search Bar */
.doc-search-box {
  display: none;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px 6px;
  gap: 4px;
}

.doc-search-box.active {
  display: flex;
}

.doc-search-input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
  width: 130px;
  padding: 4px;
}

.doc-search-count {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 0 4px;
}

.doc-search-nav-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 4px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
}

.doc-search-nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* Main Body Layout */
.doc-viewer-body {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Outline Panel */
.doc-outline-panel {
  width: 250px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px 10px;
  box-sizing: border-box;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

@media (max-width: 1023px) {
  .doc-outline-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-height: 60vh;
    border-radius: 18px 18px 0 0;
    border-top: 1px solid var(--border);
    border-right: none;
    z-index: 50;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.6);
    transform: translateY(100%);
  }

  .doc-outline-panel.mobile-open {
    transform: translateY(0);
  }
}

.doc-outline-header {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 8px 10px;
}

.doc-outline-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s ease;
}

.doc-outline-item:hover {
  background: var(--surface);
  color: var(--text-primary);
}

.doc-outline-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.doc-outline-item.item-heading {
  padding-left: 18px;
  font-size: 12px;
}

/* Scrollable Content View */
.doc-scroll-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 28px 20px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  scroll-behavior: smooth;
}

.doc-content-article {
  width: 100%;
  max-width: 72ch;
  box-sizing: border-box;
}

/* Header Info Block */
.doc-info-block {
  padding-bottom: 24px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.doc-main-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  margin-bottom: 12px;
}

.doc-meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* Page Section */
.doc-page-section {
  position: relative;
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px dashed var(--border-subtle);
  content-visibility: auto;
  contain-intrinsic-size: 500px;
  animation: docPageFadeIn 0.3s ease;
}

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

@media (prefers-reduced-motion: reduce) {
  .doc-page-section {
    animation: none;
  }
}

.doc-page-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  position: sticky;
  top: -1px;
  background: var(--bg);
  padding: 6px 0;
  z-index: 5;
}

.doc-page-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(251, 101, 0, 0.25);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.doc-page-line {
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* Headings */
.doc-section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18.5px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  margin: 24px 0 14px;
  padding-top: 8px;
  scroll-margin-top: 70px;
}

.heading-accent-bar {
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--accent);
  border-radius: 2px;
}

/* Paragraphs */
.doc-paragraph {
  font-size: 16px;
  line-height: 1.75;
  color: rgba(245, 242, 242, 0.88);
  margin-bottom: 0.75em;
  word-break: break-word;
}

/* Key-Value Metadata Cards */
.doc-kv-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 16px;
  margin: 16px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 18px;
}

.doc-kv-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.doc-kv-key {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.doc-kv-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Bullet Lists */
.doc-bullet-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.doc-bullet-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 15.5px;
  line-height: 1.6;
  color: rgba(245, 242, 242, 0.88);
}

.bullet-dot {
  width: 6px;
  height: 6px;
  min-width: 6px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-2px);
}

/* Formatted Tables */
.doc-table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin: 18px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.doc-formatted-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

.doc-formatted-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-formatted-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.doc-formatted-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.doc-table-cell-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 550;
  color: var(--accent);
}

.doc-table-total-row {
  background: var(--accent-soft) !important;
  border-top: 1px solid var(--accent);
  font-weight: 700;
}

.doc-table-total-row td {
  color: #ffffff;
  padding: 12px 14px;
  font-size: 15px;
}

/* Skeleton Loading State */
.doc-skeleton-wrapper {
  width: 100%;
  max-width: 72ch;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 0;
}

.doc-skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.05) 75%);
  background-size: 200% 100%;
  animation: docSkeletonShimmer 1.8s infinite;
}

@keyframes docSkeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Search Highlights */
mark.doc-search-hit {
  background: rgba(251, 101, 0, 0.45);
  color: #ffffff;
  padding: 1px 3px;
  border-radius: 3px;
}

mark.doc-search-hit.current-hit {
  background: var(--accent);
  outline: 2px solid #ffffff;
}

/* ── Sidebar Text / Utility ──────────────────────── */
.sidebar-text {
  white-space: nowrap;
  display: inline-block;
  max-width: 200px;
  overflow: hidden;
  transition: opacity 0.2s ease, max-width 0.2s ease;
}

/* ── Chat Empty State Polish ─────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: calc(100vh - 220px);
  position: relative;
  padding: 16px;
  box-sizing: border-box;
  margin: auto 0;
}

.empty-ambient-glow {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(251, 101, 0, 0.12) 0%, rgba(21, 21, 21, 0) 70%);
  pointer-events: none;
  z-index: 0;
}

.empty-state h2 {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  position: relative;
  z-index: 1;
}

.empty-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  max-width: 40ch;
  line-height: 1.5;
  margin-bottom: 28px;
  position: relative;
  z-index: 1;
  text-wrap: balance;
}

.empty-suggestions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 560px;
  position: relative;
  z-index: 1;
}

@media (max-width: 600px) {
  .empty-suggestions-grid {
    grid-template-columns: 1fr;
  }
}

.suggestion-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 13px 15px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.suggestion-chip:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.suggestion-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.suggestion-chip svg {
  color: var(--accent);
  flex-shrink: 0;
}

/* ── Input Container Polish ──────────────────────── */
.input-container {
  background: var(--surface);
  border: 1px solid rgba(245, 242, 242, 0.14) !important;
  border-radius: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-container:focus-within {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(251, 101, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.28) !important;
}

.chat-input {
  max-height: 140px;
  resize: none;
}

.send-btn:disabled, .send-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Settings Modal Redesign ─────────────────────── */
.modal-overlay {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.settings-modal-sheet {
  width: min(92vw, 440px);
  background: #181818;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
  animation: modalScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 767px) {
  .settings-modal-sheet {
    position: fixed;
    bottom: 0;
    width: 100vw;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    margin: 0;
    max-height: 85vh;
  }

  .modal-drag-handle {
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 10px auto 4px;
  }
}

.settings-modal-body {
  padding: 16px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.settings-account-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
}

.settings-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(251, 101, 0, 0.2);
  color: #ff9d5c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

.settings-account-details {
  flex: 1;
  min-width: 0;
}

.settings-user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-user-email {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-signout-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.settings-signout-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-color: var(--border);
}

.settings-field-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-field-label {
  font-size: 13px;
  color: var(--text-primary);
}

.settings-select-wrapper {
  position: relative;
  width: 100%;
}

.settings-select-custom {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 34px 10px 12px;
  color: var(--text-primary);
  font-size: 13.5px;
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.settings-select-custom:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.settings-select-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

/* Danger Zone */
.settings-danger-box {
  background: rgba(211, 47, 47, 0.08);
  border: 1px solid rgba(211, 47, 47, 0.28);
  border-radius: 10px;
  padding: 14px 16px;
}

.settings-danger-label {
  color: #ff6b6b;
}

.settings-danger-desc {
  font-size: 12px;
  color: rgba(245, 242, 242, 0.7);
  line-height: 1.45;
  margin: 0 0 12px;
}

.btn-danger-outline {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid #ff6b6b;
  color: #ff8585;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-danger-outline:hover {
  background: #d32f2f;
  color: #ffffff;
  border-color: #d32f2f;
}

.confirm-dialog-box {
  width: min(88vw, 360px);
  background: #1c1c1c;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
}

/* ── Sidebar Library Polish & Grouping ────────────── */
.doc-count-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(251, 101, 0, 0.16);
  border: 1px solid rgba(251, 101, 0, 0.3);
  color: #ff9d5c;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
}

.doc-lib-search {
  margin: 0 16px 10px;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  gap: 6px;
}

.doc-lib-search-input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 12px;
  color: var(--text-primary);
  width: 100%;
}

.doc-lib-search svg {
  color: var(--text-muted);
}

.pulse-once {
  animation: singlePulse 2s ease-in-out 1;
}

@keyframes singlePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 101, 0, 0.7); }
  50% { box-shadow: 0 0 0 10px rgba(251, 101, 0, 0); }
}

/* ── Section Titles ──────────────────────────────── */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 28px 28px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Knowledge-Base Stats ────────────────────────── */
.kb-stats {
  padding: 0 28px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  color: var(--text-secondary);
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.stat-row:last-child { border-bottom: none; }
.stat-val {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 15px;
}

/* ── Document List ───────────────────────────────── */
.doc-list { display: flex; flex-direction: column; }

.doc-item {
  padding: 10px 28px;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background 150ms ease;
  border-left: 2px solid transparent;
}
.doc-item:hover { background: var(--bg-hover); }
.doc-item.active {
  background: var(--bg-hover);
  border-left-color: var(--accent);
}

.doc-info { flex: 1; min-width: 0; }
.doc-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  letter-spacing: -0.01em;
}
.doc-meta {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.doc-meta span { display: flex; align-items: center; }
.doc-meta span::after {
  content: "•";
  margin: 0 6px;
  color: var(--border);
}
.doc-meta span:last-child::after { content: ""; margin: 0; }

.doc-action-btn,
.doc-delete {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  border-radius: 4px;
  transition: color 150ms ease, opacity 150ms ease, background 150ms ease;
}
.doc-item:hover .doc-action-btn,
.doc-item:hover .doc-delete { opacity: 1; }
.doc-action-btn:hover,
.doc-delete:hover { color: var(--text-primary); background: var(--bg-hover); }

/* ── Upload Button ───────────────────────────────── */
.btn-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  border: none;
  background: var(--accent);
  color: #151515;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 150ms ease;
  font-family: inherit;
}
.btn-upload:hover {
  background: var(--accent-hover);
}
.btn-upload:active { transform: scale(0.96); }
#file-input { display: none; }

/* ── Scope Select ────────────────────────────────── */
.scope-select {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  color: var(--text-secondary);
  outline: none;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease;
  letter-spacing: 0.01em;
}
.scope-select:focus {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

/* ── Empty State ─────────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  max-width: 700px;
  margin: 0 auto;
  padding-bottom: 15vh;
}
.empty-state h2 {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
  color: var(--text-primary);
  line-height: 1.1;
}
.empty-state p.subheading,
.empty-state p.small-text { display: none; }
.suggested-questions { display: none; }

/* ── Messages ────────────────────────────────────── */
.msg {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  animation: fadeInMsg 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.msg.user { align-items: flex-end; }
.msg.bot  { align-items: flex-start; }

.msg-bubble {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
}
.msg.user .msg-bubble {
  background: var(--black);
  color: var(--white-text);
  padding: 12px 20px;
  border-radius: 12px;
  border-bottom-right-radius: 4px;
  max-width: 70%;
  border: none;
}
.msg.bot .msg-bubble { padding: 0; max-width: 100%; }

.msg.bot p             { margin-bottom: 16px; }
.msg.bot p:last-child  { margin-bottom: 0; }
.msg.bot ul, .msg.bot ol { margin-left: 24px; margin-bottom: 16px; }
.msg.bot li            { margin-bottom: 6px; padding-left: 8px; }
.msg.bot strong        { font-weight: 600; }

/* ── Markdown body (bot answers) ─────────────────── */
.markdown-body {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child  { margin-bottom: 0; }
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1.1em 0 0.45em;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}
.markdown-body h1 { font-size: 1.35em; }
.markdown-body h2 { font-size: 1.2em; }
.markdown-body h3 { font-size: 1.08em; }
.markdown-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.markdown-body blockquote {
  margin: 12px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
}
.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}
.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}
.markdown-body pre {
  margin: 12px 0;
  padding: 12px 14px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  max-width: 100%;
}
.markdown-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85em;
  line-height: 1.5;
}
.markdown-body .table-wrap {
  margin: 12px 0;
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
  line-height: 1.45;
  min-width: 280px;
}
.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
}
.markdown-body th {
  background: var(--bg-sidebar);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}
.markdown-body td {
  color: var(--text-primary);
}
.markdown-body tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.msg-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.msg-trace-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  min-height: 40px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  touch-action: manipulation;
}

.msg-trace-link:hover {
  color: var(--text-primary);
}

.trace-modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 520px;
  max-width: 90vw;
  overflow: hidden;
}

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

.trace-modal-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
}

.trace-modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  padding: 0;
}

.trace-modal-body {
  max-height: 420px;
  overflow-y: auto;
  padding: 0 18px 18px;
  background: var(--sidebar-bg);
}

.trace-step-list {
  padding-top: 12px;
}

.trace-step-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.trace-step-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 600;
}

.trace-step-time {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 400;
}

.trace-step-detail {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
}

.trace-source-section {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.trace-source-header {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: 10px;
}

.trace-source-group {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.trace-source-doc {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.trace-source-pages-text {
  color: var(--text-secondary);
  font-size: 12px;
  margin-bottom: 8px;
}

.trace-source-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trace-source-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
}

/* ── Input Composer ──────────────────────────────── */
.input-container {
  width: 100%;
  max-width: 720px;
  min-height: 60px;
  border-radius: 12px;
  background: var(--white);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  pointer-events: auto;
  transition: border-color 200ms ease;
  padding: 14px 16px;
}
.input-container:focus-within { border-color: var(--accent); }
.input-container.generating {
  animation: sastaShine 1.5s infinite;
  border-width: 2px;
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0 12px;
  font-family: inherit;
  font-size: 16px;
  color: var(--text-primary);
  resize: none;
  outline: none;
  max-height: 200px;
  height: 24px;
  line-height: 24px;
  overflow-y: hidden;
  margin-bottom: 4px;
}
.chat-input::placeholder {
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.shortcut-hint { display: none; }

/* Mic and other action buttons beside send */
.msg-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease, background 0.15s ease;
}
.msg-action-btn:hover { color: var(--text-primary); background: var(--surface-hover, rgba(255,255,255,0.06)); }
.msg-action-btn.recording {
  color: #ff4d4f !important;
  animation: micPulseRed 1.4s ease-in-out infinite;
}

@keyframes micPulseRed {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255, 77, 79, 0)); }
  50% { transform: scale(1.08); filter: drop-shadow(0 0 6px rgba(255, 77, 79, 0.6)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255, 77, 79, 0)); }
}

/* ── Live Voice Recording Dock Bar ───────────────── */
.voice-recording-bar {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px;
  min-height: 28px;
  min-width: 0;
  user-select: none;
}

.voice-rec-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.voice-rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4d4f;
  box-shadow: 0 0 8px rgba(255, 77, 79, 0.8);
  animation: recDotPulse 1.2s ease-in-out infinite;
}

@keyframes recDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}

.voice-rec-timer {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.voice-waveform {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.5px;
  height: 28px;
  max-width: 240px;
  min-width: 0;
  overflow: hidden;
}

.voice-bar {
  width: 2.5px;
  min-height: 4px;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  transition: height 0.06s ease;
  flex-shrink: 0;
}

.voice-live-transcript {
  display: none;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.voice-rec-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.voice-rec-action-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.voice-rec-action-btn.cancel:hover {
  background: rgba(255, 77, 79, 0.15);
  border-color: #ff4d4f;
  color: #ff4d4f;
}

.voice-rec-action-btn.done {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent, #ffffff);
}
.voice-rec-action-btn.done:hover {
  filter: brightness(1.1);
  transform: scale(1.05);
}

@media (prefers-reduced-motion: reduce) {
  .msg-action-btn.recording,
  .voice-rec-dot {
    animation: none !important;
  }
  .voice-bar {
    transition: none !important;
  }
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}
.send-btn:hover  { background: var(--accent); color: var(--on-accent); }
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled {
  background: var(--border);
  color: var(--text-tertiary);
  cursor: not-allowed;
}

/* ── Upload Icon Button ──────────────────────────── */
.upload-icon-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  margin-right: 8px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}
.upload-icon-btn:hover { color: var(--text-primary); }

/* ── Docs Pills (above input) ────────────────────── */
.uploaded-docs-pills {
  width: 100%;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 4px;
  scrollbar-width: none;
}
.uploaded-docs-pills::-webkit-scrollbar { display: none; }

.upload-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: border-color 0.15s ease;
}

.upload-chip.ready {
  border-color: rgba(56, 142, 60, 0.4);
}

.upload-chip.failed {
  border-color: rgba(211, 47, 47, 0.4);
}

.upload-chip-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  width: 100%;
  animation: uploadProgressPulse 1.4s ease-in-out infinite;
}

@keyframes uploadProgressPulse {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(0); }
  100% { transform: translateX(100%); }
}

.upload-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  color: var(--text-muted);
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.upload-chip-remove:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.doc-pill {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 16px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.doc-pill svg { color: var(--text-tertiary); }

.doc-pill-remove {
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  color: var(--text-secondary);
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, width 0.2s ease, color 0.2s ease;
  margin-left: 0;
}
.doc-pill:hover .doc-pill-remove {
  opacity: 0.7;
  width: 14px;
  margin-left: 6px;
}
.doc-pill-remove:hover {
  opacity: 1 !important;
  color: var(--danger) !important;
}

/* ── Typing Indicator ────────────────────────────── */
.typing {
  display: flex;
  gap: 6px;
  align-items: center;
  height: 32px;
  padding-left: 4px;
}
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

/* ── Upload Toast ────────────────────────────────── */
.upload-toast {
  position: fixed;
  bottom: 32px;
  left: 352px;
  background: var(--black);
  color: var(--white-text);
  padding: 11px 22px;
  border-radius: 8px;
  font-size: 13.5px;
  display: none;
  z-index: 100;
}

/* ── Server Wakeup & Retry Notification Banner ── */
.server-wakeup-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1e1e;
  border: 1px solid rgba(251, 101, 0, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  border-radius: 12px;
  padding: 14px 18px;
  max-width: 90vw;
  width: 440px;
  z-index: 10005;
  display: none;
  animation: slideDownToast 0.25s ease-out;
  box-sizing: border-box;
}

@keyframes slideDownToast {
  from { opacity: 0; transform: translate(-50%, -12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.server-wakeup-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.server-wakeup-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(251, 101, 0, 0.3);
  border-top-color: var(--accent, #fb6500);
  border-radius: 50%;
  animation: spinWakeup 0.8s linear infinite;
  flex-shrink: 0;
  margin-top: 2px;
}

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

.server-wakeup-text {
  font-size: 13px;
  line-height: 1.5;
  color: #f5f2f2;
}

.server-wakeup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.server-wakeup-retry-btn {
  background: var(--accent, #fb6500);
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.server-wakeup-retry-btn:hover {
  opacity: 0.9;
}

.server-wakeup-close-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

/* ── Refresh Button ──────────────────────────────── */
.refresh-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  font-weight: 600;
  transition: border-color 150ms ease, color 150ms ease;
}
.refresh-btn:hover {
  border-color: var(--border);
  color: var(--text);
  background: transparent;
}

/* ── Sidebar Menu Buttons ────────────────────────── */
.sidebar-menu-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  margin: 2px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid transparent;
  width: calc(100% - 20px);
  text-align: left;
  position: relative;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease, border-color 150ms ease;
}

.sidebar-menu-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.sidebar-menu-btn:hover svg {
  color: #ffffff;
  transform: translateX(2px);
}

.sidebar-menu-btn.active {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
  font-weight: 600;
}

.sidebar-menu-btn.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.sidebar-menu-btn.active svg {
  color: var(--accent);
}

.sidebar-menu-btn:active {
  transform: scale(0.98);
}

.sidebar-menu-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sidebar-menu-btn svg {
  color: var(--text-secondary);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: color 150ms ease, transform 150ms ease;
}

@media (hover: none) {
  .sidebar-menu-btn:hover {
    background: transparent;
    color: var(--text-primary);
  }
  .sidebar-menu-btn:hover svg {
    color: var(--text-secondary);
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-menu-btn, .sidebar-menu-btn:hover svg, .suggestion-chip, .suggestion-chip:hover {
    transform: none !important;
    transition: none !important;
  }
}

/* ── Message Action Buttons ──────────────────────── */
.msg-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.msg-action-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  min-width: 40px;
  min-height: 40px;
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background 0.2s ease;
  border-radius: 6px;
  touch-action: manipulation;
}
.msg-action-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.jump-bottom-btn {
  position: absolute;
  bottom: 12px;
  right: 24px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 35;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.15s ease;
}
.jump-bottom-btn:hover {
  background: var(--bg-hover);
  transform: translateY(-2px);
}

/* ── Top-Bar Controls ────────────────────────────── */
.top-bar-left { display: flex; align-items: center; gap: 16px; }

.toggle-sidebar-btn {
  background: none;
  border: none;
  color: var(--black);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease;
}
.toggle-sidebar-btn:active { transform: scale(0.92); }
.toggle-sidebar-btn svg   { width: 22px; height: 22px; }
.toggle-sidebar-btn:hover { background: var(--bg-hover); }

/* ── Dummy PDF Placeholder ───────────────────────── */
.dummy-pdf {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
  max-width: 320px;
}

/* ── Settings Modal ──────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-overlay.visible { opacity: 1; visibility: visible; }

.modal-content {
  background: var(--white);
  border-radius: 16px;
  width: 90%;
  max-width: 440px;
  padding: 32px;
  transform: scale(0.95) translateY(10px);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  pointer-events: auto;
}
.modal-overlay.visible .modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 0.2s ease, color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close-btn:hover {
  background: var(--bg-hover);
  color: var(--white-text);
}
.modal-close-btn:active { transform: scale(0.9); }

.settings-group { margin-bottom: 20px; }
.settings-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.settings-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23212121%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 14px top 50%;
  background-size: 10px auto;
}
.settings-select:focus {
  border-color: var(--text-secondary);
}

.btn-danger {
  width: 100%;
  padding: 12px;
  background: var(--danger);
  color: #151515;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease;
  font-family: inherit;
  font-size: 15px;
}
.btn-danger:hover  { background: #b71c1c; }
.btn-danger:active { transform: scale(0.98); }

/* ── Provider Badge ──────────────────────────────── */
.provider-badge {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Sidebar Footer ──────────────────────────────── */
.sidebar-footer {
  padding: 24px 28px;
  border-top: 1px solid var(--border);
}

/* ── Mobile Component Tweaks ──────────────────────── */
@media (max-width: 768px) {
  .msg.user .msg-bubble {
    max-width: 90%;
    padding: 10px 14px;
    font-size: 15px;
  }
  .msg-bubble {
    font-size: 15px;
  }
  .input-container {
    padding: 6px 8px;
    min-height: 52px;
    border-radius: 14px;
    align-items: center;
    gap: 4px;
  }
  .chat-input {
    font-size: 15px;
    padding: 0 6px;
    margin-bottom: 0;
  }
  .send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 10px;
  }
  .upload-icon-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    margin-right: 0;
    margin-bottom: 0;
    border-radius: 10px;
  }
  .msg-action-btn.mic-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin-right: 0 !important;
    border-radius: 10px;
  }
  .input-actions {
    gap: 2px;
    flex-shrink: 0;
  }
  .voice-recording-bar {
    gap: 6px;
    padding: 0 2px;
    min-height: 44px;
  }
  .voice-waveform {
    max-width: 130px;
    gap: 2px;
  }
  .voice-rec-actions {
    gap: 4px;
  }
  .voice-rec-action-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
  }
  /* In recording mode on mobile, keep actions compact and ensure zero overflow */
  .input-container.recording-mode .upload-icon-btn {
    display: none;
  }
  .input-container.recording-mode .input-actions {
    display: none;
  }
  .input-container.recording-mode .voice-waveform {
    max-width: 160px;
  }
  .input-container.recording-mode .voice-live-transcript {
    display: block;
    flex: 1;
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 0 4px;
  }
  .uploaded-docs-pills {
    max-height: 60px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .doc-pill {
    flex-shrink: 0;
  }
  .modal-content,
  .confirm-modal-card,
  .confirm-dialog-box,
  .trace-modal-card {
    width: 100vw;
    max-width: 100vw;
    border-radius: 16px 16px 0 0;
    margin-top: auto;
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
    box-sizing: border-box;
  }

  .custom-dropdown {
    width: 100%;
    max-width: 100%;
  }

  .dropdown-menu {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-height: 60vh;
    border-radius: 16px 16px 0 0;
    z-index: 10000;
  }

  .docs-side-panel {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
  }

  #upload-status-panel {
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    bottom: 80px !important;
    max-height: 240px !important;
  }
}

/* ── Custom Scope Dropdown ────────────────────────── */
.custom-dropdown {
  position: relative;
  display: inline-block;
  min-width: 200px;
  max-width: 320px;
}

.dropdown-trigger {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-sidebar);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  transition: border-color 150ms ease, background 150ms ease;
  user-select: none;
}
.dropdown-trigger:hover,
.dropdown-trigger:focus {
  border-color: var(--text-secondary);
  background: var(--bg-hover);
}
.dropdown-trigger span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  text-align: left;
}
.dropdown-chevron {
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: transform 0.2s ease;
}
.custom-dropdown.open .dropdown-chevron {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  min-width: 240px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: none;
  z-index: 500;
  padding: 4px 0;
  display: none;
}
.custom-dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-item {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 120ms ease, color 120ms ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dropdown-item:hover,
.dropdown-item.highlighted {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.dropdown-item.selected {
  color: var(--accent);
  font-weight: 500;
  background: var(--accent-soft);
}

/* ── Documents Summary Button & Side Panel ────────── */
.docs-summary-btn {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 150ms ease, border-color 150ms ease;
  font-family: inherit;
}
.docs-summary-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

.docs-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 8999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.docs-panel-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.docs-side-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(340px, 100vw);
  height: 100vh;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  box-shadow: none;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.docs-side-panel.open {
  transform: translateX(0);
}

.docs-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.docs-panel-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.docs-panel-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.docs-panel-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.docs-panel-search-wrap {
  padding: 12px 16px 8px;
  flex-shrink: 0;
}
.docs-panel-search {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
}
.docs-panel-search::placeholder {
  color: var(--text-tertiary);
}
.docs-panel-search:focus {
  border-color: var(--text-secondary);
}

.docs-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.docs-panel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 150ms ease;
}
.docs-panel-item:hover {
  background: var(--bg-hover);
}
.docs-panel-item-info {
  flex: 1;
  min-width: 0;
}
.docs-panel-item-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.docs-panel-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Custom Confirm Modal ──────────────────────────── */
.confirm-modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 380px;
  max-width: 90vw;
  padding: 24px;
  box-shadow: none;
  pointer-events: auto;
}
.confirm-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.confirm-filename {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--accent);
  background: var(--bg-main);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.confirm-message {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.btn-cancel {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-main);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background 150ms ease;
}
.btn-cancel:hover {
  background: var(--bg-hover);
}
.btn-delete-muted {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  background: var(--danger);
  color: #151515;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background 150ms ease;
}
.btn-delete-muted:hover {
  background: #b71c1c;
}

/* ── Sidebar failed document line & spin animation ──── */
.doc-error-line {
  font-size: 11px;
  color: var(--danger);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.spin {
  animation: spin 1s linear infinite;
  transform-origin: center;
}

