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

:root {
  --bg: #ffffff;
  --secondary: #f6f8fa;
  --border: #d0d7de;
  --text: #1f2328;
  --text-secondary: #656d76;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --green: #1a7f37;
  --green-bg: #dafbe1;
  --yellow: #9a6700;
  --yellow-bg: #fff8c5;
  --purple: #8250df;
  --purple-bg: #fbefff;
  --orange: #bc4c00;
  --orange-bg: #fff1e5;
  --red: #cf222e;
  --red-bg: #ffebe9;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 48px; background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; z-index: 100; gap: 12px;
}
.topbar-logo {
  font-weight: 600; font-size: 14px; color: var(--text); text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}
.topbar-logo:hover { text-decoration: none; }

.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.topbar-actions.hidden { display: none; }

/* Buttons */
.btn {
  font-family: var(--font); font-size: 12px; font-weight: 500;
  padding: 4px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--secondary); }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* Landing */
.landing { max-width: 560px; margin: 80px auto 40px; padding: 0 24px; }
.landing h1 { font-size: 28px; font-weight: 600; margin-bottom: 8px; }
.landing-desc { color: var(--text-secondary); font-size: 15px; margin-bottom: 24px; line-height: 1.6; }

.input-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.input-tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--secondary); }
.input-tab {
  flex: 1; text-align: center; padding: 8px 0; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; user-select: none;
}
.input-tab.active { color: var(--text); border-bottom-color: var(--accent); background: var(--bg); }
.input-tab:hover:not(.active) { color: var(--text); }

.input-body { padding: 16px; }
textarea.spec-input {
  width: 100%; min-height: 180px; resize: vertical;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px;
  color: var(--text); font-family: var(--mono); font-size: 12px; line-height: 1.5; display: block;
}
textarea.spec-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(9,105,218,0.15); }

.url-row { display: flex; gap: 8px; }
.url-row input {
  flex: 1; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 13px; font-family: var(--font);
}
.url-row input:focus { outline: none; border-color: var(--accent); }

.generate-btn {
  width: 100%; padding: 8px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius); font-size: 14px; font-weight: 500;
  font-family: var(--font); cursor: pointer; margin-top: 12px; transition: background 0.15s;
}
.generate-btn:hover { background: var(--accent-hover); }
.generate-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Docs layout */
.docs-layout { display: none; margin-top: 48px; align-items: flex-start; }
.sidebar {
  width: 260px; min-width: 260px; border-right: 1px solid var(--border);
  background: var(--secondary); padding: 16px 0;
  position: sticky; top: 48px; align-self: flex-start;
  max-height: calc(100vh - 48px); overflow-y: auto;
}
.sidebar-group { margin-bottom: 8px; }
.sidebar-group-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-secondary); padding: 6px 20px 4px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 20px; font-size: 13px; color: var(--text-secondary); cursor: pointer;
  border-left: 2px solid transparent; transition: background 0.15s, color 0.15s; user-select: none;
}
.sidebar-item:hover { background: rgba(0,0,0,0.03); color: var(--text); }

.method-tag {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  padding: 1px 5px; border-radius: 3px; min-width: 36px; text-align: center; text-transform: uppercase; letter-spacing: 0.3px;
}
.method-get { background: var(--green-bg); color: var(--green); }
.method-post { background: var(--yellow-bg); color: var(--yellow); }
.method-put { background: var(--purple-bg); color: var(--purple); }
.method-patch { background: var(--orange-bg); color: var(--orange); }
.method-delete { background: var(--red-bg); color: var(--red); }

