/* Grape 文档站 —— 依赖 assets/theme.css 的明暗组件与 light token */
:root{
  --bg:#08090a;
  --bg-2:#0f1011;
  --text:#f7f8f8;
  --text-2:#d0d6e0;
  --text-3:#8a8f98;
  --accent:#7170ff;
  --accent-2:#828fff;
  --grad:linear-gradient(135deg,#5e6ad2 0%,#828fff 100%);
  --surface:rgba(255,255,255,.02);
  --surface-hover:rgba(255,255,255,.05);
  --border:rgba(255,255,255,.05);
  --border-hover:rgba(255,255,255,.08);
  --radius:8px;
  --radius-lg:12px;
  --mono:'JetBrains Mono',monospace;
  --nav-bg:rgba(8,9,10,.8);
  --docs-top:60px;
  --docs-side:240px;
  --docs-wrap:1120px;
  --doc-measure:768px;
  /* 徽章淡底：随主题切换的 accent 派生色，不支持 color-mix 时回落 --surface */
  --accent-soft:var(--surface);
}
@supports (background:color-mix(in srgb,red 10%,transparent)){
  :root{--accent-soft:color-mix(in srgb,var(--accent) 12%,transparent)}
}

*{box-sizing:border-box}
html{scroll-behavior:smooth;scroll-padding-top:calc(var(--docs-top) + 16px);color-scheme:dark}
body{
  margin:0;
  font-family:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Noto Sans SC','PingFang SC','Microsoft YaHei',sans-serif;
  background:var(--bg);
  color:var(--text);
  line-height:1.7;
  -webkit-font-smoothing:antialiased;
}
a{color:var(--accent-2)}
.skip{position:absolute;left:-9999px}
.skip:focus{left:8px;top:8px;z-index:100;background:var(--bg-2);color:var(--text);padding:8px 12px;border-radius:6px;border:1px solid var(--border-hover)}

/* 顶栏 */
.docs-top{
  position:sticky;top:0;z-index:20;
  display:flex;align-items:center;gap:18px;
  height:var(--docs-top);padding:0 20px;
  background:var(--nav-bg);backdrop-filter:blur(10px);
  border-bottom:1px solid var(--border);
  overflow-x:auto;
}
.docs-brand{font-weight:700;font-size:15px;color:var(--text);text-decoration:none;white-space:nowrap}
.docs-sections{display:flex;align-items:center;gap:4px}
.docs-sec{padding:5px 10px;border-radius:6px;font-size:13.5px;color:var(--text-3);text-decoration:none;white-space:nowrap;transition:color .15s,background-color .15s}
.docs-sec:hover{color:var(--text);background:var(--surface-hover)}
.docs-sec[aria-current="page"]{color:var(--accent-2);background:var(--surface);font-weight:600}
.docs-top-right{margin-left:auto;display:flex;align-items:center;gap:12px}
.docs-back{font-size:13px;color:var(--text-3);text-decoration:none;white-space:nowrap}
.docs-back:hover{color:var(--text)}
.docs-github,.docs-gitcode{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;flex:0 0 auto;color:var(--text-3);text-decoration:none}
.docs-github svg,.docs-gitcode svg{display:block;width:20px;height:20px}
.docs-github:hover,.docs-gitcode:hover{color:var(--text)}

/* 布局：左侧全局目录 + 右侧正文 */
.docs-layout{
  display:grid;grid-template-columns:var(--docs-side) minmax(0,1fr);
  gap:40px;max-width:var(--docs-wrap);margin:0 auto;
  padding:32px 20px 72px;
}
.docs-side{
  position:sticky;top:calc(var(--docs-top) + 16px);align-self:start;
  max-height:calc(100vh - var(--docs-top) - 32px);overflow:auto;
  padding:0 12px 0 0;
  overscroll-behavior:contain;
}
.docs-main{min-width:0}

/* 侧栏：标题 + 搜索 */
.docs-side-title{
  margin:0 0 10px;padding:0 10px;
  font-size:11.5px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;
  color:var(--text-3);
}
.docs-side-search-wrap{display:none;align-items:center;gap:8px;margin:0 0 14px;padding:0 10px}
.docs-side.docs-side-js .docs-side-search-wrap{display:flex}
.docs-side-search{
  flex:1 1 auto;min-width:0;height:32px;padding:0 10px;
  font:inherit;font-size:13px;color:var(--text);
  background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);
  outline:none;transition:border-color .15s,background-color .15s;
}
.docs-side-search::placeholder{color:var(--text-3)}
.docs-side-search:focus{border-color:var(--accent);background:var(--bg-2)}
.docs-side-search:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
.docs-side-kbd{
  flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;
  width:22px;height:22px;border-radius:5px;
  font-family:var(--mono);font-size:11px;color:var(--text-3);
  background:var(--surface);border:1px solid var(--border);
}

