/* KERNEL documentation: styles (kept out of the page so it works under a
   Content-Security-Policy without inline styles or scripts). */
/* Layout: a reference manual. Sidebar index on the left, one reading column, an
   on-this-page rail on wide screens; a header carrying the Ontario winter TOU day. */
:root {
  --bg: #f5f7f6; --surface: #ffffff; --fg: #15211f; --muted: #57686a; --line: #d6dfdd;
  --accent: #0a6971; --accent-weak: #e1efef; --code-bg: #edf2f1; --mark: #fff1c2;
  --off: #3f8d5b; --mid: #cf9312; --on: #c0442c;
  --sx-key: #0a6971; --sx-str: #8a4b08; --sx-num: #6a3ea0; --sx-com: #6b7c79; --sx-kw: #a3316a;
  --font-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --side: 248px; --rail: 220px; --col: 46rem; --header: 56px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0e1514; --surface: #131c1b; --fg: #e1e9e7; --muted: #98a9a6; --line: #263331;
  --accent: #5ec3ca; --accent-weak: #16302f; --code-bg: #101918; --mark: #4a3d12;
  --off: #5db57c; --mid: #e3b03a; --on: #e2694f;
  --sx-key: #73ced4; --sx-str: #e2a768; --sx-num: #b89be6; --sx-com: #7f918d; --sx-kw: #e589b5;
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0e1514; --surface: #131c1b; --fg: #e1e9e7; --muted: #98a9a6; --line: #263331;
  --accent: #5ec3ca; --accent-weak: #16302f; --code-bg: #101918; --mark: #4a3d12;
  --off: #5db57c; --mid: #e3b03a; --on: #e2694f;
  --sx-key: #73ced4; --sx-str: #e2a768; --sx-num: #b89be6; --sx-com: #7f918d; --sx-kw: #e589b5;
  color-scheme: dark; }

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header) + 16px); }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.6 var(--font-body);
  -webkit-text-size-adjust: 100%; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  z-index: 30; background: var(--surface); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* header */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface);
  border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 12px; height: var(--header);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: baseline; gap: 10px; color: var(--fg); text-decoration: none; white-space: nowrap; }
.wordmark { font: 800 1.15rem/1 var(--font-display); font-stretch: 118%; letter-spacing: .02em; }
.ver { font: 500 .75rem/1 var(--font-mono); color: var(--muted); }
.search { position: relative; flex: 1; max-width: 420px; margin-left: auto; min-width: 0; }
.search input { width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--fg); font: inherit; font-size: .95rem; }
.search input::placeholder { color: var(--muted); }
.hits { position: absolute; top: 42px; left: 0; right: 0; max-height: 70vh; overflow: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgb(0 0 0 / .14); padding: 6px; }
.hits a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--fg); text-decoration: none; }
.hits a[aria-selected="true"], .hits a:hover { background: var(--accent-weak); }
.hits .hp { display: block; font-size: .78rem; color: var(--muted); }
.hits .ht { font-weight: 600; }
.hits .hx { display: block; font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hits .none { padding: 10px; color: var(--muted); }
.iconbtn { height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  color: var(--fg); font: 500 .85rem var(--font-body); cursor: pointer; white-space: nowrap; }
.iconbtn:hover { border-color: var(--accent); }
.menu { display: none; }

/* the TOU day: Ontario RPP, winter weekday */
.tou { display: grid; grid-template-columns: repeat(24, 1fr); height: 5px; }
.tou span { display: block; }
.tou .o { background: var(--off); } .tou .m { background: var(--mid); } .tou .p { background: var(--on); }

/* layout */
.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); max-width: 1440px; margin: 0 auto; }
.side { position: sticky; top: calc(var(--header) + 5px + env(safe-area-inset-top, 0px)); align-self: start;
  height: calc(100vh - var(--header) - 5px); overflow: auto; padding: 24px 16px 40px max(16px, env(safe-area-inset-left, 0px));
  border-right: 1px solid var(--line); }
