.guide-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
  padding: 40px 0 64px;
}

.guide-toc {
  position: sticky;
  top: 76px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

.guide-toc h2 {
  margin: 0 0 12px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.guide-toc ol {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.9rem;
}

.guide-toc a {
  color: var(--muted);
  text-decoration: none;
}

.guide-toc a:hover { color: var(--accent); }

.guide-toc-footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.88rem;
}

.guide-content {
  min-width: 0;
}

.chapter {
  padding-bottom: 48px;
  margin-bottom: 48px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 72px;
}

.chapter:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.chapter-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.chapter-eyebrow {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.chapter h2 {
  margin: 4px 0 0;
  font-size: 1.7rem;
  line-height: 1.25;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--code-bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  text-decoration: none;
}

.tag-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chapter h3 {
  margin: 24px 0 10px;
  font-size: 1.12rem;
}

.chapter p {
  margin: 0 0 14px;
  color: var(--text);
}

.chapter ul {
  margin: 0 0 16px;
  padding-left: 22px;
}

.chapter li {
  margin-bottom: 6px;
}

.code-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin: 18px 0;
}

.code-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin: 16px 0;
}

.code-pair .code-block {
  margin: 0;
}

.code-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--muted);
}

.code-label.before { color: #cf222e; }
.code-label.after { color: #1a7f37; }

[data-theme="dark"] .code-label.before { color: #ff7b72; }
[data-theme="dark"] .code-label.after { color: #3fb950; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .code-label.before { color: #ff7b72; }
  :root:not([data-theme]) .code-label.after { color: #3fb950; }
}

.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.55;
}

.code-block pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

/* GitHub Dark / GitHub Light C# token colors matching dotnet fe doc */
:root,
[data-theme="dark"] {
  --tok-kw: #ff7b72;
  --tok-ty: #79c0ff;
  --tok-str: #a5d6ff;
  --tok-num: #79c0ff;
  --tok-com: #8b949e;
  --tok-attr: #d2a8ff;
}

[data-theme="light"] {
  --tok-kw: #cf222e;
  --tok-ty: #0550ae;
  --tok-str: #0a3069;
  --tok-num: #0550ae;
  --tok-com: #6e7781;
  --tok-attr: #8250df;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --tok-kw: #cf222e;
    --tok-ty: #0550ae;
    --tok-str: #0a3069;
    --tok-num: #0550ae;
    --tok-com: #6e7781;
    --tok-attr: #8250df;
  }
}

.tok-kw { color: var(--tok-kw); }
.tok-ty { color: var(--tok-ty); }
.tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); }
.tok-com { color: var(--tok-com); font-style: italic; }
.tok-attr { color: var(--tok-attr); }

/* Collapsible full-chapter git diff viewer */
.diff-details {
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.diff-details > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 16px;
  cursor: pointer;
  background: var(--bg-alt);
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
  list-style: none;
}

.diff-details > summary::-webkit-details-marker { display: none; }

.diff-details > summary::before {
  content: "▸ ";
  color: var(--accent);
  margin-right: 4px;
}

.diff-details[open] > summary::before {
  content: "▾ ";
}

.diff-details[open] > summary {
  border-bottom: 1px solid var(--border);
}

.diff-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
}

.diff-stat-add { color: #1a7f37; }
.diff-stat-del { color: #cf222e; }
[data-theme="dark"] .diff-stat-add { color: #3fb950; }
[data-theme="dark"] .diff-stat-del { color: #ff7b72; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .diff-stat-add { color: #3fb950; }
  :root:not([data-theme]) .diff-stat-del { color: #ff7b72; }
}

.diff-compare-link {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}

.diff-compare-link:hover { text-decoration: underline; }

.diff-body {
  max-height: 520px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
}

.diff-file-hdr {
  padding: 6px 14px;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text);
}

.diff-file-hdr:first-child { border-top: none; }

.diff-pre {
  margin: 0;
  padding: 8px 0;
}

.diff-line {
  display: block;
  padding: 0 14px;
  white-space: pre;
}

.diff-hunk {
  color: var(--tok-ty);
  background: rgba(56, 139, 253, 0.1);
}

.diff-add {
  color: #1a7f37;
  background: rgba(46, 160, 67, 0.14);
}

.diff-del {
  color: #cf222e;
  background: rgba(248, 81, 73, 0.14);
}

[data-theme="dark"] .diff-add { color: #aff5b4; background: rgba(46, 160, 67, 0.18); }
[data-theme="dark"] .diff-del { color: #ffdcd7; background: rgba(248, 81, 73, 0.18); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .diff-add { color: #aff5b4; background: rgba(46, 160, 67, 0.18); }
  :root:not([data-theme]) .diff-del { color: #ffdcd7; background: rgba(248, 81, 73, 0.18); }
}

.callout {
  margin: 20px 0;
  padding: 16px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  background: var(--bg-alt);
}

.callout-title {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 6px;
  color: var(--accent);
}

.callout.callout-catch {
  border-left-color: #d29922;
}

.callout.callout-catch .callout-title {
  color: #b0790b;
}

[data-theme="dark"] .callout.callout-catch .callout-title {
  color: #e3b341;
}

.callout.callout-win {
  border-left-color: #2da44e;
}

.callout.callout-win .callout-title {
  color: #1a7f37;
}

[data-theme="dark"] .callout.callout-win .callout-title {
  color: #3fb950;
}

.callout p:last-child {
  margin-bottom: 0;
}

.diagram-box {
  margin: 20px 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  text-align: center;
  overflow-x: auto;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 0.92rem;
}

.summary-table th,
.summary-table td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.summary-table th {
  background: var(--bg-alt);
  font-weight: 600;
}

@media (max-width: 860px) {
  .guide-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .guide-toc {
    position: static;
  }
}
