:root {
  --bg: #15131a;
  --bg-raised: #1c1922;
  --bg-inset: #211d29;
  --border: #2a2632;
  --text: #cdc7d4;
  --text-lead: #b8b1c2;
  --text-muted: #9a93a6;
  --text-faint: #6f6878;
  --heading: #e3cddc;
  --accent: #f49bd6;
  --accent-soft: rgba(244, 155, 214, 0.12);
  --accent-border: rgba(244, 155, 214, 0.35);
  --code-bg: #1a1720;
  --code-text: #e7c9ea;
  --warn-bg: #2b230f;
  --warn-border: #6b4f16;
  --warn-text: #e8c675;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

:root[data-theme="light"] {
  --bg: #faf7fb;
  --bg-raised: #ffffff;
  --bg-inset: #f1ecf3;
  --border: #e6dee8;
  --text: #372f3d;
  --text-lead: #4c4252;
  --text-muted: #6e6376;
  --text-faint: #948a9a;
  --heading: #2a2230;
  --accent: #c9448f;
  --accent-soft: rgba(201, 68, 143, 0.08);
  --accent-border: rgba(201, 68, 143, 0.3);
  --code-bg: #f1ecf3;
  --code-text: #8a2f66;
  --warn-bg: #fdf3df;
  --warn-border: #e8c675;
  --warn-text: #7a5b0f;
  --shadow: 0 8px 24px rgba(60, 40, 60, 0.08);
}

* { box-sizing: border-box; }

html {
  color-scheme: dark;
}
html[data-theme="light"] {
  color-scheme: light;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  transition: background 0.15s ease, color 0.15s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: "SF Mono", Consolas, Menlo, monospace;
  font-size: 0.9em;
}
code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.15em 0.4em;
  border-radius: 5px;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
}
pre code { background: none; padding: 0; }


/* overflow-x deliberately NOT on body (or any ancestor of .topbar/.sidebar/
   .toc) - overflow set to anything but visible on an ancestor silently
   disables position:sticky for every descendant in WebKit-based mobile
   browsers. That was the real cause of a real bug: the mobile hamburger
   button (inside the sticky .topbar) stopped being reachable the moment
   you scrolled away from the very top of the page, since the topbar's
   stickiness was quietly broken. Scoped to .content instead below, which
   is a sibling of the sticky elements, not an ancestor - still contains
   the actual risk (wide tables/code blocks bleeding horizontally) without
   breaking anything sticky. */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  color: var(--heading);
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.topbar-brand .mark { font-size: 1.3rem; flex: none; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
}

.topbar-link {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
}
.topbar-link:hover {
  color: var(--heading);
  background: var(--bg-inset);
  text-decoration: none;
}
.topbar-link.current {
  color: var(--accent);
  background: var(--accent-soft);
}

.theme-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-muted);
  border-radius: 8px;
  width: 2.1rem;
  height: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent-border); }
.no-js .theme-toggle { display: none; }

.menu-toggle-label {
  display: none;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-muted);
  border-radius: 8px;
  width: 2.1rem;
  height: 2.1rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
}


.layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 210px;
  gap: 0;
  max-width: 1440px;
  margin: 0 auto;
}
.layout.no-toc {
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem 3rem;
  align-self: start;
  position: sticky;
  top: 53px;
  max-height: calc(100vh - 53px);
  overflow-y: auto;
}

.sidebar-search {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-inset);
  color: var(--text);
  font-size: 0.85rem;
  margin-bottom: 1.1rem;
}
.sidebar-search:focus { outline: none; border-color: var(--accent-border); }
.no-js .sidebar-search { display: none; }

.sidebar-group { margin-bottom: 1.1rem; }
.sidebar-group-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
  margin: 0 0 0.4rem 0.5rem;
}
.sidebar-group ul { list-style: none; margin: 0; padding: 0; }
.sidebar-group li { margin: 0; }
.sidebar-group a {
  display: block;
  padding: 0.4rem 0.5rem;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.sidebar-group a:hover {
  background: var(--bg-inset);
  color: var(--heading);
  text-decoration: none;
}
.sidebar-group a.current {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.sidebar-group li[data-hidden="true"] { display: none; }

.sidebar-folder { margin: 0; }
.sidebar-folder > summary {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.5rem;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  list-style: none;
}
.sidebar-folder > summary::-webkit-details-marker { display: none; }
.sidebar-folder > summary::before {
  content: "";
  width: 0;
  height: 0;
  flex: none;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid var(--text-faint);
  transition: transform 0.15s ease;
}
.sidebar-folder[open] > summary::before { transform: rotate(90deg); }
.sidebar-folder > summary:hover { background: var(--bg-inset); color: var(--heading); }
.sidebar-folder > ul { list-style: none; margin: 0.1rem 0 0; padding: 0 0 0 1.05rem; }
.sidebar-folder > ul li { margin: 0; }

.content {
  padding: 2.5rem 3rem 5rem;
  min-width: 0;
  overflow-x: hidden;
}

.toc {
  padding: 1.25rem 1rem;
  align-self: start;
  position: sticky;
  top: 53px;
  max-height: calc(100vh - 53px);
  overflow-y: auto;
  font-size: 0.85rem;
}
.toc-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-faint);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  margin-bottom: 0.6rem;
}
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li a {
  display: block;
  padding: 0.3rem 0 0.3rem 0.8rem;
  margin-left: -1px;
  border-left: 1px solid transparent;
  color: var(--text-muted);
}
.toc li a:hover { color: var(--heading); text-decoration: none; }
.toc li a.active { color: var(--accent); border-left-color: var(--accent); }