.sidebar-path { font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.content { margin-left: 260px; padding: 32px 40px; max-width: none; }
.content h1 { font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.subtitle { color: var(--text-secondary); font-size: 14px; margin-bottom: 8px; font-family: var(--mono); }
.description { color: var(--text-secondary); font-size: 15px; line-height: 1.6; margin-bottom: 32px; }

/* Endpoint cards */
.endpoint { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.endpoint-header {
  padding: 10px 16px; display: flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--secondary); transition: background 0.15s; user-select: none;
}
.endpoint-header:hover { background: rgba(0,0,0,0.03); }

.endpoint-path { font-family: var(--mono); font-size: 13px; color: var(--text); flex: 1; }
.endpoint-summary { font-size: 13px; color: var(--text-secondary); }

.endpoint-body { display: none; }
.endpoint.open .endpoint-body { display: block; }

.endpoint-desc { padding: 12px 16px; font-size: 14px; color: var(--text-secondary); line-height: 1.5; border-top: 1px solid var(--border); }

/* Param table */
.params-wrap { padding: 0 16px; }
.params-wrap h4 {
  font-size: 12px; font-weight: 600; color: var(--text-secondary); margin: 14px 0 8px; letter-spacing: 0.2px;
}
.param-table { width: 100%; border-collapse: collapse; }
.param-table td { padding: 6px 8px; font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: top; }
.param-table td:first-child { white-space: nowrap; width: 140px; }
.param-name { font-weight: 500; color: var(--text); font-family: var(--mono); font-size: 12px; }
.param-type { color: var(--purple); font-size: 11px; margin-left: 4px; }
.param-req { color: var(--red); font-size: 10px; margin-left: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.param-desc { color: var(--text-secondary); font-size: 12px; line-height: 1.4; }

/* Request body */
.req-body {
  background: var(--secondary); border-radius: var(--radius); padding: 12px 16px; margin: 8px 16px 12px;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--text); white-space: pre-wrap; border: 1px solid var(--border);
}

/* Try it */
.try-it { border-top: 1px solid var(--border); padding: 12px 16px; background: var(--bg); }
.try-it-title { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 8px; }
.try-params { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.try-param { display: flex; align-items: center; gap: 4px; }
.try-param label { font-size: 12px; color: var(--text-secondary); font-weight: 500; white-space: nowrap; }
.try-param input {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 12px; font-family: var(--mono); width: 130px;
}
.try-param input:focus { outline: none; border-color: var(--accent); }

.send-btn { padding: 5px 12px; background: var(--green); color: #fff; border: none; border-radius: var(--radius); font-size: 12px; font-weight: 500; font-family: var(--font); cursor: pointer; transition: background 0.15s; }
.send-btn:hover { background: #167333; }

.response-box { margin-top: 8px; min-height: 40px; max-height: 280px; overflow-y: auto; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; font-family: var(--mono); font-size: 11px; line-height: 1.5; white-space: pre-wrap; word-break: break-all; color: var(--text-secondary); }
.response-box.has-error { border-color: #ffc1ba; color: var(--red); background: var(--red-bg); }
.response-box.has-success { border-color: #3fb950; color: var(--green); background: var(--green-bg); }

/* Responses list */
.responses-list { padding: 8px 16px; border-top: 1px solid var(--border); }
.responses-list h4 { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; letter-spacing: 0.2px; }
.resp-item { margin-bottom: 4px; font-size: 13px; }
.resp-code { font-family: var(--mono); font-weight: 600; font-size: 11px; padding: 1px 5px; border-radius: 3px; margin-right: 6px; }
.resp-code-2xx { background: var(--green-bg); color: var(--green); }
.resp-code-4xx { background: var(--yellow-bg); color: var(--yellow); }
.resp-code-5xx { background: var(--red-bg); color: var(--red); }

/* Footer */
.footer { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-secondary); display: flex; justify-content: space-between; align-items: center; }
.footer a { color: var(--text-secondary); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { margin-left: 0; padding: 20px 16px; }
}

/* Dark mode — auto adapts to system preference, no toggle */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --secondary: #161b22;
    --border: #30363d;
    --text: #c9d1d9;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #1f6feb;
    --green: #3fb950;
    --green-bg: #033a16;
    --yellow: #d29922;
    --yellow-bg: #341a00;
    --purple: #d2a8ff;
    --purple-bg: #2e1a47;
    --orange: #ffa657;
    --orange-bg: #3d1e00;
    --red: #f85149;
    --red-bg: #3c0d0d;
  }
  .btn-primary { color: #fff; }
  .endpoint-header:hover { background: rgba(255,255,255,0.03); }
  .sidebar-item:hover { background: rgba(255,255,255,0.03); }
}

/* Dropdown */
.dropdown-wrap { position: relative; display: inline-block; }
.dropdown-menu {
  display: none; position: absolute; top: calc(100% + 4px); right: 0; min-width: 220px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15); z-index: 200; padding: 6px 0;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 14px; font-size: 13px; color: var(--text); cursor: pointer; user-select: none;
}
.dropdown-item:hover { background: var(--secondary); }
.dropdown-item .di-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-item .di-time { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.dropdown-delete {
  background: none; border: none; color: var(--text-secondary); cursor: pointer;
  font-size: 14px; padding: 2px 6px; border-radius: 3px; line-height: 1;
}
.dropdown-delete:hover { background: var(--red-bg); color: var(--red); }
.dropdown-empty { padding: 8px 14px; font-size: 13px; color: var(--text-secondary); }
.dropdown-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* Comparison mode */
.compare-container { display: none; height: calc(100vh - 48px); }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; height: 100%; padding: 16px; }
.compare-panel {
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; background: var(--bg);
}
.compare-panel-header {
  padding: 8px 12px; background: var(--secondary); border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 500; color: var(--text); display: flex; align-items: center; justify-content: space-between;
}
.compare-panel-body { flex: 1; display: flex; overflow: hidden; position: relative; }
.compare-panel .sidebar {
  width: 200px; min-width: 200px; border-right: 1px solid var(--border);
  background: var(--secondary); padding: 8px 0; overflow-y: auto;
}
.compare-panel .content {
  margin-left: 200px; padding: 20px 24px; overflow-y: auto;
}
.compare-close-btn { font-size: 13px; cursor: pointer; color: var(--text-secondary); background: none; border: none; }
.compare-close-btn:hover { color: var(--red); }

@media (max-width: 768px) {
  .compare-grid { grid-template-columns: 1fr !important; }
}

/* SEO Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--secondary); margin-top: 64px; font-size: 13px; line-height: 1.6; color: var(--text-secondary); }
.footer-inner { max-width: 1100px; margin: 0 auto; padding: 40px 24px 24px; }
.footer-section { margin-bottom: 28px; }
.footer-h { font-size: 13px; font-weight: 600; color: var(--text); margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.footer-p { margin: 0; }
.footer-p code { font-family: var(--mono); font-size: 12px; background: var(--bg); border: 1px solid var(--border); padding: 1px 5px; border-radius: 3px; color: var(--text); }
.footer-cta a { color: var(--accent); }
.footer-meta { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; font-size: 12px; }
.footer-meta a { color: var(--accent); }
