:root {
  --bg:        #07101f;
  --surface:   #0d1a2e;
  --surface-2: #102035;
  --border:    #1a3355;
  --primary:   #7dd3fc;
  --green:     #4ade80;
  --purple:    #a78bfa;
  --yellow:    #fbbf24;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius:    8px;
  --max-w:     900px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  line-height: 1.7;
}

code:not(pre code) {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  color: var(--primary);
}

/* ── Nav ────────────────────────────────────────────────────────────── */

nav {
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 2rem;
}

.nav-logo {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: -0.02em;
}
.nav-logo:hover { text-decoration: none; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.nav-links a {
  color: var(--muted);
  font-size: 0.9rem;
  transition: color 0.15s;
}
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--text); }

.nav-cta {
  background: var(--primary);
  color: var(--bg) !important;
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem !important;
  transition: opacity 0.15s;
}
.nav-cta:hover { opacity: 0.85; }

/* ── Page layout ────────────────────────────────────────────────────── */

.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 4rem 2rem;
}

/* ── Hero ───────────────────────────────────────────────────────────── */

.hero {
  padding: 5rem 2rem 4rem;
  text-align: center;
}

.hero-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}

.hero-wordmark {
  font-family: var(--font-mono);
  font-size: clamp(3rem, 10vw, 5.5rem);
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 1.25rem;
}

.hero-tagline {
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  color: var(--muted);
  max-width: 520px;
  margin: 0 auto 2.5rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  border: none;
}
.btn:hover { opacity: 0.85; transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: var(--bg); }
.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

/* ── Etymology cards ────────────────────────────────────────────────── */

.etymology {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 4rem auto;
  max-width: var(--max-w);
  padding: 0 2rem;
}

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

.etym-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.etym-lang {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.etym-word {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.etym-pos {
  font-size: 0.8rem;
  color: var(--purple);
  font-style: italic;
  margin-bottom: 0.75rem;
}

.etym-def {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ── Section ────────────────────────────────────────────────────────── */

.section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 2rem;
}

.section + .section {
  border-top: 1px solid var(--border);
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.section-title {
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.section-body {
  color: var(--muted);
  font-size: 1rem;
  max-width: 660px;
  line-height: 1.7;
}

/* ── Feature grid ───────────────────────────────────────────────────── */

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
  margin-top: 2.5rem;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.feature-icon {
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
}

.feature-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.feature-desc {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ── CTA strip ──────────────────────────────────────────────────────── */

.cta-strip {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4rem 2rem;
  text-align: center;
}

.cta-strip h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.cta-strip p {
  color: var(--muted);
  margin-bottom: 2rem;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Footer ─────────────────────────────────────────────────────────── */

footer {
  padding: 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

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

/* ── Prose (help pages) ─────────────────────────────────────────────── */

.prose h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.prose .lead {
  font-size: 1.1rem;
  color: var(--muted);
  margin-bottom: 3rem;
  line-height: 1.7;
}

.prose h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 2.5rem 0 0.75rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  letter-spacing: -0.02em;
}

.prose h2:first-of-type { margin-top: 1.5rem; padding-top: 1.5rem; }

.prose h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.75rem 0 0.5rem;
}

.prose p {
  color: var(--muted);
  line-height: 1.75;
  margin-bottom: 1rem;
}

.prose ul, .prose ol {
  color: var(--muted);
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.prose li { margin-bottom: 0.35rem; line-height: 1.7; }
.prose li strong { color: var(--text); }

.prose strong { color: var(--text); }

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 1.5rem 0;
}

.prose th {
  text-align: left;
  padding: 0.6rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.prose td {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  color: var(--muted);
  vertical-align: top;
}

.prose td:first-child { color: var(--primary); font-family: var(--font-mono); }

/* ── FAQ ────────────────────────────────────────────────────────────── */

.faq-list {
  margin-top: 2rem;
}

.faq-item {
  border-top: 1px solid var(--border);
  padding: 1.75rem 0;
}

.faq-q {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.faq-a {
  color: var(--muted);
  line-height: 1.75;
}

.faq-a p + p { margin-top: 0.75rem; }
.faq-a code { color: var(--primary); }

/* ── Help index ─────────────────────────────────────────────────────── */

.help-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 2.5rem;
}

.help-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color 0.15s;
  display: block;
  color: var(--text);
}
.help-card:hover { border-color: var(--primary); text-decoration: none; }

.help-card-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 0.4rem;
}

.help-card-desc {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.55;
}

/* ── Breadcrumb ─────────────────────────────────────────────────────── */

.breadcrumb {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb span { margin: 0 0.4rem; }

/* ── Note / callout ─────────────────────────────────────────────────── */

.note {
  background: var(--surface);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.65;
}

.note strong { color: var(--text); }

/* ── Syntax highlighting (.kti / .ktip) ────────────────────────────── */
/* Token → colour mapping mirrors KitengiSyntaxHighlighter.kt          */

/* PROGRAM_KW, START_KW, PIPE, EQUALS, INPUT_ARROW, OUTPUT_ARROW       */
.hl-kw, .hl-start-kw, .hl-pipe, .hl-op { color: #7dd3fc; }

/* NODE_TYPE                                                            */
.hl-node-type { color: #c084fc; }

/* NODE_NAME                                                            */
.hl-node-id { color: #60a5fa; }

/* PORT_NAME, THREAD_INPUT                                              */
.hl-port-name, .hl-thread-port { color: #4ade80; }

/* PORT_TYPE                                                            */
.hl-port-type { color: #fbbf24; }

/* LBRACKET, RBRACKET, COLON                                           */
.hl-bracket, .hl-colon { color: #64748b; }

/* THREAD_NODE                                                          */
.hl-thread-node { color: #93c5fd; }

/* PROGRAM_NAME                                                         */
.hl-prog-name { color: #f1f5f9; font-weight: 600; }

/* DESCRIPTION                                                          */
.hl-desc { color: #64748b; font-style: italic; }

/* VALUE_TEXT                                                           */
.hl-value { color: #a78bfa; }

/* LBRACE, RBRACE                                                       */
.hl-brace { color: #e2e8f0; }

/* ── Code tabs ──────────────────────────────────────────────────────── */

.code-tabs { margin-top: 2rem; }

.code-tab-bar {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
}

.code-tab {
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
  transition: color 0.15s, background 0.15s;
}

.code-tab:last-child { border-right: none; }
.code-tab:hover { color: var(--text); background: var(--surface-2); }
.code-tab.active { color: var(--primary); background: var(--surface-2); }

.code-tabs pre {
  border-radius: 0 0 var(--radius) var(--radius);
  border-top: none;
  margin-top: 0;
}

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

/* ── Preview banner ────────────────────────────────────────────────── */

.preview-banner {
  background: #0f1e0a;
  border-bottom: 1px solid #1a3a0a;
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: #4ade80;
  letter-spacing: 0.04em;
}

.preview-banner a { color: #4ade80; text-decoration: underline; }
