:root {
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
  --mono: 'SF Mono', ui-monospace, Menlo, monospace;
  --ink: #1d1d1f;
  --muted: #8e8e93;
  --line: #e8e8ed;
  --bg: #ffffff;
  --surface: #f9f9fb;
  --surface-hover: #f2f2f4;
  --header-bg: rgba(255, 255, 255, 0.92);
  --input-bg: #f9f9fb;
  --input-focus-bg: #ffffff;
  --path-color: #48484a;
  --active-nav-bg: #eef4ff;
  --active-nav-text: #0071e3;
  --method-get-bg: #e8f2ff;
  --method-post-bg: #e8f5eb;
  --method-put-bg: #fff0eb;
  --method-delete-bg: #ffecef;
  --method-patch-bg: #f0efff;
  --method-get-active: #d6e8ff;
  --method-post-active: #d4edda;
  --blue: #0071e3;
  --green: #248a3d;
  --orange: #c93400;
  --red: #d70015;
  --purple: #5856d6;
  --header-h: 52px;
  --sidebar-w: 260px;
  --response-w: 420px;
  --code-bg: #1e1e1e;
  --code-border: #2d2d2d;
  --scrollbar-size: 6px;
  --scrollbar-track: transparent;
  --scrollbar-thumb: rgba(0, 0, 0, 0.18);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.32);
  --scrollbar-thumb-active: rgba(0, 0, 0, 0.42);
}

[data-theme='dark'] {
  --ink: #f5f5f7;
  --muted: #98989d;
  --line: #38383a;
  --bg: #1c1c1e;
  --surface: #2c2c2e;
  --surface-hover: #3a3a3c;
  --header-bg: rgba(28, 28, 30, 0.92);
  --input-bg: #2c2c2e;
  --input-focus-bg: #3a3a3c;
  --path-color: #aeaeb2;
  --active-nav-bg: #1a3050;
  --active-nav-text: #64b5ff;
  --method-get-bg: #1a3050;
  --method-post-bg: #1a3324;
  --method-put-bg: #3a2218;
  --method-delete-bg: #3a1818;
  --method-patch-bg: #2a2848;
  --method-get-active: #234068;
  --method-post-active: #244830;
  --blue: #64b5ff;
  --green: #4cd964;
  --orange: #ff9f0a;
  --red: #ff453a;
  --code-bg: #0d0d0d;
  --code-border: #333;
  --scrollbar-thumb: rgba(255, 255, 255, 0.18);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.32);
  --scrollbar-thumb-active: rgba(255, 255, 255, 0.44);
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

html {
  scrollbar-gutter: stable;
}

*::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

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

*::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
  transition: background-color 0.15s ease;
}

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

*::-webkit-scrollbar-thumb:active {
  background-color: var(--scrollbar-thumb-active);
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

.code-block::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.22);
}

.code-block::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.36);
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background 0.2s, color 0.2s;
}

/* ── Header ── */
.docs-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.docs-header__left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s;
}

.menu-toggle:hover { background: var(--surface-hover); }

.menu-toggle__bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--ink);
  border-radius: 1px;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

body.sidebar-open .menu-toggle__bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

body.sidebar-open .menu-toggle__bar:nth-child(2) {
  opacity: 0;
}

body.sidebar-open .menu-toggle__bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.docs-header__brand {
  min-width: 0;
  transition: opacity 0.22s ease, max-width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.docs-header__brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.title-short { display: none; }

.docs-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.docs-header__meta {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
}

.docs-header__meta span {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
}

.docs-header__search-wrap {
  display: flex;
  align-items: center;
  min-width: 0;
}

.search-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.search-toggle:hover { background: var(--surface-hover); }

.search-toggle__icon { display: block; }

.docs-header__search {
  display: flex;
  align-items: center;
  min-width: 0;
}

.docs-header__search input {
  width: 200px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 11px;
  font: 13px var(--font);
  background: var(--input-bg);
  color: var(--ink);
}

.docs-header__search input:focus {
  outline: none;
  border-color: var(--muted);
  background: var(--input-focus-bg);
}

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

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background 0.12s, border-color 0.12s;
}

