:root {
  --bg: #f0fdf4;
  --bg-2: #e6f3f0;
  --panel: #ffffff;
  --panel-2: #ecfdf5;
  --text: #1f2937;
  --muted: #4b5563;
  --brand: #0d9488;
  --brand-2: #2dd4bf;
  --border: #cde7e1;
  --code-bg: #f7fafc;
}

body[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-2: #1d1d1d;
  --panel: #000000;
  --panel-2: #161616;
  --text: #e5e7eb;
  --muted: #9fb0cd;
  --brand: #00b0a4;
  --brand-2: #33d3bf;
  --border: #1f1f1f;
  --code-bg: #141414;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: "Poppins", sans-serif;
  background:
    radial-gradient(circle at 8% -12%, rgba(13, 148, 136, 0.2), transparent 32%),
    radial-gradient(circle at 92% -4%, rgba(45, 212, 191, 0.17), transparent 30%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
}

.docs-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(9px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav-toggle {
  display: none;
}

.brand {
  color: #1f2937;
  text-decoration: none;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand i {
  color: var(--brand-2);
  font-size: 18px;
}

.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: #1f2937;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  background: #ffffff;
}

.btn.ghost:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: #f8fffd;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.theme-label {
  font-weight: 600;
}

.theme-toggle i {
  font-size: 13px;
  line-height: 1;
}

.docs-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: calc(100vh - 62px);
}

.docs-sidebar {
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  background: rgba(255, 255, 255, 0.78);
}

.sidebar-mobile-head {
  display: none;
}

.sidebar-block {
  margin-bottom: 12px;
}

.docs-sidebar h2,
.docs-sidebar h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

.docs-sidebar p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.docs-sidebar hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.doc-list a,
.toc a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 8px;
  margin-bottom: 6px;
  border: 1px solid transparent;
}

.toc a.is-h3 {
  margin-left: 10px;
  font-size: 13px;
}

.doc-list a.active,
.doc-list a:hover,
.toc a:hover {
  background: var(--panel-2);
  border-color: var(--border);
  color: #1f2937;
}

.docs-content-wrap {
  padding: 18px 20px 24px;
  min-width: 0;
}

.docs-hero {
  border: 1px solid rgba(13, 148, 136, 0.22);
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.13), rgba(45, 212, 191, 0.12));
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 14px;
}

.docs-hero h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.2;
}

.docs-hero p {
  margin: 0;
  color: #374151;
  line-height: 1.6;
}

.hero-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(13, 148, 136, 0.24);
  background: rgba(255, 255, 255, 0.76);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: #115e59;
}

.docs-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.search-wrap {
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: var(--muted);
}

#searchInput {
  width: 100%;
  background: transparent;
  color: var(--text);
  border: 0;
  outline: 0;
  padding: 10px 0;
}

.docs-content {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  overflow-x: auto;
  box-shadow: 0 14px 32px rgba(13, 148, 136, 0.1);
}

.docs-overlay {
  display: none;
}

.docs-content h1,
.docs-content h2,
.docs-content h3 {
  scroll-margin-top: 90px;
}

.docs-content h1 { margin-top: 0; }

.docs-content p,
.docs-content li {
  color: #374151;
  line-height: 1.7;
}

.docs-content a {
  color: #0d9488;
}

.docs-content blockquote {
  margin: 14px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--brand);
  background: rgba(13, 148, 136, 0.08);
  border-radius: 8px;
}

.docs-content pre {
  background: var(--code-bg);
  border: 1px solid #dbe4ee;
  border-radius: 10px;
  padding: 14px;
  overflow: auto;
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #334155;
  border-radius: 8px;
  font-size: 12px;
  padding: 5px 8px;
  cursor: pointer;
}

.copy-btn:hover {
  color: var(--brand);
  border-color: var(--brand);
}

.docs-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
}

.docs-content th,
.docs-content td {
  border: 1px solid var(--border);
  padding: 8px 10px;
}

.docs-content th {
  background: #f5fbfa;
}

body[data-theme="dark"] .docs-header {
  background: rgba(17, 40, 49, 0.78);
}

body[data-theme="dark"] .brand {
  color: #fff;
}

body[data-theme="dark"] .btn {
  color: #e5e7eb;
  background: #121d38;
}

body[data-theme="dark"] .btn.ghost:hover {
  color: var(--brand-2);
  background: #18284a;
}

body[data-theme="dark"] .docs-sidebar {
  background: rgba(17, 28, 53, 0.7);
}

body[data-theme="dark"] .doc-list a.active,
body[data-theme="dark"] .doc-list a:hover,
body[data-theme="dark"] .toc a:hover {
  color: #fff;
}

body[data-theme="dark"] .docs-hero p {
  color: #d6def0;
}

body[data-theme="dark"] .chip {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #e6f2ff;
}