.eyebrow {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}
.content h1 {
  margin: 0 0 0.5rem;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--heading);
}
.content .lede {
  color: var(--text-lead);
  font-size: 1.05rem;
  max-width: 60ch;
  margin-bottom: 2.5rem;
}
.content h2 {
  font-size: 1.4rem;
  font-weight: 650;
  color: var(--heading);
  margin: 2.75rem 0 0.9rem;
  scroll-margin-top: 70px;
}
.content h3 {
  font-size: 1.1rem;
  font-weight: 650;
  color: var(--heading);
  margin: 1.75rem 0 0.6rem;
  scroll-margin-top: 70px;
}
.content p { color: var(--text); }
.content ul, .content ol { color: var(--text); padding-left: 1.4rem; }
.content li { margin-bottom: 0.35rem; }
.content blockquote {
  margin: 1rem 0;
  padding: 0.2rem 1rem;
  border-left: 3px solid var(--accent-border);
  color: var(--text-lead);
}
.content blockquote p { margin: 0.5rem 0; }
.content hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }


.blog-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: -0.5rem 0 1.5rem;
}
.blog-meta .blog-author { color: var(--text-lead); font-weight: 600; }
.blog-list { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 1.5rem; }
.blog-list-item {
  display: block;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-raised);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.blog-list-item:hover { border-color: var(--accent-border); text-decoration: none; transform: translateY(-1px); }
.blog-list-item .blog-list-title { color: var(--heading); font-weight: 650; font-size: 1.05rem; margin-bottom: 0.25rem; }
.blog-list-item .blog-list-meta { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.4rem; }
.blog-list-item .blog-list-excerpt { color: var(--text-lead); font-size: 0.92rem; }
.rss-link { display: inline-flex; align-items: center; gap: 0.35rem; }

.callout {
  display: flex;
  gap: 0.7rem;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  margin: 1.2rem 0;
}
.callout .icon { flex: none; font-size: 1.1rem; }
.callout.warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}
.callout.warn p { color: var(--warn-text); margin: 0; }
.callout.info p { margin: 0; }

.img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px dashed var(--border);
  background: var(--bg-inset);
  color: var(--text-faint);
  border-radius: 12px;
  padding: 2.5rem 1rem;
  margin: 1.2rem 0;
  font-size: 0.9rem;
}

.doc-screenshot {
  display: block;
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 1.2rem 0 0.5rem;
}
.img-caption {
  color: var(--text-faint);
  font-size: 0.82rem;
  margin: 0 0 1.2rem;
}

.install-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  background: var(--accent);
  color: #1a0f16;
  font-size: 0.92rem;
  text-align: center;
}
.install-banner strong { font-weight: 700; }
.install-banner button {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
  padding: 0.1rem 0.3rem;
}
.install-banner button:hover { opacity: 1; }

.cmd-card {
  border: 1px solid var(--border);
  background: var(--bg-raised);
  border-radius: 12px;
  overflow: hidden;
  margin: 1.2rem 0;
  box-shadow: var(--shadow);
}
.cmd-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-faint);
}
.cmd-card pre {
  border: none;
  border-radius: 0;
  margin: 0;
}
.perm-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  margin: 0.1rem 0.3rem 0.1rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
  font-size: 0.92rem;
}
th, td {
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
th { color: var(--text-faint); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.7rem; margin: 1.2rem 0 1.6rem; }
.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.92rem;
}
.btn-primary { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-border); }
.btn-primary:hover { text-decoration: none; background: var(--accent-border); }
.btn-secondary { border: 1px solid var(--border); color: var(--text); background: var(--bg-raised); }
.btn-secondary:hover { text-decoration: none; border-color: var(--accent-border); }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem;
  margin: 1.4rem 0;
}
.grid-card {
  display: block;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  color: var(--text);
}
.grid-card:hover { border-color: var(--accent-border); text-decoration: none; }
.grid-card.stat { text-align: center; }
.grid-card.stat:hover { border-color: var(--border); }
.grid-card.stat .card-title { font-size: 1.7rem; justify-content: center; margin-bottom: 0.15rem; }
.grid-card.stat .card-desc { text-align: center; }
.grid-card .card-title { color: var(--heading); font-weight: 600; margin-bottom: 0.3rem; display: flex; align-items: center; gap: 0.4rem; }
.grid-card .card-desc { color: var(--text-muted); font-size: 0.88rem; }
.grid-card.featured {
  grid-column: 1 / -1;
  border-color: var(--accent-border);
  background: linear-gradient(135deg, var(--bg-raised), var(--accent-bg, var(--bg-inset)));
}
.grid-card.featured .card-title { font-size: 1.15rem; }

.page-footer {
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}


@media (max-width: 980px) {
  .layout, .layout.no-toc {
    grid-template-columns: 1fr;
  }
  .toc { display: none; }
  .sidebar {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem 0.75rem;
  }
  .sidebar-inner { display: none; }
  .menu-toggle:checked ~ .layout .sidebar-inner { display: block; padding-top: 0.75rem; }
  .menu-toggle-label { display: inline-flex; }
  .content { padding: 1.75rem 1.25rem 3.5rem; }
  .content h1 { font-size: 1.7rem; }
}

@media (max-width: 640px) {
  .topbar-right .topbar-link { display: none; }
  .topbar-brand { font-size: 0.95rem; }
}

.menu-toggle { display: none; }
