:root {
  --bg: #f4f6f8;
  --paper: #ffffff;
  --ink: #1d252f;
  --muted: #677487;
  --line: #dbe2ea;
  --brand: #5a49c6;
  --brand-soft: #ece9ff;
  --accent: #17a38c;
  --topbar-h: 64px;
  --sidebar-w: 278px;
  --toc-w: 230px;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% -20%, #dce9ff 0%, transparent 45%),
    radial-gradient(circle at 20% -20%, #fff7da 0%, transparent 50%),
    var(--bg);
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  height: 100%;
  max-width: 1480px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
}

.brand img {
  width: 125px;
  height: auto;
}

.brand-label {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.search-wrap {
  position: relative;
  max-width: 580px;
}

.search-wrap input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 40px 0 14px;
  font-size: 14px;
  color: var(--ink);
  background: #fbfcff;
}

.search-wrap span {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #8b99aa;
  font-size: 13px;
}

.top-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.top-actions a {
  font-size: 13px;
  color: var(--muted);
}

.top-actions .cta {
  color: #fff;
  background: linear-gradient(90deg, #6350d5, #4f93e8);
  padding: 8px 11px;
  border-radius: 9px;
  font-weight: 700;
}

/* ── Language switcher ── */

.lang-switcher {
  position: relative;
}

.lang-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.03em;
}

.lang-btn:hover {
  background: #f0f3f8;
}

.lang-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(36, 53, 84, 0.12);
  min-width: 130px;
  padding: 4px;
  z-index: 30;
}

.lang-switcher.open .lang-dropdown {
  display: block;
}

.lang-dropdown a {
  display: block;
  padding: 7px 12px;
  font-size: 13px;
  color: #3b4a5e;
  border-radius: 6px;
  font-weight: 500;
}

.lang-dropdown a:hover {
  background: #f0f3f8;
  text-decoration: none;
}

.lang-dropdown a.active {
  background: var(--brand-soft);
  color: #4637a3;
  font-weight: 600;
}

.shell {
  max-width: 1480px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 24px;
  padding: 18px;
}

.sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + 14px);
  align-self: start;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius);
  padding: 12px 10px;
  max-height: calc(100vh - var(--topbar-h) - 30px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #d0d8e4 transparent;
}

.sidebar::-webkit-scrollbar {
  width: 5px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #d0d8e4;
  border-radius: 4px;
}

.sidebar h3 {
  margin: 14px 0 4px 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  color: #8d9bb0;
  letter-spacing: 0.08em;
  font-weight: 700;
}

/* ── Base nav links ── */

.nav-link {
  display: block;
  border-radius: 6px;
  color: #3b4a5e;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 8px;
  line-height: 1.4;
  transition: background 0.12s, color 0.12s;
}

.nav-link:hover {
  background: #f0f3f8;
  text-decoration: none;
  color: #2b3648;
}

.nav-link.active {
  background: var(--brand-soft);
  color: #4637a3;
  font-weight: 600;
}

/* ── Sidebar nav container ── */

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-nav > .nav-link {
  font-size: 13px;
  font-weight: 500;
}

.sidebar-section-title {
  margin: 14px 0 4px 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  color: #8d9bb0;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-family: "Sora", "Segoe UI", sans-serif;
}

.sidebar-section-title:first-child {
  margin-top: 2px;
}

/* ── Nested nav tree ── */

.nav-tree {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
}

.nav-tree ul {
  list-style: none;
  margin: 0;
  padding-left: 12px;
}

.nav-item {
  position: relative;
}

.nav-item > .nav-link.nav-parent {
  padding-right: 28px;
}

.nav-toggle {
  position: absolute;
  top: 3px;
  right: 2px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9aa8ba;
  transition: background 0.12s, color 0.12s;
}

.nav-toggle:hover {
  background: #e8edf4;
  color: #5f7084;
}

.nav-toggle::after {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-left: 4px solid currentColor;
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  transition: transform 0.2s ease;
}

.nav-toggle[aria-expanded="true"]::after {
  transform: rotate(90deg);
}

.nav-children {
  display: none;
  padding: 1px 0;
}

.nav-children.open {
  display: block;
}

/* Tree link sizes — progressively smaller/lighter at depth */

.nav-tree .nav-link {
  font-size: 13px;
  font-weight: 500;
  padding: 4px 8px;
  color: #3b4a5e;
}

.nav-tree .nav-children .nav-link {
  font-size: 12.5px;
  color: #506177;
  padding: 3px 8px;
}

.nav-tree .nav-children .nav-children .nav-link {
  font-size: 12px;
  color: #647588;
  padding: 3px 8px;
}

/* Subtle left border on open tree sections */

.nav-children.open {
  border-left: 1.5px solid #e2e8f0;
  margin-left: 6px;
  padding-left: 6px;
}

