:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --ink: #111111;
  --muted: #666666;
  --line: #dddddd;
  --link: #111111;
  --code: #f6f6f6;
  --header-bg: rgba(255, 255, 255, 0.96);
  --shadow: rgba(0, 0, 0, 0.08);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #101010;
  --panel: #171717;
  --ink: #eeeeee;
  --muted: #a2a2a2;
  --line: #303030;
  --link: #eeeeee;
  --code: #1e1e1e;
  --header-bg: rgba(16, 16, 16, 0.96);
  --shadow: rgba(0, 0, 0, 0.36);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 17px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.62;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.18em;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  padding: 14px 20px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.site-title {
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
}

.sidebar-toggle:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.site-search {
  position: relative;
  width: min(360px, 46vw);
}

.site-search input {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.84rem;
  outline: none;
}

.site-search input:focus {
  border-color: var(--ink);
}

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

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(520px, 86vw);
  max-height: 60svh;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 44px var(--shadow);
}

.search-result {
  display: block;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result span {
  display: block;
}

.search-result small,
.search-empty {
  display: block;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.search-empty {
  padding: 12px;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  cursor: pointer;
}

.theme-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-slider {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: 104px;
  height: 34px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease;
}

.theme-slider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  z-index: 0;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  border-radius: 999px;
  background: var(--ink);
  transition: transform 180ms ease;
}

.theme-slider span {
  position: relative;
  z-index: 1;
  transition: color 160ms ease;
}

.theme-slider span:first-child {
  color: var(--bg);
}

.theme-switch input:checked + .theme-slider::before {
  transform: translateX(100%);
}

.theme-switch input:checked + .theme-slider span:first-child {
  color: var(--muted);
}

.theme-switch input:checked + .theme-slider span:last-child {
  color: var(--bg);
}

.theme-switch:hover .theme-slider {
  border-color: var(--ink);
}

.theme-switch input:focus-visible + .theme-slider {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.site-shell {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  max-width: 1180px;
  margin: 0 auto;
}

body.sidebar-hidden .site-shell {
  grid-template-columns: minmax(0, 1fr);
}

body.sidebar-hidden .directory {
  display: none;
}

body.sidebar-hidden .note {
  margin: 0 auto;
}

.directory {
  min-height: calc(100svh - 63px);
  border-right: 1px solid var(--line);
}

.directory-inner {
  position: sticky;
  top: 63px;
  max-height: calc(100svh - 63px);
  overflow: auto;
  padding: 18px 18px 42px;
}

.directory-label {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.directory-section {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

.directory-section:last-child {
  border-bottom: 1px solid var(--line);
}

.directory-section summary {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 650;
  text-transform: uppercase;
  user-select: none;
}

.directory-section summary::-webkit-details-marker {
  display: none;
}

.directory-section summary::before {
  content: "+";
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.76rem;
  width: 1ch;
}

.directory-section[open] summary::before {
  content: "-";
}

.directory-section ol {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.directory-section li + li {
  margin-top: 2px;
}

.directory-section a {
  display: block;
  padding: 4px 0 4px 20px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
  text-decoration: none;
}

.directory-section a::before {
  content: "└ ";
  color: #999999;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.directory-section a:hover,
.directory-section a.active {
  color: var(--ink);
}

.directory-section a.active {
  font-weight: 650;
}

.note {
  max-width: 740px;
  width: 100%;
  margin: 0;
  padding: 48px 28px 76px;
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.78rem;
}

h1,
h2,
h3 {
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: 0;
}

h1 {
  margin: 0 0 28px;
  font-size: clamp(2.1rem, 6vw, 3.6rem);
  font-weight: 700;
}

h2 {
  margin: 44px 0 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  font-size: clamp(1.35rem, 3vw, 2rem);
  font-weight: 700;
}

h3 {
  margin: 30px 0 10px;
  font-size: 1.1rem;
  font-weight: 700;
}

p,
ul,
pre {
  margin: 0 0 20px;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 28px 0;
}

p,
li {
  color: var(--ink);
}

ul {
  padding-left: 1.3rem;
}

li + li {
  margin-top: 6px;
}

strong {
  font-weight: 700;
}

code {
  padding: 0.08em 0.28em;
  border: 1px solid var(--line);
  background: var(--code);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

pre {
  overflow-x: auto;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--code);
}

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

footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px 30px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}

footer p {
  margin: 0;
}

@media (max-width: 720px) {
  .site-header {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .header-left {
    justify-content: space-between;
  }

  .header-right,
  .site-search {
    width: 100%;
  }

  .theme-switch {
    align-self: flex-end;
  }

  .search-results {
    left: 0;
    right: auto;
    width: 100%;
  }

  .site-shell {
    display: block;
  }

  body.sidebar-hidden .directory {
    display: none;
  }

  .directory {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .directory-inner {
    position: static;
    max-height: 42svh;
    padding: 16px 20px;
  }

  .note {
    padding: 40px 20px 64px;
  }
}
