:root {
  --background: #ffffff;
  --surface: #f7f7f8;
  --text: #202124;
  --muted: #6b7280;
  --border: #dfe1e5;
  --link: #4f46a5;
  --link-hover: #373083;
  --header-height: 60px;
  --sidebar-width: 240px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  padding: 6px 10px;
  background: var(--text);
  color: white;
  z-index: 10;
}
.skip-link:focus { left: 8px; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  height: var(--header-height);
  background: var(--background);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1600px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { color: var(--text); }
.brand:hover { color: var(--text); text-decoration: none; }
.brand-name { display: flex; flex-direction: column; font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.brand-name small { color: var(--muted); font-size: 0.72rem; font-weight: 400; }
.search-wrap { position: relative; width: min(380px, 100%); margin-left: auto; }
.search-wrap input,
.hero-search input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--background);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}
.search-wrap input:focus,
.hero-search input:focus { border-color: var(--link); outline: 2px solid #e0dff5; }
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 400px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--background);
  border: 1px solid var(--border);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.12);
}
.search-results[hidden] { display: none; }
.search-results li a { display: block; padding: 7px 8px; }
.search-results li a:hover { background: var(--surface); text-decoration: none; }
.search-results .sr-title { color: var(--text); font-weight: 600; }
.search-results .sr-cat { color: var(--muted); font-size: 0.78rem; margin-left: 5px; }
.search-results .sr-excerpt { overflow: hidden; color: var(--muted); font-size: 0.8rem; text-overflow: ellipsis; white-space: nowrap; }
.search-results .empty { padding: 8px; color: var(--muted); font-size: 0.85rem; }

/* Page layout */
.layout {
  max-width: 1600px;
  margin: 0 auto;
  padding: 32px 24px 56px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: calc(var(--header-height) + 24px);
}
.sidebar-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cat-nav ul { list-style: none; margin: 0; padding: 0; }
.cat-nav li { margin: 1px 0; }
.cat-nav a {
  display: block;
  padding: 5px 8px;
  color: var(--text);
  font-size: 0.92rem;
}
.cat-nav a:hover { background: var(--surface); text-decoration: none; }
.cat-nav a.active { color: var(--link); font-weight: 700; }
.sidebar-foot { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.sidebar-link { color: var(--muted); font-size: 0.88rem; }
.main { min-width: 0; }
.article-wrap { min-width: 0; }
.article-wrap.has-toc { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; }
.article { min-width: 0; max-width: 1000px; }

/* Table of contents */
.toc { display: none; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc-title { margin-bottom: 8px; color: var(--muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.toc a { display: block; padding: 3px 0; color: var(--muted); font-size: 0.82rem; line-height: 1.35; }
.toc a:hover { color: var(--link); }
@media (min-width: 1050px) {
  .article-wrap.has-toc .toc { display: block; position: sticky; top: calc(var(--header-height) + 24px); }
}

/* Content */
.breadcrumbs { margin-bottom: 12px; color: var(--muted); font-size: 0.82rem; }
.crumb-sep { padding: 0 6px; color: var(--border); }
.article h1,
.main > .article h1 {
  margin: 0 0 12px;
  font-size: 2rem;
  line-height: 1.2;
}
.article h2 { margin: 36px 0 10px; padding-bottom: 4px; border-bottom: 1px solid var(--border); font-size: 1.35rem; line-height: 1.3; scroll-margin-top: 80px; }
.article h3 { margin: 26px 0 8px; font-size: 1.12rem; scroll-margin-top: 80px; }
.article h4 { margin: 22px 0 8px; font-size: 1rem; scroll-margin-top: 80px; }
.article p { margin: 0 0 16px; }
.article ul,
.article ol { margin: 0 0 16px; padding-left: 25px; }
.article li { margin-bottom: 4px; }
.article a { font-weight: 500; }
.lede { max-width: 65ch; margin: 0 0 12px; color: var(--muted); font-size: 1.05rem; }
.meta { margin: 0 0 24px; color: var(--muted); font-size: 0.84rem; }
.wiki-source { margin-top: 32px; padding-top: 10px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.82rem; }

/* Home */
.home-intro { padding-bottom: 28px; border-bottom: 1px solid var(--border); }
.home-intro h1 { margin: 0 0 12px; font-size: 2.2rem; line-height: 1.2; }
.home-intro .meta { margin-bottom: 20px; }
.hero-search { width: min(440px, 100%); }
.main > section,
.article > section { margin-top: 32px; }
.main > section > h2 { margin: 0 0 12px; padding-bottom: 5px; border-bottom: 1px solid var(--border); font-size: 1.35rem; }
.topic-list { list-style: none; margin: 0; padding: 0; }
.topic-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
}
.topic-row h3 { margin: 0 0 3px; font-size: 1.05rem; }
.topic-row p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.topic-count { flex: 0 0 auto; color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.topic-count:hover { color: var(--link); }
.about-link { margin-top: 28px; font-size: 0.9rem; }

/* Category indexes */
.article-list { list-style: none; margin: 0; padding: 0; }
.article-list li { padding: 13px 0; border-bottom: 1px solid var(--border); }
.article-list li > a { font-size: 1rem; font-weight: 600; }
.article-list li p { margin: 3px 0 0; color: var(--muted); font-size: 0.9rem; }

/* Previous/next links */
.pager { display: flex; justify-content: space-between; gap: 24px; margin-top: 34px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 0.88rem; }
.pager-next { margin-left: auto; text-align: right; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 22px 24px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  color: var(--muted);
  font-size: 0.8rem;
}
.footer-inner p { margin: 0; }

@media (max-width: 900px) {
  .layout { display: block; padding: 24px 20px 48px; }
  .sidebar { position: static; margin-bottom: 28px; }
  .cat-nav ul { display: flex; flex-wrap: wrap; gap: 4px 14px; }
  .cat-nav a { padding: 2px 0; }
  .sidebar-foot { margin-top: 10px; padding-top: 8px; }
  .article-wrap.has-toc { display: block; }
  .toc { display: none !important; }
}

@media (max-width: 560px) {
  .header-inner { padding: 0 16px; }
  .brand-name small { display: none; }
  .search-wrap { max-width: 210px; }
  .topic-row { display: block; }
  .topic-count { display: inline-block; margin-top: 4px; }
  .footer-inner { display: block; padding: 18px 20px; }
  .footer-inner p + p { margin-top: 6px; }
}
