/* ablefy Data Genie — tokens from DESIGN.md */
:root {
  --primary: #2bff99;
  --primary-web: #00ca6a;
  --primary-hover: #76ffca;
  --surface-dark: #21282e;
  --surface-light: #eaeaef;
  --neutral-black: #000004;
  --neutral-white: #fafafc;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --font-body: "Inter", system-ui, sans-serif;
  --font-display: "Klarheit Grotesk", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--neutral-white);
  color: var(--neutral-black);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 var(--space-md);
}

/* Header */
.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-lg) 0 var(--space-md);
}

.wordmark {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0;
}

.pitch {
  margin: var(--space-xs) 0 0;
  font-size: 14px;
  color: var(--surface-dark);
}

.demo-tag {
  flex: none;
  margin-top: var(--space-xs);
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--surface-dark);
  background: var(--surface-light);
  border-radius: var(--radius-full);
  padding: var(--space-xs) 12px;
}

/* Transcript */
#transcript {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-sm) 0 var(--space-lg);
  scroll-behavior: smooth;
}

.msg { display: flex; }
.msg.assistant { justify-content: flex-start; }
.msg.user { justify-content: flex-end; }

.bubble {
  max-width: 85%;
  background: var(--surface-light);
  border-radius: var(--radius-lg);
  padding: 12px var(--space-md);
}

.bubble p { margin: 0; }
.bubble p + p { margin-top: var(--space-sm); }

.msg.user .bubble {
  border-left: 3px solid var(--primary);
  border-top-right-radius: var(--radius-sm);
}

.msg.assistant .bubble { border-top-left-radius: var(--radius-sm); }

.bubble.muted p { color: var(--surface-dark); }

/* Answer cards */
.bubble.card {
  width: 85%;
  padding: var(--space-md);
}

.chart {
  width: 100%;
  margin-top: var(--space-md);
  background: var(--neutral-white);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
}

.table-wrap {
  margin-top: var(--space-md);
  overflow-x: auto;
  background: var(--neutral-white);
  border-radius: var(--radius-md);
}

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

th, td {
  text-align: left;
  white-space: nowrap;
  padding: var(--space-sm) 12px;
}

th {
  font-weight: 600;
  border-bottom: 1px solid var(--surface-light);
}

tbody tr + tr td { border-top: 1px solid var(--surface-light); }

.more-rows, .no-rows {
  margin: var(--space-sm) 0 0;
  font-size: 12px;
  color: var(--surface-dark);
}

.no-rows { font-size: 14px; }

details.sql { margin-top: var(--space-md); }

details.sql summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--primary-web);
  list-style-position: inside;
}

details.sql summary:hover { color: var(--surface-dark); }

details.sql pre {
  margin: var(--space-sm) 0 0;
  padding: 12px;
  background: var(--surface-dark);
  color: var(--neutral-white);
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Typing indicator */
.bubble.typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 14px var(--space-md);
}

.bubble.typing .dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--surface-dark);
  opacity: 0.35;
  animation: pulse 1.2s infinite ease-in-out;
}

.bubble.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.bubble.typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* Composer: chips + input bar */
.composer {
  flex: none;
  padding: var(--space-sm) 0 var(--space-lg);
  background: var(--neutral-white);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--neutral-black);
  background: var(--surface-light);
  border: none;
  border-radius: var(--radius-full);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
}

.chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--primary);
}

.chip:hover { background: var(--primary-hover); }

#ask-form {
  display: flex;
  gap: var(--space-sm);
}

#question {
  flex: 1;
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--neutral-black);
  background: var(--surface-light);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 12px var(--space-md);
  outline: none;
}

#question:focus { border-color: var(--neutral-black); }
#question::placeholder { color: var(--surface-dark); opacity: 0.7; }
#question:disabled { opacity: 0.6; }

.model-select {
  flex: none;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--neutral-black);
  background: var(--surface-light);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  cursor: pointer;
  outline: none;
}

.model-select:focus { border-color: var(--neutral-black); }

.send {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  color: var(--neutral-black);
  background: var(--primary);
  border: none;
  border-radius: var(--radius-full);
  padding: 12px var(--space-lg);
  cursor: pointer;
}

.send:hover { background: var(--primary-hover); }
.send:disabled { opacity: 0.6; cursor: default; }

/* Auth state */
.auth-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.auth-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--surface-dark);
}

.auth-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--primary);
}

.signout {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--surface-dark);
  background: var(--surface-light);
  border: none;
  border-radius: var(--radius-full);
  padding: var(--space-xs) 12px;
  cursor: pointer;
}

.signout:hover { background: var(--primary-hover); color: var(--neutral-black); }

.signin {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-md);
  background: var(--surface-light);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
}

.signin-note {
  margin: 0;
  font-size: 14px;
  color: var(--surface-dark);
}

a.signin-btn {
  display: inline-block;
  text-decoration: none;
}

.login-error { padding-top: var(--space-lg); }
.login-error .signin-btn { margin-top: var(--space-md); }

/* Layout with the conversation sidebar */
.shell { display: flex; height: 100%; }
.shell .page { flex: 1; min-width: 0; }

.sidebar {
  width: 280px;
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-md);
  background: var(--surface-dark);
  color: var(--neutral-white);
}

.new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--neutral-black);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.new-chat:hover { background: var(--primary-hover); }

.sidebar-section {
  margin-top: var(--space-md);
  padding: 0 var(--space-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(250, 250, 252, 0.55);
}

.conv-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conv-item {
  position: relative;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  border-radius: var(--radius-sm);
  padding: 10px 12px 10px 14px;
  font-family: var(--font-body);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: background 0.15s ease;
}
.conv-item:hover { background: rgba(255, 255, 255, 0.07); }
.conv-item.active { background: rgba(255, 255, 255, 0.12); }
.conv-item.active::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 2px;
  background: var(--primary);
}

.conv-title {
  font-size: 14px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.conv-meta { font-size: 12px; color: rgba(250, 250, 252, 0.55); }
.conv-empty { margin: 0; padding: var(--space-sm); font-size: 13px; color: rgba(250, 250, 252, 0.6); }

.sidebar-user {
  margin-top: auto;
  padding-top: var(--space-md);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--neutral-black);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
}
.sidebar-user-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-meta { font-size: 12px; color: rgba(250, 250, 252, 0.55); }

@media (max-width: 820px) {
  .sidebar { display: none; }
}

/* The sidebar's seller card already says who is signed in on wide screens. */
@media (min-width: 821px) {
  .shell .sidebar ~ .page .demo-tag { display: none; }
}

/* Markdown inside replies */
.reply p { margin: 0; }
.reply p + p, .reply p + ul, .reply p + ol, .reply ul + p, .reply ol + p { margin-top: var(--space-sm); }
.reply ul, .reply ol { margin: 0; padding-left: 22px; }
.reply li { margin: 2px 0; }
.reply li p { margin: 0; }
.reply strong { font-weight: 600; }
.reply code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: rgba(33, 40, 46, 0.08);
  border-radius: 4px;
  padding: 1px 5px;
}
.reply a { color: var(--primary-web); text-decoration: underline; text-underline-offset: 2px; }
