:root {
  --ink: #1a1612;
  --muted: #6b6258;
  --paper: #f3ead6;
  --rule: #d7c9a8;
  --board: #3f4a3c;
  --board-dark: #2c342b;
  --pen: #c41e3a;
  --highlighter: #f0d35a;
  --code-bg: #1e2a24;
  --code-fg: #d6ead0;
  --code-muted: #8aa890;
  --focus: #e07a2f;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-padding-top: 1.5rem;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 0%, #4a5646 0%, transparent 50%),
    linear-gradient(160deg, var(--board) 0%, var(--board-dark) 70%);
  font-family: Figtree, ui-sans-serif, system-ui, sans-serif;
  line-height: 1.5;
}

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

.desk {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.rail {
  color: #e8ecdf;
  padding: 0.25rem 0.25rem 1rem;
  position: sticky;
  top: 2rem;
  align-self: start;
  max-height: calc(100dvh - 3rem);
  overflow: auto;
  overscroll-behavior: contain;
}

.stamp {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.15rem 0.45rem;
  border: 2px solid #e07a2f;
  color: #e07a2f;
  font-family: Oxanium, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transform: rotate(-6deg);
}

.rail h1 {
  margin: 0 0 0.35rem;
  font-family: Oxanium, sans-serif;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0 0 1.25rem;
  color: #c5cbb8;
  font-size: 0.95rem;
}

.search-wrap input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid #6a7564;
  border-radius: 2px;
  background: #2c342b;
  color: #e8ecdf;
  font: inherit;
}

.search-wrap input:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.search-wrap input::placeholder {
  color: #9aa392;
}

#toc {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#toc a {
  color: #dce3d2;
  text-decoration: none;
  font-size: 0.92rem;
  border-left: 2px solid transparent;
  padding-left: 0.55rem;
}

#toc a:hover,
#toc a:focus-visible {
  border-left-color: var(--highlighter);
  color: #fff;
}

#toc a[aria-current="page"] {
  border-left-color: var(--highlighter);
  color: #fff;
  font-weight: 600;
  background: linear-gradient(90deg, rgba(240, 211, 90, 0.22), transparent 72%);
}

.empty-nav {
  margin: 0;
  color: #9aa392;
  font-size: 0.85rem;
}

.sheet {
  position: relative;
  background:
    repeating-linear-gradient(
      transparent,
      transparent 27px,
      var(--rule) 28px
    ),
    var(--paper);
  background-attachment: local;
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 18px 40px rgba(0, 0, 0, 0.28);
  padding: 2.25rem 1.75rem 2.5rem;
  min-height: 70vh;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed #c4b38a;
  background: var(--paper);
}

