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

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  overflow-x: clip;
  max-width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overflow-x: clip;
  max-width: 100%;
}

img,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-warm);
}

.container {
  width: min(100% - 2.5rem, var(--max-width));
  max-width: 100%;
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.2);
  border-bottom: 1px solid var(--border);
}

.site-header.is-scrolled {
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  gap: 1rem;
  min-width: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.logo-mark {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.logo-text {
  display: none;
}

@media (min-width: 480px) {
  .logo-text {
    display: inline;
  }
}

.nav-desktop {
  display: none;
  gap: 0.15rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-desktop a {
  display: block;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.nav-desktop a:hover,
.nav-desktop a.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: var(--bg-muted);
  cursor: pointer;
}

.nav-toggle__bar {
  display: block;
  width: 22px;
  height: 2px;
  margin: 0 auto;
  background: var(--text);
  border-radius: 2px;
  transition: transform var(--transition);
}

.nav-mobile {
  position: fixed;
  top: var(--header-h);
  right: 0;
  bottom: 0;
  width: min(100%, 22rem);
  max-width: 100%;
  background: var(--bg-elevated);
  padding: 2rem 1.5rem;
  transform: translate3d(100%, 0, 0);
  transition: transform var(--transition), visibility var(--transition);
  z-index: 199;
  overflow-x: hidden;
  overflow-y: auto;
  visibility: hidden;
  pointer-events: none;
}

.nav-mobile.is-open {
  transform: translate3d(0, 0, 0);
  visibility: visible;
  pointer-events: auto;
}

.nav-mobile__inner ul {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
}

.nav-mobile__inner a {
  display: block;
  padding: 1rem 0;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.breadcrumb {
  padding: 1rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb span {
  margin: 0 0.4rem;
  opacity: 0.5;
}

.site-footer {
  margin-top: var(--section-pad);
  padding: 3rem 0 2rem;
  background: var(--bg-dark);
  color: var(--text-inverse);
}

.site-footer a {
  color: #a8b4ff;
}

.footer-grid {
  display: grid;
  gap: 2rem;
}

.footer-label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
}

.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-address {
  opacity: 0.75;
}

.footer-bottom {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.8125rem;
  opacity: 0.5;
}

@media (min-width: 900px) {
  .nav-desktop {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
  }

  .nav-toggle {
    display: none;
  }

  .nav-mobile {
    display: none;
  }

  .footer-grid {
    grid-template-columns: 1.5fr 1fr 1fr;
  }
}

.kb-layout {
  display: grid;
  gap: 2.5rem;
  padding: 2rem 0 var(--section-pad);
}

@media (min-width: 1100px) {
  .kb-layout {
    grid-template-columns: var(--toc-width) 1fr;
    align-items: start;
  }

  .kb-toc {
    position: sticky;
    top: calc(var(--header-h) + 1.5rem);
    max-height: calc(100vh - var(--header-h) - 3rem);
    overflow-y: auto;
  }
}
