:root {
  color-scheme: light;
  --ink: #191919;
  --muted: #66707a;
  --page: #eef0f3;
  --surface: #ffffff;
  --surface-alt: #f7f8fa;
  --line: #d9dde3;
  --line-strong: #b8c0ca;
  --charcoal: #15171b;
  --charcoal-2: #20242a;
  --charcoal-3: #2c3138;
  --red: #c53131;
  --red-dark: #8f1f1f;
  --red-deep: #5f1515;
  --gold: #d7ad4c;
  --link: #1e5c8f;
  --shadow: 0 16px 42px rgba(14, 18, 24, 0.16);
  --sharp-shadow: 0 3px 0 rgba(0, 0, 0, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(21, 23, 27, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 23, 27, 0.035) 1px, transparent 1px),
    radial-gradient(circle at top, rgba(197, 49, 49, 0.14), transparent 22rem),
    var(--page);
  background-size: 28px 28px, 28px 28px, auto, auto;
  min-height: 100vh;
}

a {
  color: var(--link);
  font-weight: 650;
  text-decoration-color: rgba(30, 92, 143, 0.3);
  text-underline-offset: 0.18em;
}

a:hover { color: var(--red-dark); text-decoration-color: currentColor; }

.skip-link {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  transform: translateY(-200%);
  z-index: 10;
  background: var(--red);
  color: white;
  padding: 0.65rem 0.9rem;
  border-radius: 0.25rem;
  box-shadow: var(--sharp-shadow);
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem clamp(1rem, 2.4vw, 2rem);
  background:
    linear-gradient(180deg, #24282f, #15171b),
    var(--charcoal);
  color: white;
  border-bottom: 4px solid var(--red);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: white;
  text-decoration: none;
  min-width: max-content;
}

.brand strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.brand small {
  display: block;
  color: #cbd0d7;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.site-logo {
  width: 3.2rem;
  height: 3.2rem;
  flex: 0 0 auto;
  background: #101216;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 0.45rem;
  filter: drop-shadow(0 5px 12px rgba(0, 0, 0, 0.35));
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.top-nav a {
  color: #f5f6f7;
  text-decoration: none;
  border-radius: 0.25rem;
  padding: 0.48rem 0.72rem;
  font-size: 0.87rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.top-nav a:hover {
  background: var(--red);
  color: #fff;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(15rem, 19rem) minmax(0, 1fr) minmax(13rem, 17rem);
  gap: clamp(1rem, 2vw, 1.6rem);
  width: min(100%, 1540px);
  margin: 0 auto;
  padding: clamp(1rem, 2.5vw, 2rem);
}

.sidebar, .right-rail {
  align-self: start;
  position: sticky;
  top: 5.8rem;
  max-height: calc(100vh - 7rem);
  overflow: auto;
}

.sidebar {
  background: var(--charcoal-2);
  border: 1px solid #343943;
  border-top: 4px solid var(--red);
  border-radius: 0.35rem;
  box-shadow: var(--shadow);
  color: #eef1f4;
  padding: 0.9rem;
}

.toc, .page-meta, .wiki-page {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  box-shadow: var(--shadow);
}

.wiki-page {
  padding: clamp(1.25rem, 3vw, 3rem);
  border-top: 5px solid var(--red);
}

.toc, .page-meta { padding: 1rem; }

.search label {
  display: block;
  color: #f4f6f8;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin-bottom: 0.45rem;
  text-transform: uppercase;
}

.search input {
  width: 100%;
  border: 1px solid #4b515c;
  border-radius: 0.25rem;
  padding: 0.68rem 0.75rem;
  background: #111318;
  color: #fff;
  outline: none;
}

.search input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(197, 49, 49, 0.3);
}

.nav-group {
  margin-top: 0.65rem;
  border-top: 1px solid #3a404a;
  padding-top: 0.65rem;
}

.nav-group summary {
  cursor: pointer;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-group summary span {
  color: #c3c8cf;
  font-weight: 800;
}

.nav-group ul { list-style: none; padding: 0; margin: 0.55rem 0 0; }
.nav-group li { margin: 0.18rem 0; }

.nav-group a {
  display: block;
  border-left: 3px solid transparent;
  border-radius: 0.2rem;
  color: #dce1e7;
  font-weight: 650;
  padding: 0.38rem 0.45rem;
  text-decoration: none;
}

.nav-group a:hover {
  background: #303640;
  border-left-color: var(--red);
  color: #fff;
}

.page-title {
  position: relative;
  margin: -0.2rem 0 1.7rem;
  padding: 0 0 1.15rem;
  border-bottom: 1px solid var(--line);
}

.page-title::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 7.5rem;
  height: 4px;
  background: linear-gradient(90deg, var(--red), var(--red-deep));
}

.eyebrow {
  color: var(--red);
  font-weight: 950;
  letter-spacing: 0.16em;
  margin: 0 0 0.45rem;
  text-transform: uppercase;
  font-size: 0.76rem;
}

.wiki-page h1, .wiki-page h2, .wiki-page h3, .toc h2, .page-meta h2 {
  color: #16191d;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.1;
}

.wiki-page h1 {
  font-size: clamp(2.1rem, 5vw, 4rem);
  margin: 0;
}

.wiki-page h2 {
  border-bottom: 1px solid var(--line);
  font-size: clamp(1.45rem, 3vw, 1.95rem);
  margin-top: 2rem;
  padding-bottom: 0.35rem;
}

.wiki-page h3 {
  color: var(--red-dark);
  font-size: 1.22rem;
  margin-top: 1.6rem;
}

.wiki-page p, .wiki-page li { line-height: 1.72; }
.wiki-page img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 0.3rem; }
.wiki-page li + li { margin-top: 0.26rem; }

.wiki-page blockquote {
  margin: 1.5rem 0;
  padding: 0.9rem 1rem;
  border-left: 0.35rem solid var(--red);
  background: #f3f4f6;
  color: #303640;
}

.wiki-page table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
}

