/* Indie Script developer portal - stylesheet
   Sections: tokens, base, primitives, top bar, project header, layout, sidebar,
   file box + markdown, code, rail, home, catalog, indicator, overlays, footer, responsive */

/* ---------- tokens ---------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --topbar-h: 56px;
  --radius: 6px;
  --radius-lg: 12px;
  --w-page: 1280px;
  --w-layout: 1560px;
  --side-w: 288px;
  --rail-w: 256px;

  /* the top bar stays dark in every theme */
  --hd-bg: #1f2328;
  --hd-fg: #f0f6fc;
  --hd-muted: #b7bdc8;
  --hd-border: #3d444d;
  --hd-control: #ffffff14;
  --hd-control-hover: #ffffff24;

  --c-indie: #7c5cff;
  --c-pine: #1f9d6b;

  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-inset: #eff2f5;
  --bg-overlay: #ffffff;
  --bg-hover: #818b981f;
  --bg-active: #818b9833;
  --border: #d1d9e0;
  --border-muted: #d1d9e0b3;
  --fg: #1f2328;
  --fg-muted: #59636e;
  --fg-subtle: #818b98;
  --fg-on-emphasis: #ffffff;
  --accent: #0969da;
  --accent-emphasis: #0969da;
  --accent-subtle: #ddf4ff;
  --accent-border: #54aeff66;
  --success: #1a7f37;
  --success-emphasis: #1f883d;
  --success-hover: #1c8139;
  --success-subtle: #dafbe1;
  --attention: #9a6700;
  --attention-subtle: #fff8c5;
  --danger: #d1242f;
  --done: #8250df;
  --done-subtle: #fbefff;
  --btn-bg: #f6f8fa;
  --btn-hover: #eff2f5;
  --btn-border: #d1d9e0;
  --counter-bg: #818b981f;
  --shadow-sm: 0 1px 1px #1f23280a, 0 1px 2px #1f232808;
  --shadow-md: 0 3px 6px #25292e1f;
  --shadow-lg: 0 8px 24px #25292e33;
  --backdrop: #25292e80;
  --hero-a: #ddf4ff;
  --hero-b: #fbefff;

  --syn-comment: #59636e;
  --syn-keyword: #cf222e;
  --syn-string: #0a3069;
  --syn-const: #0550ae;
  --syn-entity: #6639ba;
  --syn-var: #953800;
  --syn-tag: #116329;
  --syn-meta: #8250df;

  color-scheme: light;
}

[data-theme="dark"] {
  --hd-bg: #010409;
  --bg: #0d1117;
  --bg-subtle: #151b23;
  --bg-inset: #010409;
  --bg-overlay: #151b23;
  --bg-hover: #656c7633;
  --bg-active: #656c7659;
  --border: #3d444d;
  --border-muted: #3d444db3;
  --fg: #f0f6fc;
  --fg-muted: #9198a1;
  --fg-subtle: #6e7681;
  --accent: #4493f8;
  --accent-emphasis: #1f6feb;
  --accent-subtle: #388bfd1a;
  --accent-border: #388bfd66;
  --success: #3fb950;
  --success-emphasis: #238636;
  --success-hover: #29903b;
  --success-subtle: #2ea04326;
  --attention: #d29922;
  --attention-subtle: #bb800926;
  --danger: #f85149;
  --done: #ab7df8;
  --done-subtle: #ab7df826;
  --btn-bg: #212830;
  --btn-hover: #262c36;
  --btn-border: #3d444d;
  --counter-bg: #2f3742;
  --shadow-sm: 0 1px 1px #01040999;
  --shadow-md: 0 3px 6px #01040966;
  --shadow-lg: 0 8px 24px #010409cc;
  --backdrop: #010409b3;
  --hero-a: #388bfd1f;
  --hero-b: #ab7df81f;
  --c-indie: #a78bfa;
  --c-pine: #3fb98a;

  --syn-comment: #9198a1;
  --syn-keyword: #ff7b72;
  --syn-string: #a5d6ff;
  --syn-const: #79c0ff;
  --syn-entity: #d2a8ff;
  --syn-var: #ffa657;
  --syn-tag: #7ee787;
  --syn-meta: #d2a8ff;

  color-scheme: dark;
}

[data-theme="dimmed"] {
  --hd-bg: #151b23;
  --bg: #212830;
  --bg-subtle: #262c36;
  --bg-inset: #151b23;
  --bg-overlay: #2a313c;
  --bg-hover: #656c7633;
  --bg-active: #656c7659;
  --border: #3d444d;
  --border-muted: #3d444db3;
  --fg: #d1d7e0;
  --fg-muted: #9198a1;
  --fg-subtle: #656c76;
  --accent: #478be6;
  --accent-emphasis: #316dca;
  --accent-subtle: #4184e41a;
  --accent-border: #4184e466;
  --success: #57ab5a;
  --success-emphasis: #347d39;
  --success-hover: #3b8640;
  --success-subtle: #46954a26;
  --attention: #c69026;
  --attention-subtle: #ae7c1426;
  --danger: #e5534b;
  --done: #986ee2;
  --done-subtle: #986ee226;
  --btn-bg: #2a313c;
  --btn-hover: #323a46;
  --btn-border: #3d444d;
  --counter-bg: #3d444d;
  --shadow-sm: 0 1px 1px #15191f99;
  --shadow-md: 0 3px 6px #15191f66;
  --shadow-lg: 0 8px 24px #15191fcc;
  --backdrop: #151b23b3;
  --hero-a: #4184e41f;
  --hero-b: #986ee21f;
  --c-indie: #a78bfa;
  --c-pine: #3fb98a;

  --syn-comment: #768390;
  --syn-keyword: #f47067;
  --syn-string: #96d0ff;
  --syn-const: #6cb6ff;
  --syn-entity: #dcbdfb;
  --syn-var: #f69d50;
  --syn-tag: #8ddb8c;
  --syn-meta: #dcbdfb;

  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
code, kbd, pre, .path { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-border); }

