:root {
  color-scheme: dark;
  --red: #ff7583;
  --red-deep: #ffabb2;
  --accent-fill: #be1f2d;
  --accent-fill-hover: #921824;
  --focus: #ff7583;
  --ink: #f8f0f1;
  --muted: #c1b0b3;
  --line: #3d2d30;
  --paper: #0b090a;
  --panel: #171213;
  --panel-raised: #201719;
  --code: #151113;
  --sidebar: #100c0d;
  --surface-hover: #281c1f;
  --surface-active: #382329;
  --field-border: #765d63;
  --field-border-hover: #a86f77;
  --placeholder: #b6a4a8;
  --mark-bg: #664b00;
  --mark-ink: #ffe7a0;
  --on-accent: #ffffff;
  --overlay: rgb(0 0 0 / 72%);
  --shadow: rgb(0 0 0 / 52%);
  --shadow-soft: rgb(0 0 0 / 24%);
  --focus-ring: #ff7583;
  --hero-glow: rgb(255 92 108 / 17%);
  --hero-start: #1a1113;
  --hero-end: #100d0e;
  --hero-ring: rgb(255 92 108 / 9%);
  --media-surface: #090708;
}

:root[data-theme="light"] {
  color-scheme: light;
  --red: #b51d2a;
  --red-deep: #71131c;
  --accent-fill: #b51d2a;
  --accent-fill-hover: #71131c;
  --focus: #b51d2a;
  --ink: #1e1718;
  --muted: #6f6365;
  --line: #e5dcda;
  --paper: #fffaf6;
  --panel: #ffffff;
  --panel-raised: #f7efec;
  --code: #f7efec;
  --sidebar: #f4ebe8;
  --surface-hover: #eadfdd;
  --surface-active: #e5d2d1;
  --field-border: #8b7176;
  --field-border-hover: #6e4f55;
  --placeholder: #6f6365;
  --mark-bg: #ffe29a;
  --mark-ink: #1e1718;
  --on-accent: #ffffff;
  --overlay: rgb(30 23 24 / 48%);
  --shadow: rgb(58 24 29 / 28%);
  --shadow-soft: rgb(69 31 36 / 10%);
  --focus-ring: #b51d2a;
  --hero-glow: rgb(190 31 45 / 18%);
  --hero-start: #fffdfb;
  --hero-end: #f8ece9;
  --hero-ring: rgb(190 31 45 / 8%);
  --media-surface: #141010;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  scrollbar-color: var(--field-border) var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font:
    16px/1.6 system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

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

::selection {
  background: var(--accent-fill);
  color: var(--on-accent);
}

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

.docs-shell {
  display: grid;
  grid-template-columns: 18rem minmax(0, 1fr);
  min-height: 100vh;
}

.docs-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  padding: 1.25rem 1rem;
}

.docs-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.docs-sidebar h2 {
  margin: 1.5rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.docs-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.docs-sidebar a {
  display: block;
  border-radius: 6px;
  color: var(--ink);
  padding: 0.35rem 0.5rem;
  text-decoration: none;
}

.docs-sidebar a:hover,
.docs-sidebar a:focus {
  background: var(--surface-hover);
}

.docs-content {
  padding: 3rem min(7vw, 5rem);
}

.docs-content article {
  max-width: 62rem;
}

h1,
h2,
h3 {
  line-height: 1.2;
}

h1 {
  margin-top: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
}

h2 {
  border-top: 1px solid var(--line);
  margin-top: 2.4rem;
  padding-top: 1.6rem;
}

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

th,
td {
  border: 1px solid var(--line);
  padding: 0.65rem 0.75rem;
  vertical-align: top;
}

th {
  background: var(--panel-raised);
  text-align: left;
}

code {
  background: var(--code);
  border-radius: 4px;
  padding: 0.1rem 0.25rem;
}

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

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

blockquote {
  border-left: 4px solid var(--red);
  color: var(--muted);
  margin-left: 0;
  padding-left: 1rem;
}

img {
  max-width: 100%;
}

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

.docs-search {
  margin-top: 1rem;
}

.docs-search-trigger {
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 2.65rem;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: var(--panel-raised);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  text-align: left;
}

.docs-search-trigger:hover,
.docs-search-trigger:focus-visible {
  border-color: var(--field-border-hover);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.docs-search-trigger-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.docs-search-trigger kbd,
.docs-search-footer kbd {
  border: 1px solid var(--field-border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--panel);
  color: var(--muted);
  font:
    0.72rem/1 system-ui,
    sans-serif;
  padding: 0.25rem 0.32rem;
  white-space: nowrap;
}

.docs-search-dialog {
  width: min(44rem, calc(100vw - 2rem));
  max-height: min(46rem, calc(100vh - 2rem));
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  padding: 0;
  overflow: visible;
}

.docs-search-dialog::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(3px);
}

.docs-search-panel {
  display: flex;
  flex-direction: column;
  max-height: min(46rem, calc(100vh - 2rem));
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 22px 70px var(--shadow);
  overflow: hidden;
}

.docs-search-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  border-bottom: 1px solid var(--line);
  padding: 0.8rem 0.9rem;
}

