:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --surface-3: #f0f0f0;
  --text: #171717;
  --muted: #666666;
  --faint: #8f8f8f;
  --border: #eaeaea;
  --border-strong: #d4d4d4;
  --black: #0a0a0a;
  --accent: #0070f3;
  --accent-soft: rgba(0, 112, 243, 0.08);
  --accent-line: rgba(0, 112, 243, 0.25);
  --gradient: linear-gradient(135deg, #0070f3 0%, #7928ca 100%);
  --error: #e5484d;
  --error-text: #cd2b31;
  --error-bg: #fff0f0;
  --error-line: #fdd8d8;
  --warn: #f5a524;
  --warn-text: #a35200;
  --warn-bg: #fff8eb;
  --warn-line: #ffe7bf;
  --ok: #16a34a;
  --ok-text: #11743a;
  --ok-bg: #effbf3;
  --ok-line: #c9f0d6;
  --topbar: 64px;
  --radius: 12px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.03);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.04), 0 12px 32px -8px rgba(0, 0, 0, 0.12);
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  position: relative;
  min-height: 100vh;
  background: var(--bg-soft);
  color: var(--text);
  font: 15px/1.55 "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 640px;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, #000 30%, transparent 100%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, #000 30%, transparent 100%);
}

body::after {
  content: "";
  position: fixed;
  top: -260px;
  left: 50%;
  width: 900px;
  height: 480px;
  z-index: -1;
  pointer-events: none;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(0, 112, 243, 0.1), rgba(121, 40, 202, 0.05) 60%, transparent);
  filter: blur(20px);
}

::selection {
  background: rgba(0, 112, 243, 0.18);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.dataset-chip svg,
.dropzone svg,
.composer svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted {
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  transition:
    background 0.2s var(--ease),
    border-color 0.2s var(--ease),
    color 0.2s var(--ease),
    box-shadow 0.2s var(--ease),
    transform 0.2s var(--ease),
    opacity 0.2s;
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

button:focus-visible,
textarea:focus-visible,
summary:focus-visible,
.dropzone:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ghost {
  white-space: nowrap;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.ghost:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  border-radius: 4px;
}

.link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.spotlight {
  position: relative;
  isolation: isolate;
}

.spotlight::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(420px circle at var(--x, 50%) var(--y, 50%), rgba(0, 112, 243, 0.07), transparent 45%);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.spotlight:hover::after {
  opacity: 1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand svg {
  width: 26px;
  height: 26px;
  transition: transform 0.6s var(--ease);
}

.brand:hover svg {
  transform: rotate(120deg);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.usage {
  display: inline-block;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.usage::before {
  content: "";
  display: inline-block;
  vertical-align: 1px;
  margin-right: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.usage.out {
  color: var(--error-text);
  border-color: var(--error-line);
  background: var(--error-bg);
}

.usage.out::before {
  background: var(--error);
  box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.15);
}

.usage[hidden],
.ghost[hidden],
.primary[hidden] {
  display: none;
}

#sign-up {
  margin: 0;
  padding: 7px 12px;
  font-size: 13.5px;
  white-space: nowrap;
}

.github {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--muted);
  transition: color 0.2s var(--ease), background 0.2s var(--ease), transform 0.2s var(--ease);
}

.github:hover {
  color: var(--text);
  background: var(--surface-2);
  transform: translateY(-1px);
}

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

.github svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.dataset-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 14px;
}

.dataset-chip[hidden] {
  display: none;
}

.dataset-chip svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--faint);
}

#dataset-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#dataset-size {
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12.5px;
}

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 24px 56px;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(4px);
  }
}