.octicon { display: inline-block; vertical-align: text-bottom; fill: currentColor; flex: none; overflow: visible; }
.muted { color: var(--fg-muted); }
.container { width: 100%; max-width: var(--w-page); margin: 0 auto; padding: 0 24px; }
.skip-link { position: absolute; left: 8px; top: -48px; z-index: 200; padding: 8px 12px; background: var(--accent-emphasis); color: #fff; border-radius: var(--radius); }
.skip-link:focus { top: 8px; }
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 120; pointer-events: none; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--c-indie), var(--accent)); }

kbd {
  display: inline-block; min-width: 20px; padding: 2px 5px; font-size: 11px; line-height: 14px; text-align: center;
  color: var(--fg-muted); background: var(--bg-subtle); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px;
}

/* ---------- primitives ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 5px 12px; min-height: 32px; font-size: 14px; font-weight: 500; line-height: 20px; white-space: nowrap;
  color: var(--fg); background: var(--btn-bg); border: 1px solid var(--btn-border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); transition: background-color .12s, border-color .12s; text-decoration: none; user-select: none;
}
.btn:hover { background: var(--btn-hover); text-decoration: none; }
.btn:active, .btn[aria-pressed="true"] { background: var(--bg-active); }
.btn .octicon { color: var(--fg-muted); }
.btn-sm { padding: 3px 10px; min-height: 28px; font-size: 12px; gap: 6px; }
.btn-lg { padding: 9px 18px; min-height: 40px; font-size: 15px; }
.btn-icon { padding-left: 7px; padding-right: 7px; }
.btn-primary { color: #fff; background: var(--success-emphasis); border-color: #1f232826; }
.btn-primary:hover { background: var(--success-hover); }
.btn-primary .octicon { color: #fff; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn:hover { z-index: 1; }
.linklike { padding: 0; border: 0; background: none; color: var(--accent); }
.linklike:hover { text-decoration: underline; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0;
  color: var(--fg-muted); background: transparent; border: 1px solid transparent; border-radius: var(--radius); text-decoration: none;
}
.icon-btn:hover { color: var(--fg); background: var(--bg-hover); text-decoration: none; }

.counter {
  display: inline-block; min-width: 20px; padding: 0 6px; font-size: 12px; font-weight: 500; line-height: 18px; text-align: center;
  color: var(--fg); background: var(--counter-bg); border-radius: 2em; font-variant-numeric: tabular-nums;
}
.label {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 7px; font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap;
  color: var(--fg-muted); border: 1px solid var(--border); border-radius: 2em; text-decoration: none;
}
.label-accent { color: var(--accent); border-color: var(--accent-border); background: var(--accent-subtle); }
a.label:hover { text-decoration: none; border-color: var(--accent); }
.badge {
  display: inline-flex; align-items: center; padding: 0 7px; font-size: 11px; font-weight: 600; line-height: 18px; white-space: nowrap;
  border-radius: 2em; border: 1px solid transparent; font-family: var(--font-mono);
}
.badge-indie { color: var(--c-indie); background: color-mix(in srgb, var(--c-indie) 12%, transparent); border-color: color-mix(in srgb, var(--c-indie) 35%, transparent); }
.badge-pine { color: var(--c-pine); background: color-mix(in srgb, var(--c-pine) 12%, transparent); border-color: color-mix(in srgb, var(--c-pine) 35%, transparent); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--fg-subtle); flex: none; }
.dot-indie { background: var(--c-indie); }
.dot-pine { background: var(--c-pine); }

.box { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.box-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--bg-subtle); border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
}
.box-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.box-title .octicon { color: var(--fg-muted); }
.box-title a { color: var(--fg); }
.box-note { font-size: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; font-size: 13px; font-weight: 500; line-height: 20px;
  color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 2em; text-decoration: none; white-space: nowrap;
}
.chip .octicon { color: var(--fg-muted); }
.chip:hover { background: var(--bg-subtle); text-decoration: none; border-color: var(--fg-subtle); }
.chip.selected { color: var(--accent); background: var(--accent-subtle); border-color: var(--accent-border); }
.chip.selected .octicon { color: var(--accent); }

.segmented { display: inline-flex; padding: 2px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius); }
.segmented button {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; font-size: 13px; line-height: 20px; white-space: nowrap;
  color: var(--fg-muted); background: transparent; border: 1px solid transparent; border-radius: 4px;
}
.segmented button:hover { color: var(--fg); }
.segmented button.selected { color: var(--fg); background: var(--bg); border-color: var(--border); box-shadow: var(--shadow-sm); font-weight: 600; }

.input-icon { position: relative; display: inline-flex; align-items: center; flex: 1 1 220px; min-width: 0; }
.input-icon .octicon { position: absolute; left: 10px; color: var(--fg-muted); pointer-events: none; }
.input-icon input, .side-filter input {
  width: 100%; height: 32px; padding: 5px 12px 5px 32px; font-size: 14px;
  color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
}
.input-icon input:focus, .side-filter input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-border); }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

.blankslate { padding: 40px 24px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--fg-muted); }
.blankslate h1, .blankslate h3 { color: var(--fg); margin: 8px 0 4px; }
.blankslate-lg { padding: 72px 24px; border-style: solid; background: var(--bg-subtle); }
.blankslate-lg h1 { font-size: 28px; }
.blankslate-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 20px; }
.notfound-code { font: 600 72px/1 var(--font-mono); letter-spacing: -2px; color: var(--fg-subtle); }

.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 90; min-width: 200px; padding: 6px;
  color: var(--fg); background: var(--bg-overlay); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.dropdown-menu-right { left: auto; right: 0; }
.dropdown-header { padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--fg-muted); }
.dropdown-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; font-size: 14px; text-align: left;
  color: var(--fg); background: transparent; border: 0; border-radius: var(--radius);
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item .octicon { color: var(--fg-muted); }
.dropdown-item span { flex: 1; }
.dropdown-item .tick { visibility: hidden; color: var(--fg); }
.dropdown-item[aria-checked="true"] .tick { visibility: visible; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 80; height: var(--topbar-h); color: var(--hd-fg); background: var(--hd-bg); border-bottom: 1px solid var(--hd-border); }
.topbar-inner { display: flex; align-items: center; gap: 12px; height: 100%; padding: 0 16px; }
.topbar .icon-btn { color: var(--hd-muted); border-color: var(--hd-border); }
.topbar .icon-btn:hover { color: var(--hd-fg); background: var(--hd-control-hover); }
.topbar-burger { display: none; }
.k-home .topbar-burger { display: inline-flex; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 32px; height: 32px; border-radius: 6px; display: block; background: #fff; }
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.brand-tag { padding: 1px 7px; font-size: 11px; font-weight: 500; line-height: 16px; color: var(--hd-muted); border: 1px solid var(--hd-border); border-radius: 2em; }

.topnav { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.topnav-item { position: relative; }
.topnav-link {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; font-size: 14px; font-weight: 600; line-height: 20px;
  color: var(--hd-fg); background: transparent; border: 0; border-radius: var(--radius); text-decoration: none;
}
.topnav-link:hover, .topnav-item.open > .topnav-link { background: var(--hd-control); text-decoration: none; }
.topnav-link .chev { color: var(--hd-muted); transition: transform .15s; }
.topnav-item.open .chev, .topnav-item:hover .chev { transform: rotate(180deg); }

.mega {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 90; width: 760px; max-width: calc(100vw - 32px); padding: 16px;
  color: var(--fg); background: var(--bg-overlay); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .12s, transform .12s, visibility 0s .12s;
}
.mega::before { content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 12px; }
.topnav-item:hover > .mega, .topnav-item:focus-within > .mega, .topnav-item.open > .mega { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.mega-cats { width: 420px; }
.mega-narrow { width: 300px; }
.mega-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.mega-title { padding: 4px 8px 8px; font-size: 12px; font-weight: 600; color: var(--fg-muted); text-transform: uppercase; letter-spacing: .04em; }
.mega-title:not(:first-child) { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border-muted); }
.mega-col .mega-title:not(:first-child) { margin-top: 0; padding-top: 4px; border-top: 0; }
.mega-link { display: flex; gap: 10px; padding: 8px; color: var(--fg); border-radius: var(--radius); text-decoration: none; }
.mega-link:hover, .mega-cat:hover { background: var(--bg-hover); text-decoration: none; }
.mega-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px;
  color: var(--fg-muted); background: var(--bg-subtle); border: 1px solid var(--border-muted); border-radius: var(--radius);
}
.mega-text { display: flex; flex-direction: column; min-width: 0; }
.mega-text strong { font-size: 14px; }
.mega-text small { font-size: 12px; line-height: 1.4; color: var(--fg-muted); }
.mega-catgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 8px; }
.mega-cat { display: flex; align-items: center; gap: 10px; padding: 6px 8px; color: var(--fg); border-radius: var(--radius); text-decoration: none; }
.mega-cat-label { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mega-cat .ext { color: var(--fg-subtle); }
.mega-foot { display: flex; align-items: center; gap: 6px; margin-top: 12px; padding: 10px 8px 0; font-weight: 600; border-top: 1px solid var(--border-muted); }

.searchbtn {
  display: flex; align-items: center; gap: 8px; flex: 1 1 320px; max-width: 420px; height: 32px; margin-left: auto; padding: 0 8px 0 10px;
  color: var(--hd-muted); background: var(--hd-control); border: 1px solid var(--hd-border); border-radius: var(--radius); text-align: left;
}
.searchbtn:hover { background: var(--hd-control-hover); color: var(--hd-fg); }
.searchbtn-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.searchbtn kbd, .hero-search kbd { color: inherit; background: transparent; border-color: currentColor; opacity: .7; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.theme-icon { display: inline-flex; }
[data-theme="light"] .theme-icon-dark, [data-theme="dark"] .theme-icon-light, [data-theme="dimmed"] .theme-icon-light { display: none; }

/* ---------- project header + tabs ---------- */
.ctx { background: var(--bg-subtle); border-bottom: 1px solid var(--border); }
.ctx .container { max-width: var(--w-layout); }
.ctx-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0 6px; flex-wrap: wrap; }
.ctx-title { display: flex; align-items: center; gap: 6px; font-size: 18px; min-width: 0; flex-wrap: wrap; }
.ctx-title .octicon { color: var(--fg-muted); }
.ctx-sep { color: var(--fg-muted); }
.ctx-repo { font-weight: 600; }
.ctx-title .label { margin-left: 4px; }
.ctx-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; margin-bottom: -1px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px; margin: 6px 0 8px; font-size: 14px; line-height: 20px; white-space: nowrap;
  color: var(--fg); border-radius: var(--radius); text-decoration: none;
}
.tab .octicon { color: var(--fg-muted); }
.tab:hover { background: var(--bg-hover); text-decoration: none; }
.tab.selected { font-weight: 600; }
.tab.selected::after { content: ""; position: absolute; left: 0; right: 0; bottom: -8px; height: 2px; background: #fd8c73; border-radius: 2px; }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr) var(--rail-w); gap: 0 32px; align-items: start;
  width: 100%; max-width: var(--w-layout); margin: 0 auto; padding: 24px 24px 64px;
}
.layout-noside-rail { grid-template-columns: var(--side-w) minmax(0, 1fr); }
.layout-main { min-width: 0; }
[data-wide="1"] .layout { max-width: none; grid-template-columns: var(--side-w) minmax(0, 1fr); }
[data-wide="1"] .rail { display: none; }
[data-wide="1"] .toc-inline:not([hidden]) { display: block; }

