/* Local approximation of GitBook's rendering.
   Close enough to catch structural and syntax problems — not pixel-identical.
   For visual sign-off, push to a GitBook test space. */

:root {
  --gb-text: #1c1e21;
  --gb-muted: #6b7280;
  --gb-border: #e5e7eb;
  --gb-bg: #ffffff;
  --gb-bg-soft: #f9fafb;
  --gb-accent: #346ddb;
  --gb-info-bg: #eef4ff;
  --gb-info-border: #3b74dd;
  --gb-success-bg: #eafaf1;
  --gb-success-border: #12b76a;
  --gb-radius: 8px;
  --gb-sidebar-w: 290px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--gb-bg);
  color: var(--gb-text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Layout ---------- */

.gb-layout { display: flex; min-height: 100vh; align-items: flex-start; }

.gb-sidebar {
  width: var(--gb-sidebar-w);
  flex: 0 0 var(--gb-sidebar-w);
  border-right: 1px solid var(--gb-border);
  padding: 24px 16px 48px;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}

.gb-brand {
  font-weight: 700;
  font-size: 15px;
  padding: 0 12px 16px;
  display: block;
  color: var(--gb-text);
}

.gb-nav { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.gb-nav li { margin: 1px 0; }
.gb-nav a {
  display: block;
  padding: 6px 12px;
  border-radius: 6px;
  color: #374151;
}
.gb-nav a:hover { background: var(--gb-bg-soft); text-decoration: none; }
.gb-nav a.is-active { background: #eef2ff; color: var(--gb-accent); font-weight: 600; }

/* Section headings from `## ...` in SUMMARY.md */
.gb-nav__heading {
  padding: 18px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gb-muted);
}

/* Collapsible parent pages */
.gb-nav__branch > details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.gb-nav__branch > details > summary::-webkit-details-marker { display: none; }
.gb-nav__branch > details > summary::before {
  content: '';
  flex: 0 0 auto;
  width: 0;
  height: 0;
  margin-left: 4px;
  border-left: 4px solid var(--gb-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.12s ease;
}
.gb-nav__branch > details[open] > summary::before { transform: rotate(90deg); }
.gb-nav__branch > details > summary > a { flex: 1 1 auto; font-weight: 600; color: var(--gb-text); }

.gb-nav--sub {
  list-style: none;
  margin: 2px 0 6px;
  padding-left: 14px;
  margin-left: 11px;
  border-left: 1px solid var(--gb-border);
}
.gb-nav--sub a { font-size: 13.5px; padding: 5px 10px; }

.gb-main { flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; padding: 48px 40px 120px; }
.gb-content { width: 100%; max-width: 820px; }

/* ---------- Typography ---------- */

h1, h2, h3, h4, h5, h6 { line-height: 1.3; font-weight: 700; margin: 2em 0 0.6em; }
h1 { font-size: 32px; margin-top: 0; letter-spacing: -0.02em; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
h4 { font-size: 17px; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--gb-border); margin: 2.5em 0; }
code {
  background: var(--gb-bg-soft);
  border: 1px solid var(--gb-border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
blockquote {
  margin: 1.5em 0;
  padding: 2px 18px;
  border-left: 3px solid var(--gb-border);
  color: var(--gb-muted);
}
mark { background: transparent; font-weight: 600; }

/* ---------- Hints ---------- */

.gb-hint {
  border-radius: var(--gb-radius);
  padding: 14px 18px;
  margin: 1.5em 0;
  border-left: 3px solid;
}
.gb-hint > :last-child { margin-bottom: 0; }
.gb-hint--info { background: var(--gb-info-bg); border-left-color: var(--gb-info-border); }
.gb-hint--success { background: var(--gb-success-bg); border-left-color: var(--gb-success-border); }

/* ---------- Stepper ---------- */

.gb-stepper { counter-reset: gb-step; margin: 1.5em 0; }

.gb-step {
  position: relative;
  padding: 0 0 22px 46px;
  border-left: 2px solid var(--gb-border);
  margin-left: 15px;
}
.gb-step:last-child { border-left-color: transparent; padding-bottom: 0; }

.gb-step::before {
  counter-increment: gb-step;
  content: counter(gb-step);
  position: absolute;
  left: -16px;
  top: -2px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gb-accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gb-step__body > :first-child { margin-top: 0; }
.gb-step__body > :last-child { margin-bottom: 0; }

/* ---------- Embeds ---------- */

.gb-embed {
  border: 1px solid var(--gb-border);
  border-radius: var(--gb-radius);
  padding: 16px 18px;
  margin: 1.5em 0;
  background: var(--gb-bg-soft);
  display: flex;
  flex-direction: column;
  gap: 2px;
  word-break: break-all;
}
.gb-embed__note { color: var(--gb-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Images / figures ---------- */

figure { margin: 1.75em 0; }
figure img { max-width: 100%; height: auto; display: block; border-radius: 6px; }
figcaption { color: var(--gb-muted); font-size: 14px; margin-top: 8px; }
figcaption p { margin: 0; }

[data-with-frame="true"] img {
  border: 1px solid var(--gb-border);
  border-radius: var(--gb-radius);
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
}
[data-with-frame="true"][align="left"] figure { margin-left: 0; }

/* ---------- Tables ---------- */

table { border-collapse: collapse; width: 100%; margin: 1.5em 0; font-size: 15px; }
th, td { border: 1px solid var(--gb-border); padding: 8px 12px; text-align: left; vertical-align: top; }
th { background: var(--gb-bg-soft); font-weight: 600; }

/* Card grid — GitBook renders `<table data-view="cards">` as tiles. */
table[data-view="cards"] { border: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
table[data-view="cards"] thead { display: none; }
table[data-view="cards"] tbody { display: contents; }
table[data-view="cards"] tr {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--gb-border);
  border-radius: var(--gb-radius);
  padding: 16px;
  background: var(--gb-bg);
  transition: box-shadow 0.15s ease;
}
table[data-view="cards"] tr:hover { box-shadow: 0 4px 14px rgba(16, 24, 40, 0.08); }
table[data-view="cards"] td { border: 0; padding: 0; }
table[data-view="cards"] td:empty { display: none; }

/* Card title and body */
table[data-view="cards"] td:first-child a { font-weight: 700; font-size: 15px; }
table[data-view="cards"] td:nth-child(2) { color: var(--gb-muted); font-size: 13.5px; line-height: 1.55; }

/* GitBook renders a FontAwesome glyph here; locally the raw `:shortcode:`
   text would just be noise, so it is hidden rather than shown broken. */
table[data-view="cards"] i[class^="fa-"],
table[data-view="cards"] i[class*=" fa-"] { display: none; }

/* ---------- Buttons ---------- */

a.button {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  margin: 4px 6px 4px 0;
}
a.button:hover { text-decoration: none; opacity: 0.9; }
a.button.primary { background: var(--gb-accent); color: #fff; }
a.button.secondary { background: var(--gb-bg-soft); color: var(--gb-text); border: 1px solid var(--gb-border); }

/* ---------- Details ---------- */

details {
  border: 1px solid var(--gb-border);
  border-radius: var(--gb-radius);
  padding: 12px 16px;
  margin: 1.25em 0;
}
summary { cursor: pointer; font-weight: 600; }

/* FontAwesome placeholders: GitBook renders real icons, we just keep them quiet. */
i[class^="fa-"], i[class*=" fa-"] { color: var(--gb-muted); font-style: normal; font-size: 0.9em; }

/* ---------- Preview chrome ---------- */

.gb-banner {
  background: #fffbe6;
  border-bottom: 1px solid #f2e3a2;
  color: #7a5c00;
  font-size: 13px;
  padding: 7px 16px;
  text-align: center;
}

.gb-problems {
  border: 1px solid #f3c7c7;
  background: #fdf2f2;
  border-radius: var(--gb-radius);
  padding: 14px 18px;
  margin: 0 0 2em;
  font-size: 14px;
}
.gb-problems h4 { margin: 0 0 8px; color: #a12a2a; font-size: 14px; }
.gb-problems ul { margin: 0; padding-left: 18px; }
.gb-problems code { background: #fff; }
