:root {
  --bg: #0d0d14;
  --sidebar-bg: #111119;
  --sidebar-border: #1e1e2e;
  --text: #cdd6f4;
  --text-muted: #6c7086;
  --text-dim: #9399b2;
  --accent: #F05138;
  --accent-hover: #d9432c;
  --link: #89b4fa;
  --code-bg: #181825;
  --border: #1e1e2e;
  --active-bg: rgba(240, 81, 56, 0.1);
  --active-text: #F05138;
  --sidebar-width: 256px;
  --toc-width: 220px;
  --header-height: 56px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────── */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: rgba(17, 17, 25, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 200;
  gap: 1rem;
}

.logo {
  display: flex; align-items: center; gap: 0.6rem;
  text-decoration: none; color: var(--text);
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
}
.logo-icon {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: white; font-weight: 800;
}
.header-badge {
  font-size: 10px; font-weight: 600;
  background: rgba(240,81,56,0.12);
  color: var(--accent);
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid rgba(240,81,56,0.25);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
header nav { margin-left: auto; display: flex; gap: 1.25rem; align-items: center; }
header nav a {
  color: var(--text-dim); text-decoration: none;
  font-size: 13px; transition: color 0.15s;
}
header nav a:hover { color: var(--text); }
header nav a.gh {
  display: flex; align-items: center; gap: 0.35rem;
}

/* ── Layout ─────────────────────────────────────────── */
.layout { display: flex; margin-top: var(--header-height); }

/* ── Sidebar ─────────────────────────────────────────── */
aside#sidebar {
  position: fixed;
  top: var(--header-height); left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 1.5rem 0 3rem;
}
aside#sidebar::-webkit-scrollbar { width: 3px; }
aside#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-section { margin-bottom: 1.75rem; }
.nav-section-label {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 1.25rem; margin-bottom: 0.3rem;
}
.nav-item {
  display: block;
  padding: 0.38rem 1.25rem;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 13.5px;
  transition: color 0.12s, background 0.12s;
  border-left: 2px solid transparent;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-item.active {
  color: var(--active-text);
  background: var(--active-bg);
  border-left-color: var(--accent);
  font-weight: 500;
}
.nav-item.sub {
  padding-left: 2.1rem;
  font-size: 13px;
}

/* ── Main content ─────────────────────────────────────── */
main {
  margin-left: var(--sidebar-width);
  flex: 1; min-width: 0;
  padding: 3rem 3rem 4rem 3.5rem;
}
@media (min-width: 1300px) {
  main { margin-right: var(--toc-width); max-width: calc(var(--sidebar-width) + 800px + var(--toc-width)); }
}

/* ── Right TOC ─────────────────────────────────────── */
aside#toc { display: none; }
@media (min-width: 1300px) {
  aside#toc {
    display: block;
    position: fixed;
    top: var(--header-height); right: 0;
    width: var(--toc-width);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    padding: 2rem 1.25rem 3rem;
    border-left: 1px solid var(--border);
  }
}
.toc-label {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); margin-bottom: 0.75rem;
}
.toc-list { list-style: none; }
.toc-list a {
  display: block; font-size: 12.5px;
  color: var(--text-muted); text-decoration: none;
  padding: 0.28rem 0; transition: color 0.12s;
  border-left: 2px solid transparent;
  padding-left: 0.6rem;
}
.toc-list a:hover { color: var(--text); }
.toc-list a.active { color: var(--accent); border-left-color: var(--accent); }
.toc-list .toc-h3 { padding-left: 1.4rem; font-size: 12px; }

