html {
  scroll-behavior: smooth;
}

/* Layout */
.doc-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  padding-top: 70px;
}

.doc-body {
  display: flex;
  justify-content: space-between;
  gap: 56px;
  min-width: 0;
  padding: 0 56px;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 70px;
  align-self: start;
  height: calc(100vh - 70px);
  overflow-y: auto;
  padding: 24px 14px 40px;
  box-sizing: border-box;
  background: var(--bg-secondary);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  scrollbar-width: thin;
  scrollbar-color: #3b3e5a transparent;
}

.sidebar-panel {
  display: contents;
}

.sidebar-search {
  margin: 0 0 18px;
}

.sidebar-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--bg-primary);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}

.sidebar-search input:focus {
  border-color: var(--accent-discord);
}

.sidebar-toggle {
  display: none;
}

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-group {
  margin: 22px 0 6px;
  padding-left: 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.7;
}

.sidebar-group:first-child {
  margin-top: 0;
}

.sidebar li a {
  position: relative;
  isolation: isolate;
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 15px;
  text-decoration: none;
  transition: color 0.3s ease, background-color 0.3s ease, padding-left 0.3s cubic-bezier(.22,1,.36,1);
}

.sidebar li a::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(108, 121, 255, 0.22), rgba(108, 121, 255, 0.04));
  opacity: 0;
  transition: opacity 0.35s ease;
}

.sidebar li a::after {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 2px;
  border-radius: 2px;
  background: #8D98FF;
  transform: scaleY(0);
  transition: transform 0.35s cubic-bezier(.22,1,.36,1);
}

.sidebar li a:hover {
  color: #ffffff;
}

.sidebar li a:hover {
  background: rgba(255, 255, 255, 0.04);
}

.sidebar li a.active {
  color: #ffffff;
  padding-left: 16px;
}

.sidebar li a.active::before {
  opacity: 1;
}

.sidebar li a.active::after {
  transform: scaleY(1);
}

.sidebar-empty {
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-muted);
}

/* On this page */
.doc-toc {
  flex: 0 0 210px;
  position: sticky;
  top: 70px;
  align-self: start;
  max-height: calc(100vh - 70px);
  overflow-y: auto;
  padding: 40px 0;
  box-sizing: border-box;
}

.doc-toc-title {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.doc-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.doc-toc a {
  display: block;
  margin-left: -1px;
  padding: 5px 0 5px 14px;
  border-left: 1px solid transparent;
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition), border-color var(--transition);
}

.doc-toc a:hover,
.doc-toc a.active {
  color: #ffffff;
  border-left-color: #8D98FF;
}

/* Content */
.doc-main {
  min-width: 0;
  width: 100%;
  flex: 1 1 auto;
  padding: 32px 0 100px;
  box-sizing: border-box;
}

.doc-hero {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-bottom: 16px;
  padding-bottom: 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.doc-hero-img img {
  width: 110px;
  height: 110px;
  object-fit: contain;
}

.doc-hero-content h1 {
  margin: 0 0 10px;
  font-size: 2.2rem;
  font-weight: 800;
  color: #ffffff;
}

.doc-hero-content p {
  margin: 0;
  line-height: 1.6;
  color: var(--text-muted);
}

.doc-section-block {
  padding: 36px 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  scroll-margin-top: 80px;
}

.doc-section-block h2 {
  margin: 0 0 16px;
  font-size: 1.7rem;
  color: #ffffff;
}

.doc-section-block h3 {
  scroll-margin-top: 90px;
  margin: 26px 0 10px;
  font-size: 1.15rem;
  color: #ffffff;
}

.doc-section-block p,
.doc-section-block li {
  line-height: 1.7;
  color: var(--text-dim);
}

.doc-section-block p {
  margin: 0 0 14px;
}

.doc-section-block ul {
  margin: 0 0 16px;
  padding-left: 20px;
}

.doc-section-block li {
  margin-bottom: 6px;
}

.doc-section-block li::marker {
  color: #8D98FF;
}

.doc-section-block a {
  color: #A5AEFF;
  text-decoration: none;
  border-bottom: 1px solid rgba(165, 174, 255, 0.4);
}

.doc-section-block a:hover {
  color: #ffffff;
}

.doc-section-block code {
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.9em;
  color: #E6E8FF;
  white-space: nowrap;
}

.doc-note {
  padding: 12px 16px;
  border-left: 3px solid var(--accent-discord);
  border-radius: 0 10px 10px 0;
  background: rgba(88, 101, 242, 0.1);
}

.doc-table {
  margin: 0 0 18px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}

.doc-table table {
  width: 100%;
  border-collapse: collapse;
}

.doc-table th,
.doc-table td {
  padding: 11px 16px;
  text-align: left;
  vertical-align: top;
  line-height: 1.55;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.doc-table th {
  background: var(--bg-secondary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.doc-table tr:last-child td {
  border-bottom: none;
}

.doc-table td:first-child {
  white-space: nowrap;
}

@media (max-width: 1280px) {
  .doc-layout {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .doc-body {
    padding: 0 40px;
  }

  .doc-toc {
    display: none;
  }
}

/* Tablets and phones */
@media (max-width: 900px) {
  .doc-body {
    display: block;
    padding: 0;
  }

  .doc-main {
    padding: 24px 0 80px;
  }

  .doc-layout {
    display: block;
    padding: 70px 16px 0;
  }

  .sidebar {
    height: auto;
    border-right: none;
  }

  .sidebar {
    position: sticky;
    top: 70px;
    z-index: 20;
    max-height: none;
    margin: 0 -16px;
    padding: 0;
    overflow: visible;
    background: var(--bg-secondary);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  }

  .sidebar-toggle {
    display: block;
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: none;
    color: #ffffff;
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
  }

  .sidebar-toggle::after {
    content: "▾";
    float: right;
    transition: transform var(--transition);
  }

  .sidebar.open .sidebar-toggle::after {
    transform: rotate(180deg);
  }

  .sidebar-panel {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 0;
    overflow: hidden;
    background: var(--bg-secondary);
    box-shadow: 0 10px 16px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: max-height 0.45s cubic-bezier(.22,1,.36,1), opacity 0.3s ease, transform 0.45s cubic-bezier(.22,1,.36,1), visibility 0s linear 0.45s;
  }

  .sidebar.open .sidebar-panel {
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition-delay: 0s;
  }

  .sidebar-search {
    margin: 0;
    padding: 0 16px 14px;
  }

  .sidebar ul {
    padding: 0 8px 16px;
  }

  .doc-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .doc-hero-img img {
    width: 80px;
    height: 80px;
  }

  .doc-hero-content h1 {
    font-size: 1.7rem;
  }

  .doc-table td:first-child {
    white-space: normal;
  }
}