.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; font-size: 14px; color: var(--fg-muted); }
.crumbs-sep { color: var(--fg-subtle); }
.crumbs-current { color: var(--fg); font-weight: 600; }

/* ---------- sidebar ---------- */
.sidebar {
  position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 32px);
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding-right: 8px; font-size: 14px;
}
.side-top { display: none; align-items: center; justify-content: space-between; padding: 4px 4px 12px; font-size: 16px; }
.side-filter { position: relative; margin-bottom: 12px; }
.side-filter .octicon { position: absolute; left: 10px; top: 8px; color: var(--fg-muted); pointer-events: none; }
.side-heading { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 4px; padding: 12px 8px 4px; border-top: 1px solid var(--border-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.side-heading a { color: var(--fg-muted); }
.side-group > summary {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-weight: 600; cursor: pointer; list-style: none; border-radius: var(--radius); user-select: none;
}
.side-group > summary::-webkit-details-marker { display: none; }
.side-group > summary:hover { background: var(--bg-hover); }
.side-group > summary .octicon { color: var(--fg-muted); }
.side-group > summary > span:not(.counter) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-group .chev { transition: transform .12s; }
.side-group[open] > summary .chev { transform: rotate(90deg); }
.side-group > ul { margin: 2px 0 6px 13px; padding-left: 8px; border-left: 1px solid var(--border-muted); }
.side-link {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 5px 8px; line-height: 20px;
  color: var(--fg); border-radius: var(--radius); text-decoration: none;
}
.side-link .octicon { color: var(--fg-muted); }
.side-link .octicon.dir, .rail-links .octicon.dir { color: #54aeff; }
.side-link > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-link:hover { background: var(--bg-hover); text-decoration: none; }
.side-link.current { background: var(--bg-active); font-weight: 600; }
.side-link.current::before { content: ""; position: absolute; left: -9px; top: 4px; bottom: 4px; width: 3px; background: var(--accent); border-radius: 3px; }
.side-root.current::before { left: -4px; }
.side-root { font-weight: 600; }
.side-all { color: var(--fg-muted); }
.side-empty { padding: 16px 8px; color: var(--fg-muted); }
.drawer-backdrop { position: fixed; inset: 0; z-index: 99; background: var(--backdrop); }

/* off-canvas mode: always on the overview page, below 1012px everywhere else */
.k-home .sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; width: min(336px, 88vw); max-height: none; padding: 12px;
  background: var(--bg); border-right: 1px solid var(--border); transform: translateX(-100%); visibility: hidden; transition: transform .2s, visibility 0s .2s;
}
.k-home .side-top { display: flex; }
.drawer-open .sidebar { transform: none; visibility: visible; transition-delay: 0s; box-shadow: var(--shadow-lg); }

/* ---------- file box + markdown ---------- */
.filebox { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; min-width: 0; }
.filebox-head {
  position: sticky; top: var(--topbar-h); z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 8px 8px 8px 16px; background: var(--bg-subtle); border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
}
.filebox-path { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.filebox-path .octicon { color: var(--fg-muted); }
.filebox-path .path { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.filebox-meta { font-size: 12px; color: var(--fg-muted); padding-left: 8px; border-left: 1px solid var(--border); }
.filebox-actions { display: flex; align-items: center; gap: 8px; }
.filebox-foot { display: flex; flex-wrap: wrap; gap: 20px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; }
.filebox-foot a { display: inline-flex; align-items: center; gap: 6px; color: var(--fg-muted); }
.filebox-foot a:hover { color: var(--accent); }
.commitbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 16px; font-size: 13px; color: var(--fg-muted); background: var(--bg); border-bottom: 1px solid var(--border-muted); }
.commitbar .octicon { color: var(--fg-muted); }
.commitbar-msg { color: var(--fg); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch; }
.commitbar code { font-size: 12px; color: var(--fg-muted); }
.commitbar-right { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.toc-inline { display: none; border-bottom: 1px solid var(--border-muted); }
.toc-inline > summary { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-weight: 600; cursor: pointer; list-style: none; }
.toc-inline > summary::-webkit-details-marker { display: none; }
.toc-inline > summary .chev { margin-left: auto; transition: transform .12s; }
.toc-inline[open] > summary .chev { transform: rotate(180deg); }
.toc-inline .toc { padding: 0 16px 12px; max-height: 50vh; overflow: auto; }

.markdown-body { padding: 32px; font-size: 16px; line-height: 1.6; overflow-wrap: break-word; min-width: 0; }
.markdown-body > :first-child { margin-top: 0 !important; }
.markdown-body > :last-child { margin-bottom: 0 !important; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { position: relative; margin: 24px 0 16px; font-weight: 600; line-height: 1.25; }
.markdown-body h1 { font-size: 2em; padding-bottom: .3em; border-bottom: 1px solid var(--border-muted); }
.markdown-body h2 { font-size: 1.5em; padding-bottom: .3em; border-bottom: 1px solid var(--border-muted); }
.markdown-body h3 { font-size: 1.25em; }
.markdown-body h4 { font-size: 1em; }
.markdown-body h5 { font-size: .875em; }
.markdown-body h6 { font-size: .85em; color: var(--fg-muted); }
.markdown-body p, .markdown-body blockquote, .markdown-body ul, .markdown-body ol, .markdown-body dl, .markdown-body table, .markdown-body pre, .markdown-body details, .markdown-body .codeblock { margin: 0 0 16px; }
.markdown-body ul, .markdown-body ol { padding-left: 2em; }
.markdown-body ul { list-style: disc; }
.markdown-body ul ul { list-style: circle; }
.markdown-body ul ul, .markdown-body ul ol, .markdown-body ol ol, .markdown-body ol ul { margin-bottom: 0; }
.markdown-body li + li { margin-top: .25em; }
.markdown-body li > p { margin-top: 16px; }
.markdown-body strong { font-weight: 600; }
.markdown-body hr { height: .25em; margin: 24px 0; padding: 0; background: var(--border); border: 0; border-radius: 2px; }
.markdown-body blockquote { padding: 0 1em; color: var(--fg-muted); border-left: .25em solid var(--border); }
.markdown-body img { display: block; max-width: 100%; height: auto; margin: 0 auto; border: 1px solid var(--border); border-radius: var(--radius); cursor: zoom-in; background: var(--bg-subtle); }
.markdown-body a { text-decoration: underline; text-underline-offset: .2em; }
.markdown-body table { display: block; width: max-content; max-width: 100%; overflow: auto; border-spacing: 0; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
.markdown-body th, .markdown-body td { padding: 6px 13px; border: 1px solid var(--border); vertical-align: top; }
.markdown-body th { font-weight: 600; background: var(--bg-subtle); text-align: left; }
.markdown-body tr { background: var(--bg); border-top: 1px solid var(--border-muted); }
.markdown-body tr:nth-child(2n) { background: var(--bg-subtle); }
.markdown-body code { padding: .2em .4em; margin: 0; font-size: 85%; white-space: break-spaces; background: var(--bg-hover); border-radius: 6px; }
.markdown-body pre { padding: 16px; overflow: auto; font-size: 85%; line-height: 1.45; color: var(--fg); background: var(--bg-subtle); border-radius: var(--radius); }
.markdown-body pre code { display: block; padding: 0; margin: 0; font-size: 100%; white-space: pre; background: transparent; border: 0; border-radius: 0; overflow-wrap: normal; }
.markdown-body .highlighter-rouge, .markdown-body .highlight { margin: 0; }
.markdown-body div.highlighter-rouge { margin-bottom: 16px; }
.markdown-body div.highlighter-rouge pre, .markdown-body .codeblock pre { margin: 0; }
.markdown-body .anchor { position: absolute; left: -24px; top: 0; bottom: 0; display: flex; align-items: center; width: 24px; padding-right: 4px; color: var(--fg-muted); opacity: 0; text-decoration: none; }
.markdown-body :is(h1, h2, h3, h4, h5, h6):hover .anchor, .markdown-body .anchor:focus { opacity: 1; }
.markdown-body :is(h1, h2, h3, h4, h5, h6):target { scroll-margin-top: calc(var(--topbar-h) + 64px); }
.markdown-body .task-list-item { list-style: none; }

/* ---------- code ---------- */
.codeblock { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-subtle); }
.codeblock-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px 4px 12px; font-size: 12px; color: var(--fg-muted); background: var(--bg); border-bottom: 1px solid var(--border-muted); }
.codeblock-lang { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-weight: 600; text-transform: lowercase; }
.codeblock-copy { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; font-size: 12px; color: var(--fg-muted); background: transparent; border: 1px solid transparent; border-radius: var(--radius); }
.codeblock-copy:hover { color: var(--fg); background: var(--bg-hover); border-color: var(--border); }
.codeblock-copy.done { color: var(--success); }
.codeblock pre { border-radius: 0; background: transparent; }

.hljs-comment, .hljs-quote, .c, .c1, .cm, .cs, .ch, .cd, .cpf { color: var(--syn-comment); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-doctag, .hljs-template-tag, .hljs-type, .k, .kd, .kn, .kr, .kc, .kp, .kt, .ow { color: var(--syn-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition, .s, .s1, .s2, .sb, .sc, .sd, .se, .sh, .si, .sx, .sr, .ss, .dl { color: var(--syn-string); }
.hljs-number, .hljs-literal, .hljs-attr, .hljs-attribute, .hljs-selector-attr, .hljs-selector-class, .hljs-selector-id, .hljs-symbol, .hljs-bullet, .m, .mi, .mf, .mh, .mo, .il, .bp, .no { color: var(--syn-const); }
.hljs-title, .hljs-title.function_, .hljs-title.class_, .hljs-section, .nf, .nc, .fm, .ne { color: var(--syn-entity); }
.hljs-built_in, .hljs-variable, .hljs-template-variable, .hljs-params, .nb, .nv, .vi, .vc, .vg { color: var(--syn-var); }
.hljs-params { color: inherit; }
.hljs-name, .hljs-tag, .nt { color: var(--syn-tag); }
.hljs-meta, .hljs-meta .hljs-keyword, .nd { color: var(--syn-meta); }
.hljs-deletion { color: var(--danger); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }

.code-table { width: 100%; border-collapse: collapse; font: 12px/20px var(--font-mono); tab-size: 4; }
.code-table td { padding: 0; vertical-align: top; }
.code-table .ln { width: 1%; min-width: 48px; padding: 0 12px 0 16px; text-align: right; color: var(--fg-subtle); user-select: none; white-space: nowrap; cursor: pointer; }
.code-table .ln::before { content: attr(data-ln); }
.code-table .ln:hover { color: var(--fg); }
.code-table .lc { padding: 0 16px 0 8px; white-space: pre; }
.code-table tr.hl .lc, .code-table tr.hl .ln { background: var(--attention-subtle); }
.code-table tr.hl .ln { box-shadow: inset 2px 0 0 var(--attention); color: var(--fg); }
.wrap .code-table .lc { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- right rail ---------- */
.rail { position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 32px); overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; font-size: 13px; padding-right: 8px; }
.rail-box { padding: 0 0 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border-muted); }
.rail-box:last-child { border-bottom: 0; }
.rail-box h2, .side-box h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.rail-box h2 .octicon { color: var(--fg-muted); }
.toc ul { margin: 0; padding: 0; list-style: none; }
.toc a { display: block; padding: 3px 8px 3px 12px; color: var(--fg-muted); border-left: 2px solid var(--border-muted); line-height: 1.4; text-decoration: none; }
.toc a:hover { color: var(--fg); text-decoration: none; }
.toc a.active { color: var(--fg); font-weight: 600; border-left-color: var(--accent); background: var(--accent-subtle); }
.toc .toc-h3 a { padding-left: 24px; }
.toc .toc-h4 a { padding-left: 36px; }
.rail-links li + li { margin-top: 2px; }
.rail-links a { display: flex; align-items: center; gap: 8px; padding: 4px 8px; color: var(--fg); border-radius: var(--radius); text-decoration: none; }
.rail-links a:hover { background: var(--bg-hover); text-decoration: none; }
.rail-links a .octicon { color: var(--fg-muted); }
.rail-links a > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-links .ext { margin-left: auto; color: var(--fg-subtle); }
.rail-links a.current { font-weight: 600; background: var(--bg-active); }
.rail-related { max-height: 320px; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; }
.rail-more { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-weight: 600; font-size: 13px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 24px 0 0; }
.pager-link { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; color: var(--fg); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; }
.pager-link:hover { border-color: var(--accent); text-decoration: none; }
.pager-next { text-align: right; align-items: flex-end; }
.pager-dir { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-muted); }
.pager-title { font-weight: 600; color: var(--accent); }

/* ---------- overview page ---------- */
.hero { position: relative; padding: 48px 0 0; background: radial-gradient(900px 380px at 12% -10%, var(--hero-a), transparent 70%), radial-gradient(800px 360px at 92% 0%, var(--hero-b), transparent 70%), var(--bg); border-bottom: 1px solid var(--border); overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 48px; align-items: center; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 16px; padding: 3px 10px; font: 600 12px/18px var(--font-mono); color: var(--fg-muted); background: var(--bg); border: 1px solid var(--border); border-radius: 2em; }
.hero h1 { font-size: clamp(30px, 3.4vw, 44px); line-height: 1.12; letter-spacing: -.02em; }
.lead { margin-top: 16px; font-size: 18px; line-height: 1.5; color: var(--fg-muted); max-width: 62ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.hero-search { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 520px; height: 40px; margin-top: 16px; padding: 0 10px 0 12px; color: var(--fg-muted); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); text-align: left; }
.hero-search:hover { border-color: var(--fg-subtle); }
.hero-search span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.codewin { min-width: 0; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.codewin-bar { display: flex; align-items: center; gap: 12px; padding: 0 12px; background: var(--bg-subtle); border-bottom: 1px solid var(--border); }
.codewin-dots { display: inline-flex; gap: 6px; }
.codewin-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.codewin-tabs { display: flex; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.codewin-tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; font: 12px/18px var(--font-mono); white-space: nowrap; color: var(--fg-muted); background: transparent; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.codewin-tab:hover { color: var(--fg); }
.codewin-tab.selected { color: var(--fg); border-bottom-color: #fd8c73; font-weight: 600; }
.codewin-body pre { margin: 0; padding: 16px 20px; min-height: 248px; overflow: auto; font: 13px/1.6 var(--font-mono); }
.codewin-body code { font: inherit; }
.codewin-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; font-size: 12px; background: var(--bg-subtle); border-top: 1px solid var(--border); }
.codewin-foot a { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }

.stats { display: flex; flex-wrap: wrap; margin: 40px 0 0; border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; background: var(--bg); overflow: hidden; }
.stat { flex: 1 1 150px; padding: 14px 20px; border-right: 1px solid var(--border-muted); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat dt { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-muted); white-space: nowrap; }
.stat dd { margin: 2px 0 0; font-size: 24px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-commit { flex: 2 1 280px; }
.stat-commit dd { font-size: 14px; line-height: 1.5; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 296px; gap: 32px; padding-top: 32px; padding-bottom: 64px; align-items: start; }
.home-main { min-width: 0; }
.home-sec { margin-bottom: 32px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sec-head h2 { display: flex; align-items: center; gap: 8px; font-size: 20px; }
.sec-head h2 .octicon { color: var(--fg-muted); }
.sec-more { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card { display: flex; gap: 12px; padding: 16px; color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; transition: border-color .12s, box-shadow .12s; }
.card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); text-decoration: none; }
.card-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; color: var(--accent); background: var(--accent-subtle); border-radius: var(--radius); }
.card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-kicker { font: 600 11px/16px var(--font-mono); color: var(--fg-muted); text-transform: uppercase; letter-spacing: .04em; }
.card-title { font-size: 15px; }
.card-text { font-size: 13px; color: var(--fg-muted); }
.catgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.catcard { display: flex; flex-direction: column; padding: 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.catcard-head { display: flex; align-items: center; gap: 10px; }
.catcard-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; color: var(--fg); }
.catcard-sum { margin: 8px 0 10px; font-size: 13px; color: var(--fg-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.catcard-list { margin: 0 -8px; }
.catcard-list a { display: flex; align-items: center; gap: 8px; padding: 4px 8px; font-size: 13px; color: var(--fg); border-radius: var(--radius); text-decoration: none; }
.catcard-list a:hover { background: var(--bg-hover); color: var(--accent); }
.catcard-list a .octicon { color: var(--accent); opacity: .8; }
.catcard-list a span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catcard-more { display: inline-flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 10px; font-size: 13px; font-weight: 600; }
.readme .filebox-head { position: static; }

.home-side { font-size: 14px; }
.side-box { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border-muted); }
.side-box:last-child { border-bottom: 0; }
.side-box h2 { font-size: 16px; margin-bottom: 12px; }
.side-box p { color: var(--fg); }
.side-note { margin-top: 8px; font-size: 12px; }
.topics { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.topic { display: inline-block; padding: 0 10px; font-size: 12px; font-weight: 500; line-height: 22px; color: var(--accent); background: var(--accent-subtle); border-radius: 2em; }
.facts li { margin-top: 8px; }
.facts a, .facts span { display: inline-flex; align-items: center; gap: 8px; color: var(--fg-muted); }
.facts a:hover { color: var(--accent); text-decoration: none; }
.facts strong { color: var(--fg); }
.langbar { display: flex; height: 8px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--bg-inset); }
.langbar-indie { background: var(--c-indie); }
.langbar-pine { background: var(--c-pine); }
.langs { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; font-size: 12px; }
.langs li { display: inline-flex; align-items: center; gap: 6px; }
.activity li { padding: 6px 0; border-bottom: 1px solid var(--border-muted); font-size: 13px; }
.activity li:last-child { border-bottom: 0; }
.activity a { color: var(--fg); font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity a:hover { color: var(--accent); }
.activity small { color: var(--fg-muted); font-size: 12px; }
.activity code { font-size: 11px; }

/* ---------- catalog ---------- */
.pagehead { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border-muted); flex-wrap: wrap; }
.pagehead-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 48px; height: 48px; color: var(--accent); background: var(--accent-subtle); border: 1px solid var(--accent-border); border-radius: var(--radius-lg); }
.pagehead-text { flex: 1 1 320px; min-width: 0; }
.pagehead h1 { font-size: 28px; letter-spacing: -.01em; }
.pagehead .lead { margin-top: 6px; font-size: 16px; max-width: 80ch; }
.pagehead-stats { display: flex; gap: 24px; margin: 0; }
.pagehead-stats dt { font-size: 12px; color: var(--fg-muted); }
.pagehead-stats dd { margin: 0; font-size: 24px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-count { margin-left: auto; font-size: 13px; }
.catsec { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.catsec-head { align-items: baseline; }
.catsec-sum { flex: 1 1 320px; font-size: 13px; text-align: right; }
.rowlist .row, .filelist .filerow {
  display: grid; align-items: center; gap: 12px; padding: 8px 16px; border-top: 1px solid var(--border-muted); min-width: 0;
}
.rowlist .row { grid-template-columns: 16px minmax(0, 340px) minmax(0, 1fr) auto 44px; }
.is-flat .rowlist .row { grid-template-columns: 16px minmax(0, 340px) minmax(0, 1fr) 160px auto 44px; }
.rowlist .row:first-child, .filelist .filerow:first-child { border-top: 0; }
.rowlist .row:hover, .filelist .filerow:hover { background: var(--bg-subtle); }
.row-icon { display: inline-flex; color: var(--accent); }
.filerow .row-icon { color: var(--fg-muted); }
.row-name { font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-name:hover { color: var(--accent); }
.row-desc { font-size: 13px; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-cat { display: none; font-size: 12px; color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.is-flat .row-cat { display: block; }
.row-badges { display: inline-flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.row-count { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 12px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }

/* ---------- indicator page ---------- */
.dirhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.dirhead-main { display: flex; gap: 12px; min-width: 0; }
.dirhead-icon { display: inline-flex; color: var(--accent); margin-top: 4px; }
.dirhead-name { font-size: 24px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.dirhead-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 12px; }
.filelist .filerow { grid-template-columns: 16px minmax(0, 1fr) auto 72px 32px; }
.file-tags { display: inline-flex; gap: 6px; align-items: center; }
.file-name { font: 13px/20px var(--font-mono); color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name:hover { color: var(--accent); }
.filerow.active { background: var(--accent-subtle); box-shadow: inset 2px 0 0 var(--accent); }
.file-size { font-size: 12px; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }

.viewer { display: flex; flex-direction: column; min-width: 0; scroll-margin-top: calc(var(--topbar-h) + 16px); }
.viewer-head { display: flex; align-items: stretch; justify-content: space-between; gap: 12px; background: var(--bg-subtle); border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; padding-right: 8px; }
.viewer-tabs { display: flex; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.viewer-tabs::-webkit-scrollbar, .codewin-tabs::-webkit-scrollbar { display: none; }
.viewer-tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; font: 12px/18px var(--font-mono); white-space: nowrap; color: var(--fg-muted); background: transparent; border: 0; border-right: 1px solid var(--border-muted); }
.viewer-tab:hover { color: var(--fg); background: var(--bg-hover); }
.viewer-tab.selected { color: var(--fg); background: var(--bg); box-shadow: inset 0 -2px 0 #fd8c73; font-weight: 600; }
.viewer-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.viewer-panes { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 0; flex: 1; }
.viewer.split .viewer-panes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.viewer.split .pane + .pane { border-left: 1px solid var(--border); }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pane-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 12px 6px 16px; font-size: 12px; border-bottom: 1px solid var(--border-muted); }
.pane-select { max-width: 60%; height: 26px; padding: 0 8px; font: 12px var(--font-mono); color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); display: none; }
.viewer.split .pane-select { display: block; }
.pane-info { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-code { max-height: 460px; overflow: auto; padding: 8px 0; scrollbar-width: thin; }
.pane-code:focus-visible { outline-offset: -2px; }
.pane-empty { padding: 32px 16px; text-align: center; color: var(--fg-muted); }
.viewer.full { position: fixed; inset: 0; z-index: 110; margin: 0; border: 0; border-radius: 0; }
.viewer.full .viewer-head { border-radius: 0; }
.viewer.full .pane-code { max-height: none; flex: 1; }
body.viewer-full { overflow: hidden; }

/* ---------- overlays ---------- */
.overlay-backdrop { position: fixed; inset: 0; background: var(--backdrop); }
.palette, .modal { position: fixed; inset: 0; z-index: 150; display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.palette-panel, .modal-panel { position: relative; width: 100%; max-width: 680px; max-height: 76vh; display: flex; flex-direction: column; color: var(--fg); background: var(--bg-overlay); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.palette-input .octicon { color: var(--fg-muted); }
.palette-input input { flex: 1; min-width: 0; font-size: 16px; background: transparent; border: 0; outline: 0; }
.palette-scopes { display: flex; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--border-muted); overflow-x: auto; scrollbar-width: none; }
.palette-scopes .chip { font-size: 12px; padding: 1px 9px; background: transparent; }
.palette-results { flex: 1; overflow-y: auto; padding: 6px; min-height: 120px; scrollbar-width: thin; }
.palette-group { padding: 8px 10px 4px; font-size: 12px; font-weight: 600; color: var(--fg-muted); }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; color: var(--fg); border-radius: var(--radius); cursor: pointer; text-decoration: none; }
.palette-item:hover { text-decoration: none; }
.palette-item .octicon { color: var(--fg-muted); }
.palette-item.active { background: var(--accent-emphasis); color: #fff; }
.palette-item.active .octicon, .palette-item.active .palette-sub, .palette-item.active .palette-hint { color: #ffffffcc; }
.palette-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.palette-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-sub { font-size: 12px; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-hint { font-size: 12px; color: var(--fg-muted); white-space: nowrap; }
.palette-item mark { color: inherit; background: var(--attention-subtle); border-radius: 2px; font-weight: 600; }
.palette-item.active mark { background: #ffffff33; }
.palette-empty { padding: 32px 16px; text-align: center; color: var(--fg-muted); }
.palette-foot { display: flex; gap: 16px; padding: 8px 16px; font-size: 12px; color: var(--fg-muted); background: var(--bg-subtle); border-top: 1px solid var(--border); }
.palette-foot kbd { margin-right: 2px; }
.palette-foot-right { margin-left: auto; }
.modal-panel { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 16px 20px 20px; overflow-y: auto; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.keys h3 { font-size: 13px; color: var(--fg-muted); margin-bottom: 4px; }
.keys dl { margin: 0; }
.keys dl > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border-muted); }
.keys dt { font-size: 13px; }
.keys dd { margin: 0; white-space: nowrap; color: var(--fg-muted); font-size: 12px; }
.lightbox { position: fixed; inset: 0; z-index: 160; display: flex; align-items: center; justify-content: center; padding: 24px; background: #010409e6; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.lightbox-close { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; color: #fff; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 170; transform: translateX(-50%); padding: 8px 14px; font-size: 13px; color: #fff; background: #1f2328; border: 1px solid #3d444d; border-radius: var(--radius); box-shadow: var(--shadow-lg); }

/* ---------- footer ---------- */
.foot { margin-top: auto; padding: 40px 0 24px; font-size: 13px; color: var(--fg-muted); background: var(--bg-subtle); border-top: 1px solid var(--border); }
.foot .container { max-width: var(--w-layout); }
.foot-grid { display: grid; grid-template-columns: minmax(220px, 1.6fr) repeat(4, minmax(0, 1fr)); gap: 32px; }
.brand-foot { color: var(--fg); margin-bottom: 12px; }
.foot-brand p { max-width: 36ch; }
.foot-build { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12px; }
.foot-col h2 { margin-bottom: 10px; font-size: 12px; font-weight: 600; color: var(--fg); text-transform: uppercase; letter-spacing: .04em; }
.foot-col li + li { margin-top: 6px; }
.foot-col a { color: var(--fg-muted); }
.foot-col a:hover { color: var(--accent); }
.foot-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 24px; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border-muted); font-size: 12px; }
.foot-bar > span { display: inline-flex; align-items: center; gap: 6px; }
.foot-top { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; color: var(--fg-muted); }

/* ---------- responsive ---------- */
@media (max-width: 1279px) {
  .layout { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .rail { display: none; }
  .toc-inline:not([hidden]) { display: block; }
  .searchbtn { flex-basis: 220px; }
  .brand-tag { display: none; }
}
@media (max-width: 1011px) {
  .layout, .layout-noside-rail, [data-wide="1"] .layout { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 48px; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; width: min(336px, 88vw); max-height: none; padding: 12px;
    background: var(--bg); border-right: 1px solid var(--border); transform: translateX(-100%); visibility: hidden; transition: transform .2s, visibility 0s .2s;
  }
  .side-top { display: flex; }
  .topbar-burger { display: inline-flex; }
  .topnav { display: none; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .home-grid { grid-template-columns: minmax(0, 1fr); }
  .foot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .foot-brand { grid-column: 1 / -1; }
  [data-wide-toggle] { display: none; }
  .filebox-head { position: static; }
}
@media (max-width: 767px) {
  .container { padding: 0 16px; }
  .markdown-body { padding: 20px 16px; font-size: 15px; }
  .markdown-body .anchor { display: none; }
  .searchbtn { flex: 0 0 auto; width: 32px; padding: 0; justify-content: center; margin-left: auto; }
  .searchbtn-text, .searchbtn kbd, .hide-sm { display: none; }
  .ctx-actions { display: none; }
  .ctx-title { font-size: 16px; }
  .hero { padding-top: 32px; }
  .stats { margin-top: 28px; }
  .stat { flex-basis: 50%; border-bottom: 1px solid var(--border-muted); }
  .rowlist .row, .is-flat .rowlist .row { grid-template-columns: 16px minmax(0, 1fr) auto; }
  .row-desc, .row-cat, .is-flat .row-cat, .row-count { display: none; }
  .filelist .filerow { grid-template-columns: 16px minmax(0, 1fr) auto 32px; }
  .file-size, .filerow .label { display: none; }
  .row-badges .badge + .badge + .badge { display: none; }
  .catsec-sum { display: none; }
  .viewer.split .viewer-panes { grid-template-columns: minmax(0, 1fr); }
  .viewer.split .pane + .pane { border-left: 0; border-top: 1px solid var(--border); }
  .filebox-actions .btn span { display: none; }
  .filebox-meta { display: none; }
  .keys { grid-template-columns: 1fr; }
  .palette, .modal { padding-top: 16px; }
  .palette-foot span:not(.palette-foot-right) { display: none; }
  .pager { grid-template-columns: 1fr; }
  .foot-top { margin-left: 0; }
  .commitbar-msg { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .ctx, .sidebar, .rail, .foot, .filebox-head, .progress, .pager, .viewer, .files { display: none !important; }
  .layout { display: block; padding: 0; }
  .filebox { border: 0; }
}

/* rich content: mermaid diagrams and KaTeX math (assets/js/rich.js) */
.markdown-body pre.mermaid { background: transparent; border: 1px solid var(--border, #d0d7de); border-radius: 6px; padding: 16px; text-align: center; overflow-x: auto; }
.markdown-body .math-block { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* Built-in indicators: purple folders and badge, so they read apart from community indicators */
:root { --c-builtin: #8250df; }
[data-theme="dark"], [data-theme="dimmed"] { --c-builtin: #ab7df8; }
.row-icon.is-builtin, .dirhead-icon.is-builtin { color: var(--c-builtin); }
.side-link .octicon.dir.builtin, .rail-links .octicon.dir.builtin, .side-sub > summary .octicon.dir { color: var(--c-builtin); }
.badge-builtin { color: var(--c-builtin); background: color-mix(in srgb, var(--c-builtin) 12%, transparent); border-color: color-mix(in srgb, var(--c-builtin) 35%, transparent); }
.side-sub { margin: 0; }
