@font-face { font-family: "VCR"; src: url("fonts/vcr.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "VCR"; src: url("fonts/vcr-bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --bg: #000000;
  --side: #05050c;
  --box: #0b0b1a;
  --rule: #23233f;
  --text: #f1f3ff;
  --muted: #9a9fc4;
  --link: #00faff;
  --visited: #c3a8ff;
  --accent: #00faff;
  --on-accent: #000000;
  --blue: #0000ff;
  --h3: #c3a8ff;
  --code-bg: #07071a;
  --code-ink: #dbe2ff;

  --tok-keyword: #c3a8ff;
  --tok-string: #8be9c5;
  --tok-number: #ffb86b;
  --tok-comment: #7f8bbd;
  --tok-func: #6fc8ff;

  --font: system-ui, "Segoe UI", Roboto, sans-serif;
  --vcr: "VCR", Consolas, monospace;
  --mono: Consolas, "Cascadia Mono", Menlo, monospace;
  --side-w: 250px;
  --topbar-h: 54px;
  --cursor: url("cursor/cursor-default.png") 0 0, auto;
  --cursor-pointer: url("cursor/cursor-pointer.png") 8 0, pointer;
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --side: #f1f3fb;
  --box: #f1f3fb;
  --rule: #cdd2ea;
  --text: #0a0c1f;
  --muted: #4a5070;
  --link: #0000ff;
  --visited: #6a2fc0;
  --accent: #0000ff;
  --on-accent: #ffffff;
  --h3: #6a2fc0;
  --code-bg: #f1f3fb;
  --code-ink: #0a0c1f;

  --tok-keyword: #6a2fc0;
  --tok-string: #0b6b4f;
  --tok-number: #9a4a00;
  --tok-comment: #6b7391;
  --tok-func: #0a47c9;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar-h) + 14px); cursor: var(--cursor); }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--font); }
::selection { background: #00faff; color: #000; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--accent); color: var(--on-accent); padding: 8px 12px; z-index: 300; }
.skip:focus { top: 8px; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

a { color: var(--link); }
a:visited { color: var(--visited); }
a, button, label, select, summary { cursor: var(--cursor-pointer); }
input[type="search"] { cursor: text; }

.brand { display: block; color: var(--text); text-decoration: none; font: 700 20px var(--vcr); }
.brand:visited { color: var(--text); }
.brand em { font-style: normal; color: var(--link); }
.side-logo, .home-logo { display: block; transition: transform 0.12s; }
.brand:hover .side-logo, .home-logo:hover { transform: scale(1.04); }

.topbar {
  display: none; position: fixed; inset: 0 0 auto 0; height: var(--topbar-h);
  align-items: center; gap: 4px; padding: 0 8px; background: var(--side); border-bottom: 2px solid var(--rule); z-index: 30;
}
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; color: var(--text); }
.scrim { display: none; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--side); border-right: 2px solid var(--rule);
  display: flex; flex-direction: column; padding: 14px 0 0; z-index: 40; overflow: hidden;
}
.sidebar .brand { padding: 0 20px 8px; }
.side-logo { width: 130px; margin: 0 auto; }
.search { margin: 4px 16px 10px; }
.search input { width: 100%; height: 38px; padding: 0 10px; background: var(--bg); color: var(--text); border: 2px solid var(--rule); border-radius: 0; font: 15px var(--font); }
.search input:focus { outline: none; border-color: var(--accent); }
.search input::placeholder { color: var(--muted); }
#nav, #results { flex: 1; overflow-y: auto; padding-bottom: 12px; }
#nav[hidden], #results[hidden] { display: none; }
.grp p { margin: 16px 20px 4px; font: 700 14px var(--vcr); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.grp ul, #results ul { list-style: none; margin: 0; padding: 0; }
.grp a { display: block; padding: 6px 20px; color: var(--text); text-decoration: none; font: 15px var(--vcr); transition: transform 0.1s; }
.grp a:hover { color: var(--link); transform: translateX(5px); }
.grp a.on { background: var(--accent); color: var(--on-accent); font-weight: 700; transform: none; }
#results a { display: block; padding: 8px 20px; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--rule); }
#results a:hover { background: var(--box); }
#results b { display: block; font-family: var(--vcr); }
#results small { color: var(--muted); font-size: 13px; }
#results span { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.none { padding: 0 20px; color: var(--muted); }
.side-foot { display: flex; justify-content: center; padding: 12px 18px 16px; border-top: 2px solid var(--rule); }

.text-btn, .codebar button {
  background: transparent; color: var(--accent); border: 2px solid var(--accent); border-radius: 0;
  font: 14px var(--vcr); padding: 4px 14px; min-height: 32px;
}
.text-btn:hover, .codebar button:hover { background: var(--accent); color: var(--on-accent); }

main { margin-left: var(--side-w); outline: none; padding: 44px 48px 110px; min-height: 100vh; }
main:focus, main:focus-visible { outline: none; }
#doc, .pager { max-width: 800px; }

#doc h1, #doc h2, #doc h3, #doc h4 { line-height: 1.25; position: relative; }
#doc h1 { font: 700 34px/1.15 var(--vcr); text-transform: uppercase; letter-spacing: 0.02em; margin: 0 0 22px; }
#doc h2 { font: 700 24px/1.25 var(--vcr); color: var(--link); margin: 44px 0 14px; padding-bottom: 6px; border-bottom: 2px solid var(--rule); }
#doc h3 { font: 700 19px/1.3 var(--vcr); color: var(--h3); margin: 28px 0 8px; }
#doc h4 { font-size: 16px; margin: 20px 0 6px; }
#doc .anchor { position: absolute; left: -22px; color: var(--muted); text-decoration: none; opacity: 0; font-family: var(--font); }
#doc h2:hover .anchor, #doc h3:hover .anchor, #doc h4:hover .anchor, #doc .anchor:focus { opacity: 1; }
#doc p, #doc li { max-width: 70ch; }
#doc p { margin: 0 0 14px; }
#doc ul, #doc ol { padding-left: 26px; margin: 0 0 16px; }
#doc li { margin: 4px 0; }
#doc li::marker { color: var(--link); }
#doc hr { border: 0; border-top: 2px solid var(--rule); margin: 28px 0; }

#doc code { font: 0.9em var(--mono); background: var(--code-bg); border: 1px solid var(--rule); padding: 0 5px; overflow-wrap: anywhere; }
.code { position: relative; margin: 0 0 20px; background: var(--code-bg); border: 2px solid var(--rule); }
.codebar span { display: none; }
.codebar button { position: absolute; top: 6px; right: 6px; font-size: 13px; padding: 2px 10px; min-height: 28px; opacity: 0; background: var(--bg); }
.code:hover .codebar button, .codebar button:focus-visible { opacity: 1; }
@media (hover: none) { .codebar button { opacity: 1; } }
#doc pre { margin: 0; padding: 14px 16px; overflow-x: auto; color: var(--code-ink); font: 14px/1.55 var(--mono); tab-size: 4; }
#doc pre code { background: none; border: 0; padding: 0; font: inherit; }
.hljs-keyword, .hljs-literal, .hljs-built_in { color: var(--tok-keyword); }
.hljs-string { color: var(--tok-string); }
.hljs-number { color: var(--tok-number); }
.hljs-comment { color: var(--tok-comment); font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-attr { color: var(--tok-func); }

#doc blockquote { margin: 0 0 20px; padding: 10px 16px; background: var(--box); border: 2px solid var(--blue); max-width: 70ch; }
#doc blockquote p:last-child { margin: 0; }

.tbl { overflow-x: auto; margin: 0 0 20px; border: 2px solid var(--rule); }
#doc table { border-collapse: collapse; width: 100%; font-size: 15px; }
#doc th { text-align: left; background: var(--blue); color: #fff; font: 700 15px var(--vcr); }
#doc th, #doc td { padding: 8px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
#doc tr:last-child td { border-bottom: 0; }
#doc td:first-child { white-space: nowrap; }

#doc ul.chips { list-style: none; padding: 0; columns: 18em; column-gap: 24px; max-width: none; }
#doc ul.chips li { margin: 0; max-width: none; break-inside: avoid; }
#doc ul.chips code { background: none; border: 0; padding: 0; font-size: 14px; }

.home-top { display: flex; align-items: center; gap: 32px; margin-bottom: 8px; }
.home-top > div { flex: 1; min-width: 0; }
.home-logo { width: 230px; flex: none; }

.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 56px; }
.pager a { display: block; min-width: 190px; padding: 8px 16px; color: var(--accent); text-decoration: none; font: 700 17px var(--vcr); border: 2px solid var(--accent); }
.pager a:visited { color: var(--accent); }
.pager a:hover { background: var(--accent); color: var(--on-accent); }
.pager small { display: block; font: 13px var(--vcr); opacity: 0.8; }
.pager .next { text-align: right; margin-left: auto; }

.ai-note {
  position: fixed; right: 20px; bottom: 22px; z-index: 50; pointer-events: none;
  background: #e11d2e; color: #fff; font: 700 15px var(--vcr); padding: 8px 16px; border-radius: 16px 16px 3px 16px;
}
.ai-note::after { content: ""; position: absolute; right: 12px; bottom: -7px; width: 14px; height: 14px; background: #e11d2e; transform: rotate(45deg); z-index: -1; }

#intro {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: #72b6ff;
  border-bottom: 10px solid #00faff; box-shadow: 0 10px 0 #000, 0 30px 0 #0000ff;
  animation: introExit 0.6s cubic-bezier(0.7, 0, 0.25, 1) 1.2s forwards;
}
#intro.leave { animation-delay: 0s; animation-duration: 0.25s; }
#intro img { width: min(300px, 60vw); animation: logoIn 0.75s cubic-bezier(0.2, 1.6, 0.4, 1) both, logoBop 0.45s ease-in-out 0.8s; }
@keyframes logoIn { from { transform: scale(0.15) rotate(-14deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes logoBop { 50% { transform: scale(1.09) rotate(2deg); } }
@keyframes introExit { to { transform: translateY(calc(-100% - 40px)); } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes slideIn { from { transform: translateX(-110%); } }
main { animation: rise 0.5s ease-out 1.25s backwards; }

@media (min-width: 900px) {
  .sidebar { animation: slideIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.1) 1.15s backwards; }
}

@media (max-width: 899px) {
  .topbar { display: flex; }
  .desktop-only { display: none; }
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; padding-top: 8px; }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 35; }
  main { margin: 0; padding: calc(var(--topbar-h) + 24px) 16px 96px; }
  #doc .anchor { display: none; }
  #doc h1 { font-size: 28px; }
  .home-top { flex-direction: column-reverse; align-items: flex-start; gap: 16px; }
  .home-logo { width: 170px; }
  .ai-note { right: 12px; bottom: 16px; font-size: 13px; padding: 6px 12px; }
  .pager a { min-width: 0; flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #intro { display: none; }
  main, .sidebar { animation: none; }
  * { transition: none !important; }
}

.pop { position: fixed; width: 8px; height: 8px; margin: -4px 0 0 -4px; border: 2px solid var(--accent); border-radius: 50%; pointer-events: none; z-index: 250; animation: pop 0.45s ease-out forwards; }
@keyframes pop { to { transform: scale(5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pop { display: none; } }
.trail { position: fixed; width: 7px; height: 7px; margin: -3px 0 0 -3px; background: var(--accent); border-radius: 50%; pointer-events: none; z-index: 249; animation: trail 0.45s ease-out forwards; }
@keyframes trail { from { opacity: 0.8; } to { opacity: 0; transform: scale(0.2); } }
@media (prefers-reduced-motion: reduce) { .trail { display: none; } }

.no-intro #intro { display: none; }
.no-intro main, .no-intro .sidebar { animation-delay: 0s !important; }

#progress {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60; pointer-events: none;
  background: linear-gradient(90deg, #00faff, #0000ff, #8b5cf6); transform: scaleX(0); transform-origin: 0 50%;
}

.topbar .brand { flex: 1; }
.search { position: relative; }
.search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none;
  font: 12px var(--mono); color: var(--muted); border: 1px solid var(--rule); padding: 0 6px; line-height: 18px;
}
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }
#results mark, #doc mark { background: var(--accent); color: var(--on-accent); padding: 0 1px; }

.side-foot { flex-wrap: wrap; gap: 8px; }
.side-foot .text-btn { flex: 1; min-width: 0; }
#install-btn { background: var(--accent); color: var(--on-accent); }
#install-btn:hover { filter: brightness(1.15); }
#install-btn[hidden] { display: none; }
.ver { flex-basis: 100%; margin: 2px 0 0; text-align: center; font: 12px var(--vcr); color: var(--muted); }
.ver:empty { display: none; }

.toc {
  position: fixed; top: 44px; right: 24px; width: 220px; max-height: calc(100vh - 160px); overflow-y: auto;
  padding: 4px 0 4px 14px; border-left: 2px solid var(--rule); display: none;
}
.toc p { margin: 0 0 8px; font: 700 13px var(--vcr); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; padding: 3px 0; font-size: 13.5px; line-height: 1.35; color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--link); }
.toc a.on { color: var(--accent); font-weight: 700; }
@media (min-width: 1400px) { .toc:not([hidden]) { display: block; } }

.to-top {
  position: fixed; right: 20px; bottom: 76px; z-index: 50; width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--bg); color: var(--accent); border: 2px solid var(--accent); border-radius: 0;
}
.to-top:hover { background: var(--accent); color: var(--on-accent); }
.to-top[hidden] { display: none; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 260;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  background: var(--box); color: var(--text); border: 2px solid var(--accent); padding: 10px 14px;
  font: 14px var(--vcr); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35); animation: toastIn 0.25s ease-out;
}
.toast[hidden] { display: none; }
.toast button { background: var(--accent); color: var(--on-accent); border: 0; font: 700 14px var(--vcr); padding: 6px 12px; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } }

body.offline .topbar, body.offline .side-foot { box-shadow: inset 0 -3px 0 #e11d2e; }

.standalone .ai-note { display: none; }
.standalone .to-top { bottom: 24px; }
.topbar { padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
.sidebar { padding-bottom: env(safe-area-inset-bottom); }

@media (max-width: 899px) {
  main { padding-top: calc(var(--topbar-h) + env(safe-area-inset-top) + 24px); padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .sidebar { padding-top: calc(8px + env(safe-area-inset-top)); }
  .to-top { right: 12px; bottom: 64px; }
  .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  html { scroll-behavior: auto; }
}

.loading { color: var(--muted); font-family: var(--vcr); }
.side-logo { height: auto; }
#intro img { height: auto; }
.home-logo { height: auto; }

body.tool #doc, body.tool .pager { max-width: 1240px; }
.gen-intro p { max-width: 70ch; }
.gen-wrap { display: grid; gap: 28px; align-items: start; }
@media (min-width: 1240px) { .gen-wrap { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); } }
.gen-form h2:first-child { margin-top: 8px; }
#doc .gen-form h2 { margin: 30px 0 12px; }
#doc .gen-form h3 { margin: 16px 0 8px; font-size: 15px; color: var(--muted); }

.gen-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.gen-tab { background: transparent; color: var(--accent); border: 2px solid var(--accent); font: 700 14px var(--vcr); padding: 8px 14px; min-height: 40px; }
.gen-tab.on { background: var(--accent); color: var(--on-accent); }
.gen-tab:not(.on):hover { background: var(--box); }

.gen-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { background: var(--box); color: var(--text); border: 2px solid var(--rule); font: 13px var(--vcr); padding: 5px 12px; min-height: 34px; }
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }

.gen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; }
.gen-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.gen-field input[type="text"], .gen-field input[type="number"], .gen-field select {
  width: 100%; height: 36px; padding: 0 8px; background: var(--bg); color: var(--text);
  border: 2px solid var(--rule); border-radius: 0; font: 14px var(--mono);
}
.gen-field input:focus, .gen-field select:focus { outline: none; border-color: var(--accent); }
.gen-field input[type="color"] { width: 100%; height: 36px; padding: 2px; background: var(--bg); border: 2px solid var(--rule); border-radius: 0; }
.gen-check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); align-self: end; min-height: 36px; }
.gen-check input, .gen-card-head input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }

