html, body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  min-height: 100vh;
  font-size: var(--font-size-root);
  line-height: var(--leading-normal);
}

/* ─── Layout ─── */
.page { max-width: 1600px; margin: 0 auto; padding: var(--space-6) var(--space-5) var(--space-12); }

/* ─── Header ─── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.header-left h1 {
  font-size: var(--text-3xl);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--tracking-tight);
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-info) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-left p {
  color: var(--color-text-muted);
  font-size: var(--text-md);
  margin-top: var(--space-0p5);
}

.header-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1p5);
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--text-base);
  padding: var(--space-1p5) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.header-link:hover { color: var(--color-text); border-color: var(--color-accent); }

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ─── Theme toggle ─── */
.btn-theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--space-8);
  height: var(--space-8);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--text-xl);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  line-height: var(--leading-snug);
  padding: 0;
  flex-shrink: 0;
}
.btn-theme:hover { color: var(--color-text); border-color: var(--color-accent); background: var(--color-accent-a8); }

/* ─── Sample Picker ─── */
.picker-section {
  margin-bottom: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
}

.picker-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.picker-label {
  font-size: var(--text-base);
  font-weight: var(--font-weight-semi);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--color-text-muted);
  flex: 1;
}

.btn-shuffle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--text-xl);
  padding: var(--space-1) var(--space-2);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  line-height: var(--leading-snug);
}
.btn-shuffle:hover { color: var(--color-text); border-color: var(--color-accent); background: var(--color-accent-a8); }

/* Domain filter bar */
.domain-filter-bar {
  display: flex;
  gap: var(--space-1p5);
  overflow-x: auto;
  padding-bottom: var(--space-2p5);
  margin-bottom: var(--space-3);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}
.domain-filter-bar::-webkit-scrollbar { height: var(--space-1); }
.domain-filter-bar::-webkit-scrollbar-track { background: transparent; }
.domain-filter-bar::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--space-0p5); }

.domain-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1p5);
  white-space: nowrap;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  padding: var(--space-1) var(--space-3);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  font-family: var(--font-sans);
  flex-shrink: 0;
}
.domain-pill:hover {
  color: var(--color-text);
  border-color: var(--color-accent);
  background: var(--color-accent-a8);
}
.domain-pill.active {
  color: var(--color-white);
  background: var(--color-accent);
  border-color: var(--color-accent);
}

/* Sample cards grid */
.sample-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--space-2);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sample-card {
  --card-accent-effective: var(--card-accent, var(--color-accent));
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-3p5);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  animation: cardIn 0.18s ease both;
  display: flex;
  flex-direction: column;
  gap: var(--space-1p5);
  position: relative;
  overflow: hidden;
}

.sample-card:nth-child(2) { animation-delay: 0.04s; }
.sample-card:nth-child(3) { animation-delay: 0.08s; }
.sample-card:nth-child(4) { animation-delay: 0.12s; }
.sample-card:nth-child(5) { animation-delay: 0.16s; }
.sample-card:nth-child(6) { animation-delay: 0.20s; }

.sample-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--size-stripe);
  background: var(--card-accent-effective);
  border-radius: 0 var(--space-0p5) var(--space-0p5) 0;
}

.sample-card:hover {
  border-color: var(--card-accent-effective);
  background: var(--color-accent-a6);
  box-shadow: 0 2px 12px var(--color-black-a30);
}

.sample-card.selected {
  border-color: var(--card-accent-effective);
  background: var(--color-accent-a10);
}

.card-domain-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semi);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--card-accent-effective);
  opacity: 0.85;
}

.card-question {
  font-size: var(--text-base);
  color: var(--color-text);
  line-height: var(--leading-tight);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Input area ─── */
.input-section { margin-bottom: var(--space-7); }

.textarea-wrapper {
  position: relative;
  margin-bottom: var(--space-3);
}

textarea {
  width: 100%;
  min-height: 120px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  padding: var(--space-4);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  line-height: var(--leading-normal);
}
textarea::placeholder { color: var(--color-text-faint); }
textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-a15);
}
textarea:disabled { opacity: 0.6; cursor: not-allowed; }

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.hint { color: var(--color-text-faint); font-size: var(--text-md); }

