:root {
  --bg: #fbfbfa;
  --fg: #1d2125;
  --muted: #5d6670;
  --rule: #dcdfe3;
  --accent: #1a5fb4;
  --code-bg: #f0f1f3;
  --note-bg: #eef4fb;
  --note-rule: #8fb4e3;
  --warn-bg: #fdf3e6;
  --warn-rule: #e0a458;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b;
    --fg: #e3e6ea;
    --muted: #9aa3ad;
    --rule: #2f343a;
    --accent: #7fb2f0;
    --code-bg: #20242a;
    --note-bg: #1b2736;
    --note-rule: #3c6196;
    --warn-bg: #2d2518;
    --warn-rule: #a8742a;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent); }

.layout {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  min-height: 100vh;
}

nav.side {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  padding: 1.25rem 1rem 2rem 1.25rem;
  border-right: 1px solid var(--rule);
  font-size: 0.9rem;
}

nav.side .brand {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--fg);
  text-decoration: none;
  margin-bottom: 0.25rem;
}

nav.side .switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

nav.side .switch a {
  flex: 1 1 40%;
  text-align: center;
  padding: 0.25rem 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  text-decoration: none;
  color: var(--fg);
}

nav.side .switch a.here {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

nav.side ol, nav.side ul { list-style: none; margin: 0; padding: 0; }
nav.side li { margin: 0.15rem 0; }
nav.side ul ul { padding-left: 0.9rem; }
nav.side a { text-decoration: none; }
nav.side a:hover { text-decoration: underline; }

main {
  max-width: 52rem;
  padding: 2rem 2rem 6rem;
}

h1 { font-size: 2.1rem; line-height: 1.2; margin: 0 0 0.5rem; }
h2 { font-size: 1.55rem; margin: 3rem 0 0.75rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
h3 { font-size: 1.2rem; margin: 2rem 0 0.5rem; }
h4 { font-size: 1rem; margin: 1.5rem 0 0.4rem; }

p.lead { font-size: 1.15rem; color: var(--muted); margin-top: 0; }

code, pre, kbd { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.88em; }
code { background: var(--code-bg); padding: 0.1em 0.3em; border-radius: 3px; }

pre {
  background: var(--code-bg);
  padding: 0.85rem 1rem;
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.45;
}
pre code { background: none; padding: 0; }

pre[data-title]::before {
  content: attr(data-title);
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: 0.93rem;
}
th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--rule);
}
th { font-weight: 600; background: var(--code-bg); }
td code { white-space: nowrap; }
td.wrap code { white-space: normal; }

.note, .warn {
  padding: 0.7rem 1rem;
  margin: 1.25rem 0;
  border-left: 4px solid var(--note-rule);
  background: var(--note-bg);
  border-radius: 0 6px 6px 0;
}
.warn { border-left-color: var(--warn-rule); background: var(--warn-bg); }
.note > :first-child, .warn > :first-child { margin-top: 0; }
.note > :last-child, .warn > :last-child { margin-bottom: 0; }

.pager {
  display: flex;
  justify-content: space-between;
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin: 2rem 0; }
.card {
  display: block;
  padding: 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  text-decoration: none;
  color: var(--fg);
}
.card:hover { border-color: var(--accent); }
.card h2 { margin: 0 0 0.5rem; padding: 0; border: 0; font-size: 1.3rem; color: var(--accent); }
.card p { margin: 0; color: var(--muted); }

dl.keys dt { font-weight: 600; margin-top: 1rem; }
dl.keys dd { margin: 0.2rem 0 0 1.25rem; }

[hidden] { display: none !important; }

