/* docs.drever.io: GitBook-style layout (top bar, page list, text, "On this page"), Drever colours.
   No web font: the system font stack, like the app. Light by default, dark from the system or the toggle. */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f8;
  --bg-hover: #f0f1f3;
  --text: #1c1d1f;
  --text-soft: #5b5f66;
  --text-faint: #80858d;
  --border: #e6e7ea;
  --brand: #3b82f6;
  --link: #1d4ed8;
  --active-bg: #eaf1fe;
  --active-text: #1d4ed8;
  --code-bg: #f3f4f6;
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.18);

  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --info-icon: #2563eb;
  --tip-bg: #f0fdf4;
  --tip-border: #bbf7d0;
  --tip-icon: #16a34a;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-icon: #b45309;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-icon: #dc2626;

  --topbar-h: 64px;
  --sidebar-w: 288px;
  --toc-w: 240px;
  --font:
    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono:
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono",
    monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1b1a;
    --bg-soft: #222221;
    --bg-hover: #2a2a29;
    --text: #ececea;
    --text-soft: #b3b3ae;
    --text-faint: #8d8d88;
    --border: #33332f;
    --link: #7fb0ff;
    --active-bg: #1f2b44;
    --active-text: #93bbff;
    --code-bg: #262625;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    --info-bg: #17223a;
    --info-border: #24406e;
    --info-icon: #7fb0ff;
    --tip-bg: #142a1c;
    --tip-border: #1f5130;
    --tip-icon: #4ade80;
    --warn-bg: #2d2410;
    --warn-border: #5c4512;
    --warn-icon: #fbbf24;
    --danger-bg: #331717;
    --danger-border: #6b2222;
    --danger-icon: #f87171;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #1b1b1a;
  --bg-soft: #222221;
  --bg-hover: #2a2a29;
  --text: #ececea;
  --text-soft: #b3b3ae;
  --text-faint: #8d8d88;
  --border: #33332f;
  --link: #7fb0ff;
  --active-bg: #1f2b44;
  --active-text: #93bbff;
  --code-bg: #262625;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --info-bg: #17223a;
  --info-border: #24406e;
  --info-icon: #7fb0ff;
  --tip-bg: #142a1c;
  --tip-border: #1f5130;
  --tip-icon: #4ade80;
  --warn-bg: #2d2410;
  --warn-border: #5c4512;
  --warn-icon: #fbbf24;
  --danger-bg: #331717;
  --danger-border: #6b2222;
  --danger-icon: #f87171;
  color-scheme: dark;
}

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

