:root[data-theme="light"] {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1e293b;
  --text-muted: #64748b;
  --connector: #cbd5e1;
  --nav-bg: rgba(255, 255, 255, 0.85);
  --nav-border: #e5e7eb;

  --entry: #2563eb;
  --entry-bg: #eff6ff;
  --orchestration: #7c3aed;
  --orchestration-bg: #f5f3ff;
  --domain: #059669;
  --domain-bg: #ecfdf5;
  --adapter: #d97706;
  --adapter-bg: #fffbeb;
  --shared: #475569;
  --shared-bg: #f1f5f9;

  --node-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --node-shadow-hover: 0 10px 28px rgba(15, 23, 42, 0.12);
  --node-glow: none;
  --tier-ring: rgba(15, 23, 42, 0.04);
}

:root[data-theme="dark"] {
  --bg: #1a1a2e;
  --surface: rgba(255, 255, 255, 0.03);
  --border: rgba(255, 255, 255, 0.08);
  --text: rgba(255, 255, 255, 0.9);
  --text-muted: rgba(255, 255, 255, 0.45);
  --connector: rgba(255, 255, 255, 0.2);
  --nav-bg: rgba(26, 26, 46, 0.9);
  --nav-border: rgba(255, 255, 255, 0.08);

  --entry: #818cf8;
  --entry-bg: rgba(129, 140, 248, 0.14);
  --orchestration: #f472b6;
  --orchestration-bg: rgba(244, 114, 182, 0.14);
  --domain: #22d3ee;
  --domain-bg: rgba(34, 211, 238, 0.14);
  --adapter: #fbbf24;
  --adapter-bg: rgba(251, 191, 36, 0.14);
  --shared: #94a3b8;
  --shared-bg: rgba(148, 163, 184, 0.12);

  --node-shadow: none;
  --node-shadow-hover: 0 0 18px rgba(255, 255, 255, 0.06);
  --node-glow: 0 0 14px;
  --tier-ring: rgba(255, 255, 255, 0.04);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-width: 900px;
}

code {
  font-family: "SF Mono", "Fira Code", ui-monospace, monospace;
  font-size: 0.92em;
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 60px 40px;
}

/* === Nav === */

#nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--nav-border);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 40px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-logo {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.3px;
}

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-link {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s, background 0.2s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-link.active {
  color: var(--text);
  background: var(--surface);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

:root[data-theme="light"] .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }

/* === Hero === */

#hero {
  text-align: center;
  padding-top: 80px;
  padding-bottom: 32px;
}

#hero h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.hero-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.6;
}

/* === Section titles === */

.section-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.section-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

/* === Diagram === */

.arch-diagram {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 48px;
  padding: 24px 0;
}

.arch-connectors {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.tier {
  position: relative;
  z-index: 2;
  background: var(--tier-ring);
  border-radius: 18px;
  padding: 20px 24px 24px;
}

.tier-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.tier-nodes {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.tier-nodes-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.ctx-node {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  min-width: 180px;
  max-width: 260px;
  flex: 1 1 180px;
  box-shadow: var(--node-shadow);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ctx-node:hover {
  transform: translateY(-3px);
  box-shadow: var(--node-shadow-hover);
}

.ctx-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
}

.ctx-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.2px;
}

.ctx-pkg {
  font-family: "SF Mono", "Fira Code", ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-muted);
}

.ctx-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 4px;
}

.ctx-node-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.ctx-node-link:hover {
  border-color: var(--domain);
}

.ctx-node-cta {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--domain);
  letter-spacing: -0.1px;
}

/* Tier-specific coloring */

.ctx-node[data-tier="entry"] { border-color: var(--entry); }
.ctx-node[data-tier="entry"] .ctx-icon { background: var(--entry-bg); color: var(--entry); }
.ctx-node[data-tier="entry"]:hover { box-shadow: var(--node-shadow-hover), var(--node-glow) var(--entry); }

.ctx-node[data-tier="orchestration"] { border-color: var(--orchestration); }
.ctx-node[data-tier="orchestration"] .ctx-icon { background: var(--orchestration-bg); color: var(--orchestration); }
.ctx-node[data-tier="orchestration"]:hover { box-shadow: var(--node-shadow-hover), var(--node-glow) var(--orchestration); }

.ctx-node[data-tier="domain"] { border-color: var(--domain); }
.ctx-node[data-tier="domain"] .ctx-icon { background: var(--domain-bg); color: var(--domain); }
.ctx-node[data-tier="domain"]:hover { box-shadow: var(--node-shadow-hover), var(--node-glow) var(--domain); }

.ctx-node[data-tier="adapter"] { border-color: var(--adapter); }
.ctx-node[data-tier="adapter"] .ctx-icon { background: var(--adapter-bg); color: var(--adapter); }
.ctx-node[data-tier="adapter"]:hover { box-shadow: var(--node-shadow-hover), var(--node-glow) var(--adapter); }

.ctx-node[data-tier="shared"] { border-color: var(--shared); }
.ctx-node[data-tier="shared"] .ctx-icon { background: var(--shared-bg); color: var(--shared); }
.ctx-node[data-tier="shared"]:hover { box-shadow: var(--node-shadow-hover), var(--node-glow) var(--shared); }

.tier-note {
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* === Dependency table === */

.dep-table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--node-shadow);
}

.dep-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.dep-table th,
.dep-table td {
  text-align: left;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

.dep-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  background: var(--bg);
}

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

.dep-table tbody tr:hover {
  background: var(--bg);
}

.dep-table code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.dep-table em {
  color: var(--text-muted);
  font-size: 13px;
}

.tier-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 6px;
}

.pill-entry { background: var(--entry-bg); color: var(--entry); }
.pill-orchestration { background: var(--orchestration-bg); color: var(--orchestration); }
.pill-domain { background: var(--domain-bg); color: var(--domain); }
.pill-adapter { background: var(--adapter-bg); color: var(--adapter); }
.pill-shared { background: var(--shared-bg); color: var(--shared); }

/* === Legend === */

.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.legend-card {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--node-shadow);
}

.legend-swatch {
  width: 10px;
  align-self: stretch;
  border-radius: 3px;
  flex-shrink: 0;
}

.swatch-entry { background: var(--entry); }
.swatch-orchestration { background: var(--orchestration); }
.swatch-domain { background: var(--domain); }
.swatch-adapter { background: var(--adapter); }
.swatch-shared { background: var(--shared); }

.legend-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.legend-body strong {
  font-size: 14px;
  font-weight: 700;
}

.legend-body span {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* === Footer === */

footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 40px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.footer-inner a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

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

/* === Connector SVG === */

.arch-connector-line {
  stroke: var(--connector);
  stroke-width: 1.6;
  fill: none;
}

.arch-connector-arrow {
  fill: var(--connector);
}
