/* The book's pages. The notes use lib/theme/style.css; this is the prose
   around them, the bar and the contents. The colors are the docs app's
   (apps/docs/src/app.css): dark here, .xmd-light on <html> for light, which
   the head script picks from the app's saved theme or else the system's. */
:root {
  --ink: #e3e3e3; --muted: #9aa0a6; --faint: #6f7378; --paper: #202124; --side: #232528;
  --rule: #3c4043; --code: #1b1c1e; --hover: rgba(232, 234, 237, .1); --link: #8ab4f8; --accent: #8ab4f8;
  --xmd-foreground: #e3e3e3; --xmd-inlay-background: #2d3138; --xmd-inlay-foreground: #c3cad6;
  --sidebar: 264px; --measure: 740px; --bar: 52px;
  color-scheme: dark;
}
:root.xmd-light {
  --ink: #1f1f1f; --muted: #5f6368; --faint: #9aa0a6; --paper: #ffffff; --side: #f8f9fa;
  --rule: #dadce0; --code: #f8f9fa; --hover: rgba(60, 64, 67, .08); --link: #185abc; --accent: #1a73e8;
  --xmd-foreground: #1f1f1f; --xmd-inlay-background: #eef0f3; --xmd-inlay-foreground: #3c4653;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { scroll-padding-top: var(--bar); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16.5px/1.7 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* The top bar: the contents button, the name, and the way out to the app
   and GitHub. It stays on top while the page scrolls. */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; height: var(--bar); padding: 0 16px; background: var(--paper); border-bottom: 1px solid var(--rule); font-size: 14px; }
