/* ============================================================
   文档 wiki 视图样式
   所有选择器以 .view-docs 开头；颜色/阴影仅使用 CSS 变量
   ============================================================ */

.view-docs .docs-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  min-height: 0;
}

/* ---------------- 移动端工具条（桌面隐藏） ---------------- */
.view-docs .docs-mobilebar {
  display: none;
  align-items: center;
  gap: 12px;
}
.view-docs .docs-mobilebar-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- 布局 ---------------- */
.view-docs .docs-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 16px;
  align-items: stretch;
}

/* ---------------- 左侧目录 ---------------- */
.view-docs .docs-toc {
  width: 270px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(130%);
  -webkit-backdrop-filter: blur(24px) saturate(130%);
  overflow: hidden;
}
.view-docs .docs-toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.view-docs .docs-toc-title {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.view-docs .docs-toc-close {
  display: none;
}

.view-docs .docs-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-2);
  color: var(--text-dim);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.view-docs .docs-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.view-docs .docs-search svg {
  flex-shrink: 0;
}
.view-docs .docs-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
.view-docs .docs-search-input::placeholder {
  color: var(--text-dim);
  opacity: 0.75;
}

.view-docs .docs-fulltext-btn {
  width: 100%;
}

.view-docs .docs-toc-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 -6px;
  padding: 0 6px;
}
.view-docs .docs-toc-item {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.view-docs .docs-toc-item:hover {
  background: var(--hover);
  color: var(--text);
}
.view-docs .docs-toc-item.active {
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 600;
}
.view-docs .docs-toc-item.is-filtered {
  display: none;
}
.view-docs .docs-toc-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 5px;
  color: var(--text-dim);
}
.view-docs .docs-toc-toggle svg {
  transition: transform 0.18s ease;
}
.view-docs .docs-toc-item.is-collapsed > .docs-toc-toggle svg {
  transform: rotate(0deg);
}
.view-docs .docs-toc-item:not(.is-collapsed) > .docs-toc-toggle svg {
  transform: rotate(90deg);
}
.view-docs .docs-toc-item:hover .docs-toc-toggle {
  color: var(--accent-2);
}
.view-docs .docs-toc-toggle.is-leaf {
  visibility: hidden;
}
.view-docs .docs-toc-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.view-docs .docs-toc-state {
  padding: 16px 8px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.view-docs .docs-toc-mask {
  display: none;
}
/* author 样式会盖过 UA 的 [hidden] 规则，显式兜底 */
.view-docs .docs-toc-mask[hidden],
.view-docs .modal-mask[hidden] {
  display: none;
}

/* ---------------- 右侧正文 ---------------- */
.view-docs .docs-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  border-radius: var(--radius);
}
.view-docs .docs-article-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding-bottom: 40px;
}

.view-docs .docs-article {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(130%);
  -webkit-backdrop-filter: blur(24px) saturate(130%);
  padding: 30px 34px;
  user-select: text;
}
.view-docs .docs-ch-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding-bottom: 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.view-docs .docs-updated {
  font-size: 12px;
  margin: 8px 0 4px;
}

.view-docs .docs-welcome {
  max-width: 860px;
  margin: 0 auto 16px;
  padding: 8px 4px 0;
}
.view-docs .docs-welcome-title {
  font-size: 22px;
  font-weight: 700;
}
.view-docs .docs-welcome-desc {
  margin-top: 6px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-dim);
}
.view-docs .docs-welcome .muted {
  display: block;
  margin-top: 12px;
  font-size: 13px;
}

