/* chat.css - Chat and Ask surface
 *
 * Extracted verbatim from style.css. Rules keep their original
 * relative order, and @media rules travel with the surface so its
 * responsive overrides still land after the rules they override.
 */
.dashboard-view .chat-panel { min-height: 520px !important; display: flex; flex-direction: column; }
.dashboard-view .chat-panel .chat-messages { flex: 1 1 auto; max-height: none; min-height: 0; margin-bottom: auto; }
.dashboard-lower .chat-panel, .dashboard-lower > .card.chat-panel, .dashboard-view .chat-panel, .dashboard-view .chat-panel.card { background: radial-gradient(ellipse 560px 340px at 8% 6%, rgba(25, 118, 210, 0.06), rgba(25, 118, 210, 0) 70%), linear-gradient(180deg, #1E1F1F 0%, #17181A 100%) !important; border: 1px solid rgba(234, 235, 236, 0.08) !important; color: var(--fg-primary-warm) !important; }
.dashboard-lower > .card.chat-panel, .dashboard-lower .chat-panel, .dashboard-view .chat-panel.card, .dashboard-view .chat-panel { background: var(--bg-card); border: 1px solid var(--accent-hover-soft-28); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
html body .floating-chat-composer .chat-textarea { font-family: var(--font-body); }
html body .floating-chat-composer .chat-textarea:focus { border-color: #1976D2; }

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .dashboard-view .card.chat-panel > h3.panel-title { margin: 0 0 2px; font-size: 13.5px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: rgba(15, 23, 42, 0.62); }
  .dashboard-view .card.chat-panel .chat-messages.chat-messages--chip { min-height: 0; max-height: 260px; overflow-y: auto; flex: 0 1 auto; padding: 0; background: transparent; border: 0; box-shadow: none; }
  .dashboard-view .card.chat-panel .chat-messages.chat-messages--chip .chat-empty { margin: 0; padding: 2px 2px 0; background: transparent; border: 0; font-size: 13px; line-height: 1.4; color: rgba(15, 23, 42, 0.55); text-align: left; }
  .dashboard-view .card.chat-panel .ai-composer-wrap.ai-composer-wrap--chip { padding: 0; margin: 0; background: transparent; border: 0; box-shadow: none; }
  .dashboard-view .card.chat-panel {
    min-height: 0;
    height: auto;
    max-height: none;
    align-self: start;
    justify-self: stretch;
    padding: 18px 18px 16px !important;
    gap: 12px !important;
    display: flex;
    flex-direction: column !important;
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.82) 0%,
      rgba(226, 236, 248, 0.76) 100%
    ) !important;
    background-color: rgba(255, 255, 255, 0.82) !important;
    background-image: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.82) 0%,
      rgba(226, 236, 248, 0.76) 100%
    ) !important;
    backdrop-filter: blur(22px) saturate(150%) !important;
    -webkit-backdrop-filter: blur(22px) saturate(150%) !important;
    border: 1px solid rgba(255, 255, 255, 0.8) !important;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.9),
      0 12px 28px rgba(15, 23, 42, 0.08) !important;
  }
  .dashboard-view .card.chat-panel .rich-composer { padding: 10px 10px 8px; border-radius: 14px; min-height: 0; }
  .dashboard-view .card.chat-panel .rich-composer::before, .dashboard-view .card.chat-panel .rich-composer::after { display: none; content: none; background: none; box-shadow: none; }
  .dashboard-view .card.chat-panel .rich-composer .rc-textarea { min-height: 36px; max-height: 160px; padding: 6px 8px; font-size: 14px; line-height: 1.45; }
  .dashboard-view .card.chat-panel .rich-composer .rc-toolbar { gap: 6px; padding-top: 6px; }
  .dashboard-view .card.chat-panel .rich-composer .rc-left { gap: 6px; flex-wrap: wrap; }
  .dashboard-view .card.chat-panel .rich-composer .rc-chip { padding: 4px 9px; font-size: 12px; height: 26px; }
  .dashboard-view .card.chat-panel .rich-composer .rc-icon-btn, .dashboard-view .card.chat-panel .rich-composer .rc-mic { width: 28px; height: 28px; }
  .dashboard-view .card.chat-panel .rich-composer .rc-send { width: 30px; height: 30px; }
  .dashboard-view .card.chat-panel .rich-composer .rc-model-select { font-size: 12px; }
}
.chat-msg-meta .cs-meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}
html body .chat-msg-meta {
  color: rgba(255, 255, 255, 0.42);
  font-size: 0.74rem;
  letter-spacing: 0.01em;
  margin-top: 6px;
  padding: 2px 4px;
  animation: none;
}
html body .chat-msg-meta .cs-meta-dot {
  color: rgba(255, 255, 255, 0.30);
}
[data-app-theme="light"] html body .chat-msg-meta,
[data-app-theme="og"] html body .chat-msg-meta {
  color: rgba(28, 30, 34, 0.55);
}
html[data-app-theme="dark"] .chats-header .page-title,
html[data-app-theme="dark"] .chats-header h1,
html[data-app-theme="dark"] .chats-header h2 {
  color: var(--fg-primary, #E3E1DD);
}
body .floating-chat-composer .chat-textarea:focus {
  border-color: var(--brand-blue-pure);
}
body .chats-view {
  background: transparent;
  /* Beat style.css section spacing (gap: 24px) so search sits under the title row. */
  gap: 12px !important;
}
/* Chat history header: actions only (no page title). SuperViz keeps titles. */
html body.route-chats .chats-header,
html body .chats-view > .chats-header,
body .chats-header {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 0.75rem !important;
  background: transparent !important;
  background-image: none !important;
  border: 0 !important;
  border-bottom: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 0 !important;
  margin: 0 !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  border-radius: 0 !important;
}
html body.route-chats .chats-title,
body .chats-title { display: none !important; }
html body.route-chats .chats-header::before,
html body.route-chats .chats-header::after,
body .chats-header::before,
body .chats-header::after {
  content: none !important;
  display: none !important;
  height: 0 !important;
  background: none !important;
  border: 0 !important;
  box-shadow: none !important;
}
/* Empty global topbar still reserved ~44px above Chat history (same pattern
   as Messages). Title + New chat live in .chats-header, so hide the chrome. */
html body.route-chats header.topbar#topbar,
html body.route-chats header.topbar.topbar--no-header,
html body.route-chats header.topbar.topbar--with-pill.topbar--no-header {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  visibility: hidden !important;
}
html body.route-chats header.topbar#topbar::before,
html body.route-chats header.topbar#topbar::after,
html body.route-chats header.topbar::before,
html body.route-chats header.topbar::after {
  content: none !important;
  display: none !important;
  height: 0 !important;
}
html body.route-chats #main-content,
html body.route-chats .main-content,
html body.route-chats main#main-content {
  padding-top: 1rem !important;
}
body .chats-title {
  color: var(--border-card-light) !important;
  font-size: 24px !important;
  font-weight: 600;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif !important;
}
body .chats-new-btn {
  background: var(--brand-blue-pure);
  color: var(--surface-charcoal-deep);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  padding: 8px 16px;
}
body .chats-search {
  background: var(--bg-card);
  border: 1px solid var(--surface-charcoal);
  color: var(--border-card-light);
  border-radius: 8px;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}
