/* msb-manager docs — a terminal, rendered.
 *
 * Two palettes behind one set of variables. <html data-theme> is set by the
 * inline script in template.html before anything paints: the stored choice,
 * else prefers-color-scheme. No web fonts: nothing is fetched from anywhere
 * but this site, and every machine already has a monospace face. */

:root {
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", "SF Mono", "Fira Code",
          Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  --top: 3.25rem;
  --radius: 6px;
}

html[data-theme="dark"] {
  --bg: #0b0e0c;
  --bg-2: #101512;
  --bg-3: #161d18;
  --fg: #cfd8cf;
  --fg-strong: #eef5ee;
  --dim: #77847a;
  --line: #243027;
  --green: #7ee787;
  --amber: #e3b341;
  --cyan: #6cc3f5;
  --magenta: #d2a8ff;
  --red: #ff7b72;
  /* The logo's lavender. Green stays for what a terminal paints green:
     prompts and success. */
  --accent: #c488ff;
  --accent-soft: #e7c1ff;
  --mark: rgba(227, 179, 65, 0.28);
  --glow: 0 0 0.6em rgba(196, 136, 255, 0.3);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #fbfaf4;
  --bg-2: #f3f1e6;
  --bg-3: #eae7d8;
  --fg: #2b2f2a;
  --fg-strong: #10130f;
  --dim: #6c7066;
  --line: #d9d5c3;
  --green: #1a7f37;
  --amber: #8a5a00;
  --cyan: #0b5cad;
  --magenta: #7a3ea8;
  --red: #c4271c;
  --accent: #7340b0;
  --accent-soft: #8456be;
  --mark: rgba(191, 135, 0, 0.25);
  --glow: none;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--top) + 1rem); }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.65 var(--mono);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--cyan); text-decoration: underline dotted; text-underline-offset: 3px; }
a:hover { color: var(--accent); text-decoration-style: solid; }
::selection { background: var(--accent); color: var(--bg); }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 0.5rem; z-index: 100; background: var(--bg); padding: 0.25rem 0.5rem; }

:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ------------------------------------------------------------- top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--top);
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 100%;
  padding: 0 1rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  color: var(--fg-strong);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}
.brand:hover { color: var(--fg-strong); }
.brand-mark { align-self: center; width: 26px; height: 26px; }
/* The "-dark" artwork is lavender for dark grounds; on the light theme it is
   deepened rather than redrawn. */
html[data-theme="light"] .brand-mark, html[data-theme="light"] .hero img {
  filter: brightness(0.62) saturate(1.4);
}

/* The overview's large mark. */
.doc .hero { margin: 0 0 1.5rem; }
.doc .hero img { display: block; width: 7.5rem; height: auto; }
.doc img { max-width: 100%; }
.brand-path { color: var(--accent); text-shadow: var(--glow); }
.brand-dollar { color: var(--dim); }
.cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.05em;
  margin-left: 0.1em;
  transform: translateY(0.18em);
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.version {
  color: var(--dim);
  font-size: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 0.5rem;
}

.btn, .menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 2rem;
  padding: 0 0.6rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover, .menu-btn:hover { border-color: var(--accent); color: var(--accent); }
.gh svg { flex: none; }
.menu-btn { display: none; font-size: 1.1rem; padding: 0 0.55rem; }

/* -------------------------------------------------------------- search */