.view-docs .docs-empty {
  max-width: 860px;
  margin: 24px auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 52px 20px;
  color: var(--text-dim);
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.view-docs .docs-empty svg {
  opacity: 0.5;
}
.view-docs .docs-empty p {
  font-size: 14px;
  line-height: 1.7;
}

/* ---------------- 骨架屏 ---------------- */
.view-docs .docs-skeleton {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 30px 34px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.view-docs .docs-skel-line {
  display: block;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--card-2) 25%, var(--hover) 50%, var(--card-2) 75%);
  background-size: 200% 100%;
  animation: docs-skel 1.4s ease infinite;
}
.view-docs .docs-skel-title {
  height: 26px;
  width: 46%;
  margin-bottom: 8px;
}
.view-docs .docs-skel-short {
  width: 62%;
}
@keyframes docs-skel {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ---------------- markdown 正文排版 ---------------- */
.view-docs .docs-content {
  font-size: 14.5px;
  line-height: 1.8;
  word-break: break-word;
}
.view-docs .docs-content h1,
.view-docs .docs-content h2,
.view-docs .docs-content h3,
.view-docs .docs-content h4 {
  font-weight: 700;
  line-height: 1.4;
  margin: 24px 0 10px;
  color: var(--text);
}
.view-docs .docs-content h1 { font-size: 21px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.view-docs .docs-content h2 { font-size: 18px; }
.view-docs .docs-content h3 { font-size: 16px; }
.view-docs .docs-content h4 { font-size: 14.5px; }
.view-docs .docs-content p { margin: 10px 0; }
.view-docs .docs-content ul,
.view-docs .docs-content ol {
  margin: 10px 0;
  padding-left: 26px;
}
.view-docs .docs-content li { margin: 4px 0; }
.view-docs .docs-content li > ul,
.view-docs .docs-content li > ol { margin: 4px 0; }
.view-docs .docs-content a {
  color: var(--accent-2);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}
.view-docs .docs-content a:hover {
  border-bottom-color: var(--accent-2);
}
.view-docs .docs-content code {
  font-family: 'Cascadia Code', Consolas, 'Courier New', monospace;
  font-size: 12.5px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
}
.view-docs .docs-content pre {
  margin: 14px 0;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
}
.view-docs .docs-content pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 12.5px;
  line-height: 1.7;
}
.view-docs .docs-content blockquote {
  margin: 14px 0;
  padding: 8px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  color: var(--text-dim);
}
.view-docs .docs-content blockquote p { margin: 6px 0; }
.view-docs .docs-content table {
  width: 100%;
  margin: 14px 0;
  border-collapse: collapse;
  font-size: 13px;
  display: block;
  overflow-x: auto;
}
.view-docs .docs-content th,
.view-docs .docs-content td {
  border: 1px solid var(--border);
  padding: 7px 12px;
  text-align: left;
}
.view-docs .docs-content th {
  background: var(--card-2);
  font-weight: 600;
}
.view-docs .docs-content tr:hover td {
  background: var(--hover);
}
.view-docs .docs-content img {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin: 10px 0;
}
.view-docs .docs-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 22px 0;
}
.view-docs .docs-content mark {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-radius: 4px;
  padding: 0 4px;
}

/* ---------------- 全文搜索面板 ---------------- */
.view-docs .docs-search-panel {
  width: min(560px, calc(100vw - 48px));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.view-docs .docs-search-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.view-docs .modal-title {
  font-size: 16px;
  font-weight: 700;
}
.view-docs .docs-search-panel-bar {
  display: flex;
  gap: 10px;
}
.view-docs .docs-search-panel-bar .input {
  flex: 1;
}
.view-docs .docs-search-results {
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.view-docs .docs-search-hit {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-2);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.view-docs .docs-search-hit:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.view-docs .docs-search-hit-title {
  font-size: 13.5px;
  font-weight: 600;
}
.view-docs .docs-search-hit-snippet {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------------- 移动端（<900px）：目录变抽屉 ---------------- */
@media (max-width: 899px) {
  .view-docs .docs-mobilebar {
    display: flex;
  }
  .view-docs .docs-toc {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 120;
    width: min(300px, 84vw);
    border-radius: 0 var(--radius) var(--radius) 0;
    box-shadow: var(--shadow-lg);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }
  .view-docs .docs-toc.open {
    transform: translateX(0);
  }
  .view-docs .docs-toc-close {
    display: inline-flex;
  }
  .view-docs .docs-toc-mask {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 110;
    background: var(--mask);
    backdrop-filter: blur(4px);
  }
  .view-docs .docs-article {
    padding: 20px 18px;
  }
  .view-docs .docs-ch-title {
    font-size: 20px;
  }
}
