/* enokiwiki — own stylesheet. System fonts, light and dark. */
:root {
  --bg: #ffffff; --bg-alt: #f6f7f9; --surface: #ffffff; --fg: #1d2230; --muted: #5f6878;
  --border: #e1e4ea; --border-strong: #cdd2da; --accent: #2f6fde; --accent-fg: #ffffff;
  --accent-soft: #e8f0fd; --danger: #cf222e; --ok: #1a7f37; --warn-bg: #fff8c5; --warn-border: #d4a72c;
  --add-bg: #e6ffec; --del-bg: #ffebe9; --mark: #fff3a3; --code-bg: #f1f3f6;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .08);
  --radius: 8px; --topbar-h: 3.25rem; --nav-w: 17rem; --rail-w: 14rem; --read: 46rem;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --bg-alt: #161a22; --surface: #1a1f29; --fg: #e4e8ef; --muted: #9099a8;
    --border: #262c38; --border-strong: #353d4c; --accent: #6ea2ff; --accent-fg: #0f1218;
    --accent-soft: #1b2a45; --danger: #f85149; --ok: #3fb950; --warn-bg: #3a2f00; --warn-border: #9e6a03;
    --add-bg: #0f2d1a; --del-bg: #3c1618; --mark: #5a4700; --code-bg: #1b2029;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --bg-alt: #161a22; --surface: #1a1f29; --fg: #e4e8ef; --muted: #9099a8;
  --border: #262c38; --border-strong: #353d4c; --accent: #6ea2ff; --accent-fg: #0f1218;
  --accent-soft: #1b2a45; --danger: #f85149; --ok: #3fb950; --warn-bg: #3a2f00; --warn-border: #9e6a03;
  --add-bg: #0f2d1a; --del-bg: #3c1618; --mark: #5a4700; --code-bg: #1b2029;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 1rem); }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .9em; }
[hidden] { display: none !important; }
.js-only { display: none; }
html:not(.js) .js-only { display: none !important; }
.js .js-only { display: inline-flex; }
.js .editor-bar.js-only { display: flex; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.octicon { flex: none; vertical-align: text-bottom; }
.skip-link { position: absolute; left: -999px; top: .5rem; z-index: 100; padding: .4rem .8rem; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.skip-link:focus { left: .5rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: .75rem; padding: 0 1rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: .45rem; color: var(--fg); font-weight: 650; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand .octicon { color: var(--accent); }
.topbar-end { display: flex; align-items: center; gap: .25rem; margin-left: auto; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-width: 2.25rem; height: 2.25rem; padding: 0 .5rem;
  color: var(--muted); background: none; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; font: inherit; font-size: .9rem;
}
.icon-btn:hover { color: var(--fg); background: var(--bg-alt); text-decoration: none; }
.nav-toggle { display: none; margin-left: -.5rem; }
.theme-toggle .to-light, .theme-toggle[data-mode="dark"] .to-dark { display: none; }
.theme-toggle[data-mode="dark"] .to-light { display: inline-flex; }
.login-link { margin-left: .25rem; }

/* search */
.search { position: relative; flex: 0 1 26rem; margin-left: 1.5rem; display: flex; align-items: center; }
.search .search-icon { position: absolute; left: .7rem; color: var(--muted); pointer-events: none; display: inline-flex; }
.search input[type=search] {
  width: 100%; height: 2.25rem; padding: 0 2.2rem 0 2.2rem; font: inherit; font-size: .92rem;
  color: var(--fg); background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius);
}
.search input[type=search]:focus { background: var(--surface); border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.search input::-webkit-search-cancel-button { display: none; }
.kbd { position: absolute; right: .6rem; padding: 0 .35rem; font: .75rem/1.4 var(--mono); color: var(--muted); border: 1px solid var(--border-strong); border-radius: 4px; pointer-events: none; }
.search:focus-within .kbd { display: none; }
.search-pop {
  display: none; position: absolute; top: calc(100% + .35rem); left: 0; right: 0; z-index: 40; max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: .3rem;
}
.search:focus-within .search-pop:not(:empty), .search.open .search-pop:not(:empty) { display: block; }
.search-hit { display: grid; grid-template-columns: 1fr auto; gap: 0 .75rem; padding: .45rem .65rem; border-radius: 6px; color: var(--fg); }
.search-hit:hover, .search-hit.active { background: var(--accent-soft); text-decoration: none; }
.hit-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hit-path { color: var(--muted); font-size: .8rem; align-self: center; }
.hit-snippet { grid-column: 1 / -1; color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-all { display: flex; align-items: center; gap: .5rem; color: var(--accent); border-top: 1px solid var(--border); border-radius: 0 0 6px 6px; margin-top: .2rem; }
.search-empty { padding: .6rem .65rem; color: var(--muted); font-size: .9rem; }
.js .search-open, .js .search-close { display: none; }

/* shell */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
main { min-width: 0; padding: 1.5rem 2.5rem 0; }
.site-footer { color: var(--muted); font-size: .8rem; padding: 3rem 0 1.5rem; }

/* navigation */
.nav {
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column;
  background: var(--bg-alt); border-right: 1px solid var(--border); font-size: .92rem;
}
.nav-scroll { flex: 1; overflow-y: auto; padding: 1rem .75rem; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.nav-heading { margin: .5rem .5rem .35rem; font-size: .72rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.nav-heading:not(:first-child) { margin-top: 1.25rem; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list .nav-list { margin-left: .9rem; padding-left: .5rem; border-left: 1px solid var(--border); }
.nav-link {
  display: flex; align-items: center; gap: .55rem; padding: .3rem .5rem; border-radius: 6px; color: var(--fg); line-height: 1.35;
}
.nav-link:hover { background: color-mix(in srgb, var(--fg) 6%, transparent); text-decoration: none; }
.nav-link.current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-chapter summary { display: flex; align-items: center; list-style: none; cursor: pointer; border-radius: 6px; }
.nav-chapter summary::-webkit-details-marker { display: none; }
.nav-chapter summary .nav-link { flex: 1; font-weight: 550; padding-left: .2rem; }
.nav-chapter .chev { display: inline-flex; padding: .3rem .1rem .3rem .3rem; color: var(--muted); transition: transform .15s; }
.nav-chapter details[open] > summary .chev { transform: rotate(90deg); }
.nav-back { display: inline-flex; align-items: center; gap: .4rem; margin: 0 .5rem .75rem; font-size: .85rem; color: var(--muted); }
.nav-book { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; padding: .45rem .5rem; border-radius: 6px; color: var(--fg); font-weight: 650; font-size: 1rem; }
.nav-book:hover { text-decoration: none; background: color-mix(in srgb, var(--fg) 6%, transparent); }
.nav-book.current { color: var(--accent); }
.book-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 1.75rem; height: 1.75rem; border-radius: 6px;
  color: var(--book, var(--accent)); background: color-mix(in srgb, var(--book, var(--accent)) 14%, transparent);
}
.nav-list .book-icon { width: 1.5rem; height: 1.5rem; }
.nav-foot { display: flex; flex-direction: column; padding: .6rem .75rem; border-top: 1px solid var(--border); }
.nav-foot a { display: flex; align-items: center; gap: .55rem; padding: .3rem .5rem; color: var(--muted); border-radius: 6px; font-size: .88rem; }
.nav-foot a:hover { color: var(--fg); background: color-mix(in srgb, var(--fg) 6%, transparent); text-decoration: none; }
.nav-backdrop { display: none; }

/* menus (details/summary) */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + .35rem); z-index: 35; min-width: 13rem; padding: .3rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.menu-pop a, .menu-pop button {
  display: flex; align-items: center; gap: .6rem; width: 100%; padding: .45rem .65rem; border: 0; border-radius: 6px;
  background: none; color: var(--fg); font: inherit; font-size: .92rem; text-align: left; cursor: pointer;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--bg-alt); text-decoration: none; }
.menu-pop .danger { color: var(--danger); }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: .3rem 0; }
.menu-pop form { margin: 0; }
.user-label { max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .4rem; color: var(--muted); font-size: .85rem; margin-bottom: 1rem; }
.crumbs a { color: var(--muted); display: inline-flex; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { opacity: .6; }
.crumbs [aria-current] { color: var(--fg); }

/* banners */
.banner { padding: .65rem .9rem; margin: .75rem 0; border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius); background: var(--bg-alt); }
.banner.notice { border-left-color: var(--ok); }
.banner.error { border-left-color: var(--danger); }
.banner.version, .banner.warn { background: var(--warn-bg); border-color: var(--warn-border); }

/* buttons and forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.25rem; padding: .35rem .85rem; font: inherit; font-size: .9rem; font-weight: 500;
  color: var(--fg); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); cursor: pointer;
}
.btn:hover { text-decoration: none; background: var(--bg-alt); }
.btn.icon-only { padding: .35rem .55rem; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--fg)); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
input[type=text], input[type=search], input[type=password], select, textarea {
  font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: .45rem .65rem;
}
textarea { width: 100%; font-family: var(--mono); font-size: .9rem; line-height: 1.5; resize: vertical; }
.form-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .75rem 0; }
.form-row input[type=text] { flex: 1 1 14rem; }
.check { display: inline-flex; align-items: center; gap: .35rem; margin: .5rem 0; }
.edit-form label { color: var(--muted); }

/* page */
.page-title { margin: 0; font-size: 2rem; line-height: 1.2; letter-spacing: -.015em; font-weight: 700; overflow-wrap: anywhere; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; max-width: calc(var(--read) + var(--rail-w) + 3rem); }
.page:not(.has-toc) .page-head { max-width: var(--read); }
.page-actions { display: flex; align-items: center; gap: .4rem; flex: none; padding-top: .2rem; }
.page-grid { display: grid; grid-template-columns: minmax(0, var(--read)); gap: 3rem; }
.page.has-toc .page-grid { grid-template-columns: minmax(0, var(--read)) var(--rail-w); }
.toc-rail { position: sticky; top: calc(var(--topbar-h) + 1.5rem); align-self: start; max-height: calc(100vh - var(--topbar-h) - 3rem); overflow-y: auto; font-size: .85rem; }
.rail-heading { margin: 0 0 .5rem; font-size: .72rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.outline { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.outline a { display: block; padding: .2rem 0 .2rem .8rem; margin-left: -1px; color: var(--muted); border-left: 2px solid transparent; line-height: 1.35; }
.outline a:hover { color: var(--fg); text-decoration: none; }
.outline a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 550; }
.outline .lvl-3 a { padding-left: 1.6rem; }
.outline .lvl-4 a, .outline .lvl-5 a, .outline .lvl-6 a { padding-left: 2.4rem; }
.toc-inline { display: none; margin: 0 0 1.5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-alt); font-size: .92rem; }
.toc-inline summary { display: flex; align-items: center; gap: .5rem; padding: .6rem .85rem; cursor: pointer; font-weight: 550; list-style: none; }
.toc-inline summary::-webkit-details-marker { display: none; }
.toc-inline .outline { margin: 0 .85rem .75rem; }
/* A [[_TOC_]] written into the page repeats the generated outline. */
.page.has-toc .markdown-body .toc { display: none; }
.section-title { font-size: 1.05rem; margin: 2.5rem 0 .9rem; }
.last-commit { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: .85rem; }
.avatar { border-radius: 50%; vertical-align: middle; margin-right: .3rem; }
.fab { display: none; }

/* contents of a book or chapter */
.contents { list-style: none; margin: 0; padding: 0; max-width: var(--read); }
.contents > li { padding: .55rem 0; border-bottom: 1px solid var(--border); }
.contents > li:last-child { border-bottom: 0; }
.contents-page, .contents-head { display: flex; align-items: center; gap: .55rem; font-weight: 550; }
.contents-head { font-size: 1.05rem; color: var(--fg); }
.contents-head .muted { margin-left: auto; font-weight: 400; }
.contents-page .octicon, .contents-head .octicon { color: var(--muted); }
.contents-desc { margin: .15rem 0 0 1.6rem; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.contents .contents { margin: .4rem 0 0 .45rem; padding-left: 1rem; border-left: 2px solid var(--border); }
.contents .contents > li { padding: .35rem 0; border-bottom: 0; }
.contents-fold { margin: .3rem 0 0 1.6rem; }
.contents-fold > summary { display: inline-flex; align-items: center; gap: .3rem; list-style: none; cursor: pointer; color: var(--accent); font-size: .85rem; padding: .15rem 0; }
.contents-fold > summary::-webkit-details-marker { display: none; }
.contents-fold > summary .octicon { transition: transform .15s; }
.contents-fold[open] > summary .octicon { transform: rotate(90deg); }
.contents-fold > .contents { margin-left: -1.15rem; }
.jump-link { display: inline-flex; align-items: center; gap: .45rem; margin: 0 0 1.25rem; padding: .35rem .75rem; font-size: .88rem; color: var(--fg); background: var(--bg-alt); border: 1px solid var(--border); border-radius: 999px; }
.jump-link:hover { text-decoration: none; border-color: var(--border-strong); }
.jump-link .octicon:last-child { color: var(--muted); }
.rail-jump { display: inline-flex; align-items: center; gap: .45rem; margin-top: 1rem; font-size: .85rem; color: var(--muted); }
.rail-jump:hover { color: var(--accent); text-decoration: none; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; max-width: var(--read); margin-top: 3rem; }
.pager a { display: flex; flex-direction: column; gap: .15rem; padding: .75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); color: var(--fg); background: var(--surface); }
.pager a:hover { text-decoration: none; border-color: var(--accent); }
.pager-next { grid-column: 2; text-align: right; align-items: flex-end; }
.pager-label { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; color: var(--muted); }
.pager-title { font-weight: 600; color: var(--accent); overflow-wrap: anywhere; }
.pager + .last-commit { margin-top: 1.5rem; }
.contents-files { font-size: .9rem; margin: 1.5rem 0 .6rem; color: var(--muted); }

/* home */
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .9rem; }
.card {
  display: flex; flex-direction: column; gap: .4rem; height: 100%; padding: 1rem 1.1rem; color: var(--fg);
  background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) + 2px);
  border-top: 3px solid var(--book, var(--accent)); transition: box-shadow .15s, transform .15s;
}
.card:hover { text-decoration: none; box-shadow: var(--shadow); transform: translateY(-1px); }
.card .book-icon { width: 2.1rem; height: 2.1rem; }
.card-title { font-weight: 650; font-size: 1.05rem; }
.card-desc { color: var(--muted); font-size: .88rem; line-height: 1.45; }
.card-meta { margin-top: auto; color: var(--muted); font-size: .78rem; }
.home-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0 2.5rem; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: 0; }