/* ─── Button ─── */
.btn-generate {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-accent);
  color: var(--color-white);
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--space-2p5) var(--space-6);
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semi);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
  white-space: nowrap;
}
.btn-generate:hover:not(:disabled) { background: var(--color-accent-hover); }
.btn-generate:active:not(:disabled) { transform: translateY(1px); }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; }

.spinner {
  width: var(--size-spinner); height: var(--size-spinner);
  border: 2px solid var(--color-white-a30);
  border-top-color: var(--color-white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.loading .spinner { display: block; }
.loading .btn-icon { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Error banner ─── */
.error-banner {
  display: none;
  align-items: flex-start;
  gap: var(--space-2p5);
  background: var(--color-error-a12);
  border: 1px solid var(--color-error-a40);
  border-radius: var(--radius-lg);
  padding: var(--space-3p5) var(--space-4);
  margin-bottom: var(--space-5);
  color: var(--color-error-text);
  font-size: var(--text-md);
}
.error-banner.visible { display: flex; }
.error-banner svg { flex-shrink: 0; margin-top: var(--space-px); }
.error-close {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0 var(--space-1);
  font-size: var(--text-xl);
  opacity: 0.7;
  flex-shrink: 0;
}
.error-close:hover { opacity: 1; }

/* ─── Three-panel grid ─── */
.panels {
  display: grid;
  grid-template-columns: 25fr 50fr 25fr;
  gap: var(--space-4);
  align-items: start;
}

@media (max-width: 768px) {
  .panels { grid-template-columns: 1fr; }
  .header-left h1 { font-size: var(--text-2xl); }
  .sample-cards { grid-template-columns: 1fr; }
}

/* ─── Panel card ─── */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2p5) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  gap: var(--space-2);
  flex-wrap: wrap;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  font-weight: var(--font-weight-semi);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--color-text-muted);
}
.panel-title .dot {
  width: var(--size-dot); height: var(--size-dot);
  border-radius: 50%;
  flex-shrink: 0;
}
.panel--schema .dot   { background: var(--color-info); }
.panel--queries .dot  { background: var(--color-success); }
.panel--explain .dot  { background: var(--color-warning); }

/* ─── Schema textarea (editable) ─── */
.schema-textarea {
  width: 100%;
  min-height: 160px;
  max-height: 500px;
  background: transparent;
  border: none;
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  padding: var(--space-4);
  resize: vertical;
  outline: none;
  line-height: var(--leading-code);
  white-space: pre;
  overflow-x: auto;
}
.schema-textarea::placeholder { color: var(--color-text-faint); font-size: var(--text-base); }
.schema-textarea:focus { background: var(--color-accent-a3); }

/* Schema mode badges */
.schema-mode-badge {
  font-size: var(--text-2xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  padding: var(--space-0p5) var(--space-2);
  border-radius: var(--radius-xs);
  flex-shrink: 0;
  display: none;
}
.schema-mode-badge.badge--provided { display: inline; background: var(--color-info-a15); color: var(--color-info); border: 1px solid var(--color-info-a30); }
.schema-mode-badge.badge--generated { display: inline; background: var(--color-success-a10); color: var(--color-success); border: 1px solid var(--color-success-a30); }

.btn-clear-schema {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--text-xs);
  padding: var(--space-0p5) var(--space-2);
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  display: none;
}
.btn-clear-schema:hover { color: var(--color-error); border-color: var(--color-error); }

/* Schema panel visual states */
.panel--schema.schema--provided { border-color: var(--color-info-a35); }
.panel--schema.schema--generated { border-color: var(--color-success-a25); }

/* ─── Query tab toggle ─── */
.query-tabs {
  display: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
}
.query-tabs.visible { display: flex; }

.tab-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semi);
  letter-spacing: var(--tracking-normal);
  padding: var(--space-1) var(--space-2p5);
  transition: color 0.15s, background 0.15s;
  font-family: var(--font-sans);
  white-space: nowrap;
}
.tab-btn + .tab-btn { border-left: 1px solid var(--color-border); }
.tab-btn:hover:not(:disabled) { color: var(--color-text); background: var(--color-accent-a8); }
.tab-btn.tab-active { background: var(--color-accent); color: var(--color-white); }
.tab-btn:disabled { opacity: 0.35; cursor: default; }

