:root {
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --font-text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;

  /* ── Design tokens (locked scale — see .opencode/skills/designing-frontend-interfaces) ──
     TYPE: one ratio 1.25 (major third). SPACE: 4px base unit. RADIUS: 10 surfaces /
     7 controls / 5 tiny inner (999 pill + 50% dot only as exceptions).
     MOTION: 3 durations, 2 easings. */
  --step--1: 0.8rem;  --step-0: 1rem;    --step-1: 1.25rem;
  --step-2: 1.563rem; --step-3: 1.953rem;

  --space-3xs: 4px;  --space-2xs: 8px;  --space-xs: 12px;
  --space-s: 16px;   --space-m: 24px;   --space-l: 32px;
  --space-xl: 48px;

  --radius: 10px;      /* surfaces: panels, cards, grid, dialogs */
  --radius-sm: 7px;    /* controls: buttons, inputs, selects, chips */
  --radius-xs: 5px;    /* tiny inner: bars, cells, code */
  --radius-pill: 999px;

  --dur-fast: 120ms; --dur: 220ms; --dur-slow: 420ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --bg-light: #0f1115;
  --panel: #171a21;
  --border: #2a2f3a;
  --row-border: #21252e;
  --input-bg: #0b0d11;
  --text: #e6e9ef;
  --muted: #9aa3b2;
  --accent: #6aa9ff;
  --accent-dim: #2c4a6e;
  --btn-hover: #1f242d;
  --row-hover: rgba(106,169,255,.05);
  --shadow: rgba(0,0,0,.4);
  --ok: #6fe3a8;
  --err: #ff7a7a;
  --corr-border: #1e2128;
  --panel-text-glow: #fff;
}

:root[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-light: #f5f6f8;
  --panel: #ffffff;
  --border: #d9dee7;
  --row-border: #e6e9ee;
  --input-bg: #ffffff;
  --text: #1c2330;
  --muted: #5c6573;
  --accent: #2563eb;
  --accent-dim: #dbe7fe;
  --btn-hover: #eceff3;
  --row-hover: rgba(37,99,235,.05);
  --shadow: rgba(15,23,42,.15);
  --ok: #15803d;
  --err: #b3261e;
  --corr-border: #d9dee7;
  --panel-text-glow: #1c2330;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font-text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 12px var(--shadow);
}

.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.brand-home {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  padding: 2px 4px;
  margin: -2px -4px;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius-xs);
  text-decoration: none;
}
.brand-home:hover strong { color: var(--accent); }
.brand-icon { width: 22px; height: 22px; flex: none; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 65%, transparent)); }
.tag {
  font-size: 11px;
  color: var(--ok);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  font-weight: 500;
  text-decoration: none;
}
a.tag:hover { border-color: var(--ok); }
.topnav { display: flex; align-items: center; gap: 14px; }
.topnav a, .topnav .link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.topnav a:hover, .topnav .link:hover { color: var(--text); }
/* Nav CTA (e.g. "← Back to app") keeps button chrome inside .topnav */
.topnav a.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text);
}
.topnav a.btn:hover { background: var(--btn-hover); color: var(--text); }
.theme-toggle {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  flex: none;
  transition: background .12s, color .12s, border-color .12s;
}
.theme-toggle:hover { background: var(--btn-hover); color: var(--text); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 18px; height: 18px; fill: currentColor; }

