/* The style of the ztcl and ztk sites. The two sites use the same file.
   Only the accent tokens in the first two blocks differ. */
:root {
  color-scheme: light dark;
  --accent: #6d28d9;
  --accent-strong: #5b21b6;
  --accent-soft: #ede9fe;
  --accent-ink: #ffffff;
  --sib: #0f766e;
  --bg: #ffffff;
  --bg-soft: #f6f7f8;
  --surface: #ffffff;
  --code-bg: #f3f4f6;
  --text: #16181d;
  --text-2: #4b5160;
  --text-3: #6b7180;
  --line: #e3e5ea;
  --line-strong: #cfd3da;
  --bar-muted: #9aa1ad;
  --warn: #9a5b00;
  --warn-soft: #fff6e5;
  --tok-kw: #7c3aed;
  --tok-str: #047857;
  --tok-var: #b45309;
  --tok-com: #6b7180;
  --tok-num: #be123c;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --wrap: 1120px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #a78bfa;
    --accent-strong: #c4b5fd;
    --accent-soft: #2a2145;
    --accent-ink: #1a1033;
    --sib: #0d9488;
    --bg: #0d0f12;
    --bg-soft: #13161b;
    --surface: #171a20;
    --code-bg: #1b1f26;
    --text: #eceef2;
    --text-2: #b4bac6;
    --text-3: #8b92a0;
    --line: #262b33;
    --line-strong: #353b45;
    --bar-muted: #5d6573;
    --warn: #f5b754;
    --warn-soft: #2a2114;
    --tok-kw: #c4a5ff;
    --tok-str: #6ee7b7;
    --tok-var: #fbbf6b;
    --tok-com: #8b92a0;
    --tok-num: #fb8aa3;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: var(--accent-strong); }
code, pre, kbd { font-family: var(--mono); }
img, svg { max-width: 100%; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 20; }
.skip:focus { left: 8px; }

/* The top bar of each page. */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 24px; height: 60px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font: 700 19px/1 var(--mono); letter-spacing: -.01em; }
.logo:hover { color: var(--text); }
.logo .glyph { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 14px; }
.toplinks { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.toplinks a { color: var(--text-2); text-decoration: none; font-size: 15px; padding: 6px 10px; border-radius: 8px; }
.toplinks a:hover, .toplinks a[aria-current] { color: var(--text); background: var(--bg-soft); }
.toplinks .sib { display: inline-flex; gap: 6px; align-items: center; }
.toplinks .sib::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--sib); }

/* Buttons. */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: 10px; font-weight: 600; font-size: 15px; text-decoration: none; border: 1px solid transparent; transition: background .15s, border-color .15s; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); color: var(--accent-ink); }
.btn.ghost { border-color: var(--line-strong); color: var(--text); background: var(--surface); }
.btn.ghost:hover { border-color: var(--text-3); color: var(--text); }

/* The landing page. */
.hero { padding: 44px 0 40px; border-bottom: 1px solid var(--line); background:
  radial-gradient(1200px 400px at 85% -10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%); }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.hero .wrap > div:first-child { padding-top: 8px; }
.hero .live-demo { max-width: 100%; min-width: 0; }
.pill { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 12px; margin-bottom: 14px; background: var(--surface); }
.pill b { color: var(--accent); font-weight: 600; }
.hero h1 { font-size: clamp(32px, 3.8vw, 46px); line-height: 1.08; letter-spacing: -.03em; margin: 0 0 14px; font-weight: 750; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .sub { font-size: 17px; line-height: 1.55; color: var(--text-2); margin: 0 0 20px; max-width: 36em; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero .meta { margin-top: 22px; font-size: 14px; color: var(--text-3); }

.codecard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; min-width: 0; }
.codecard .bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); font: 13px var(--mono); color: var(--text-3); background: var(--bg-soft); }
.codecard .bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); display: inline-block; }
.codecard .bar span { margin-left: 8px; }
.codecard pre { margin: 0; padding: 18px 20px; font-size: 14px; line-height: 1.6; overflow-x: auto; background: none; border-radius: 0; }
.codecard pre + pre { border-top: 1px dashed var(--line); }
.term { color: var(--text-2); }
.term .p { color: var(--accent); user-select: none; }
.k { color: var(--tok-kw); } .s { color: var(--tok-str); } .v { color: var(--tok-var); } .c { color: var(--tok-com); } .n { color: var(--tok-num); }

