:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --bg-soft: #f2f4f8;
  --bg-hover: #eaedf3;
  --fg: #171a21;
  --fg-soft: #5d6575;
  --fg-faint: #8b93a3;
  --border: #e3e7ee;
  --border-strong: #d3d9e3;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef0ff;
  --new: #13794a;
  --new-bg: #dcf5e7;
  --upd: #96590a;
  --upd-bg: #fdf0d5;
  --del: #b42318;
  --del-bg: #fde7e5;
  --code-bg: #f3f5f9;
  --mark: #ffe58a;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .06);
  --shadow-lg: 0 2px 4px rgba(16, 24, 40, .04), 0 12px 32px rgba(16, 24, 40, .10);
  --avatar-l: 92%;
  --avatar-fg-l: 32%;
  --topbar-h: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015;
    --surface: #151820;
    --bg-soft: #191c25;
    --bg-hover: #222632;
    --fg: #e6e9ef;
    --fg-soft: #9aa3b3;
    --fg-faint: #6f7888;
    --border: #262b36;
    --border-strong: #333a48;
    --accent: #8b8cff;
    --accent-2: #b48cff;
    --accent-soft: #1f2140;
    --new: #5fd394;
    --new-bg: #15301f;
    --upd: #f2c063;
    --upd-bg: #352910;
    --del: #ff8a80;
    --del-bg: #3a1b19;
    --code-bg: #1a1e27;
    --mark: #6b5600;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .4);
    --avatar-l: 24%;
    --avatar-fg-l: 78%;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.65 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--fg-soft); }
.pad { padding: 8px 12px; }
.nowrap { white-space: nowrap; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* scrollbars */
.sidebar, .toc, .table-wrap, pre { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; color: var(--fg); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 40%, transparent);
}
.search { flex: 1; max-width: 560px; margin-left: auto; position: relative; }
.search::before {
  content: ""; position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  background: var(--fg-faint);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}
.search input, .filter {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--fg);
  font: inherit; font-size: 14px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.search input { padding-left: 38px; }
.search input::placeholder, .filter::placeholder { color: var(--fg-faint); }
.search input:focus, .filter:focus {
  outline: none; background: var(--surface); border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}
.icon-btn { display: none; background: none; border: 0; color: var(--fg); font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg-hover); }

/* layout */
.layout { display: flex; }
.sidebar {
  position: sticky; top: var(--topbar-h);
  width: 290px; flex: none;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 16px 10px 40px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.filter { margin: 0 4px 12px; width: calc(100% - 8px); padding: 7px 12px; font-size: 13.5px; }
main { flex: 1; min-width: 0; }
.loading { padding: 48px; color: var(--fg-soft); }
.loading::before {
  content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 10px; vertical-align: -2px;
  border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* avatar */
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 10px;
  font-size: 15px; font-weight: 700; line-height: 1;
  background: hsl(var(--h) 70% var(--avatar-l));
  color: hsl(var(--h) 60% var(--avatar-fg-l));
}
.avatar.sm { width: 22px; height: 22px; border-radius: 6px; font-size: 11.5px; }
.avatar.lg { width: 44px; height: 44px; border-radius: 12px; font-size: 20px; }

/* sidebar nav */
#nav details { margin-bottom: 2px; }
#nav summary {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius-sm);
  cursor: pointer; font-weight: 600; font-size: 14px; list-style: none;
}
#nav summary::-webkit-details-marker { display: none; }
#nav summary::after {
  content: ""; width: 6px; height: 6px; margin-right: 4px; flex: none;
  border-right: 1.5px solid var(--fg-faint); border-bottom: 1.5px solid var(--fg-faint);
  transform: rotate(-45deg); transition: transform .15s;
}
#nav details[open] > summary::after { transform: rotate(45deg); }
#nav summary a { color: var(--fg); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#nav summary a:hover { text-decoration: none; }
#nav summary a.active { color: var(--accent); }
#nav summary:hover { background: var(--bg-hover); }
#nav ul { list-style: none; margin: 2px 0 10px 19px; padding: 0 0 0 10px; border-left: 1px solid var(--border); }
#nav li { display: flex; align-items: center; }
#nav li a {
  flex: 1; display: block; min-width: 0;
  padding: 4px 10px; border-radius: 6px;
  color: var(--fg-soft); font-size: 13.5px; line-height: 1.4;
}
#nav li a:hover { background: var(--bg-hover); color: var(--fg); text-decoration: none; }
#nav li.active a { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
#nav li.folder { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-faint); padding: 10px 10px 3px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--upd); flex: none; margin: 0 6px; box-shadow: 0 0 0 3px var(--upd-bg); }
.count {
  font-size: 11px; font-weight: 700;
  background: var(--upd-bg); color: var(--upd);
  border-radius: 10px; padding: 1px 7px;
}

