* {
  box-sizing: border-box;
}

:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-alt: #f8fbff;
  --text: #162638;
  --muted: #4e6277;
  --border: #d3deea;
  --accent: #0f7a55;
  --accent-soft: #e6f4ee;
  --shadow: 0 10px 25px rgba(15, 30, 54, 0.08);
}

html[data-theme="dark"] {
  --bg: #11151d;
  --surface: #181f2a;
  --surface-alt: #141b25;
  --text: #edf2fb;
  --muted: #b2bfd3;
  --border: #2a3444;
  --accent: #62d0ff;
  --accent-soft: #1d3242;
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.42);
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.docs-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  min-height: 58px;
  white-space: nowrap;
}

html[data-theme="dark"] .docs-header {
  background: rgba(10, 18, 31, 0.92);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 0;
  min-width: 0;
}

.header-right {
  justify-content: flex-end;
}

.header-title {
  margin: 0;
  text-align: center;
  font-size: 1.02rem;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 48vw;
}

.header-icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.header-icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.header-link {
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.header-link:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #b9dccd;
  transform: translateY(-1px);
}

.header-link-primary {
  background: #145d43;
  border-color: #145d43;
  color: #f3fff9;
}

.header-link-primary:hover {
  background: #1a7b58;
  border-color: #1a7b58;
  color: #ffffff;
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
  width: 100%;
  transition: grid-template-columns 0.2s ease;
}

body.sidebar-collapsed .layout {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  background: var(--surface-alt);
  border-right: 1px solid var(--border);
  padding: 18px 16px 28px;
  overflow-y: auto;
  transition: transform 0.2s ease, opacity 0.2s ease, padding 0.2s ease;
}

body.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
  opacity: 0;
  padding-left: 0;
  padding-right: 0;
  border-right: 0;
}

.sidebar h2 {
  margin: 0 0 14px;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.sidebar section {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar h3 {
  margin: 0 0 9px;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #2f4559;
}

.sidebar a {
  display: block;
  text-decoration: none;
  color: var(--text);
  padding: 7px 9px;
  border-radius: 8px;
  margin-bottom: 3px;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.sidebar a:hover,
.sidebar a.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #cae4d8;
}

#content {
  padding: 26px clamp(20px, 4vw, 58px) 40px;
  display: block;
  background: transparent;
  min-width: 0;
}

#content > * {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  width: 100%;
  max-width: none;
}

#content [class*="-intro"],
#content [class*="-section"],
#content [class*="-toc"],
#content [class*="-run-wrap"] {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}

#content [class*="-mini"],
#content [class*="-syntax"] {
  background: transparent !important;
  border: 0 !important;
  border-left: 3px solid var(--accent) !important;
  border-radius: 0 !important;
  padding: 6px 0 6px 12px !important;
}

#content p {
  color: var(--muted);
}

#content h1,
#content h2,
#content h3,
#content h4,
#content h5,
#content h6 {
  color: var(--text);
}

#content li,
#content strong,
#content label,
#content summary {
  color: var(--text);
}

#content :not(pre) > code {
  color: var(--text);
}

.sidebar-backdrop {
  position: fixed;
  inset: 58px 0 0;
  background: rgba(2, 12, 20, 0.45);
  z-index: 18;
}

@media (max-width: 1060px) {
  .layout {
    grid-template-columns: 270px minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .docs-header {
    gap: 6px;
    padding: 8px 10px;
  }

  .header-left,
  .header-right {
    gap: 6px;
  }

  .header-title {
    font-size: 0.96rem;
    max-width: 44vw;
  }

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

  .sidebar {
    position: fixed;
    left: 0;
    top: 58px;
    bottom: 0;
    width: min(82vw, 320px);
    z-index: 19;
    border-right: 1px solid var(--border);
    max-height: none;
    padding: 12px 12px 16px;
    transform: translateX(-100%);
    opacity: 1;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
    opacity: 1;
    padding: 12px 12px 16px;
    border-right: 1px solid var(--border);
  }

  #content {
    padding: 14px 10px 20px;
    background: transparent;
  }

  #content > * {
    padding: 0;
  }
}

@media (max-width: 560px) {
  .header-title {
    font-size: 0.89rem;
    max-width: 38vw;
  }

  .header-left .header-link.docs-link {
    display: none;
  }

  .header-link {
    padding: 6px 10px;
    font-size: 0.84rem;
  }

  .sidebar h2 {
    font-size: 0.74rem;
  }

  .sidebar h3 {
    font-size: 0.79rem;
  }

  .sidebar a {
    font-size: 0.86rem;
    padding: 6px 8px;
  }
}
