:root {
  --accent-1: #fdc811;
  --accent-2: #ff7808;
  --bg: #ffffff;
  --bg-alt: #f6f6f7;
  --bg-elev: #ffffff;
  --text-1: #3c3c43;
  --text-2: #67676c;
  --border: #e2e2e3;
  --link: #ff7808;
}
:root[data-theme="dark"] {
  --bg: #1b1b1f;
  --bg-alt: #161618;
  --bg-elev: #202127;
  --text-1: #dfdfd6;
  --text-2: #98989f;
  --border: #2a2a2e;
  --link: #ff7808;
}
* { box-sizing: border-box; }
body {
  font-family: ui-monospace, SFMono-Regular, monospace;
  margin: 0; line-height: 1.5;
  color: var(--text-1); background: var(--bg);
}
main, .page { max-width: 64rem; margin: 0 auto; padding: 1rem; }
a { color: var(--link); text-decoration: underline; }
a:hover { text-decoration: none; }
.brand, .sections-grid a { text-decoration: none; }

/* header */
.site-header {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem 1rem; background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; color: var(--text-1); font-weight: 700; }
.brand .logo { height: 26px; width: auto; display: block; }
.brand .brand-title { color: var(--text-1); }
.site-header .spacer { flex: 1; }
.hsearch input {
  width: 170px; max-width: 40vw; padding: .3rem .55rem;
  font: inherit; font-size: .85rem;
  color: var(--text-1); background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 6px;
}
.theme-toggle {
  font-size: .95rem; line-height: 1; cursor: pointer;
  padding: .3rem .5rem; border-radius: 6px;
  color: var(--text-1); background: var(--bg-elev); border: 1px solid var(--border);
}
.branch-select {
  font: inherit; font-size: .8rem; line-height: 1; cursor: pointer;
  padding: .3rem .4rem; border-radius: 6px;
  color: var(--text-1); background: var(--bg-elev); border: 1px solid var(--border);
}
.repo-link { display: inline-flex; align-items: center; color: var(--text-2); padding: .25rem; border-radius: 6px; }
.repo-link:hover { color: var(--link); text-decoration: none; }
.repo-link .repo-icon { display: block; }
.accent-bar { height: 3px; background: linear-gradient(90deg, #fdc811, #ff7808); }
.crumbs { max-width: 64rem; margin: 0 auto; padding: .4rem 1rem; font-size: .8rem; color: var(--text-2); }
.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--link); }

/* home */
.hero { text-align: center; padding: 2rem 1rem 1.4rem; background: var(--bg-alt); border-bottom: 1px solid var(--border); }
.hero h1 { font-size: 1.6rem; margin: .2rem 0 .4rem; }
.hero .lead { color: var(--text-2); max-width: 34rem; margin: 0 auto 1rem; }
.hero form { display: flex; justify-content: center; }
.hero input { width: 30rem; max-width: 90vw; padding: .55rem .7rem; font: inherit;
  color: var(--text-1); background: var(--bg-elev); border: 2px solid var(--link); border-radius: 8px; }