body[data-theme="dark"] .search-wrap {
  background: var(--panel);
}

body[data-theme="dark"] .docs-content {
  background: rgba(17, 29, 56, 0.82);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.2);
}

body[data-theme="dark"] .docs-content p,
body[data-theme="dark"] .docs-content li {
  color: #d1d7e6;
}

body[data-theme="dark"] .docs-content a {
  color: #70ded3;
}

body[data-theme="dark"] .docs-content blockquote {
  background: rgba(0, 176, 164, 0.08);
}

body[data-theme="dark"] .docs-content pre {
  border: 1px solid #223455;
}

body[data-theme="dark"] .copy-btn {
  background: #0f1a33;
  color: #cbd5e1;
}

body[data-theme="dark"] .copy-btn:hover {
  color: #fff;
}

body[data-theme="dark"] .docs-content th {
  background: #0c1630;
}

@media (max-width: 980px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }

  .docs-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(86vw, 340px);
    z-index: 110;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    transform: translateX(-105%);
    transition: transform 0.24s ease;
    overflow-y: auto;
    padding-top: 14px;
  }

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

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

  .sidebar-close {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    padding: 0;
    display: grid;
    place-items: center;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }

  .docs-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.32);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 105;
    border: 0;
    padding: 0;
  }

  body.sidebar-open .docs-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .docs-header {
    padding: 12px 14px;
    gap: 10px;
  }

  .brand {
    font-size: 15px;
    min-width: 0;
  }

  .brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-actions {
    gap: 6px;
  }

  .btn {
    padding: 8px 11px;
    font-size: 13px;
  }

  .theme-toggle span,
  .ghost {
    font-size: 13px;
  }

  .docs-content-wrap {
    padding: 12px 12px 16px;
  }

  .docs-hero {
    padding: 14px;
    margin-bottom: 10px;
  }

  .docs-hero h1 {
    font-size: 22px;
  }

  .docs-hero p {
    font-size: 14px;
  }

  .hero-chips {
    gap: 8px;
    margin-top: 10px;
  }

  .chip {
    font-size: 11px;
    padding: 5px 8px;
  }

  .docs-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 10px;
  }

  .search-wrap {
    max-width: 100%;
  }

  #rawDocLink {
    text-align: center;
  }

  .search-meta {
    margin-bottom: 8px;
  }

  .docs-content {
    padding: 14px;
    border-radius: 12px;
    font-size: 14px;
  }

  .docs-content h1 { font-size: 24px; }
  .docs-content h2 { font-size: 20px; }
  .docs-content h3 { font-size: 17px; }

  .docs-content pre {
    padding: 12px;
    font-size: 12px;
  }

  .copy-btn {
    top: 6px;
    right: 6px;
    font-size: 11px;
    padding: 4px 6px;
  }

  .docs-content table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 560px) {
  .theme-toggle .theme-label {
    display: none;
  }

  .nav-toggle span {
    display: none;
  }

  .btn {
    padding: 8px 10px;
  }

  .docs-header {
    padding: 10px 12px;
  }
}

/* Smooth theme transition */
body,
.docs-header,
.docs-sidebar,
.docs-content,
.docs-hero,
.btn,
.search-wrap,
.chip {
  transition: background-color .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: 10px;
  top: -48px;
  z-index: 1000;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
}
.skip-link:focus {
  top: 10px;
}

/* Header actions + remove need of inline styles */
.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  padding: 10px 14px;
  font-weight: 600;
}
.theme-toggle i {
  font-size: 14px;
  line-height: 1;
}

/* Strong focus-visible for keyboard UX */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--brand-2);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.22);
}

/* Search meta */
.search-meta {
  min-height: 20px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

/* Highlighted terms */
mark.docs-highlight {
  background: rgba(45, 212, 191, 0.35);
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

/* Heading link copy button */
.heading-anchor-btn {
  margin-left: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  font-size: 12px;
  padding: 2px 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease, color .15s ease, border-color .15s ease;
}
.docs-content h2:hover .heading-anchor-btn,
.docs-content h3:hover .heading-anchor-btn,
.docs-content h2:focus-within .heading-anchor-btn,
.docs-content h3:focus-within .heading-anchor-btn {
  opacity: 1;
}
.heading-anchor-btn:hover {
  color: var(--brand);
  border-color: var(--brand);
}

/* Loading skeleton */
.docs-loading {
  display: grid;
  gap: 10px;
}
.docs-loading-line {
  height: 12px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(148,163,184,.25), rgba(148,163,184,.45), rgba(148,163,184,.25));
  background-size: 200% 100%;
  animation: docsSkeleton 1.2s linear infinite;
}
.docs-loading-line.w-90 { width: 90%; }
.docs-loading-line.w-75 { width: 75%; }
.docs-loading-line.w-60 { width: 60%; }

@keyframes docsSkeleton {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}