@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Sora:wght@300;400;600;700&display=swap');

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #21253a;
  --border: #2e3350;
  --accent: #7c6af7;
  --accent2: #4ecdc4;
  --accent3: #f7c948;
  --text: #e2e4f0;
  --muted: #7a7e9a;
  --code-bg: #12141f;
  --green: #56d364;
  --red: #f85149;
}

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

body {
  font-family: 'Sora', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  padding: 40px 20px;
}

.container {
  max-width: 860px;
  margin: 0 auto;
}

/* ── Navigation ── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 48px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.nav a {
  color: var(--accent2);
  text-decoration: none;
  transition: color 0.2s;
}

.nav a:hover { color: white; }

.nav-chapter {
  color: var(--muted);
  font-size: 0.8rem;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.chapter-nav a {
  color: var(--accent2);
  text-decoration: none;
  transition: color 0.2s;
}

.chapter-nav a:hover { color: white; }

.chapter-nav .center { color: var(--muted); }

/* ── Header ── */
header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 32px;
  margin-bottom: 48px;
}

.tag {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 16px;
}

.tag.teal { background: var(--accent2); color: #0f1117; }

h1 {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: white;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 300;
}

/* ── Index page ── */
.chapter-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 40px;
}

.chapter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: 20px;
  transition: border-color 0.2s, background 0.2s;
}

.chapter-card:hover {
  border-color: var(--accent);
  background: var(--surface2);
}

.chapter-card-num {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  color: white;
  font-family: 'JetBrains Mono', monospace;
}

.chapter-card-body h3 {
  font-size: 1rem;
  font-weight: 600;
  color: white;
  margin-bottom: 6px;
}

.chapter-card-body p {
  font-size: 0.83rem;
  color: var(--muted);
  font-weight: 300;
  margin: 0;
}

.chapter-card-body .topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.topic-pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  padding: 2px 8px;
  border-radius: 4px;
}

/* ── TOC ── */
.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px 28px;
  margin-bottom: 48px;
}

.toc h3 {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}

.toc ol { padding-left: 18px; }
.toc li { margin-bottom: 6px; }

.toc a {
  color: var(--accent2);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.toc a:hover { color: white; }

/* ── Lesson sections ── */
.lesson { margin-bottom: 60px; scroll-margin-top: 24px; }

.lesson-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.lesson-num {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  color: white;
}

h2 {
  font-size: 1.4rem;
  font-weight: 600;
  color: white;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent2);
  margin: 24px 0 10px;
  letter-spacing: 0.01em;
}

h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent3);
  margin: 16px 0 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

p {
  font-size: 0.92rem;
  color: var(--text);
  margin-bottom: 10px;
  font-weight: 300;
}

ul, ol { padding-left: 20px; margin-bottom: 12px; }

li {
  font-size: 0.92rem;
  font-weight: 300;
  margin-bottom: 5px;
  color: var(--text);
}

li li { color: var(--muted); margin-top: 4px; }

/* ── Code ── */
code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--code-bg);
  color: var(--accent3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  overflow-x: auto;
  margin: 14px 0;
}

pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: 0.83rem;
  line-height: 1.8;
}

.comment { color: var(--muted); }
.keyword { color: var(--accent); }
.type    { color: var(--accent2); }
.value   { color: var(--accent3); }
.string  { color: var(--green); }

/* ── Callouts ── */
.callout {
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 14px 18px;
  margin: 14px 0;
  font-size: 0.88rem;
  font-weight: 300;
}

.callout.warn { border-left-color: var(--accent3); }
.callout.tip  { border-left-color: var(--accent2); }

/* ── Two-column ── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 14px 0;
}

.col-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.col-box.green { border-top: 2px solid var(--green); }
.col-box.red   { border-top: 2px solid var(--red); }

.col-box h5 {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.col-box.green h5 { color: var(--green); }
.col-box.red h5   { color: var(--red); }
.col-box li        { font-size: 0.85rem; }

/* ── Memory diagram ── */
.memory-diagram {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin: 14px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

.mem-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 4px;
}

.mem-label       { width: 60px; font-weight: 600; text-align: center; }
.mem-label.stack { color: #7c6af7; }
.mem-label.heap  { color: var(--red); }
.mem-label.data  { color: var(--green); }
.mem-label.text  { color: var(--accent3); }
.mem-desc        { color: var(--muted); font-size: 0.78rem; }
.arrow-down      { text-align: center; color: var(--accent); margin: 2px 0; }
.arrow-up        { text-align: center; color: var(--red); margin: 2px 0; }

/* ── Tables ── */
.type-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.85rem;
}

.type-table th {
  background: var(--surface2);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.type-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 300;
}

.type-table tr:last-child td { border-bottom: none; }
.type-table tr:hover td { background: var(--surface); }

.type-table td:first-child {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent2);
  font-size: 0.8rem;
}

.type-table td:nth-child(2) {
  color: var(--accent3);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
}

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

@media (max-width: 600px) {
  .two-col { grid-template-columns: 1fr; }
  h1 { font-size: 1.7rem; }
  .chapter-card { flex-direction: column; }
}