main { max-width: 1280px; margin: 0 auto; padding: var(--space-m); }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: var(--space-l) var(--space-m);
  text-align: center;
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .18s, box-shadow .18s;
  position: relative;
  background:
    radial-gradient(600px 120px at 50% -40px, color-mix(in srgb, var(--accent) 12%, transparent), transparent),
    var(--panel);
}
.dropzone:hover { border-color: var(--accent); box-shadow: 0 4px 24px var(--shadow); }
.dropzone.dragover { border-color: var(--accent); background: var(--row-hover); transform: scale(1.005); }
.dropzone:focus-visible { outline: 2px solid var(--accent); }
.dropzone.compact { padding: var(--space-xs) var(--space-s); }
.dropzone.compact .dz-icon,
.dropzone.compact .dz-drop-hint,
.dropzone.compact .dz-privacy,
.dropzone.compact .dz-advanced { display: none; }
.dropzone.compact .dz-inner { display: flex; align-items: center; gap: var(--space-xs); flex-wrap: wrap; }
.dropzone.compact .dz-actions { margin-top: 0; }
.dz-icon { font-size: 34px; color: var(--accent); transition: transform .2s; }
.dropzone:hover .dz-icon, .dropzone.dragover .dz-icon { transform: translateY(-4px); }
.muted { color: var(--muted); }
.dz-drop-hint { margin: var(--space-2xs) 0; }
.dz-privacy { max-width: 60ch; margin: var(--space-2xs) auto 0; }
.dz-privacy a { color: var(--muted); }
.dz-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-top: var(--space-s);
}
.dz-advanced { margin-top: var(--space-xs); color: var(--muted); font-size: 13px; }
.dz-advanced > summary { cursor: pointer; display: inline-block; }
.dz-advanced > summary:hover { color: var(--text); }
.dz-advanced-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-top: var(--space-2xs);
}

.url-open { display: inline-flex; gap: var(--space-2xs); }
.persist-opt { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; white-space: nowrap; }
.persist-opt input { accent-color: var(--accent); }
#url-input {
  width: 320px; background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 10px;
  font: 12px var(--mono);
}
#url-input:focus { border-color: var(--accent); }

.hidden { display: none !important; }

.onboard {
  position: relative;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 12px 40px 12px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.onboard-step {
  flex: 1 1 180px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.onboard-step em { display: block; font-style: normal; font-size: 11px; opacity: .8; }
.onboard-step:hover { border-color: var(--accent); color: var(--text); }
.onboard-dot {
  flex: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--btn-hover);
  font-weight: 700;
  font-size: 12px;
}
.onboard-step.current { border-color: var(--accent); color: var(--text); }
.onboard-step.current .onboard-dot { background: var(--accent); color: #fff; }
.onboard-step.done { opacity: .65; }
.onboard-step.done .onboard-dot { background: var(--ok); color: #fff; }
.onboard-hide {
  position: absolute; top: 4px; right: 8px;
  background: none; border: none; color: var(--muted);
  font-size: 16px; cursor: pointer; line-height: 1;
}
.onboard-hide:hover { color: var(--text); }
.onboard-step:disabled { opacity: .45; cursor: not-allowed; }
.onboard-step:disabled:hover { border-color: var(--border); color: var(--muted); }

.empty {
  margin: 16px 0;
  padding: 28px 24px;
  text-align: center;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty p { margin: 8px 0; }
.empty .btn { margin: 0 4px; }

.grid th .coltype {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 6px;
  letter-spacing: .04em;
}
.grid th .coltype-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  padding: 0 4px;
  font: inherit;
  cursor: pointer;
}
.grid th .coltype-btn:hover { color: var(--accent); border-color: var(--accent); }
.grid th .coltype-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.date-filters { display: flex; flex-direction: column; gap: 4px; }
.col-filter[type="date"] { font-size: 11px; max-width: 135px; }

.coltoggle { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.coltoggle summary { cursor: pointer; display: inline-block; }
.coltoggle summary:hover { color: var(--text); }
.coltoggle label {
  display: inline-flex; align-items: center; gap: 4px;
  margin: 4px 12px 0 0; cursor: pointer; white-space: nowrap;
}

.files { margin-top: 16px; }
.files h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
#file-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 8px; }
#file-list li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-family: var(--mono);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#file-list .fmt { color: var(--accent); font-weight: 700; }
#file-list .rows { color: var(--muted); }
#file-list button {
  background: none; border: none; color: var(--err); cursor: pointer; font-size: 14px; line-height: 1;
}
#file-list button.pin { color: var(--muted); }
#file-list button.pin.pinned { color: var(--ok); }
#file-list .name { cursor: pointer; }
#file-list .name:hover { color: var(--accent); }
#file-list li.active { border-color: var(--accent); }

.tabs { display: flex; gap: 4px; margin: 20px 0 12px; border-bottom: 1px solid var(--border); }
.tab {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  padding: 8px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); background: var(--row-hover); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.grid thead tr.filters th { padding: 2px 8px; position: static; }
.col-filter {
  width: 100%; min-width: 80px;
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 3px 6px; font: 11px var(--mono);
}
.col-filter:focus { border-color: var(--accent); }

.gridwrap { overflow: auto; max-height: 60vh; border: 1px solid var(--border); border-radius: var(--radius); }
.grid { border-collapse: collapse; width: 100%; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.grid thead th {
  position: sticky; top: 0;
  background: var(--panel);
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
}
.grid tbody td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--row-border);
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 27px;
  line-height: 15px;
}
.grid tbody tr:hover td { background: var(--row-hover); }
.grid td.null { color: var(--muted); font-style: italic; }

.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 10px; }
#page-info { font-size: 12px; color: var(--muted); font-family: var(--mono); }

.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform .06s var(--ease);
}
.btn:hover { background: var(--btn-hover); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Text actions (one voice, token-driven) ── */
.link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.link:hover { filter: brightness(1.15); }

#sql-input {
  width: 100%;
  min-height: 160px;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--mono);
  font-size: 13px;
  resize: vertical;
}
#sql-input:focus { border-color: var(--accent); }
.sqlwrap { display: grid; grid-template-columns: auto 1fr; position: relative; }
.sqlnums { padding: 12px 6px; text-align: right; color: var(--muted); font: 13px/1.5 var(--mono); user-select: none; background: var(--input-bg); border: 1px solid var(--border); border-right: none; border-radius: var(--radius) 0 0 var(--radius); overflow: hidden; }
.sqlwrap #sql-input { border-radius: 0 var(--radius) var(--radius) 0; }
.sql-ac {
  position: absolute;
  z-index: 60;
  min-width: 200px;
  max-width: 380px;
  max-height: 240px;
  overflow: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 24px var(--shadow);
  font: 12px/1.7 var(--mono);
}
.sql-ac li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sql-ac li.active, .sql-ac li:hover { background: var(--accent-dim); }
.sql-ac .ac-detail { color: var(--muted); font-size: 11px; margin-left: auto; padding-left: 12px; }
.explain { background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; font: 11px/1.5 var(--mono); color: var(--muted); max-height: 300px; overflow: auto; white-space: pre; margin-top: 10px; }
.explain.error { border-color: var(--err); color: var(--err); }
.sql-tools { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.sql-tools .meta { margin: 0; }
.sql-tools select {
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 8px; font-size: 12px;
}

.progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
  z-index: 100;
}
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress-fill.indeterminate { width: 30% !important; animation: indet 1s infinite ease-in-out; }
@keyframes indet { 0% { margin-left: 0; } 100% { margin-left: 70%; } }

.toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 13px;
  box-shadow: 0 8px 30px var(--shadow);
  max-width: 80vw;
  z-index: 100;
}
.toast.error { border-color: var(--err); color: var(--err); }
.toast.ok { border-color: var(--ok); color: var(--ok); }
#cancel-op { position: fixed; bottom: 20px; right: 20px; z-index: 100; }
.toast-stack { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 80vw; }
.toast-stack .toast { position: static; transform: none; }
.help { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 200; }
.help-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; min-width: 280px; }
.help-box table { border-collapse: collapse; margin: 10px 0; }
.help-box td { padding: 3px 12px 3px 0; font: 12px var(--mono); }

.join-box {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.join-side label, .join-mid label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.join-side select, .join-mid select {
  width: 100%;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 10px;
}
.join-mid { display: flex; flex-direction: column; gap: 8px; }
#join-meta { margin-top: 10px; }

.chart-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.chart-tools label { font-size: 12px; color: var(--muted); }
.chart-tools select {
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
}
#chart-meta { margin-bottom: 8px; }
.chartwrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
#chart-canvas { width: 100%; height: 420px; }
#chart-series { min-width: 80px; }

#profile-detail { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-top: 14px; }
.prof-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.prof-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 12px; }
.prof-stats { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.prof-table { width: 100%; border-collapse: collapse; font: 11px var(--mono); }
.prof-table td { padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.prof-table td.num { text-align: right; color: var(--muted); }
.prof-bar { background: var(--input-bg); border-radius: var(--radius-xs); height: 8px; min-width: 60px; }
.prof-bar > div { background: var(--accent-dim); height: 100%; border-radius: var(--radius-xs); }
.prof-hist { display: flex; align-items: flex-end; gap: 3px; height: 64px; }
.prof-hist-bar { flex: 1; background: var(--accent-dim); border-radius: var(--radius-xs) var(--radius-xs) 0 0; }
.prof-axis { font-size: 10px; margin-top: 4px; font-family: var(--mono); }

.union-check { accent-color: var(--accent); }
#union-run { margin-top: 8px; }

.analyze-section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 10px; }
.corr-wrap { display: inline-block; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; overflow-x: auto; }
.corr-row { display: flex; }
.corr-cell {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 600; text-align: center;
  border: 1px solid var(--corr-border); cursor: default; white-space: nowrap; overflow: hidden;
}
.corr-corner { background: transparent; }
.corr-header { background: var(--panel); color: var(--muted); font-weight: 400; font-size: 10px; padding: 0 4px; }
.corr-legend { font-size: 11px; margin-top: 8px; font-family: var(--mono); }
.box-canvas { width: 100%; display: block; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }

/* ── Theme-aware scrollbars ── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-sm); }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Accessible focus ── */
.btn:focus-visible, .tab:focus-visible, .link:focus-visible, .brand-home:focus-visible,
#file-list button:focus-visible, select:focus-visible, input:focus-visible,
textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ── Row detail drawer (bonus) ── */
#row-detail {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 360px;
  max-width: 92vw;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px var(--shadow);
  z-index: 150;
  transform: translateX(100%);
  transition: transform .18s ease;
  display: flex;
  flex-direction: column;
}
#row-detail.open { transform: translateX(0); }
#row-detail .rd-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
#row-detail .rd-close {
  background: none; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; line-height: 1;
}
#row-detail .rd-body { overflow: auto; padding: 8px 0; flex: 1; }
#row-detail .rd-row {
  display: flex; gap: 10px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--row-border);
  cursor: pointer;
}
#row-detail .rd-row:hover { background: var(--row-hover); }
#row-detail .rd-key {
  flex: none; width: 130px;
  font-family: var(--mono); font-size: 11px;
  color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#row-detail .rd-val {
  font-family: var(--mono); font-size: 12px;
  word-break: break-word; white-space: pre-wrap;
}
#row-detail .rd-empty { color: var(--muted); font-style: italic; padding: 6px 16px; }

