/* ── Knowledge Base reader — shared visitor + admin styles ────────────────
   Standalone document chrome (NOT the viewer's overlay shell). Greens match
   the viewer accent (#2e7d32) so the brand reads consistently. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
               Ubuntu, Cantarell, sans-serif;
  background: #f5f7f4;
  color: #1f2a23;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: #2e7d32; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ────────────────────────────────────────────────────────────── */
.kb-header {
  background: #fff;
  border-bottom: 1px solid #e2e8de;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 rgba(46, 125, 50, 0.04);
}
.kb-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
}
.kb-header-brand img { width: 30px; height: 30px; border-radius: 6px; }
.kb-header-titles { display: flex; flex-direction: column; line-height: 1.15; }
.kb-header-title { font-weight: 700; font-size: 15px; color: #1b3320; }
.kb-header-tag { font-size: 12px; color: #6f7c72; }
.kb-header-spacer { flex: 1; }
.kb-header-link {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  background: #2e7d32;
  color: #fff;
}
.kb-header-link:hover { background: #266c2a; text-decoration: none; }
.kb-header-link.outline {
  background: transparent;
  color: #2e7d32;
  border: 1px solid #cfe0d1;
}
.kb-header-link.outline:hover { background: #ecf4ed; }

/* ── Search bar (under header) ────────────────────────────────────────── */
.kb-search-wrap {
  background: linear-gradient(180deg, #ecf4ed 0%, #f5f7f4 100%);
  padding: 36px 22px 26px;
  border-bottom: 1px solid #e2e8de;
}
.kb-search-inner {
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}
.kb-search-hed {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 6px;
  color: #1b3320;
  letter-spacing: -0.01em;
}
.kb-search-sub {
  margin: 0 0 18px;
  color: #5a6960;
  font-size: 14px;
}
.kb-search-box {
  position: relative;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 18px rgba(31, 42, 35, 0.06),
              0 1px 2px rgba(31, 42, 35, 0.04);
  border: 1px solid #d8e3da;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.kb-search-box:focus-within {
  border-color: #2e7d32;
  box-shadow: 0 0 0 4px rgba(46, 125, 50, 0.12),
              0 4px 18px rgba(31, 42, 35, 0.06);
}
.kb-search-box input {
  width: 100%;
  border: 0;
  background: transparent;
  font-size: 16px;
  font-family: inherit;
  padding: 16px 16px 16px 46px;
  border-radius: 14px;
  outline: none;
  color: #1f2a23;
}
.kb-search-box svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.kb-search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #99a59c;
  cursor: pointer;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 6px;
}
.kb-search-clear:hover { background: #ecf4ed; color: #2e7d32; }

/* ── Body layout ──────────────────────────────────────────────────────── */
.kb-body {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 22px 60px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.kb-aside { position: sticky; top: 84px; align-self: start; }
.kb-aside-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7a877e;
  margin: 0 0 10px;
  font-weight: 700;
}
.kb-cat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kb-cat-list button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: #3a4a40;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 100ms ease, color 100ms ease;
}
.kb-cat-list button:hover { background: #ecf4ed; color: #2e7d32; }
.kb-cat-list button.is-active {
  background: #2e7d32;
  color: #fff;
  font-weight: 600;
}
.kb-cat-list button.is-active .kb-cat-count {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.kb-cat-count {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #e2e8de;
  color: #6f7c72;
  font-weight: 600;
}

/* ── Main column ──────────────────────────────────────────────────────── */
.kb-main { min-width: 0; }
.kb-result-head {
  font-size: 14px;
  color: #5a6960;
  margin: 0 0 14px;
}
.kb-result-head strong { color: #1b3320; }

.kb-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.kb-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  background: #fff;
  border: 1px solid #e2e8de;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(31, 42, 35, 0.03);
  transition: transform 120ms ease, box-shadow 120ms ease,
              border-color 120ms ease;
  color: inherit;
  text-decoration: none;
}
.kb-card:hover {
  transform: translateY(-2px);
  border-color: #b8d1bc;
  box-shadow: 0 8px 24px rgba(31, 42, 35, 0.07);
  text-decoration: none;
}
.kb-card-title {
  font-size: 16px;
  font-weight: 700;
  color: #1b3320;
  margin: 0;
  line-height: 1.3;
}
.kb-card-summary {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: #4a5a50;
}
.kb-card-summary mark {
  background: #fff3b8;
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}
.kb-card-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 6px;
}

.kb-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e2e8de;
  color: #4a5a50;
}
.kb-pill.is-viewer { background: #e8f1e9; color: #2e7d32; }
.kb-pill.is-admin { background: #ede4f7; color: #6a3eb8; }
.kb-pill.is-both { background: #fff3d6; color: #7a5a14; }
.kb-pill-time {
  font-size: 12px;
  color: #7a877e;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ── Empty / loading / error states ──────────────────────────────────── */
.kb-state {
  background: #fff;
  border: 1px dashed #d8e3da;
  border-radius: 12px;
  padding: 36px 22px;
  text-align: center;
  color: #5a6960;
  font-size: 14px;
}
.kb-state strong { display: block; color: #1b3320; font-size: 16px; margin-bottom: 4px; }

/* ── Article reader ──────────────────────────────────────────────────── */
.kb-article-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 22px 60px;
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 40px;
}
.kb-article { min-width: 0; }
.kb-crumbs {
  font-size: 13px;
  color: #6f7c72;
  margin-bottom: 16px;
}
.kb-crumbs a { color: #6f7c72; }
.kb-crumbs a:hover { color: #2e7d32; }
.kb-crumbs span.sep { margin: 0 6px; color: #c0cbc3; }
.kb-crumbs span.here { color: #1b3320; font-weight: 600; }

.kb-article h1 {
  margin: 4px 0 8px;
  font-size: 30px;
  line-height: 1.2;
  color: #1b3320;
  letter-spacing: -0.015em;
}
.kb-article .kb-summary {
  font-size: 16px;
  line-height: 1.55;
  color: #4a5a50;
  margin: 0 0 14px;
}
.kb-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 26px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8de;
}
.kb-updated {
  font-size: 12px;
  color: #7a877e;
}

/* Steps */
.kb-steps {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 32px;
}
.kb-step {
  background: #fff;
  border: 1px solid #e2e8de;
  border-radius: 12px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 16px;
  scroll-margin-top: 84px;
}
.kb-step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2e7d32;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}
.kb-step-body h3 { margin: 0 0 4px; font-size: 16px; color: #1b3320; }
.kb-step-text { margin: 0; line-height: 1.55; color: #36443c; font-size: 14.5px; }
.kb-step-anchor {
  font-size: 11px;
  color: #99a59c;
  margin-left: 6px;
  text-decoration: none;
}
.kb-step:target { border-color: #2e7d32; box-shadow: 0 0 0 3px rgba(46,125,50,0.1); }
.kb-shot {
  margin-top: 12px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e2e8de;
  background: #f5f7f4;
}
.kb-shot img { display: block; width: 100%; height: auto; }
.kb-shot-caption {
  font-size: 12px;
  color: #6f7c72;
  padding: 8px 12px;
  background: #f9faf8;
  border-top: 1px solid #e2e8de;
}

/* Body markdown */
.kb-body-md {
  font-size: 15px;
  line-height: 1.65;
  color: #2c3a32;
}
.kb-body-md h2 {
  margin: 32px 0 10px;
  font-size: 20px;
  color: #1b3320;
  scroll-margin-top: 84px;
}
.kb-body-md h3 {
  margin: 22px 0 8px;
  font-size: 16px;
  color: #1b3320;
  scroll-margin-top: 84px;
}
.kb-body-md p { margin: 0 0 12px; }
.kb-body-md ul, .kb-body-md ol { margin: 0 0 14px; padding-left: 22px; }
.kb-body-md li { margin: 4px 0; }
.kb-body-md code {
  background: #ecf4ed;
  color: #1b3320;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.92em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.kb-body-md pre {
  background: #1b2620;
  color: #ecf4ed;
  padding: 12px 14px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}
.kb-body-md pre code { background: transparent; color: inherit; padding: 0; }
.kb-body-md blockquote {
  border-left: 3px solid #2e7d32;
  background: #ecf4ed;
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  color: #36443c;
}
.kb-body-md a { color: #2e7d32; text-decoration: underline; }

/* Related */
.kb-related {
  margin-top: 36px;
  border-top: 1px solid #e2e8de;
  padding-top: 22px;
}
.kb-related h2 {
  font-size: 18px;
  margin: 0 0 12px;
  color: #1b3320;
}

/* Sticky TOC */
.kb-toc {
  position: sticky;
  top: 84px;
  align-self: start;
  font-size: 13px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.kb-toc-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7a877e;
  font-weight: 700;
  margin: 0 0 8px;
}
.kb-toc ul { list-style: none; margin: 0; padding: 0; }
.kb-toc li { line-height: 1.4; }
.kb-toc a {
  display: block;
  color: #5a6960;
  padding: 5px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  transition: color 100ms ease, border-color 100ms ease, background 100ms ease;
}
.kb-toc a:hover {
  color: #2e7d32;
  background: #ecf4ed;
  border-left-color: #2e7d32;
  text-decoration: none;
}
.kb-toc a.toc-h3 { padding-left: 22px; font-size: 12.5px; }
.kb-toc a.is-active {
  color: #2e7d32;
  border-left-color: #2e7d32;
  font-weight: 600;
}

/* ── Loading skeleton ─────────────────────────────────────────────────── */
.kb-skeleton {
  background: linear-gradient(90deg, #eef2ec 0%, #f6f8f4 50%, #eef2ec 100%);
  background-size: 200% 100%;
  animation: kb-shimmer 1.4s linear infinite;
  border-radius: 8px;
}
@keyframes kb-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.kb-sk-card {
  height: 130px;
  border-radius: 12px;
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 880px) {
  .kb-body { grid-template-columns: 1fr; gap: 18px; }
  .kb-aside {
    position: static;
    background: #fff;
    border: 1px solid #e2e8de;
    border-radius: 12px;
    padding: 14px;
  }
  .kb-aside-title { margin-top: 0; }
  .kb-cat-list { flex-direction: row; flex-wrap: wrap; }
  .kb-cat-list button { width: auto; }
  .kb-article-wrap { grid-template-columns: 1fr; gap: 18px; }
  .kb-toc {
    position: static;
    border: 1px solid #e2e8de;
    border-radius: 12px;
    padding: 14px;
    background: #fff;
    max-height: none;
  }
  .kb-search-hed { font-size: 22px; }
  .kb-article h1 { font-size: 24px; }
  .kb-step { grid-template-columns: 28px 1fr; padding: 14px; gap: 12px; }
  .kb-step-num { width: 28px; height: 28px; font-size: 13px; }
}
@media (max-width: 540px) {
  .kb-header { padding: 10px 14px; gap: 10px; }
  .kb-header-tag { display: none; }
  .kb-search-wrap { padding: 24px 14px 18px; }
  .kb-body, .kb-article-wrap { padding: 18px 14px 40px; }
}
