:root {
  --kb-bg: #0a0c12;
  --kb-panel: #12161f;
  --kb-card: #ffffff;
  --kb-card-text: #1a1d26;
  --kb-muted: #6b7280;
  --kb-border: rgba(255, 255, 255, 0.1);
  --kb-accent: #ffc84d;
  --kb-cyan: #3de8ff;
  --kb-sidebar-w: 280px;
  --font: "Inter", system-ui, sans-serif;
  --font-display: "Outfit", var(--font);
}

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

body.kb-page {
  font-family: var(--font);
  background: var(--kb-bg);
  color: #e8eaef;
  line-height: 1.55;
  min-height: 100vh;
}

.kb-top {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--kb-border);
  background: rgba(10, 12, 18, 0.94);
  backdrop-filter: blur(12px);
}

.kb-top-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.kb-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}

.kb-brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--kb-accent), #ff4fd8);
  color: #0a0612;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.72rem;
  display: grid;
  place-items: center;
}

.kb-brand strong {
  font-family: var(--font-display);
  font-size: 0.95rem;
  display: block;
}

.kb-brand small {
  color: var(--kb-cyan);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.kb-top-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.kb-top-links a {
  color: #9ca3af;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
}

.kb-top-links a:hover { color: var(--kb-cyan); background: rgba(61, 232, 255, 0.08); }

.kb-layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem;
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 960px) {
  .kb-layout.has-sidebar {
    grid-template-columns: var(--kb-sidebar-w) 1fr;
    align-items: start;
  }
}

.kb-sidebar {
  background: var(--kb-panel);
  border: 1px solid var(--kb-border);
  border-radius: 12px;
  overflow: hidden;
}

.kb-sidebar-title {
  padding: 0.85rem 1rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--kb-accent);
  border-bottom: 1px solid var(--kb-border);
}

.kb-cat-nav { list-style: none; }

.kb-cat-nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  color: #c5cad6;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s, color 0.15s;
}

.kb-cat-nav a:hover,
.kb-cat-nav a.is-active {
  background: rgba(255, 200, 77, 0.08);
  color: var(--kb-accent);
}

.kb-cat-nav .badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #9ca3af;
}

.kb-main { min-width: 0; }

.kb-breadcrumb {
  margin-bottom: 1rem;
}

.kb-breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--kb-muted);
}

.kb-breadcrumb li + li::before {
  content: "›";
  margin-right: 0.35rem;
  opacity: 0.5;
}

.kb-breadcrumb a {
  color: var(--kb-cyan);
  text-decoration: none;
}

.kb-breadcrumb li[aria-current] {
  color: #e8eaef;
  font-weight: 600;
}

.kb-hero {
  margin-bottom: 1.5rem;
}

.kb-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  margin-bottom: 0.35rem;
}

.kb-hero p {
  color: #9ca3af;
  max-width: 42rem;
}

.kb-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.kb-cat-card {
  display: block;
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--kb-border);
  background: var(--kb-panel);
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, border-color 0.2s;
}

.kb-cat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 200, 77, 0.4);
}

.kb-cat-card .icon { font-size: 1.75rem; margin-bottom: 0.5rem; }

.kb-cat-card h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.kb-cat-card p {
  font-size: 0.85rem;
  color: #9ca3af;
}

.kb-cat-card .count {
  margin-top: 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--kb-accent);
}

.kb-search {
  margin-bottom: 1rem;
}

.kb-search input {
  width: 100%;
  max-width: 480px;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border-radius: 10px;
  border: 1px solid var(--kb-border);
  background: var(--kb-panel);
  color: #fff;
  font: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='%233de8ff' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.9rem center;
}

.kb-article-list {
  list-style: none;
  border: 1px solid var(--kb-border);
  border-radius: 12px;
  background: var(--kb-panel);
  overflow: hidden;
}

.kb-article-list li { border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.kb-article-list li:last-child { border-bottom: none; }

.kb-article-list a {
  display: block;
  padding: 0.85rem 1rem;
  color: #e8eaef;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s;
}

.kb-article-list a:hover {
  background: rgba(61, 232, 255, 0.06);
  color: var(--kb-cyan);
}

.kb-article-list li.is-hidden { display: none; }

.kb-article-panel {
  background: var(--kb-card);
  color: var(--kb-card-text);
  border-radius: 12px;
  padding: 1.5rem 1.75rem 2rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.kb-article-panel h1 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  color: #111827;
  margin-bottom: 1rem;
  line-height: 1.3;
}

.kb-article-body {
  font-size: 0.95rem;
  line-height: 1.65;
}

.kb-article-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1rem 0;
}

.kb-article-body pre,
.kb-article-body code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85em;
}

.kb-article-body pre {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
  white-space: pre-wrap;
}

.kb-article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.88rem;
}

.kb-article-body th,
.kb-article-body td {
  border: 1px solid #e5e7eb;
  padding: 0.5rem 0.65rem;
  text-align: left;
}

.kb-article-body a { color: #2563eb; }

.kb-article-meta {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
  font-size: 0.82rem;
  color: var(--kb-muted);
}

.kb-article-meta a { color: #2563eb; }

.kb-portal-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--kb-muted);
  text-decoration: none;
}

.kb-portal-link:hover { color: #2563eb; }

.kb-empty {
  padding: 2rem;
  text-align: center;
  color: #9ca3af;
}

@media (max-width: 959px) {
  .kb-sidebar-toggle {
    display: block;
    width: 100%;
    margin-bottom: 0.75rem;
    padding: 0.6rem;
    border: 1px solid var(--kb-border);
    border-radius: 8px;
    background: var(--kb-panel);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
  }

  .kb-sidebar.is-collapsed { display: none; }
}

@media (min-width: 960px) {
  .kb-sidebar-toggle { display: none; }
}