.search {
  position: relative;
  margin-left: auto;
  display: flex;
  align-items: center;
  width: min(26rem, 40vw);
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}
.search:focus-within { border-color: var(--accent); box-shadow: var(--glow); }
.search-label { color: var(--amber); padding: 0 0.5rem; font-size: 0.85rem; user-select: none; }
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  font: inherit;
  font-size: 0.9rem;
  color: var(--fg-strong);
  background: transparent;
  border: 0;
  outline: none;
}
.search input::-webkit-search-cancel-button { display: none; }
.search-key {
  margin: 0 0.4rem;
  padding: 0 0.35rem;
  font: inherit;
  font-size: 0.75rem;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.search-results {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  max-height: min(70vh, 32rem);
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  min-width: 22rem;
}
.search-results a {
  display: block;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  color: var(--fg);
  text-decoration: none;
}
.search-results a:last-child { border-bottom: 0; }
.search-results a[aria-selected="true"], .search-results a:hover { background: var(--bg-3); }
.search-results a[aria-selected="true"] .r-head::before { content: "> "; color: var(--accent); }
.r-head { color: var(--fg-strong); font-weight: 700; }
.r-page { color: var(--dim); font-weight: 400; }
.r-snip { display: block; font-size: 0.8rem; color: var(--dim); margin-top: 0.15rem; }
.search-results mark { background: var(--mark); color: inherit; border-radius: 2px; }
.r-empty { padding: 0.75rem; color: var(--dim); font-size: 0.85rem; }

/* -------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr) 15rem;
  max-width: 92rem;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: var(--top);
  height: calc(100vh - var(--top));
  overflow-y: auto;
  padding: 1.5rem 1rem 2rem 1.25rem;
  border-right: 1px solid var(--line);
  font-size: 0.9rem;
}
.nav-group + .nav-group { margin-top: 1.1rem; }
.nav-dir { color: var(--amber); font-weight: 700; }
.nav-dir::before { content: "▸ "; color: var(--dim); }
.sidebar ul { list-style: none; margin: 0.15rem 0 0; padding: 0; }
.sidebar li { display: flex; gap: 0.4rem; white-space: nowrap; }
.branch { color: var(--line); user-select: none; }
html[data-theme="light"] .branch { color: var(--dim); opacity: 0.6; }
.sidebar a { color: var(--fg); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.sidebar a:hover { color: var(--accent); }
.sidebar a.active { color: var(--accent); font-weight: 700; text-shadow: var(--glow); }
.sidebar a.active::before { content: "▌"; margin-right: 0.2rem; }

.content { min-width: 0; padding: 2rem 2.5rem 3rem; outline: none; }
.doc { max-width: 52rem; }

.toc {
  position: sticky;
  top: var(--top);
  align-self: start;
  max-height: calc(100vh - var(--top));
  overflow-y: auto;
  padding: 2rem 1rem;
  font-size: 0.8rem;
}
.toc-title { color: var(--dim); text-transform: lowercase; margin-bottom: 0.4rem; }
.toc-title::before { content: "# "; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li { padding-left: 0.75rem; }
.toc li.toc-l3 { padding-left: 1.6rem; }
.toc a { color: var(--dim); text-decoration: none; display: block; padding: 0.1rem 0; }
.toc a:hover, .toc a.current { color: var(--accent); }

/* ---------------------------------------------------------- typography */

.doc h1, .doc h2, .doc h3, .doc h4 {
  color: var(--fg-strong);
  line-height: 1.3;
  scroll-margin-top: calc(var(--top) + 1rem);
}
.doc h1 { font-size: 1.6rem; margin: 0 0 1.5rem; }
.h1-prompt { color: var(--accent); font-weight: 400; }
.doc h2 { font-size: 1.2rem; margin: 2.5rem 0 0.75rem; padding-bottom: 0.3rem; border-bottom: 1px dashed var(--line); }
.doc h2::before { content: "## "; color: var(--accent); }
.doc h3 { font-size: 1.02rem; margin: 2rem 0 0.5rem; }
.doc h3::before { content: "### "; color: var(--dim); }
.doc h4 { font-size: 0.95rem; margin: 1.5rem 0 0.4rem; color: var(--amber); }
.anchor { margin-left: 0.5rem; color: var(--dim); text-decoration: none; opacity: 0; }
.doc :is(h2, h3, h4):hover .anchor, .anchor:focus { opacity: 1; }

.doc p, .doc ul, .doc ol { margin: 0.75rem 0; }
.doc ul { list-style: none; padding-left: 1.4rem; }
.doc ul > li { position: relative; }
.doc ul > li::before { content: "-"; position: absolute; left: -1.1rem; color: var(--accent); }
.doc ol { padding-left: 1.8rem; }
.doc ol > li::marker { color: var(--accent); }
.doc li { margin: 0.25rem 0; }
.doc li > ul, .doc li > ol { margin: 0.25rem 0; }
.doc strong { color: var(--fg-strong); }
.doc em { color: var(--amber); font-style: normal; }
.doc hr { border: 0; border-top: 1px dashed var(--line); margin: 2rem 0; }

.doc code {
  font: inherit;
  font-size: 0.92em;
  color: var(--accent-soft);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05em 0.3em;
}
.doc a code { color: inherit; }
.doc h2 code, .doc h3 code { color: inherit; background: none; border: 0; padding: 0; }

/* ------------------------------------------------- terminal code blocks */

.term {
  margin: 1rem 0 1.25rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.term-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 1.9rem;
  padding: 0 0.6rem;
  background: var(--bg-3);
  border-bottom: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--dim);
}
.dots { display: inline-flex; gap: 0.3rem; }
.dots i { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--line); }
.term:hover .dots i:nth-child(1) { background: #ff5f57; }
.term:hover .dots i:nth-child(2) { background: #febc2e; }
.term:hover .dots i:nth-child(3) { background: #28c840; }
.term-title { flex: 1; }
.copy {
  font: inherit;
  font-size: 0.75rem;
  color: var(--dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0 0.4rem;
  cursor: pointer;
}
.copy:hover { color: var(--green); border-color: var(--line); }
.copy.done { color: var(--green); }
.term pre { margin: 0; padding: 0.9rem 1rem; overflow-x: auto; }
.doc .term code {
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--fg);
  /* Not the inline-code chip: inside a block it would box every line. */
  background: none;
  border: 0;
  padding: 0;
}
.t-prompt { color: var(--green); user-select: none; }
.t-cmd { color: var(--fg-strong); }
.t-out { color: var(--dim); }
.t-com { color: var(--dim); font-style: italic; }
.t-str { color: var(--amber); }
.t-tbl { color: var(--cyan); font-weight: 700; }
.t-key { color: var(--green); }

/* -------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; margin: 1rem 0; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
th, td { text-align: left; vertical-align: top; padding: 0.45rem 0.75rem; border-bottom: 1px solid var(--line); }
th { color: var(--amber); background: var(--bg-2); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }

/* ------------------------------------------------------------ callouts */

.callout, .doc blockquote {
  margin: 1.25rem 0;
  padding: 0.6rem 1rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--cyan);
  border-radius: var(--radius);
}
.callout::before {
  content: "[" attr(data-label) "]";
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cyan);
  text-transform: lowercase;
}
.callout-tip { border-left-color: var(--green); }
.callout-tip::before { color: var(--green); }
.callout-warning, .callout-important { border-left-color: var(--amber); }
.callout-warning::before, .callout-important::before { color: var(--amber); }
.callout > :first-child, .doc blockquote > :first-child { margin-top: 0.25rem; }
.callout > :last-child, .doc blockquote > :last-child { margin-bottom: 0.25rem; }

/* ---------------------------------------------------------- pager, foot */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: 52rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--line);
}
.pager a { text-decoration: none; padding: 0.4rem 0.6rem; border: 1px solid var(--line); border-radius: var(--radius); }
.pager a:hover { border-color: var(--accent); }
.dim { color: var(--dim); }

