:root {
  --bg: #f4f7fc;
  --surface: #ffffff;
  --surface-2: #edf3ff;
  --text: #0f1f3a;
  --muted: #5b6e8e;
  --border: #d9e4f7;
  --primary: #1f67e0;
  --primary-2: #0f4fbd;
  --link: #0f5cd8;
  --shadow: 0 8px 24px rgba(15, 63, 148, 0.08);
}

[data-theme="dark"] {
  --bg: #0d1524;
  --surface: #131f34;
  --surface-2: #162845;
  --text: #e8eefc;
  --muted: #9fb2d7;
  --border: #233a61;
  --primary: #5b9dff;
  --primary-2: #86b7ff;
  --link: #8db8ff;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.62;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.02rem;
  white-space: nowrap;
}

.top-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.top-nav a {
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.28rem 0.58rem;
  border-radius: 6px;
}
.top-nav a:hover { background: rgba(255, 255, 255, 0.14); }

.theme-toggle {
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.36rem 0.66rem;
  border-radius: 8px;
  cursor: pointer;
}
.theme-toggle:hover { background: rgba(255, 255, 255, 0.16); }

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.1rem 1rem 2rem;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 240px;
  gap: 1rem;
}

.sidebar-sticky {
  position: sticky;
  top: 4.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem;
  box-shadow: var(--shadow);
}

.sidebar-title {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.sidebar-search {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font: inherit;
  margin-bottom: 0.65rem;
}

.sidebar a {
  display: block;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-size: 0.92rem;
}
.sidebar a:hover { background: var(--surface-2); }
.sidebar a.active {
  background: var(--surface-2);
  color: var(--primary);
  font-weight: 600;
}

.doc-hero {
  margin-bottom: 0.75rem;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(31, 103, 224, 0.12), rgba(31, 103, 224, 0.02));
  box-shadow: var(--shadow);
}
.doc-hero-title {
  margin: 0 0 0.25rem;
  font-size: 1.28rem;
}
.doc-hero-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.35rem 1.5rem;
}

h1, h2, h3 { line-height: 1.28; color: var(--text); }
h1 { margin-top: 0; font-size: 1.85rem; }
h2 { margin-top: 1.8rem; font-size: 1.3rem; border-bottom: 1px solid var(--border); padding-bottom: 0.32rem; }
h3 { margin-top: 1.15rem; font-size: 1.04rem; }
p, li { color: var(--text); }
a { color: var(--link); }
code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.08rem 0.35rem;
}
pre {
  background: #0f1d35;
  color: #edf4ff;
  border-radius: 10px;
  padding: 0.9rem;
  overflow-x: auto;
}
pre code { background: transparent; border: none; padding: 0; color: inherit; }

.toc-sticky {
  position: sticky;
  top: 4.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem;
  box-shadow: var(--shadow);
}
.toc-title {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.toc-links a {
  display: block;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  padding: 0.26rem 0.38rem;
  margin-bottom: 0.12rem;
  font-size: 0.86rem;
}
.toc-links a:hover {
  background: var(--surface-2);
}

.pager {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.pager-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  padding: 0.72rem 0.85rem;
  min-height: 68px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.pager-item-next { text-align: right; }
.pager-item-empty { visibility: hidden; }
.pager-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.pager-title { font-weight: 600; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar-sticky { position: static; }
  .toc-sticky { position: static; }
  .toc { order: 3; }
}
