:root {
  --kb-chrome-height: 72px;
  --kb-sidebar-width: 286px;
  --kb-ink: #162226;
  --kb-muted: #607178;
  --kb-paper: #fffdfa;
  --kb-panel: rgba(255, 255, 255, 0.94);
  --kb-line: #d8e3e0;
  --kb-teal: #0e756d;
  --kb-coral: #c75b42;
  --kb-gold: #b8841f;
  --kb-shadow: 0 18px 55px rgba(20, 32, 36, 0.16);
}

* { box-sizing: border-box; }

body.kb-has-chrome {
  padding-top: var(--kb-chrome-height);
}

body.kb-has-chrome > header {
  top: var(--kb-chrome-height);
}

body.kb-reading-article {
  padding-top: 0;
}

body.kb-reading-article > header {
  top: 0;
}

body.kb-reading-article .kb-topbar,
body.kb-reading-article .kb-sidebar,
body.kb-reading-article .kb-backdrop,
body.kb-reading-article .kb-skip-link {
  display: none !important;
}

.kb-skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 80;
  transform: translateY(-160%);
  border-radius: 7px;
  background: var(--kb-ink);
  color: #ffffff;
  padding: 10px 12px;
  text-decoration: none;
  font-weight: 800;
}

.kb-skip-link:focus { transform: translateY(0); }

.kb-topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  min-height: var(--kb-chrome-height);
  display: grid;
  grid-template-columns: auto minmax(150px, max-content) minmax(240px, 640px);
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--kb-line);
  background: rgba(255, 253, 250, 0.94);
  box-shadow: 0 8px 28px rgba(20, 32, 36, 0.08);
  backdrop-filter: blur(14px);
  padding: 11px 20px;
}

.kb-home-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--kb-ink);
  text-decoration: none;
  font-weight: 900;
  white-space: nowrap;
}

.kb-home-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--kb-teal), var(--kb-coral));
  color: #ffffff;
  font-size: 0.82rem;
}

.kb-icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--kb-line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--kb-ink);
  cursor: pointer;
}

.kb-menu-button span {
  width: 18px;
  height: 2px;
  display: block;
  margin: 2px 0;
  background: currentColor;
  border-radius: 999px;
}

.kb-close-button {
  display: none;
  font-size: 1.2rem;
  font-weight: 900;
}

.kb-search {
  position: relative;
  width: 100%;
  justify-self: end;
}

.kb-search-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.kb-search input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--kb-line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--kb-ink);
  font: 600 0.98rem "Segoe UI", Roboto, Arial, sans-serif;
  padding: 0 15px;
  outline: none;
}

.kb-search input:focus {
  border-color: var(--kb-teal);
  box-shadow: 0 0 0 3px rgba(14, 117, 109, 0.14);
}

.kb-search-results {
  position: absolute;
  inset: calc(100% + 8px) 0 auto 0;
  display: none;
  max-height: min(440px, calc(100vh - 105px));
  overflow: auto;
  border: 1px solid var(--kb-line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--kb-shadow);
  padding: 6px;
}

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

.kb-search-results a,
.kb-search-empty {
  display: block;
  border-radius: 7px;
  padding: 11px 12px;
}

.kb-search-results a {
  color: var(--kb-ink);
  text-decoration: none;
}

.kb-search-results a:hover,
.kb-search-results a:focus {
  background: #edf4f3;
  outline: none;
}

.kb-search-results strong {
  display: block;
  font-size: 0.96rem;
}

.kb-search-results span,
.kb-search-empty {
  color: var(--kb-muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.kb-sidebar {
  position: absolute;
  z-index: 50;
  top: calc(var(--kb-chrome-height) + 22px);
  left: 18px;
  width: calc(var(--kb-sidebar-width) - 36px);
  border: 1px solid rgba(216, 227, 224, 0.96);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.84);
  box-shadow: 0 18px 52px rgba(20, 32, 36, 0.08);
  overflow: visible;
  padding: 16px 14px 18px;
}

.kb-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 6px 12px;
  border-bottom: 1px solid rgba(216, 227, 224, 0.75);
}

.kb-sidebar-title {
  color: var(--kb-ink);
  font-weight: 900;
  font-size: 1.02rem;
}

.kb-sidebar-subtitle {
  margin-top: 3px;
  color: var(--kb-muted);
  font-size: 0.84rem;
}

.kb-sidebar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kb-tree-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(216, 227, 224, 0.95);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--kb-teal);
  cursor: pointer;
  font: 900 1rem "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1;
  padding: 0;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.kb-tree-toggle:hover,
.kb-tree-toggle:focus {
  border-color: rgba(14, 117, 109, 0.4);
  background: #ffffff;
  outline: none;
}

.kb-tree-toggle.is-collapsed {
  color: var(--kb-coral);
}

.kb-tree {
  position: static !important;
  border: 0 !important;
  padding: 10px 0 0 !important;
  max-height: none !important;
  overflow: visible !important;
}