.stats { border-bottom: 1px solid var(--line); background: var(--bg-soft); }
.stats .wrap { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 28px 24px 26px 0; }
.stat + .stat { padding-left: 24px; border-left: 1px solid var(--line); }
.stat b { display: block; font-size: 30px; line-height: 1.1; letter-spacing: -.02em; font-weight: 700; }
.stat span { display: block; margin-top: 6px; color: var(--text-2); font-size: 14px; line-height: 1.45; }

.section { padding: 56px 0; border-bottom: 1px solid var(--line); }
.section.alt { background: var(--bg-soft); }
.eyebrow { font: 600 13px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 0 0 14px; }
.section h2 { font-size: clamp(26px, 3vw, 34px); line-height: 1.15; letter-spacing: -.025em; margin: 0 0 16px; font-weight: 720; max-width: 22em; }
.lede { font-size: 18px; color: var(--text-2); max-width: 40em; margin: 0 0 40px; }
.section h3 { font-size: 18px; margin: 0 0 8px; letter-spacing: -.01em; }
.section p { margin: 0 0 12px; }
.muted { color: var(--text-3); }
.small { font-size: 14px; }

.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; min-width: 0; }
.card p:last-child, .card ul:last-child { margin-bottom: 0; }
.card .tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-strong); margin-bottom: 12px; }
.card .tag.plan { background: var(--bg-soft); color: var(--text-2); border: 1px solid var(--line); }
.card ul { padding-left: 20px; margin: 8px 0 0; color: var(--text-2); }
.card li + li { margin-top: 4px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: start; }

/* Bar charts: HTML rows. Each bar has its value as text. */
.chart { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px 24px 18px; }
.chart h3 { margin-bottom: 4px; }
.chart .how { font-size: 14px; color: var(--text-3); margin: 0 0 20px; }
.bars { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; gap: 10px 14px; align-items: center; margin: 0; }
.bars dt { font-size: 14px; color: var(--text-2); white-space: nowrap; }
.bars dd { margin: 0; display: contents; }
.bars .track { height: 22px; display: flex; align-items: center; }
.bars .fill { height: 100%; min-width: 3px; border-radius: 0 4px 4px 0; background: var(--accent); }
.bars .fill.base { background: var(--bar-muted); }
.bars .fill.t1 { background: color-mix(in srgb, var(--accent) 70%, var(--bg)); }
.bars .fill.t0 { background: color-mix(in srgb, var(--accent) 42%, var(--bg)); }
.bars .val { font: 600 14px var(--mono); text-align: right; }
.bars .val small { font-weight: 400; color: var(--text-3); }
.chart .note { font-size: 13px; color: var(--text-3); margin: 16px 0 0; }
.multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.multiples .chart { padding: 18px 18px 14px; }
.multiples h4 { font: 600 14px var(--mono); margin: 0 0 12px; }
.multiples .bars { gap: 6px 10px; }
.multiples .bars .track { height: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--text-2); margin: 0 0 16px; padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; background: var(--accent); }
.legend i.base { background: var(--bar-muted); }
.legend i.t1 { background: color-mix(in srgb, var(--accent) 70%, var(--bg)); }
.legend i.t0 { background: color-mix(in srgb, var(--accent) 42%, var(--bg)); }