/* 侧栏：区块分组（原生 details 折叠） */
.docs-side ul{list-style:none;margin:0;padding:0}
.docs-side a{display:block;padding:5px 10px;border-radius:6px;font-size:13.5px;line-height:1.45;color:var(--text-3);text-decoration:none}
.docs-side a:hover{color:var(--text);background:var(--surface-hover)}
.docs-side a[aria-current="page"]{color:var(--accent-2);background:var(--surface);font-weight:600;box-shadow:inset 2px 0 0 var(--accent)}
.docs-group{border-top:1px solid var(--border);padding:6px 0}
.docs-group:first-of-type{border-top:0}
.docs-group[hidden],.docs-side li[hidden]{display:none}
.docs-group>summary{
  display:flex;align-items:center;gap:6px;
  padding:6px 10px;border-radius:6px;
  font-size:13px;font-weight:600;color:var(--text-2);
  cursor:pointer;list-style:none;
}
.docs-group>summary::-webkit-details-marker{display:none}
.docs-group>summary:hover{color:var(--text);background:var(--surface-hover)}
.docs-group>summary:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
.docs-group-name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
/* 组标题即入口：summary 内的入口页链接（保留标题省略号，不与 .docs-side a 的块级内边距/阴影叠加） */
.docs-group>summary>a{
  display:flex;flex:1 1 auto;min-width:0;align-items:center;
  padding:0;border-radius:4px;
  font:inherit;color:inherit;text-decoration:none;
}
.docs-group>summary>a:hover{color:var(--accent-2);background:transparent}
.docs-group>summary>a:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.docs-group>summary>a[aria-current="page"]{
  color:var(--accent-2);font-weight:700;background:transparent;box-shadow:none;
}
.docs-group-count{
  margin-left:auto;flex:0 0 auto;padding:1px 6px;min-width:20px;
  border-radius:999px;background:var(--surface);
  font-size:11.5px;font-weight:500;color:var(--text-3);text-align:center;
}
.docs-group>summary::after{
  content:"";flex:0 0 auto;width:6px;height:6px;margin-left:2px;
  border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;
  transform:rotate(-45deg);opacity:.6;transition:transform .15s;
}
.docs-group[open]>summary::after{transform:rotate(45deg)}
.docs-group ul{padding:2px 0 4px 8px}
.docs-side-empty{margin:6px 0 0;padding:10px 12px;font-size:13px;color:var(--text-3)}

/* 正文 */
.doc{font-size:16px;line-height:1.7;max-width:var(--doc-measure);color:var(--text-2);overflow-wrap:anywhere}
.doc h1,.doc h2,.doc h3,.doc h4{color:var(--text);line-height:1.3;font-weight:650;scroll-margin-top:calc(var(--docs-top) + 16px);overflow-wrap:anywhere}
.doc h1{font-size:26px;margin:0 0 18px;letter-spacing:-.01em}
.doc h2{font-size:21px;margin:40px 0 14px;padding-bottom:10px;border-bottom:1px solid var(--border)}
.doc h3{font-size:17px;margin:28px 0 12px}
.doc h4{font-size:15.5px;margin:22px 0 10px}
.doc p{margin:12px 0}
.doc ul,.doc ol{margin:12px 0;padding-left:24px}
.doc li{margin:5px 0}
.doc a{text-decoration:underline;text-underline-offset:2px}
.doc strong{color:var(--text)}
.doc hr{border:0;border-top:1px solid var(--border);margin:28px 0}
.doc blockquote{
  margin:16px 0;padding:10px 16px;
  border-left:3px solid var(--accent);
  background:var(--surface);border-radius:0 var(--radius) var(--radius) 0;
  color:var(--text-2);
}
.doc blockquote p{margin:6px 0}
.doc code{font-family:var(--mono);font-size:13px}
.doc :not(pre)>code{
  background:var(--surface-hover);color:var(--text);
  padding:2px 5px;border-radius:4px;overflow-wrap:anywhere;
}
.doc pre{
  background:var(--bg-2);border:1px solid var(--border);
  border-radius:var(--radius);padding:14px 16px;margin:16px 0;
  overflow-x:auto;line-height:1.55;
}
.doc pre code{background:none;padding:0;color:var(--text-2);white-space:pre}