#analyze-insights { display: grid; gap: 8px; margin-bottom: 16px; }
.insight { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; background: var(--panel); }
.insight > summary { cursor: pointer; font-weight: 600; }
.insight-warn { border-left: 3px solid var(--err); }
.insight-info { border-left: 3px solid var(--accent); }
.insight-ok { border-left: 3px solid var(--ok); }
.insight-sql { font: 11px var(--mono); background: var(--input-bg); border: 1px solid var(--row-border); border-radius: var(--radius-sm); padding: 6px 8px; overflow-x: auto; cursor: pointer; white-space: pre-wrap; }
.corr-link { cursor: pointer; }
.corr-link:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
/* Keep Analyze controls visible while scrolling long matrices/reports. */
#tab-analyze > .sql-tools:first-child { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; }
#ai-model-url { background: var(--input-bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 6px 8px; font: 12px var(--mono); max-width: 100%; }
#ai-question { flex: 1; min-width: 200px; background: var(--input-bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 6px 8px; font-size: 13px; }
#ai-question:focus { border-color: var(--accent); }
#ai-answer { white-space: pre-wrap; max-height: 260px; overflow-y: auto; }
#ai-budget.risk-warn { color: var(--accent); }
#ai-budget.risk-red { color: var(--err); font-weight: 600; }
.ok-text { color: var(--ok); }
.err-text { color: var(--err); }
#ai-risk-ack { display: block; margin: 6px 0; font-size: 13px; color: var(--err); }
#ai-modal ul { margin: 8px 0; padding-left: 18px; font-size: 12px; }
#ai-modal label { display: block; margin: 10px 0; font-size: 13px; }