/* rendered markdown */
.markdown-body { overflow-wrap: break-word; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2 { padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { position: relative; margin: 1.5em 0 .6em; line-height: 1.25; }
.markdown-body .anchor { position: absolute; left: -1.1em; width: 1em; opacity: 0; text-decoration: none; }
.markdown-body .anchor::before { content: "#"; color: var(--muted); }
.markdown-body :is(h1,h2,h3,h4,h5,h6):hover .anchor { opacity: 1; }
.markdown-body img { max-width: 100%; height: auto; }
.markdown-body pre { overflow: auto; padding: .8rem 1rem; background: var(--code-bg); border-radius: var(--radius); font-size: .88rem; line-height: 1.45; }
.markdown-body code, .markdown-body tt { font-family: var(--mono); font-size: .88em; background: var(--code-bg); padding: .15em .35em; border-radius: 4px; }
.markdown-body pre code { background: none; padding: 0; font-size: inherit; }
.markdown-body .highlight pre.chroma { background: var(--code-bg); }
.markdown-body pre.plain { white-space: pre-wrap; }
.markdown-body blockquote { margin: 1em 0; padding: 0 1em; color: var(--muted); border-left: .25em solid var(--border); }
.markdown-body table { border-collapse: collapse; display: block; max-width: 100%; overflow: auto; margin: 1em 0; }
.markdown-body th, .markdown-body td { padding: .35rem .75rem; border: 1px solid var(--border); }
.markdown-body tr:nth-child(2n) { background: var(--bg-alt); }
.markdown-body hr { border: 0; border-top: 1px solid var(--border); margin: 1.5em 0; }
.markdown-body li > input[type=checkbox] { margin-right: .4em; }
.markdown-body ul.contains-task-list { list-style: none; padding-left: 1.2em; }
.markdown-body a.internal.absent { color: var(--danger); }
.markdown-body .footnotes { font-size: .9em; color: var(--muted); border-top: 1px solid var(--border); margin-top: 2rem; }
.markdown-body table.metadata { font-size: .9rem; margin: 0 0 1.5rem; }
.markdown-body table.metadata th { text-align: left; background: var(--bg-alt); white-space: nowrap; }
.markdown-body .toc { display: inline-block; min-width: 14rem; max-width: 100%; padding: .6rem 1rem; margin: .5rem 0 1rem; background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius); font-size: .92rem; }
.markdown-body .toc-title { font-weight: 600; margin-bottom: .25rem; }
.markdown-body .toc ul { margin: 0; padding-left: 1.2rem; }
.markdown-body .clearfloat { clear: both; }
.markdown-body .image.frame { display: inline-block; border: 1px solid var(--border); padding: 4px; background: var(--bg-alt); text-align: center; }
.markdown-body .image .caption { display: block; font-size: .85em; color: var(--muted); padding-top: 2px; }
.markdown-body .image.float-left { float: left; margin: 0 1em 1em 0; }
.markdown-body .image.float-right { float: right; margin: 0 0 1em 1em; }
.markdown-body .image.align-center { display: block; text-align: center; }
.markdown-body .image.align-left { display: block; text-align: left; }
.markdown-body .image.align-right { display: block; text-align: right; }
.markdown-body .include { border-left: 3px solid var(--border); padding-left: 1rem; margin: 1rem 0; }
.markdown-body .include-error { color: var(--danger); font-style: italic; }
.markdown-body pre.mermaid { background: none; text-align: center; }

/* lists */
.listing { list-style: none; padding: 0; margin: 0; max-width: var(--read); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.listing li + li { border-top: 1px solid var(--border); }
.listing a { display: flex; align-items: center; gap: .5rem; padding: .5rem .8rem; }
.listing a:hover { background: var(--bg-alt); text-decoration: none; }
.results { list-style: none; padding: 0; }
.results li { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.results .result-title { font-size: 1.1rem; }
.results .path { font-size: .8rem; }
.tags { margin-top: .25rem; display: flex; flex-wrap: wrap; gap: .25rem; }
.tag { font-size: .75rem; padding: 0 .5rem; border: 1px solid var(--border); border-radius: 1rem; color: var(--muted); text-decoration: none; }
.tag:hover { color: var(--fg); border-color: currentColor; }
.snippet { margin: .25rem 0 0; font-size: .9rem; color: var(--muted); overflow-wrap: anywhere; }
mark { background: var(--mark); color: inherit; padding: 0 .1em; border-radius: 2px; }
.empty { text-align: center; padding: 3rem 1rem; }

table.history { width: 100%; border-collapse: collapse; }
table.history th, table.history td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.history .pick { width: 2rem; }
table.history .msg { overflow-wrap: anywhere; }
table.history tr.more td { text-align: center; }
ol.changes { list-style: none; padding: 0; }
ol.changes > li { padding: .75rem 0; border-bottom: 1px solid var(--border); }
ol.changes .msg { font-weight: 600; }
ul.files { list-style: none; padding: 0; margin: .4rem 0 0; font-size: .9rem; }
.badge { display: inline-block; min-width: 4.6rem; text-align: center; padding: 0 .4rem; font-size: .75rem; border-radius: 10px; border: 1px solid var(--border); color: var(--muted); }
.badge.added { color: var(--ok); border-color: var(--ok); }
.badge.deleted { color: var(--danger); border-color: var(--danger); }
.badge.renamed { color: var(--accent); border-color: var(--accent); }

.commit-message { white-space: pre-wrap; font: inherit; margin: 0 0 .5rem; }

/* diffs */
.diff-file { border: 1px solid var(--border); border-radius: var(--radius); margin: 1rem 0; overflow-x: auto; }
.diff-file > header { padding: .5rem .8rem; background: var(--bg-alt); border-bottom: 1px solid var(--border); display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.diff-file .note { padding: .5rem .8rem; margin: 0; color: var(--muted); }
table.diff { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: .85rem; }
table.diff tr.hunk td { background: var(--bg-alt); color: var(--muted); padding: .15rem .6rem; }
table.diff td { padding: 0 .6rem; vertical-align: top; }
table.diff td.code { width: 100%; }
table.diff td.sign { width: 1.5rem; user-select: none; color: var(--muted); }
table.diff pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
table.diff tr.add { background: var(--add-bg); }
table.diff tr.del { background: var(--del-bg); }

.preview { margin-top: 1rem; }
.preview:not(:empty) { padding-top: 1rem; border-top: 1px solid var(--border); }

/* editor */
.banner.warn { background: var(--warn-bg); border-color: var(--warn-border); }
.editor-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem; padding: .3rem; border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; background: var(--bg-alt); }
.editor-bar.off .tb, .editor-bar.off .sep { display: none; }
.editor-bar .tb { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; padding: 0; color: var(--fg); background: none; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; }
.editor-bar .tb:hover { background: var(--bg); border-color: var(--border); }
.editor-bar .sep { width: 1px; height: 1.2rem; margin: 0 .3rem; background: var(--border); }
.editor-bar .spacer { flex: 1; }
.editor-bar label { font-size: .85rem; display: flex; align-items: center; gap: .3rem; }
.editor-bar select { padding: .1rem .3rem; font-size: .85rem; }
.editor .draft-banner { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 0 .5rem; }
.js .editor-bar + textarea, .js .editor-bar ~ .ace-host { border-top-left-radius: 0; border-top-right-radius: 0; }
.ace-host { height: 60vh; min-height: 16rem; border: 1px solid var(--border); border-radius: var(--radius); }
.ace_editor { font-family: var(--mono); }
.conflict details { margin: .5rem 0; border: 1px solid var(--border); border-radius: var(--radius); }
.conflict summary { cursor: pointer; padding: .4rem .8rem; background: var(--bg-alt); }
.conflict code { white-space: nowrap; }
.js .editor-bar.js-only { display: flex; }

/* sync admin */
table.kv { border-collapse: collapse; margin: 1rem 0; }
table.kv th { text-align: left; padding: .3rem 1.2rem .3rem 0; color: var(--muted); font-weight: normal; vertical-align: top; }
table.kv td { padding: .3rem 0; }
.badge.state-idle { color: var(--ok); border-color: var(--ok); }
.badge.state-offline, .badge.state-auth-error { color: var(--danger); border-color: var(--danger); }
.event { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem 1rem; margin: .75rem 0; }
.event.dismissed { opacity: .65; }
.event header { display: flex; align-items: center; gap: .6rem; }
.event details { margin: .3rem 0; }
form.inline { display: inline; margin-left: auto; }

/* users and login */
button.linklike { background: none; border: 0; padding: 0; font: inherit; font-size: .95rem; color: var(--muted); cursor: pointer; }
button.linklike:hover { color: var(--fg); text-decoration: underline; }
.login { max-width: 24rem; margin: 2rem auto; }
.login input[type=text], .login input[type=password], .edit-form input[type=password] { width: 100%; max-width: 24rem; }
code.token { display: block; padding: .5rem .7rem; background: var(--code-bg); border-radius: var(--radius); overflow-wrap: anywhere; user-select: all; }

/* macros */
.markdown-body .flash { margin: 1em 0; padding: .7rem 1rem; border: 1px solid var(--border); border-left-width: .3rem; border-radius: var(--radius); background: var(--bg-alt); }
.markdown-body .flash-info { border-left-color: var(--accent); }
.markdown-body .flash-success { border-left-color: var(--ok); }
.markdown-body .flash-warn { border-left-color: var(--warn-border); background: var(--warn-bg); }
.markdown-body .flash-error { border-left-color: var(--danger); }
.markdown-body .macro-error { color: var(--danger); font-style: italic; }
.markdown-body video.media, .markdown-body audio.media { max-width: 100%; display: block; margin: 1em 0; }
.markdown-body ul.all-pages { columns: 2 14rem; }
.markdown-body .global-toc ul { list-style: none; padding-left: 1.2rem; }
.markdown-body .global-toc > ul { padding-left: 0; }
.markdown-body .global-toc li.dir > span { font-weight: 600; }
.markdown-body nav.navigation ul { list-style: none; padding-left: 0; }
.markdown-body nav.navigation li.current { font-weight: 600; }
.markdown-body nav.series { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; align-items: center; margin: 1em 0; padding: .5rem .8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-alt); font-size: .92rem; }
.markdown-body nav.series .series-name { color: var(--muted); flex: 1; text-align: center; }
.markdown-body .octicon { vertical-align: text-bottom; }

/* CriticMarkup */
.markdown-body ins.critic { background: var(--add-bg); text-decoration: none; }
.markdown-body del.critic { background: var(--del-bg); }
.markdown-body mark.critic { background: var(--mark); }
.markdown-body .critic.comment { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 4px; padding: 0 .35em; font-size: .88em; color: var(--muted); }
.markdown-body .critic.comment::before { content: "💬 "; }

/* uploads */
.upload-status:not(:empty) { margin: .4rem 0; font-size: .9rem; }
.editor.dragging textarea, .editor.dragging .ace-host { outline: 2px dashed var(--accent); outline-offset: -2px; }

/* editor tabs and actions */
.js .editor-tabs { display: none; }
.editor-tab {
  display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .9rem; font: inherit; font-size: .9rem; color: var(--muted);
  background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer;
}
.editor-tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }

/* ---- responsive ---- */
@media (min-width: 960px) and (max-width: 1239px) {
  .page.has-toc .page-grid { grid-template-columns: minmax(0, var(--read)); }
  .toc-rail { display: none; }
  .toc-inline { display: block; max-width: var(--read); }
}
@media (max-width: 959px) {
  :root { --nav-w: min(20rem, 86vw); }
  .shell { display: block; }
  main { padding: 1rem 1rem 0; }
  .nav-toggle { display: inline-flex; }
  .nav {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; width: var(--nav-w); height: auto;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; visibility: hidden;
  }
  .nav:target, .nav.open { transform: none; visibility: visible; box-shadow: var(--shadow); }
  .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(10, 15, 25, .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .nav:target + .nav-backdrop, .nav.open + .nav-backdrop { opacity: 1; pointer-events: auto; }
  .nav-scroll { padding-top: 1.25rem; }
  .nav-link, .nav-foot a { padding-top: .5rem; padding-bottom: .5rem; }
  .page-grid, .page.has-toc .page-grid { grid-template-columns: minmax(0, 1fr); }
  .toc-rail { display: none; }
  .toc-inline { display: block; }
  .page-head { max-width: none; }
}
@media (max-width: 719px) {
  .topbar { gap: .35rem; padding: 0 .75rem; }
  .search { margin-left: 0; flex: 1; }
  .kbd { display: none; }
  .js .search { display: none; }
  /* backdrop-filter would make the bar the containing block of the sheet */
  .js body.search-active .topbar { backdrop-filter: none; }
  .js .search-open { display: inline-flex; }
  .js body.search-active .search {
    display: flex; position: fixed; inset: 0; z-index: 60; flex-direction: column; align-items: stretch; padding: .6rem .75rem; background: var(--bg);
  }
  .js body.search-active .search .search-icon { top: 1.25rem; left: 1.4rem; }
  .js body.search-active .search input[type=search] { height: 2.75rem; font-size: 1rem; padding-right: 3rem; }
  .js body.search-active .search-close { display: inline-flex; position: absolute; right: 1rem; top: .85rem; }
  .js body.search-active .search-pop { display: block; position: static; margin-top: .6rem; max-height: none; flex: 1; border: 0; box-shadow: none; padding: 0; }
  .js body.search-active .search-hit { padding: .7rem .5rem; }
  .user-label { display: none; }
  .page-title { font-size: 1.6rem; }
  .page-head { margin-bottom: 1rem; }
  .page-actions .edit-btn { display: none; }
  .fab {
    display: inline-flex; align-items: center; justify-content: center; position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 20;
    width: 3.25rem; height: 3.25rem; border-radius: 50%; background: var(--accent); color: var(--accent-fg); box-shadow: var(--shadow);
  }
  .fab:hover { text-decoration: none; }
  .fab .octicon { width: 20px; height: 20px; }
  .icon-btn, .btn { min-height: 2.6rem; }
  .menu-pop a, .menu-pop button { padding: .65rem .75rem; }
  .markdown-body pre { margin-left: -1rem; margin-right: -1rem; border-radius: 0; }
  table.history th:nth-child(3), table.history td:nth-child(3) { display: none; }

  /* editor */
  .js .editor-tabs { display: flex; margin-bottom: .5rem; border-bottom: 1px solid var(--border); }
  .js .desktop-only { display: none; }
  .editor-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .editor-bar .tb { flex: none; width: 2.5rem; height: 2.5rem; }
  .editor-bar .keymap-label { display: none; }
  .ace-host { height: calc(100dvh - 17rem); min-height: 14rem; }
  .editor textarea { min-height: calc(100dvh - 17rem); }
  .editor-actions {
    position: sticky; bottom: 0; z-index: 15; margin: 0 -1rem; padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom));
    background: var(--bg); border-top: 1px solid var(--border); flex-wrap: nowrap;
  }
  .editor-actions input[type=text] { flex: 1 1 auto; min-width: 0; }
  .editor-actions .btn { flex: none; }
  .edit-tab-preview .editor-bar, .edit-tab-preview .editor .ace-host, .edit-tab-preview .editor textarea { display: none !important; }
  .js body:not(.edit-tab-preview) #preview { display: none; }
  .edit-tab-preview #preview { margin-top: 0; padding-top: 0; border-top: 0; min-height: calc(100dvh - 14rem); }
}
