:root {
  --bg: #f4f6f9;
  --surface: #fff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --header-h: 56px;
  --sidebar-w: 270px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.docs-app {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.docs-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--header-h);
  padding: 0.4rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.docs-header-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem 1rem;
  flex-wrap: wrap;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}

.docs-header-brand:hover {
  color: var(--text);
}

.docs-header-brand:hover .docs-header-title {
  color: var(--accent);
}

.docs-header-logo {
  height: 28px;
  width: auto;
  max-width: min(120px, 36vw);
  display: block;
  flex-shrink: 0;
}

.docs-header-title {
  font-weight: 650;
  font-size: clamp(0.95rem, 2.4vw, 1.1rem);
  letter-spacing: -0.02em;
  line-height: 1.25;
  border-left: 1px solid var(--border);
  padding-left: 1rem;
}

@media (max-width: 480px) {
  .docs-header-title {
    border-left: none;
    padding-left: 0;
    width: 100%;
  }
}

.docs-menu-toggle {
  margin-left: auto;
  display: none;
  padding: 0.4rem 0.65rem;
  font-size: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.docs-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

.docs-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 29;
}

.docs-backdrop.is-open {
  display: block;
}

.docs-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0 2rem;
  overflow-y: auto;
  position: sticky;
  top: var(--header-h);
  align-self: flex-start;
  max-height: calc(100vh - var(--header-h));
  z-index: 30;
}

.docs-nav-section {
  margin-bottom: 1.1rem;
}

.docs-nav-label {
  padding: 0.3rem 1rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.docs-nav a {
  display: block;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  border-left: 3px solid transparent;
}

.docs-nav a:hover {
  background: var(--bg);
  color: var(--accent);
}

.docs-nav a.is-active {
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.docs-nav--nested a {
  padding-left: 1.5rem;
  font-size: 0.85rem;
}

.docs-nav-group > a {
  display: block;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  border-left: 3px solid transparent;
}

.docs-nav-group > a:hover {
  background: var(--bg);
  color: var(--accent);
}

.docs-nav-group > a.is-active {
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

/* API flows: when a subsection is active, parent stays readable but lighter than a top-level nav item */
.docs-nav-group:has(.docs-nav--sublinks a.is-active) > a.is-active {
  font-weight: 500;
  color: var(--accent);
  background: rgba(37, 99, 235, 0.04);
  border-left-color: rgba(37, 99, 235, 0.4);
}

/* Sub-route under API flows: distinct, lighter fill so it does not read the same as the parent row */
.docs-nav--sublinks a.is-active {
  font-weight: 600;
  color: var(--accent);
  background: rgba(37, 99, 235, 0.07);
  border-left-color: var(--accent);
}

.docs-nav--sublinks a {
  padding-left: 1.75rem;
  font-size: 0.82rem;
}

.docs-main {
  flex: 1;
  min-width: 0;
  padding: 1.75rem 1.25rem 2.5rem;
}

.docs-content {
  max-width: 50rem;
  margin: 0 auto;
  background: var(--surface);
  padding: 1.75rem 2rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.docs-content h1 {
  margin: 0 0 0.75rem;
  font-size: 1.65rem;
  letter-spacing: -0.02em;
}

.docs-content h2 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.docs-content h2:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.docs-content p,
.docs-content ul {
  margin: 0 0 1rem;
  color: var(--text);
}

.docs-content ul {
  padding-left: 1.25rem;
}

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

.docs-placeholder {
  padding: 1rem 1.1rem;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.95rem;
}

.docs-content pre {
  font-size: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: #0f172a;
  color: #f1f5f9;
  overflow-x: auto;
  line-height: 1.55;
}

/* Inline `code` styles must not apply inside `pre` or text becomes low-contrast. */
.docs-content pre code {
  display: block;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font-size: inherit;
  line-height: inherit;
  white-space: pre;
}

.docs-content code {
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.docs-content h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

.docs-content h3:first-child {
  margin-top: 0;
}

.docs-content ol {
  margin: 0 0 1rem;
  padding-left: 1.35rem;
}

.docs-content ol li {
  margin-bottom: 0.45rem;
}

.docs-content blockquote {
  margin: 1rem 0;
  padding: 0.65rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 8px 8px 0;
  color: var(--text);
  font-size: 0.95rem;
}

.docs-content blockquote p:last-child {
  margin-bottom: 0;
}

.docs-lead {
  font-size: 1.08rem;
  line-height: 1.65;
  color: var(--text);
  margin: 0 0 1rem;
  font-weight: 500;
}

/* Optional de-emphasised line after a lead — apply explicitly; do not use `.docs-lead + p` (breaks other pages). */
.docs-lead-muted {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.65;
}

.docs-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  margin: 1rem 0 0;
}

.docs-pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}

.docs-ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 0.75rem 0 1.25rem;
}

.docs-ref-card {
  padding: 1rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: linear-gradient(165deg, var(--surface) 0%, var(--bg) 100%);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.docs-ref-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
}

.docs-ref-card p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
}

.docs-example-list {
  margin: 0.75rem 0 0;
  padding: 0.75rem 1rem 0.75rem 1.25rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text);
}

