:root {
  --bg: #fbfaf7;
  --surface: #f2efe9;
  --raised: #ffffff;
  --text: #161514;
  --body: #3d3a36;
  --muted: #66615a;
  --border: #e5e0d8;
  --accent: #8a6220;
  --accent-soft: rgb(138 98 32 / 0.12);
  --header-height: 72px;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #161615;
    --surface: #201f1d;
    --raised: #252422;
    --text: #f4f1ec;
    --body: #c9c4bc;
    --muted: #a19b92;
    --border: #2f2d2a;
    --accent: #d9ad5f;
    --accent-soft: rgb(217 173 95 / 0.14);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #161615;
  --surface: #201f1d;
  --raised: #252422;
  --text: #f4f1ec;
  --body: #c9c4bc;
  --muted: #a19b92;
  --border: #2f2d2a;
  --accent: #d9ad5f;
  --accent-soft: rgb(217 173 95 / 0.14);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 'Instrument Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-underline-offset: 3px;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  z-index: 50;
  top: -60px;
  left: 16px;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
}

.skip-link:focus {
  top: 12px;
}

/* Header */
.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}

.site-header__inner {
  display: grid;
  grid-template-columns: 280px minmax(0, 760px) 1fr;
  align-items: center;
  column-gap: 64px;
  max-width: 1440px;
  height: var(--header-height);
  margin: 0 auto;
  padding: 0 40px;
}

.brand {
  justify-self: start;
  color: var(--accent);
  font-weight: 600;
  font-size: 26px;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.brand span {
  margin-left: 4px;
  color: var(--muted);
  font: 400 12px 'IBM Plex Mono', monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.search-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 44px;
  padding: 0 12px 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.search-button:hover {
  border-color: var(--muted);
}

.search-button svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.search-button__label {
  flex: 1;
  text-align: left;
}

.search-button__key {
  font: 12px 'IBM Plex Mono', monospace;
}

.site-header__end {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 20px;
}

.version {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}

.header-link {
  font-size: 15px;
  text-decoration: none;
}

.header-link:hover {
  text-decoration: underline;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.menu-button {
  display: none;
}

.theme-toggle__sun {
  display: none;
}

:root[data-theme='dark'] .theme-toggle__sun {
  display: block;
}

:root[data-theme='dark'] .theme-toggle__moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .theme-toggle__sun {
    display: block;
  }

  :root:not([data-theme='light']) .theme-toggle__moon {
    display: none;
  }
}

/* Three columns: contents, page, "On this page" */
.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 760px) minmax(200px, 1fr);
  column-gap: 64px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 40px;
}

.layout--no-toc {
  grid-template-columns: 280px minmax(0, 760px);
}

.sidebar {
  position: sticky;
  top: var(--header-height);
  align-self: start;
  max-height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 40px 0 48px;
  border-left: 1px solid var(--border);
  scrollbar-width: thin;
}

.nav,
.nav-group__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav {
  display: grid;
  gap: 28px;
}

.nav-group__title {
  margin: 0 0 10px;
  padding-left: 24px;
  color: var(--text);
  font-weight: 500;
  font-size: 17px;
}

.nav-group__list {
  display: grid;
  gap: 2px;
}

.nav-group__list a {
  position: relative;
  display: block;
  padding: 7px 12px 7px 40px;
  color: var(--muted);
  font-size: 16px;
  text-decoration: none;
  transition: color 0.15s;
}

.nav-group__list a:hover {
  color: var(--text);
}

.nav-group__list a[aria-current='page'] {
  color: var(--text);
  font-weight: 500;
}

.nav-group__list a[aria-current='page']::before {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  content: '';
}

.sidebar-backdrop,
.sidebar__close {
  display: none;
}

/* Page */
.content {
  min-width: 0;
  padding: 56px 0 96px;
  color: var(--body);
  font-size: 17px;
  line-height: 1.85;
}

.content:focus {
  outline: none;
}

