/* Lloyal docs.

   One stylesheet, written against tokens. Dark is the default and matches
   lloyal.ai (public/styles.css there); light is the blog's article palette
   (public/blog/assets/lloyal-docs.css). A colour belongs in a token, never in
   a rule — that is what lets one set of rules serve both themes. */

@font-face {
  font-family: 'Readex Pro Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('https://cdn.jsdelivr.net/fontsource/fonts/readex-pro:vf@5.3.0/latin-wght-normal.woff2') format('woff2-variations');
}

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080808;
  --panel: #0b0b0b;
  --panel-2: #111110;
  --ink: #f2f1ed;
  --body: #d2cfc9;
  --muted: #aaa7a1;
  --faint: #77746e;
  --line: #2a2927;
  --line-soft: #1b1b1a;
  --link: #e6e3dc;
  --link-line: #55524d;
  --link-hover: #fff;
  --inline-code-bg: #1a1a19;
  --inline-code-ink: #ece9e2;
  --bar-bg: rgba(8, 8, 8, .78);
  --bar-bg-solid: rgba(8, 8, 8, .97);
  --current: #fff;
  --pill-current-bg: #f2f1ed;
  --pill-current-ink: #080808;
  --pill-planned-bg: transparent;
  --pill-planned-ink: #aaa7a1;
  --selection-bg: #f2f1ed;
  --selection-ink: #080808;
  --grid: rgba(255, 255, 255, .022);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fff;
  --panel: #f6f6f6;
  --panel-2: #efefef;
  --ink: #111;
  --body: #333;
  --muted: #666;
  --faint: #777;
  --line: #d3d3d3;
  --line-soft: #e9e9e9;
  --link: #111;
  --link-line: #aaa;
  --link-hover: #000;
  --inline-code-bg: #efefef;
  --inline-code-ink: #111;
  --bar-bg: rgba(255, 255, 255, .82);
  --bar-bg-solid: rgba(255, 255, 255, .98);
  --current: #111;
  --pill-current-bg: #111;
  --pill-current-ink: #fff;
  --pill-planned-bg: #ececec;
  --pill-planned-ink: #555;
  --selection-bg: #111;
  --selection-ink: #fff;
  --grid: transparent;
}
:root {
  /* Code frames are dark in both themes, as they are across lloyal.ai. */
  --code-bg: #070707;
  --code-head: #0d0d0c;
  --code-line: #242422;
  --code-label: #96938d;
  --shiki-background: transparent;
  --shiki-foreground: #f8f8f2;
  --shiki-token-keyword: #ff4689;
  --shiki-token-constant: #66d9ef;
  --shiki-token-function: #a6e22e;
  --shiki-token-string: #e6db74;
  --shiki-token-string-expression: #e6db74;
  --shiki-token-comment: #959077;
  --shiki-token-parameter: #fd971f;
  --shiki-token-punctuation: #f8f8f2;
  --shiki-token-link: #66d9ef;
  --shiki-token-inserted: #a6e22e;
  --shiki-token-deleted: #ff4689;
  --shiki-token-changed: #e6db74;

  --sans: 'Readex Pro Variable', 'Readex Pro', Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --mono: 'SFMono-Regular', ui-monospace, Menlo, Consolas, 'Liberation Mono', monospace;
  --bar-h: 58px;
  --sidebar-w: 236px;
  --rail-w: 216px;
  --measure: 740px;
  --gutter: clamp(18px, 3vw, 40px);
}

/* ── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--bar-h) + 20px);
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 96px 96px;
  color: var(--body);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 300;
  line-height: 1.65;
  letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--selection-bg); color: var(--selection-ink); }
a { color: inherit; }
img { max-width: 100%; height: auto; }
.skip {
  position: absolute; left: -9999px; top: 8px; z-index: 200;
  padding: 8px 12px; background: var(--ink); color: var(--bg); text-decoration: none;
}
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ── Top bar ────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--bar-h);
  border-bottom: 1px solid var(--line-soft);
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.topbar-inner {
  height: 100%;
  display: flex; align-items: center; gap: 34px;
  padding-inline: var(--gutter);
}
.wordmark {
  display: inline-flex; align-items: baseline; gap: 6px;
  color: var(--ink); text-decoration: none;
  font-size: 17px; letter-spacing: -.045em; white-space: nowrap;
}
.wordmark strong { font-weight: 700; }
.wordmark span { color: var(--muted); font-weight: 400; }
.tabs { display: flex; align-items: center; gap: 24px; min-width: 0; }
.tabs a {
  position: relative;
  padding: 6px 0;
  color: var(--muted); text-decoration: none;
  font-size: 13px; font-weight: 400; letter-spacing: .005em; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a.is-current { color: var(--current); font-weight: 500; }
.tabs a.is-current::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: calc((var(--bar-h) - 32px) / -2 - 1px);
  height: 1px; background: var(--current);
}
.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 20px; }
.topbar-out {
  color: var(--muted); text-decoration: none; font-size: 12.5px; white-space: nowrap;
}
.topbar-out:hover { color: var(--ink); }
.theme-toggle {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font: inherit; font-size: 15px; line-height: 1; cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--link-line); }
.menu-button {
  display: none;
  width: 36px; height: 32px; padding: 0 6px;
  border: 0; background: none; cursor: pointer;
  flex-direction: column; justify-content: center; gap: 6px;
}
.menu-button span { display: block; width: 22px; height: 1px; margin-left: auto; background: var(--ink); }
.drawer {
  position: fixed; inset: var(--bar-h) 0 0 0; z-index: 90;
  overflow-y: auto;
  padding: 18px var(--gutter) 40px;
  background: var(--bg);
  border-top: 1px solid var(--line-soft);
}
.drawer[hidden] { display: none; }
.drawer-group { padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.drawer-group a {
  display: block; padding: 8px 0;
  color: var(--muted); text-decoration: none; font-size: 15px;
}
.drawer-group a.is-current { color: var(--current); font-weight: 500; }
html.drawer-open { overflow: hidden; }

/* Search */
.search-button {
  display: inline-flex; align-items: center; gap: 22px;
  height: 32px; padding: 0 8px 0 12px;
  border: 1px solid var(--line); background: transparent; color: var(--faint);
  font: inherit; font-size: 13px; cursor: pointer;
}
.search-button:hover { color: var(--ink); border-color: var(--link-line); }
.search-button kbd {
  padding: 1px 6px; border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; color: var(--faint);
}
.search-dialog {
  width: min(680px, calc(100vw - 32px)); max-height: min(78vh, 760px);
  margin: 10vh auto auto; padding: 0;
  border: 1px solid var(--line); background: var(--bg); color: var(--body);
  overflow: auto;
}
.search-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.search-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft); background: var(--bg);
  color: var(--faint); font-family: var(--mono); font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
}
.search-close {
  border: 1px solid var(--line); background: transparent; color: var(--faint);
  font-family: var(--mono); font-size: 10px; padding: 3px 7px; cursor: pointer;
}
#search { padding: 16px; }
#search {
  --pagefind-ui-scale: .9;
  --pagefind-ui-primary: var(--ink);
  --pagefind-ui-text: var(--body);
  --pagefind-ui-background: var(--bg);
  --pagefind-ui-border: var(--line);
  --pagefind-ui-tag: var(--panel);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 0;
  --pagefind-ui-font: var(--sans);
}
#search mark { background: transparent; color: var(--ink); font-weight: 600; }

