/* Anvil docs — one stylesheet. Brand values come from the marketing site's theme
   (packages/anvil-theme in the anvil monorepo): black #10181B, lime #B4E33D, coral #f45d4a,
   Syne for headings. Light palette on :root, dark palette on [data-theme=dark] and on the
   system preference when the theme is "auto". The lime is used as the dark-mode accent and as
   the highlight colour in light mode; link text in light mode uses a darker green that meets
   contrast on white. */
:root {
  --brand-black: #10181b;
  --brand-lime: #b4e33d;
  --brand-coral: #f45d4a;
  --font-brand: "Syne", system-ui, sans-serif;
  --bg: #ffffff;
  --bg-soft: #f5f7f4;
  --bg-code: #f6f8f5;
  --ink: #10181b;
  --muted: #5b6660;
  --line: #d9ded8;
  --accent: #3f6d00;
  --accent-soft: #eef7d8;
  --info: #2563eb;
  --success: #3f6d00;
  --warning: #d97706;
  --danger: #f45d4a;
  --shadow: 0 8px 24px rgba(16, 24, 27, 0.12);
  --sidebar-w: 272px;
  --outline-w: 220px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #10181b;
  --bg-soft: #172124;
  --bg-code: #0c1215;
  --ink: #e8ecea;
  --muted: #98a39e;
  --line: #27333a;
  --accent: #b4e33d;
  --accent-soft: #1d2a17;
  --success: #b4e33d;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #10181b;
    --bg-soft: #172124;
    --bg-code: #0c1215;
    --ink: #e8ecea;
    --muted: #98a39e;
    --line: #27333a;
    --accent: #b4e33d;
    --accent-soft: #1d2a17;
    --success: #b4e33d;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}
html {
  scroll-padding-top: 72px;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px / 1.65 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
code,
pre,
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
.skip {
  position: absolute;
  left: -999px;
}
.skip:focus {
  left: 8px;
  top: 8px;
  background: var(--bg);
  padding: 8px;
  z-index: 100;
}

/* header */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  white-space: nowrap;
}
.brand svg {
  height: 20px;
  width: auto;
  display: block;
}
.brand:hover {
  color: var(--accent);
}
.menu {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 18px;
  padding: 2px 8px;
}
.links {
  margin-left: auto;
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 14px;
}
.links a {
  color: var(--muted);
}
.theme {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  padding: 2px 8px;
  font-size: 15px;
}
.search {
  position: relative;
  flex: 1;
  max-width: 460px;
}
.search input {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--ink);
  font: inherit;
}
.results {
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 60vh;
  overflow: auto;
  padding: 4px;
}
.results a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--ink);
}
.results a:hover,
.results a.active {
  background: var(--accent-soft);
  text-decoration: none;
}
.results small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.results mark {
  background: none;
  color: var(--accent);
  font-weight: 600;
}
.results .empty {
  padding: 10px;
  color: var(--muted);
}

/* layout */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--outline-w);
  gap: 0 32px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}
.sidebar {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 20px 12px 40px 0;
  border-right: 1px solid var(--line);
  font-size: 14px;
}
.sidebar h3 {
  margin: 20px 0 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidebar section:first-child h3 {
  margin-top: 0;
}
.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar ul ul {
  padding-left: 14px;
  border-left: 1px solid var(--line);
  margin-left: 6px;
}
.sidebar a {
  display: block;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--ink);
}
.sidebar a:hover {
  background: var(--bg-soft);
  text-decoration: none;
}
.sidebar a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.sidebar summary {
  list-style: none;
  cursor: pointer;
  position: relative;
}
.sidebar summary::-webkit-details-marker {
  display: none;
}
.sidebar summary::after {
  content: "›";
  position: absolute;
  right: 8px;
  top: 3px;
  color: var(--muted);
  transition: transform 0.15s;
}
.sidebar details[open] > summary::after {
  transform: rotate(90deg);
}
main {
  min-width: 0;
  padding: 28px 0 80px;
}
article {
  max-width: 860px;
}
.crumb {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.outline {
  position: sticky;
  top: 56px;
  align-self: start;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 24px 0;
  font-size: 13px;
}
.outline h4 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.outline ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line);
}
.outline li a {
  display: block;
  padding: 3px 12px;
  color: var(--muted);
  border-left: 2px solid transparent;
  margin-left: -1px;
}
.outline li.d3 a {
  padding-left: 24px;
}
.outline li a:hover,
.outline li a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  text-decoration: none;
}
.edit {
  display: inline-block;
  margin-top: 32px;
  font-size: 13px;
  color: var(--muted);
}
.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  max-width: 860px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.pager a {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-weight: 600;
}
.pager a.next {
  text-align: right;
}
.pager a:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.pager small {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
}
.foot {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px 32px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
}