.side h2 { margin: 22px 0 6px; font: 700 .72rem/1.2 var(--font-display); font-stretch: 112%; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted); }
.side h2:first-child { margin-top: 0; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side a { display: block; padding: 5px 10px; margin: 1px 0; border-radius: 6px; color: var(--fg); text-decoration: none; font-size: .93rem; }
.side a:hover { background: var(--accent-weak); }
.side a[aria-current="page"] { background: var(--accent-weak); color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }

main { min-width: 0; padding-block: 32px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.page { display: grid; grid-template-columns: minmax(0, var(--col)) var(--rail); gap: 48px; justify-content: center; }
[hidden] { display: none !important; }   /* one page at a time; also closed search results and tab panels */
.page-body { min-width: 0; }
.rail { position: sticky; top: calc(var(--header) + 32px); align-self: start; font-size: .85rem; }
.rail p { margin: 0 0 8px; font: 700 .72rem/1.2 var(--font-display); font-stretch: 112%; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted); }
.rail ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.rail a { display: block; padding: 3px 0 3px 12px; color: var(--muted); text-decoration: none; }
.rail a:hover { color: var(--accent); }

/* type */
h1, h2, h3, h4 { font-family: var(--font-display); font-stretch: 108%; line-height: 1.2; text-wrap: balance; color: var(--fg); }
h1 { font-size: clamp(1.9rem, 1.4rem + 1.8vw, 2.6rem); font-weight: 800; font-stretch: 116%; margin: 0 0 18px; letter-spacing: -.005em; }
h2 { font-size: 1.45rem; font-weight: 750; margin: 2.4em 0 .6em; padding-top: .6em; border-top: 1px solid var(--line); }
h3 { font-size: 1.12rem; font-weight: 700; margin: 1.9em 0 .5em; }
h4 { font-size: 1rem; font-weight: 700; margin: 1.5em 0 .4em; }
.page-body > h1 + p { font-size: 1.08rem; }
p, li { max-width: 68ch; }
ul, ol { padding-left: 1.4em; }
li { margin: .25em 0; }
strong { font-weight: 650; }
code { font: .86em/1.4 var(--font-mono); background: var(--code-bg); padding: .1em .35em; border-radius: 4px;
  overflow-wrap: anywhere; }
sub, sup { line-height: 0; }

/* code blocks */
.code { position: relative; margin: 1.1em 0; }
.hl { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.hl pre { margin: 0; padding: 14px 16px; font: .84rem/1.55 var(--font-mono); tab-size: 4; }
.hl code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }
.copy { position: absolute; top: 8px; right: 8px; padding: 3px 9px; font: 500 .72rem var(--font-body);
  color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; opacity: 0; transition: opacity .15s; }
.code:hover .copy, .copy:focus-visible { opacity: 1; }
@media (hover: none) { .copy { opacity: 1; } }
.hl .k, .hl .kd, .hl .kn, .hl .kr, .hl .kt, .hl .ow { color: var(--sx-kw); }
.hl .kc, .hl .m, .hl .mi, .hl .mf, .hl .mh, .hl .il { color: var(--sx-num); }
.hl .s, .hl .s1, .hl .s2, .hl .sb, .hl .sd, .hl .se, .hl .sh, .hl .si, .hl .sx, .hl .sa, .hl .dl { color: var(--sx-str); }
.hl .nt, .hl .nf, .hl .fm, .hl .nc, .hl .nn, .hl .na, .hl .nb, .hl .bp { color: var(--sx-key); }
.hl .c, .hl .c1, .hl .cm, .hl .cs, .hl .ch, .hl .cp, .hl .cpf, .hl .gp { color: var(--sx-com); font-style: italic; }
.hl .cp, .hl .cpf, .hl .gp { font-style: normal; }
.hl .err { color: inherit; border: 0; background: none; }

/* tables */
.table { overflow-x: auto; margin: 1.1em 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--line); }
th { font: 650 .78rem/1.3 var(--font-body); text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  background: var(--bg); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }
td:first-child code { color: var(--accent); background: var(--accent-weak); }