/* ── Shell: sidebar · main · contents rail ──────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--rail-w);
  gap: clamp(28px, 3.4vw, 56px);
  max-width: 1440px;
  margin: 0 auto;
  padding-inline: var(--gutter);
}
.sidebar, .toc-rail {
  position: sticky; top: var(--bar-h);
  align-self: start;
  max-height: calc(100vh - var(--bar-h));
  overflow-y: auto;
  padding: 36px 0 40px;
  scrollbar-width: thin;
}
.sidebar-label, .toc-label, .crumb {
  margin-bottom: 12px;
  color: var(--faint);
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: .18em; text-transform: uppercase;
}
.sidebar a {
  display: block;
  margin-left: -12px; padding: 6px 12px;
  border-left: 1px solid transparent;
  color: var(--muted); text-decoration: none;
  font-size: 14px; line-height: 1.4;
}
.sidebar a:hover { color: var(--ink); }
.sidebar a.is-current { color: var(--current); font-weight: 500; border-left-color: var(--current); }

.main { min-width: 0; max-width: var(--measure); padding: 44px 0 56px; }

.toc a {
  display: block; padding: 4px 0;
  color: var(--faint); text-decoration: none;
  font-size: 12.5px; line-height: 1.4;
}
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--current); }
.toc .toc-l2 { padding-left: 12px; }
.toc .toc-l3 { padding-left: 24px; font-size: 12px; }
.toc code, .toc-inline code { font-family: var(--mono); font-size: .92em; }
.toc-inline { display: none; }

/* ── Page head ──────────────────────────────────────────────────────────── */
.page-head { padding-bottom: 28px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.page-head h1 {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: clamp(38px, 4.6vw, 58px); font-weight: 600;
  line-height: .98; letter-spacing: -.055em;
}
.lede { margin: 0; color: var(--muted); font-size: 18px; line-height: 1.5; font-weight: 300; max-width: 64ch; }

/* ── Article ────────────────────────────────────────────────────────────── */
.article { overflow-wrap: break-word; }
.article > :first-child { margin-top: 28px; }
.article > h2:first-child { border-top: 0; padding-top: 0; }
.article h2, .article h3, .article h4, .article h5 { color: var(--ink); font-weight: 600; }
.article h2 {
  margin: 64px 0 18px; padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 32px; line-height: 1.08; letter-spacing: -.042em;
}
.article h3 { margin: 42px 0 12px; font-size: 23px; line-height: 1.15; letter-spacing: -.03em; }
.article h4 { margin: 32px 0 10px; font-size: 18px; line-height: 1.25; letter-spacing: -.02em; }
.article h5 { margin: 26px 0 8px; font-size: 15px; letter-spacing: -.01em; }
.article p, .article li { max-width: 70ch; }
.article p { margin: 0 0 18px; }
.article strong { color: var(--ink); font-weight: 550; }
.article em { font-style: italic; }
.article a {
  color: var(--link); text-decoration: none;
  border-bottom: 1px solid var(--link-line);
  overflow-wrap: anywhere;
}
.article a:hover { color: var(--link-hover); border-bottom-color: currentColor; }
.article ul, .article ol { margin: 0 0 20px; padding-left: 22px; }
.article li { margin: 6px 0; }
.article li::marker { color: var(--faint); }
.article hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }
.article :not(pre) > code {
  padding: .12em .36em;
  background: var(--inline-code-bg); color: var(--inline-code-ink);
  font-family: var(--mono); font-size: .86em;
  overflow-wrap: anywhere;
}
.article blockquote {
  margin: 26px 0; padding: 4px 0 4px 20px;
  border-left: 2px solid var(--ink);
  color: var(--body);
}
.article blockquote p:last-child { margin-bottom: 0; }