@media (max-width: 760px) {
  main { padding: 10px; }
  .join-box { grid-template-columns: 1fr; }
  #profile-detail { grid-template-columns: 1fr; }
  .tab { padding: 8px 10px; font-size: 13px; }
  .tabs { overflow-x: auto; }
  .gridwrap { max-height: 50vh; }
  .dropzone { padding: 28px 14px; }
  #url-input { width: 100%; }
  #ai-model-url { width: 100%; }
  .help-box { max-width: calc(100vw - 32px); }
  .onboard { padding-right: 36px; }
}

/* ── Design refresh: depth + motion, theme-agnostic via vars ── */
.analyze-section-title, .files h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.analyze-section-title::before, .files h2::before {
  content: "";
  width: 3px;
  height: 1em;
  border-radius: var(--radius-xs);
  background: linear-gradient(180deg, var(--accent), transparent);
  flex: none;
}
.insight {
  box-shadow: 0 2px 10px var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.insight:hover { border-color: var(--accent); box-shadow: 0 4px 18px var(--shadow); }
.insight > summary::marker { color: var(--accent); }
.insight-sql { transition: border-color .15s; }
.insight-sql:hover { border-color: var(--accent); }
.corr-cell { transition: transform .1s, outline-color .1s; border-radius: var(--radius-xs); }
.corr-link:hover { outline: 2px solid var(--accent); outline-offset: -2px; transform: scale(1.06); }
#file-list li { transition: border-color .15s, box-shadow .15s, transform .15s; }
#file-list li:hover { box-shadow: 0 2px 10px var(--shadow); transform: translateY(-1px); }
.toast-stack .toast { animation: toast-in .18s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.grid tbody tr { transition: background .1s; }
.grid tbody tr:hover { background: var(--row-hover); }

/* ── Brand pages: footer, docs, pricing, help steps ── */
.footer {
  max-width: 1280px;
  margin: 24px auto 0;
  padding: 14px 20px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text); }
.footer .link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.footer .link:hover { color: var(--text); filter: none; }
.privacy-list { margin: 8px 0 4px; padding-left: 18px; font-size: 13px; }
.privacy-list li { margin: 6px 0; }
.footer .muted { margin-left: auto; }
.dz-title {
  font-size: var(--step-2);
  font-weight: 700;
  margin: 6px 0 10px;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.help-steps { margin: 8px 0 4px; padding-left: 20px; font-size: 13px; }
.help-steps li { margin: 4px 0; }
.help-box h3 { margin: 14px 0 6px; font-size: 14px; }
.help-box h3:first-child { margin-top: 0; }
.doc { max-width: 760px; }
.doc h1 { font-size: 26px; letter-spacing: -0.02em; margin: 8px 0 12px; }
.doc h2 { font-size: 17px; margin: 26px 0 8px; }
.doc .lede { font-size: 16px; color: var(--text); }
.doc li { margin: 5px 0; }
.doc code { font-family: var(--mono); font-size: 12px; background: var(--input-bg); border: 1px solid var(--row-border); border-radius: var(--radius-xs); padding: 1px 6px; }
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 18px 0; }
.price-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.price-card.featured { border-color: var(--accent); box-shadow: 0 4px 24px var(--shadow); }
.price-card h2 { margin: 0 0 4px; font-size: 16px; }
.price-card .price { font-size: 15px; font-weight: 700; margin: 0 0 10px; }
.price-card ul { margin: 8px 0 12px; padding-left: 18px; font-size: 13px; }
@media (max-width: 760px) {
  .topbar { flex-direction: row; align-items: center; }
  .topnav { margin-left: auto; gap: 10px; }
}

/* ── Empty state: hide data chrome until the first file/SQL result ── */
body.is-empty #tab-data .gridwrap,
body.is-empty #tab-data .pager,
body.is-empty #col-toggle { display: none; }

/* Skeleton preview shown instead of the void (static — no shimmer: nothing is loading yet) */
.skel { padding: var(--space-s) 0; }
.skel-row {
  height: 28px;
  border: 1px solid var(--row-border);
  border-radius: var(--radius-xs);
  background: var(--input-bg);
  margin-bottom: var(--space-2xs);
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html:focus-within { scroll-behavior: auto; }
}