/* callouts */
.callout { margin: 1.3em 0; padding: 12px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.callout p { margin: .3em 0; }
.callout-title { font: 700 .75rem/1.2 var(--font-display); font-stretch: 112%; text-transform: uppercase; letter-spacing: .09em; }
.callout-note .callout-title { color: var(--accent); }
.callout-tip .callout-title { color: var(--off); }
.callout-warning { border-color: color-mix(in srgb, var(--mid) 55%, var(--line)); }
.callout-warning .callout-title { color: var(--mid); }

/* tabs */
.tabs { margin: 1.1em 0; }
.tablist { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tablist button { padding: 7px 12px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none;
  color: var(--muted); font: 600 .88rem var(--font-body); cursor: pointer; }
.tablist button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabpanel > .code:first-child { margin-top: .6em; }

/* diagrams */
.diagram { margin: 1.6em 0; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.diagram svg { display: block; width: 100%; height: auto; max-width: 100%; font-family: var(--font-body); }
.diagram figcaption { margin-top: 12px; font-size: .88rem; color: var(--muted); max-width: 68ch; }
.d-box rect { fill: var(--bg); stroke: var(--line); stroke-width: 1.5; }
.d-box text { fill: var(--fg); font-size: 14px; font-weight: 600; text-anchor: middle; }
.d-key rect { fill: var(--accent-weak); stroke: var(--accent); }
.d-key text { fill: var(--accent); }
.d-solver rect { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; }
.d-solver text { fill: var(--fg); font-size: 13px; text-anchor: middle; }
.d-opt rect { stroke-dasharray: 5 4; stroke: var(--muted); }
.d-line path { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.d-dash path { stroke-dasharray: 4 4; }
.d-arrow path { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.d-label text { fill: var(--fg); font-size: 13px; font-weight: 700; }
.d-sub text { fill: var(--muted); font-size: 12px; }
.d-note text { fill: var(--muted); font-size: 12px; text-anchor: middle; }
.d-hint text { fill: var(--accent); font-size: 12px; }
.d-dot circle { fill: var(--accent); }
.d-model rect { fill: var(--accent-weak); stroke: var(--accent); stroke-width: 1; }
.d-out rect { fill: var(--bg); stroke: var(--fg); stroke-width: 1; }
.d-shade rect { fill: var(--accent-weak); }

/* pager and footer */
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--line); }
.pager a { display: flex; flex-direction: column; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px;
  text-decoration: none; color: var(--fg); min-width: 0; max-width: 48%; background: var(--surface); }
.pager a:hover { border-color: var(--accent); }
.pager small { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.pager .next { margin-left: auto; text-align: right; }
.foot { margin-top: 40px; font-size: .82rem; color: var(--muted); }
.foot a { color: inherit; }
/* author page */
.author-card { margin-top: 8px; padding: 22px 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.author-name { margin: 0 0 14px; font: 800 1.45rem/1.15 var(--font-display); font-stretch: 112%; letter-spacing: .01em; }
.author-card dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 22px; margin: 0; }
.author-card dt { color: var(--muted); font-weight: 600; }
.author-card dd { margin: 0; }
@media (max-width: 560px) { .author-card dl { grid-template-columns: minmax(0, 1fr); gap: 2px; } .author-card dd { margin-bottom: 10px; } }

mark { background: var(--mark); color: inherit; border-radius: 2px; }

@media (max-width: 1200px) { .page { grid-template-columns: minmax(0, var(--col)); } .rail { display: none; } }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu { display: inline-block; }
  .side { position: fixed; z-index: 25; top: calc(var(--header) + 5px + env(safe-area-inset-top, 0px)); left: 0; bottom: 0;
    width: min(300px, 85vw); height: auto; background: var(--surface); box-shadow: 8px 0 32px rgb(0 0 0 / .18); transform: translateX(-105%);
    transition: transform .2s ease; padding-bottom: max(40px, env(safe-area-inset-bottom, 0px)); }
  body.nav-open .side { transform: none; }
  main { padding-block: 24px 48px; }
}
@media (max-width: 560px) {
  .ver { display: none; }
  .wordmark { font-size: 1rem; }
  .top-in { gap: 8px; }
  #theme { display: none; }
  h2 { font-size: 1.3rem; }
  td code { white-space: normal; overflow-wrap: anywhere; }
  th, td { padding: 7px 9px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Website copy only: link back to the KERNEL website. */
.back { display: inline-flex; align-items: center; text-decoration: none; }