html {
  scroll-padding-top: calc(var(--topbar-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--link);
  text-underline-offset: 2px;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.skip-link:focus {
  top: 12px;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  font-size: 17px;
  white-space: nowrap;
}
.brand img {
  display: block;
  border-radius: 6px;
}
.brand-sub {
  color: var(--text-soft);
  font-weight: 500;
}

.search-btn {
  margin-left: 32px;
  flex: 0 1 340px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text-faint);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}
.search-btn:hover {
  background: var(--bg-hover);
}
.search-btn svg {
  width: 17px;
  height: 17px;
}
.search-btn-text {
  flex: 1;
}

kbd {
  font-family: var(--font);
  font-size: 11.5px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  background: var(--bg);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.open-app {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.open-app:hover {
  background: #2563eb;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.menu-btn {
  display: none;
}

.icon-moon {
  display: none;
}
:root[data-theme="dark"] .icon-sun {
  display: none;
}
:root[data-theme="dark"] .icon-moon {
  display: block;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun {
    display: none;
  }
  :root:not([data-theme="light"]) .icon-moon {
    display: block;
  }
}

/* ---------- Three columns ---------- */

.layout {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 24px 16px 40px 24px;
  border-right: 1px solid var(--border);
}

.sidebar-head {
  display: none;
}

.nav-group + .nav-group {
  margin-top: 22px;
}

.nav-title {
  margin: 0 0 6px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

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

.nav-list a {
  display: block;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text-soft);
  font-size: 14.5px;
  line-height: 1.45;
  text-decoration: none;
}
.nav-list a:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.nav-list a[aria-current="page"] {
  background: var(--active-bg);
  color: var(--active-text);
  font-weight: 600;
}

.content {
  min-width: 0;
  padding: 40px 48px 64px;
}

.page {
  max-width: 760px;
  margin: 0 auto;
}

.page-header h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  font-weight: 700;
}

.lead {
  margin: 12px 0 0;
  color: var(--text-soft);
  font-size: 18px;
  line-height: 1.55;
}

.toc {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 40px 24px 40px 8px;
}

.toc-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

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

.toc a {
  display: block;
  margin-left: -1px;
  padding: 4px 0 4px 14px;
  border-left: 2px solid transparent;
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.45;
  text-decoration: none;
}
.toc a.depth-3 {
  padding-left: 26px;
}
.toc a:hover {
  color: var(--text);
}
.toc a.is-active {
  color: var(--active-text);
  border-left-color: var(--brand);
}

/* ---------- Page text ---------- */

.prose {
  margin-top: 28px;
}

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

.prose h2 {
  margin: 44px 0 12px;
  font-size: 24px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.prose h3 {
  margin: 32px 0 8px;
  font-size: 18.5px;
  line-height: 1.35;
}

.prose h2,
.prose h3 {
  position: relative;
}

.anchor {
  margin-left: 8px;
  color: var(--text-faint);
  text-decoration: none;
  opacity: 0;
}
.prose h2:hover .anchor,
.prose h3:hover .anchor,
.anchor:focus {
  opacity: 1;
}

.prose p,
.prose ul,
.prose ol,
.prose table,
.prose pre {
  margin: 0 0 16px;
}

.prose ul {
  padding-left: 22px;
}

.prose li + li {
  margin-top: 4px;
}

.prose strong {
  font-weight: 650;
}

.prose code {
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}
.prose th,
.prose td {
  text-align: left;
  vertical-align: top;
  padding: 10px 14px;
  border: 1px solid var(--border);
}
.prose th {
  background: var(--bg-soft);
  font-weight: 600;
}

/* Steps: every numbered list (GitBook "stepper"). */

.prose ol {
  list-style: none;
  counter-reset: step;
  padding: 0;
}

.prose ol > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 18px 44px;
  margin: 0;
}

.prose ol > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--active-bg);
  color: var(--active-text);
  font-size: 14px;
  font-weight: 700;
  line-height: 28px;
  text-align: center;
}

.prose ol > li::after {
  content: "";
  position: absolute;
  left: 13.5px;
  top: 34px;
  bottom: 4px;
  width: 1px;
  background: var(--border);
}

.prose ol > li:last-child {
  padding-bottom: 4px;
}
.prose ol > li:last-child::after {
  display: none;
}

.prose ol > li > p {
  margin: 0 0 8px;
}

/* Hint blocks: > [!NOTE] / [!TIP] / [!WARNING] / [!DANGER] in the Markdown. */

.hint {
  display: flex;
  gap: 12px;
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--info-border);
  border-radius: 12px;
  background: var(--info-bg);
}
.hint-icon {
  color: var(--info-icon);
  padding-top: 2px;
}
.hint-body > :last-child {
  margin-bottom: 0;
}
.hint-body p {
  margin: 0 0 8px;
}
.hint-tip {
  border-color: var(--tip-border);
  background: var(--tip-bg);
}
.hint-tip .hint-icon {
  color: var(--tip-icon);
}
.hint-warning {
  border-color: var(--warn-border);
  background: var(--warn-bg);
}
.hint-warning .hint-icon {
  color: var(--warn-icon);
}
.hint-danger {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}
.hint-danger .hint-icon {
  color: var(--danger-icon);
}

/* Code block with a Copy button. */