.footer {
  display: flex;
  justify-content: space-between;
  max-width: 52rem;
  margin-top: 2rem;
  font-size: 0.8rem;
  color: var(--dim);
}
.footer a { color: var(--dim); }

/* ---------------------------------------------------------- responsive */

@media (max-width: 1200px) {
  .layout { grid-template-columns: 15rem minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 860px) {
  .layout { display: block; }
  .menu-btn { display: inline-flex; }
  .version, .gh span, .brand-path { display: none; }
  /* An <input> keeps an intrinsic width of ~20 characters unless told
     otherwise, which pushed the buttons off a phone screen. */
  .search { width: auto; flex: 1; min-width: 0; }
  .search input { width: 100%; }
  .search-label { padding: 0 0.35rem; }
  .search-key { display: none; }
  .topbar-inner { gap: 0.5rem; padding: 0 0.6rem; }
  .search-results { min-width: 0; position: fixed; left: 0.5rem; right: 0.5rem; top: calc(var(--top) + 0.25rem); }
  .sidebar {
    position: fixed;
    z-index: 15;
    top: var(--top);
    left: 0;
    width: min(18rem, 85vw);
    background: var(--bg-2);
    transform: translateX(-100%);
    transition: transform 0.18s ease;
  }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45); }
  .content { padding: 1.5rem 1.1rem 3rem; }
}

@media (max-width: 480px) {
  .search-label { display: none; }
  .search input { padding-left: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  .sidebar { transition: none; }
}

@media print {
  .topbar, .sidebar, .toc, .pager, .copy { display: none; }
  .layout { display: block; }
}
