/* ==========================================================================
   凯视佳产品文档 · 前台样式
   浅色主题，纯 CSS 变量，无外部依赖
   ========================================================================== */

:root {
    --c-bg: #f5f7fa;
    --c-surface: #ffffff;
    --c-border: #e2e6ee;
    --c-border-strong: #ccd3e0;
    --c-text: #1f2733;
    --c-text-muted: #61708a;
    --c-primary: #0b5fa5;
    --c-primary-dark: #084a80;
    --c-primary-soft: #eaf2fb;
    --c-accent: #0f6e56;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(24, 39, 75, .06), 0 6px 18px rgba(24, 39, 75, .05);
    --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "Cascadia Code", Consolas, "Courier New", monospace;
    --header-h: 60px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body.front {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.7;
    color: var(--c-text);
    background: var(--c-bg);
}

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

:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
    border-radius: 3px;
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: 8px; top: -40px; z-index: 100;
    background: var(--c-primary); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm);
    transition: top .15s ease;
}
.skip-link:focus { top: 8px; }

/* ---------- 顶部 ---------- */
.site-header {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    position: sticky; top: 0; z-index: 20;
}
.site-header__inner {
    max-width: 1400px; margin: 0 auto; padding: 12px 24px;
    display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--c-text); }
.brand:hover { text-decoration: none; }
.brand__logo {
    /* 横向品牌 logo（180×50 原始比例），按高度自适应、不拉伸变形 */
    height: 36px; width: auto; display: block; flex: none;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.25; }
.brand__text strong { font-size: 16px; }
.brand__text small { color: var(--c-text-muted); font-size: 12px; }

.search { margin-left: auto; display: flex; gap: 8px; }
.search input {
    width: min(420px, 46vw); padding: 9px 13px;
    border: 1px solid var(--c-border-strong); border-radius: var(--radius-sm);
    font: inherit; font-size: 14px; background: #fff;
}
.search input:focus { border-color: var(--c-primary); outline: none; box-shadow: 0 0 0 3px var(--c-primary-soft); }
.search button {
    padding: 9px 18px; border: 0; border-radius: var(--radius-sm);
    background: var(--c-primary); color: #fff; font: inherit; font-size: 14px; cursor: pointer;
}
.search button:hover { background: var(--c-primary-dark); }

.topnav { border-top: 1px solid var(--c-border); background: #fbfcfe; }
.topnav > ul {
    max-width: 1400px; margin: 0 auto; padding: 0 24px; list-style: none;
    display: flex; gap: 4px; flex-wrap: wrap;
}
.topnav > ul > li { position: relative; }
.topnav > ul > li > a {
    display: block; padding: 10px 14px; font-size: 14px; color: var(--c-text); font-weight: 500;
}
.topnav > ul > li > a:hover { color: var(--c-primary); text-decoration: none; }
.topnav__sub {
    list-style: none; margin: 0; padding: 0;
    position: absolute; left: 0; top: 100%; min-width: 180px;
    background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow); display: none; z-index: 30;
}
.topnav > ul > li:hover .topnav__sub,
.topnav > ul > li:focus-within .topnav__sub { display: block; }
.topnav__sub a { display: block; padding: 8px 14px; font-size: 13px; color: var(--c-text); }
.topnav__sub a:hover { background: var(--c-primary-soft); text-decoration: none; }

/* ---------- 主体布局 ---------- */
.layout {
    max-width: 1400px; margin: 0 auto; padding: 24px;
    display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px;
    align-items: start;
}

.sidebar {
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
    padding: 16px 14px; position: sticky; top: calc(var(--header-h) + 20px);
    max-height: calc(100dvh - var(--header-h) - 60px); overflow: auto;
}
.sidebar__head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-bottom: 10px;
}
.sidebar__title {
    margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .08em;
    text-transform: uppercase; color: var(--c-text-muted);
}
.sidebar__toggle {
    flex: 0 0 auto; padding: 4px 10px; border: 1px solid var(--c-border-strong);
    border-radius: 999px; background: #fff; color: var(--c-text-muted);
    font: inherit; font-size: 11px; line-height: 1.5; cursor: pointer;
    transition: color .15s ease, border-color .15s ease;
}
.sidebar__toggle:hover { color: var(--c-primary); border-color: var(--c-primary); background: var(--c-primary-soft); }
.sidebar__empty { color: var(--c-text-muted); font-size: 13px; }