.kb-tree-group {
  margin: 0 0 4px;
}

.kb-tree summary {
  cursor: pointer;
  list-style: none;
  border-radius: 6px;
  color: #314246;
  font-weight: 900;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  padding: 8px 9px;
  text-transform: uppercase;
}

.kb-tree summary::-webkit-details-marker { display: none; }

.kb-tree summary::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 9px 1px 0;
  border-right: 2px solid var(--kb-coral);
  border-bottom: 2px solid var(--kb-coral);
  transform: rotate(-45deg);
  transition: transform 140ms ease;
}

.kb-tree details[open] summary::before { transform: rotate(45deg); }

.kb-tree ul {
  list-style: none;
  margin: 0;
  padding: 0 0 2px 13px;
  border-left: 1px solid rgba(14, 117, 109, 0.18);
}

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

.kb-tree a {
  display: block;
  border-radius: 6px;
  border: 1px solid transparent;
  color: var(--kb-ink) !important;
  text-decoration: none;
  padding: 7px 9px;
}

.kb-tree a:hover {
  background: #edf4f3;
  border-color: var(--kb-line);
}

.kb-tree a[aria-current="page"] {
  background: rgba(14, 117, 109, 0.10);
  border-color: rgba(14, 117, 109, 0.28);
  box-shadow: inset 3px 0 0 var(--kb-teal);
}

.kb-tree a span {
  display: block;
  font-weight: 900;
  font-size: 0.87rem;
  line-height: 1.25;
}

.kb-tree a small {
  display: block;
  margin-top: 2px;
  color: var(--kb-muted);
  font-size: 0.72rem;
  line-height: 1.25;
}

[data-kb-card-list] {
  align-items: stretch;
}

[data-kb-card] {
  transition:
    order 160ms ease,
    transform 180ms ease,
    opacity 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    filter 180ms ease;
}

body.kb-searching [data-kb-card] {
  opacity: 0.5;
  filter: saturate(0.75);
}

body.kb-searching [data-kb-card].kb-card-match {
  opacity: 1;
  filter: none;
  transform: translateY(-8px);
  border-color: rgba(184, 132, 31, 0.62);
  box-shadow: 0 30px 90px rgba(24, 38, 41, 0.18), 0 0 0 3px rgba(184, 132, 31, 0.12);
}

body.kb-searching [data-kb-card].kb-card-best {
  border-color: rgba(14, 117, 109, 0.68);
  box-shadow: 0 34px 96px rgba(14, 117, 109, 0.18), 0 0 0 3px rgba(14, 117, 109, 0.14);
}

.kb-backdrop {
  display: none;
}

@media (min-width: 1040px) {
  body.kb-has-chrome {
    padding-left: var(--kb-sidebar-width);
  }

  body.kb-reading-article {
    padding-left: 0;
  }

  .kb-menu-button {
    visibility: hidden;
  }
}

@media (max-width: 1039px) {
  .kb-topbar {
    grid-template-columns: auto minmax(130px, max-content) minmax(0, 1fr);
    padding: 10px 14px;
  }

  .kb-sidebar {
    position: fixed;
    inset: var(--kb-chrome-height) auto 0 0;
    width: var(--kb-sidebar-width);
    border-radius: 0;
    border-top: 0;
    border-bottom: 0;
    border-left: 0;
    overflow: auto;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: 14px 0 38px rgba(20, 32, 36, 0.18);
    padding: 18px 16px 28px;
  }

  body.kb-menu-open .kb-sidebar {
    transform: translateX(0);
  }

  body.kb-menu-open {
    overflow: hidden;
  }

  body.kb-menu-open .kb-backdrop {
    display: block;
    position: fixed;
    z-index: 45;
    inset: var(--kb-chrome-height) 0 0 0;
    background: rgba(12, 20, 22, 0.36);
  }

  .kb-close-button {
    display: inline-grid;
  }
}

@media (max-width: 700px) {
  :root {
    --kb-chrome-height: 126px;
  }

  .kb-topbar {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .kb-search {
    grid-column: 1 / -1;
  }

  .kb-home-link {
    min-width: 0;
  }

  .kb-home-link span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .kb-sidebar {
    width: min(88vw, 330px);
  }

  body.kb-has-chrome main > nav[aria-label="Page sections"] {
    display: none !important;
  }

  body.kb-has-chrome main,
  body.kb-has-chrome .layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.kb-has-chrome article {
    min-width: 0;
    width: 100%;
  }

  body.kb-has-chrome .entries,
  body.kb-has-chrome .mode-grid,
  body.kb-has-chrome .concept-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .kb-sidebar-head {
    align-items: flex-start;
  }

  .kb-sidebar-actions {
    flex-direction: column-reverse;
    align-items: flex-end;
  }
}

@media (max-width: 420px) {
  .kb-home-mark {
    width: 32px;
    height: 32px;
  }

  .kb-search input {
    font-size: 0.92rem;
  }
}