.clip {
  position: absolute;
  top: -12px;
  left: 50%;
  width: 72px;
  height: 22px;
  margin-left: -36px;
  background: linear-gradient(#9aa3a0, #6d7572);
  border-radius: 3px 3px 6px 6px;
  box-shadow: 0 4px 0 #4a504e;
}

.eyebrow {
  margin: 0;
  font-family: IBM Plex Mono, ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.sheet-head h2 {
  margin: 0.15rem 0 0;
  font-family: Oxanium, sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
}

.count {
  margin: 0;
  font-family: IBM Plex Mono, ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.mark {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.35rem;
  vertical-align: -1px;
}

.mark.rule {
  background: var(--ink);
}

.mark.snip {
  background: var(--code-bg);
}

.mark.gotcha {
  background: var(--pen);
  transform: rotate(12deg);
}

.mark.when {
  background: var(--highlighter);
}

.empty-card {
  padding: 2rem 0.25rem;
}

.cursor-line {
  margin: 0 0 0.6rem;
  font-family: IBM Plex Mono, ui-monospace, monospace;
  font-size: 1rem;
  color: var(--ink);
}

.blink {
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.topic {
  margin: 0 0 1.75rem;
  padding: 0 0 1.25rem;
  border-bottom: 1px dashed #c4b38a;
  scroll-margin-top: 1.5rem;
}

.topic h3 {
  margin: 0 0 0.75rem;
  font-family: Oxanium, sans-serif;
  font-size: 1.15rem;
}

.topic .subhead {
  margin: 1.35rem 0 0.35rem;
  font-family: Oxanium, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.pick-list {
  margin: 0.5rem 0 1rem;
  padding: 0;
  list-style: none;
}

.pick-list li {
  position: relative;
  margin: 0.35rem 0;
  padding-left: 1.1rem;
  font-size: 0.95rem;
}

.pick-list li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: #e07a2f;
  font-family: IBM Plex Mono, ui-monospace, monospace;
  font-size: 0.8rem;
}

.table-wrap {
  margin: 0.55rem 0 1rem;
  overflow-x: auto;
}

.crib-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.crib-table th,
.crib-table td {
  padding: 0.4rem 0.55rem 0.4rem 0;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px dashed #c4b38a;
}

.crib-table th {
  font-family: IBM Plex Mono, ui-monospace, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.crib-table td:first-child {
  font-family: IBM Plex Mono, ui-monospace, monospace;
  font-size: 0.82rem;
  white-space: nowrap;
  color: #1e2a24;
}

.block {
  margin: 0.65rem 0;
}

.block .label {
  display: inline-block;
  font-family: IBM Plex Mono, ui-monospace, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
  color: var(--muted);
}

.block.gotcha {
  background: linear-gradient(transparent, transparent) padding-box;
  box-shadow: inset 0 -0.35em 0 var(--highlighter);
  padding: 0.15rem 0.15rem 0.1rem;
}

.block.gotcha .label {
  color: var(--pen);
  font-weight: 500;
}

.block.gotcha p {
  text-decoration: underline;
  text-decoration-color: var(--pen);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.block p {
  margin: 0.15rem 0 0;
}

pre.code-block,
pre.code-block code {
  margin: 0;
  white-space: pre;
  tab-size: 2;
  -moz-tab-size: 2;
  font-variant-ligatures: none;
}

pre.code-block {
  margin: 0.35rem 0 0;
  padding: 0.9rem 1rem 1rem;
  overflow-x: auto;
  background: var(--code-bg);
  color: var(--code-fg);
  font-family: IBM Plex Mono, ui-monospace, monospace;
  font-size: 0.84rem;
  line-height: 1.55;
  border-left: 3px solid #e07a2f;
}

pre.code-block code {
  display: block;
  min-width: max-content;
  background: none;
  font: inherit;
  color: inherit;
}

.snip-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.snip-bar .lang {
  font-family: IBM Plex Mono, ui-monospace, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e07a2f;
}

.tok-kw { color: #e07a2f; font-weight: 500; }
.tok-fn { color: #8fd0c0; }
.tok-str { color: #f0d35a; }
.tok-num { color: #e8b48a; }
.tok-cmt { color: var(--code-muted); font-style: italic; }
.tok-op { color: #b7c4b0; }
.tok-id { color: var(--code-fg); }

.hidden {
  display: none !important;
}

.topbar {
  display: none;
}

.menu-btn {
  display: none;
}

.scrim {
  display: none;
}

@media (max-width: 760px) {
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 45;
    height: 3.5rem;
    padding: 0 0.65rem 0 0.9rem;
    background: var(--board-dark);
    border-bottom: 1px solid #6a7564;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: #e8ecdf;
    text-decoration: none;
    font-family: Oxanium, sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  .brand img {
    display: block;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 5px;
  }

  .desk {
    grid-template-columns: 1fr;
    padding: 4.75rem 0.75rem 2rem;
  }

  .menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 0;
    border-radius: 2px;
    background: transparent;
    color: #e8ecdf;
    cursor: pointer;
  }

  .burger {
    position: relative;
    display: block;
    width: 1.15rem;
    height: 0.85rem;
  }

  .burger span,
  .burger::before,
  .burger::after {
    position: absolute;
    left: 0;
    display: block;
    width: 100%;
    height: 2px;
    background: #e8ecdf;
    content: "";
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  .burger::before { top: 0; }
  .burger span { top: 50%; margin-top: -1px; }
  .burger::after { bottom: 0; }

  body.nav-open .burger span {
    opacity: 0;
  }

  body.nav-open .burger::before {
    top: 50%;
    transform: translateY(-1px) rotate(45deg);
  }

  body.nav-open .burger::after {
    bottom: 50%;
    transform: translateY(1px) rotate(-45deg);
  }

  .scrim {
    display: block;
    position: fixed;
    top: 3.5rem;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 25;
    background: rgba(18, 22, 16, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.nav-open .scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .rail {
    position: fixed;
    top: 3.5rem;
    left: 0;
    bottom: 0;
    z-index: 30;
    width: min(19.5rem, 86vw);
    max-height: none;
    margin: 0;
    padding: 1.15rem 1.1rem 1.5rem;
    background: linear-gradient(160deg, var(--board) 0%, var(--board-dark) 70%);
    box-shadow: 12px 0 32px rgba(0, 0, 0, 0.28);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overscroll-behavior: contain;
  }

  body.nav-open .rail {
    transform: translateX(0);
  }

  .sheet {
    padding: 2rem 1.1rem 1.75rem;
  }

  .clip {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .blink {
    animation: none;
  }

  .rail,
  .scrim,
  .burger span,
  .burger::before,
  .burger::after {
    transition: none;
  }
}

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