:root {
  color-scheme: dark;
  --bg: #100b1d;
  --bg-soft: #171027;
  --surface: #191128;
  --surface-soft: #211633;
  --text: #f4efff;
  --muted: #b9aacd;
  --line: #34264a;
  --accent: #a78bfa;
  --accent-strong: #c4b5fd;
  --accent-soft: #2d2145;
  --code-bg: #0b0713;
  --code-text: #f6f0ff;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f8f5ff;
  --bg-soft: #efe7ff;
  --surface: #ffffff;
  --surface-soft: #fbf9ff;
  --text: #241b36;
  --muted: #716384;
  --line: #e3d8f4;
  --accent: #7c3aed;
  --accent-strong: #5b21b6;
  --accent-soft: #ede9fe;
  --code-bg: #1d1530;
  --code-text: #f6f0ff;
  --shadow: 0 16px 40px rgba(56, 31, 91, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 16%, transparent), transparent 34rem),
    linear-gradient(180deg, var(--bg), var(--bg-soft));
  min-height: 100vh;
}

a {
  color: var(--accent-strong);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

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

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header__inner,
.site-footer__inner,
.page {
  width: min(100% - 32px, 1680px);
  margin: 0 auto;
}

.site-header__inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-title {
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.site-nav a,
.theme-toggle,
.search-trigger {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
}

.site-nav a:hover,
.theme-toggle:hover,
.search-trigger:hover {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.theme-toggle,
.search-trigger {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  gap: 8px;
}

.search-trigger {
  min-width: 180px;
  justify-content: space-between;
}

.search-trigger__icon,
.theme-toggle__icon {
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 0 0 4px var(--accent-soft);
  display: inline-block;
  height: 10px;
  width: 10px;
}

.search-trigger kbd {
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  padding: 1px 5px;
}

.page {
  padding: 44px 0 56px;
  display: grid;
  grid-template-columns: minmax(240px, 18vw) minmax(0, 1fr);
  align-items: start;
  gap: 28px;
}

.sidebar {
  position: sticky;
  top: 88px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(56, 31, 91, 0.08);
  padding: 16px;
}

.sidebar__title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.sidebar-nav__group {
  display: grid;
  gap: 2px;
}

.sidebar-nav__folder {
  align-items: stretch;
  display: grid;
  gap: 4px;
  grid-template-columns: 30px minmax(0, 1fr);
}

.sidebar-nav__toggle {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  min-height: 34px;
  padding: 0;
}

.sidebar-nav__toggle:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.sidebar-nav__toggle span {
  border-bottom: 5px solid transparent;
  border-left: 6px solid currentColor;
  border-top: 5px solid transparent;
  display: block;
  height: 0;
  transition: transform 160ms ease;
  width: 0;
}

.sidebar-nav__toggle[aria-expanded="true"] span {
  transform: rotate(90deg);
}

.sidebar-nav__children {
  border-left: 1px solid var(--line);
  display: grid;
  gap: 2px;
  margin: 2px 0 6px 10px;
  padding-left: 10px;
}

.sidebar-nav__children[hidden] {
  display: none;
}

.sidebar-nav__link {
  border-radius: 6px;
  color: var(--muted);
  display: block;
  font-size: 0.95rem;
  line-height: 1.35;
  padding: 7px 9px;
  text-decoration: none;
}

.sidebar-nav__link:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.sidebar-nav__link.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.sidebar-nav__link--child {
  font-size: 0.9rem;
}

.sidebar-nav__link--folder {
  min-width: 0;
}

.content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 4vw, 64px);
  width: 100%;
}

.content > :first-child {
  margin-top: 0;
}

.content > :last-child {
  margin-bottom: 0;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 1.7em 0 0.65em;
}

h1 {
  font-size: clamp(2rem, 8vw, 4.4rem);
  max-width: 12ch;
}

h2 {
  font-size: 1.55rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--line);
}

h3 {
  font-size: 1.12rem;
}

p,
ul,
ol {
  max-width: 82ch;
}

table,
pre {
  max-width: 100%;
}

li + li {
  margin-top: 0.25rem;
}

table {
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  width: max-content;
}

th,
td {
  border: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-soft);
  color: var(--text);
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.94em;
}

:not(pre) > code {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.08em 0.32em;
}

pre {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
}

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

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.site-footer__inner {
  padding: 24px 0;
  font-size: 0.92rem;
}

.search-backdrop {
  align-items: flex-start;
  background: rgba(10, 6, 18, 0.62);
  backdrop-filter: blur(14px);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 12vh 16px 32px;
  position: fixed;
  z-index: 100;
}

.search-backdrop[hidden] {
  display: none;
}

.search-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  max-height: min(680px, 80vh);
  overflow: hidden;
  width: min(100%, 760px);
}

.search-panel__header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

.search-panel__header h2 {
  border: 0;
  font-size: 1rem;
  margin: 0;
  padding: 0;
}

.search-panel__close {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: 5px 9px;
}

.search-panel__close:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.search-box {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  padding: 14px 18px;
}

.search-box__icon {
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 0 0 5px var(--accent-soft);
  flex: 0 0 auto;
  height: 12px;
  width: 12px;
}

.search-box input {
  background: transparent;
  border: 0;
  color: var(--text);
  flex: 1;
  font: inherit;
  font-size: 1.05rem;
  min-width: 0;
  outline: 0;
}

.search-box input::placeholder {
  color: var(--muted);
}

.search-results {
  display: grid;
  gap: 4px;
  max-height: min(520px, 58vh);
  overflow-y: auto;
  padding: 10px;
}

.search-result {
  border-radius: 7px;
  color: var(--text);
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  text-decoration: none;
}

.search-result:hover,
.search-result.is-active {
  background: var(--accent-soft);
}

.search-result__title {
  font-weight: 750;
  line-height: 1.25;
}

.search-result__meta,
.search-results__empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.search-results__empty {
  padding: 18px 12px;
}

.is-search-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .site-header__inner {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding: 14px 0;
    gap: 8px;
  }

  .site-nav a {
    padding-left: 0;
  }

  .search-trigger {
    min-width: 100%;
  }

  .content {
    border-radius: 0;
    margin-inline: -16px;
    border-left: 0;
    border-right: 0;
  }
}

@media (max-width: 820px) {
  .page {
    grid-template-columns: 1fr;
    gap: 18px;
    padding-top: 22px;
  }

  .sidebar {
    position: static;
  }
}
