/* kalp docs — Clerk-inspired layout, dark mode matches the kalp panel palette */

:root {
  --bg: #ffffff;
  --bg-sidebar: #fafafa;
  --bg-card: #ffffff;
  --bg-field: #f5f5f5;
  --bg-code: #f6f6f6;
  --bg-hover: #f0f0f0;
  --text: #1a1a1a;
  --text-muted: #595959;
  --text-faint: #8c8c8c;
  --border: #e6e6e6;
  --accent: #1f6fd6;
  --accent-soft: rgba(31, 111, 214, 0.08);
  --green: #0e9f6e;
  --red: #dc2626;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] {
  /* pixel-matched to the kalp inspector panel */
  --bg: #1a1a1a;
  --bg-sidebar: #202020;
  --bg-card: #242424;
  --bg-field: rgba(255, 255, 255, 0.025);
  --bg-code: #2a2a2a;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --text: rgba(255, 255, 255, 0.9);
  --text-muted: rgba(255, 255, 255, 0.6);
  --text-faint: rgba(255, 255, 255, 0.4);
  --border: rgba(255, 255, 255, 0.1);
  --accent: #93c5fd;
  --accent-soft: rgba(106, 168, 255, 0.08);
  --green: #10b981;
  --red: #f87171;
  --shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---- layout shell ------------------------------------------------------ */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 14px 40px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 18px;
  color: var(--text);
}

.logo:hover {
  text-decoration: none;
}

.logo-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent);
  color: #0d1b33;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.logo-chip {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-field);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 7px;
}

.nav-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin: 18px 10px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

.nav-link svg {
  flex-shrink: 0;
  opacity: 0.75;
}

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

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---- main column ------------------------------------------------------- */

.main {
  flex: 1;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 32px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.search-input {
  width: 100%;
  height: 38px;
  padding: 0 40px 0 36px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-field);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

.search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-faint);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: 44px;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  display: none;
}

.search-results.open {
  display: block;
}

.search-result {
  display: block;
  padding: 9px 14px;
  color: var(--text);
  font-size: 14px;
}

.search-result:hover,
.search-result.selected {
  background: var(--accent-soft);
  text-decoration: none;
}

.search-result small {
  display: block;
  color: var(--text-faint);
  font-size: 12px;
}

.search-empty {
  padding: 12px 14px;
  color: var(--text-faint);
  font-size: 13px;
}

.theme-toggle {
  margin-left: auto;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-field);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

.gh-link {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-field);
  border: 1px solid var(--border);
  border-radius: 10px;
}

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

/* ---- content ----------------------------------------------------------- */

.content {
  max-width: 780px;
  padding: 40px 32px 96px;
}

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 6px;
}

h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
  margin: 0 0 10px;
}

.lede {
  font-size: 17px;
  color: var(--text-muted);
  margin: 0 0 32px;
}

h2 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.3px;
  margin: 44px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

h2:first-of-type {
  border-top: none;
  padding-top: 0;
}

h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 28px 0 8px;
}

p {
  margin: 0 0 14px;
  color: var(--text-muted);
}

p strong,
li strong {
  color: var(--text);
  font-weight: 600;
}

ul,
ol {
  margin: 0 0 16px;
  padding-left: 22px;
  color: var(--text-muted);
}

li {
  margin-bottom: 6px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--text);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0 0 18px;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}

.code-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  margin: 0 0 6px;
}

/* ---- cards (home) ------------------------------------------------------ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 28px 0 8px;
}

.card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  color: var(--text);
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s;
}

.card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.card p {
  margin: 0;
  font-size: 14px;
}

/* ---- tables ------------------------------------------------------------ */

.table-wrap {
  overflow-x: auto;
  margin: 0 0 18px;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: top;
}

td code {
  white-space: nowrap;
}

/* ---- callouts & misc --------------------------------------------------- */

.callout {
  display: flex;
  gap: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--text-muted);
}

.callout svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--accent);
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  padding: 1px 7px;
  vertical-align: middle;
}

.badge.get {
  color: var(--green);
  background: rgba(16, 185, 129, 0.12);
}

.badge.post {
  color: var(--accent);
  background: var(--accent-soft);
}

kbd {
  font-family: inherit;
  font-size: 12px;
  background: var(--bg-field);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 7px;
  color: var(--text);
}

.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.error-msg {
  color: var(--red);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

/* ---- responsive -------------------------------------------------------- */

@media (max-width: 860px) {
  .shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 12px 18px;
  }

  .content {
    padding: 28px 18px 72px;
  }
}