.upload-view:not([hidden]) {
  animation: enter 0.6s var(--ease) both;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.login-dialog {
  width: min(400px, calc(100vw - 32px));
  margin: auto;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  overflow: visible;
}

.login-dialog[open] {
  animation: pop 0.4s var(--ease);
}

.login-dialog::backdrop {
  background: rgba(250, 250, 250, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.login-dialog[open]::backdrop {
  animation: fade 0.3s ease;
}

.login-card {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 32px;
  box-shadow: var(--shadow-hover);
}

.close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
}

.close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.login-mark {
  width: 40px;
  height: 40px;
  margin-bottom: 20px;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 24px;
}

.login-card label {
  font-weight: 500;
  font-size: 13.5px;
  margin: 0 0 6px;
}

.login-hint {
  margin: 16px 0 0;
  font-size: 12.5px;
  color: var(--faint);
  text-align: center;
}

.login-hint a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s var(--ease);
}

.login-hint a:hover {
  color: var(--text);
}

.login-card input {
  font: inherit;
  padding: 9px 12px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.login-card input:hover {
  border-color: #b5b5b5;
}

.login-card input:focus-visible {
  outline: none;
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.primary {
  border: 0;
  background: var(--black);
  color: #fff;
  font-weight: 500;
  padding: 10px 16px;
  margin-top: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.primary:hover:not(:disabled) {
  background: #2b2b2b;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.35);
  transform: translateY(-1px);
}

.upload-view {
  max-width: 760px;
  margin: 48px auto 0;
  text-align: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 6px;
  margin-bottom: 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  color: var(--muted);
  box-shadow: var(--shadow-sm);
}

.eyebrow b {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--black);
  color: #fff;
  font-size: 11.5px;
  font-weight: 500;
}

.upload-view h1 {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.05;
  background: linear-gradient(180deg, #000 20%, #6b6b6b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
  margin: 18px auto 36px;
  max-width: 580px;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 52px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition:
    border-color 0.25s var(--ease),
    box-shadow 0.25s var(--ease),
    transform 0.25s var(--ease);
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--black);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.dropzone.dragging {
  border-style: solid;
  background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--gradient) border-box;
  border-color: transparent;
}

.dropzone.busy {
  pointer-events: none;
  opacity: 0.6;
}

.dropzone svg {
  width: 44px;
  height: 44px;
  padding: 11px;
  margin-bottom: 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: transform 0.35s var(--ease);
}

.dropzone:hover svg,
.dropzone.dragging svg {
  transform: translateY(-4px);
}

.dropzone strong {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.status:empty {
  display: none;
}

.status {
  margin: 14px 0 0;
  color: var(--muted);
  animation: enter 0.35s var(--ease);
}

.status.error {
  color: var(--error-text);
  background: var(--error-bg);
  border: 1px solid var(--error-line);
  border-radius: 8px;
  padding: 10px 14px;
}

#sample-button {
  margin-top: 20px;
}

.how {
  list-style: none;
  counter-reset: how;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0;
  margin: 48px 0 0;
  text-align: left;
}

.how li {
  counter-increment: how;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: enter 0.6s var(--ease) both;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}

.how li:nth-child(2) {
  animation-delay: 0.08s;
}

.how li:nth-child(3) {
  animation-delay: 0.16s;
}

.how li:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-strong);
}

.how li::before {
  content: counter(how, decimal-leading-zero);
  display: block;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
}

.how strong,
.how span {
  display: block;
}

.how strong {
  margin-bottom: 4px;
  font-weight: 600;
}

.how span {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 460px);
  gap: 20px;
  align-items: start;
}

.workspace[hidden],
.upload-view[hidden] {
  display: none;
}

.overview {
  min-width: 0;
}

.overview > *,
.chat {
  animation: enter 0.6s var(--ease) both;
}

.overview > :nth-child(2) {
  animation-delay: 0.06s;
}

.overview > :nth-child(3) {
  animation-delay: 0.12s;
}

.overview > :nth-child(4) {
  animation-delay: 0.18s;
}

.chat {
  animation-delay: 0.1s;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}

.overview .card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
}

.card h2 {
  margin-bottom: 14px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card-head h2 {
  margin: 0;
}

.card-head .muted {
  font-size: 13px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  min-width: 0;
  box-shadow: var(--shadow);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}

.stat:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat small {
  display: block;
  margin-top: 4px;
  color: var(--faint);
  font-size: 12px;
}

.quality {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.quality li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  animation: enter 0.5s var(--ease) both;
  transition: transform 0.2s var(--ease);
}

.quality li:hover {
  transform: translateX(3px);
}

.quality li:nth-child(2) {
  animation-delay: 0.05s;
}

.quality li:nth-child(3) {
  animation-delay: 0.1s;
}

.quality li:nth-child(4) {
  animation-delay: 0.15s;
}

.quality li:nth-child(n + 5) {
  animation-delay: 0.2s;
}

.quality li::before {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.quality li.ok {
  background: var(--ok-bg);
  border-color: var(--ok-line);
  color: var(--ok-text);
}

.quality li.ok::before {
  content: "✓";
  background: var(--ok);
}

.quality li.warn {
  background: var(--warn-bg);
  border-color: var(--warn-line);
  color: var(--warn-text);
}

.quality li.warn::before {
  content: "!";
  background: var(--warn);
}

.quality li.info::before {
  content: "i";
  background: var(--faint);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th,
td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  transition: background 0.15s;
}

tbody tr:hover {
  background: var(--surface-2);
}

tbody tr:last-child td {
  border-bottom: 0;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  background: var(--bg-soft);
}

.number {
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

th.number {
  font-family: inherit;
  font-size: 12.5px;
}

td.empty {
  color: var(--faint);
  font-style: italic;
}

.type {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--muted);
}

.type.numeric {
  background: #ebf5ff;
  border-color: #cfe4ff;
  color: #0059c9;
}

.type.datetime {
  background: #f5ecff;
  border-color: #e6d4fb;
  color: #6b21a8;
}

.type.boolean {
  background: var(--ok-bg);
  border-color: var(--ok-line);
  color: var(--ok-text);
}

.missing-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.bar {
  width: 48px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--warn);
  transform-origin: left;
  animation: grow 0.9s var(--ease) both 0.3s;
}

@keyframes grow {
  from {
    transform: scaleX(0);
  }
}

.chat {
  position: sticky;
  top: calc(var(--topbar) + 28px);
  height: calc(100vh - var(--topbar) - 56px);
  min-height: 480px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-hover);
}

