:root {
  color-scheme: dark;
  --bg: #0c0e12;
  --surface: #13161c;
  --surface-strong: #181c23;
  --ink: #f2f4f3;
  --muted: #979da5;
  --line: #2b3038;
  --accent: #72e0b4;
  --accent-soft: #17392e;
  --max-width: 1240px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  color: inherit;
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 50;
  padding: 8px 12px;
  color: #07100c;
  background: var(--accent);
  transform: translateY(-160%);
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.kb-header,
main,
footer {
  width: min(calc(100% - 48px), var(--max-width));
  margin-inline: auto;
}

.kb-header {
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.18em;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid #424852;
  border-radius: 50%;
  letter-spacing: 0;
}

.kb-header nav {
  display: flex;
  gap: 28px;
  color: var(--muted);
  font-size: 0.8rem;
}

.kb-header nav a:hover {
  color: var(--ink);
}

.kb-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.7fr);
  gap: 72px;
  align-items: end;
  padding: 88px 0 72px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 0;
  font-size: clamp(3.4rem, 7vw, 7rem);
  font-weight: 520;
  line-height: 0.92;
}

.intro-copy {
  color: var(--muted);
  font-size: 1.05rem;
}

.sync-state {
  margin: 28px 0 0;
  color: #c7ccd1;
  font-size: 0.78rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-block: 1px solid var(--line);
}

.stats div {
  display: grid;
  padding: 28px 24px;
  gap: 5px;
  border-right: 1px solid var(--line);
}

.stats div:last-child {
  border-right: 0;
}

.stats strong {
  font-size: 2rem;
  font-weight: 560;
}

.stats span {
  color: var(--muted);
  font-size: 0.75rem;
}

.insights,
.library {
  padding: 96px 0;
  border-bottom: 1px solid var(--line);
}

.section-heading,
.library-heading {
  display: flex;
  gap: 36px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 42px;
}

.section-heading h2,
.library-heading h2 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  font-weight: 520;
  line-height: 1.05;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.insight-grid article {
  min-height: 220px;
  padding: 28px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.insight-grid article > span {
  color: var(--accent);
  font-size: 0.7rem;
}

.insight-grid h3 {
  margin: 44px 0 10px;
  font-size: 1.25rem;
  font-weight: 560;
}

.insight-grid p {
  max-width: 500px;
  margin-bottom: 0;
  color: var(--muted);
}

.text-link {
  color: var(--accent);
  font-size: 0.82rem;
}

.controls {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(0, 1.5fr);
  gap: 20px;
  align-items: start;
  padding: 22px 0;
  border-block: 1px solid var(--line);
}

.search-control {
  display: flex;
  min-height: 46px;
  gap: 12px;
  align-items: center;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.search-control input {
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  outline: 0;
}

.search-control input::placeholder {
  color: #747b84;
}

.topic-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.topic-filters button,
.result-meta button {
  min-height: 38px;
  padding: 0 12px;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.75rem;
}

.topic-filters button[aria-pressed="true"],
.result-meta button[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: #2d7058;
}

.result-meta {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
}

.post-list {
  border-top: 1px solid var(--line);
}

.post-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 30px;
  gap: 18px;
  align-items: center;
  min-height: 112px;
  padding: 22px 8px;
  border-bottom: 1px solid var(--line);
}

.post-item:hover {
  background: var(--surface);
}

.post-index {
  color: #646b74;
  font-variant-numeric: tabular-nums;
}

.post-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 0.72rem;
}

.topic {
  padding: 3px 7px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
}

.post-item h3 {
  margin: 9px 0 0;
  font-size: clamp(1rem, 2vw, 1.3rem);
  font-weight: 520;
}

.post-item h3 a:hover {
  color: var(--accent);
}

.post-arrow {
  color: var(--muted);
}

.empty-state {
  padding: 60px 0;
  color: var(--muted);
  text-align: center;
}

footer {
  display: flex;
  min-height: 100px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.75rem;
}

footer p {
  margin-bottom: 0;
}

@media (max-width: 760px) {
  .kb-header,
  main,
  footer {
    width: min(calc(100% - 30px), var(--max-width));
  }

  .kb-header nav {
    gap: 14px;
  }

  .kb-header nav a:not(:last-child) {
    display: none;
  }

  .kb-intro {
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 64px 0 52px;
  }

  h1 {
    font-size: clamp(3rem, 15vw, 4.8rem);
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats div:nth-child(2) {
    border-right: 0;
  }

  .stats div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .insights,
  .library {
    padding: 72px 0;
  }

  .section-heading,
  .library-heading {
    align-items: start;
    flex-direction: column;
  }

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

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

  .post-item {
    grid-template-columns: 34px minmax(0, 1fr) 20px;
    gap: 10px;
    min-height: 104px;
  }

  .post-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