/* pages */
.page { max-width: 1100px; padding: 36px 40px 96px; }
h1 { font-size: 30px; line-height: 1.2; letter-spacing: -.02em; font-weight: 700; margin: 0 0 8px; }
h2 { font-size: 19px; letter-spacing: -.01em; font-weight: 650; margin: 44px 0 14px; }
.title-row { display: flex; align-items: center; gap: 14px; }
.lead { font-size: 17px; color: var(--fg-soft); margin-top: 0; }
.crumbs { font-size: 13px; color: var(--fg-faint); margin-bottom: 14px; }
.crumbs a { color: var(--fg-soft); }

.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; margin-right: 6px;
  vertical-align: 1px; white-space: nowrap; line-height: 1.5;
}
.badge.new { background: var(--new-bg); color: var(--new); }
.badge.upd { background: var(--upd-bg); color: var(--upd); }
.badge.del { background: var(--del-bg); color: var(--del); }
.chip {
  display: inline-block; font-size: 12px; font-weight: 500;
  padding: 2px 10px; border-radius: 999px;
  background: var(--surface); color: var(--fg-soft);
  border: 1px solid var(--border);
}
a.chip:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* home */
.hero {
  position: relative; overflow: hidden;
  padding: 28px 30px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 16px;
  background:
    radial-gradient(600px 220px at 100% 0%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 70%),
    radial-gradient(500px 220px at 0% 100%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}
.hero h1 { margin-bottom: 4px; }
.hero > p { margin: 0 0 20px; }
.stats { display: flex; flex-wrap: wrap; gap: 12px; }
.stat {
  display: flex; flex-direction: column; min-width: 130px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--border);
}
.stat b { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--fg-soft); }
.stat.accent b { color: var(--accent); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 24px; }
.card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px 18px 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--fg); background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); text-decoration: none; box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.card-head { display: flex; align-items: center; gap: 12px; font-size: 16px; }
.card-head strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.01em; }
.card-head .badge { margin: 0; }
.card .desc {
  margin: 0; color: var(--fg-soft); font-size: 14px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta {
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center;
  font-size: 12.5px; color: var(--fg-soft); margin-top: auto;
  padding-top: 10px; border-top: 1px dashed var(--border);
}
.card-meta code { background: var(--bg-soft); padding: 1px 6px; border-radius: 5px; }

/* activity timeline */
.feed { max-width: 780px; position: relative; padding-left: 22px; }
.feed::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: var(--border); border-radius: 2px; }
.day { position: relative; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-faint); margin: 26px 0 10px; }
.day:first-child { margin-top: 0; }
.day::before {
  content: ""; position: absolute; left: -22px; top: 50%; width: 12px; height: 12px; transform: translateY(-50%);
  border-radius: 50%; background: var(--surface); border: 2px solid var(--accent);
}
.event {
  padding: 14px 16px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.ev-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.ev-head a { color: var(--fg); }
.ev-head .muted { font-size: 13px; }
.ev-head code { background: var(--bg-soft); padding: 1px 6px; border-radius: 5px; }
.ev-sum { font-size: 14px; color: var(--fg-soft); margin-top: 4px; }
.ev-list { list-style: none; margin: 10px 0 0; padding: 0; font-size: 14px; }
.ev-list li { padding: 3px 0; }
.ev-list .removed span:last-child { text-decoration: line-through; color: var(--fg-soft); }

/* project */
.meta-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1px;
  margin: 20px 0; font-size: 14px;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: var(--border);
}
.meta-grid div { display: flex; flex-direction: column; min-width: 0; padding: 12px 16px; background: var(--surface); }
.meta-grid span { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--fg-faint); margin-bottom: 2px; }
.meta-grid b { font-weight: 500; overflow-wrap: anywhere; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.btn {
  padding: 6px 14px; font-size: 13.5px; font-weight: 500;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm);
  transition: border-color .15s, color .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.readme {
  margin-top: 24px; padding: 8px 28px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 40px; }
.section-head h2 { margin: 0; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--bg-hover); }
.seg button { background: none; border: 0; padding: 5px 12px; border-radius: 7px; color: var(--fg-soft); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.seg button:hover { color: var(--fg); }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm); }

.table-wrap { overflow-x: auto; margin: 14px 0; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--fg-faint); font-weight: 600; }
table.docs { background: var(--surface); }
.table-wrap:has(table.docs) { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
table.docs th { background: var(--bg-soft); }
table.docs tr:last-child td { border-bottom: 0; }
table.docs tr:hover td { background: var(--bg-soft); }
table.docs td a { font-weight: 500; }
.path { font-family: var(--mono); font-size: 11.5px; color: var(--fg-faint); }

/* search */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 22px; }
.result {
  display: block; padding: 14px 16px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.result:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); text-decoration: none; box-shadow: var(--shadow); }