.code-block {
  position: relative;
  margin: 0 0 16px;
}
.code-block pre {
  margin: 0;
  padding: 14px 92px 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--code-bg);
  overflow-x: auto;
}
.code-block pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: 14.5px;
}
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-soft);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.copy-btn:hover {
  color: var(--text);
}

/* Cards on the welcome page. */

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}
.cards li {
  margin: 0;
}
.cards a {
  display: block;
  height: 100%;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
}
.cards a:hover {
  border-color: var(--brand);
}
.cards strong {
  display: block;
  margin-bottom: 4px;
}
.cards span {
  color: var(--text-soft);
  font-size: 14.5px;
}

/* ---------- Page foot ---------- */

.page-foot {
  margin-top: 48px;
}

.updated {
  margin: 0 0 20px;
  color: var(--text-faint);
  font-size: 13.5px;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.pager a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
}
.pager a:hover {
  border-color: var(--brand);
}
.pager .next {
  grid-column: 2;
  text-align: right;
}
.pager small {
  color: var(--text-faint);
  font-size: 13px;
}
.pager span {
  font-weight: 600;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 14px;
}
.site-footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
}
.footer-links {
  display: flex;
  gap: 18px;
}
.site-footer a {
  color: var(--text-soft);
}

/* ---------- Search ---------- */

.search-dialog {
  position: fixed;
  inset: 0;
  z-index: 60;
}
.search-dialog[hidden] {
  display: none;
}
.search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
}
.search-panel {
  position: relative;
  max-width: 640px;
  margin: 10vh auto 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-faint);
}
.search-field input {
  flex: 1;
  min-width: 0;
  height: 56px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 17px;
}
.search-results {
  list-style: none;
  margin: 0;
  padding: 8px;
  max-height: min(60vh, 480px);
  overflow-y: auto;
}
.search-results:empty {
  display: none;
}
.search-results a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}
.search-results a[aria-selected="true"],
.search-results a:hover {
  background: var(--active-bg);
}
.search-results small {
  display: block;
  color: var(--text-faint);
  font-size: 12.5px;
}
.search-results .result-text {
  display: block;
  color: var(--text-soft);
  font-size: 14px;
}
.search-empty {
  padding: 14px 12px;
  color: var(--text-soft);
  font-size: 14.5px;
}
mark {
  background: transparent;
  color: var(--active-text);
  font-weight: 650;
}

/* ---------- Smaller screens ---------- */

@media (max-width: 1279px) {
  .layout {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }
  .toc {
    display: none;
  }
}

@media (max-width: 1023px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .menu-btn {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: min(320px, 86vw);
    height: 100%;
    padding: 12px 16px 40px;
    background: var(--bg);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    visibility: hidden;
  }
  .sidebar.is-open {
    transform: none;
    visibility: visible;
  }
  .sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 12px;
    padding: 0 0 0 10px;
    font-weight: 650;
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(15, 23, 42, 0.4);
  }
  .sidebar-backdrop[hidden] {
    display: none;
  }
  .content {
    padding: 32px 32px 56px;
  }
}

@media (max-width: 720px) {
  .topbar-inner {
    padding: 0 12px 0 8px;
    gap: 6px;
  }
  .brand {
    font-size: 16px;
  }
  .search-btn {
    margin-left: auto;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--text-soft);
  }
  .search-btn-text,
  .search-kbd {
    display: none;
  }
  .topbar-actions {
    margin-left: 0;
    gap: 2px;
  }
  .open-app {
    height: 34px;
    padding: 0 10px;
    font-size: 13px;
  }
  .content {
    padding: 24px 16px 48px;
  }
  .page-header h1 {
    font-size: 28px;
  }
  .lead {
    font-size: 16.5px;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .pager {
    grid-template-columns: 1fr;
  }
  .pager .next {
    grid-column: 1;
  }
  .search-panel {
    margin: 0;
    border-radius: 0;
    border-width: 0 0 1px;
  }
  .site-footer-inner {
    padding: 18px 16px;
  }
}

@media (max-width: 380px) {
  .brand-sub {
    display: none;
  }
}

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