nav.side .patches a {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
nav.side .patches a.here { font-weight: 700; }

.review-tabs { display: flex; gap: 0.5rem; align-items: center; margin: 1rem 0; }
.review-tabs a:not(.rawlink) {
  padding: 0.2rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  text-decoration: none;
  color: var(--fg);
}
.review-tabs a.here { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.review-tabs .rawlink { margin-left: auto; font-size: 0.9rem; }

pre.review-raw { font-size: 0.8rem; line-height: 1.4; white-space: pre; }

.rc {
  position: relative;
  padding: 0.4rem 2.4rem 0.4rem 1rem;
  margin: 0.9rem 0;
  border-left: 4px solid var(--note-rule);
  background: var(--note-bg);
  border-radius: 0 6px 6px 0;
}
.rc:has(> a.anchor:target) { outline: 2px solid var(--accent); outline-offset: 2px; }
.rc .pilcrow {
  position: absolute;
  top: 0.3rem;
  right: 0.7rem;
  color: var(--muted);
  opacity: 0.75;
  text-decoration: none;
  font-size: 1.25rem;
  line-height: 1.2;
}
.rc:hover .pilcrow, .rc .pilcrow:focus { opacity: 1; color: var(--accent); }
.rc .copied {
  position: absolute;
  top: 1.9rem;
  right: 0.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--fg);
  color: var(--bg);
  font-size: 0.8rem;
  white-space: nowrap;
  pointer-events: none;
}
.rc p { margin: 0.6rem 0; }
.rc ul, .rc ol { margin: 0.6rem 0; padding-left: 1.6rem; }
.rc li { margin: 0.25rem 0; }
.rc p.list { white-space: pre-wrap; }
.rc pre { background: none; padding: 0; margin: 0.6rem 0; }

blockquote.q {
  margin: 0.75rem 0;
  padding-left: 0.8rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}
blockquote.q pre { background: none; padding: 0; margin: 0; white-space: pre-wrap; }

/* Diffs are black on white in both colour schemes. */
.diff {
  background: #fff;
  color: #000;
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.75rem 0;
  font: 0.82rem/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.diff-in { display: inline-block; min-width: 100%; }
.diff .l { white-space: pre; padding: 0 0.6rem; }
.diff .sg { display: inline-block; width: 1.2ch; user-select: none; }
.diff .add { background: #e6ffec; }
.diff .del { background: #ffebe9; }
.diff .add .ch { background: #96e6a8; }
.diff .del .ch { background: #ffaaa3; }
.diff .hunk, .diff .file, .diff .meta { background: #eef1f4; color: #57606a; }
.diff .file { font-weight: 600; }
.diff .hunk { color: #0550ae; }
.diff .snip {
  display: flex;
  gap: 0.75rem;
  padding: 0 0.6rem;
  border-top: 1px solid #d0d7de;
  border-bottom: 1px solid #d0d7de;
  background: #f6f8fa;
  color: #57606a;
}
.diff .snip button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
}
.diff .snip button:hover { text-decoration: underline; }

ol.reviews { padding-left: 0; list-style: none; }
ol.reviews li { margin: 0.3rem 0; }

main.wide { max-width: none; }
p.xlink { margin: 0.25rem 0 1rem; }

.walk .woverview { font-size: 1.05rem; }
.walk .wtoc { margin: 1.5rem 0; }
.walk .wtoc ul { columns: 2; padding-left: 1.2rem; }
.walk .wtoc .count { color: var(--muted); font-size: 0.85rem; }
.walk-file h2 { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.2rem; }
.walk-file .wpurpose { color: var(--muted); max-width: 60rem; }
.walk-unit {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(16rem, 2fr);
  gap: 1.25rem;
  align-items: start;
  margin: 1rem 0;
}
.walk-unit .diff { margin: 0; max-height: 36rem; overflow: auto; }
.walk-unit .wnote {
  position: sticky;
  top: 1rem;
  padding: 0.6rem 1rem;
  border-left: 4px solid var(--note-rule);
  background: var(--note-bg);
  border-radius: 0 6px 6px 0;
  font-size: 0.93rem;
}
.walk-unit .wnote h4 { margin: 0 0 0.3rem; font-size: 1rem; word-break: break-word; }
.walk-unit .wnote h4 a { color: inherit; text-decoration: none; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.walk-unit .wnote .kind {
  margin-left: 0.5rem;
  padding: 0 0.4rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: system-ui, sans-serif;
}
.walk-unit .wnote p { margin: 0.4rem 0; }
.walk-unit .wnote p.wsum { font-weight: 600; }
.walk-unit .wnote ul { margin: 0.4rem 0; padding-left: 1.2rem; }

@media (max-width: 52rem) {
  .walk-unit { grid-template-columns: 1fr; }
  .walk-unit .wnote { position: static; }
  .walk .wtoc ul { columns: 1; }
}

@media (max-width: 52rem) {
  .layout { grid-template-columns: 1fr; }
  nav.side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--rule); }
  .cards { grid-template-columns: 1fr; }
  main { padding: 1.25rem 1rem 4rem; }
}