body .chats-row {
  background: var(--bg-card);
  border: 1px solid var(--surface-charcoal);
  border-radius: 12px;
  color: var(--border-card-light);
  transition: border-color .12s ease;
}
body .chats-row:hover {
  border-color: var(--border-strong-warm);
}
body .chats-row-title {
  color: var(--border-card-light);
  font-weight: 500;
}
body .chats-row-preview {
  color: var(--fg-faint);
  font-size: 13px;
}
body .chats-row-meta {
  color: var(--fg-faint);
  font-size: 12px;
}
body .chats-empty {
  color: var(--fg-faint);
}
body .chats-search,
body .floating-chat-composer .chat-textarea {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}
body .chat-panel::after {
  display: none;
}
html body .chat-sources {
  margin: 8px 0 2px 0;
  font-size: 12px;
}
html body .chat-sources-toggle {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  background: rgba(33,150,243,0.08);
  border: 1px solid rgba(33,150,243,0.20);
  color: #2196F3;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 150ms ease, border-color 150ms ease;
}
html body .chat-sources-chev {
  display: inline-flex;
  transform: rotate(0deg);
  transition: transform 150ms ease;
}
html body .chat-sources.is-open .chat-sources-chev {
  transform: rotate(90deg);
}
html body .chat-sources-panel {
  display: none;
  margin-top: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  overflow: hidden;
  background: #14161B;
}
html body .chat-sources.is-open .chat-sources-panel {
  display: block;
}
html body .chat-sources-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: #8A8F9C;
  font-size: 11px;
}
html body .chat-sources-meta b {
  color: #B8B8B8;
  font-weight: 600;
}
html body .chat-sources-sql {
  margin: 0;
  padding: 10px 12px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  color: rgba(255,255,255,0.85);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow: auto;
}
html body .chat-suggest-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  justify-content: center;
}
html body .chat-suggest-chip {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  background: rgba(33,150,243,0.06);
  border: 1px solid rgba(33,150,243,0.20);
  color: #E3E1DD;
  font-size: 13px;
  line-height: 1.3;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}