.hero .stats { margin-top: .8rem; font-size: .8rem; color: var(--text-2); }
.hero .stats b { color: var(--link); }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; }
.how .card { border: 1px solid var(--border); border-radius: 8px; padding: .7rem .8rem; background: var(--bg-elev); }
.how .card b { color: var(--link); display: inline-flex; align-items: center; gap: .4rem; }
.card-ico { width: 18px; height: 18px; flex: none; }
.how code, code.addr { background: var(--bg-alt); border: 1px solid var(--border); padding: .05rem .3rem; border-radius: 4px; }
.sections-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; list-style: none; padding: 0; }
@media (max-width: 560px) { .sections-grid { grid-template-columns: repeat(2, 1fr); } }
.sections-grid a { display: block; border: 1px solid var(--border); border-radius: 6px; padding: .45rem .6rem; background: var(--bg-elev); }
.sections-grid a:hover { border-color: var(--link); }
.sections-grid b { color: var(--link); }
/* exact-match block above the search results — the authoritative hit for the typed name */
#exact:not(:empty) { border: 1px solid var(--border); border-left: 3px solid var(--link); border-radius: 8px; padding: .5rem .8rem; margin: .6rem 0 1rem; background: var(--bg-elev); }
.exact-label { margin: 0 0 .3rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.exact-list { list-style: none; padding: 0; margin: 0; }
.exact-list li { padding: .15rem 0; }
.exact-list a { font-weight: 700; }
.exact-desc { color: var(--text-2); }
h2 { font-size: 1.15rem; border-bottom: 1px solid var(--border); padding-bottom: .2rem; margin-top: 1.5rem; }
ul { padding-left: 1.2rem; }
.foot { color: var(--text-2); font-size: .72rem; padding: 1rem; text-align: center; border-top: 1px solid var(--border); }

/* cross-branch branch bar + slide-out panel (packages.altlinux.org style, our palette) */
.branch-bar {
  position: fixed; left: 0; top: 0; height: 100%; width: 26px; z-index: 32;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem;
  border: 0; margin: 0; padding: .5rem 0;
  background: var(--accent-1); color: #1b1b1f; cursor: pointer;
}
.branch-bar:hover { background: var(--accent-2); color: #fff; }
.branch-bar-chevron::before { content: '\00BB'; font-size: 1.1rem; font-weight: 700; }
.branch-bar[aria-expanded="true"] .branch-bar-chevron::before { content: '\00AB'; }
.branch-bar-label {
  writing-mode: vertical-lr; transform: rotate(180deg);
  white-space: nowrap; font-weight: 700; font-size: .82rem; letter-spacing: .03em;
}
.branch-panel {
  position: fixed; left: 26px; top: 0; height: 100%; width: 15rem; max-width: 78vw; z-index: 31;
  background: var(--bg-elev); border-right: 1px solid var(--border);
  padding: 1rem; overflow-y: auto;
  transform: translateX(-120%); transition: transform .18s ease;
}
.branch-panel.open { transform: translateX(0); box-shadow: 3px 0 16px rgba(0,0,0,.25); }
.branch-panel h2 { font-size: 1rem; margin: 0 0 .6rem; border: none; padding: 0; }
/* Reserve the bar's gutter (branch-panel.js adds .has-branch-bar once the bar is shown) and, on a
   wide viewport, push the page content aside when the panel opens — like packages.altlinux.org —
   instead of overlaying it. On narrow screens the panel stays an overlay so it does not crush the
   content. */
body.has-branch-bar { margin-left: 26px; }
@media (min-width: 48rem) {
  body.has-branch-bar { transition: margin-left .18s ease; }
  body.has-branch-bar.branch-open { margin-left: calc(26px + 15rem); }
}
@media (prefers-reduced-motion: reduce) {
  body.has-branch-bar { transition: none; }
  .branch-panel { transition: none; }
}
#branch-list { list-style: none; padding: 0; margin: 0; }
#branch-list li { padding: .3rem 0; border-bottom: 1px solid var(--border); }
#branch-list li:last-child { border-bottom: none; }
#branch-list a { display: flex; justify-content: space-between; gap: .6rem; text-decoration: none; }
#branch-list a:hover { text-decoration: underline; }
#branch-list li.cur .bp-name { font-weight: 700; color: var(--link); }
.bp-ver { color: var(--text-2); font-size: .85rem; }
.bp-absent { color: var(--text-2); opacity: .7; }

/* "On this page" table of contents for long man pages (built client-side by page-toc.js) */
.page-toc {
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-alt);
  padding: .3rem .8rem .5rem; margin: 0 0 1.3rem; font-size: .9rem;
}
.page-toc summary {
  cursor: pointer; padding: .25rem 0; color: var(--text-2);
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.page-toc ul { list-style: none; margin: .35rem 0 0; padding: 0; columns: 2; column-gap: 1.4rem; }
.page-toc li { margin: .14rem 0; break-inside: avoid; }
.page-toc a { color: var(--link); text-decoration: none; }
.page-toc a:hover { text-decoration: underline; }
@media (max-width: 40rem) { .page-toc ul { columns: 1; } }
/* On a wide viewport, float the TOC to the right edge and keep it in place while the page scrolls
   (position: fixed); the page content shifts left to make room. Below this width it stays the top
   box above. page-toc.js adds body.has-toc so the content only shifts when a TOC is actually shown. */
@media (min-width: 60rem) {
  body.has-toc main { margin-right: 14rem; }
  .page-toc {
    position: fixed; top: 4.6rem; right: .75rem; z-index: 20;
    width: 12rem; max-height: calc(100vh - 6rem); overflow-y: auto;
    margin: 0; font-size: .8rem;
  }
  .page-toc ul { columns: 1; }
}

/* mandoc fragment */
h1.Sh, main h1 { font-size: 1.25rem; border-bottom: 1px solid var(--border); padding-bottom: .2rem; margin-top: 1.5rem; }
h1.manpage-title { font-size: 1.4rem; margin: .2rem 0 1rem; }
table.head, table.foot { width: 100%; color: var(--text-2); font-size: .85rem; }
dl.Bl-tag > dt { font-weight: bold; margin-top: .5rem; }

/* Pagefind search UI — themed via its own custom properties so results stay readable
   in both themes (default Pagefind colors assume a light background). */
:root .pagefind-ui {
  --pagefind-ui-primary: var(--link);
  --pagefind-ui-text: var(--text-1);
  --pagefind-ui-background: var(--bg);
  --pagefind-ui-border: var(--border);
  --pagefind-ui-tag: var(--bg-alt);
}
.pagefind-ui__result-link { color: var(--link); }
.pagefind-ui__result-excerpt { color: var(--text-2); }
.pagefind-ui__result-title mark, .pagefind-ui__result-excerpt mark {
  background: var(--link); color: #fff; padding: 0 .1em; border-radius: 2px;
}