.callout { border: 1px solid var(--line); border-left: 4px solid var(--warn); background: var(--warn-soft); border-radius: 0 12px 12px 0; padding: 16px 20px; margin: 24px 0 0; }
.callout p { margin: 0; }
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { position: relative; padding-left: 28px; margin: 0 0 10px; color: var(--text-2); }
.checks li::before { content: ""; position: absolute; left: 2px; top: .5em; width: 12px; height: 7px; border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(-45deg); }
.checks li b { color: var(--text); }
.status { list-style: none; padding: 0; margin: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.status li { background: var(--surface); padding: 16px 20px; display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; align-items: baseline; }
.status .st { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.st.ok { color: var(--accent); } .st.wip { color: var(--warn); } .st.plan { color: var(--text-3); } .st.no { color: var(--tok-num); }
.family { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; border: 1px solid var(--line); border-radius: 16px; padding: 28px 32px; background: var(--surface); }
.family h3 { font-size: 22px; margin: 0 0 6px; }
.family p { margin: 0; color: var(--text-2); }
.family .btn.sib-btn { background: var(--sib); color: #fff; }

/* The docs pages. */
.docs { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 56px; max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.sidebar { position: sticky; top: 60px; align-self: start; max-height: calc(100vh - 60px); overflow: auto; padding: 32px 4px 48px 0; font-size: 15px; }
.sidebar h2, .sidebar summary { font: 600 12px/1 var(--sans); letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); margin: 24px 0 8px; }
.sidebar h2:first-child { margin-top: 0; }
.sidebar summary { cursor: pointer; list-style-position: outside; }
.sidebar a.item { display: block; padding: 5px 10px; margin: 1px 0; border-radius: 8px; color: var(--text-2); text-decoration: none; line-height: 1.4; }
.sidebar a.item:hover { color: var(--text); background: var(--bg-soft); }
.sidebar a.item[aria-current] { color: var(--accent-strong); background: var(--accent-soft); font-weight: 600; }
.toc-toggle { position: absolute; opacity: 0; pointer-events: none; }
.toc-button { display: none; }
.prose { padding: 40px 0 80px; max-width: 780px; min-width: 0; }
.prose h1 { font-size: 38px; line-height: 1.15; letter-spacing: -.025em; margin: 0 0 24px; }
.prose h2 { font-size: 26px; line-height: 1.25; letter-spacing: -.015em; margin: 48px 0 12px; padding-top: 8px; }
.prose h3 { font-size: 20px; margin: 32px 0 8px; }
.prose h4 { font-size: 17px; margin: 24px 0 6px; }
.prose p, .prose ul, .prose ol { margin: 0 0 16px; }
.prose li + li { margin-top: 4px; }
.prose code { font-size: .88em; background: var(--code-bg); padding: .14em .36em; border-radius: 5px; }
.prose pre { background: var(--code-bg); border: 1px solid var(--line); padding: 16px 18px; border-radius: 10px; overflow: auto; line-height: 1.5; font-size: 14px; margin: 0 0 20px; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose .table { overflow-x: auto; margin: 0 0 20px; border: 1px solid var(--line); border-radius: 10px; }
.prose table { border-collapse: collapse; min-width: 100%; font-size: 14.5px; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 8px 12px; text-align: left; vertical-align: top; }
.prose tr:last-child td { border-bottom: 0; }
.prose th { background: var(--bg-soft); font-weight: 600; }
.prose td + td, .prose th + th { border-left: 1px solid var(--line); }
.prose blockquote { margin: 0 0 20px; padding: 4px 18px; border-left: 3px solid var(--line-strong); color: var(--text-2); }
.prose .alert { margin: 0 0 20px; padding: 12px 18px; border: 1px solid var(--line); border-left: 4px solid var(--accent); background: var(--bg-soft); border-radius: 0 10px 10px 0; }
.prose .alert.warning { border-left-color: var(--warn); background: var(--warn-soft); }
.prose .alert p { margin: 0; }
.prose h1 + p, .prose h1 + .alert { margin-top: 0; }
.pager { margin-top: 56px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pager a { display: block; border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; text-decoration: none; color: var(--text); }
.pager a:hover { border-color: var(--accent); color: var(--text); }
.pager a span { display: block; font-size: 13px; color: var(--text-3); }
.pager .next { text-align: right; grid-column: 2; }

.foot { padding: 40px 0 48px; color: var(--text-3); font-size: 14px; }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center; }
.foot a { color: var(--text-2); text-decoration: none; }
.foot a:hover { color: var(--text); }
.foot .right { margin-left: auto; display: flex; gap: 20px; flex-wrap: wrap; }
.docs-foot { border-top: 1px solid var(--line); }

@media (max-width: 960px) {
  .hero { padding: 32px 0 32px; }
  .hero .wrap, .split { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .g3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .stats .wrap { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; padding-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .docs { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc-button { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; padding: 9px 14px; border: 1px solid var(--line-strong); border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; width: max-content; }
  .toc-button::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); }
  .toc-toggle:focus-visible + .toc-button { outline: 2px solid var(--accent); outline-offset: 2px; }
  .sidebar { display: none; position: static; max-height: none; padding: 8px 0 16px; border-bottom: 1px solid var(--line); }
  .toc-toggle:checked ~ .sidebar { display: block; }
  .prose { padding-top: 24px; }
}
@media (max-width: 640px) {
  .wrap, .docs { padding: 0 16px; }
  .top .wrap { gap: 12px; }
  .toplinks a { padding: 6px 7px; font-size: 14px; }
  .section { padding: 40px 0; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .hero .sub { font-size: 17px; }
  .stat { padding: 20px 12px 18px 0; }
  .stat + .stat { padding-left: 12px; }
  .stat b { font-size: 24px; }
  .codecard pre { font-size: 13px; padding: 14px 16px; }
  .bars { grid-template-columns: minmax(0, 1fr) max-content; }
  .bars dt { grid-column: 1 / -1; margin-bottom: -6px; white-space: normal; }
  .multiples { grid-template-columns: minmax(0, 1fr); }
  .status li { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .family { grid-template-columns: minmax(0, 1fr); padding: 22px; }
  .prose h1 { font-size: 30px; }
  .prose h2 { font-size: 22px; }
  .pager { grid-template-columns: minmax(0, 1fr); }
  .pager .next { grid-column: 1; }
  .foot .right { margin-left: 0; }
}
figure.chart { margin: 0; }
.bars dt code { font-size: 13px; color: var(--text-2); }
.bars .track.budget { position: relative; }
.bars .track.budget::after { content: ""; position: absolute; left: 50%; top: -4px; bottom: -4px; border-left: 2px dashed var(--text-3); }
.bars .fill.over { background: var(--warn); }
.prose :not(pre) > code { overflow-wrap: anywhere; }

/* The screenshots of the examples on the ztk landing page. */
.shots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.shot { margin: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; min-width: 0; }
.shot.wide { grid-column: span 2; }
.shot.full { grid-column: 1 / -1; }
.shot.full img { max-height: 520px; }
.shot .frame { flex: 1; display: grid; place-items: center; min-height: 260px; padding: 28px 20px; background:
  radial-gradient(600px 240px at 50% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%), var(--bg-soft);
  border-bottom: 1px solid var(--line); }
.shot img { display: block; width: auto; height: auto; max-width: 100%; max-height: 380px; border-radius: 10px; border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.shot figcaption { padding: 16px 20px 18px; font-size: 15px; color: var(--text-2); line-height: 1.5; }
.shot figcaption b { display: block; color: var(--text); font-size: 17px; margin: 2px 0 4px; }
.shot figcaption code { font-size: 13px; color: var(--text-3); }
.shot figcaption a { text-decoration: none; }
.shot figcaption a:hover code { color: var(--accent); }
.shot .live-canvas { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.shot .live-canvas canvas { display: block; touch-action: none; }
.shot details.source { margin-top: 10px; font-size: 14px; }
.shot details.source summary { cursor: pointer; color: var(--accent); }
.shot details.source a { display: inline-block; margin: 6px 0; }
.shot details.source pre { max-height: 320px; overflow: auto; font-size: 12px; background: var(--bg-soft); padding: 10px; border-radius: 8px; }
@media (max-width: 960px) {
  .shots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .shots { grid-template-columns: minmax(0, 1fr); }
  .shot.wide, .shot.full { grid-column: auto; }
  .shot .frame { min-height: 0; padding: 20px 16px; }
}
.prose img { display: block; max-width: min(100%, 480px); height: auto; margin: 8px 0 20px; border-radius: 10px; border: 1px solid var(--line); }

/* Live snippets (assets/live.js): the code as an editor next to the running window. */
.o { color: var(--accent); }
.live-demo { margin: 8px 0 28px; display: grid; grid-template-columns: minmax(0, 1fr) auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.live-demo .ld-code { position: relative; min-width: 0; border-right: 1px solid var(--line); background: var(--code-bg); }
.live-demo .ld-code pre, .live-demo .ld-code textarea { margin: 0; padding: 14px 16px; border: 0; border-radius: 0; background: none; font: 13px/1.55 var(--mono); tab-size: 4; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; }
.live-demo .ld-code textarea { position: absolute; inset: 0; width: 100%; height: 100%; resize: none; overflow: hidden; color: transparent; caret-color: var(--text); outline: none; }
.live-demo .ld-code textarea::selection { background: var(--accent-soft); color: transparent; }
.live-demo .ld-code:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.live-demo .ld-view { display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; background: var(--bg-soft); position: relative; }
.live-demo .ld-frame { width: 360px; max-width: 100%; aspect-ratio: 3 / 2; border-radius: 8px; overflow: hidden; border: 1px solid var(--line-strong); box-shadow: var(--shadow); display: grid; place-items: center; background: var(--surface); }
.live-demo .ld-frame img { display: block; width: 100%; height: auto; }
.live-demo .ld-frame canvas { display: block; touch-action: none; }
.live-demo .ld-empty { color: var(--text-3); font-size: 14px; }
.live-demo .ld-bar { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--text-3); }
.live-demo .ld-bar button, .live-demo .ld-bar select, .live-demo .ld-bar a { font: inherit; color: var(--text-2); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; padding: 3px 10px; cursor: pointer; text-decoration: none; }
.live-demo .ld-bar button:hover, .live-demo .ld-bar a:hover { color: var(--accent); border-color: var(--accent); }
.live-demo .ld-tag { font-weight: 650; color: var(--text-3); }
.live-demo[data-live="1"] .ld-tag { color: var(--accent); }
.live-demo[data-live="loading"] .ld-tag::after { content: " (loading)"; font-weight: 400; }
.live-demo .ld-hud { margin-left: auto; font: 12px var(--mono); }
.live-demo .ld-err { grid-column: 1 / -1; margin: 0; padding: 10px 14px; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; color: var(--warn); background: var(--warn-soft); border-top: 1px solid var(--line); max-height: 10em; overflow: auto; }
@media (max-width: 1100px) {
  .live-demo { grid-template-columns: minmax(0, 1fr); }
  .live-demo .ld-code { border-right: 0; border-bottom: 1px solid var(--line); order: 2; }
  .live-demo .ld-view { order: 1; }
  .live-demo .ld-bar { order: 3; }
  .live-demo .ld-err { order: 4; }
}

/* The overview grid of the widgets page (tools/build-docs.py). */
.wgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin: 8px 0 32px; }
.wgrid .wcard { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none; }
.wgrid .wcard:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.wgrid picture { grid-column: 1 / -1; }
.wgrid img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; border-radius: 8px; border: 1px solid var(--line); }
.wgrid .wname { font-weight: 600; font-size: 15px; }
.wgrid .wkind { font: 12px var(--mono); color: var(--text-3); border: 1px solid var(--line-strong); border-radius: 999px; padding: 1px 8px; }

/* X-ray and Inspect of the live snippets. */
.live-demo .ld-frame { position: sticky; top: 76px; }
.live-demo .ld-view { place-items: start center; }
.live-demo .ld-layer { position: absolute; inset: 0; pointer-events: none; }
.live-demo .ld-layer.pick { pointer-events: auto; cursor: crosshair; }
.live-demo .ld-box, .live-demo .ld-cell, .live-demo .ld-hot { position: absolute; box-sizing: border-box; }
.live-demo .ld-box { border: 1.5px solid; background: color-mix(in srgb, currentColor 0%, transparent); }
.live-demo .ld-cell { border: 1px dashed var(--tok-str); opacity: .7; }
.live-demo .ld-hot { border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.live-demo .ld-hot::after { content: attr(data-label); position: absolute; left: -2px; top: -20px; font: 11px/18px var(--mono); padding: 0 6px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); white-space: nowrap; }
.live-demo .ld-bar button[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.live-demo .ld-inspect { position: fixed; z-index: 60; display: flex; flex-direction: column; box-sizing: border-box; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 14px; font-size: 13px; overflow: hidden; }
.live-demo .ld-inspect[hidden] { display: none; }
.live-demo .ld-inspect .ld-iscroll { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.live-demo .ld-inspect.sheet { left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 60vh; border-radius: 14px 14px 0 0; }
.live-demo .ld-inspect .ld-iclose { margin-left: auto; font-size: 12px; }
.live-demo .ld-ihead { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.live-demo .ld-ihead b { font-family: var(--mono); }
.live-demo .ld-ihead span { color: var(--text-3); font: 12px var(--mono); }
.live-demo .ld-note { margin: 4px 0 8px; color: var(--text-3); font-size: 12.5px; }
.live-demo .ld-inspect table { border-collapse: collapse; width: 100%; font: 12.5px var(--mono); }
.live-demo .ld-inspect td { padding: 2px 6px; border-bottom: 1px solid var(--line); }
.live-demo .ld-inspect tr.set td:first-child { color: var(--accent); font-weight: 600; }
.live-demo .ld-inspect input { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; width: 100%; box-sizing: border-box; }
.live-demo .ld-inspect input[type="color"] { width: 28px; padding: 0; margin-right: 4px; vertical-align: middle; }
.live-demo .ld-iopts td:nth-child(2) { display: flex; }
.live-demo .ld-inspect input.bad { border-color: var(--warn); }
.live-demo .ld-console { margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--code-bg); }
.live-demo .ld-console[hidden] { display: none; }
.live-demo .ld-console pre { margin: 0; padding: 6px 10px; height: 11em; overflow: auto; font: 12.5px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.live-demo .ld-console input { display: block; box-sizing: border-box; width: 100%; font: 13px var(--mono); color: var(--text); background: var(--surface); border: 0; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; padding: 6px 10px; }
/* The panel has one height for all tabs, so a change of tab moves nothing. */
.live-demo .ld-inspect:not(.sheet) { height: min(440px, calc(100vh - 16px)); }
.live-demo .ld-inspect.sheet { height: 60vh; }
.live-demo .ld-itabs { display: flex; gap: 2px; margin: 8px 0 0; border-bottom: 1px solid var(--line); }
.live-demo .ld-itabs button { font-size: 12px; padding: 4px 8px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text-3); border-radius: 0; cursor: pointer; }
.live-demo .ld-itabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.live-demo .ld-iopts td:first-child { width: 11.5em; white-space: nowrap; vertical-align: top; padding-top: 4px; }
.live-demo .ld-iopts td:nth-child(2) { flex-wrap: wrap; }
.live-demo .ld-iopts td:nth-child(2) input:not([type="color"]) { flex: 1 1 0; min-width: 0; }
.live-demo .ld-inspect .ld-isrc { flex: 0 0 100%; color: var(--text-3); font-size: 11.5px; padding: 1px 0 0 2px; overflow-wrap: anywhere; }
.live-demo .ld-inspect h4 { margin: 8px 0 2px; font: 600 12px var(--mono); }
.live-demo .ld-icode { margin: 0 0 4px; padding: 4px 6px; font: 12px/1.45 var(--mono); background: var(--code-bg); border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.live-demo .ld-iprobe { border-collapse: collapse; width: 100%; font-size: 12px; }
.live-demo .ld-iprobe td { padding: 1px 4px 1px 0; vertical-align: top; }
.live-demo .ld-iprobe td:first-child { color: var(--text-3); text-align: right; font: 12px/1.45 var(--mono); }
.live-demo .ld-iprobe td.ld-icode { width: 100%; margin: 0; padding: 0 4px; background: none; }
.live-demo .ld-iprobe button { font-size: 11px; padding: 1px 6px; }
.live-demo .ld-iprobe button[aria-pressed="true"] { background: var(--accent); color: var(--bg); }
.live-demo .ld-istop { margin: 6px 0; padding: 4px 6px; border-left: 3px solid var(--accent); }

/* The live snippet of the landing page: the window above the code. */
.live-demo.stack { grid-template-columns: minmax(0, 1fr); margin: 0; box-shadow: var(--shadow); }
.live-demo.stack .ld-code { border-right: 0; border-top: 1px solid var(--line); order: 2; }
.live-demo.stack .ld-view { order: 1; }
.live-demo.stack .ld-bar { order: 3; }
.live-demo.stack .ld-err { order: 4; }
.live-demo.stack .ld-frame { position: relative; top: auto; }

/* The replay player (assets/replay.js). */
.replay { margin: 8px 0 12px; }
.replay .rp-title { margin: 0 0 8px; font-size: 20px; }
.replay .rp-bar { display: flex; align-items: center; gap: 12px; margin: 8px 0 12px; font-size: 14px; color: var(--text-3); }
.replay .rp-bar input { flex: 1; accent-color: var(--accent); }
.replay .rp-bar button { font: inherit; color: var(--accent-ink); background: var(--accent); border: 0; border-radius: 6px; padding: 4px 14px; cursor: pointer; }
.replay .rp-chat { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.replay .rp-chat li { max-width: 85%; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.replay .rp-chat li.rp-person { justify-self: end; background: var(--accent-soft); }
.replay .rp-chat li.rp-now { border-color: var(--accent); }
.replay .rp-chat b { display: block; font-size: 12px; color: var(--text-3); }
.replay .rp-chat p { margin: 2px 0 0; }
.replay .rp-check { margin: 10px 0 0; font-size: 14px; }
.replay .rp-check.ok { color: var(--tok-str); }
.replay .rp-check.bad { color: var(--warn); }

/* A game (assets/toys.js): a closed frame of 16 by 9. The frame clips
   its content, and the game gets the keys only after a click on it. */
.live-demo.toy { grid-template-columns: minmax(0, 1fr); max-width: 880px; margin-inline: auto; }
.live-demo.toy .ld-view { display: block; padding: 0; overflow: hidden; contain: paint; isolation: isolate; aspect-ratio: 480 / 270; width: 100%; background: #0b0f1a; }
.live-demo.toy .ld-frame { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border: 0; border-radius: 0; box-shadow: none; }
.live-demo.toy .ld-frame canvas, .live-demo.toy .ld-frame img { width: 100% !important; height: 100% !important; display: block; }
.live-demo.toy.toy-active .ld-view { box-shadow: inset 0 0 0 3px var(--accent); }
.live-demo.toy.toy-active .ld-frame { inset: 3px; width: auto; height: auto; }
.toy-cover { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 16px; background: rgb(6 8 18 / 50%); }
.toy-cover[hidden] { display: none; }
.toy-go { font: 600 16px/1 var(--sans); padding: 12px 22px; border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; box-shadow: 0 6px 20px rgb(0 0 0 / 35%); }
.toy-go:hover { background: var(--accent-strong); }
.toy-go:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.toy-keys { margin: 0; max-width: 40ch; font-size: 13px; line-height: 1.45; color: #eceaf4; text-align: center; text-shadow: 0 1px 2px #000; }
.toy-touch { display: none; }
@media (pointer: coarse) {
  .toy-active .toy-touch { position: absolute; inset: auto 10px 10px; z-index: 3; display: flex; justify-content: space-between; align-items: end; pointer-events: none; }
  .toy-touch button { pointer-events: auto; width: 44px; height: 44px; border-radius: 50%; border: 0; font: 700 14px/1 var(--mono); color: #fff; background: rgb(255 255 255 / 22%); touch-action: none; }
  .toy-dpad { display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); }
  .toy-dpad [data-in="up"] { grid-area: 1 / 2; } .toy-dpad [data-in="left"] { grid-area: 2 / 1; } .toy-dpad [data-in="right"] { grid-area: 2 / 3; } .toy-dpad [data-in="down"] { grid-area: 3 / 2; }
  .toy-ab { display: flex; gap: 12px; }
}
.toy-controls { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 10px 12px; border-top: 1px solid var(--line); }
.toy-controls button { font: 500 13px/1 var(--sans); padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); cursor: pointer; }
.toy-controls button:hover { color: var(--text); border-color: var(--line-strong); }
.toy-controls button[aria-pressed="true"] { color: var(--text); border-color: var(--accent); }
.live-demo.toy .ld-more { border-top: 1px solid var(--line); }
.live-demo.toy .ld-more > summary { cursor: pointer; padding: 10px 14px; font-size: 14px; color: var(--text-2); }
.live-demo.toy .ld-more > summary:hover { color: var(--accent); }
.live-demo.toy .ld-more .ld-code { max-height: 560px; overflow: auto; border-right: 0; border-top: 1px solid var(--line); }
/* The picker of the Toys page. */
.toy-pick { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 8px 0 14px; }
.toy-pick button { display: grid; gap: 6px; padding: 6px 6px 8px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); color: var(--text-2); font: 600 14px/1.2 var(--sans); cursor: pointer; }
.toy-pick button img { display: block; width: 160px; height: 90px; border-radius: 7px; }
.toy-pick button:hover { border-color: var(--line-strong); color: var(--text); }
.toy-pick button[aria-pressed="true"] { border-color: var(--accent); color: var(--text); }
.toy-note { max-width: 720px; margin: 10px auto 0; }
.toy-note p { margin: 4px 0; }
/* A card of a widget page that links to its game. */
.toy-card { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: center; margin: 16px 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: inherit; text-decoration: none; }
.toy-card:hover { border-color: var(--accent); }
.toy-card img { display: block; width: 240px; height: auto; border-radius: 8px; }
.tc-text { display: grid; gap: 4px; }
.tc-kicker { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.tc-go { color: var(--accent); font-weight: 600; }
@media (max-width: 560px) { .toy-card { grid-template-columns: minmax(0, 1fr); } .toy-card img { width: 100%; } }

/* A folded section of a page: <!-- more: TITLE --> in the Markdown. */
details.more { margin: 16px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
details.more > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; color: var(--text-2); }
details.more[open] > summary { border-bottom: 1px solid var(--line); }
details.more > :not(summary) { margin-left: 14px; margin-right: 14px; }

/* The stage of a build replay (assets/stage.js): four panels of fixed
   size. A step changes their content, and only the steps and the code
   scroll, inside their boxes. */
.stage { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto 210px 270px; grid-template-areas: "bar bar" "view steps" "view code"; gap: 12px; margin: 16px 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-soft); outline: none; }
.stage:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }
.stage .st-bar { grid-area: bar; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.stage .st-bar button { font: inherit; min-width: 36px; padding: 4px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.stage .st-bar .st-play { background: var(--accent); color: var(--accent-ink); border-color: transparent; min-width: 72px; }
.stage .st-range { flex: 0 1 220px; accent-color: var(--accent); }
.stage .st-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage .st-steps { grid-area: steps; list-style: none; margin: 0; padding: 4px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 8px; }
.stage .st-steps li { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); opacity: 0.4; transition: opacity 0.25s ease, border-color 0.25s ease; }
.stage .st-steps li.st-person { margin-left: 16px; background: var(--accent-soft); }
.stage .st-steps li.st-done { opacity: 0.8; }
.stage .st-steps li.st-now { opacity: 1; border-color: var(--accent); }
.stage .st-steps b { display: block; font-size: 12px; color: var(--text-3); }
.stage .st-steps p { margin: 2px 0 0; font-size: 14px; line-height: 1.45; }
.stage .st-part { display: inline-block; margin-top: 6px; padding: 1px 8px; border-radius: 999px; font: 12px var(--mono); background: var(--bg-soft); border: 1px solid var(--line); }
.stage .st-code { grid-area: code; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.stage .st-code pre { margin: 0; padding: 10px 0; font: 11.5px/1.5 var(--mono); }
.stage .st-line { display: block; padding: 0 12px; white-space: pre; color: var(--text-2); }
.stage .st-new { color: var(--text); background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); animation: st-in 0.4s ease both; }
@keyframes st-in { from { opacity: 0; } to { opacity: 1; } }
.stage .st-view { grid-area: view; position: relative; align-self: start; overflow: hidden; }
.stage .st-view figure { margin: 0; border: 0; background: none; box-shadow: none; width: 500px; zoom: 0.8; }
.stage .st-view .ld-more, .stage .st-view .ld-bar, .stage .st-view .toy-keys { display: none; }
.stage .st-view .ld-view { padding: 4px 0; }
.stage .st-mark { position: absolute; left: 0; top: 0; pointer-events: none; border: 2px solid var(--accent); border-radius: 6px; opacity: 0; transition: transform 0.35s ease, width 0.35s ease, height 0.35s ease, opacity 0.25s ease; }
.stage .st-mark.on { opacity: 1; }
.stage .st-mark span { position: absolute; left: -2px; bottom: 100%; margin-bottom: 4px; padding: 1px 8px; border-radius: 6px; font: 600 12px var(--mono); white-space: nowrap; background: var(--accent); color: var(--accent-ink); }
@media (max-width: 900px) {
  .stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto 260px; grid-template-areas: "bar bar" "view view" "steps code"; }
  .stage .st-view { justify-self: center; width: min(400px, 100%); }
}
@media (max-width: 640px) {
  .stage .st-bar { flex-wrap: wrap; }
  .stage .st-range { flex: 1 1 120px; min-width: 0; }
  .stage .st-label { flex-basis: 100%; white-space: normal; }
  .stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 180px 220px; grid-template-areas: "bar" "view" "steps" "code"; padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .stage .st-steps li, .stage .st-mark { transition: none; }
  .stage .st-new { animation: none; }
}
.live-demo.wide { margin: 0 0 24px; }
.live-demo.wide .ld-more { order: 2; }
.live-demo.wide .ld-frame { width: 100%; max-width: var(--w); aspect-ratio: var(--ar); }
/* A showcase (assets/showcase.js): an app in the page itself, with no
   card and no toolbar. Its height follows its width. */
figure.showcase { margin: 24px 0 32px; max-width: none; position: relative; z-index: 5; background: var(--bg); box-shadow: 0 0 0 12px var(--bg); }
.showcase .sc-stage { position: relative; aspect-ratio: var(--ar); border-radius: 16px; overflow: hidden; background: #f7f5ff; display: grid; place-items: center; }
.showcase .sc-stage canvas { position: absolute; inset: 0; }
.showcase .sc-poster { margin: 0; padding: 16px; color: #4b4670; text-align: center; }
.showcase .sc-code { margin-top: 12px; }
.showcase .sc-code > summary { cursor: pointer; color: var(--text-2); font-size: 15px; }
.showcase .sc-code > summary:hover { color: var(--accent); }
.showcase .sc-code .ld-code { margin-top: 8px; }
.showcase .sc-code pre { max-height: 480px; overflow: auto; }
@media (max-width: 639px) { .showcase .sc-stage { aspect-ratio: var(--nar); border-radius: 12px; } }
.stage { position: relative; z-index: 5; }
@media (min-width: 1100px) {
  .stage { grid-template-rows: auto 250px 330px; }
  .stage .st-view figure { zoom: 1; width: 600px; }
  .stage .st-view .ld-frame { width: 560px; }
}
/* A phone: the links of the top bar fit with less space, so the page
   has no sideways scroll. */
@media (max-width: 480px) {
  .top .wrap { gap: 8px; }
  .logo { gap: 6px; font-size: 16px; }
  .toplinks { gap: 0; min-width: 0; }
  .toplinks a { padding: 6px 4px; font-size: 13.5px; }
  .toplinks .sib { gap: 4px; }
}
/* The landing page has six links: its GitHub link is also at the end of
   the page. */
@media (max-width: 420px) {
  .toplinks a[href^="https://github.com"]:nth-child(6) { display: none; }
}
