/*
 * Reusable components. Sections:
 *   buttons & pills · sidebar items · welcome & suggestions · setup banner · composer
 *   messages (question, answer card, tabs, table, SQL, steps) · loading · KPI & chart cards
 *   data view · toast
 */

/* Icon tiles: centre the SVG inside a coloured square/circle. */
.avatar, .s-icon, .kpi-icon, .step-dot { display: inline-flex; align-items: center; justify-content: center; }
.kpi-icon svg, .s-icon svg { width: 18px; height: 18px; }

/* ===== Buttons & pills ===== */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.link-btn { border: 0; background: none; color: var(--primary); font-size: 12px; font-weight: 600; padding: 0; text-transform: none; letter-spacing: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 9px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn svg { width: 15px; height: 15px; }

/* "Powered by Gemini": quiet footer line with a gradient sparkle. */
.powered-by {
  display: flex; align-items: center; gap: 7px; padding: 6px 10px;
  font-size: 12px; color: var(--muted); letter-spacing: 0.01em; white-space: nowrap;
}
.powered-by .pb-mark { color: #4f8cff; }
.powered-by .pb-mark svg { width: 13px; height: 13px; }
.powered-by.needs-key { color: var(--warning); }
.powered-by.needs-key .pb-mark { color: var(--warning); }

/* New chat: the primary action in the sidebar. */
.new-chat-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; border-radius: 11px; border: 0;
  background: var(--gradient); color: #fff; font-weight: 600; font-size: 14px;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.28);
  transition: transform 0.15s, box-shadow 0.15s;
}
.new-chat-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(79, 70, 229, 0.36); }
.new-chat-btn svg { width: 16px; height: 16px; }

/* Theme toggle (ink transition). z-index puts it above the ink overlay (1000); it is hidden
   in snapshots via data-ink-live. No colour transitions: the ink hands it its new colours. */