/* content */
article h1 {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 2rem;
  line-height: 1.2;
  margin: 0 0 16px;
}
article h2,
article h3 {
  font-family: var(--font-brand);
  font-weight: 600;
}
.sidebar h3,
.outline h4,
.crumb {
  font-family: var(--font-brand);
}
article h2 {
  font-size: 1.4rem;
  margin: 40px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
article h3 {
  font-size: 1.15rem;
  margin: 28px 0 8px;
}
article h4 {
  margin: 20px 0 6px;
}
h1 .anchor,
h2 .anchor,
h3 .anchor,
h4 .anchor {
  margin-left: 8px;
  color: var(--line);
  font-weight: 400;
  opacity: 0;
}
h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor {
  opacity: 1;
}
article p,
article ul,
article ol {
  margin: 0 0 14px;
}
article li + li {
  margin-top: 4px;
}
article img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}
article figure {
  margin: 16px 0;
}
article figcaption {
  color: var(--muted);
  font-size: 13px;
}
article blockquote {
  margin: 16px 0;
  padding: 10px 16px;
  border-left: 4px solid var(--line);
  background: var(--bg-soft);
  border-radius: 0 8px 8px 0;
}
article blockquote p:last-child {
  margin-bottom: 0;
}
article blockquote.note {
  border-left-color: var(--info);
}
article blockquote.warning {
  border-left-color: var(--warning);
}
article blockquote.known-issue {
  border-left-color: var(--danger);
}
article table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}
article th,
article td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
article th {
  background: var(--bg-soft);
}
article :not(pre) > code {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.9em;
}
article details {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
}
article summary {
  cursor: pointer;
  font-weight: 600;
}
article hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 28px 0;
}

/* code blocks (shiki emits --shiki-light / --shiki-dark per token) */
pre.shiki {
  position: relative;
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
  background: var(--bg-code) !important;
}
pre.shiki code {
  display: block;
  white-space: pre;
}
.shiki,
.shiki span {
  color: var(--shiki-light);
}
[data-theme="dark"] .shiki,
[data-theme="dark"] .shiki span {
  color: var(--shiki-dark);
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] .shiki,
  [data-theme="auto"] .shiki span {
    color: var(--shiki-dark);
  }
}
pre.plain code {
  color: var(--ink);
}
/* Diagrams are drawn for a light background, so their panel is light in both themes. */
.diagram {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  text-align: center;
}
.diagram a {
  display: block;
}
.diagram img {
  display: block;
  margin: 0 auto;
  border-radius: 0;
}
.copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font: 12px system-ui, sans-serif;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
pre.shiki:hover .copy,
.copy:focus {
  opacity: 1;
}
.code-block {
  margin: 16px 0;
}
.code-block .code-title {
  display: flex;
  justify-content: space-between;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--bg-soft);
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--muted);
}
.code-block .code-title + pre {
  margin-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* GitBook shims: callouts, cards, tabs */
.callout {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--info);
  border-radius: 0 8px 8px 0;
  background: var(--bg-soft);
}
.callout > :last-child {
  margin-bottom: 0;
}
.callout-success {
  border-left-color: var(--success);
}
.callout-warning {
  border-left-color: var(--warning);
}
.callout-danger {
  border-left-color: var(--danger);
}
.card {
  margin: 12px 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.card p {
  margin: 0;
}
.card a {
  font-weight: 600;
}
.card a::after {
  content: " →";
}
.tabs {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.tabs .tab-bar {
  display: flex;
  gap: 4px;
  padding: 6px 8px 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 8px 8px 0 0;
  overflow-x: auto;
}
.tabs .tab-bar button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 6px 10px;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.tabs .tab-bar button[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tabs section.tab {
  padding: 12px 16px;
}
.tabs section.tab[hidden] {
  display: none;
}
.tabs .tab-title {
  font-weight: 600;
  margin: 0 0 8px;
}

/* responsive */
@media (max-width: 1100px) {
  .shell {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }
  .outline {
    display: none;
  }
}
@media (max-width: 800px) {
  .menu {
    display: inline-block;
  }
  .search {
    max-width: none;
  }
  .links a {
    display: none;
  }
  .shell {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 16px;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 56px;
    width: min(320px, 85vw);
    background: var(--bg);
    border-right: 1px solid var(--line);
    padding: 16px;
    transform: translateX(-100%);
    transition: transform 0.2s;
    z-index: 15;
    box-shadow: var(--shadow);
  }
  .sidebar.open {
    transform: none;
  }
}
