:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --panel: #ffffff;
  --panel-soft: #eef5ff;
  --text: #111827;
  --muted: #617083;
  --border: #d9e3f0;
  --brand: #0b72f0;
  --brand-strong: #0757bd;
  --accent: #16a085;
  --code-bg: #0d1726;
  --code-text: #dce8ff;
  --shadow: 0 12px 36px rgba(19, 46, 84, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1018;
  --panel: #111a27;
  --panel-soft: #0e2236;
  --text: #edf4ff;
  --muted: #9dafc4;
  --border: #243447;
  --brand: #58a6ff;
  --brand-strong: #8ac0ff;
  --accent: #39d0ae;
  --code-bg: #060b12;
  --code-text: #e8f1ff;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  color: var(--brand-strong);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(210px, 280px) 1fr minmax(240px, 420px) auto;
  gap: 18px;
  align-items: center;
  min-height: 64px;
  padding: 10px 22px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 800;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.topnav {
  display: flex;
  gap: 18px;
  font-size: 14px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.mobile-actions {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.search {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  width: min(100%, 340px);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
}

.search input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}

kbd {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
}

.icon-button,
.doc-actions button,
.dialog-head button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
}

.icon-button {
  width: 38px;
  height: 38px;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.layout {
  display: grid;
  grid-template-columns: minmax(210px, 280px) minmax(0, 1fr) minmax(180px, 240px);
  gap: 30px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 26px 22px 64px;
}

.sidebar,
.toc {
  position: sticky;
  top: 90px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow: auto;
}

.nav-section {
  margin-bottom: 22px;
}

.nav-title,
.toc-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav a,
.toc a {
  display: block;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
}

.nav a.active,
.nav a:hover,
.toc a:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.content {
  min-width: 0;
}

.doc-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.doc-actions button {
  padding: 8px 10px;
  font-size: 13px;
}

.doc {
  min-height: 75vh;
  padding: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  line-height: 1.18;
  letter-spacing: 0;
}

h1 {
  margin: 8px 0 16px;
  font-size: clamp(32px, 5vw, 58px);
}

h2 {
  margin: 38px 0 12px;
  padding-top: 6px;
  font-size: 26px;
}

h3 {
  margin: 24px 0 8px;
  font-size: 19px;
}

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

.lead {
  max-width: 760px;
  color: var(--muted);
  font-size: 18px;
}

.callout {
  margin: 22px 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: var(--panel-soft);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 22px 0;
}

.card {
  min-height: 120px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
}

.card strong {
  display: block;
  margin-bottom: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
}

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

th {
  color: var(--text);
  background: var(--panel-soft);
}

code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--panel-soft);
  color: var(--text);
}

pre {
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-text);
}

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

dialog {
  width: min(900px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.dialog-head button {
  width: 34px;
  height: 34px;
}

textarea {
  width: 100%;
  min-height: 60vh;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-text);
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (max-width: 1020px) {
  .topbar,
  .layout {
    grid-template-columns: 1fr;
  }

  .topnav,
  .toolbar {
    justify-content: flex-start;
    overflow: auto;
  }

  .sidebar,
  .toc {
    position: static;
    max-height: none;
  }

  .toc {
    display: none;
  }

  .doc {
    padding: 24px;
  }
}

@media (max-width: 720px) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0d12;
    --panel: #10151d;
    --panel-soft: #151c28;
    --text: #f4f8ff;
    --muted: #c3cfdd;
    --border: #273241;
    --brand: #4ea1ff;
    --brand-strong: #77b8ff;
    --accent: #7ee0c7;
    --code-bg: #151b25;
    --code-text: #f0f6ff;
    --shadow: none;
  }

  body {
    background: var(--bg);
  }

  .topbar {
    grid-template-columns: 1fr auto;
    gap: 12px;
    min-height: 76px;
    padding: 14px 16px;
    background: var(--bg);
    border-bottom-color: var(--border);
    backdrop-filter: none;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 7px;
  }

  .brand strong {
    display: block;
    max-width: 150px;
    font-size: 15px;
    line-height: 1.05;
  }

  .brand small {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.1;
  }

  .topnav {
    display: none;
  }

  .mobile-actions {
    display: flex;
    grid-column: 2;
    grid-row: 1;
  }

  .mobile-actions .icon-button {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--panel);
  }

  .toolbar {
    display: none;
    grid-column: 1 / -1;
    grid-row: 2;
    align-items: stretch;
    justify-content: stretch;
    width: 100%;
  }

  body.search-open .toolbar {
    display: flex;
  }

  .toolbar .search {
    width: 100%;
  }

  .toolbar #themeToggle,
  .search kbd {
    display: none;
  }

  .search {
    grid-template-columns: auto 1fr;
    padding: 12px;
    border-radius: 10px;
    background: var(--panel);
  }

  .layout {
    display: block;
    max-width: none;
    padding: 22px 16px 72px;
  }

  .sidebar {
    display: none;
    position: static;
    max-height: none;
    margin: 0 0 22px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
  }

  body.nav-open .sidebar {
    display: block;
  }

  .nav-section {
    margin-bottom: 16px;
  }

  .nav a {
    padding: 9px 10px;
  }

  .doc-actions {
    justify-content: flex-start;
    margin-bottom: 52px;
  }

  .doc-actions button {
    min-height: 44px;
    padding: 10px 13px;
    border-radius: 10px;
    background: var(--panel);
    font-size: 15px;
  }

  .doc {
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    margin: 0 0 16px;
    font-size: 46px;
  }

  h2 {
    margin-top: 52px;
    font-size: 36px;
  }

  h3 {
    font-size: 22px;
  }

  .lead {
    font-size: 23px;
    line-height: 1.45;
  }

  p,
  li {
    color: var(--muted);
    font-size: 18px;
  }

  .callout {
    margin: 28px 0;
    padding: 18px;
    border-left-color: var(--accent);
    background: color-mix(in srgb, var(--brand) 18%, var(--panel));
  }

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

  .card {
    min-height: 0;
    background: var(--panel);
  }

  table {
    display: block;
    overflow-x: auto;
    border-radius: 0;
  }

  pre {
    margin-inline: -2px;
    padding: 14px;
    border-radius: 6px;
  }
}
