/* AILANG Document Extractor — Sunholo Design System
   Matches the ecommerce demo: orange brand, charcoal header, Montserrat + JetBrains Mono */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --primary: #e73c17;
  --primary-light: #f25d3b;
  --primary-dark: #c43010;
  --primary-faded: rgba(231, 60, 23, 0.08);

  --charcoal: #314352;
  --charcoal-light: #3d5468;
  --sidebar: #1e293b;

  --purple: #6b46c1;
  --indigo: #4f46e5;
  --indigo-light: #6366f1;

  --bg: #f6f8fa;
  --bg-card: #ffffff;
  --bg-code: #0f172a;
  --bg-input: #f1f5f9;

  --border: #e2e8f0;
  --text-primary: #1a202c;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --success: #059669;
  --success-bg: #ecfdf5;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;

  --ai-orange: #f59e0b;
  --ai-orange-bg: rgba(245, 158, 11, 0.1);
  --contract-purple: #8b5cf6;
  --contract-purple-bg: rgba(139, 92, 246, 0.1);

  --radius: 10px;
  --radius-sm: 6px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.10), 0 4px 10px rgba(0, 0, 0, 0.04);

  --font-display: 'Montserrat', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Menlo', monospace;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(231, 60, 23, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(231, 60, 23, 0.015) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes pipePulse {
  0% { box-shadow: 0 0 0 0 rgba(231, 60, 23, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(231, 60, 23, 0); }
  100% { box-shadow: 0 0 0 0 rgba(231, 60, 23, 0); }
}

/* ── Container ─────────────────────────────────────────────── */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ── Header (compact navbar) ───────────────────────────────── */
header {
  background: var(--charcoal);
  color: white;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.12);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  padding-bottom: 10px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-left img {
  height: 28px;
  width: auto;
}

header h1 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1;
}

header .tagline {
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.55;
  letter-spacing: 0.2px;
  border-left: 1px solid rgba(255,255,255,0.2);
  padding-left: 10px;
  margin-left: 2px;
}

.header-right {
  display: flex;
  gap: 8px;
}

.header-right a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.header-right a:hover {
  color: white;
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.35);
}

.header-right a.nav-demo {
  color: white;
  background: rgba(231, 60, 23, 0.25);
  border-color: var(--primary);
  font-weight: 700;
}

.header-right a.nav-demo:hover {
  background: var(--primary);
  border-color: var(--primary);
}

/* ── Toolbar (demos + API key) ─────────────────────────────── */
.toolbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  padding-bottom: 8px;
  gap: 16px;
}

.toolbar-demos {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 2px;
}

.demo-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.demo-chip:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}

.demo-chip.active {
  border-color: var(--primary);
  background: var(--primary-faded);
  color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-faded);
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.upload-chip,
.demo-chip:has(svg) {
  gap: 5px;
}

.upload-chip svg,
.demo-chip svg {
  flex-shrink: 0;
}

.upload-chip.has-file {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}

.toolbar-key {
  flex-shrink: 0;
}

/* ── API Key Panel ─────────────────────────────────────────── */
.api-key-panel {
  position: relative;
}

.api-key-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  transition: all 0.15s ease;
}

.api-key-header:hover {
  border-color: var(--text-muted);
}

.api-key-header svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Main Content ──────────────────────────────────────────── */
main {
  padding: 20px 0 0;
}

section {
  margin-bottom: 32px;
  animation: fadeInUp 0.4s ease both;
}

section:nth-child(1) { animation-delay: 0.05s; }
section:nth-child(2) { animation-delay: 0.1s; }
section:nth-child(3) { animation-delay: 0.15s; }

section h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

section p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.65;
}

/* ── Section Label ─────────────────────────────────────────── */
.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.demo-badge {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(217, 119, 6, 0.2);
}

.demo-badge.live {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(5, 150, 105, 0.2);
}

.chevron {
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.api-key-panel.open .chevron {
  transform: rotate(180deg);
}

.api-key-body {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 14px;
  width: 340px;
  z-index: 100;
}

.api-key-panel.open .api-key-body {
  display: block;
}

.api-key-input-row {
  display: flex;
  gap: 6px;
}

.api-key-input-row input {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.api-key-input-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-faded);
  background: var(--bg-card);
}

