:root {
  --bg: #0f1419;
  --bg-elevated: #1a222d;
  --bg-hover: #243044;
  --border: #2d3a4f;
  --text: #e8eef7;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --get: #22c55e;
  --post: #3b82f6;
  --patch: #f59e0b;
  --put: #a855f7;
  --delete: #ef4444;
  --radius: 10px;
  --nav-width: 240px;
  --subnav-width: 260px;
  --header-h: 56px;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.doc-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  background: rgba(15, 20, 25, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.doc-header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.doc-header .meta {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.doc-actions a,
.doc-actions button {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.doc-actions a:hover,
.doc-actions button:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.doc-layout {
  display: grid;
  grid-template-columns: var(--nav-width) 1fr var(--subnav-width);
  min-height: calc(100vh - var(--header-h));
}

.nav-modules,
.nav-sections {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 1rem 0.75rem;
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
}

.nav-sections {
  border-right: none;
  border-left: 1px solid var(--border);
}

.nav-modules h2,
.nav-sections h2 {
  margin: 0 0 0.75rem;
  padding: 0 0.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.nav-modules ul,
.nav-sections ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-modules li button,
.nav-sections li a {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.65rem;
  margin-bottom: 2px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}

.nav-modules li button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-modules li button:hover:not(.active),
.nav-sections li a:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-sections li a.active {
  color: var(--accent);
  font-weight: 500;
}

.doc-main {
  padding: 1.25rem 1.5rem 3rem;
  max-width: 920px;
}

.module-panel {
  display: none;
}

.module-panel.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.module-intro {
  margin-bottom: 1.5rem;
  padding: 1rem 1.15rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.module-intro h2 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
}

.module-intro p {
  margin: 0.5rem 0;
  color: var(--text-muted);
}

.subsection-title {
  margin: 1.75rem 0 0.75rem;
  padding-bottom: 0.35rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  border-bottom: 1px dashed var(--border);
}

.op-accordion {
  margin-bottom: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
}

.op-accordion summary {
  list-style: none;
  cursor: pointer;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  user-select: none;
}

.op-accordion summary::-webkit-details-marker {
  display: none;
}

.op-accordion summary::after {
  content: '▸';
  margin-left: auto;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.op-accordion[open] summary::after {
  transform: rotate(90deg);
}

.method {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  letter-spacing: 0.04em;
}

.method-get {
  background: rgba(34, 197, 94, 0.2);
  color: var(--get);
}
.method-post {
  background: rgba(59, 130, 246, 0.2);
  color: var(--post);
}
.method-patch {
  background: rgba(245, 158, 11, 0.2);
  color: var(--patch);
}
.method-put {
  background: rgba(168, 85, 247, 0.2);
  color: var(--put);
}
.method-delete {
  background: rgba(239, 68, 68, 0.2);
  color: var(--delete);
}

.op-path {
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  color: var(--text);
}

.op-summary-text {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.op-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border);
}

.op-body p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.op-block {
  margin-top: 0.75rem;
}

.op-block h4 {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.op-block pre {
  margin: 0;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.78rem;
  overflow-x: auto;
  border: 1px solid var(--border);
}

.badge-auth {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(168, 85, 247, 0.2);
  color: #c4b5fd;
}

.loading,
.error {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

.error {
  color: #fca5a5;
}

@media (max-width: 1100px) {
  .doc-layout {
    grid-template-columns: var(--nav-width) 1fr;
  }
  .nav-sections {
    display: none;
  }
}

@media (max-width: 720px) {
  .doc-layout {
    grid-template-columns: 1fr;
  }
  .nav-modules {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .nav-modules h2 {
    width: 100%;
  }
  .nav-modules ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .nav-modules li button {
    width: auto;
  }
}