.docs-search-icon {
  color: var(--red);
  font-size: 1.4rem;
  line-height: 1;
}

.docs-search-input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  outline: 0;
}

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

.docs-search-close {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--muted);
  cursor: pointer;
  font:
    0.75rem/1 system-ui,
    sans-serif;
  padding: 0.35rem 0.45rem;
}

.docs-search-close:hover,
.docs-search-close:focus-visible {
  border-color: var(--field-border-hover);
  color: var(--ink);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.docs-search-status {
  margin: 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0.55rem 1rem;
}

.docs-search-results {
  list-style: none;
  margin: 0;
  padding: 0.45rem;
  overflow-y: auto;
}

.docs-search-results:empty {
  display: none;
}

.docs-search-results li {
  margin: 0;
}

.docs-search-results a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.15rem 1rem;
  border-radius: 8px;
  color: var(--ink);
  padding: 0.7rem 0.75rem;
  text-decoration: none;
}

.docs-search-results a:hover,
.docs-search-results a:focus-visible,
.docs-search-results a.is-active {
  background: var(--surface-hover);
}

.docs-search-results a:focus-visible {
  box-shadow: inset 0 0 0 2px var(--focus-ring);
}

.docs-search-result-title {
  min-width: 0;
  font-weight: 750;
}

.docs-search-result-section {
  max-width: 18rem;
  color: var(--red-deep);
  font-size: 0.78rem;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.docs-search-result-snippet {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.docs-search-results mark {
  border-radius: 2px;
  background: var(--mark-bg);
  color: var(--mark-ink);
  padding: 0 0.05em;
}

.docs-search-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.73rem;
  padding: 0.55rem 0.85rem;
}

.docs-search-footer span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

@media (max-width: 860px) {
  .docs-shell {
    grid-template-columns: 1fr;
  }

  .docs-sidebar {
    position: static;
    height: auto;
  }

  .docs-content {
    padding: 2rem 1rem;
  }

  .docs-search-dialog {
    width: min(100% - 1rem, 44rem);
    max-height: calc(100vh - 1rem);
  }

  .docs-search-panel {
    max-height: calc(100vh - 1rem);
  }

  .docs-search-result-section {
    display: none;
  }

  .docs-search-footer {
    display: none;
  }
}

@media print {
  :root,
  :root[data-theme="light"] {
    color-scheme: light;
    --red: #8f1722;
    --red-deep: #5f121a;
    --ink: #1e1718;
    --muted: #51484a;
    --line: #cfc5c3;
    --paper: #ffffff;
    --panel: #ffffff;
    --panel-raised: #f5f1ef;
    --code: #f5f1ef;
  }

  .docs-sidebar {
    display: none;
  }

  .docs-shell {
    display: block;
  }

  .docs-content {
    padding: 0;
  }

  .docs-content article {
    max-width: none;
  }
}
