:root {
  --sidebar-width: 260px;
  --header-height: 60px;
  --toc-width: 220px;
  --primary: #0057b8;
  --primary-light: #e8f0fb;
  --primary-hover: #003f8a;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --bg-white: #ffffff;
  --code-bg: #1e1e2e;
  --code-text: #cdd6f4;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --badge-get: #16a34a;
  --badge-post: #2563eb;
  --badge-delete: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
}

/* ─── Layout ────────────────────────────────────────────────── */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
  box-shadow: var(--shadow);
}

#header .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

#header .logo img {
  max-width: 50%;
}

#header .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.5px;
}

#header .logo-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

#header .logo-text span {
  color: var(--primary);
}

#header .header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

#header .version-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

#header .lang-switcher {
  display: flex;
  gap: 4px;
}

#header .lang-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

#header .lang-btn.active,
#header .lang-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-light);
}

#sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  z-index: 50;
}

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

.sidebar-section {
  margin-bottom: 8px;
}

.sidebar-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 20px 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.sidebar-nav a:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.sidebar-nav a.active {
  color: var(--primary);
  background: var(--primary-light);
  border-left-color: var(--primary);
  font-weight: 600;
}

.sidebar-sub-nav {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar-sub-nav a {
  padding: 5px 20px 5px 48px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
}

.sidebar-sub-nav a:hover,
.sidebar-sub-nav a.active {
  color: var(--primary);
  background: var(--primary-light);
  border-left-color: var(--primary);
}

#main {
  margin-left: var(--sidebar-width);
  margin-right: var(--toc-width);
  margin-top: var(--header-height);
  padding: 40px 48px;
  max-width: 1100px;
}

/* ─── Section headings ──────────────────────────────────────── */
.doc-section {
  margin-bottom: 64px;
  scroll-margin-top: calc(var(--header-height) + 24px);
}

.section-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 10px;
  border-radius: 20px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

h1.section-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.25;
}

h2.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

h3.sub-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 28px 0 10px;
}

.section-desc {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 20px;
  max-width: 680px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.info-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.info-card .card-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.info-card .card-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-family: 'SFMono-Regular', Consolas, monospace;
  word-break: break-all;
}

.info-card .card-value a {
  color: var(--primary);
  text-decoration: none;
}

.info-card .card-value a:hover {
  text-decoration: underline;
}

/* ─── Alerts / callouts ─────────────────────────────────────── */
.callout {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
}

.callout-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.callout-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.callout-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.callout-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.callout-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #14532d;
}

