/* ---- three column wiki layout (left: site directory, center: content, right: page TOC) ---- */
.wiki-layout {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box;
}
.wiki-sidebar {
  flex: 0 0 240px;
  width: 240px;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 10px 4px 20px 0;
  border-right: 1px solid #eee;
  font-size: 14px;
}
.wiki-sidebar[hidden] { display: none; }
.wiki-toc {
  flex: 0 0 220px;
  width: 220px;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 10px 0 20px 4px;
  border-left: 1px solid #eee;
  font-size: 14px;
}
.wiki-main {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 820px;
  padding: 10px 0 40px;
}
/* never let wide content push the page sideways (applies at all widths).
   the bundled theme sets inline `code{white-space:nowrap}` and
   `pre code{white-space:pre}`, so long code/URLs overflow unless tamed. */
.wiki-main { overflow-wrap: break-word; }
.wiki-main img { max-width: 100%; height: auto; }
.wiki-main pre,
.wiki-main div.sourceCode { max-width: 100%; overflow-x: auto; }
.wiki-main table { display: block; max-width: 100%; overflow-x: auto; }
.wiki-main :not(pre) > code { white-space: normal; overflow-wrap: break-word; word-break: break-word; }
mjx-container[display="true"] { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
/* site directory tree */
.wiki-sidebar .wiki-home {
  display: block;
  font-weight: bold;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
  text-decoration: none;
  color: #333;
}
.wiki-sidebar ul { list-style: none; margin: 0 0 0 12px; padding: 0; }
.wiki-sidebar > ul { margin-left: 0; }
.wiki-sidebar li { line-height: 1.7; }
.wiki-sidebar a { text-decoration: none; color: #555; }
.wiki-sidebar a:hover { color: #0088cc; text-decoration: underline; }
.wiki-sidebar a.active { color: #0088cc; font-weight: bold; }
/* page TOC */
.wiki-toc ul { list-style: none; margin: 0 0 0 12px; padding: 0; }
.wiki-toc > ul { margin-left: 0; }
.wiki-toc li { line-height: 1.6; }
.wiki-toc a { text-decoration: none; color: #555; }
.wiki-toc a:hover { color: #0088cc; }
/* collapse toggle (mobile only) */
.wiki-collapse-btn { display: none; }
@media (max-width: 980px) {
  .wiki-layout { flex-direction: column; gap: 0; align-items: stretch; }
  /* page TOC on top, then content, then the whole-site directory */
  .wiki-toc { order: 0; }
  .wiki-main { order: 1; max-width: none; padding-top: 0; margin-top: 12px; }
  .wiki-sidebar { order: 2; }
  .wiki-sidebar, .wiki-toc {
    position: static;
    width: 100%;
    flex-basis: auto;
    max-height: none;
    overflow: visible;
    border: 0;
    padding: 0;
    margin-top: 12px;
  }
  .wiki-collapse-btn {
    display: block;
    width: 100%;
    text-align: left;
    font: inherit;
    font-size: 15px;
    font-weight: bold;
    color: #333;
    background: #f7f7f7;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    padding: 10px 14px;
    margin: 0;
    cursor: pointer;
  }
  .wiki-collapse-btn::after { content: '\25be'; float: right; }
  .wiki-collapse-btn[aria-expanded="true"]::after { content: '\25b4'; }
  /* collapsed state: show only the toggle button */
  .wiki-sidebar:not(.open) .wiki-home,
  .wiki-sidebar:not(.open) > ul,
  .wiki-toc:not(.open) > ul { display: none; }
  .wiki-sidebar.open > ul,
  .wiki-toc.open > ul { margin-top: 8px; }
  /* the bundled bootstrap theme pins .container to a fixed 940px, which
     forces the whole page wider than a phone screen -> override it */
  .container,
  .navbar-static-top .container,
  .navbar-fixed-top .container,
  .navbar-fixed-bottom .container { width: auto; max-width: 100%; }
}