/* Training badge in panel body */
.training-badge {
  display: none;
  align-items: center;
  gap: var(--space-1p5);
  margin: var(--space-2p5) var(--space-4) 0;
  background: var(--color-success-a8);
  border: 1px solid var(--color-success-a25);
  border-radius: var(--radius-md);
  padding: var(--space-1p5) var(--space-2p5);
  font-size: var(--text-sm);
  color: var(--color-success);
  font-weight: var(--font-weight-medium);
}
.training-badge.visible { display: flex; }

/* ─── Copy button ─── */
.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1p5);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-2);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.btn-copy:hover { color: var(--color-text); border-color: var(--color-accent); background: var(--color-accent-a8); }
.btn-copy.copied { color: var(--color-success); border-color: var(--color-success); }
.btn-copy:disabled { opacity: 0.35; cursor: default; }

/* ─── Panel body ─── */
.panel-body {
  padding: 0;
  flex: 1;
  min-height: 160px;
  position: relative;
}

/* Code area */
.code-block {
  margin: 0;
  padding: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  line-height: var(--leading-code);
  overflow-x: auto;
  white-space: pre;
  color: var(--color-text);
  background: transparent;
  min-height: 160px;
}

/* Explanation prose */
.prose {
  padding: var(--space-4);
  font-size: var(--text-md);
  color: var(--color-text);
  line-height: var(--leading-loose);
  min-height: 160px;
}

/* Queries: each query separated */
.query-item {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-4);
}
.query-item:last-child { border-bottom: none; }
.query-num {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-family: var(--font-mono);
  margin-bottom: var(--space-1p5);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
}
.query-code {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  line-height: var(--leading-code);
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--color-text);
}

/* Empty placeholder */
.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  color: var(--color-text-faint);
  font-size: var(--text-base);
  font-style: italic;
  padding: var(--space-4);
  text-align: center;
}

/* ─── Skeleton loading ─── */
.skeleton-wrap {
  padding: var(--space-4);
  display: none;
}
.skeleton-wrap.visible { display: block; }

.skeleton-bar {
  height: var(--size-skeleton);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  margin-bottom: var(--space-2p5);
  animation: pulse 1.4s ease-in-out infinite;
}
.skeleton-bar:last-child { margin-bottom: 0; }
.skeleton-bar.w-full  { width: 100%; }
.skeleton-bar.w-3qtr  { width: 75%; }
.skeleton-bar.w-half  { width: 50%; }
.skeleton-bar.w-2qtr  { width: 60%; }
.skeleton-bar.w-sm    { width: 35%; }

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.9; }
}

/* stagger delays */
.skeleton-bar:nth-child(1) { animation-delay: 0s; }
.skeleton-bar:nth-child(2) { animation-delay: 0.1s; }
.skeleton-bar:nth-child(3) { animation-delay: 0.2s; }
.skeleton-bar:nth-child(4) { animation-delay: 0.3s; }
.skeleton-bar:nth-child(5) { animation-delay: 0.4s; }
.skeleton-bar:nth-child(6) { animation-delay: 0.5s; }

/* ─── TypeQL syntax highlight ─── */
.kw-keyword  { color: var(--syntax-keyword); }
.kw-type     { color: var(--syntax-type); }
.kw-agg      { color: var(--syntax-agg); }
.kw-punct    { color: var(--syntax-punct); }
.kw-string   { color: var(--syntax-string); }
.kw-comment  { color: var(--syntax-comment); font-style: italic; }
.kw-varname  { color: var(--syntax-var); }
.kw-num      { color: var(--syntax-num); }

/* ─── Footer ─── */
.page-footer {
  margin-top: var(--space-10);
  text-align: center;
  color: var(--color-text-faint);
  font-size: var(--text-md);
}
.page-footer a { color: var(--color-text-muted); text-decoration: none; }
.page-footer a:hover { color: var(--color-text); }