.wiki-page th {
  background: var(--charcoal-2);
  color: white;
  text-align: left;
}

.wiki-page th, .wiki-page td {
  border: 1px solid var(--line);
  padding: 0.65rem 0.75rem;
}

.wiki-page tr:nth-child(even) td { background: var(--surface-alt); }

.wiki-page code, .page-meta code {
  background: #eef0f3;
  border: 1px solid #d9dde3;
  border-radius: 0.22rem;
  color: #941f1f;
  padding: 0.1rem 0.3rem;
}

.wiki-page pre, .diff-stat, .diff pre {
  overflow: auto;
  border-radius: 0.3rem;
  border: 1px solid #2d333b;
  background: #15191f;
  color: #f2f5f8;
  padding: 1rem;
}

.toc { margin-bottom: 1rem; border-top: 4px solid var(--red); }
.toc h2, .page-meta h2 { margin: 0 0 0.75rem; font-size: 1.05rem; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0.45rem 0; }
.toc a { font-weight: 750; text-decoration: none; }
.toc-level-3 { padding-left: 0.85rem; font-size: 0.92rem; }

.page-meta { border-top: 4px solid var(--charcoal-2); }
.page-meta dl { margin: 0; }
.page-meta dt {
  color: var(--red-dark);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.page-meta dd { margin: 0 0 0.8rem; overflow-wrap: anywhere; }

.lede { font-size: 1.1rem; color: #38424c; }
.commit-list { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.commit-card { margin: 0 0 1rem; }
.commit-card article {
  border: 1px solid var(--line);
  border-left: 5px solid var(--red);
  border-radius: 0.35rem;
  background: var(--surface-alt);
  padding: 1rem;
}
.commit-card h2 { font-size: 1.22rem; margin: 0 0 0.3rem; }
.commit-card header p { margin: 0 0 0.75rem; color: var(--muted); }
.diff summary { cursor: pointer; font-weight: 900; margin-top: 0.8rem; color: var(--red-dark); }

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.35rem clamp(1rem, 2.4vw, 2rem);
  background: #101216;
  color: #dce1e7;
  border-top: 4px solid var(--red);
}

.site-footer p { margin: 0; }

@media (max-width: 1100px) {
  .page-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .right-rail { position: static; max-height: none; }
  .right-rail { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }
}

@media (max-width: 720px) {
  .site-header { align-items: flex-start; flex-direction: column; position: static; }
  .top-nav { justify-content: flex-start; }
  .top-nav a { background: #2a2f37; }
  .wiki-page { border-radius: 0.25rem; }
}