.chat-head {
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.chat-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-head h2::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 6px rgba(22, 163, 74, 0.05);
  }
}

.chat-head p {
  margin: 2px 0 0;
  font-size: 13px;
}

.messages {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-soft);
}

.message {
  max-width: 100%;
  border-radius: 12px;
  padding: 11px 15px;
  font-size: 14.5px;
  animation: rise 0.4s var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.message.user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--black);
  color: #fff;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, 0.35);
}

.message.assistant {
  align-self: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}

.message.assistant > * + * {
  margin-top: 12px;
}

.message.assistant > [hidden] {
  display: none;
}

.answer-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

.chip {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.chip:hover:not(:disabled) {
  border-color: var(--black);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.15);
}

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.badge[data-status="clarify"],
.badge[data-status="empty"] {
  background: var(--warn-bg);
  border-color: var(--warn-line);
  color: var(--warn-text);
}

.badge[data-status="unsupported"],
.badge[data-status="error"] {
  background: var(--error-bg);
  border-color: var(--error-line);
  color: var(--error-text);
}

.message.error {
  border-color: var(--error-line);
  background: linear-gradient(180deg, var(--error-bg), var(--surface) 70%);
}

.chart {
  min-height: 260px;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 4px 6px 0;
}

.result-table {
  max-height: 280px;
}

.result-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 13px;
}

.result-foot .link {
  font-size: 13px;
}

.warnings {
  margin: 0;
  padding: 9px 12px 9px 28px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn-text);
  border-radius: 8px;
  font-size: 13px;
}

.trace {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  font-size: 13px;
}

.trace summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  border-radius: 4px;
  transition: color 0.2s;
}

.trace summary:hover {
  color: var(--text);
}

.trace[open] > :not(summary) {
  animation: enter 0.35s var(--ease) both;
}

.steps {
  margin: 10px 0 0;
  padding-left: 20px;
}

.steps li + li {
  margin-top: 5px;
}

.steps li::marker {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 12px;
}

.steps code {
  font: 12.5px/1.4 var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 6px;
}

.definitions h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 12px 0 4px;
}

.definitions ul {
  margin: 0;
  padding-left: 18px;
}

.definitions li + li {
  margin-top: 4px;
}

.trace-meta {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
  overflow-wrap: anywhere;
}

.typing {
  display: inline-flex;
  gap: 5px;
  padding: 5px 0;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text);
  animation: blink 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.2;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 12px 4px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.composer textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  font: inherit;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.composer textarea:hover:not(:disabled) {
  border-color: #b5b5b5;
}

.composer textarea::placeholder {
  color: var(--faint);
}

.composer textarea:focus-visible {
  outline: none;
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.composer button {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  background: var(--black);
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.composer button:hover:not(:disabled) {
  background: #2b2b2b;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.4);
}

.composer button:hover:not(:disabled) svg {
  transform: translateX(2px);
}

.composer svg {
  width: 19px;
  height: 19px;
  stroke-width: 2.2;
  transition: transform 0.2s var(--ease);
}

.composer-hint {
  margin: 0;
  padding: 0 14px 10px;
  font-size: 12px;
  color: var(--faint);
  background: var(--surface);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .overview {
    display: contents;
  }

  .overview > * {
    margin-bottom: 0;
  }

  .quality-card {
    order: 1;
  }

  .chat {
    order: 2;
    position: static;
    height: 75vh;
  }

  .columns-card {
    order: 3;
  }

  .sample-card {
    order: 4;
  }
}

@media (max-width: 640px) {
  main {
    padding: 16px 16px 32px;
  }

  .topbar {
    padding: 0 16px;
  }

  .brand span {
    display: none;
  }

  .upload-view {
    margin-top: 16px;
  }

  .lead {
    font-size: 15.5px;
  }

  .how {
    grid-template-columns: 1fr;
  }

  #dataset-size,
  .dataset-chip svg {
    display: none;
  }

  .topbar-right {
    gap: 8px;
  }

  .usage {
    font-size: 12px;
    padding: 3px 8px;
  }

  .usage-word {
    display: none;
  }

  .message.user {
    max-width: 92%;
  }
}