.gen-features { display: grid; gap: 10px; }
.gen-card { border: 2px solid var(--rule); background: var(--box); transition: border-color 0.12s; }
.gen-card.on { border-color: var(--accent); }
.gen-card-head { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; }
.gen-card-head input { margin-top: 3px; }
.gen-card-head b { display: block; font: 700 15px var(--vcr); color: var(--text); }
.gen-card-head small { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; }
.gen-card > .gen-grid { display: none; padding: 2px 12px 14px 40px; }
.gen-card.on > .gen-grid { display: grid; }

.gen-out { position: sticky; top: 20px; min-width: 0; }
.gen-out-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-bottom: 8px; font: 13px var(--vcr); color: var(--muted); }
#doc .gen-path { font-size: 13px; overflow-wrap: anywhere; }
.gen-code { margin-bottom: 12px; }
#doc .gen-code pre { max-height: min(62vh, 640px); overflow: auto; }
.gen-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.gen-actions .text-btn { min-height: 38px; padding: 4px 16px; }
.text-btn.solid { background: var(--accent); color: var(--on-accent); }
.text-btn.solid:hover { filter: brightness(1.15); }
.gen-used { margin: 12px 0 4px; color: var(--muted); font-size: 14px; }
.gen-doc { font-size: 14px; }
.link-btn { margin-top: 18px; background: none; border: 0; padding: 0; color: var(--muted); font: 13px var(--vcr); text-decoration: underline; }
.link-btn:hover { color: #e11d2e; }

@media (max-width: 1239px) {
  .gen-out { position: static; }
}
@media (max-width: 899px) {
  .gen-card > .gen-grid { padding-left: 12px; }
  .gen-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

.gen-jump { display: none; }
@media (max-width: 1239px) {
  .gen-jump:not([hidden]) {
    display: flex; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 55;
    align-items: center; gap: 8px; background: var(--accent); color: var(--on-accent); border: 0; padding: 10px 18px;
    font: 700 14px var(--vcr); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
  }
  body.tool .ai-note, body.tool .to-top { display: none; }
}
@media (max-width: 899px) {
  .gen-tab { flex: 1 1 100%; }
}
@media (max-width: 1239px) {
  body.tool .toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
}

.pal-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: calc(100% - 32px); margin: -2px 16px 10px;
  background: var(--box); color: var(--muted); border: 2px solid var(--rule); font: 13px var(--vcr); padding: 6px 10px; min-height: 34px;
}
.pal-btn:hover { border-color: var(--accent); color: var(--accent); }
.pal-btn kbd, .pal-foot kbd { font: 11px var(--mono); border: 1px solid var(--rule); padding: 0 5px; line-height: 17px; color: var(--muted); background: var(--bg); }
@media (max-width: 899px) { .pal-btn kbd { display: none; } }

.pal { position: fixed; inset: 0; z-index: 300; background: rgba(0, 0, 10, 0.55); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.pal[hidden] { display: none; }
.pal-box { width: min(640px, 100%); max-height: 70vh; display: flex; flex-direction: column; background: var(--bg); border: 2px solid var(--accent); box-shadow: 0 10px 0 rgba(0, 0, 0, 0.35); animation: palIn 0.14s ease-out; }
@keyframes palIn { from { opacity: 0; transform: translateY(-8px); } }
.pal-q { flex: none; height: 52px; padding: 0 16px; border: 0; border-bottom: 2px solid var(--rule); background: transparent; color: var(--text); font: 17px var(--font); outline: none; }
.pal-q::placeholder { color: var(--muted); }
.pal-list { list-style: none; margin: 0; padding: 6px 0; overflow-y: auto; overscroll-behavior: contain; }
.pal-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; cursor: pointer; }
.pal-list li.on { background: var(--accent); color: var(--on-accent); }
.pal-list li.on small, .pal-list li.on .pal-tag { color: var(--on-accent); }
.pal-main { min-width: 0; display: flex; flex-direction: column; }
.pal-main code { font: 14px var(--mono); overflow-wrap: anywhere; }
.pal-main small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-tag { flex: none; font: 11px var(--vcr); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.pal-none { color: var(--muted); cursor: default; }
.pal-foot { display: flex; gap: 16px; margin: 0; padding: 8px 16px; border-top: 2px solid var(--rule); font-size: 12px; color: var(--muted); }
@media (max-width: 899px) {
  .pal { padding: calc(8px + env(safe-area-inset-top)) 8px 8px; }
  .pal-box { max-height: calc(100vh - 16px); }
  .pal-foot { display: none; }
}
body.pal-open { overflow: hidden; }

#doc a.api-ref { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--link); }
#doc a.api-ref:hover { border-bottom-style: solid; background: var(--box); }
#doc pre a.api-ref { border-bottom-color: color-mix(in srgb, var(--link) 60%, transparent); }
.api-tip {
  position: fixed; z-index: 280; max-width: min(460px, calc(100vw - 16px)); pointer-events: none;
  background: var(--bg); border: 2px solid var(--accent); padding: 8px 10px; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
}
.api-tip[hidden] { display: none; }
.api-tip code { display: block; font: 13.5px var(--mono); color: var(--text); overflow-wrap: anywhere; }
.api-tip span { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
#doc code.def { color: var(--text); }
@keyframes flashIn { 0%, 30% { background: color-mix(in srgb, var(--accent) 30%, transparent); } 100% { background: transparent; } }
#doc .flash { animation: flashIn 1.6s ease-out; }

.codebar button.try { right: 74px; }

.pg-lead { max-width: 75ch; color: var(--muted); }
.ai-bar { display: grid; grid-template-columns: minmax(0, 1fr) 150px 150px; gap: 10px; margin: 8px 0 6px; }
.ai-bar input[type="search"] { width: 100%; height: 36px; padding: 0 8px; background: var(--bg); color: var(--text); border: 2px solid var(--rule); border-radius: 0; font: 14px var(--mono); }
.ai-bar input[type="search"]:focus { outline: none; border-color: var(--accent); }
.ai-count { color: var(--muted); font-size: 13px; }
.ai-list { border-top: 2px solid var(--rule); }
.ai-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--rule); }
.ai-row[hidden] { display: none; }
.ai-row:hover { background: var(--box); }
.ai-row a { text-decoration: none; min-width: 0; }
#doc .ai-row code { background: none; border: 0; padding: 0; font-size: 14px; color: var(--link); }
.ai-meta { font-size: 13px; color: var(--muted); min-width: 0; }
.ai-tag { font: 11px var(--vcr); text-transform: uppercase; padding: 1px 5px; border: 1px solid currentColor; margin-right: 4px; }
.ai-tag.luaslice { color: var(--accent); }
.ai-tag.psych { color: #c084fc; }
.ai-copy { background: none; border: 1px solid var(--rule); color: var(--muted); font: 12px var(--vcr); padding: 2px 8px; opacity: 0; }
.ai-row:hover .ai-copy, .ai-copy:focus-visible { opacity: 1; }
@media (hover: none) { .ai-copy { opacity: 1; } }
@media (max-width: 699px) {
  .ai-bar { grid-template-columns: 1fr 1fr; }
  .ai-q { grid-column: 1 / -1; }
  .ai-row { grid-template-columns: minmax(0, 1fr) auto; }
  .ai-meta { grid-column: 1; grid-row: 2; }
  .ai-copy { grid-row: 1 / span 2; grid-column: 2; }
}

.pg-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin: 12px 0; }
.pg-wrap { display: grid; gap: 20px; align-items: start; }
@media (min-width: 1240px) { .pg-wrap { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
.pg-left { min-width: 0; }
.pg-editor {
  --pg-font: 14px; --pg-lh: 21px; --pg-pad: 12px;
  display: flex; height: min(60vh, 560px); min-height: 300px; background: var(--code-bg); border: 2px solid var(--rule); overflow: hidden; position: relative;
}
.pg-editor:focus-within { border-color: var(--accent); }
.pg-gutter {
  flex: none; width: 44px; padding: var(--pg-pad) 8px var(--pg-pad) 0; text-align: right; color: var(--muted); opacity: 0.7;
  font: var(--pg-font)/var(--pg-lh) var(--mono); border-right: 1px solid var(--rule); user-select: none; will-change: transform;
}
.pg-gutter span { display: block; }
.pg-gutter span.err { color: #fff; background: #e11d2e; opacity: 1; }
.pg-area { position: relative; flex: 1; min-width: 0; overflow: hidden; }
#doc .pg-hl, .pg-input {
  position: absolute; top: 0; left: 0; margin: 0; padding: var(--pg-pad); border: 0;
  font: var(--pg-font)/var(--pg-lh) var(--mono); letter-spacing: 0; tab-size: 4; white-space: pre; word-wrap: normal;
}
#doc .pg-hl { min-width: 100%; min-height: 100%; overflow: visible; pointer-events: none; color: var(--code-ink); will-change: transform; }
#doc .pg-hl code { font: inherit; }
.pg-input {
  width: 100%; height: 100%; resize: none; overflow: auto; background: transparent; color: transparent; caret-color: var(--text);
  outline: none; -webkit-text-fill-color: transparent;
}
.pg-input::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); -webkit-text-fill-color: transparent; }
#doc .pg-status { margin: 8px 0 12px; font: 13px var(--mono); color: var(--muted); min-height: 1.4em; }
.pg-status.good { color: #22c55e; }
.pg-status.bad { color: #ef4444; }
.pg-sim { border: 2px solid var(--rule); padding: 8px 12px; }
.pg-sim summary { cursor: pointer; font: 700 14px var(--vcr); }
.pg-sim .gen-grid { margin-top: 10px; }
.pg-out { min-width: 0; border: 2px solid var(--rule); background: var(--code-bg); display: flex; flex-direction: column; height: min(72vh, 700px); min-height: 320px; }
.pg-out-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 12px; border-bottom: 2px solid var(--rule); }
.pg-out-head b { font: 700 14px var(--vcr); }
.pg-out-head .gen-check { min-height: 0; font-size: 13px; }
.pg-out-head .link-btn { margin: 0 0 0 auto; }
.pg-stats { color: var(--muted); font: 12px var(--mono); }
.pg-console { flex: 1; overflow: auto; padding: 8px 0; font: 13px/1.5 var(--mono); }
#doc .pg-line { margin: 0; padding: 1px 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: none !important; }
#doc .pg-hook { color: var(--link); font-weight: 700; margin-top: 6px; }
.pg-call { color: var(--muted); padding-left: 26px; }
.pg-print, .pg-info { color: var(--text); padding-left: 26px; }
.pg-info::before { content: "info "; color: #22c55e; }
.pg-warn { color: #eab308; padding-left: 26px; }
#doc .pg-error { color: #fff; background: #b91c1c; margin: 6px 0; padding: 4px 12px; }
.pg-muted { color: var(--muted); }
.hide-calls .pg-call { display: none; }
@media (max-width: 899px) {
  .pg-editor { height: 52vh; --pg-font: 13px; --pg-lh: 20px; }
  .pg-gutter { width: 36px; }
  .pg-out { height: 60vh; }
}