/* ── Search results ── */

.search-results {
  list-style: none;
  padding: 0;
  margin: 0;
}

.search-result-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--paper);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-result-card:hover {
  border-color: #c0cce0;
  box-shadow: 0 4px 14px rgba(36, 53, 84, 0.08);
}

.search-result-card a {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand);
}

.search-result-card .search-module-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--brand-soft);
  color: #4637a3;
  padding: 2px 8px;
  border-radius: 6px;
  margin-left: 8px;
  vertical-align: middle;
}

.search-result-card .search-excerpt {
  margin: 6px 0 0;
  font-size: 14px;
  color: #506177;
  line-height: 1.5;
}

.search-result-card .search-excerpt mark {
  background: #fff3cd;
  border-radius: 3px;
  padding: 0 2px;
}

.content {
  min-width: 0;
}

.article {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px clamp(18px, 4vw, 54px);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.breadcrumbs a {
  color: var(--muted);
}

h1,
h2,
h3 {
  font-family: "Sora", "Segoe UI", sans-serif;
  letter-spacing: -0.02em;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(30px, 3.3vw, 42px);
}

h2 {
  margin: 34px 0 10px;
  font-size: 24px;
}

h3 {
  margin: 24px 0 10px;
  font-size: 18px;
}

p,
li {
  color: #3b4758;
  font-size: 16px;
  line-height: 1.65;
}

.intro {
  font-size: 18px;
  color: #506177;
  margin-bottom: 24px;
}

code {
  font-family: "JetBrains Mono", monospace;
  background: #f4f6fd;
  border: 1px solid #e2e8f2;
  border-radius: 7px;
  padding: 2px 6px;
  font-size: 13px;
}

pre {
  background: #121926;
  color: #c9d4e6;
  border-radius: 12px;
  padding: 14px;
  overflow: auto;
}

pre code {
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0;
}

.notice {
  border-left: 4px solid var(--accent);
  background: #ecfbf8;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 18px 0;
  color: #275d55;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.module-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.module-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(36, 53, 84, 0.11);
  border-color: #cfd8e6;
}

.module-card img {
  width: 100%;
  height: 124px;
  object-fit: contain;
  border-radius: 10px;
  background: linear-gradient(180deg, #f7f8ff, #f3f6fb);
  border: 1px solid #e8edf6;
}

.module-card h3 {
  margin: 12px 0 6px;
  font-size: 17px;
  color: #273449;
}

.module-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #5d6e84;
}

.module-hero {
  display: inline-block;
  border: 1px solid #dde5f1;
  background: linear-gradient(135deg, #f7f9ff, #eff5ff);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
}

.module-hero img {
  width: 48px;
  height: 48px;
  display: block;
  image-rendering: auto;
}

.cloned-docs .doc-body,
.cloned-docs [role="main"] {
  margin-top: 20px;
}

.cloned-docs img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}

.cloned-docs table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}

.cloned-docs th,
.cloned-docs td {
  border: 1px solid #dee6f0;
  padding: 8px 10px;
  vertical-align: top;
}

.cloned-docs .alert {
  border-radius: 10px;
  padding: 12px 14px;
  margin: 14px 0;
  border: 1px solid #dbe4ef;
  background: #f5f8fd;
}

.cloned-docs .alert-title {
  margin: 0 0 6px;
  font-weight: 800;
}

.cloned-docs .alert-warning {
  border-color: #ffe3b0;
  background: #fff7e6;
}

.cloned-docs .alert-primary {
  border-color: #cde2ff;
  background: #eef5ff;
}

.toc {
  position: sticky;
  top: calc(var(--topbar-h) + 14px);
  align-self: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 16px;
}

.toc h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7b8999;
}

.toc a {
  display: block;
  color: #5f7084;
  font-size: 14px;
  margin: 8px 0;
}

.toc a:hover {
  color: #3f4f64;
  text-decoration: none;
}

.mobile-menu {
  display: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 10px;
  background: #fff;
  color: #304258;
  font-weight: 700;
}

footer {
  text-align: center;
  font-size: 13px;
  color: #7d8a9b;
  padding: 24px;
}

@media (max-width: 1150px) {
  .shell {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 880px) {
  .topbar-inner {
    grid-template-columns: auto 1fr auto;
    gap: 10px;
  }

  .mobile-menu {
    display: inline-flex;
  }

  .search-wrap {
    max-width: none;
  }

  .top-actions a:not(.cta) {
    display: none;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    width: min(84vw, 320px);
    height: calc(100vh - var(--topbar-h));
    border-radius: 0;
    z-index: 50;
    transform: translateX(-104%);
    transition: transform 0.2s ease;
    max-height: none;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .article {
    padding: 22px 18px;
  }

  .brand-label {
    display: none;
  }
}