.theme-toggle:hover {
  background: var(--surface-hover);
}

.theme-toggle__icon { display: none; }

[data-theme='light'] .theme-toggle__icon--dark { display: block; }
[data-theme='dark'] .theme-toggle__icon--light { display: block; }

/* ── Layout ── */
.docs-layout {
  display: flex;
  padding-top: var(--header-h);
  height: 100vh;
  background: var(--bg);
}

.docs-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--bg);
  border-right: 1px solid var(--line);
  padding: 8px 0 24px;
}

.docs-content {
  flex: 1;
  display: flex;
  min-width: 0;
  height: calc(100vh - var(--header-h));
}

.docs-details {
  flex: 1;
  overflow-y: auto;
  padding: 32px 36px 48px;
  min-width: 0;
  background: var(--bg);
}

.docs-responses {
  width: var(--response-w);
  flex-shrink: 0;
  overflow: hidden;
  background: var(--bg);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

/* ── Sidebar ── */
.nav-group { margin-bottom: 2px; }

.nav-group__title {
  display: flex;
  align-items: center;
  gap: 6px;
  width: calc(100% - 16px);
  margin: 4px 8px 2px;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}

.nav-group__title:hover {
  background: var(--surface);
  color: var(--ink);
}

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

.nav-group__count {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.nav-group__chevron {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  margin-top: -2px;
  transition: transform 0.15s ease;
}

.nav-group.collapsed .nav-group__chevron {
  transform: rotate(-45deg);
  margin-top: 2px;
}

.nav-group.collapsed .nav-group__list { display: none; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 1px 8px;
  padding: 7px 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}

.nav-link:hover { background: var(--surface); }

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

.nav-link.hidden { display: none; }

.nav-link__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.35;
}

.method {
  flex-shrink: 0;
  min-width: 36px;
  padding: 2px 0;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
}

.method-get { color: var(--blue); background: var(--method-get-bg); }
.method-post { color: var(--green); background: var(--method-post-bg); }
.method-put { color: var(--orange); background: var(--method-put-bg); }
.method-delete { color: var(--red); background: var(--method-delete-bg); }
.method-patch { color: var(--purple); background: var(--method-patch-bg); }

.nav-link.active .method-get { background: var(--method-get-active); }
.nav-link.active .method-post { background: var(--method-post-active); }

/* ── Details (center) ── */
.details-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 14px;
}

.endpoint-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.endpoint-head .method {
  min-width: 48px;
  padding: 5px 0;
  font-size: 10px;
  border-radius: 6px;
}

.endpoint-path {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--path-color);
  word-break: break-all;
}

.endpoint-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.endpoint-desc {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  max-width: 520px;
}

.endpoint-desc p { margin: 0; }

.section { margin-bottom: 28px; }

.section h3 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.params-table th,
.params-table td {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.params-table tr:last-child td,
.params-table tr:last-child th { border-bottom: none; }

.params-table th {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

.params-table code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: none;
  padding: 0;
}

.params-table td:nth-child(2) {
  color: var(--muted);
  font-size: 12px;
}
.params-table--headers td:nth-child(2) { width: 10%; color: var(--muted); font-size: 12px; }
.params-table--headers td:nth-child(3) { width: 12%; font-size: 12px; }
.params-table--headers td:nth-child(4) { width: 28%; }

.params-table--params th { width: 16%; }
.params-table--params td:nth-child(2) { width: 10%; color: var(--muted); font-size: 12px; }
.params-table--params td:nth-child(3) { width: 12%; font-size: 12px; white-space: nowrap; }
.params-table--params td:nth-child(4) { width: 22%; }
.params-table--params td:nth-child(5) { width: auto; }

.param-example,
.header-example {
  color: var(--blue) !important;
  word-break: break-all;
  font-size: 11px !important;
}

.req-badge {
  font-size: 11px;
  color: var(--red);
  font-weight: 600;
}

/* ── Code blocks & JSON syntax ── */
.code-wrap {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--code-border);
  background: var(--code-bg);
}

