*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #1a1a1a;
  --muted: #555;
  --accent: #2563eb;
  --border: #e5e7eb;
  --bg: #ffffff;
  --pill-bg: #1a1a1a;
  --pill-text: #ffffff;
  --tab-active: #1a1a1a;
  --tab-inactive: #6b7280;
  --max: 780px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ── HERO ── */
.hero {
  text-align: center;
  padding: 72px 24px 56px;
  max-width: var(--max);
  margin: 0 auto;
}

.project-name {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 20px;
}

.authors {
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.authors a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.authors a:hover { text-decoration: underline; }

.affiliation {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 28px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn:hover { opacity: 0.82; }

.btn-dark {
  background: var(--pill-bg);
  color: var(--pill-text);
}

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

/* ── CONTENT WRAPPER ── */
.content {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ── SECTION TITLES ── */
.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-bottom: 16px;
  margin-top: 56px;
  color: var(--ink);
}

/* ── DIVIDER ── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 48px 0 0;
}

/* ── PROSE ── */
p {
  margin-bottom: 16px;
  color: #222;
}

p:last-child { margin-bottom: 0; }

strong { font-weight: 600; }

/* ── PIPELINE FLOW ── */
.pipeline-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
  margin: 28px 0;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.flow-step {
  background: #f3f4f6;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 6px;
  white-space: nowrap;
}

.flow-arrow {
  color: #9ca3af;
  font-size: 1rem;
  padding: 0 6px;
}

/* ── PIPELINE GRID ── */
.pipeline-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 28px 0;
}

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

.pipeline-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}

.pipeline-card .card-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.pipeline-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink);
}

.pipeline-card p {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0;
  line-height: 1.5;
}

/* ── GIF FIGURE ── */
.demo-figure {
  margin: 36px 0;
  text-align: center;
}

.demo-figure img {
  width: 100%;
  max-width: 640px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: inline-block;
}

.demo-figure figcaption {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 10px;
  font-style: italic;
}

/* ── VIDEO COMPARISON ── */
.video-section {
  margin-top: 56px;
}

.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  gap: 0;
}

.tab-btn {
  background: none;
  border: none;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--tab-inactive);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}

.tab-btn:hover { color: var(--ink); }

.tab-btn.active {
  color: var(--tab-active);
  border-bottom-color: var(--tab-active);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.video-wrapper {
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.video-wrapper video {
  width: 100%;
  display: block;
  max-height: 480px;
  object-fit: contain;
}

.video-meta {
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── FOOTER ── */
footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 28px 24px;
  font-size: 0.82rem;
  color: #9ca3af;
}

footer a {
  color: var(--muted);
  text-decoration: none;
}

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

/* ── FLOW DIAGRAMS ── */
.flow-diag {
  margin: 28px 0 20px;
  font-size: 0.78rem;
  width: 100%;
}

.flow-row {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
}

.fnode {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 13px;
  border-radius: 9px;
  border: 1.5px solid;
  flex: 1 1 0;
  min-width: 0;
  gap: 5px;
  line-height: 1.3;
  font-weight: 600;
}

.fnode svg { flex-shrink: 0; }

.fnode-label { font-size: 0.75rem; font-weight: 600; }
.fnode-sub   { font-size: 0.68rem; font-weight: 400; color: inherit; opacity: 0.72; }

.fnode-blue   { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
.fnode-amber  { background: #fffbeb; border-color: #fcd34d; color: #b45309; }
.fnode-green  { background: #f0fdf4; border-color: #86efac; color: #15803d; }
.fnode-red    { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }
.fnode-slate  { background: #f8fafc; border-color: #cbd5e1; color: #475569; }
.fnode-purple { background: #faf5ff; border-color: #d8b4fe; color: #7e22ce; }
.fnode-teal   { background: #f0fdfa; border-color: #99f6e4; color: #0f766e; }
.fnode-dashed { border-style: dashed !important; opacity: 0.85; }

.farrow {
  color: #94a3b8;
  font-size: 1.05rem;
  padding: 0 2px;
  flex-shrink: 0;
  align-self: center;
}

.flow-note {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 500;
  color: #92400e;
  background: #fffbeb;
  border: 1.5px dashed #f59e0b;
  border-radius: 6px;
  padding: 5px 12px;
  margin-top: 8px;
  width: 100%;
  box-sizing: border-box;
}

.flow-note svg { flex-shrink: 0; }

/* labeled arrow for "inject context →" style connectors */
.farrow-labeled {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  flex-shrink: 0;
}

.farrow-labeled .farrow-text {
  font-size: 0.6rem;
  font-weight: 700;
  color: #7e22ce;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.farrow-labeled .farrow { padding: 0; }

/* Error-path sub-row (execution diagram) */
.flow-subrow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  padding-left: 0;
}

.flow-branch {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

/* ── RAG DIAGRAM ── */
.rag-diag {
  margin: 28px 0;
  font-size: 0.78rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  width: 100%;
}

.rag-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.rag-down { color: #94a3b8; font-size: 0.9rem; line-height: 1; padding: 3px 0 3px 37px; }

.rag-db {
  border: 1.5px solid #a78bfa;
  border-radius: 10px;
  background: #faf5ff;
  padding: 12px 14px;
  width: 100%;
}

.rag-db-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #7e22ce;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.rag-chunks {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 7px;
}

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

.rag-chunk {
  border: 1.5px solid;
  border-radius: 7px;
  padding: 7px 9px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.4;
}

.rag-chunk-boost {
  font-size: 0.64rem;
  font-weight: 500;
  opacity: 0.8;
  display: block;
  margin-top: 2px;
}

.rag-chunk-code     { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
.rag-chunk-tutorial { background: #f0fdf4; border-color: #86efac; color: #15803d; }
.rag-chunk-api      { background: #faf5ff; border-color: #d8b4fe; color: #7e22ce; }

/* ── SYNC DIAGRAM ── */
.sync-diag {
  margin: 28px 0;
  font-size: 0.78rem;
}

.sync-tracks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

@media (max-width: 540px) {
  .sync-tracks { grid-template-columns: 1fr; }
}

.sync-track {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.sync-track-label {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 8px;
}

.sync-track .flow-row { flex-wrap: wrap; gap: 3px; }

.sync-merge {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  background: #f8fafc;
  margin-bottom: 8px;
}

.sync-merge-label {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 6px;
}

.sync-formula {
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  font-family: 'SFMono-Regular', 'Consolas', monospace;
}