.content h1,
.content h2,
.content h3 {
  position: relative;
  color: var(--text);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.content h1 {
  margin: 0 0 28px;
  font-size: clamp(38px, 5vw, 54px);
}

.content h2 {
  margin: 64px 0 18px;
  font-size: clamp(26px, 3vw, 34px);
}

.content h3 {
  margin: 40px 0 10px;
  font-size: 23px;
}

.anchor {
  position: absolute;
  left: -0.9em;
  padding-right: 0.3em;
  color: var(--accent);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
}

:is(h2, h3):hover .anchor,
.anchor:focus-visible {
  opacity: 1;
}

.content p,
.content ul,
.content ol {
  margin: 0 0 20px;
}

.content li + li {
  margin-top: 8px;
}

.content strong {
  color: var(--text);
  font-weight: 500;
}

.content a {
  color: var(--text);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
}

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

.lead {
  color: var(--body);
  font-size: 19px;
}

code,
.path {
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: 14px 'IBM Plex Mono', monospace;
}

.path {
  white-space: nowrap;
}

table {
  width: 100%;
  margin: 20px 0;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.6;
}

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

th {
  color: var(--muted);
  font: 500 12px 'IBM Plex Mono', monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td:first-child {
  color: var(--text);
}

.table-wrap {
  overflow-x: auto;
}

.note {
  margin: 28px 0;
  padding: 18px 20px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-soft);
  color: var(--text);
}

.note p {
  margin: 0;
}

.faq details {
  border-bottom: 1px solid var(--border);
}

.faq summary {
  padding: 18px 0;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}

.faq details > *:not(summary) {
  margin-top: 0;
}

/* Previous and next pages */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 72px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.content .pager__link {
  display: grid;
  gap: 2px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 17px;
  line-height: 1.4;
  text-decoration: none;
}

.content .pager__link:hover {
  border-color: var(--accent);
  color: var(--text);
}

.pager__link span {
  color: var(--muted);
  font: 12px 'IBM Plex Mono', monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pager__link--next {
  grid-column: 2;
  text-align: right;
}

/* On this page */
.toc {
  position: sticky;
  top: var(--header-height);
  align-self: start;
  max-height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 56px 0 48px;
  scrollbar-width: thin;
}

.toc__title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  color: var(--text);
  font-size: 16px;
}

.toc__title svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.toc ul {
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
  list-style: none;
}

.toc a {
  position: relative;
  display: block;
  padding: 6px 0 6px 20px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.45;
  text-decoration: none;
}

.toc__item--h3 a {
  padding-left: 38px;
  font-size: 14px;
}

.toc a:hover,
.toc a[aria-current] {
  color: var(--text);
}

.toc a[aria-current]::before {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  content: '';
}

/* Search */
.search {
  width: min(640px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 96px));
  margin: 80px auto auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--raised);
  color: var(--text);
  box-shadow: 0 24px 64px rgb(0 0 0 / 0.25);
}

.search[open] {
  display: flex;
  flex-direction: column;
}

.search::backdrop {
  background: rgb(10 10 10 / 0.45);
  backdrop-filter: blur(3px);
}

.search__field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}

.search__field svg {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--muted);
}

.search__input {
  flex: 1;
  min-width: 0;
  height: 60px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 18px 'Instrument Sans', system-ui, sans-serif;
}

.search__input:focus {
  outline: none;
}

.search__input::-webkit-search-cancel-button {
  display: none;
}

.search__close {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: 12px 'IBM Plex Mono', monospace;
  cursor: pointer;
}

.search__results {
  overflow-y: auto;
}

.search__results ul {
  margin: 0;
  padding: 8px;
  list-style: none;
}

.search__result {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 8px;
  text-decoration: none;
}

.search__result:hover,
.search__result:focus-visible {
  outline: none;
  background: var(--accent-soft);
}

.search__page {
  color: var(--muted);
  font: 11px 'IBM Plex Mono', monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search__section {
  font-weight: 500;
}

.search__text {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.search mark {
  background: none;
  color: var(--accent);
  font-weight: 600;
}

.search__empty {
  margin: 0;
  padding: 32px 20px;
  color: var(--muted);
  text-align: center;
}

/* Support form */
.form {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.form label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.5;
}

.form .hint {
  color: var(--muted);
  font-weight: 400;
  font-size: 14px;
}

.form input,
.form select,
.form textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

.form textarea {
  min-height: 160px;
  resize: vertical;
}

.form button {
  justify-self: start;
  min-height: 48px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font: 500 16px 'Instrument Sans', system-ui, sans-serif;
  cursor: pointer;
}

.form .honeypot {
  display: none;
}

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

.site-footer p {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 40px;
}

/* Medium screens: no "On this page" column */
@media (max-width: 1199px) {
  .layout,
  .layout--no-toc,
  .site-header__inner {
    grid-template-columns: 240px minmax(0, 1fr);
    column-gap: 48px;
  }

  .site-header__inner {
    grid-template-columns: 240px minmax(0, 1fr) auto;
    column-gap: 32px;
  }

  .toc {
    display: none;
  }
}

/* Small screens: the contents open in a drawer */
@media (max-width: 959px) {
  :root {
    --header-height: 64px;
  }

  .site-header {
    border-bottom: 1px solid var(--border);
  }

  .site-header__inner,
  .layout,
  .layout--no-toc {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 16px;
  }

  .site-header__inner {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    column-gap: 8px;
  }

  .menu-button {
    display: inline-grid;
    margin-left: -8px;
  }

  .brand {
    font-size: 22px;
  }

  .search-button {
    justify-self: end;
    width: 44px;
    padding: 0;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--text);
  }

  .search-button__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .search-button__key,
  .version,
  .header-link {
    display: none;
  }

  .site-header__end {
    gap: 0;
    margin-right: -8px;
  }

  .sidebar {
    position: fixed;
    z-index: 30;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 85vw);
    max-height: none;
    padding: 24px 16px 40px 0;
    border-left: 0;
    border-right: 1px solid var(--border);
    background: var(--bg);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
  }

  .sidebar__close {
    display: inline-grid;
    margin: -8px 0 16px 16px;
  }

  .sidebar.is-open {
    transform: none;
    visibility: visible;
    transition: transform 0.25s ease;
  }

  .sidebar-backdrop:not([hidden]) {
    position: fixed;
    z-index: 25;
    inset: 0;
    display: block;
    background: rgb(10 10 10 / 0.45);
  }

  .content {
    padding: 32px 0 64px;
    font-size: 16.5px;
    line-height: 1.8;
  }

  .content h2 {
    margin-top: 48px;
  }

  .anchor {
    display: none;
  }

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

  .pager__link--next {
    grid-column: auto;
  }

  .site-footer p {
    padding: 24px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar.is-open {
    transition: none;
  }
}