.code-block {
  margin: 0;
  padding: 16px 18px;
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  overflow: auto;
  tab-size: 2;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

.code-block--plain {
  color: #d4d4d4;
  white-space: pre-wrap;
}

.json-key { color: #9cdcfe; }
.json-str { color: #ce9178; }
.json-num { color: #b5cea8; }
.json-bool { color: #569cd6; }
.json-null { color: #569cd6; }
.json-punct { color: #d4d4d4; }

.section-empty {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

/* ── Responses (right) ── */
.responses-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.responses-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.responses-panel__head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--surface);
  border-left: 3px solid var(--blue);
}

.responses-panel__head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}

.responses-panel__endpoint {
  margin-top: 8px;
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--path-color);
  word-break: break-all;
  line-height: 1.4;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.status-tab {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.12s;
}

.status-tab:hover {
  border-color: var(--muted);
  color: var(--ink);
}

.status-tab.active {
  border-color: transparent;
  color: #fff;
}

.status-tab.status-2.active { background: var(--green); }
.status-tab.status-4.active { background: var(--orange); }
.status-tab.status-5.active { background: var(--red); }

.response-body {
  flex: 1;
  overflow: auto;
  padding: 16px 20px 24px;
}

.response-desc {
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  :root { --header-h: 50px; }

  body { overflow: auto; }
  body.sidebar-open { overflow: hidden; }

  .menu-toggle { display: flex; }

  .docs-layout { height: auto; min-height: calc(100vh - var(--header-h)); }

  .docs-content {
    flex-direction: column;
    height: auto;
  }

  .docs-responses {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--line);
    min-height: 360px;
  }

  .docs-sidebar {
    display: block;
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    z-index: 200;
    width: min(280px, 88vw);
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    border-right: 1px solid var(--line);
  }

  body.sidebar-open .docs-sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.18);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    z-index: 150;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
  }

  [data-theme='dark'] .sidebar-backdrop {
    background: rgba(0, 0, 0, 0.6);
  }

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

  .search-toggle { display: flex; }

  .docs-header__search {
    width: 0;
    opacity: 0;
    overflow: hidden;
    margin-left: 0;
    transition:
      width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
      opacity 0.22s ease,
      margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .docs-header__search input {
    width: 100%;
    min-width: 160px;
  }

  body.search-open .docs-header__search {
    width: min(240px, calc(100vw - 132px));
    opacity: 1;
    margin-left: 8px;
  }

  body.search-open .docs-header__brand {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    pointer-events: none;
  }

  body.search-open .search-toggle {
    color: var(--blue);
    border-color: var(--blue);
    background: var(--active-nav-bg);
  }
}

@media (max-width: 640px) {
  :root { --header-h: 48px; }

  .docs-header {
    padding: 0 10px;
    gap: 8px;
  }

  .docs-header__left { gap: 8px; }

  .title-full { display: none; }
  .title-short { display: inline; }

  .docs-header__brand h1 {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 46vw;
  }

  .docs-header__meta {
    font-size: 10px;
    margin-top: 1px;
  }

  body.search-open .docs-header__search {
    width: min(210px, calc(100vw - 118px));
  }

  .search-toggle,
  .theme-toggle,
  .menu-toggle {
    width: 32px;
    height: 32px;
  }

  .docs-details { padding: 20px 16px 32px; }

  .responses-panel__head {
    padding: 14px 16px;
  }

  .status-tabs { padding: 10px 16px; }

  .response-body { padding: 12px 16px 20px; }
}
