:root {
  --indigo-500: #1e055b;
  --indigo-400: #390f9c;
  --indigo-200: #8c74f8;
  --indigo-100: #beb4fb;
  --brand-500: #007af9;
  --brand-400: #4ca2fb;
  --cerise-300: #f57fb6;
  --pumpkin-300: #ffb286;
  --meadow-300: #54d2b4;
  --atlantis-200: #d5f5c7;
  --code-bg: #1a0b47;
  --radius: 12px;
  --radius-small: 8px;
  --font: "Onest", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-width: 288px;
}

/* Dark theme (default) — indigo-tinted, never pure black */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #100b26;
  --sidebar-bg: #0c081c;
  --surface: #171130;
  --surface-raised: #1c1540;
  --border: #28204e;
  --border-soft: #221a45;
  --ink: #d9d4ee;
  --ink-strong: #f4f2fc;
  --ink-muted: #9d95c2;
  --link: #5aa9ff;
  --label-fg: #beb4fb;
  --hover-bg: rgba(255, 255, 255, 0.06);
  --active-bg: rgba(0, 122, 249, 0.18);
  --control-hover: rgba(255, 255, 255, 0.08);
  --code-inline-bg: rgba(140, 116, 248, 0.16);
  --code-inline-fg: #beb4fb;
  --quote-bg: rgba(0, 122, 249, 0.1);
  --auth-bg: rgba(216, 50, 141, 0.16);
  --auth-fg: #f57fb6;
  --chip-get: #54d2b4;
  --chip-post: #4ca2fb;
  --chip-patch: #ffb286;
  --chip-delete: #f57fb6;
  --panel-shadow: 0 16px 40px -20px rgba(0, 0, 0, 0.6);
}

[data-theme="light"] {
  color-scheme: light;
  --page-bg: #f6f7fb;
  --sidebar-bg: #eff1f8;
  --surface: #ffffff;
  --surface-raised: #f8f9fc;
  --border: #e3e6f2;
  --border-soft: #ebedf6;
  --ink: #373356;
  --ink-strong: #1e055b;
  --ink-muted: #71767c;
  --link: #007af9;
  --label-fg: #390f9c;
  --hover-bg: #ffffff;
  --active-bg: #ecf5ff;
  --control-hover: #ebedf6;
  --code-inline-bg: #f1effe;
  --code-inline-fg: #390f9c;
  --quote-bg: #ecf5ff;
  --auth-bg: #fdedf3;
  --auth-fg: #d8328d;
  --chip-get: #139e83;
  --chip-post: #007af9;
  --chip-patch: #ff7212;
  --chip-delete: #d8328d;
  --panel-shadow: 0 2px 4px rgba(2, 0, 5, 0.05), 0 16px 40px -16px rgba(30, 5, 91, 0.22);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: rgba(0, 122, 249, 0.4); }

/* ---------- Theme-dependent logo ---------- */

[data-theme="light"] .logo-dark { display: none; }
:root:not([data-theme="light"]) .logo-light { display: none; }

/* ---------- App shell ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-soft);
  padding: 18px 14px 14px;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 8px 14px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.sidebar-brand:hover { text-decoration: none; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 5px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.theme-toggle:hover {
  background: var(--control-hover);
  color: var(--ink-strong);
}

[data-theme="light"] .icon-sun { display: none; }
:root:not([data-theme="light"]) .icon-moon { display: none; }

.sidebar-search {
  position: relative;
  margin: 0 2px 14px;
}

.sidebar-search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
}

.sidebar-search input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  padding: 7px 12px 7px 30px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink-strong);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sidebar-search input::placeholder { color: var(--ink-muted); }

.sidebar-search input:focus {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(0, 122, 249, 0.2);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  padding-bottom: 16px;
}

.nav-group { margin-bottom: 4px; }

.nav-group-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-strong);
  padding: 14px 8px 5px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 7px;
  color: var(--ink-muted);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
}

.nav-link:hover {
  background: var(--hover-bg);
  color: var(--ink-strong);
  text-decoration: none;
}

.nav-link.active {
  background: var(--active-bg);
  color: var(--link);
  font-weight: 700;
}

.nav-single { font-weight: 600; color: var(--ink); }

.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  display: flex;
  gap: 14px;
  padding: 12px 8px 2px;
  border-top: 1px solid var(--border-soft);
}

.sidebar-footer a {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
}

.sidebar-footer a:hover { color: var(--link); text-decoration: none; }

/* ---------- Method chips & badges ---------- */