/* Code frames */
.code-frame { margin: 22px 0 24px; border: 1px solid var(--code-line); background: var(--code-bg); }
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px 8px 16px;
  border-bottom: 1px solid var(--code-line); background: var(--code-head);
}
.code-label {
  color: var(--code-label);
  font-family: var(--mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
}
.code-copy {
  padding: 3px 8px;
  border: 1px solid var(--code-line); background: transparent; color: var(--code-label);
  font-family: var(--mono); font-size: 10px; letter-spacing: .08em; cursor: pointer;
}
.code-copy:hover { color: #f2f1ed; border-color: #4c4a45; }
.code-frame pre {
  margin: 0; padding: 18px 20px 20px;
  overflow-x: auto;
  color: var(--shiki-foreground);
  font-family: var(--mono); font-size: 13px; line-height: 1.65; tab-size: 2;
}
.code-frame pre code { font-family: inherit; }

/* Tables */
.table-wrap { margin: 24px 0 28px; overflow-x: auto; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
.table-wrap th, .table-wrap td { padding: 11px 14px 11px 0; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.table-wrap tr:last-child td { border-bottom: 1px solid var(--line); }
.table-wrap th {
  color: var(--faint);
  font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase;
}
.table-wrap td:first-child { color: var(--ink); }
/* Code in a table breaks at spaces, never inside an identifier: `model.llm.id` stays whole, a long message wraps. */
.table-wrap td code { overflow-wrap: normal; word-break: normal; }

/* Blocks */
.block { margin: 26px 0; }
.block-title {
  margin-bottom: 8px;
  color: var(--ink); font-weight: 550; font-size: 14px; letter-spacing: -.005em;
}
.block-callout, .block-note, .block-warning, .block-owns {
  padding: 16px 20px;
  border: 1px solid var(--line); border-left: 2px solid var(--ink);
  background: var(--panel);
}
.block-owns .block-title, .block-note .block-title, .block-warning .block-title {
  color: var(--faint);
  font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase;
}
.block-callout > :last-child, .block-note > :last-child, .block-warning > :last-child, .block-owns > :last-child, .block-proof > :last-child { margin-bottom: 0; }
.block-pull {
  padding: 18px 0 18px 22px;
  border-left: 2px solid var(--ink);
  color: var(--ink);
  font-size: 26px; font-weight: 500; line-height: 1.2; letter-spacing: -.035em;
}
.block-pull p { margin: 0; }
.block-proof { padding: 20px 22px; border: 1px solid var(--line); background: var(--panel); }
.block-proof .block-title {
  color: var(--faint);
  font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase;
}
.block-proof p:first-of-type strong { display: block; font-size: 21px; line-height: 1.25; letter-spacing: -.03em; font-weight: 550; }

/* Figures. Terminal screenshots are dark already; diagrams drawn for a light page sit on a light plate. */
.article figure { margin: 26px 0; }
.flow-shot { border: 1px solid var(--line); background: #0a0d18; overflow: hidden; }
.flow-shot img { display: block; width: 100%; }
.flow-shot figcaption {
  padding: 11px 14px 12px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  color: #b8bcc8; font-size: 12px; line-height: 1.5;
}
img.plate, .platform-map img { display: block; padding: 14px; background: #fff; border: 1px solid var(--line); }
.platform-map { margin: 26px 0; }
.map-caption { margin-top: 10px; color: var(--faint); font-size: 13px; }

/* Current / planned */
.status-columns {
  display: grid; grid-template-columns: 1fr 1fr;
  margin: 28px 0;
  border-top: 1px solid var(--line); border-left: 1px solid var(--line);
}
.status-columns section { padding: 24px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.status-title { margin-bottom: 14px; color: var(--ink); font-size: 18px; font-weight: 550; letter-spacing: -.02em; }
.status {
  display: inline-block; margin-right: 8px; padding: 4px 8px 3px;
  border: 1px solid var(--line);
  font-family: var(--mono); font-size: 9px; line-height: 1; font-weight: 600; letter-spacing: .13em; text-transform: uppercase;
  vertical-align: 3px;
}
.status.current { background: var(--pill-current-bg); color: var(--pill-current-ink); border-color: var(--pill-current-bg); }
.status.planned { background: var(--pill-planned-bg); color: var(--pill-planned-ink); }
.status-columns ul { margin: 0; }

/* The execution stack diagram (Thinking in Lloyal) */
.execution-stack { margin: 28px 0 32px; padding: 14px; border: 1px solid var(--line); background: var(--panel); }
.stack-layer {
  display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 24px; align-items: start;
  padding: 18px 20px; border: 1px solid var(--line); background: var(--bg);
}
.stack-layer-name { color: var(--ink); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; line-height: 1.3; }
.stack-layer-copy { color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.stack-components { display: grid; gap: 10px; }
.stack-component {
  display: grid; grid-template-columns: minmax(180px, .72fr) minmax(0, 1.28fr); gap: 14px; align-items: baseline;
  padding-top: 10px; border-top: 1px solid var(--line-soft);
}
.stack-component:first-child { padding-top: 0; border-top: 0; }
.execution-stack a { border-bottom: 0; font-weight: 500; }
.execution-stack a:hover { text-decoration: underline; }
.stack-connector {
  position: relative; height: 40px;
  display: flex; justify-content: center; align-items: center;
  color: var(--faint); font-family: var(--mono); font-size: 9px; letter-spacing: .17em; text-transform: uppercase;
}
.stack-connector::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--line); }
.stack-connector span { position: relative; z-index: 1; padding: 3px 9px; background: var(--panel); }

/* ── Prev / next, footer ────────────────────────────────────────────────── */
.prev-next { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 64px; }
.prev-next a {
  display: block; padding: 16px 18px;
  border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-weight: 500; font-size: 15px;
}
.prev-next a:hover { border-color: var(--link-line); background: var(--panel); }
.prev-next span { display: block; margin-bottom: 4px; color: var(--faint); font-family: var(--mono); font-size: 10px; font-weight: 400; letter-spacing: .16em; text-transform: uppercase; }
.pn-next { text-align: right; grid-column: 2; }
.footer {
  display: flex; flex-wrap: wrap; gap: 8px 22px;
  margin-top: 48px; padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  color: var(--faint); font-size: 12.5px;
}
.footer a { color: var(--faint); text-decoration: none; }
.footer a:hover { color: var(--ink); }
.back-to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 50;
  display: grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid var(--line); background: var(--bar-bg-solid); color: var(--muted);
  text-decoration: none; opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.back-to-top.show { opacity: 1; pointer-events: auto; }
.back-to-top:hover { color: var(--ink); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc-rail { display: none; }
  .toc-inline { display: block; margin: 20px 0 0; border: 1px solid var(--line); }
  .toc-inline summary {
    padding: 10px 14px; cursor: pointer;
    color: var(--faint); font-family: var(--mono); font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
  }
  .toc-inline nav { padding: 0 14px 12px; }
  .toc-inline a { display: block; padding: 4px 0; color: var(--muted); text-decoration: none; font-size: 13.5px; }
  .toc-inline .toc-l2 { padding-left: 12px; }
  .toc-inline .toc-l3 { padding-left: 24px; }
  .topbar-out { display: none; }
}
@media (max-width: 960px) {
  .tabs { gap: 18px; }
  .topbar-inner { gap: 22px; }
}
@media (max-width: 820px) {
  :root { --bar-h: 54px; }
  .search-button span { display: none; }
  .search-button { gap: 0; padding: 0 8px; }
  .tabs, .sidebar { display: none; }
  .menu-button { display: inline-flex; }
  .shell { display: block; }
  .main { max-width: none; padding-top: 28px; }
  .status-columns { grid-template-columns: 1fr; }
  .stack-layer, .stack-component { grid-template-columns: 1fr; gap: 6px; }
}
@media (max-width: 560px) {
  body { font-size: 15px; }
  .article h2 { font-size: 26px; margin-top: 48px; }
  .article h3 { font-size: 20px; }
  .lede { font-size: 16px; }
  .block-pull { font-size: 21px; }
  .prev-next { grid-template-columns: 1fr; }
  .pn-next { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .back-to-top { transition: none; }
}
@media print {
  .topbar, .drawer, .sidebar, .toc-rail, .toc-inline, .prev-next, .back-to-top, .code-copy { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #111; }
}
