/* Page chrome for the library and designer. Tokens follow styles.css; one class per theme on <body>. */
.ui-dark  { --page:#1a1918; --text:#f3f2f2; --muted:rgba(243,242,242,.7); --rule:rgba(243,242,242,.4); --hair:rgba(243,242,242,.15); --active:var(--color-accent); --kicker:var(--color-accent-400); --field:rgba(255,255,255,.04); --warn:#ff8a78; }
.ui-gold  { --page:#101010; --text:#f3f2f2; --muted:rgba(243,242,242,.7); --rule:rgba(217,164,65,.5); --hair:rgba(243,242,242,.14); --active:#0a7d50; --kicker:#e3bb67; --field:rgba(255,255,255,.04); --warn:#ff8a78; }
.ui-light { --page:#f3f2f2; --text:#201e1d; --muted:#5b5856; --rule:#201e1d; --hair:rgba(32,30,29,.2); --active:var(--color-accent); --kicker:var(--color-accent-700); --field:#fff; --warn:#b3261e; }
body { background:var(--page); color:var(--text); }

.wrap { max-width:1600px; margin:0 auto; padding:32px 24px 64px; display:flex; flex-direction:column; gap:20px; }
.top { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:flex-start; gap:16px 32px; border-bottom:2px solid var(--rule); padding-bottom:16px; }
.intro { flex:1 1 480px; min-width:0; display:flex; flex-direction:column; gap:8px; }
.intro h1 { margin:0; font-size:40px; line-height:1.05; }
.intro p { margin:0; max-width:680px; font-size:15px; line-height:1.5; text-wrap:pretty; }
.nav { display:flex; gap:8px 16px; flex-wrap:wrap; font-size:13px; font-weight:600; letter-spacing:.08em; text-transform:uppercase; }
.nav a { color:var(--muted); text-decoration:none; }
.nav a:hover { color:var(--active); }
.nav .on { color:var(--kicker); border-bottom:2px solid var(--kicker); }
.cap { font-size:12px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; }
.hint { color:var(--muted); font-size:13px; line-height:1.45; margin:0 0 8px; }
.status { font-size:13px; color:var(--muted); }
.export { display:flex; flex-direction:column; align-items:flex-start; gap:6px; }
.btns { display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
.bar { display:flex; flex-wrap:wrap; gap:12px 32px; align-items:center; border-bottom:2px solid var(--rule); padding-bottom:14px; }
.grp { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.grp[hidden], .seg[hidden] { display:none; }
.seg { display:flex; flex-wrap:wrap; }
.seg button + button { margin-left:-2px; }

button { font:600 13px var(--font-body); padding:6px 12px; border:2px solid var(--text); background:transparent; color:var(--text); cursor:pointer; border-radius:0; text-align:left; }
button:hover { border-color:var(--active); }
button[aria-pressed="true"] { background:var(--active); color:#fff; }
button.primary { background:var(--active); border-color:var(--active); color:#fff; font-weight:700; font-size:14px; padding:8px 14px; }
button.outline { border-color:var(--active); font-weight:700; font-size:14px; padding:8px 14px; }
button.tight { padding:4px 10px; font-size:12px; }
input, textarea, select { font:500 13px var(--font-body); color:var(--text); background:var(--field); border:1px solid var(--hair); border-radius:0; padding:6px 8px; min-width:0; }
select { border:2px solid var(--text); background:var(--page); padding:5px 8px; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible { outline:2px solid var(--active); outline-offset:2px; }

/* preview + form */
.grid { display:grid; grid-template-columns:minmax(0,1fr) minmax(460px,1fr); gap:24px; align-items:start; }
#previewCol { position:sticky; top:12px; height:calc(100vh - 24px); display:flex; flex-direction:column; min-width:0; }
#previewBar { display:flex; flex-wrap:wrap; gap:6px 12px; align-items:center; padding:10px 14px; font-size:13px; }
#previewBar .hint { margin:0 auto 0 0; }
#warnSum { color:var(--warn); font-weight:600; }
/* the drawing scales to fit the preview box (viewBox + preserveAspectRatio), never past it */
#stage { flex:1; min-height:0; position:relative; touch-action:none; }
#stage > p { margin:6px 14px; }
#stage > svg, #stage > .duo { position:absolute; inset:4px 14px 14px; width:calc(100% - 28px); height:calc(100% - 18px); display:block; }
#stage .duo { display:flex; gap:12px; }
#stage .duo > svg { flex:1 1 0; min-width:0; height:100%; }
#stage [data-key] { cursor:grab; }
#stage.dragging, #stage.dragging [data-key] { cursor:grabbing; }

#formCol h2 { font-size:15px; font-weight:700; margin:26px 0 6px; padding-top:12px; border-top:2px solid var(--rule); }
#formCol > h2:first-child { margin-top:0; border-top:0; padding-top:0; }
.meta { display:grid; grid-template-columns:1fr 1fr 110px; gap:8px; }
.meta .full { grid-column:1/-1; }
.meta label span { display:block; font-size:12px; color:var(--muted); margin-bottom:2px; }
.meta input, .meta textarea { width:100%; }
.meta textarea { min-height:56px; resize:vertical; }
.meta.links { grid-template-columns:1fr 1fr; margin-top:8px; }
.meta textarea.code { font:12px/1.4 ui-monospace,Consolas,monospace; min-height:84px; }
.fprow { display:flex; align-items:center; gap:8px; margin-top:10px; flex-wrap:wrap; }
.fprow .hint { margin:0; }
.builds { margin-top:8px; display:grid; gap:6px; }
.builds .xchk { margin:0 0 4px; }
.build { display:flex; flex-wrap:wrap; align-items:center; gap:4px 14px; padding:6px 10px; border:2px solid var(--hair); }
.build.on { border-color:var(--kicker); }
.build .hint { margin:0; flex:1 1 160px; }
.lgrid { display:grid; gap:0 8px; align-items:start; }
.colhead { font-size:12px; color:var(--muted); padding:2px 0 4px; border-bottom:1px solid var(--hair); margin-bottom:4px; }
.rowid { font-size:13px; font-weight:700; padding:6px 0 0; cursor:pointer; white-space:nowrap; display:flex; flex-direction:column; line-height:1.15; overflow:hidden; }
.rowid small { font-size:11px; font-weight:500; color:var(--muted); text-overflow:ellipsis; overflow:hidden; }
.rowid .mtype { align-self:flex-start; margin-top:2px; padding:0 5px; font-size:10px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; border-width:1px; border-color:currentColor; color:inherit; }
.cell { padding:3px 0; }
.cell input { width:100%; font-size:14px; }
.cell input.l2 { font-size:13px; }
.cell input.modin { border-left:3px solid var(--mcol); }
.cell input.own { box-shadow:inset 0 -2px 0 var(--kicker); }
.meta.modes { grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); }
.meta.modes select { width:100%; }
.modebar { position:sticky; top:0; z-index:5; display:flex; flex-wrap:wrap; align-items:center; gap:6px 12px; margin:0 0 12px; padding:8px 0 10px; background:var(--page); border-bottom:2px solid var(--kicker); }
.modebar .hint { margin:0; flex:1 1 260px; }
.cell input.midi { font:13px ui-monospace,Consolas,monospace; }
.cell input.midi.bad { border-color:var(--warn); }
.tog { display:flex; align-items:center; justify-content:center; padding-top:7px; }
.tog input { appearance:none; -webkit-appearance:none; width:18px; height:18px; border:2px solid var(--muted); border-radius:50%; margin:0; padding:0; cursor:pointer; background:var(--field); }
.tog input:checked { border-color:var(--mc,currentColor); background:radial-gradient(circle,var(--mc,currentColor) 0 45%,transparent 50%); }
.tog input:disabled { opacity:.35; cursor:not-allowed; }
.rowline { display:contents; }
.rowline.hi > * { background:var(--hair); }
.rowmsg { grid-column:1/-1; font-size:12px; color:var(--warn); margin:-2px 0 4px; }
.rowmsg:empty { display:none; }
.cgrid { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.3fr) auto; gap:6px 8px; align-items:center; margin-bottom:8px; }
.notesgrid { display:grid; gap:12px; }
textarea.notes { min-height:220px; resize:vertical; font:13px/1.5 ui-monospace,Menlo,monospace; width:100%; }
.notesprev { border:1px solid var(--hair); padding:12px 14px; }

/* design */
.design { margin-top:26px; border-top:2px solid var(--rule); padding-top:12px; }
.design summary { cursor:pointer; font-size:15px; font-weight:700; }
.dgrid { display:grid; gap:6px; padding:12px 0; max-width:520px; }
.dc { display:grid; grid-template-columns:170px minmax(0,1fr) 40px; align-items:center; gap:8px; font-size:13px; }
.dcol, .dhead { display:grid; grid-template-columns:170px minmax(0,1fr) minmax(0,1fr); align-items:center; gap:8px; font-size:13px; }
.dhead { color:var(--muted); margin-top:8px; }
.dgrid input[type=range] { accent-color:var(--active); padding:0; border:0; background:none; }
.dgrid input[type=color] { width:100%; height:26px; padding:0; border:1px solid var(--hair); background:none; }
.dgrid input.code { font:13px ui-monospace,Consolas,monospace; }
.dgrid input.bad { border-color:var(--warn); }
.dc output { text-align:right; font-variant-numeric:tabular-nums; }

/* font modal */
dialog { background:var(--page); color:var(--text); border:2px solid var(--text); box-shadow:10px 10px 0 var(--active); padding:24px; width:min(100% - 32px,540px); }
dialog::backdrop { background:rgba(0,0,0,.65); }
.modal { display:flex; flex-direction:column; gap:10px; }
.modal input { width:100%; font-size:14px; padding:8px 10px; border:2px solid var(--text); }
.mhead { display:flex; justify-content:space-between; align-items:center; border-bottom:2px solid var(--rule); padding-bottom:10px; font:800 20px var(--font-heading); }
.mfoot { display:flex; justify-content:flex-end; gap:8px; padding-top:4px; }
.chips { display:flex; flex-wrap:wrap; gap:6px; }
.chips button { font-size:12px; padding:4px 8px; border-width:1px; border-color:var(--rule); }
.fpreview { border:1px solid var(--hair); padding:12px; display:flex; flex-direction:column; gap:6px; }
/* community directory entry */
dialog.dir { width:min(100% - 32px,640px); }
/* web app: the steps to put it on GitHub Pages */
dialog.app { width:min(100% - 32px,820px); max-height:calc(100vh - 32px); }
#appSteps h2 { font-size:20px; margin-top:.4em; }
#appSteps h3 { font-size:16px; }
#appSteps ol, #appSteps ul { padding-left:1.4em; }
#appSteps li { margin:.35em 0; }
/* repository kit: options, then the image and the README side by side */
dialog.kit { width:min(100% - 32px,1240px); max-height:calc(100vh - 32px); }
.kitopts { display:flex; flex-wrap:wrap; gap:10px 28px; align-items:center; }
.kitbody { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.3fr); gap:16px; align-items:start; }
.kitimg { margin:0; display:flex; flex-direction:column; gap:6px; }
.kitimg figcaption { font-family:ui-monospace,Consolas,monospace; text-transform:none; letter-spacing:0; font-weight:500; color:var(--muted); }
#kitImg { border:1px solid var(--hair); min-height:160px; display:flex; align-items:center; justify-content:center; }
#kitImg img { display:block; width:100%; height:auto; }
.kitreadme { display:flex; flex-direction:column; gap:6px; min-width:0; }
.kithead { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.kitmd { border:1px solid var(--hair); padding:14px 16px; max-height:min(62vh,640px); overflow:auto; }
pre.kitmd { margin:0; }
.kitmd img { max-width:100%; height:auto; }
.kitfiles ul { margin:4px 0 0; padding-left:1.2em; font-size:13px; line-height:1.5; color:var(--muted); }
.kitfiles code { color:var(--text); font:12px ui-monospace,Consolas,monospace; }
.mfoot .status { margin-right:auto; align-self:center; }
@media (max-width:860px) { .kitbody { grid-template-columns:1fr; } }
.modal textarea { width:100%; font-size:14px; padding:8px 10px; border:2px solid var(--text); min-height:64px; resize:vertical; }
.modal .hint { margin:0; }
.dirmsg { margin:0; padding-left:1.2em; font-size:13px; line-height:1.45; color:var(--warn); }
.dirok { margin:0; font-size:13px; color:var(--muted); }
.dirjson { margin:0; padding:10px 12px; border:1px solid var(--hair); background:var(--field); font:12px/1.5 ui-monospace,Consolas,monospace; white-space:pre-wrap; overflow-wrap:anywhere; max-height:240px; overflow:auto; }
.mfoot button:disabled { opacity:.45; cursor:not-allowed; }
#fontPrev { font-size:20px; }

/* library page */
.lib { display:flex; flex-wrap:wrap; gap:32px 40px; align-items:flex-start; }
.lib figure { margin:0; flex:none; min-width:0; width:min(100%, 460px, max(33.333%, 380px)); }   /* width first: a third of the row, 380–460px */
.lib figure.wide { width:min(100%, 920px, max(60%, 700px)); }                                 /* desktop layout, or main + secondary side by side */
.lib figure svg { display:block; width:100%; height:auto; }
.lib figure .duo { display:flex; flex-wrap:wrap; gap:12px; }
.lib figure .duo svg { flex:1 1 300px; min-width:0; }   /* stacks on phones */
.side { flex:1 1 380px; min-width:0; display:flex; flex-direction:column; gap:24px; }
.side table { width:100%; }
.sources { display:flex; flex-direction:column; gap:10px; border-top:2px solid var(--rule); padding-top:16px; font-size:14px; }
.sources a { display:block; margin:0 0 4px; }
/* where a community entry's labels came from */
.notice { border:2px solid var(--kicker); border-left-width:8px; padding:12px 16px; font-size:14px; line-height:1.5; max-width:1100px; }
.notice[hidden] { display:none; }
.notice p { margin:0 0 6px; }
.notice > :last-child { margin-bottom:0; }
.notice a { font-weight:700; }
.notice code { font:13px ui-monospace,Consolas,monospace; }
.notice details { margin-top:8px; }
.notice summary { cursor:pointer; font-weight:700; }
.notice details .ctab { margin-top:8px; }
.notice details td.k { font-size:12px; overflow-wrap:anywhere; }
.notice .seg { display:inline-flex; vertical-align:middle; margin-left:4px; }

/* the firmware repository's README, collapsed under the manual (drawn by readmeFragment in community.js) */
.readme { border-top:2px solid var(--rule); padding-top:14px; }
.readme[hidden] { display:none; }
.readme > summary { cursor:pointer; font-size:15px; font-weight:700; }
.readme > summary .cap { margin-right:6px; }
.readme > summary #readmeName { color:var(--muted); font-weight:600; }
#readmeBody { max-width:980px; padding-top:12px; }
.rm-src { margin-bottom:16px; }
.rm { overflow-wrap:break-word; }
.rm h1 { font:800 32px/1.1 var(--font-heading,Archivo,sans-serif); margin:1em 0 .4em; padding-bottom:.25em; border-bottom:1px solid var(--hair); }
.rm h2 { padding-bottom:.2em; border-bottom:1px solid var(--hair); }
.rm h4, .rm h5, .rm h6 { font-size:15px; margin:1em 0 .3em; }
.rm blockquote, .rm pre, .rm details, .rm dl, .rm video, .rm .rm-mermaid, .rm .rm-yt { margin:0 0 1em; }
.rm img { max-width:100%; height:auto; }
.rm video { display:block; width:100%; max-height:70vh; background:#000; }
.rm .rm-yt { position:relative; max-width:720px; aspect-ratio:16/9; }
.rm .rm-yt iframe { position:absolute; inset:0; width:100%; height:100%; border:0; }
.rm pre { padding:12px 14px; border:1px solid var(--hair); background:var(--field); overflow-x:auto; font:13px/1.5 ui-monospace,Consolas,monospace; }
.rm pre code { font:inherit; white-space:pre; }
.rm :not(pre) > code { padding:.1em .35em; border:1px solid var(--hair); background:var(--field); }
.rm kbd { font:12px ui-monospace,Consolas,monospace; padding:.1em .4em; border:1px solid var(--rule); border-bottom-width:2px; }
.rm blockquote { padding:2px 0 2px 14px; border-left:4px solid var(--hair); color:var(--muted); }
.rm blockquote > :last-child { margin-bottom:0; }
.rm .rm-alert { --al:#4493f8; color:var(--text); border-left-color:var(--al); }
.rm .rm-alert-title { font-weight:700; color:var(--al); margin-bottom:.3em; }
.rm .rm-tip { --al:#3fb950; } .rm .rm-important { --al:#ab7df8; } .rm .rm-warning { --al:#d29922; } .rm .rm-caution { --al:#f85149; }
.ui-light .rm .rm-alert { --al:#0969da; } .ui-light .rm .rm-tip { --al:#1a7f37; } .ui-light .rm .rm-important { --al:#8250df; } .ui-light .rm .rm-warning { --al:#9a6700; } .ui-light .rm .rm-caution { --al:#d1242f; }
.rm .rm-mermaid { overflow-x:auto; padding:12px; border:1px solid var(--hair); }
.rm .rm-mermaid svg { display:block; max-width:100%; height:auto; margin:0 auto; }
.rm li > input[type=checkbox] { margin:0 .4em 0 0; vertical-align:middle; }
.rm ul:has(> li > input[type=checkbox]) { list-style:none; padding-left:.4em; }
.rm details > summary { cursor:pointer; font-weight:600; }
.rm table { width:auto; min-width:50%; }

/* Play: a firmware's approved browser build (play.js), and its controls on the drawing */
.play { border:2px solid var(--active); border-left-width:8px; padding:10px 16px; max-width:1100px; font-size:14px; line-height:1.5; }
.play[hidden] { display:none; }
/* while playing: no tap highlight, selection or long-press menu on the drawing; with the lock, touching it never scrolls the page */
#fig svg { -webkit-tap-highlight-color:transparent; }
body.playing #fig { -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; }
body.play-lock #fig { touch-action:none; overscroll-behavior:contain; }
/* full screen: the drawing alone; the sound controls in a sheet above the bar */
body.play-stage { overflow:hidden; }
body.play-stage .lib figure#fig { position:fixed; inset:0; z-index:900; width:auto !important; max-width:none; margin:0; padding:8px 8px 60px; background:var(--page); display:flex; align-items:center; justify-content:center; touch-action:none; }
body.play-stage #fig > svg { width:100%; height:100%; }
body.play-stage #play { display:none; position:fixed; left:8px; right:8px; bottom:60px; z-index:902; max-height:70vh; overflow:auto; background:var(--page); box-shadow:0 -8px 24px rgba(0,0,0,.4); }
body.play-stage.stage-sound #play { display:block; }
body.play-stage.stage-nopadlabels #fig .padlabel { display:none; }
.stagebar { position:fixed; left:0; right:0; bottom:0; z-index:903; display:flex; gap:8px; justify-content:center; padding:8px; background:var(--page); border-top:1px solid var(--hair); }
.stagebar button { min-width:0; padding:8px 12px; }
.play p { margin:0; }
.play a { font-weight:700; }
.play code { font:13px ui-monospace,Consolas,monospace; }
.play .pctl { display:flex; flex-wrap:wrap; gap:10px 18px; align-items:center; }
.play .pctl label { display:flex; align-items:center; gap:8px; }
.play .pctl label[hidden] { display:none; }
.play input[type=range] { width:110px; padding:0; border:0; background:none; accent-color:var(--active); }
.play .pctl button { min-width:92px; }
.play .pctl + .pctl { margin-top:8px; }
.play .pctl .seg button { min-width:0; }
.play .keys { display:flex; align-items:center; gap:8px; }
.ctab tr td { transition:background-color .25s; }
.ctab tr.hov td { background:color-mix(in srgb, var(--active) 9%, transparent); transition:none; }
.ctab tr.hot td { background:color-mix(in srgb, var(--active) 24%, transparent); transition:none; }
g[data-for] { pointer-events:none; fill:var(--play,#ff7a1a); stroke:none; }
g[data-for].hl-hover { fill-opacity:.2; }
g[data-for].hl-use { fill-opacity:.5; }
g[data-key].hl-hover { filter:drop-shadow(0 0 5px rgba(255,122,26,.55)); }
g[data-key].hl-use { filter:drop-shadow(0 0 7px rgba(255,122,26,.95)); }
.ctab tr.midirow td[data-last] { font:13px ui-monospace,Consolas,monospace; }
.ctab td.midi .mv { color:var(--play,#ff7a1a); margin-left:.6em; }
.play .hint { margin:8px 0 0; }
.play .status.err { color:var(--warn); }
.pmeter { width:90px; height:8px; background:var(--hair); position:relative; overflow:hidden; }
.pmeter i { position:absolute; left:0; top:0; bottom:0; width:0; background:var(--active); transition:width 60ms linear; }
.playov { --play:#ff7a1a; }
.playov .hit { fill:transparent; pointer-events:all; touch-action:none; }
.playov .hit.knob, .playov .hit.fader { cursor:ns-resize; }
.playov .hit.lever { cursor:pointer; }
.playov .pad { fill:var(--play); fill-opacity:0; pointer-events:all; touch-action:none; cursor:pointer; }
.playov .pad.on { stroke:var(--play); stroke-width:3; stroke-linejoin:round; }
.playov.under { pointer-events:none; }
.playov .padfill { fill:var(--play); fill-opacity:0; }
.playov .padart { --pline:var(--play); --pbg:transparent; opacity:0; }
.playov .track, .playov [data-knob] .val { fill:none; stroke-width:6; stroke-linecap:round; pointer-events:none; }
.playov .track { stroke:rgba(128,128,128,.4); }
.playov [data-knob] .val { stroke:var(--play); }
.playov .ptr { stroke:var(--play); stroke-width:6; stroke-linecap:round; pointer-events:none; }
.playov [data-fader] .val, .playov .thumb { fill:var(--play); pointer-events:none; }
.playov .cap { fill:#f3f2f2; stroke:var(--play); stroke-width:3; pointer-events:none; }
.playov [data-led] { pointer-events:none; opacity:0; transition:opacity 40ms; }
.playov [data-led].on { opacity:1; }
.playov [data-led] .lit { fill:#ff4a2f; }
.playov [data-led] .glow { fill:url(#playGlow); }
.playov .oled { pointer-events:none; }
.playov .oled .bezel { fill:#05070a; stroke:var(--pline,#888); stroke-width:2; }

/* about page */
.about { max-width:820px; font-size:15px; line-height:1.6; }
.about h2 { font:800 26px/1.15 var(--font-heading); margin:1.6em 0 .5em; scroll-margin-top:16px; }
.about h3 { font:800 18px/1.2 var(--font-heading); margin:1.2em 0 .4em; }
.about p, .about ul, .about ol { margin:0 0 .9em; }
.about ul, .about ol { padding-left:1.3em; }
.about li { margin:.25em 0; }
.about code { font:13px ui-monospace,Consolas,monospace; }
.about pre { margin:0 0 1em; padding:12px 14px; border:1px solid var(--hair); background:var(--field); font:13px/1.5 ui-monospace,Consolas,monospace; overflow-x:auto; }
.flow { display:grid; grid-template-columns:1fr auto 1fr auto 1fr; align-items:stretch; gap:10px; margin:0 0 1em; }
.flow .box { border:2px solid var(--text); padding:12px 14px; font-size:14px; line-height:1.45; }
.flow .box b { display:block; font-size:15px; margin-bottom:4px; }
.flow .box span { color:var(--muted); }
.flow .arr { align-self:center; text-align:center; font-size:12px; color:var(--muted); max-width:110px; }
.flow .arr::before { content:'→'; display:block; font-size:26px; line-height:1; color:var(--kicker); }
/* the whole route: numbered steps on a line, step 2 forks into two orders and joins again */
.about .route { list-style:none; margin:0 0 1.4em; padding:0; position:relative; }
.route::before { content:''; position:absolute; left:17px; top:18px; bottom:18px; border-left:2px solid var(--kicker); }
.route .step { position:relative; display:grid; grid-template-columns:36px minmax(0,1fr); gap:14px; margin:0 0 14px; }
.route .step:last-child { margin-bottom:0; }
.route .num { position:relative; width:36px; height:36px; display:flex; align-items:center; justify-content:center; background:var(--page); border:2px solid var(--kicker); color:var(--kicker); font:800 16px/1 var(--font-heading); }
.route .card { border:2px solid var(--text); padding:10px 14px 12px; font-size:14px; line-height:1.5; scroll-margin-top:16px; }
.route .card p { margin:0 0 .5em; }
.route .card > :last-child { margin-bottom:0; }
.route .head { display:flex; flex-wrap:wrap; align-items:baseline; justify-content:space-between; gap:4px 12px; margin-bottom:4px; }
.route .head b { font-size:16px; }
.route .tools { display:flex; flex-wrap:wrap; gap:4px; }
.route .tool { display:inline-block; padding:0 6px; border:1px solid var(--hair); font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; line-height:1.7; white-space:nowrap; color:var(--muted); }
.route .tool.t-des { border-color:var(--active); background:var(--active); color:#fff; }
.route .tool.t-lib { border-color:var(--kicker); color:var(--kicker); }
.route .tool.t-web { border-color:var(--text); color:var(--text); }
.route .out { padding-top:6px; border-top:1px solid var(--hair); color:var(--muted); }
.route .out span { font-size:11px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--kicker); margin-right:6px; }
.route .fork { display:grid; grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); gap:10px; margin:8px 0 10px; }
.route .way { border:1px dashed var(--rule); padding:8px 12px; scroll-margin-top:16px; }
.route .way .cap { display:block; color:var(--kicker); margin-bottom:4px; }
.route .way p { margin:0 0 .5em; }
.route .way p:last-child { margin:0; }
.route .or { align-self:center; font-size:12px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--muted); }
@media (max-width:640px) {
  .route .fork { grid-template-columns:1fr; }
  .route .or { justify-self:center; }
}

@media (max-width:760px) {
  .flow { grid-template-columns:1fr; }
  .flow .arr { max-width:none; }
  .flow .arr::before { content:'↓'; }
}

.foot { border-top:1px solid var(--hair); padding-top:16px; font-size:13px; line-height:1.5; color:var(--muted); }

@media (max-width:1000px) {
  .grid { grid-template-columns:1fr; }
  #previewCol { top:0; height:60vh; z-index:2; }
  .intro h1 { font-size:32px; }
}
@media (max-width:560px) {
  .wrap { padding:20px 16px 48px; }
  .meta { grid-template-columns:1fr 1fr; }
  .dc, .dcol, .dhead { grid-template-columns:120px minmax(0,1fr) minmax(0,1fr); }
}

/* main + secondary one above the other */
#stage .duo.stack { flex-direction:column; }
#stage .duo.stack > svg { flex:1 1 0; width:100%; min-height:0; }
.lib figure .duo.stack { flex-direction:column; }
.lib figure .duo.stack svg { flex:none; width:100%; }

/* grab handles: between drawing and table (library), on the preview's edge (designer) */
.split { flex:none; align-self:stretch; width:12px; margin:0 -26px; cursor:col-resize; touch-action:none; display:flex; align-items:flex-start; justify-content:center; position:relative; z-index:1; }
.split span, .colgrip span, .xgrip span { display:block; width:6px; height:48px; border:2px solid var(--text); background:var(--page); box-sizing:border-box; }
.split span { position:sticky; top:45vh; margin-top:120px; }
.colgrip { position:absolute; top:0; bottom:0; right:-18px; width:12px; cursor:col-resize; touch-action:none; display:flex; align-items:center; justify-content:center; z-index:3; }
@media (max-width:1000px) { .colgrip { display:none; } }
@media (max-width:760px) { .split { display:none; } }

/* export preview modal */
dialog.xprev { width:calc(100vw - 32px); max-width:none; height:calc(100vh - 32px); max-height:none; padding:0; display:flex; flex-direction:column; box-shadow:none; }
dialog.xprev:not([open]) { display:none; }
.xbar { display:flex; flex-wrap:wrap; align-items:center; gap:8px 16px; padding:12px 20px; border-bottom:2px solid var(--rule); }
.xbar .sp { flex:1; }
.xbar .hint { margin:0; }
.xscroll { flex:1; overflow:auto; padding:24px; background:rgba(0,0,0,.35); }
.xsheet { width:max-content; margin:0 auto; box-shadow:0 12px 48px rgba(0,0,0,.5); }
.xgrip { position:absolute; top:0; bottom:0; right:-26px; width:12px; cursor:col-resize; touch-action:none; display:flex; align-items:center; justify-content:center; }
.xgrip span { border-color:currentColor; background:transparent; }

/* greyed-out toolbar options keep their place */
.seg button:disabled { opacity:.35; cursor:not-allowed; border-color:var(--text); }
.seg button:disabled[aria-pressed="true"] { background:transparent; color:var(--text); }

/* Labels / Style tabs */
.tabs { display:flex; gap:0; margin:0 0 18px; border-bottom:2px solid var(--rule); }
.tabs button { border:0; border-bottom:3px solid transparent; margin-bottom:-2px; padding:8px 16px 7px; font-size:13px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--muted); }
.tabs button[aria-selected="true"] { color:var(--text); border-bottom-color:var(--active); background:transparent; }
.tabs button:hover { color:var(--text); }
#formCol > .tabs + h2 { margin-top:0; border-top:0; padding-top:0; }
.fphelp { font-size:13px; line-height:1.5; color:var(--muted); max-width:640px; margin:10px 0 8px; }
.fphelp p { margin:0 0 6px; }
.fphelp b { color:var(--text); }
.fphelp code { font:12px ui-monospace,Menlo,monospace; color:var(--text); }
.mcolors { display:flex; flex-wrap:wrap; gap:10px 18px; }
.mcolors label { display:flex; align-items:center; gap:8px; font-size:13px; }
.mcolors input[type=color] { width:44px; height:28px; padding:0; border:1px solid var(--hair); background:none; }
button.cswatch { width:100%; height:26px; padding:0; border:1px solid var(--hair); background:var(--c); }
button.cswatch[data-open] { outline:2px solid var(--active); outline-offset:1px; }
.mcolors button.cswatch { width:44px; height:28px; }
.cpop { position:absolute; z-index:60; display:grid; gap:8px; padding:10px; background:var(--page); color:var(--text); border:1px solid var(--rule); box-shadow:0 8px 24px rgba(0,0,0,.35); max-width:calc(100vw - 16px); }
.cpop .crow { display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
.cpop .clab { font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.06em; }
.cpop .crow > .clab:first-child { min-width:52px; }
.cpop .cchip { display:inline-block; width:24px; height:24px; padding:0; border:1px solid var(--hair); background:var(--c); }
.cpop .hex { width:84px; padding:3px 6px; font:13px ui-monospace,Consolas,monospace; }
.cpop input[type=color] { width:36px; height:26px; padding:0; border:1px solid var(--hair); background:none; cursor:pointer; }
.cpop .hint { margin:0; font-size:12px; }

.ui-vis { --page:#141414; --text:#f3f2f2; --muted:rgba(243,242,242,.7); --rule:rgba(243,242,242,.35); --hair:rgba(243,242,242,.14); --active:#0a7d50; --kicker:#e3bb67; --field:rgba(255,255,255,.04); --warn:#ff8a78; }
.dc .seg button { padding:4px 10px; font-size:12px; }
.dc .chk { display:flex; align-items:center; gap:6px; }
.dc .chk small { color:var(--muted); font-size:12px; }
.dc input[type=color] { width:100%; height:26px; padding:0; border:1px solid var(--hair); background:none; }

/* export minimap */
.mm { display:flex; flex-direction:column; align-items:center; gap:4px; user-select:none; }
.mm .cap { font-size:10px; color:var(--muted); }
.mm-sheet { width:116px; height:96px; padding:6px; border:2px solid; box-shadow:4px 4px 0 var(--hair); display:flex; flex-direction:column; gap:4px; box-sizing:border-box; }
.mm-sheet button { padding:0; border-radius:0; background:transparent; color:inherit; font:inherit; cursor:pointer; text-align:left; }
.mm-top { display:flex; gap:4px; flex:1; min-height:0; }
.mm-panels { flex:none; display:flex; gap:2px; border:1.5px solid var(--active) !important; padding:2px !important; }
.mm-panels.stacked { flex-direction:column; }
.mm-dev { display:flex; flex-direction:column; justify-content:space-between; width:24px; flex:1; padding:2px; border:1px solid; box-sizing:border-box; min-height:0; }
.mm-panels:not(.stacked) .mm-dev:only-child { width:34px; }
.mm-dev > i { display:block; height:40%; }
.mm-dev b { font:800 5px/1 var(--font-body); letter-spacing:.02em; text-align:center; overflow:hidden; white-space:nowrap; }
.mm-panels .mm-dev + .mm-dev b, .mm-panels .mm-dev:has(+ .mm-dev) b { visibility:hidden; }
.mm-pads { display:grid; grid-template-columns:repeat(4,1fr); gap:1px; height:24%; }
.mm-pads i { display:block; }
.mm-table, .mm-notes { border:1px dashed var(--muted) !important; opacity:.4; padding:3px 4px !important; display:flex; }
.mm-table { flex:1; flex-direction:column; justify-content:space-between; }
.mm-notes { height:22px; flex:none; align-items:center; gap:6px; }
.mm-table.on, .mm-notes.on { border:1.5px solid var(--active) !important; opacity:1; background:color-mix(in srgb, var(--active) 12%, transparent) !important; }
.mm-notes:disabled { cursor:not-allowed; opacity:.2; }
.mm-sheet b { font:800 7px/1 var(--font-body); letter-spacing:.05em; }
.mm-table span { display:flex; flex-direction:column; gap:3px; }
.mm-table span i { display:block; height:2px; border-bottom:1.5px solid currentColor; }
.mm-notes span { flex:1; display:grid; grid-template-columns:1fr 1fr; gap:2px 4px; }
.mm-notes span i { display:block; height:1.5px; background:currentColor; opacity:.55; }
.mm-cap { font-size:10px; color:var(--muted); white-space:nowrap; }
.top > .mm { align-self:flex-start; }

.pdfig { margin:0; display:flex; flex-direction:column; gap:8px; border-top:2px solid var(--rule); padding-top:16px; }
.pdfig img { width:100%; height:auto; display:block; border:2px solid var(--rule); }

/* select with ‹ › step buttons */
.stepper { display:flex; align-items:stretch; min-width:0; }
.stepper select { flex:1; min-width:0; }
.stepper button { padding:0 9px; font-size:15px; line-height:1; border-width:2px; }
.stepper button:first-child { border-right:0; }
.stepper button:last-child { border-left:0; }

/* export sheet */
.xsheet { padding:var(--xpad,32px); font-family:Archivo,system-ui,sans-serif; box-sizing:border-box; }
.xh1 { margin:0 0 6px; font:800 40px/1.05 Archivo,sans-serif; }
.xdesc { margin:0 0 20px; max-width:760px; font-size:15px; line-height:1.5; }
.xh1 + .xbody { margin-top:14px; }
.xbody { display:flex; gap:var(--xtgap,40px); align-items:flex-start; }
.xbody[data-table="below"] { flex-direction:column; gap:var(--xtgap,24px); }
.xfigs { position:relative; display:flex; align-items:flex-start; }
/* panel gap as a margin, so it can go below zero and the drawings' empty edges overlap; labels stay above every drawing */
.xfigs { flex-direction:column; }
.xfrow { display:flex; align-items:flex-start; }
.xfrow + .xfrow { margin-top:var(--xfgap,16px); }
.xfrow > .xfig + .xfig { margin-left:var(--xfgap,16px); }
.xcap { font-weight:700; font-size:calc(var(--xfs,14px) * 1.15); margin:0 0 6px; }
.xmode { display:inline-flex; align-items:center; gap:2px; border:2px solid var(--hair); padding:2px 2px 2px 8px; font-size:13px; }
.xmode.on { border-color:var(--text); }
.xmode label { display:flex; align-items:center; gap:4px; margin-right:4px; cursor:pointer; }
.xmode button { padding:2px 7px; min-width:0; }
.xrow[hidden] { display:none; }
.xfigs [data-fig] > img { z-index:0; }
.xfigs [data-fig] > svg { z-index:1; }
.xtable { width:calc(var(--xfs,14px) * 40); flex:none; }
/* text size slider: the table and the notes scale together */
.xsheet .xtable .ctab { font-size:var(--xfs,14px); }
.xsheet .xnotes { font-size:var(--xfs,15px); }
.xsheet .ctab .k { font-size:.85em; }
.xsheet .md h2 { font-size:1.6em; }
.xsheet .md h3 { font-size:1.2em; }
.xsheet .md table { font-size:.93em; }
.xsheet .md code { font-size:.87em; }
.xnotes { margin-top:28px; padding-top:16px; columns:2 420px; column-gap:40px; }
.xfoot { margin:24px 0 0; font-size:11px; line-height:1.5; }
.xfoot span:not(:empty)::before { content:''; display:block; }
.xchk { display:flex; align-items:center; gap:6px; font-size:13px; cursor:pointer; }
.xbar .seg button:disabled { opacity:.35; cursor:not-allowed; }
/* on paper: smaller type, the table takes the room that's left */
.xsheet.paper { padding:var(--xpad,28px); overflow:hidden; }
.xsheet.paper .xh1 { font-size:28px; }
.xsheet.paper .xdesc { font-size:13px; margin-bottom:14px; }
.xsheet.paper .xbody { gap:var(--xtgap,24px); }
.xsheet.paper .xbody[data-table="side"] .xtable { flex:1 1 0; min-width:calc(var(--xfs,12px) * 20); width:auto; }
.xsheet.paper .xbody[data-table="below"] .xtable { width:100%; }
.xsheet.paper .xtable .ctab { font-size:var(--xfs,12px); }
.xsheet.paper .xtable .ctab th, .xsheet.paper .xtable .ctab td { padding:.33em .67em .33em 0; }
.xsheet.paper .xnotes { margin-top:18px; padding-top:12px; columns:2 280px; column-gap:28px; font-size:var(--xfs,12px); }
.xsheet.paper .xfoot { margin-top:14px; font-size:9px; }

.xgrip[hidden] { display:none; }
.xscroll .xsheet + .xsheet { margin-top:24px; }
.xsheet[hidden] { display:none; }
.xpage2 .xnotes2 { columns:2 280px; column-gap:28px; font-size:var(--xfs,12px); }
/* notes on an export sheet: no scroll boxes, tables and headings stay with what follows */
.xsheet .md .tw { overflow:visible; }   /* (break-inside on tables makes html-to-image drop the rows) */
.xsheet .md h2, .xsheet .md h3 { break-after:avoid; }
.xsheet .md li { break-inside:avoid; }

/* notes columns on export sheets: see balanceNotes() */
.xsheet .xnotes, .xsheet .xnotes2 { columns:auto; display:flex; gap:40px; align-items:flex-start; }
.xsheet.paper .xnotes, .xsheet.paper .xnotes2 { columns:auto; gap:28px; }
.ncol { flex:1 1 0; min-width:0; }
.ncol > :first-child { margin-top:0; }

/* export preview bar: minimap on the left, options and actions beside it */
.xbar { align-items:flex-start; gap:12px 20px; flex-wrap:nowrap; }
.xbar > [data-mm] { flex:none; }
.xopts { flex:1; min-width:0; display:flex; flex-direction:column; gap:8px; }
.xrow { display:flex; flex-wrap:wrap; align-items:center; gap:8px 14px; }
.xrow .sp { flex:1; }
.xrow .hint { margin:0; }
.xsl { display:flex; align-items:center; gap:6px; font-size:13px; }
.xsl input[type=range] { width:110px; accent-color:var(--active); padding:0; border:0; background:none; }
.xsl output { min-width:3.2em; font-variant-numeric:tabular-nums; color:var(--muted); }
.xacts { display:flex; flex-wrap:wrap; align-items:center; gap:8px 14px; }
/* phones: the whole screen, the minimap beside the look / paper choices, actions and sliders full width
   below, so the bar stays short and the sheet gets the room */
@media (max-width:700px) {
  dialog.xprev { width:100vw; height:100dvh; margin:0; border-width:0; }
  .xbar { display:grid; grid-template-columns:auto minmax(0,1fr); gap:6px 12px; padding:10px 12px; max-height:55dvh; overflow:auto; }
  .xopts, .xopts > .xrow:first-child { display:contents; }
  .xbar > [data-mm] { grid-column:1; grid-row:1 / span 4; }
  .xrow:first-child > :is(.cap, .sp) { display:none; }
  .xrow:first-child > :is([data-look], [data-paper], [data-orient], .xchk) { grid-column:2; }
  .xacts, .xopts > .xrow:not(:first-child) { grid-column:1 / -1; }
  .xacts { gap:5px; }
  .xbar button { padding:5px 7px; font-size:12px; }
  .xchk { font-size:12px; }
  .xrow[data-sliders] { display:grid; grid-template-columns:1fr 1fr; gap:4px 16px; }
  .xsl { display:grid; grid-template-columns:1fr auto; gap:0 6px; font-size:12px; }
  .xsl input[type=range] { grid-row:2; grid-column:1 / -1; width:100%; }
  .xsl output { grid-row:1; grid-column:2; min-width:0; }
  [data-slreset] { grid-column:1 / -1; justify-self:start; }
  .xrow .hint { font-size:12px; }
  .xscroll { padding:12px; }
}

/* guide.html: the start choices, and a check per line that remembers its tick */
.gsetup { display:flex; flex-wrap:wrap; align-items:flex-end; gap:12px 28px; margin:0 0 8px; padding:12px 0 14px; border-bottom:2px solid var(--rule); position:sticky; top:0; z-index:5; background:var(--page); }
.gsetup .grp { display:flex; flex-direction:column; gap:4px; }
.gsetup .grepo { flex:1 1 240px; }
.gsetup .grepo input { width:100%; }
.gsetup .hint { flex-basis:100%; margin:0; }
.guide .chk { display:flex; align-items:flex-start; gap:8px; margin:6px 0 0; padding:6px 8px; border:1px solid var(--hair); cursor:pointer; }
.guide .chk input { margin-top:3px; flex:none; }
.guide .chk.done { border-color:var(--kicker); color:var(--muted); }
.guide .chk + .hint, .guide .card > .hint { margin-top:8px; }
.guide a:not([href]) { text-decoration:underline dotted; cursor:help; }
.guide [hidden] { display:none !important; }
@media (max-width:600px){ .gsetup { position:static; } }