/* ── Typography ─────────────────────────────────────── */
article h1 {
  font-size: 2.1rem; font-weight: 800; line-height: 1.15;
  color: #fff; margin-bottom: 0.6rem; letter-spacing: -0.02em;
}
.page-description {
  font-size: 1.05rem; color: var(--text-dim);
  margin-bottom: 2.5rem; line-height: 1.6; max-width: 600px;
}
article h2 {
  font-size: 1.35rem; font-weight: 700;
  margin: 2.75rem 0 0.9rem; color: #e2e2f0;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}
article h3 {
  font-size: 1.05rem; font-weight: 600;
  margin: 1.75rem 0 0.65rem; color: #e2e2f0;
}
article h4 {
  font-size: 0.95rem; font-weight: 600;
  margin: 1.25rem 0 0.5rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em; font-size: 11px;
}
article p { margin-bottom: 1rem; }
article a { color: var(--link); text-decoration: none; }
article a:hover { text-decoration: underline; }
article ul, article ol { margin: 0.5rem 0 1rem 1.5rem; }
article li { margin-bottom: 0.4rem; }
article strong { color: #e2e2f0; font-weight: 600; }

article code {
  font-family: "SF Mono", "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.85em; background: var(--code-bg);
  padding: 0.15em 0.45em; border-radius: 4px;
  color: #cba6f7; border: 1px solid var(--border);
}
article pre {
  margin: 1.5rem 0; border-radius: 10px;
  overflow: hidden; border: 1px solid var(--border);
}
article pre code {
  font-size: 13px; background: transparent;
  padding: 0; color: inherit; border: none;
  border-radius: 0; display: block;
  padding: 1.25rem 1.5rem; overflow-x: auto;
}
article pre code::-webkit-scrollbar { height: 4px; }
article pre code::-webkit-scrollbar-thumb { background: var(--border); }

/* ── Code block with label ─────────────────────────── */
.code-block {
  margin: 1.5rem 0; border-radius: 10px;
  overflow: hidden; border: 1px solid var(--border);
}
.code-header {
  background: #161622;
  padding: 0.5rem 1.1rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.code-label { font-size: 12px; color: var(--text-muted); font-family: "SF Mono", monospace; }
.code-lang {
  font-size: 10.5px; font-weight: 700;
  color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em;
}
.code-block pre { margin: 0; border: none; border-radius: 0; }

/* ── Callout boxes ─────────────────────────────────── */
.callout {
  border-radius: 8px; padding: 1rem 1.25rem;
  margin: 1.5rem 0; border-left: 3px solid;
  display: flex; gap: 0.75rem; align-items: flex-start;
}
.callout-note { background: rgba(137,180,250,0.06); border-color: #89b4fa; }
.callout-tip  { background: rgba(166,227,161,0.06); border-color: #a6e3a1; }
.callout-warn { background: rgba(249,226,175,0.06); border-color: #f9e2af; }
.callout-icon { font-size: 1rem; flex-shrink: 0; margin-top: 0.1rem; }
.callout-body { flex: 1; }
.callout-body p { margin: 0; font-size: 13.5px; line-height: 1.55; }
.callout-body p + p { margin-top: 0.4rem; }

/* ── Tables ─────────────────────────────────────────── */
article table { width: 100%; border-collapse: collapse; margin: 1.25rem 0; font-size: 13.5px; }
article th {
  background: var(--code-bg); padding: 0.6rem 1rem;
  text-align: left; font-weight: 600; border: 1px solid var(--border); color: var(--text);
}
article td { padding: 0.6rem 1rem; border: 1px solid var(--border); color: var(--text-dim); vertical-align: top; }
article tr:hover td { background: rgba(255,255,255,0.015); }
article td code { font-size: 12px; }

/* ── Feature cards ─────────────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.card {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.25rem 1.3rem;
  text-decoration: none; display: block;
  transition: border-color 0.15s, transform 0.12s;
}
.card:hover { border-color: rgba(240,81,56,0.5); transform: translateY(-2px); }
.card-icon { font-size: 1.5rem; margin-bottom: 0.65rem; }
.card h3 { font-size: 0.95rem; font-weight: 600; margin: 0 0 0.35rem; color: #e2e2f0; }
.card p { font-size: 12.5px; color: var(--text-muted); margin: 0; line-height: 1.5; }

/* ── Comparison cards ─────────────────────────────── */
.comparison-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.comparison-card {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.5rem;
}
.comparison-card h3 { font-size: 1rem; font-weight: 700; margin: 0 0 0.3rem; color: #fff; }
.comparison-card .tagline { font-size: 12.5px; color: var(--text-muted); margin-bottom: 1rem; }
.comparison-card ul { margin: 0; padding: 0; list-style: none; }
.comparison-card li { font-size: 13px; color: var(--text-dim); padding: 0.25rem 0; border-top: 1px solid var(--border); }
.comparison-card li:first-child { border-top: none; }
.comparison-card li::before { content: "→ "; color: var(--accent); }

/* ── Step list ──────────────────────────────────────── */
.steps { list-style: none; margin: 1rem 0 1rem 0; counter-reset: step; }
.step { counter-increment: step; position: relative; padding-left: 2.75rem; margin-bottom: 1.75rem; }
.step::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 1.75rem; height: 1.75rem;
  background: rgba(240,81,56,0.12); border: 1px solid rgba(240,81,56,0.35);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: var(--accent);
}
.step h4 { font-size: 15px; font-weight: 600; margin-bottom: 0.4rem; color: #e2e2f0; text-transform: none; letter-spacing: 0; }

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 4px; vertical-align: middle; letter-spacing: 0.02em;
}
.badge-swift  { background: rgba(240,81,56,0.12); color: #F05138; border: 1px solid rgba(240,81,56,0.25); }
.badge-new    { background: rgba(166,227,161,0.12); color: #a6e3a1; border: 1px solid rgba(166,227,161,0.25); }
.badge-cloud  { background: rgba(137,180,250,0.1); color: #89b4fa; border: 1px solid rgba(137,180,250,0.2); }
.badge-local  { background: rgba(203,166,247,0.1); color: #cba6f7; border: 1px solid rgba(203,166,247,0.2); }

/* ── Breadcrumb ──────────────────────────────────────── */
.breadcrumb {
  font-size: 12.5px; color: var(--text-muted);
  margin-bottom: 1.25rem; display: flex; gap: 0.5rem; align-items: center;
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb-sep { color: var(--border); }

/* ── Page nav ────────────────────────────────────────── */
.page-nav {
  display: flex; justify-content: space-between;
  margin-top: 4rem; padding-top: 1.75rem;
  border-top: 1px solid var(--border); gap: 1rem;
}
.page-nav a {
  display: flex; flex-direction: column; padding: 0.85rem 1.1rem;
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 8px; text-decoration: none; flex: 1; max-width: 220px;
  transition: border-color 0.15s;
}
.page-nav a:hover { border-color: rgba(240,81,56,0.4); }
.page-nav .next { align-items: flex-end; margin-left: auto; }
.nav-dir { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 0.3rem; }
.nav-title { font-size: 13px; color: var(--link); font-weight: 500; }

/* ── Flow diagram ────────────────────────────────────── */
.flow {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.5rem 2rem; margin: 1.5rem 0;
  font-family: "SF Mono", monospace; font-size: 13px; overflow-x: auto;
}
.flow-row { display: flex; align-items: center; gap: 0.5rem; margin: 0.3rem 0; flex-wrap: wrap; }
.flow-node {
  background: rgba(240,81,56,0.1); border: 1px solid rgba(240,81,56,0.3);
  color: #F05138; padding: 0.3rem 0.75rem; border-radius: 6px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.flow-node.blue {
  background: rgba(137,180,250,0.1); border-color: rgba(137,180,250,0.3); color: #89b4fa;
}
.flow-node.green {
  background: rgba(166,227,161,0.1); border-color: rgba(166,227,161,0.3); color: #a6e3a1;
}
.flow-node.purple {
  background: rgba(203,166,247,0.1); border-color: rgba(203,166,247,0.3); color: #cba6f7;
}
.flow-arrow { color: var(--text-muted); font-size: 14px; }
.flow-label { font-size: 11.5px; color: var(--text-muted); }

/* ── Divider ─────────────────────────────────────────── */
hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }

/* ── Hero (index page) ──────────────────────────────── */
.hero {
  padding: 3rem 0 2.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}
.hero-badges { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.hero h1 { font-size: 2.5rem; margin-bottom: 0.75rem; }
.hero p { font-size: 1.1rem; color: var(--text-dim); max-width: 560px; line-height: 1.6; margin-bottom: 1.5rem; }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.6rem 1.25rem; border-radius: 7px;
  font-size: 14px; font-weight: 600; text-decoration: none;
  transition: opacity 0.15s, transform 0.12s;
}
.btn:hover { opacity: 0.85; transform: translateY(-1px); text-decoration: none; }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}

/* ── Menu toggle (mobile) ────────────────────────────── */
.menu-toggle {
  display: none; background: none; border: none;
  color: var(--text); cursor: pointer; font-size: 20px; padding: 4px;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  .menu-toggle { display: block; }
  aside#sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
  }
  aside#sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.5); }
  main { margin-left: 0; padding: 2rem 1.5rem 3rem; }
}