.docs-example-list li {
  margin-bottom: 0.35rem;
}

.docs-example-list li:last-child {
  margin-bottom: 0;
}

.docs-aside-tip {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-left-color: var(--accent);
  background: var(--bg);
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
}

.docs-aside-tip strong {
  color: var(--text);
}

.docs-mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.25rem;
}

.docs-mode-card {
  position: relative;
  padding: 1.1rem 1.15rem 1.15rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.docs-mode-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
  border-radius: 12px 0 0 12px;
}

.docs-mode-card--record::before {
  background: var(--muted);
  opacity: 0.5;
}

.docs-mode-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.docs-mode-path {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.65rem;
  word-break: break-all;
}

.docs-mode-card p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
}

.docs-flow-steps {
  margin: 0 0 1.25rem;
  padding-left: 0;
  list-style: none;
  counter-reset: flowstep;
}

.docs-flow-steps li {
  position: relative;
  padding-left: 2.5rem;
  margin-bottom: 0.85rem;
  min-height: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text);
}

.docs-flow-steps li::before {
  counter-increment: flowstep;
  content: counter(flowstep);
  position: absolute;
  left: 0;
  top: 0.1rem;
  width: 1.65rem;
  height: 1.65rem;
  line-height: 1.65rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border-radius: 50%;
}

.docs-callout-rich {
  margin: 1.15rem 0 1.5rem;
  padding: 1.3rem 1.4rem 1.35rem;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid rgba(37, 99, 235, 0.25);
  font-size: 0.93rem;
  line-height: 1.65;
  color: var(--text);
}

/* Title only: do not style `p strong` or inline emphasis breaks across lines. */
.docs-callout-rich > strong {
  display: block;
  margin-bottom: 0.55rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.docs-callout-rich p strong {
  display: inline;
  margin: 0;
  font-size: inherit;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 650;
  color: var(--text);
}

.docs-callout-rich p {
  margin: 0;
  padding-top: 0.15rem;
}

.docs-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.35rem;
}

.docs-pretty-link {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--accent);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.docs-pretty-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.docs-fine-print {
  margin: 0.25rem 0 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
}

@media (prefers-color-scheme: dark) {
  .docs-flow-steps li::before {
    color: #0f172a;
  }

  .docs-callout-rich {
    border-color: rgba(96, 165, 250, 0.35);
  }

  .docs-mode-card--record::before {
    opacity: 0.65;
  }
}

.docs-review-banner {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.92rem;
}

.docs-table-wrap {
  overflow-x: auto;
  margin: 0 0 1rem;
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.docs-table th,
.docs-table td {
  text-align: left;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  vertical-align: top;
}

.docs-table th {
  background: var(--bg);
  font-weight: 600;
}

.docs-table tbody tr:nth-child(even) {
  background: rgba(37, 99, 235, 0.03);
}

.diagram-frame {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
}

.diagram-caption {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}

.docs-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8125rem;
  color: var(--muted);
}

.docs-footer-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.25rem;
  min-width: 0;
}

.docs-footer-sep {
  color: var(--border);
  user-select: none;
}

.docs-footer-left a,
.docs-footer-swagger {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  flex-shrink: 0;
}

.docs-footer-left a:hover,
.docs-footer-swagger:hover {
  text-decoration: underline;
}

.docs-footer-copy {
  color: var(--muted);
  font-weight: 400;
}

@media (max-width: 900px) {
  .docs-menu-toggle {
    display: block;
  }

  .docs-sidebar {
    position: fixed;
    left: 0;
    top: var(--header-h);
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    max-height: none;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.08);
  }

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

  .docs-backdrop.is-open {
    display: block;
  }

  .docs-content {
    padding: 1.25rem 1.1rem;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --surface: #1a1f26;
    --border: #2d3748;
    --text: #e8ecf1;
    --muted: #9ca8b4;
    --accent: #60a5fa;
    --accent-soft: rgba(96, 165, 250, 0.12);
  }
}
