:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: #07111f;
  color: #e8f0fa;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: #9edfff; }
:focus-visible { outline: 2px solid #73d8ff; outline-offset: 2px; }
[hidden] { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px clamp(12px, 3vw, 24px);
  border-bottom: 1px solid #263a52;
  background: #07111f;
}

.navigation-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.burger, .back {
  display: inline-grid;
  place-items: center;
  min-height: 40px;
  border: 1px solid #334760;
  border-radius: 8px;
  color: #dce8f6;
}

.burger { width: 40px; flex: 0 0 auto; cursor: pointer; font-size: 1.3rem; }
.navigation-toggle:focus-visible + .topbar .burger { outline: 2px solid #73d8ff; outline-offset: 2px; }
.brand { color: inherit; font-weight: 750; text-decoration: none; }
.back { margin-left: auto; padding: 7px 10px; text-decoration: none; }
.back:hover, .burger:hover { border-color: #73d8ff; }

.layout { display: grid; grid-template-columns: minmax(0, 330px) minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 64px;
  align-self: start;
  max-height: calc(100dvh - 64px);
  overflow: auto;
  min-width: 0;
  background: #0a1626;
  padding: 20px 12px;
  border-right: 1px solid #263a52;
}

.navigation-toggle:not(:checked) ~ .layout { grid-template-columns: minmax(0, 1fr); }
.navigation-toggle:not(:checked) ~ .layout .sidebar { display: none; }
.sidebar h2 {
  margin: 0 0 12px 6px;
  color: #73d8ff;
  font-size: .8rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.tree, .tree ul { margin: 0; padding: 0; list-style: none; }
.tree li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 32px;
  align-items: start;
  column-gap: 3px;
  min-width: 0;
}

.tree li + li { margin-top: 3px; }
.tree li > ul {
  grid-column: 1 / -1;
  margin: 3px 0 4px 9px;
  border-left: 1px solid #334760;
  padding-left: 5px;
}

.branch-toggle {
  appearance: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 32px;
  margin: 0;
  color: #9edfff;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.branch-toggle::before { content: "▸"; }
.branch-toggle:checked::before { content: "▾"; }
.branch-toggle:not(:checked) ~ ul { display: none; }
.tree-page, .tree-comment {
  border-radius: 6px;
  color: #c2d1e1;
  text-decoration: none;
}

.tree-page { display: block; padding: 6px; line-height: 1.4; overflow-wrap: anywhere; }
.tree-comment { display: grid; place-items: center; width: 32px; height: 32px; }
.branch-toggle:hover, .tree-page:hover, .tree-comment:hover { background: #19314a; color: #fff; }
.tree-page[aria-current="page"] { background: #19314a; color: #fff; font-weight: 700; }

.reading {
  width: min(100%, 930px);
  min-width: 0;
  padding: clamp(20px, 4vw, 52px) clamp(14px, 4vw, 52px) 70px;
  margin-inline: auto;
}

.breadcrumbs, .read-more {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  list-style: none;
  padding: 0;
  color: #a6bad0;
}

.breadcrumbs { margin: 0 0 20px; font-size: .87rem; }
.breadcrumbs li + li::before { content: "›"; padding-right: 8px; }
.read-more { justify-content: space-between; }
.doc-article, .discussion {
  min-width: 0;
  overflow-wrap: anywhere;
  border: 1px solid #263a52;
  border-radius: 14px;
  padding: clamp(15px, 3vw, 29px);
  background: #0c1a2b;
  line-height: 1.65;
}

.doc-article h1 { margin: 0 0 .65em; font-size: clamp(1.75rem, 4vw, 3rem); line-height: 1.15; }
.documentation-review { margin-top: 1.25rem; font-size: .875rem; }
.doc-article h2, .discussion h2 { margin: .9em 0 .4em; font-size: 1.25rem; }
.doc-article li + li { margin-top: 6px; }
.doc-article pre {
  max-width: 100%;
  overflow: auto;
  border: 1px solid #263a52;
  border-radius: 8px;
  padding: 12px;
  background: #07111f;
  font-size: .87rem;
}

.doc-article code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.doc-article :not(pre) > code { background: #13263c; padding: 1px 4px; border-radius: 4px; }
.doc-article table { border-collapse: collapse; width: 100%; }
.doc-article th, .doc-article td { padding: 6px 9px; text-align: left; border: 1px solid #334760; }
.notice { margin: 16px 0; border-left: 3px solid #73d8ff; padding: 12px 15px; background: #0a1626; }
.warning { border-left-color: #f0bd5b; }
.danger { border-left-color: #ee7a7a; }
.source-links { display: flex; flex-wrap: wrap; gap: 9px; margin: 18px 0; }
.source-links a { border: 1px solid #334760; border-radius: 8px; padding: 7px 10px; }
.subtopics { margin-top: 24px; border-top: 1px solid #263a52; }
.subtopic-summary { display: block; color: #c2d1e1; }

.discussion { scroll-margin-top: 80px; margin-top: 25px; }
.discussion h2 { margin-top: 0; }
.discussion-controls, .comment-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.discussion button {
  padding: 7px 10px;
  color: #e8f0fa;
  background: #13263c;
  border: 1px solid #334760;
  border-radius: 8px;
  cursor: pointer;
}

.discussion button:enabled:not([aria-disabled]):hover { border-color: #73d8ff; }
.discussion button:disabled, .discussion button[aria-disabled] { cursor: default; opacity: .6; }
.comment-form { display: grid; gap: 8px; margin: 18px 0; }
.comment-form textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  padding: 10px;
  font: inherit;
  border: 1px solid #334760;
  border-radius: 8px;
  background: #07111f;
  color: #e8f0fa;
}

.comments, .comment-children { display: grid; gap: 12px; }
.comment { border-left: 2px solid #334760; padding: 8px 0 3px 11px; }
.comment-meta, #discussion-auth-status, #discussion-availability { color: #a6bad0; font-size: .9rem; }
.comment-body { margin: 7px 0; white-space: pre-wrap; }
.comment-children { margin: 8px 0 0 7px; }
.reply-context { color: #f0bd5b; }
.discussion-error { color: #ff9c9c; }
.discussion-error:empty, #discussion-availability:empty { display: none; }

@media (max-width: 720px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static;
    max-height: 45dvh;
    border-right: 0;
    border-bottom: 1px solid #263a52;
  }
}
