/* Override main site scrolling for knowledge page */
body {
  overflow: hidden;
  height: 100vh;
}

main {
  max-width: 100% !important;
  width: 100% !important;
  height: 100vh;
  padding: 24px 40px !important;
  display: flex;
  flex-direction: column;
}

.kb-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid #e5e5e5;
  font-size: 14px;
  flex-shrink: 0;
}

.kb-back {
  color: #555;
  text-decoration: none;
}

.kb-back:hover {
  color: #1e40af;
}

.kb-update-btn {
  background: none;
  border: 1px solid #d5d5d5;
  border-radius: 4px;
  color: #888;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 8px;
  line-height: 1;
}
.kb-update-btn:hover {
  color: #1e40af;
  border-color: #1e40af;
}

.kb-updated {
  font-size: 12px;
  color: #999;
}

.kb-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 48px;
  height: calc(100vh - 100px);
  overflow: hidden;
  transition: grid-template-columns 0.3s ease;
}

.kb-layout.sidebar-collapsed {
  grid-template-columns: 32px 1fr;
  gap: 12px;
}

.kb-sidebar {
  overflow-y: auto;
  padding-right: 8px;
  transition: padding 0.3s ease;
}

.kb-layout.sidebar-collapsed .kb-sidebar {
  padding-right: 0;
  overflow: hidden;
}

.kb-content {
  overflow-y: auto;
  min-height: 0;
  font-size: 15px;
  line-height: 1.85;
  color: #1a1a1a;
  padding-bottom: 40px;
}

.kb-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: flex-direction 0.3s ease;
}

.kb-layout.sidebar-collapsed .kb-sidebar-header {
  flex-direction: column;
  align-items: center;
}

.kb-layout.sidebar-collapsed .kb-title {
  display: none;
}

.kb-sidebar-body {
  transition: opacity 0.2s ease, max-height 0.3s ease;
  overflow: hidden;
}

.kb-layout.sidebar-collapsed .kb-sidebar-body {
  opacity: 0;
  max-height: 0;
  pointer-events: none;
}

.kb-toggle {
  background: none;
  border: 1px solid #d5d5d5;
  border-radius: 4px;
  color: #888;
  font-size: 10px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}
.kb-toggle:hover {
  color: #1e40af;
  border-color: #1e40af;
}

.kb-layout.sidebar-collapsed .kb-toggle {
  transform: rotate(180deg);
}

.kb-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
  color: #1a1a1a;
}

.kb-search {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #d5d5d5;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  margin-bottom: 10px;
}

.kb-search:focus {
  border-color: #1e40af;
  box-shadow: 0 0 0 2px rgba(30,64,175,0.1);
}

.kb-sort {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.kb-sort-btn {
  background: none;
  border: 1px solid #d5d5d5;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  color: #888;
  cursor: pointer;
  font-family: inherit;
}

.kb-sort-btn.active {
  background: #1e40af;
  color: #fff;
  border-color: #1e40af;
}

.kb-path-hint {
  display: block;
  font-size: 11px;
  color: #bbb;
  margin-left: 10px;
}

.kb-none {
  color: #aaa;
  font-style: italic;
  font-size: 13px;
  padding: 8px 0;
}

.kb-tree {
  list-style: none;
  padding: 0;
  font-size: 14px;
  line-height: 2;
}

.kb-tree li {
  padding: 1px 0;
}

.kb-dir {
  font-weight: 600;
  color: #1a1a1a;
  margin-top: 6px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
}

.kb-file a {
  color: #555;
  text-decoration: none;
  display: block;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 10px;
  font-size: 13px;
}

.kb-file a:hover {
  color: #1e40af;
  background: #f4f4f0;
}

.kb-pinned a {
  font-weight: 600 !important;
  color: #1e40af !important;
}

.kb-divider {
  height: 1px;
  background: #e5e5e5;
  margin: 6px 0 6px 10px !important;
  padding: 0 !important;
}

.kb-file.active a {
  color: #1e40af;
  background: #eef2ff;
  font-weight: 500;
}

.kb-placeholder,
.kb-loading {
  color: #aaa;
  font-style: italic;
  padding: 40px 0;
}

/* Markdown rendered content */
.kb-article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
}

.kb-article-date {
  font-size: 13px;
  color: #999;
  font-family: "SF Mono", "Fira Code", monospace;
}

.kb-article-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 12px;
  background: #ede9fe;
  color: #5b21b6;
  cursor: pointer;
}

.kb-article-tag:hover {
  background: #ddd6fe;
}

.kb-content h1 { font-size: 26px; font-weight: 700; margin: 12px 0 12px; }
.kb-content h1:first-child { margin-top: 0; }
.kb-content h2 { font-size: 20px; font-weight: 600; margin: 28px 0 8px; padding-bottom: 4px; border-bottom: 1px solid #e5e5e5; }
.kb-content h3 { font-size: 17px; font-weight: 600; margin: 22px 0 6px; }
.kb-content h4 { font-size: 15px; font-weight: 600; margin: 18px 0 4px; }
.kb-content p { margin-bottom: 12px; }
.kb-content ul, .kb-content ol { margin-bottom: 12px; padding-left: 24px; }
.kb-content li { margin-bottom: 4px; }
.kb-content li > ul, .kb-content li > ol { margin-top: 4px; margin-bottom: 0; }

.kb-content a { color: #1e40af; text-decoration: none; }
.kb-content a:hover { text-decoration: underline; }

.kb-content strong { font-weight: 600; }

.kb-content code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;
  font-size: 13px;
  background: #f5f5f4;
  padding: 2px 6px;
  border-radius: 3px;
  color: #d63384;
}

.kb-content pre {
  background: #f8f8f8;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 14px 16px;
  overflow-x: auto;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.6;
}

.kb-content pre code {
  background: none;
  padding: 0;
  color: #1a1a1a;
  font-size: 13px;
}

.kb-content blockquote {
  border-left: 3px solid #1e40af;
  margin: 0 0 14px;
  padding: 8px 16px;
  color: #555;
  background: #f8fafc;
  border-radius: 0 6px 6px 0;
}

.kb-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 14px;
}

.kb-content th, .kb-content td {
  border: 1px solid #e5e5e5;
  padding: 8px 12px;
  text-align: left;
}

.kb-content th {
  background: #f5f5f4;
  font-weight: 600;
}

.kb-content img {
  max-width: 100%;
  border-radius: 6px;
}

.kb-content hr {
  border: none;
  border-top: 1px solid #e5e5e5;
  margin: 24px 0;
}

/* KaTeX math */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

@media (max-width: 640px) {
  .kb-layout {
    grid-template-columns: 1fr;
  }

  .kb-sidebar {
    position: static;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e5e5;
  }
}

.kb-gh-link {
  color: #888;
  display: flex;
  align-items: center;
}
.kb-gh-link:hover {
  color: #1a1a1a;
}