.result p { margin: 6px 0 0; font-size: 14px; color: var(--fg-soft); }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }

/* doc */
.doc-layout { display: grid; grid-template-columns: minmax(0, 820px) 220px; gap: 48px; padding: 36px 40px 96px; }
.doc-layout.no-toc { grid-template-columns: minmax(0, 820px); }
.doc {
  padding: 32px 40px 40px;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.doc-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  font-size: 13px; color: var(--fg-soft);
  padding-bottom: 18px; margin-bottom: 24px; border-bottom: 1px solid var(--border);
}
.toc { position: sticky; top: calc(var(--topbar-h) + 36px); align-self: start; max-height: calc(100vh - var(--topbar-h) - 60px); overflow-y: auto; font-size: 13px; }
.toc-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-faint); margin-bottom: 10px; }
.toc a { display: block; padding: 4px 0 4px 12px; color: var(--fg-soft); border-left: 2px solid var(--border); line-height: 1.4; transition: color .15s, border-color .15s; }
.toc a.lvl3 { padding-left: 24px; font-size: 12.5px; }
.toc a:hover { color: var(--fg); text-decoration: none; }
.toc a.on { color: var(--accent); border-left-color: var(--accent); font-weight: 500; }

/* markdown */
.md { overflow-wrap: break-word; font-size: 15.5px; line-height: 1.75; }
.md h1, .md h2, .md h3, .md h4 { letter-spacing: -.015em; line-height: 1.3; }
.md h1 { font-size: 32px; font-weight: 700; margin: 0 0 18px; }
.md h2 { font-size: 23px; font-weight: 650; margin: 44px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.md h3 { font-size: 18.5px; font-weight: 650; margin: 32px 0 10px; }
.md h4 { font-size: 16px; font-weight: 650; margin: 24px 0 8px; }
.md .anchor { margin-left: 8px; color: var(--fg-faint); opacity: 0; font-weight: 400; transition: opacity .15s; }
.md :is(h1, h2, h3, h4, h5, h6):hover .anchor { opacity: 1; text-decoration: none; }
.md p, .md ul, .md ol, .md blockquote, .md pre { margin: 0 0 16px; }
.md ul, .md ol { padding-left: 1.5em; }
.md li { margin: 4px 0; }
.md li::marker { color: var(--fg-faint); }
.md li > ul, .md li > ol { margin: 4px 0; }
.md a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 3px; }
.md a:hover { text-decoration-color: var(--accent); }
.md a.anchor { text-decoration: none; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
.md blockquote {
  padding: 12px 18px; color: var(--fg);
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.md blockquote p:last-child { margin-bottom: 0; }
.md :not(pre) > code { background: var(--code-bg); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; }
.md pre {
  background: var(--code-bg); padding: 16px 18px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow-x: auto; font-size: 13px; line-height: 1.6;
}
.md pre code.hljs { background: transparent; padding: 0; }
.md img { max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.md .table-wrap { border: 1px solid var(--border); border-radius: var(--radius-sm); }
.md table { width: 100%; font-size: 14px; }
.md td, .md th { border: 0; border-bottom: 1px solid var(--border); }
.md td + td, .md th + th { border-left: 1px solid var(--border); }
.md tr:last-child td { border-bottom: 0; }
.md th { text-transform: none; letter-spacing: 0; font-size: 13.5px; color: var(--fg); background: var(--bg-soft); }
.md tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-soft) 55%, transparent); }
.md input[type=checkbox] { margin-right: 6px; accent-color: var(--accent); }
.md .mermaid { margin: 0 0 16px; text-align: center; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.deadlink { border-bottom: 1px dotted var(--fg-soft); cursor: help; }

.onboarding {
  margin-top: 40px; max-width: 780px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 18px; background: var(--surface);
}
.onboarding summary { cursor: pointer; font-weight: 600; }
.onboarding pre { background: var(--code-bg); border: 1px solid var(--border); padding: 14px 16px; border-radius: var(--radius-sm); overflow-x: auto; font-size: 13px; margin: 12px 0 4px; }

/* responsive */
@media (max-width: 1180px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .icon-btn { display: block; }
  .sidebar {
    position: fixed; z-index: 30; left: 0; top: var(--topbar-h);
    transform: translateX(-100%); transition: transform .2s;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  .page, .doc-layout { padding: 20px 16px 60px; }
  .doc { padding: 20px 18px 28px; border-radius: var(--radius); }
  .readme { padding: 4px 16px; }
  .hero { padding: 20px; }
  .stat { min-width: 0; flex: 1; }
  .topbar { gap: 8px; padding: 0 12px; }
  .brand { display: none; }
  h1, .md h1 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