/* ─── Code blocks ───────────────────────────────────────────── */
.code-block-wrapper {
  margin: 16px 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.code-block-header {
  background: #16213e;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.code-block-header .code-lang {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.code-block-header .copy-btn {
  background: none;
  border: 1px solid #334155;
  color: #94a3b8;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.code-block-header .copy-btn:hover {
  border-color: #64748b;
  color: #e2e8f0;
}

.code-block-header .copy-btn.copied {
  color: #4ade80;
  border-color: #4ade80;
}

pre[class*="language-"] {
  margin: 0 !important;
  border-radius: 0 !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
}

code[class*="language-"] {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace !important;
}

/* ─── Inline code ───────────────────────────────────────────── */
code:not([class]) {
  background: #f1f5f9;
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 13px;
  border: 1px solid #e2e8f0;
}

/* ─── Tables ────────────────────────────────────────────────── */
.param-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 24px;
  font-size: 14px;
  background: var(--bg-white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.param-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.param-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

.param-table tr:hover td {
  background: var(--bg);
}

.param-name {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
}

.param-type {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12px;
  color: var(--primary);
}

.param-required {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #dc2626;
  background: #fef2f2;
  padding: 1px 6px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 5px;
}

.param-optional {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #6b7280;
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 5px;
}

/* ─── Method badges ─────────────────────────────────────────── */
.method-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  margin-right: 8px;
}

.method-get  { background: #dcfce7; color: #15803d; }
.method-post { background: #dbeafe; color: #1d4ed8; }
.method-put  { background: #fef9c3; color: #a16207; }
.method-del  { background: #fee2e2; color: #b91c1c; }

/* ─── Endpoint card ─────────────────────────────────────────── */
.endpoint-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.endpoint-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.endpoint-path {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.endpoint-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-left: auto;
}

.endpoint-body {
  padding: 18px;
}

/* ─── Error code table ──────────────────────────────────────── */
.error-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: var(--bg-white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.error-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.error-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

.error-table tr:hover td {
  background: var(--bg);
}

.error-code {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
  color: #dc2626;
  background: #fef2f2;
  padding: 2px 8px;
  border-radius: 4px;
}

.http-status {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: monospace;
}

.status-200 { background: #dcfce7; color: #15803d; }
.status-400 { background: #fef9c3; color: #a16207; }
.status-401 { background: #fee2e2; color: #b91c1c; }
.status-422 { background: #fef3c7; color: #92400e; }
.status-500 { background: #fee2e2; color: #b91c1c; }
.status-503 { background: #f3e8ff; color: #6b21a8; }

/* ─── Test card section ─────────────────────────────────────── */
.test-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.test-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.test-card .tc-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.test-card .tc-number {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.test-card .tc-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.test-card .tc-result {
  margin-top: 10px;
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.result-success { background: #dcfce7; color: #15803d; }
.result-fail    { background: #fee2e2; color: #b91c1c; }

/* ─── Hash algorithm diagram ────────────────────────────────── */
.hash-steps {
  counter-reset: hash-step;
  margin: 16px 0;
}

.hash-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.hash-step-num {
  counter-increment: hash-step;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hash-step-num::before {
  content: counter(hash-step);
}

.hash-step-content {
  flex: 1;
  padding-top: 4px;
}

.hash-step-content strong {
  display: block;
  font-size: 14px;
  margin-bottom: 3px;
}

.hash-step-content p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ─── Tabs ──────────────────────────────────────────────────── */
.tabs {
  margin-bottom: 20px;
}

.tab-list {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ─── Right-side TOC panel ──────────────────────────────────── */
#toc {
  position: fixed;
  top: var(--header-height);
  left: min(calc(100vw - var(--toc-width)), calc(var(--sidebar-width) + 1100px));
  width: var(--toc-width);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 24px 16px;
  z-index: 40;
}

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

.toc-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.toc-link {
  display: block;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid var(--border);
  transition: all 0.15s;
}

.toc-link:hover {
  color: var(--primary);
}

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

/* ─── Search Modal ─────────────────────────────────────────── */
#search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
}

#search-overlay.active {
  display: block;
}

#search-modal {
  display: none;
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 600px;
  max-height: 70vh;
  background: var(--bg-white);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  z-index: 201;
  overflow: hidden;
  display: none;
  flex-direction: column;
}

#search-modal.active {
  display: flex;
}

#search-input {
  width: 100%;
  padding: 16px 20px;
  font-size: 17px;
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-white);
}

#search-input::placeholder {
  color: var(--text-muted);
}

#search-results {
  overflow-y: auto;
  padding: 8px;
  flex: 1;
}

.search-result-item {
  display: block;
  padding: 10px 14px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}

.search-result-item:hover {
  background: var(--primary-light);
}

.search-result-section {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.search-result-title {
  font-size: 14px;
  font-weight: 600;
  margin-top: 2px;
}

.search-result-preview {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.search-kbd {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: inherit;
  line-height: 1.4;
}

#search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  transition: all 0.15s;
}

#search-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

#search-btn svg {
  width: 14px;
  height: 14px;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 1200px) {
  #toc {
    display: none;
  }
  #main {
    margin-right: 0;
  }
}

@media (max-width: 900px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
    z-index: 200;
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }

  #main {
    margin-left: 0;
    padding: 24px 20px;
  }

  .menu-toggle {
    display: flex !important;
  }
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  margin-right: 12px;
  color: var(--text);
  font-size: 20px;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 150;
}

.overlay.active {
  display: block;
}

/* ─── Misc ──────────────────────────────────────────────────── */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary);
}

ul.feature-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

ul.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

ul.feature-list li:last-child {
  border-bottom: none;
}

ul.feature-list li::before {
  content: '✓';
  color: var(--success);
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

p + p {
  margin-top: 10px;
}

/* scroll to top */
#scrollTop {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: 99;
  transition: background 0.15s;
}

#scrollTop:hover {
  background: var(--primary-hover);
}

#scrollTop.visible {
  display: flex;
}