.chip {
  flex-shrink: 0;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  font-family: var(--mono);
}

.chip-get { color: var(--chip-get); }
.chip-post { color: var(--chip-post); }
.chip-put, .chip-patch { color: var(--chip-patch); }
.chip-delete { color: var(--chip-delete); }

.badge {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 4px 11px;
  border-radius: 7px;
  color: #fff;
}

.badge-get { background: #139e83; }
.badge-post { background: var(--brand-500); }
.badge-put, .badge-patch { background: #ff7212; }
.badge-delete { background: #d8328d; }

/* ---------- Doc layout ---------- */

.doc { min-width: 0; }

.doc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 48px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 44px 48px 80px;
}

.doc-main { min-width: 0; max-width: 690px; }

.doc-kicker {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--link);
  margin-bottom: 8px;
}

.doc-main h1 {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 16px;
  color: var(--ink-strong);
}

/* ---------- Endpoint bar ---------- */

.endpoint-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  padding: 9px 12px;
  margin-bottom: 26px;
}

.endpoint-path {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-strong);
  word-break: break-all;
}

.copy-path {
  display: inline-flex;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}

.copy-path:hover { background: var(--control-hover); color: var(--ink-strong); }
.copy-path.copied { color: var(--chip-get); }

.auth-flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--auth-fg);
  background: var(--auth-bg);
  border-radius: 999px;
  padding: 2px 10px;
}

/* ---------- Prose ---------- */

.prose {
  font-size: 15px;
  line-height: 1.75;
}

.prose h2, .prose h3, .prose h4, .prose h5, .prose h6 { color: var(--ink-strong); }

.prose strong { color: var(--ink-strong); }

.prose h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 2.2em 0 0.6em;
  padding-top: 1.4em;
  border-top: 1px solid var(--border-soft);
}

.prose h2:first-child { margin-top: 0; padding-top: 0; border-top: none; }

.prose h3 {
  font-size: 20px;
  font-weight: 700;
  margin: 1.8em 0 0.5em;
}

.prose h4 {
  font-size: 16.5px;
  font-weight: 700;
  margin: 1.6em 0 0.5em;
}

.prose h5 {
  font-size: 15.5px;
  font-weight: 700;
  margin: 1.4em 0 0.4em;
}

.prose h6 {
  font-size: 15.5px;
  font-weight: 700;
  margin: 1.4em 0 0.4em;
}

.prose p { margin: 0.8em 0; }

.prose hr {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 2em 0;
}

.prose code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--code-inline-bg);
  color: var(--code-inline-fg);
  padding: 2px 6px;
  border-radius: 5px;
}

.prose pre code, .panel pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: 12.5px;
  line-height: 1.7;
}

.prose ul, .prose ol { padding-left: 24px; }
.prose li { margin: 0.3em 0; }

.prose img { max-width: 100%; border-radius: var(--radius-small); }

.prose blockquote {
  margin: 1.2em 0;
  padding: 10px 16px;
  border-left: 3px solid var(--brand-400);
  background: var(--quote-bg);
  border-radius: 0 var(--radius-small) var(--radius-small) 0;
}

.prose blockquote p { margin: 0; }

/* ---------- Tables ---------- */

.prose table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  overflow: hidden;
  margin: 1.3em 0;
  font-size: 13.5px;
  background: var(--surface);
}

.prose table thead { background: var(--surface-raised); }

.prose th {
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--label-fg);
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.prose td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}

.prose td:first-child { white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: none; }

/* ---------- Code blocks (chroma) — always dark, in both themes ---------- */