.api-key-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.4;
}

.api-key-note a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.api-key-note a:hover {
  text-decoration: underline;
}

/* ── Legacy demo-btn (unused, kept for compat) ────────────── */

/* ── Pipeline Section (3-column layout) ────────────────────── */
.pipeline-section {
  margin-bottom: 56px;
}

.pipeline-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1.1fr;
  gap: 24px;
  align-items: start;
}

.pipeline-col {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  min-width: 0;          /* prevent content from expanding grid columns */
  overflow: hidden;
}

.pipeline-col h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--charcoal);
  letter-spacing: -0.2px;
}

.col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.col-header h2 {
  margin-bottom: 0;
}

.file-input-hidden {
  display: none;
}

/* ── File Preview ──────────────────────────────────────────── */
.file-preview {
  margin-bottom: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-input);
  position: relative;
}

.file-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.file-preview-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.file-preview-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-size {
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.file-preview-remove {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.file-preview-remove:hover {
  color: var(--error);
}

.file-preview-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  min-height: 120px;
  max-height: 400px;
  overflow: hidden;
}

.file-preview-body img {
  max-width: 100%;
  max-height: 380px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.file-preview-body object,
.file-preview-body iframe {
  width: 100%;
  height: 360px;
  border: none;
  border-radius: var(--radius-sm);
}

.file-preview-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  color: var(--text-secondary);
}

.file-preview-fallback svg {
  color: var(--error);
}

.file-preview-fallback span {
  font-size: 0.82rem;
  font-weight: 500;
}


/* ── Pipeline Steps ────────────────────────────────────────── */
.pipeline-middle h2 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.pipeline-middle pre {
  background: var(--bg-code);
  color: #e2e8f0;
  padding: 14px;
  border-radius: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 500px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.7rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.pipeline-middle code {
  font-family: var(--font-mono);
  font-weight: 400;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.pipeline-steps {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  margin-bottom: 20px;
}

.pipe-step {
  display: grid;
  grid-template-columns: 12px 1fr;
  grid-template-rows: auto auto;
  gap: 0 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.25s ease;
}

.pipe-dot {
  grid-column: 1;
  grid-row: 1;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--text-muted);
  flex-shrink: 0;
  transition: all 0.25s ease;
}

.pipe-step.active .pipe-dot {
  background: var(--primary);
  border-color: var(--primary);
  animation: pipePulse 1.5s ease infinite;
}

.pipe-step.complete .pipe-dot {
  background: var(--success);
  border-color: var(--success);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3.5 6l2 2 3-3.5' fill='none' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 10px 10px;
  background-repeat: no-repeat;
  background-position: center;
}

.pipe-step.error .pipe-dot {
  background: var(--error);
  border-color: var(--error);
}

.pipe-step.active {
  background: var(--primary-faded);
}

.pipe-label {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.pipe-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.pipe-step.active .pipe-name {
  color: var(--primary);
}

.pipe-step.complete .pipe-name {
  color: var(--success);
}

.pipe-log {
  grid-column: 2;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.3;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease, opacity 0.2s ease;
  opacity: 0;
}

.pipe-step.active .pipe-log,
.pipe-step.complete .pipe-log,
.pipe-step.error .pipe-log {
  max-height: 40px;
  opacity: 1;
}

.pipe-step.active .pipe-log {
  color: var(--primary);
}

.pipe-step.complete .pipe-log {
  color: var(--success);
}

.pipe-step.error .pipe-log {
  color: var(--error);
}

.pipe-hint {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  opacity: 0.7;
}

.pipe-step-optional {
  opacity: 0.5;
  transition: opacity 0.3s ease, background 0.25s ease;
}

.pipe-step-optional.active,
.pipe-step-optional.complete {
  opacity: 1;
}

.pipe-connector {
  width: 2px;
  height: 10px;
  background: var(--border);
  margin-left: 15px;
  transition: background 0.25s ease;
}

.pipe-connector.complete {
  background: var(--success);
}

/* ── Effect Badges ─────────────────────────────────────────── */
.effect-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
  line-height: 1.4;
}

.effect-badge.ai {
  background: var(--ai-orange-bg);
  color: var(--ai-orange);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.effect-badge.pure {
  background: rgba(5, 150, 105, 0.08);
  color: var(--success);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.effect-badge.contract {
  background: var(--contract-purple-bg);
  color: var(--contract-purple);
  border: 1px solid rgba(139, 92, 246, 0.25);
}

/* Inline badges (inside tab labels and text) */
.effect-badge.inline {
  font-size: 0.6rem;
  padding: 1px 6px;
  vertical-align: middle;
  margin-right: 4px;
}

.effect-badge.inline-sm {
  font-size: 0.55rem;
  padding: 1px 5px;
  vertical-align: middle;
}

/* Syntax highlighting in generated code */
.generated-code .kw { color: #c792ea; }
.generated-code .fn { color: #82aaff; }
.generated-code .ty { color: #ffcb6b; }
.generated-code .ct { color: #f78c6c; }
.generated-code .st { color: #c3e88d; }
.generated-code .cm { color: #546e7a; }

/* ── Schema Editor ─────────────────────────────────────────── */
.schema-mode-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}

.schema-tab {
  flex: 1;
  padding: 7px 12px;
  border: none;
  background: var(--bg);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s ease;
  text-align: center;
}

.schema-tab.active {
  background: var(--charcoal);
  color: white;
}

.schema-tab:hover:not(.active) {
  background: var(--bg-input);
}

/* Schema name row */
.schema-name-row {
  margin-bottom: 10px;
}

.schema-name-row label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.schema-name-input {
  width: 100%;
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.schema-name-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-faded);
  background: var(--bg-card);
}

/* Field header */
.schema-field-header {
  display: grid;
  grid-template-columns: 1fr 68px 30px 1fr 28px;
  gap: 6px;
  align-items: center;
  padding: 0 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.schema-field-header span {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* Field rows */
.schema-field-row {
  display: grid;
  grid-template-columns: 1fr 68px 30px 1fr 28px;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
}

.schema-field-row input[type="text"],
.schema-field-row select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.15s ease;
}

.schema-field-row input[type="text"]:focus,
.schema-field-row select:focus {
  outline: none;
  border-color: var(--primary);
}

.schema-field-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
  justify-self: center;
}

.field-remove {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.field-remove:hover {
  background: var(--error-bg);
  color: var(--error);
}

/* Detect Schema button */
.btn-detect {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1.5px solid var(--ai-orange);
  border-radius: 20px;
  background: var(--ai-orange-bg);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ai-orange);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-detect:hover {
  background: rgba(245, 158, 11, 0.18);
  border-color: #d97706;
}

.btn-detect:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-detect.detecting {
  animation: pulse 1.2s ease infinite;
}

.btn-detect svg {
  flex-shrink: 0;
}

/* Add field button */
.schema-add-btn {
  display: block;
  width: 100%;
  padding: 6px;
  margin-top: 6px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.schema-add-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-faded);
}

/* AILANG type editor */
.schema-ailang-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ailang-editor-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.ailang-editor-hint code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--primary-faded);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--primary-dark);
}

.ailang-type-textarea {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.6;
  resize: vertical;
  background: #0f172a;
  color: #e2e8f0;
  -webkit-text-fill-color: #e2e8f0;
  -webkit-appearance: none;
  opacity: 1;
  transition: border-color 0.15s ease;
  color-scheme: dark;
}

.ailang-type-textarea:focus,
.ailang-type-textarea:active {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-faded);
  background: #0f172a;
  color: #e2e8f0;
  -webkit-text-fill-color: #e2e8f0;
}

/* ── Output Toolbar (tabs + copy button) ──────────────────── */
.output-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.output-format-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex: 1;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-copy:hover {
  border-color: var(--charcoal);
  color: var(--text-primary);
  background: var(--bg-input);
}

.btn-copy.copied {
  border-color: var(--success);
  color: var(--success);
}

.btn-copy svg {
  flex-shrink: 0;
}

/* Table metadata rows */
.meta-separator .meta-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.meta-row td {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.output-tab {
  flex: 1;
  padding: 6px 10px;
  border: none;
  background: var(--bg);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s ease;
  text-align: center;
}

.output-tab.active {
  background: var(--charcoal);
  color: white;
}

.output-tab:hover:not(.active) {
  background: var(--bg-input);
}

.output-content {
  margin-top: 8px;
}

.output-json {
  background: var(--bg-code);
  color: #e2e8f0;
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.78rem;
  line-height: 1.6;
}

.output-json code {
  font-family: var(--font-mono);
  font-weight: 400;
}

/* Syntax colors for output JSON/AILANG (same as tab-panel) */
.output-json .fn,
.output-ailang .fn { color: #82aaff; }
.output-json .st,
.output-ailang .st { color: #c3e88d; }
.output-json .ct,
.output-ailang .ct { color: #f78c6c; }
.output-json .kw,
.output-ailang .kw { color: #c792ea; }
.output-json .cm,
.output-ailang .cm { color: #546e7a; }

.output-ailang {
  background: var(--bg-code);
  color: #e2e8f0;
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.78rem;
  line-height: 1.6;
}

.output-ailang code {
  font-family: var(--font-mono);
  font-weight: 400;
}

/* ── Demo Panel (legacy, still used by output panel) ───────── */
.demo-panel {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.panel-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

@media (max-width: 968px) {
  .panel-container {
    grid-template-columns: 1fr;
  }
}

.input-panel h2,
.output-panel h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--charcoal);
  letter-spacing: -0.2px;
}

/* ── Examples (legacy) ────────────────────────────────────── */
.examples {
  margin-bottom: 16px;
}

.examples h3 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  color: var(--text-muted);
}

.example-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.example-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  transition: all 0.15s ease;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.example-btn:hover {
  background: var(--bg-card);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.example-btn.success {
  border-color: var(--success);
  color: var(--success);
}

.example-btn.success:hover {
  background: var(--success-bg);
}

.example-btn.error {
  border-color: var(--error);
  color: var(--error);
}

.example-btn.error:hover {
  background: var(--error-bg);
}

.example-btn.active {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.example-btn.success.active {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.example-btn.error.active {
  background: var(--error);
  color: white;
  border-color: var(--error);
}

.example-btn.active .btn-icon.pass {
  background: white;
}

.example-btn.active .btn-icon.fail {
  background: white;
}

/* ── Button Icons (small pass/fail indicators) ────────────── */
.btn-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  background-size: 12px 12px;
  background-repeat: no-repeat;
  background-position: center;
}

.btn-icon.pass {
  background-color: var(--success);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3.5 6l2 2 3-3.5' fill='none' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.btn-icon.fail {
  background-color: var(--error);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4 4l4 4M8 4l-4 4' fill='none' stroke='white' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ── Status Icons (medium, for comparison section) ────────── */
.status-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 6px;
  background-size: 20px 20px;
  background-repeat: no-repeat;
  background-position: center;
}

.status-icon.status-pass {
  background-color: var(--success);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M6 10l3 3 5-6' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.status-icon.status-fail {
  background-color: var(--error);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M7 7l6 6M13 7l-6 6' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ── Result Icons (used in JS-generated result headings) ──── */
.icon-pass,
.icon-fail {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 8px;
  background-size: 22px 22px;
  background-repeat: no-repeat;
  background-position: center;
}

.icon-pass {
  background-color: var(--success);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Cpath d='M6.5 11l3.5 3.5 5.5-6.5' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.icon-fail {
  background-color: var(--error);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Cpath d='M7.5 7.5l7 7M14.5 7.5l-7 7' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ── Button SVG (inline icon in buttons) ──────────────────── */
.btn-svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── Textarea ──────────────────────────────────────────────── */
textarea {
  width: 100%;
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.6;
  resize: vertical;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: all 0.15s ease;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-faded);
  background: var(--bg-card);
}

/* ── Buttons ───────────────────────────────────────────────── */
.button-group {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.btn {
  padding: 10px 22px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.78rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(231, 60, 23, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(231, 60, 23, 0.30);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

/* ── Results Panel ─────────────────────────────────────────── */
#results {
  min-height: 200px;
  padding: 18px;
  background: var(--bg);
  border-radius: 8px;
  border: 1.5px solid var(--border);
  overflow-x: auto;
}

#results table {
  font-size: 0.75rem;
}

#results .placeholder {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 16px;
  font-style: normal;
  font-size: 0.85rem;
}

/* ── Loading ───────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 40px 20px;
}

.loading p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 18px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Status Messages ───────────────────────────────────────── */
.status-success,
.status-error {
  padding: 16px 20px;
  border-radius: 8px;
  margin: 16px 0;
  font-size: 0.9rem;
  font-weight: 500;
}

.status-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.status-success p,
.status-error p {
  display: flex;
  align-items: center;
}

.status-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

/* ── Result: Success ───────────────────────────────────────── */
.result-success {
  padding: 0;
}

.result-success h3 {
  color: var(--success);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
}

.result-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 6px 10px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--ai-orange);
}

.invoice-info {
  background: var(--bg-card);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  border-left: 3px solid var(--success);
  box-shadow: var(--shadow-sm);
}

.invoice-info p {
  margin: 4px 0;
  color: var(--text-primary);
  font-size: 0.88rem;
}

.result-success h4 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin: 18px 0 8px;
}

/* ── Line Items Table ──────────────────────────────────────── */
.line-items-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 0.75rem;
}

.line-items-table th {
  padding: 10px 12px;
  text-align: left;
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 2px solid var(--border);
}

.line-items-table td {
  padding: 10px 12px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.line-items-table tbody tr:hover {
  background: rgba(231, 60, 23, 0.02);
}

.line-items-table tbody tr:last-child td {
  border-bottom: none;
}

/* ── Totals ────────────────────────────────────────────────── */
.totals {
  background: var(--bg-card);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
  border-left: 3px solid var(--primary);
  box-shadow: var(--shadow-sm);
}

.totals p {
  margin: 6px 0;
  font-size: 0.92rem;
  color: var(--text-primary);
  font-weight: 500;
}

.totals .final-total {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--border);
}

/* ── Result: Error ─────────────────────────────────────────── */
.result-error {
  padding: 0;
}

.result-error h3 {
  color: var(--error);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
}

.error-message {
  background: var(--bg-card);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--error);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--error);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.error-explanation {
  background: var(--bg-card);
  padding: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.error-explanation h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.error-explanation p {
  margin: 8px 0;
  font-size: 0.88rem;
}

.error-explanation ul {
  margin: 8px 0 8px 20px;
}

.error-explanation li {
  margin: 4px 0;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.error-wrapper {
  background: var(--warning-bg);
  border: 1px solid rgba(217, 119, 6, 0.3);
}

.error-wrapper details {
  margin-top: 10px;
}

.error-wrapper summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--warning);
  font-size: 0.85rem;
}

.error-wrapper pre {
  background: var(--bg-code);
  color: #e2e8f0;
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  margin-top: 8px;
}

/* ── Code Showcase (tabbed AILANG examples) ────────────────── */
.code-showcase {
  background: var(--bg-card);
  padding: 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.code-showcase > p {
  font-size: 0.92rem;
  margin-bottom: 24px;
}

.code-showcase a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.code-showcase a:hover {
  text-decoration: underline;
}

.showcase-source {
  margin-top: 20px;
  font-size: 0.85rem !important;
  color: var(--text-muted) !important;
}

.showcase-source code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--text-secondary);
}

/* Tab container: flex wrap layout */
.showcase-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

.showcase-tabs input[type="radio"] {
  display: none;
}

.showcase-tabs label {
  padding: 10px 20px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
  letter-spacing: 0.2px;
  user-select: none;
}

.showcase-tabs label:hover {
  color: var(--text-primary);
}

/* Active tab label */
.showcase-tabs input:checked + label {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Tab panels */
.tab-panel {
  display: none;
  width: 100%;
  order: 1;
  margin-top: 4px;
}

/* Show active panel — original invoice processor tabs */
#tab-contracts:checked ~ #panel-contracts,
#tab-guards:checked ~ #panel-guards,
#tab-pattern:checked ~ #panel-pattern,
#tab-types:checked ~ #panel-types,
#tab-recursion:checked ~ #panel-recursion {
  display: block;
}

/* Show active panel — effects showcase tabs */
#fx-docparse:checked ~ #panel-fx-docparse,
#fx-ai:checked ~ #panel-fx-ai,
#fx-contracts:checked ~ #panel-fx-contracts,
#fx-json:checked ~ #panel-fx-json,
#fx-option:checked ~ #panel-fx-option,
#fx-security:checked ~ #panel-fx-security {
  display: block;
}

/* Tab explanation */
.tab-explanation {
  background: var(--bg);
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  border-left: 3px solid var(--primary);
}

.tab-explanation h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.tab-explanation p {
  font-size: 0.88rem;
  line-height: 1.65;
}

.tab-explanation code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: rgba(231, 60, 23, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--primary-dark);
  font-weight: 500;
}

/* Code block inside tab */
.tab-panel pre {
  background: var(--bg-code);
  color: #e2e8f0;
  padding: 20px;
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-panel code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.7;
}

/* Syntax highlighting — Material Palenight inspired */
.tab-panel code .kw { color: #c792ea; }         /* keywords: purple */
.tab-panel code .fn { color: #82aaff; }         /* functions: blue */
.tab-panel code .ty { color: #ffcb6b; }         /* types: yellow-amber */
.tab-panel code .ct { color: #f78c6c; }         /* constructors: orange */
.tab-panel code .st { color: #c3e88d; }         /* strings: green */
.tab-panel code .cm { color: #546e7a; }         /* comments: muted gray */

/* ── Comparison ────────────────────────────────────────────── */
.comparison {
  text-align: center;
}

.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

@media (max-width: 768px) {
  .comparison-grid {
    grid-template-columns: 1fr;
  }
}

.comparison-col {
  padding: 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  text-align: left;
}

.comparison-col.bad {
  background: var(--error-bg);
  border: 1.5px solid rgba(220, 38, 38, 0.2);
}

.comparison-col.good {
  background: var(--success-bg);
  border: 1.5px solid rgba(5, 150, 105, 0.2);
}

.comparison-col h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
}

.comparison-col.bad h3 { color: var(--error); }
.comparison-col.good h3 { color: var(--success); }

.comparison-col ul {
  list-style: none;
}

.comparison-col li {
  padding: 9px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.comparison-col li:last-child {
  border-bottom: none;
}

/* ── Features ──────────────────────────────────────────────── */
.features {
  text-align: center;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.feature {
  background: var(--bg-card);
  padding: 28px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  text-align: left;
}

.feature:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-faded);
}

/* Feature icons: SVG-based */
.feature-icon {
  width: 44px;
  height: 44px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-faded);
  border-radius: 10px;
}

.feature-icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--primary);
}

.feature h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.feature p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ── How It Works ──────────────────────────────────────────── */
.how-it-works {
  text-align: center;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.step {
  padding: 28px 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.step:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.step-number {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 auto 14px;
  box-shadow: 0 3px 10px rgba(231, 60, 23, 0.25);
}

.step h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.step p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ── Call to Action ────────────────────────────────────────── */
.cta {
  text-align: center;
  background: var(--bg-card);
  padding: 48px 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.cta::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 500px 200px at 50% 100%, var(--primary-faded), transparent);
  pointer-events: none;
}

.cta h2 {
  margin-bottom: 12px;
  position: relative;
}

.cta p {
  max-width: 540px;
  margin: 0 auto 28px;
  position: relative;
}

.cta-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  position: relative;
}

/* ── Footer ────────────────────────────────────────────────── */
footer {
  background: var(--charcoal);
  color: white;
  padding: 28px 0;
  text-align: center;
  margin-top: 56px;
}

footer p {
  margin: 6px 0;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.85rem;
}

footer a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  transition: color 0.15s ease;
}

footer a:hover {
  color: var(--primary-light);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .pipeline-grid {
    grid-template-columns: 1fr 1fr;
  }

  .pipeline-middle {
    grid-column: 1 / -1;
    order: -1;       /* code panel goes to top row */
  }

  .pipeline-middle pre {
    max-height: 260px;
  }

  .pipeline-steps {
    margin-bottom: 16px;
  }
}

@media (max-width: 768px) {
  .header-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .header-left {
    flex-wrap: wrap;
  }

  header .tagline {
    display: none;
  }

  .toolbar-row {
    flex-wrap: wrap;
    gap: 8px;
  }

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

  .pipeline-middle {
    display: block;
  }

  .pipeline-steps {
    flex-direction: column;
    gap: 0;
  }

  .pipe-connector {
    height: 6px;
  }

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

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

  .cta {
    padding: 32px 20px;
  }

  .showcase-tabs label {
    padding: 8px 12px;
    font-size: 0.72rem;
  }

  .schema-field-header,
  .schema-field-row {
    grid-template-columns: 1fr 56px 26px 80px 24px;
    gap: 4px;
  }
}

@media (max-width: 480px) {
  .steps {
    grid-template-columns: 1fr;
  }

  .example-buttons {
    gap: 4px;
  }

  .example-btn {
    font-size: 0.68rem;
    padding: 5px 8px;
  }

  .showcase-tabs label {
    padding: 6px 10px;
    font-size: 0.68rem;
  }

  .pipeline-col {
    padding: 16px;
  }

  .schema-field-header,
  .schema-field-row {
    grid-template-columns: 1fr 48px 24px 60px 20px;
    gap: 3px;
  }

  .schema-field-row input[type="text"],
  .schema-field-row select {
    font-size: 0.68rem;
    padding: 4px 6px;
  }
}

/* ── Office Document Preview ──────────────────────────────── */
.office-preview {
  max-height: 600px;
  overflow-y: auto;
  padding: 16px;
}

.office-preview-loading {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.office-preview-fallback {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* DOCX preview — document-like page */
.office-preview-docx {
  padding: 0;
}

.office-preview-page {
  background: white;
  padding: 32px 40px;
  max-width: 800px;
  margin: 16px auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-display);
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-primary);
}

.office-preview-page h1 { font-size: 1.4rem; font-weight: 700; margin: 20px 0 12px; }
.office-preview-page h2 { font-size: 1.15rem; font-weight: 700; margin: 18px 0 10px; }
.office-preview-page h3 { font-size: 1rem; font-weight: 700; margin: 16px 0 8px; }
.office-preview-page p { margin-bottom: 10px; }
.office-preview-page ul, .office-preview-page ol { margin: 8px 0 12px 24px; }
.office-preview-page li { margin-bottom: 4px; }
.office-preview-page table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.82rem;
}
.office-preview-page th,
.office-preview-page td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: left;
}
.office-preview-page th {
  background: var(--bg);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.office-preview-page img { max-width: 100%; height: auto; border-radius: 4px; }

.office-preview-note {
  text-align: center;
  padding: 8px 16px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* XLSX preview — spreadsheet grid */
.office-preview-xlsx {
  padding: 0;
}

.xlsx-sheet-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  overflow-x: auto;
}

.xlsx-sheet-tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s ease;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.xlsx-sheet-tab:hover { color: var(--text-primary); }

.xlsx-sheet-tab.active {
  color: var(--success);
  border-bottom-color: var(--success);
  background: var(--bg-card);
}

.xlsx-sheet-content {
  display: none;
  padding: 12px;
  overflow-x: auto;
}

.xlsx-sheet-content.active {
  display: block;
}

.xlsx-sheet-name {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 8px;
}

.xlsx-table-wrap {
  overflow-x: auto;
  margin-bottom: 16px;
}

.xlsx-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.xlsx-table th {
  padding: 8px 10px;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  white-space: nowrap;
}

.xlsx-table td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  color: var(--text-primary);
  white-space: nowrap;
}

.xlsx-table tbody tr:hover {
  background: rgba(231, 60, 23, 0.02);
}

/* PPTX preview — slide cards */
.office-preview-pptx {
  padding: 16px;
}

.office-preview-thumb {
  text-align: center;
  margin-bottom: 16px;
}

.office-preview-thumb img {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.pptx-slides {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pptx-slide {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.pptx-slide-number {
  background: var(--bg);
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.pptx-slide-content {
  padding: 20px 24px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.pptx-slide-content h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 10px; }
.pptx-slide-content h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.pptx-slide-content p { margin-bottom: 8px; color: var(--text-secondary); }
.pptx-slide-content ul, .pptx-slide-content ol { margin: 8px 0 12px 20px; }
.pptx-slide-content li { margin-bottom: 4px; color: var(--text-secondary); }
.pptx-slide-img { max-width: 100%; height: auto; border-radius: 4px; margin: 8px 0; }

/* PDF preview */
.office-preview-pdf object {
  width: 100%;
  min-height: 500px;
  border: none;
}

/* Image preview */
.office-preview-image {
  text-align: center;
}

.office-preview-image img {
  max-width: 100%;
  max-height: 500px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

/* Text preview */
.office-preview-text pre {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* File preview body for Office docs */
.file-preview-body.office-preview-body {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
}
