* {
  box-sizing: border-box;
}

:root {
  --bg: #0b0c0f;
  --panel: #111318;
  --panel-hover: #161a21;
  --text: #e6e7eb;
  --muted: #a1a5b0;
  --border: #23262d;
  --border-hover: #333842;
  --accent: #00ff88;
  --accent-dim: #00cc6a;
  --accent-glow: rgba(0, 255, 136, 0.15);
  --ok: #6eedaf;
  --header-h: 72px;
  --transition: 0.2s ease;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.7 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell,
    Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  overflow-x: hidden;
}

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

a:hover {
  color: #4dffaa;
  text-decoration: none;
}

.wrap {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding-left: 32px;
  padding-right: 32px;
}

header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(11, 12, 15, 0.85);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  transition: box-shadow var(--transition), background var(--transition);
}

.bar {
  display: flex;
  justify-content: space-between;
}

header .bar {
  display: flex;
  gap: 20px;
  align-items: center;
  min-height: var(--header-h);
}

header .logo {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
}

header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}

/* Back button styling */
.nav-buttons {
  display: flex;
  gap: 12px;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.secondary-button:hover {
  background: var(--panel);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* Sidebar toggle button */
.sidebar-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 24px;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 8px;
  transition: all var(--transition);
}

.sidebar-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  padding-top: 32px;
  padding-bottom: 64px;
  min-height: calc(100vh - var(--header-h));
  max-width: 1400px;
}

.image-container {
  width: 100%;
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 16px auto;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0a0c10;
}

.image-container img {
  width: 100%;
  height: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
  border-radius: 12px;
  transition: transform var(--transition);
}

.image-container:hover img {
  transform: scale(1.01);
}

@media (min-width: 980px) {
  main {
    grid-template-columns: 260px 1fr;
    align-items: start;
  }
}

/* TOC */
.toc {
  max-width: 260px;
}

nav.toc {
  position: -webkit-sticky;
  position: sticky;
  top: calc(var(--header-h) + 24px);
  align-self: start;
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
}

.toc a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--transition);
  position: relative;
}

.toc a::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: all var(--transition);
  flex-shrink: 0;
}

.toc a:hover {
  background: var(--panel-hover);
  border-color: var(--border);
  color: var(--text);
}

.toc a:hover::before {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.toc a.active {
  background: var(--accent-glow);
  border-color: var(--accent-dim);
  color: var(--accent);
}

.toc a.active::before {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* Content */
section {
  scroll-margin-top: calc(var(--header-h) + 24px);
}

.panel {
  max-width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  gap: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.panel:hover {
  border-color: var(--border-hover);
}

/* Nested panels get subtler styling */
.panel .panel {
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--border);
}

.panel .panel:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-hover);
}

h2 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
  letter-spacing: -0.02em;
}

h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 12px 0 8px;
  font-weight: 600;
}

li {
  position: relative;
  padding-left: 20px;
  list-style: none;
  margin-bottom: 8px;
  line-height: 1.7;
}

li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent-glow);
}

li.bad-dot::before {
  background: #ff6b6b;
  box-shadow: 0 0 6px rgba(255, 107, 107, 0.4);
}

ol li {
  counter-increment: item;
  padding-left: 0;
}

ol li::before {
  content: counter(item);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-right: 12px;
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  top: 0;
  box-shadow: none;
}

ol {
  counter-reset: item;
}

.lead {
  color: var(--text);
  font-size: 17px;
  line-height: 1.8;
}

.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

.grid > * {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

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

.cols-2 {
  grid-template-columns: 1fr;
}

.cols-3 {
  grid-template-columns: 1fr;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

@media (min-width: 860px) {
  .cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.kpis {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.kpis .panel {
  text-align: center;
  padding: 24px;
}

.kpis .panel h3 {
  margin-top: 0;
}

@media (min-width: 720px) {
  .kpis {
    grid-template-columns: repeat(3, 1fr);
  }
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
  font-size: 0.9em;
  background: rgba(0, 255, 136, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}

pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  overflow: auto;
  font-size: 14px;
  line-height: 1.6;
}

pre code {
  background: none;
  padding: 0;
  color: var(--text);
}

footer {
  border-top: 1px solid var(--border);
  padding: 48px 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--panel);
}

.small {
  font-size: 13px;
}

ul,
ol {
  padding-left: 8px;
  margin: 8px 0;
}

.note {
  height: 100%;
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  background: var(--accent-glow);
  border-radius: 0 8px 8px 0;
  padding: 16px;
  padding-left: 20px;
}

/* Documentation-specific styling */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--muted);
}

.breadcrumb a {
  color: var(--accent);
}

.breadcrumb a:hover {
  color: #4dffaa;
}

.breadcrumb .separator {
  color: var(--border);
}

/* Callout/Alert boxes */
.callout {
  padding: 20px;
  border-left: 4px solid var(--accent);
  background: var(--accent-glow);
  border-radius: 0 8px 8px 0;
  margin: 20px 0;
}

.callout.warning {
  border-left-color: #ffa500;
  background: rgba(255, 165, 0, 0.1);
}

.callout.info {
  border-left-color: var(--accent);
  background: var(--accent-glow);
}

/* Step-by-step styling */
.steps {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 20px 0;
}

.step {
  display: flex;
  gap: 16px;
}

.step-number {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-glow);
  border: 2px solid var(--accent-dim);
  border-radius: 10px;
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
}

.step-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-content h4 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.step-content p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* Table styling for documentation */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

table th {
  background: var(--panel-hover);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--border-hover);
}

table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

table tr:last-child td {
  border-bottom: none;
}

table tr:hover {
  background: rgba(0, 255, 136, 0.03);
}

/* Documentation image with captions */
.figure {
  margin: 24px 0;
  text-align: center;
}

.figure figcaption {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

/* Enhanced code block */
pre {
  position: relative;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.6;
  margin: 16px 0;
}

pre code {
  background: none;
  padding: 0;
  color: var(--text);
}

/* API endpoint styling */
.endpoint {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
  font-size: 13px;
}

.endpoint-method {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 600;
  margin-right: 8px;
  font-size: 11px;
}

.endpoint-method.get {
  background: rgba(0, 255, 136, 0.1);
  color: var(--accent);
}

.endpoint-method.post {
  background: rgba(100, 200, 255, 0.1);
  color: #64c8ff;
}

.endpoint-method.put {
  background: rgba(255, 200, 100, 0.1);
  color: #ffc864;
}

@media (max-width: 979px) {
  :root {
    --header-h: 64px;
  }

  .wrap {
    padding-left: 20px;
    padding-right: 20px;
  }

  header {
    background: rgba(11, 12, 15, 0.98);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  header h1 {
    font-size: 16px;
  }

  header p {
    font-size: 11px;
  }

  .sidebar-toggle {
    display: block;
  }

  nav.toc {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    max-height: calc(100vh - var(--header-h));
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
    flex-direction: column;
    z-index: 999;
    overflow-y: auto;
  }

  nav.toc.open {
    display: flex;
  }

  h2 {
    font-size: 22px;
  }

  .panel {
    padding: 20px;
  }

  .lead {
    font-size: 15px;
  }

  .image-container img {
    width: 100%;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}