.toggle { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.toggle:hover, .toggle[aria-expanded="true"] { color: var(--ink); background: var(--hover); }
.brand { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.links { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.links :is(a, button) { display: grid; padding: 0; border: 0; background: transparent; cursor: pointer; place-items: center; width: 32px; height: 32px; border-radius: 6px; color: var(--muted); }
.links :is(a, button):hover { color: var(--ink); background: var(--hover); }
/* The theme button shows where it goes: the sun in the dark, the moon in the light. */
.theme .moon, .xmd-light .theme .sun { display: none; }
.xmd-light .theme .moon { display: block; }
.links svg { display: block; }

/* The contents: closed until the button opens them, under the bar along the
   left edge. On a phone they cover the text; on a wide screen the text moves
   over for them (the rules at the end). */
.sidebar { position: fixed; top: var(--bar); bottom: 0; left: 0; z-index: 15; display: flex; flex-direction: column; width: var(--sidebar); max-width: 85vw; background: var(--side); border-right: 1px solid var(--rule); transform: translateX(-100%); visibility: hidden; transition: transform 0.18s ease, visibility 0.18s; }
.contents-open .sidebar { transform: none; visibility: visible; box-shadow: 8px 0 24px rgb(0 0 0 / 0.18); }
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
.contents { flex: 1; overflow-y: auto; padding: 18px 16px 24px; font-size: 13.5px; line-height: 1.45; }
.contents ol { list-style: none; margin: 0; padding: 0; }
.contents a { display: block; padding: 4px 8px; border-radius: 5px; color: var(--muted); text-decoration: none; }
.contents a:hover { color: var(--ink); background: var(--hover); }
.contents a[aria-current] { color: var(--ink); font-weight: 600; }
.contents ol ol { margin: 2px 0 8px 12px; padding-left: 4px; border-left: 1px solid var(--rule); font-size: 13px; }
.contents ol ol a { padding: 3px 8px; }
.contents ol ol a.here { color: var(--ink); box-shadow: inset 2px 0 0 var(--accent); border-radius: 0 5px 5px 0; }
.contents p { margin: 20px 8px 6px; color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }

main { max-width: var(--measure); margin: 0 auto; padding: 8px 20px 24px; }

h1, h2, h3 { position: relative; letter-spacing: -0.015em; scroll-margin-top: 24px; }
h1 { font-size: 2.1em; line-height: 1.15; margin: 0.9em 0 0.45em; }
h2 { font-size: 1.45em; line-height: 1.25; margin: 2.2em 0 0.6em; padding-bottom: 0.3em; border-bottom: 1px solid var(--rule); }
h3 { font-size: 1.08em; margin: 1.8em 0 0.4em; }
h3 code { font-size: 0.95em; }
.anchor { margin-left: 0.35em; color: var(--faint); text-decoration: none; font-weight: 400; opacity: 0; transition: opacity 0.12s; }
:is(h2, h3):hover .anchor, .anchor:focus-visible { opacity: 1; }
p, ul, ol { margin: 0 0 1em; }
main li { margin: 0.25em 0; }
main ul, main ol { padding-left: 1.3em; }

code { font: 0.86em/1.5 "Ioskeley Mono", ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--code); border: 1px solid var(--rule); padding: 0.08em 0.32em; border-radius: 4px; }
pre.code { background: var(--code); border: 1px solid var(--rule); border-radius: 8px; padding: 14px 16px; overflow-x: auto; margin: 1.2em 0; line-height: 1.55; }
pre.code code { background: none; border: 0; padding: 0; font-size: 13.5px; }

/* The notes: live editors and build-time highlighted modules share the code
   blocks' surface. */
.xmd-block, .xmd-static { --xmd-background: var(--code); }
.xmd-block { display: flex; flex-direction: column; margin: 1.4em 0; }
.xmd-block .xmd-live { border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.xmd-block .xmd-live .xmd { margin: 0; padding: 14px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.xmd-block .xmd-live .xmd .inlay { white-space: pre-wrap; }
.xmd-block .xmd-live:focus-within { border-color: var(--faint); }
/* Features a block turned off (data-off): the text stays, only the overlay goes. */
.xmd-block[data-off~="highlight"] .xmd [class^="t-"] { all: unset; }
.xmd-block[data-off~="results"] .xmd .inlay { display: none; }
.xmd-static .xmd { margin: 1.2em 0; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 8px; overflow-x: auto; font-size: 13.5px; line-height: 1.6; }
.xmd-block .reset { align-self: flex-end; margin-top: 6px; height: 24px; padding: 0 10px; border: 1px solid var(--rule); border-radius: 12px; background: transparent; color: var(--faint); font: 500 11.5px system-ui, sans-serif; cursor: pointer; }
.xmd-block .reset:hover { color: var(--ink); border-color: var(--faint); }

/* A terminal: the note in its tab, and a shell beneath that queries it. The
   shell is dark in both themes, as terminals are. */
.xmd-terminal { --xmd-background: var(--code); margin: 1.4em 0; border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.xmd-terminal > pre.code { margin: 0; border: 0; border-radius: 0; }
.term-tab { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 0; background: var(--side); border-bottom: 1px solid var(--rule); font: 500 12px system-ui, sans-serif; }
.term-file { padding: 9px 14px; color: var(--ink); border-right: 1px solid var(--rule); background: var(--code); box-shadow: inset 0 2px 0 var(--accent); }
.term-reset { height: 22px; padding: 0 9px; border: 1px solid var(--rule); border-radius: 11px; background: transparent; color: var(--faint); font: 500 11px system-ui, sans-serif; cursor: pointer; }
.term-reset:hover { color: var(--ink); border-color: var(--faint); }
.xmd-terminal .xmd-live { max-height: 340px; overflow: auto; }
.xmd-terminal .xmd-live .xmd { margin: 0; padding: 12px 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.term-screen { background: #0f1114; color: #d7dade; font: 13px/1.55 "Ioskeley Mono", ui-monospace, SFMono-Regular, Menlo, monospace; border-top: 1px solid var(--rule); cursor: text; }
.term-log { max-height: 360px; overflow: auto; padding: 12px 16px 2px; }
.term-entry + .term-entry { margin-top: 10px; }
.term-cmd { color: #f1f3f5; white-space: pre-wrap; overflow-wrap: anywhere; }
.term-prompt { color: #7ee2a8; margin-right: 0.15em; user-select: none; }
.term-out, .term-err { margin: 2px 0 0; padding: 0; background: none; border: 0; font: inherit; white-space: pre; overflow-x: auto; tab-size: 12; }
.term-out { color: #b9c0c8; }
.term-err { color: #f59f9f; }
.term-line { display: flex; align-items: center; gap: 0.5em; padding: 6px 16px 12px; }
.term-line input { flex: 1; min-width: 0; padding: 4px 0; border: 0; outline: 0; background: transparent; color: #f1f3f5; font: inherit; caret-color: #7ee2a8; }
.term-line input::placeholder { color: #5d646c; }
.term-screen:focus-within { box-shadow: inset 0 0 0 1px #3a4048; }

.table { overflow-x: auto; margin: 1.2em 0; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; line-height: 1.5; }
th { font-weight: 600; color: var(--muted); font-size: 13px; }
th, td { text-align: left; vertical-align: top; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--rule); }
td:first-child { white-space: nowrap; }
img { max-width: 100%; height: auto; border-radius: 8px; }

footer { display: flex; gap: 16px; max-width: var(--measure); margin: 0 auto; padding: 24px 20px 48px; color: var(--faint); font-size: 13px; }
footer a { color: var(--faint); }

/* Wide screens: open contents take the left edge beside the text, which
   keeps its measure, centered in what is left. Last, so it wins over the
   rules above. */
@media (min-width: 1024px) {
  .topbar { padding: 0 20px; }
  .contents-open .sidebar { box-shadow: none; }
  .contents-open :is(main, footer) { --gutter: max(48px, calc((100vw - var(--sidebar) - var(--measure)) / 2)); max-width: none; margin: 0 0 0 var(--sidebar); padding-left: var(--gutter); padding-right: var(--gutter); }
  main { padding-top: 32px; padding-bottom: 32px; }
}