/* ---------- 目录树 ---------- */
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { margin-left: 12px; border-left: 1px dashed var(--c-border-strong); padding-left: 6px; }

.tree-row { display: flex; align-items: center; gap: 2px; }
.tree-link {
    flex: 1 1 auto; min-width: 0;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px 8px; border-radius: var(--radius-sm); font-size: 14px; color: var(--c-text);
}
.tree-name { min-width: 0; overflow-wrap: anywhere; }
.tree-link:hover { background: var(--c-primary-soft); text-decoration: none; }
.tree-item.is-active > .tree-row > .tree-link { background: var(--c-primary-soft); color: var(--c-primary); font-weight: 600; }
/* 当前所在分支的祖先：左侧加一条主色导引线，便于定位 */
.tree-item.has-children > .tree-row:has(+ .tree .tree-item.is-active) > .tree-link { color: var(--c-primary); }
.tree-count {
    flex: 0 0 auto;
    font-size: 11px; color: var(--c-text-muted); background: #eef1f6;
    border-radius: 999px; padding: 1px 7px;
}

/* 逐节点折叠按钮：三角箭头，展开时旋转 90° */
.tree-toggle {
    flex: 0 0 auto; width: 22px; height: 22px; margin-left: -2px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 4px; background: transparent;
    color: var(--c-text-muted); cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.tree-toggle:hover { background: #eef1f6; color: var(--c-primary); }
.tree-toggle__icon {
    display: block; width: 0; height: 0; border-style: solid;
    border-width: 5px 0 5px 7px; border-color: transparent transparent transparent currentColor;
    transform-origin: 40% 50%; transition: transform .15s ease;
}
.tree-toggle[aria-expanded="true"] .tree-toggle__icon { transform: rotate(90deg); }
/* 叶子节点占位：不可点、不显示箭头，仅保证同级文字左对齐 */
.tree-toggle--leaf { cursor: default; }
.tree-toggle--leaf:hover { background: transparent; color: var(--c-text-muted); }

/* 折叠：仅在脚本可用时隐藏（无 JS 时保持目录全展开可浏览） */
html.has-js .tree-item:not(.is-open) > .tree { display: none; }

.content { min-width: 0; }

/* ---------- 首页 ---------- */
.hero {
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
    padding: 28px 28px 24px; box-shadow: var(--shadow); margin-bottom: 24px;
}
.hero h1 { margin: 0 0 8px; font-size: 26px; line-height: 1.3; }
.hero__desc { margin: 0 0 10px; color: var(--c-text-muted); max-width: 70ch; }
.hero__stats { margin: 0; font-size: 14px; color: var(--c-text-muted); }
.hero__stats strong { color: var(--c-text); }

.section { margin-bottom: 28px; }
.section__title {
    font-size: 17px; margin: 0 0 12px; padding-bottom: 8px;
    border-bottom: 1px solid var(--c-border);
}

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card {
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
    padding: 18px; transition: border-color .15s ease, transform .15s ease;
}
.card:hover { border-color: var(--c-primary); transform: translateY(-1px); }
.card__title { margin: 0 0 8px; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card__desc { margin: 0 0 10px; color: var(--c-text-muted); font-size: 13px; }
.card__links { margin: 0; padding-left: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.card__links a { font-size: 13px; }

.child-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.child-list li {
    display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-sm);
    padding: 12px 16px;
}

.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.doc-list li {
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.doc-list time, .doc-list .muted { color: var(--c-text-muted); font-size: 12px; margin-left: 10px; }
.doc-list p { margin: 6px 0 0; font-size: 13px; }

/* ---------- 页面头部 / 面包屑 ---------- */
.breadcrumb { margin-bottom: 14px; font-size: 13px; }
.breadcrumb ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumb li + li::before { content: "/"; margin-right: 6px; color: var(--c-border-strong); }
.breadcrumb [aria-current="page"] { color: var(--c-text-muted); }
.breadcrumb--admin { margin-bottom: 16px; }

.page-head {
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
    padding: 20px 24px; margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 22px; display: inline-flex; align-items: center; gap: 10px; }
.page-head__meta { margin: 8px 0 0; font-size: 13px; color: var(--c-text-muted); }
.page-head__desc { margin: 10px 0 0; color: var(--c-text-muted); }
.page-head code { font-family: var(--font-mono); font-size: 12px; background: #eef1f6; padding: 2px 6px; border-radius: 4px; }

/* ---------- 文档详情 ---------- */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 24px; align-items: start; }
.doc-body {
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
    padding: 24px; min-width: 0;
}
.doc-toc {
    position: sticky; top: calc(var(--header-h) + 20px);
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
    padding: 14px 16px; font-size: 13px;
}
.doc-toc__title { margin: 0 0 8px; font-size: 12px; letter-spacing: .06em; color: var(--c-text-muted); text-transform: uppercase; }
.doc-toc ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.doc-toc__item--h3 { padding-left: 12px; }

.prose { font-size: 15px; }
.prose h2 { font-size: 19px; margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--c-border); }
.prose h3 { font-size: 16px; margin: 22px 0 8px; }
.prose p, .prose li { line-height: 1.8; }
.prose img { max-width: 100%; height: auto; }
/* 图片尺寸与对齐（Markdown 属性块 {width=.. align=..} 生成） */
.prose .md-img { margin: 16px 0; }
.prose .md-img img { max-width: 100%; height: auto; }
.prose .md-img--center { text-align: center; }
.prose .md-img--right { text-align: right; }
.prose code { font-family: var(--font-mono); font-size: 13px; background: #eef1f6; padding: 2px 6px; border-radius: 4px; }
.prose pre {
    background: #1f2733; color: #e6edf3; padding: 14px 16px; border-radius: var(--radius-sm);
    overflow: auto; font-size: 13px; line-height: 1.6;
}
.prose pre code { background: none; padding: 0; color: inherit; }
/* 表格：宽表在容器内横向滚动，避免撑破正文栏、压到右侧页内目录 */
.prose .table-wrap {
    margin: 14px 0;
    max-width: 100%;
    overflow-x: auto;                 /* 宽表出现横向滚动条，不再溢出 */
    -webkit-overflow-scrolling: touch; /* iOS 惯性滚动 */
    scrollbar-width: thin;
}
.prose .table-wrap > table { margin: 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; }
.prose th, .prose td {
    border: 1px solid var(--c-border); padding: 8px 12px; text-align: left;
    /* 长型号 / 长单词允许换行，降低表格最小宽度 */
    overflow-wrap: break-word; word-break: break-word;
}
.prose th { background: #f5f7fa; font-weight: 600; }
.prose blockquote {
    margin: 14px 0; padding: 10px 16px; border-left: 3px solid var(--c-primary);
    background: var(--c-primary-soft); color: var(--c-text-muted);
}
.raw-md { white-space: pre-wrap; }

/* ---------- 反馈 ---------- */
.feedback { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--c-border); }
.feedback h2 { font-size: 15px; margin: 0 0 6px; }
.feedback__form { display: grid; gap: 10px; max-width: 620px; margin-top: 10px; }
.feedback__row { display: flex; gap: 10px; flex-wrap: wrap; }
.feedback textarea, .feedback input {
    width: 100%; padding: 9px 12px; border: 1px solid var(--c-border-strong);
    border-radius: var(--radius-sm); font: inherit; font-size: 14px;
}
.feedback__notice {
    margin: 0; font-size: 12px; color: #8a6d1f; background: #fdf7e3;
    border: 1px solid #f0e0b0; border-radius: var(--radius-sm); padding: 8px 12px;
}

/* ---------- 通用元素 ---------- */
.tag {
    display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
    background: #eef1f6; color: var(--c-text-muted); vertical-align: middle;
}
.tag--shared { background: #e7f3ee; color: var(--c-accent); }

.muted { color: var(--c-text-muted); font-size: 13px; }
.empty-state {
    background: var(--c-surface); border: 1px dashed var(--c-border-strong); border-radius: var(--radius);
    padding: 24px; color: var(--c-text-muted); text-align: center;
}
.btn {
    display: inline-block; padding: 8px 16px; border: 1px solid var(--c-primary);
    border-radius: var(--radius-sm); background: var(--c-primary); color: #fff; font-size: 14px;
}
.btn:hover { background: var(--c-primary-dark); text-decoration: none; }

.site-footer { border-top: 1px solid var(--c-border); background: var(--c-surface); margin-top: 40px; }
.site-footer__inner {
    max-width: 1400px; margin: 0 auto; padding: 20px 24px;
    display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    font-size: 13px; color: var(--c-text-muted);
}
.site-footer p { margin: 0; }
.site-footer__meta { display: flex; gap: 14px; flex-wrap: wrap; }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
    .doc-layout { grid-template-columns: minmax(0, 1fr); }
    .doc-toc { position: static; order: -1; }
}

@media (max-width: 860px) {
    .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; }
    .sidebar { position: static; max-height: none; }
    .site-header__inner { padding: 10px 16px; gap: 12px; }
    .search { margin-left: 0; width: 100%; }
    .search input { width: 100%; }
    .topnav > ul { padding: 0 16px; }
    .hero { padding: 20px; }
    /* 窄屏压缩表格内边距，尽量少滚动 */
    .prose th, .prose td { padding: 6px 8px; font-size: 13px; }
    .doc-body { padding: 16px; }
}

@media print {
    .site-header, .sidebar, .doc-toc, .site-footer, .feedback { display: none; }
    .layout { display: block; padding: 0; }
    .doc-body { border: 0; padding: 0; }
}

/* ===================== 下载中心 / 文档附加信息（P2） ===================== */
.dl-filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.dl-pill {
    display: inline-block; padding: 4px 14px; border-radius: 999px;
    border: 1px solid #d0d7de; font-size: 13px; color: #24292f; text-decoration: none;
}
.dl-pill.is-active { background: #1f6feb; border-color: #1f6feb; color: #fff; }
.dl-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.dl-table th, .dl-table td { border-bottom: 1px solid #eaeef2; padding: 10px 8px; text-align: left; }
.dl-table th { color: #57606a; font-weight: 600; font-size: 13px; }
.dl-btn {
    display: inline-block; padding: 4px 16px; border-radius: 6px;
    background: #1f6feb; color: #fff; text-decoration: none; font-size: 13px;
}
.dl-btn:hover { background: #1a5fd0; }
.dl-tag {
    display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 4px;
    background: #e7f0ff; color: #1f6feb; font-size: 12px; font-weight: 600;
    vertical-align: middle;
}
.doc-extra { margin-top: 28px; padding-top: 16px; border-top: 1px solid #eaeef2; }
.doc-extra h2 { font-size: 16px; margin: 0 0 8px; }
.doc-pill {
    display: inline-block; margin: 2px 6px 2px 0; padding: 3px 12px;
    border-radius: 999px; background: #eef4ff; color: #1f4fd0; font-size: 13px;
}
.doc-attachments { list-style: none; margin: 0; padding: 0; }
.doc-attachments li { padding: 4px 0; }
.feedback__ok { color: #1a7f37; background: #dafbe1; border-radius: 6px; padding: 8px 12px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ===================== 搜索高亮（P3） ===================== */
mark.hl { background: #fff3bf; color: inherit; padding: 0 1px; border-radius: 2px; }