html body .chat-jump-latest {
  all: unset;
  box-sizing: border-box;
  position: absolute;
  z-index: 6;
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  cursor: pointer;
  background: #1F2121;
  border: 1px solid rgba(33,150,243,0.35);
  color: #2196F3;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  transition: background 150ms ease, transform 150ms ease, opacity 150ms ease;
}
html body .chat-jump-latest.is-visible {
  display: inline-flex;
}
html body .chat-jump-latest:hover {
  background: #252727;
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
  html body .chat-sources-toggle, html body .chat-sources-chev, html body .chat-suggest-chip, html body .chat-jump-latest {
    transition: none;
  }
}
.chat-dataset { margin: 12px 0; border: 1px solid var(--overlay-w-08); border-radius: 10px; background: var(--overlay-w-02); overflow: hidden; }
.chat-dataset-download:hover { background: var(--brand-blue-hover-pure); }
.chat-dataset-table-wrap { overflow-x: auto; }
.chat-dataset-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.chat-dataset-table th { color: var(--fg-muted-alpha); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.68rem; background: var(--overlay-w-03); }
.chat-dataset-table tbody tr:hover { background: rgba(33, 150, 243, 0.05); }
.chat-dataset-footer { padding: 8px 14px; font-size: 0.72rem; color: var(--fg-faint-alpha); border-top: 1px solid var(--overlay-w-04); }
.chat-eval-page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}
.chat-eval-eyebrow {
  display: none;
}
.chat-eval-header p:not(.chat-eval-eyebrow) { display: none; }
.chat-eval-kpis article,
.chat-eval-panel,
.chat-eval-state,
.chat-eval-loading {
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 10px;
  background: rgba(255,255,255,0.025);
}
.chat-eval-kpis article { padding: 14px; }
.chat-eval-kpis span { display: block; color: rgba(200,201,204,0.60); font-size: 12px; }
.chat-eval-panel { margin-top: 14px; overflow: hidden; }
.chat-eval-panel-head h2 { margin: 0; font-size: 14px; font-weight: 650; }
.chat-eval-panel-head span { color: rgba(200,201,204,0.52); font-size: 12px; }
.chat-eval-chart-series { min-width: 0; }
.chat-eval-chart-label { color: rgba(200,201,204,0.62); font-size: 12px; margin-bottom: 4px; }
.chat-eval-table-wrap { overflow-x: auto; }
.chat-eval-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.chat-eval-table th { color: rgba(200,201,204,0.52); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.chat-eval-count { color: var(--brand-blue-pure); font-variant-numeric: tabular-nums; font-weight: 650; }
.chat-eval-empty { color: rgba(200,201,204,0.55); text-align: center !important; }
.chat-eval-state,
.chat-eval-loading { padding: 28px; color: rgba(200,201,204,0.65); font-size: 14px; }
html[data-app-theme="light"] .chat-eval-header p:not(.chat-eval-eyebrow),
html[data-app-theme="light"] .chat-eval-kpis span,
html[data-app-theme="light"] .chat-eval-panel-head span,
html[data-app-theme="light"] .chat-eval-chart-label,
html[data-app-theme="light"] .chat-eval-table td:last-child,
html[data-app-theme="light"] .chat-eval-empty,
html[data-app-theme="light"] .chat-eval-state,
html[data-app-theme="light"] .chat-eval-loading { color: rgba(60,64,67,0.60); }
.msg-bubble.msg-assistant > .chat-msg-meta {
  display: none !important;
}