/* 页首徽章：区块名 · 序号（用 p，避免多出标题） */
.doc-kicker{
  display:inline-flex;align-items:center;gap:6px;
  margin:0 0 14px;padding:3px 10px;
  font-size:12px;font-weight:600;letter-spacing:.02em;
  color:var(--accent-2);background:var(--accent-soft);
  border-radius:999px;
}

/* 表格：两列「痛点 / 解决方案」对比也适用 */
.doc table{
  display:block;max-width:100%;overflow-x:auto;
  width:100%;border-collapse:collapse;margin:18px 0;font-size:14.5px;
}
.doc th,.doc td{border:1px solid var(--border);padding:8px 12px;text-align:left;vertical-align:top}
.doc th{background:var(--accent-soft);color:var(--text);font-weight:600;white-space:nowrap}
.doc tbody tr:nth-child(even) td{background:var(--surface)}
.doc img{max-width:100%;height:auto;border-radius:var(--radius)}

/* 浅灰占位卡片（正文内可选组件） */
.doc-card{
  margin:16px 0;padding:16px 18px;
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius-lg);
}
.doc-card>:first-child{margin-top:0}
.doc-card>:last-child{margin-bottom:0}
.doc-card h3,.doc-card h4{margin-top:0;font-size:15.5px}

/* 页脚 */
.docs-foot{
  margin-top:48px;padding-top:18px;border-top:1px solid var(--border);
  display:flex;flex-wrap:wrap;align-items:center;gap:14px;font-size:13.5px;
}
.docs-pager,.docs-mailto{color:var(--text-3);text-decoration:none}
.docs-pager:hover,.docs-mailto:hover{color:var(--accent-2)}
.docs-pager[rel="next"]{margin-left:auto}

/* 首页：与内页同构的双栏外壳，版心与留白统一交给 .docs-layout */
.docs-landing h1{font-size:26px;margin:0 0 12px;letter-spacing:-.01em}
.docs-lead{color:var(--text-3);max-width:64ch;margin:0 0 32px}
.docs-landing .docs-lead{margin:0 0 8px}
.docs-landing section h2{
  font-size:21px;font-weight:650;line-height:1.3;color:var(--text);
  margin:36px 0 14px;padding-bottom:10px;border-bottom:1px solid var(--border);
  scroll-margin-top:calc(var(--docs-top) + 16px);
}

/* 区块索引页（/docs/usage/ 等）的页面列表 */
.docs-toc{list-style:none;margin:0;padding:0;max-width:66ch}
.docs-toc li{border-bottom:1px solid var(--border)}
.docs-toc li:last-child{border-bottom:0}
.docs-toc a{display:block;padding:11px 2px;color:var(--text-2);text-decoration:none;font-size:14.5px}
.docs-toc a:hover{color:var(--accent-2)}

/* 宽屏：目录栏加宽到 288px、版心 1200px */
@media (min-width:1280px){
  :root{--docs-side:288px;--docs-wrap:1200px}
  .docs-layout{gap:48px}
}

/* 窄屏：侧栏折到正文上方，避免横向溢出 */
@media (max-width:999px){
  .docs-layout{display:block;padding:20px 16px 56px}
  .docs-side{
    position:static;max-height:min(52vh,420px);overflow:auto;
    margin:0 0 24px;padding:0 0 12px;border-bottom:1px solid var(--border);
    overscroll-behavior:contain;
  }
  .doc h1{font-size:26px}
}
@media (max-width:640px){
  .docs-top{gap:8px;padding:0 10px;overflow-x:visible}
  .docs-sections{display:none}
  .docs-top-right{gap:8px}
  .docs-back{font-size:12px}
  .docs-brand{font-size:14px}
  .docs-sec{padding:5px 7px;font-size:12.5px}
  .doc{font-size:15.5px}
  .doc table{font-size:13px}
}
@media (prefers-reduced-motion:reduce){
  html{scroll-behavior:auto}
  *{transition:none!important}
}