.theme-toggle {
  position: relative; z-index: 1001; flex: none;
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.theme-toggle:hover { transform: rotate(-12deg) scale(1.04); border-color: var(--text-2); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle__icon { overflow: visible; }
.theme-toggle__body { fill: currentColor; }
.theme-toggle__rays { stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge svg { width: 13px; height: 13px; }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.unanswerable { background: var(--warning-soft); color: var(--warning); }
.badge.failed { background: var(--danger-soft); color: var(--danger); }

/* ===== Sidebar items ===== */
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; border: 0; background: none;
  color: var(--text-2); font-weight: 500; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.recent-list { list-style: none; margin: 0; padding: 0 2px 0 0; display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.recent-list button {
  width: 100%; display: flex; gap: 10px; align-items: center;
  padding: 7px 10px; border: 0; border-radius: 9px; background: none;
  color: var(--text-2); font-size: 13px; text-align: left; line-height: 1.4;
}
/* One line per question (full text on hover), so more of the history fits. */
.recent-list button span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-list button:hover { background: var(--surface-2); color: var(--text); }
.recent-list svg { color: var(--muted); flex: none; }
.recent-list svg { width: 14px; height: 14px; }
.recent-empty { font-size: 13px; color: var(--muted); padding: 0 10px; }
.side-head .link-btn { display: inline-flex; align-items: center; gap: 4px; }
.side-head .link-btn svg { width: 13px; height: 13px; }

/* Dataset list ("Your data"). */
.dataset-list { list-style: none; margin: 0; padding: 0 2px 0 0; display: flex; flex-direction: column; gap: 2px; max-height: clamp(110px, 24vh, 260px); min-height: 0; overflow-y: auto; }
.ds-item { position: relative; display: flex; align-items: center; border-radius: 10px; }
.ds-item:hover { background: var(--surface-2); }
.ds-item.is-active { background: var(--primary-soft); }
.ds-select {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 0; background: none; text-align: left; color: var(--text-2);
}
.ds-icon {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-2);
}
.ds-item.is-active .ds-icon { background: var(--primary); color: var(--primary-ink); }
.ds-icon svg { width: 15px; height: 15px; }
.ds-text { min-width: 0; display: flex; flex-direction: column; }
.ds-name { font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-meta { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-delete {
  flex: none; width: 28px; height: 28px; margin-right: 6px; border: 0; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; color: var(--muted); opacity: 0; transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.ds-item:hover .ds-delete, .ds-delete:focus-visible { opacity: 1; }
.ds-delete:hover { color: var(--danger); background: var(--danger-soft); }
.ds-delete svg { width: 14px; height: 14px; }
@media (hover: none) { .ds-delete { opacity: 1; } }

/* Upload in progress. */
.ds-item.is-uploading .ds-icon { background: var(--primary-soft); color: var(--primary); }
.ds-progress { display: block; height: 4px; margin-top: 5px; border-radius: 4px; background: var(--surface-2); overflow: hidden; width: 160px; max-width: 100%; }
.ds-progress span { display: block; height: 100%; width: 0; background: var(--gradient); transition: width 0.2s; }

/* ===== Welcome & suggestions ===== */
.welcome { text-align: center; padding: 28px 0 8px; }
.welcome-art {
  width: 56px; height: 56px; border-radius: 16px; margin-bottom: 16px;
  background: var(--gradient); color: #fff; box-shadow: 0 10px 28px rgba(79, 70, 229, 0.35);
}
.welcome-art svg { width: 26px; height: 26px; }
.welcome h2 { font-size: 26px; font-weight: 700; }
.welcome > p { color: var(--text-2); max-width: 520px; margin: 8px auto 24px; }

.suggestions { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; text-align: left; }
.suggestion {
  display: flex; gap: 12px; align-items: flex-start; text-align: left;
  padding: 14px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.suggestion:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: var(--shadow); }
.suggestion .s-icon {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: var(--primary-soft); color: var(--primary);
}
.suggestion .s-tag { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.suggestion .s-text { font-size: 14px; font-weight: 500; color: var(--text); margin-top: 2px; }

/* ===== Setup banner (no API key) ===== */
.setup-banner {
  margin-bottom: 8px; border-radius: var(--radius);
  background: var(--warning-soft); border: 1px solid var(--warning-border);
}
.setup-banner summary {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; list-style: none;
  font-size: 14px; font-weight: 600; color: var(--warning);
}
.setup-banner summary::-webkit-details-marker { display: none; }
.setup-banner .setup-toggle { margin-left: auto; font-size: 13px; color: var(--primary); white-space: nowrap; }
.setup-banner[open] .setup-toggle { visibility: hidden; }
.setup-banner .setup-body { padding: 0 16px 14px 44px; }
.setup-banner p { color: var(--text-2); margin: 0 0 8px; font-size: 14px; }
.setup-banner ol { margin: 0; padding-left: 20px; color: var(--text-2); font-size: 14px; display: grid; gap: 4px; }
.setup-banner code { background: var(--surface); padding: 1px 6px; border-radius: 5px; font-size: 13px; color: var(--text); }
.setup-banner a { color: var(--primary); font-weight: 600; }

/* Same steps shown inside an error card. */
.setup-inline p { color: var(--text-2); font-size: 14px; margin: 4px 0 8px; }
.setup-inline ol { margin: 0; padding-left: 20px; color: var(--text-2); font-size: 14px; display: grid; gap: 4px; }
.setup-inline code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.setup-inline a { color: var(--primary); font-weight: 600; }

/* ===== Composer ===== */
.composer { padding: 10px 0 18px; background: linear-gradient(to bottom, transparent, var(--bg) 30%); }
.composer-box {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 10px 10px 10px 8px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft), var(--shadow-lg); }
.composer textarea {
  flex: 1; border: 0; outline: none; resize: none; background: transparent;
  max-height: 160px; padding: 8px 0; font-size: 15px; line-height: 1.5;
}
.composer textarea::placeholder { color: var(--muted); }
.send-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 0; flex: none;
  background: var(--gradient); color: #fff; display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.15s, opacity 0.15s;
}
.send-btn:hover { transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.5; cursor: progress; transform: none; }
.composer-hint { text-align: center; font-size: 12px; color: var(--muted); margin-top: 8px; }
.attach-btn {
  width: 38px; height: 38px; margin-bottom: 2px; border: 0; border-radius: 10px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; color: var(--muted); transition: background 0.15s, color 0.15s;
}
.attach-btn:hover { background: var(--surface-2); color: var(--primary); }
.attach-btn svg { width: 18px; height: 18px; }

/* ===== Upload: dropzone on the welcome screen, overlay while dragging a file ===== */
.dropzone {
  width: 100%; margin-top: 18px; padding: 18px; border-radius: var(--radius);
  border: 1.5px dashed var(--border); background: transparent; color: var(--text-2);
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px;
  text-align: left; align-items: center; transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: var(--primary); background: var(--primary-soft); }
.dz-icon {
  grid-row: 1 / span 2; width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.dz-title { font-weight: 600; color: var(--text); }
.dz-sub { font-size: 13px; color: var(--muted); }

.drop-overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(12, 14, 26, 0.55); padding: 24px;
}
.drop-overlay[hidden] { display: none; }
.drop-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 36px 44px; border-radius: var(--radius-lg); border: 2px dashed var(--primary);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.drop-card svg { width: 32px; height: 32px; color: var(--primary); }
.drop-card span:last-child { font-size: 13px; color: var(--muted); }

/* Dashboard for an uploaded dataset: invitation to ask. */
.overview-cta { display: flex; align-items: center; gap: 16px; }
.overview-cta > div { flex: 1; }
.overview-cta h3 { font-size: 15px; margin-bottom: 4px; }
.overview-cta .btn { text-decoration: none; }

/* ===== Ink theme transition ===== */
.ink-canvas {
  position: fixed; inset: 0; z-index: 1000; width: 100%; height: 100%;
  pointer-events: none; visibility: hidden;
}
.ink-canvas.is-active { visibility: visible; }
.theme-toggle.is-preparing { cursor: progress; }

/* CSS fallback (no WebGL2, reduced motion, or snapshots not ready): applied only during a flip. */
html.theme-fade, html.theme-fade *, html.theme-fade *::before, html.theme-fade *::after {
  transition:
    background-color var(--theme-fade, 0.45s) ease,
    border-color var(--theme-fade, 0.45s) ease,
    color var(--theme-fade, 0.45s) ease,
    fill var(--theme-fade, 0.45s) ease,
    stroke var(--theme-fade, 0.45s) ease,
    box-shadow var(--theme-fade, 0.45s) ease !important;
}

/* ===== Messages ===== */
.thread-inner { display: flex; flex-direction: column; gap: 22px; }

.msg-q { display: flex; justify-content: flex-end; }
.msg-q .bubble {
  max-width: 80%; padding: 11px 16px; border-radius: 16px 16px 4px 16px;
  background: var(--gradient); color: #fff; font-weight: 500; box-shadow: var(--shadow);
}

.msg-a { display: flex; gap: 12px; align-items: flex-start; }
.avatar {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: var(--primary-soft); color: var(--primary);
}
.answer-card {
  flex: 1; min-width: 0; padding: 18px 20px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.answer-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.answer-meta { font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.answer-meta svg { width: 13px; height: 13px; }
.btn svg, .tab svg { flex: none; }
.answer-text { font-size: 17px; line-height: 1.6; margin: 12px 0 4px; color: var(--text); }
.answer-explain { font-size: 13px; color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 4px; margin: 16px 0 12px; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 8px 12px; border: 0; background: none; color: var(--muted); font-weight: 500; font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab svg { width: 15px; height: 15px; }
.tab-panel[hidden] { display: none; }

.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 320px; }

/* Results table */
.table-wrap { overflow: auto; max-height: 360px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 9px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-note { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* SQL block */
.sql-block { position: relative; }
.sql-block pre {
  margin: 0; padding: 16px; border-radius: var(--radius-sm); overflow-x: auto;
  background: var(--code-bg); color: var(--code-text); font-size: 13px; line-height: 1.6;
}
.sql-block .btn { position: absolute; top: 10px; right: 10px; background: rgba(255, 255, 255, 0.08); color: #dfe3ff; border-color: rgba(255, 255, 255, 0.12); }
.sql-kw { color: #a5b4fc; font-weight: 500; }
.sql-str { color: #86efac; }
.sql-num { color: #fcd34d; }

/* Agent steps timeline */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; }
.step-dot {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: var(--success-soft); color: var(--success);
}
.step-dot svg { width: 13px; height: 13px; }
.steps li.err .step-dot { background: var(--danger-soft); color: var(--danger); }
.step-title { font-weight: 600; }
.step-detail { color: var(--muted); font-size: 13px; }
.step-detail.err { color: var(--danger); }

.answer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ===== Loading ===== */
.loading-steps { display: grid; gap: 10px; margin-top: 12px; }
.loading-step { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.loading-step .ls-icon { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); flex: none; }
.loading-step.active { color: var(--text); font-weight: 500; }
.loading-step.active .ls-icon { border-color: var(--primary); border-top-color: transparent; animation: spin 0.8s linear infinite; }
.loading-step.done { color: var(--text-2); }
.loading-step.done .ls-icon { border: 0; background: var(--success-soft); color: var(--success); display: inline-flex; align-items: center; justify-content: center; }
.loading-step.done .ls-icon svg { width: 12px; height: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== Dashboard ===== */
/* Six KPI cards: 3 x 2 by default, one row on very wide screens, 2 columns on phones. */
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (min-width: 1500px) { .kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 700px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi-value { font-size: 22px; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.kpi { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.delta { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.delta.up { background: var(--success-soft); color: var(--success); }
.delta.down { background: var(--danger-soft); color: var(--danger); }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.chart-card { padding: 18px; }
.chart-card.wide { grid-column: 1 / -1; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-head .muted { font-size: 13px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }

/* ===== Data view ===== */
.data-intro { display: flex; gap: 12px; align-items: flex-start; padding: 16px 18px; color: var(--text-2); font-size: 14px; }
.data-intro [data-icon] { color: var(--primary); margin-top: 2px; }
.table-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin-top: 14px; }
.table-card { padding: 18px; }
.table-card .card-head h3 { font-family: var(--font-mono); font-size: 15px; }
.table-card .rows { font-size: 12px; font-weight: 600; color: var(--primary); background: var(--primary-soft); padding: 2px 9px; border-radius: 999px; }
.table-card > p { color: var(--muted); font-size: 13px; margin: -4px 0 12px; }
.col-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.col-list li { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.col-name { font-family: var(--font-mono); font-weight: 500; }
.col-type { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.col-desc { color: var(--text-2); grid-column: 2; grid-row: 1 / span 2; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); pointer-events: none; z-index: 50;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); color: #fff; max-width: min(560px, 92vw); text-align: center; }

@media (max-width: 600px) {
  .composer-hint { display: none; } /* keyboard shortcuts don't apply on phones */
  .answer-card { padding: 14px; }
  .answer-text { font-size: 16px; }
  .msg-q .bubble { max-width: 92%; }
  .avatar { display: none; }
  .table-cards { grid-template-columns: 1fr; }
  .welcome h2 { font-size: 22px; }
}

/* ===== Account row (sidebar) ===== */
.account { display: flex; align-items: center; gap: 10px; padding: 10px; margin-top: 8px; border-top: 1px solid var(--border); }
.acct-avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: none;
  border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.acct-avatar.guest { background: var(--surface-2); color: var(--muted); }
.acct-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.acct-email { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-sub { font-size: 11px; color: var(--muted); }
.acct-out { width: 32px; height: 32px; }
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; border-color: transparent; justify-content: center; }
.btn-primary:hover { background: var(--primary-2); color: #fff; }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }

/* ===== Sign-in dialog ===== */
.auth-dialog { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0; width: min(400px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.auth-dialog::backdrop { background: rgb(15 23 42 / 0.45); backdrop-filter: blur(2px); }
.auth-form { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 28px 24px 22px; }
.auth-form h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.auth-form > p { font-size: 13px; margin-top: -6px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.auth-form input { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 14px; }
.auth-form input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
.auth-form .btn-primary { padding: 11px; font-size: 14px; margin-top: 4px; }
.auth-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; }
.auth-mark { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.auth-error { font-size: 13px; color: var(--danger); background: var(--danger-soft); padding: 8px 10px; border-radius: 8px; }
.auth-hint { font-size: 12px !important; margin-top: -6px !important; }
.auth-switch { text-align: center; font-size: 13px !important; margin-top: 2px !important; }
.auth-switch .link-btn { font-size: 13px; }

/* ===== Answer: follow-up note, feedback, export menu ===== */
.followup-note { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.followup-note svg { width: 13px; height: 13px; color: var(--primary); flex: none; }
.answer-actions { align-items: center; }
.actions-spacer { flex: 1; }
.feedback { display: inline-flex; align-items: center; gap: 4px; }
.feedback-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.icon-btn.fb { width: 32px; height: 32px; }
.icon-btn.fb[aria-pressed="true"][data-action="up"] { background: var(--success-soft); color: var(--success); border-color: transparent; }
.icon-btn.fb[aria-pressed="true"][data-action="down"] { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.feedback-note { display: flex; gap: 8px; margin-top: 10px; }
.feedback-note input { flex: 1; min-width: 0; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 13px; }
.export-wrap { position: relative; }
.export-menu { display: none; position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 20; min-width: 200px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); flex-direction: column; }
.export-menu[open] { display: flex; }
.export-menu button { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 0; background: none; border-radius: 8px;
  font-size: 13px; color: var(--text-2); text-align: left; }
.export-menu button:hover { background: var(--surface-2); color: var(--text); }
.export-menu svg { width: 15px; height: 15px; }

/* ===== Metrics view ===== */
.metrics-section { margin-bottom: 28px; }
.metrics-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 6px 0 12px; }
.metrics-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.metrics-head .muted { font-size: 13px; }
.metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metrics-section .kpi-value { font-size: 24px; }
.table-card { margin-top: 14px; padding: 4px; }
.table-card .table-wrap { border: 0; }
.metrics-section code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }
.fb-list { display: grid; gap: 10px; }
.fb-item { padding: 14px 16px; display: grid; gap: 6px; }
.fb-q { font-weight: 600; font-size: 14px; }
.fb-note { font-size: 13px; color: var(--text-2); }
.fb-meta { font-size: 12px; }
.fb-sql { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--code-bg); color: var(--code-text); font-family: var(--font-mono); font-size: 12px; overflow-x: auto; }
@media (max-width: 900px) { .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .metrics-grid { grid-template-columns: 1fr; } .actions-spacer { display: none; } }

/* Answers about the data itself can be a short list: keep the model's line breaks. */
.answer-text.is-prose { white-space: pre-line; }

/* ===== Quick questions: drifting pills (js/ask.js pillRows) ===== */
.suggestions { display: flex; flex-direction: column; gap: 10px; margin: 0 -8px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent); }
.pill-row { overflow: hidden; padding: 3px 0; }
.pill-track { display: flex; gap: 10px; width: max-content; animation: pill-drift var(--pill-duration, 34s) linear infinite; }
.pill-row.reverse .pill-track { animation-direction: reverse; }
.pill-row:hover .pill-track, .pill-row:focus-within .pill-track { animation-play-state: paused; }
@keyframes pill-drift { from { transform: translateX(0); } to { transform: translateX(calc(-50% - 5px)); } }
.pill {
  display: inline-flex; align-items: center; gap: 8px; flex: none; white-space: nowrap;
  padding: 9px 16px 9px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.pill svg { width: 15px; height: 15px; color: var(--primary); flex: none; }
.pill:hover, .pill:focus-visible { transform: translateY(-2px); border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--shadow); }
@media (prefers-reduced-motion: reduce) {
  .pill-track { animation: none; }
  .pill-row { overflow-x: auto; }
  .pill[aria-hidden="true"] { display: none; }
}

/* ===== Help button + "How to use" dialog ===== */
.help-btn { flex: none; margin-right: 8px; }
.help-btn svg { width: 18px; height: 18px; }
.help-dialog { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0; width: min(520px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.help-dialog::backdrop { background: rgb(15 23 42 / 0.45); backdrop-filter: blur(3px); }
.help-body { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 28px 26px 22px; }
.help-body h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.help-steps { margin: 0; padding-left: 20px; display: grid; gap: 10px; font-size: 14px; line-height: 1.5; color: var(--text-2); }
.help-steps b { color: var(--text); }
.help-steps li::marker { color: var(--primary); font-weight: 700; }
.help-keys { font-size: 12.5px; }
.help-keys kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); }
.help-body .btn-primary { padding: 11px; font-size: 14px; }

/* Dialogs: rise in, sink out. */
.help-dialog[open], .auth-dialog[open] { animation: dialog-in 0.32s cubic-bezier(0.2, 0.9, 0.25, 1.05); }
.help-dialog[open]::backdrop, .auth-dialog[open]::backdrop { animation: backdrop-in 0.3s ease; }
.help-dialog.is-closing, .auth-dialog.is-closing { animation: dialog-out 0.18s ease forwards; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes dialog-out { to { opacity: 0; transform: translateY(8px) scale(0.97); } }
@keyframes backdrop-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .help-dialog[open], .auth-dialog[open], .help-dialog.is-closing, .auth-dialog.is-closing { animation: none; }
}

/* ===== Sign-in dialog: success moment and mode switch ===== */
.auth-form > * { transition: opacity 0.22s ease, transform 0.22s ease; }
.auth-success {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px; text-align: center; opacity: 0; pointer-events: none; transform: scale(0.96);
}
.auth-success h2 { font-size: 21px; }
.auth-success p { font-size: 13.5px; max-width: 280px; }
.auth-form.is-success > :not(.auth-success) { opacity: 0; transform: translateY(-6px); pointer-events: none; }
.auth-form.is-success .auth-success { opacity: 1; transform: none; transition-delay: 0.12s; }
.auth-check { width: 64px; height: 64px; margin-bottom: 6px; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.auth-check circle { stroke: var(--primary); stroke-width: 2.5; stroke-dasharray: 145; stroke-dashoffset: 145; }
.auth-check path { stroke: var(--primary); stroke-width: 3.5; stroke-dasharray: 32; stroke-dashoffset: 32; }
.auth-form.is-success .auth-check circle { animation: draw 0.6s 0.15s cubic-bezier(0.65, 0, 0.35, 1) forwards; }
.auth-form.is-success .auth-check path { animation: draw 0.35s 0.65s cubic-bezier(0.65, 0, 0.35, 1) forwards; }
.auth-form.is-success .auth-check { animation: check-pop 0.4s 0.95s ease; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes check-pop { 50% { transform: scale(1.08); } }
.auth-form.is-switching :is(h2, #auth-reason, #auth-submit, #auth-switch) { animation: swap-in 0.28s ease; }
@keyframes swap-in { from { opacity: 0; transform: translateY(4px); } }

/* Account row: slides in after signing in or out. */
.account.acct-enter { animation: acct-in 0.5s cubic-bezier(0.2, 0.9, 0.25, 1.05); }
.account.acct-enter .acct-avatar { animation: avatar-pop 0.55s 0.1s cubic-bezier(0.2, 0.9, 0.25, 1.3) both; }
@keyframes acct-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes avatar-pop { from { transform: scale(0.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .auth-check circle, .auth-check path { stroke-dashoffset: 0; animation: none !important; }
  .auth-form.is-switching *, .account.acct-enter, .account.acct-enter * { animation: none !important; }
}

/* During the ink switch the pill strip is live (left out of snapshots) and sits above the ink
   overlay; its colours ease to the new theme when the ink reaches it (js/ink/transition.js). */
html.theme-switching .suggestions { position: relative; z-index: 1001; }
html.theme-switching .pill { transition: transform 0.2s ease, background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease; }
html.theme-switching .pill svg { transition: color 0.3s ease; }

/* Sign-up only: name and company (shown in "Create account" mode). */
.auth-signup-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-signup-fields label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
@media (max-width: 420px) { .auth-signup-fields { grid-template-columns: 1fr; } }

/* ===== Upload popup =====
   One dialog follows the upload through its states (data-state on the dialog):
   compress -> upload -> read -> done | error. The tile in the middle changes with the state:
   a rising arrow while sending, a filling grid while tables are read, a drawn check or a cross. */
.upload-dialog { border: 1px solid var(--border); border-radius: 22px; padding: 0; width: min(420px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden; }
.upload-dialog::backdrop { background: rgb(15 23 42 / 0.5); backdrop-filter: blur(4px); }
.upload-dialog[open] { animation: up-in 0.5s cubic-bezier(0.18, 0.95, 0.22, 1.08); }
.upload-dialog[open]::backdrop { animation: backdrop-in 0.35s ease; }
.upload-dialog.is-closing { animation: dialog-out 0.2s ease forwards; }
@keyframes up-in { from { opacity: 0; transform: translateY(26px) scale(0.92); } 60% { opacity: 1; } to { opacity: 1; transform: none; } }

.up-body { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 30px 26px 24px; text-align: center; }
.up-body::before { /* soft glow behind the tile */
  content: ""; position: absolute; top: -90px; left: 50%; width: 320px; height: 220px; transform: translateX(-50%);
  background: radial-gradient(closest-side, var(--primary-soft), transparent); opacity: 0.9; pointer-events: none; }
.up-body > * { position: relative; }
.up-body > .auth-close { position: absolute; }
.up-body h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; margin-top: 4px; }
.up-sub { font-size: 13px; color: var(--muted); max-width: 320px; overflow-wrap: anywhere; }

/* Tile with a spinning gradient ring around it */
.up-visual { position: relative; width: 92px; height: 92px; display: grid; place-items: center; }
.up-orbit { position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 55%, #7c8cff 75%, #a77bff 92%, transparent);
  -webkit-mask: radial-gradient(circle, transparent 41px, #000 42px); mask: radial-gradient(circle, transparent 41px, #000 42px);
  animation: spin 1.4s linear infinite; transition: opacity 0.4s ease; }
.up-tile { position: relative; width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center;
  background: var(--gradient); box-shadow: 0 12px 28px rgba(79, 70, 229, 0.38); color: #fff;
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.25, 1.3), background 0.4s ease, box-shadow 0.4s ease, border-radius 0.4s ease; }
.up-tile > * { position: absolute; transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.2, 0.9, 0.25, 1.2); }
.up-doc { width: 34px; height: 34px; fill: rgba(255, 255, 255, 0.16); stroke: #fff; stroke-width: 2.2; stroke-linejoin: round; }
.up-arrow { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round;
  top: 26px; animation: up-rise 1.1s cubic-bezier(0.5, 0, 0.3, 1) infinite; }
@keyframes up-rise { 0% { transform: translateY(7px); opacity: 0; } 35% { opacity: 1; } 75% { transform: translateY(-5px); opacity: 1; } 100% { transform: translateY(-9px); opacity: 0; } }
.up-grid { display: grid; grid-template-columns: repeat(3, 9px); gap: 3px; opacity: 0; transform: scale(0.6); }
.up-grid i { width: 9px; height: 9px; border-radius: 2.5px; background: rgba(255, 255, 255, 0.28); }
.up-check, .up-fail { width: 64px; height: 64px; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.up-check circle, .up-fail circle { stroke: #fff; stroke-width: 2.5; stroke-dasharray: 145; stroke-dashoffset: 145; }
.up-check path { stroke: #fff; stroke-width: 3.5; stroke-dasharray: 32; stroke-dashoffset: 32; }
.up-fail path { stroke: #fff; stroke-width: 3.5; stroke-dasharray: 20; stroke-dashoffset: 20; }

/* compress: the document breathes */
.upload-dialog[data-state="compress"] .up-doc { animation: up-breathe 1s ease-in-out infinite; }
.upload-dialog[data-state="compress"] .up-arrow { opacity: 0; animation: none; }
@keyframes up-breathe { 50% { transform: scale(0.88); } }
/* read: the document gives way to a grid whose cells light up in turn */
.upload-dialog[data-state="read"] :is(.up-doc, .up-arrow) { opacity: 0; transform: scale(0.6); animation: none; }
.upload-dialog[data-state="read"] .up-grid { opacity: 1; transform: none; }
.upload-dialog[data-state="read"] .up-grid i { animation: up-cell 1.35s ease-in-out infinite; }
.up-grid i:nth-child(2) { animation-delay: 0.08s; } .up-grid i:nth-child(3) { animation-delay: 0.16s; }
.up-grid i:nth-child(4) { animation-delay: 0.24s; } .up-grid i:nth-child(5) { animation-delay: 0.32s; }
.up-grid i:nth-child(6) { animation-delay: 0.4s; } .up-grid i:nth-child(7) { animation-delay: 0.48s; }
.up-grid i:nth-child(8) { animation-delay: 0.56s; } .up-grid i:nth-child(9) { animation-delay: 0.64s; }
@keyframes up-cell { 0%, 100% { background: rgba(255, 255, 255, 0.25); transform: scale(0.85); } 40% { background: #fff; transform: scale(1); } }
/* done and error: the tile becomes a circle, the ring fades, a mark is drawn */
.upload-dialog:is([data-state="done"], [data-state="error"]) .up-orbit { opacity: 0; }
.upload-dialog:is([data-state="done"], [data-state="error"]) .up-tile { border-radius: 50%; transform: scale(1.12); }
.upload-dialog:is([data-state="done"], [data-state="error"]) :is(.up-doc, .up-arrow, .up-grid) { opacity: 0; transform: scale(0.5); animation: none; }
.upload-dialog[data-state="done"] .up-tile { background: linear-gradient(135deg, #12a150, #10b981); box-shadow: 0 12px 30px rgba(18, 161, 80, 0.38); }
.upload-dialog[data-state="done"] .up-check { opacity: 1; }
.upload-dialog[data-state="done"] .up-check circle { animation: draw 0.6s 0.1s cubic-bezier(0.65, 0, 0.35, 1) forwards; }
.upload-dialog[data-state="done"] .up-check path { animation: draw 0.35s 0.55s cubic-bezier(0.65, 0, 0.35, 1) forwards; }
.upload-dialog[data-state="error"] .up-tile { background: linear-gradient(135deg, #e5484d, #d92d20); box-shadow: 0 12px 30px rgba(217, 45, 32, 0.35);
  animation: up-shake 0.45s 0.2s ease; }
.upload-dialog[data-state="error"] .up-fail { opacity: 1; }
.upload-dialog[data-state="error"] .up-fail circle { animation: draw 0.5s cubic-bezier(0.65, 0, 0.35, 1) forwards; }
.upload-dialog[data-state="error"] .up-fail path { animation: draw 0.3s 0.4s ease forwards; }
@keyframes up-shake { 20%, 60% { transform: scale(1.12) translateX(-6px); } 40%, 80% { transform: scale(1.12) translateX(6px); } }

/* File and table chips (staggered in) */
.up-files { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 360px; }
.up-files:empty { display: none; }
.up-files li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); max-width: 100%;
  animation: up-chip 0.4s cubic-bezier(0.2, 0.9, 0.25, 1.2) both; }
.up-files li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.up-files li b { font-weight: 600; color: var(--text); }
.up-files svg { width: 13px; height: 13px; color: var(--primary); flex: none; }
@keyframes up-chip { from { opacity: 0; transform: translateY(6px) scale(0.9); } }

/* Progress bar: gradient fill with a moving sheen; a sliding bar while the length is unknown */
.up-progress { width: 100%; margin-top: 8px; }
.up-track { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.up-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; border-radius: inherit; background: var(--gradient); transition: width 0.35s ease; overflow: hidden; }
.up-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: translateX(-100%); animation: up-sheen 1.3s ease-in-out infinite; }
@keyframes up-sheen { to { transform: translateX(100%); } }
.upload-dialog:is([data-state="read"], [data-state="compress"]) .up-fill { width: 38% !important; animation: up-slide 1.2s ease-in-out infinite; transition: none; }
@keyframes up-slide { from { left: -38%; } to { left: 100%; } }
.up-stats { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
#up-pct { font-weight: 700; color: var(--text); }
.upload-dialog:is([data-state="done"], [data-state="error"]) .up-progress { display: none; }

/* Steps */
.up-steps { list-style: none; display: flex; gap: 18px; margin: 6px 0 0; padding: 0; font-size: 12px; color: var(--muted); }
.up-steps li { display: flex; align-items: center; gap: 6px; transition: color 0.3s ease; }
.up-steps li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--border); transition: background 0.3s ease; }
.up-steps li.is-active { color: var(--text); font-weight: 600; }
.up-steps li.is-active::before { background: var(--primary); animation: up-dot 1.2s ease-out infinite; }
.up-steps li.is-done::before { background: var(--success); }
@keyframes up-dot { from { box-shadow: 0 0 0 0 var(--primary-soft); } to { box-shadow: 0 0 0 7px transparent; } }
.upload-dialog:is([data-state="done"], [data-state="error"]) .up-steps { display: none; }

.up-error { font-size: 13px; color: var(--danger); background: var(--danger-soft); padding: 9px 12px; border-radius: 10px; width: 100%; }
.up-actions { display: flex; gap: 10px; width: 100%; margin-top: 8px; animation: swap-in 0.35s 0.45s ease both; }
.up-actions .btn { flex: 1; justify-content: center; padding: 10px; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  .upload-dialog[open], .upload-dialog.is-closing, .up-orbit, .up-arrow, .up-doc, .up-grid i, .up-fill, .up-fill::after,
  .up-files li, .up-steps li::before, .up-tile, .up-actions { animation: none !important; }
  .up-check circle, .up-check path, .up-fail circle, .up-fail path { stroke-dashoffset: 0; animation: none !important; }
}

/* ===== Answers fit the visible thread =====
   The chart and the table are sized from the thread's height (--thread-h, set by ask.js), so a
   whole answer (text, tabs, chart or table, actions) reads on one screen without nested scrolls
   on typical laptops. Long tables still scroll inside their own box; tiny windows fall back to
   sensible minimums. */
.answer-card .chart-box { height: clamp(200px, calc(var(--thread-h, 640px) - 380px), 340px); }
.answer-card .table-wrap { max-height: clamp(180px, calc(var(--thread-h, 640px) - 360px), 420px); }

/* ===== Dashboard: charts from your questions ===== */
.saved-section { margin-top: 26px; }
.saved-section:empty { display: none; }
.saved-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.saved-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.saved-head p { font-size: 13px; color: var(--muted); }
.saved-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 16px; }
.saved-card { display: flex; flex-direction: column; gap: 10px; animation: swap-in 0.35s ease both; }
.saved-card .card-head { align-items: flex-start; gap: 10px; }
.saved-card h3 { font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.saved-when { font-size: 12px; color: var(--muted); margin-top: 2px; }
.saved-card .chart-box { height: 240px; }
.saved-remove { width: 28px; height: 28px; flex: none; opacity: 0.55; transition: opacity 0.15s; }
.saved-card:hover .saved-remove, .saved-remove:focus-visible { opacity: 1; }
.saved-empty { display: flex; align-items: center; gap: 14px; }

/* ===== Answer details: no-SQL steps, technical detail on failures, questions left ===== */
.steps .step-dot.info { background: var(--primary-soft); color: var(--primary); }
.answer-detail { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.answer-detail summary { cursor: pointer; width: fit-content; }
.answer-detail p { margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-family: var(--font-mono); font-size: 12px; overflow-wrap: anywhere; }
.composer-left::before { content: " · "; }
.composer-left { color: var(--warning); font-weight: 600; }