.chroma {
  position: relative;
  background: var(--code-bg) !important;
  border: 1px solid rgba(140, 116, 248, 0.22);
  border-radius: var(--radius-small);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 1.1em 0;
}

.chroma, .chroma span { color: #e9e4fd; }
.chroma code { font-family: var(--mono); }

.chroma .k, .chroma .kc, .chroma .kd, .chroma .kr, .chroma .kt { color: var(--indigo-200); }
.chroma .s, .chroma .s1, .chroma .s2, .chroma .sb, .chroma .sh { color: var(--atlantis-200); }
.chroma .m, .chroma .mi, .chroma .mf { color: #ffd1b5; }
.chroma .nt, .chroma .nb, .chroma .nf, .chroma .nx { color: var(--brand-400); }
.chroma .c, .chroma .c1, .chroma .cm { color: rgba(255, 255, 255, 0.45); }
.chroma .p, .chroma .o { color: rgba(190, 180, 251, 0.75); }
.chroma .err { color: #e9e4fd; }

.copy-code {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.75);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.chroma:hover .copy-code { opacity: 1; }
.copy-code:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }
.copy-code.copied { color: var(--atlantis-200); opacity: 1; }

/* ---------- Code rail ---------- */

.doc-code {
  position: sticky;
  top: 44px;
  align-self: start;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  scrollbar-width: thin;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.panel {
  background: var(--code-bg);
  border: 1px solid rgba(140, 116, 248, 0.22);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--panel-shadow);
}

.panel-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-method {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.method-get { color: var(--meadow-300); }
.method-post { color: var(--brand-400); }
.method-put, .method-patch { color: var(--pumpkin-300); }
.method-delete { color: var(--cerise-300); }

.panel-path {
  font-family: var(--mono);
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.7);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--meadow-300);
  flex-shrink: 0;
}

.panel .chroma {
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent !important;
  max-height: 480px;
  overflow: auto;
}

.hosts-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hosts-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 12px;
}

.hosts-row span {
  flex-shrink: 0;
  width: 72px;
  font-weight: 800;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.hosts-row code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--code-inline-fg);
  word-break: break-all;
}

.panel-link {
  font-size: 13px;
  font-weight: 700;
  padding: 0 4px;
}

/* ---------- TOC (guide pages) ---------- */

.toc { font-size: 13px; padding: 4px 0 0 4px; }

.toc-title {
  font-size: 13.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--label-fg);
  opacity: 0.85;
  margin-bottom: 8px;
}

.toc-link {
  display: block;
  color: var(--ink-muted);
  padding: 3.5px 0 3.5px 12px;
  border-left: 2px solid var(--border);
  line-height: 1.4;
}

.toc-link:hover { color: var(--ink-strong); text-decoration: none; }

.toc-link.active {
  color: var(--link);
  font-weight: 700;
  border-left-color: var(--link);
}

.toc-level-3 { padding-left: 24px; }
.toc-level-4 { padding-left: 36px; font-size: 12px; }

/* Guide pages: narrower rail, content gets the room. */
.doc-grid-guide { grid-template-columns: minmax(0, 1fr) 230px; }
.doc-grid-guide .doc-main { max-width: 750px; }

/* ---------- Doc footer ---------- */

.doc-footer {
  margin-top: 44px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

.markdown-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
}

.markdown-link:hover { color: var(--link); text-decoration: none; }

/* ---------- Home extras ---------- */

.home-hosts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 1.6em 0;
}

.home-host {
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  padding: 14px 16px;
}

.home-host-label {
  display: block;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.home-host code {
  background: none;
  padding: 0;
  font-size: 13px;
  color: var(--code-inline-fg);
  word-break: break-all;
}

.home-host p {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--ink-muted);
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .doc-grid { grid-template-columns: minmax(0, 1fr); }
  .doc-grid-guide { grid-template-columns: minmax(0, 1fr); }
  .doc-code { position: static; max-height: none; }
  .doc-grid-guide .toc { display: none; }
}

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
  }

  .sidebar-nav { max-height: 320px; }

  .doc-grid { padding: 28px 20px 60px; }

  .home-hosts { grid-template-columns: 1fr; }
}
