/* ============================================================
   文档页（飞书原文本地化）— 排版补充
   依赖 style.css 的变量与基础排版
   ============================================================ */

.doc-article {
    padding-top: clamp(28px, 4.4vw, 46px);
}

.doc-article h1 {
    font-size: clamp(23px, 3.4vw, 32px);
    line-height: 1.24;
    letter-spacing: -.028em;
}

/* ---------- 目录 ---------- */

.doc-toc {
    margin: 26px 0 6px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.doc-toc-title {
    margin: 0 0 8px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--muted);
}

.doc-toc ol {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: toc;
    columns: 2;
    column-gap: 26px;
    font-size: 13px;
    line-height: 1.9;
}

@media (max-width: 560px) {
    .doc-toc ol {
        columns: 1;
    }
}

.doc-toc li {
    display: flex;
    gap: 7px;
    break-inside: avoid;
    counter-increment: toc;
    overflow: hidden;
}

.doc-toc li a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-toc li::before {
    content: counter(toc, decimal-leading-zero);
    flex: none;
    font-size: 10.5px;
    color: #cbd5e1;
    font-variant-numeric: tabular-nums;
}

.doc-toc a {
    border-bottom: 0;
    color: var(--ink-2);
    transition: color .18s var(--ease);
}

.doc-article .doc-toc a:hover {
    border-bottom: 0;
    color: var(--accent);
}

/* ---------- 正文 ---------- */

.doc-article h1,
.doc-article h2,
.doc-article h3,
.doc-article h4,
.doc-article h5 {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.doc-article h2 {
    margin: clamp(34px, 4.6vw, 46px) 0 14px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--line);
    font-size: clamp(18px, 2.3vw, 21px);
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -.02em;
    scroll-margin-top: 24px;
}

.doc-article h3 {
    margin: 28px 0 10px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.45;
    letter-spacing: -.01em;
    scroll-margin-top: 24px;
}

.doc-article h4 {
    margin: 22px 0 8px;
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--ink-2);
    scroll-margin-top: 24px;
}

.doc-article h5 {
    margin: 18px 0 6px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--ink-2);
    scroll-margin-top: 24px;
}

.doc-article p {
    margin: 0 0 9px;
    font-size: 13.5px;
    line-height: 1.85;
    color: var(--ink-2);
    overflow-wrap: anywhere;
}

.doc-article p:empty {
    display: none;
}

.doc-article a:not(.doc-back) {
    border-bottom: 1px solid rgba(37, 99, 235, .28);
    color: #2563eb;
    transition: border-color .16s var(--ease), color .16s var(--ease);
}

.doc-article a:hover {
    border-bottom-color: var(--accent);
    color: var(--accent);
}

.doc-article img {
    max-width: 100%;
    height: auto;
}

.doc-article code {
    padding: 1px 5px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #f8fafc;
    font-size: 12.5px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    color: #1e40af;
}

.doc-article pre {
    overflow-x: auto;
    margin: 12px 0 14px;
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f7f9fc;
    font-size: 12.5px;
    line-height: 1.7;
}

.doc-article pre code {
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink-2);
}

.doc-article blockquote {
    margin: 12px 0;
    padding: 2px 0 2px 14px;
    border-left: 2px solid var(--line-strong);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.8;
}

.doc-article hr {
    margin: 28px 0;
    border: 0;
    border-top: 1px solid var(--line);
}

/* 列表 */

.doc-article ul,
.doc-article ol {
    margin: 0 0 10px;
    padding-left: 20px;
    font-size: 13.5px;
    line-height: 1.85;
    color: var(--ink-2);
}

.doc-article li {
    margin-bottom: 5px;
    overflow-wrap: anywhere;
}

.doc-article li:last-child {
    margin-bottom: 0;
}

.doc-article ul li::marker {
    color: #cbd5e1;
}

/* 提示块 */

.doc-article .note {
    margin: 14px 0 16px;
    font-size: 13px;
}

.doc-article .note p {
    margin: 0 0 5px;
    font-size: 13px;
    line-height: 1.8;
    color: #1e40af;
}

.doc-article .note p:last-child {
    margin-bottom: 0;
}

.doc-article .note a {
    color: #2563eb;
    border-bottom-color: rgba(37, 99, 235, .3);
}

.doc-article .note h3,
.doc-article .note h4,
.doc-article .note h5 {
    margin: 10px 0 4px;
    color: #1e40af;
}

.doc-article .note h3:first-child,
.doc-article .note h4:first-child {
    margin-top: 0;
}

/* 图片 */

.doc-fig {
    margin: 14px 0 18px;
}

.doc-fig img {
    display: block;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f7f9fc;
}

.doc-fig figcaption {
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--muted);
    text-align: center;
}

.doc-fig.is-missing {
    padding: 22px 16px;
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
    background: #f8fafc;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

/* 多列（飞书分栏） */

.doc-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 12px 0 16px;
}

@media (max-width: 620px) {
    .doc-grid {
        grid-template-columns: 1fr;
    }
}

.doc-grid .doc-fig {
    margin: 0;
}

/* 附件 / 视频占位 */

.doc-attach {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 10px 0;
    padding: 11px 13px;
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
    background: #f8fafc;
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--muted);
}

.doc-attach-tag {
    flex: none;
    padding: 1px 7px;
    border-radius: 5px;
    background: #e9ecf2;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .04em;
    color: #8b93a1;
}

/* 长文档底部 */


.doc-extnote {
    margin: 26px 0 0;
    padding: 10px 13px;
    border-left: 2px solid var(--line-strong);
    font-size: 12px;
    line-height: 1.7;
    color: var(--muted);
}

.doc-end {
    margin: 40px 0 0;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: 12px;
    line-height: 1.8;
    color: var(--muted);
}

.doc-end a {
    border-bottom: 1px solid rgba(37, 99, 235, .26);
    color: #2563eb;
}

/* ============================================================
   文档索引页（全部文档 · 搜索 + 卡片墙）
   ============================================================ */

.wrap-index {
    max-width: 1400px;
}

.doc-library {
    padding-top: clamp(24px, 3.2vw, 40px);
}

/* ---------- 页头 ---------- */

.lib-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
    margin: 0 0 24px;
    padding-bottom: clamp(18px, 2.2vw, 24px);
    border-bottom: 1px solid var(--line);
}

.lib-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--muted);
}

.lib-eyebrow::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.doc-library .lib-hero h1 {
    margin: 12px 0 0;
    font-size: clamp(30px, 3.8vw, 46px);
    font-weight: 700;
    line-height: 1.06;
    letter-spacing: -.045em;
    color: var(--ink);
}

.doc-library .doc-meta {
    margin: 11px 0 0;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--muted);
    letter-spacing: .01em;
}

/* ---------- 搜索条 ---------- */

.lib-bar {
    display: flex;
    align-items: center;
    gap: 18px;
    margin: 0 0 20px;
}

.lib-search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 420px;
    cursor: text;
}

.lib-search-icon {
    position: absolute;
    left: 15px;
    width: 16px;
    height: 16px;
    color: var(--muted);
    pointer-events: none;
    transition: color .2s var(--ease);
}

.lib-search input {
    width: 100%;
    height: 44px;
    padding: 0 42px 0 43px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 13.5px;
    line-height: 44px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease),
        background-color .2s var(--ease);
}

.lib-search input::-webkit-search-cancel-button {
    display: none;
}

.lib-search input::placeholder {
    color: var(--muted);
    opacity: .86;
}

.lib-search input:focus {
    border-color: rgba(37, 99, 235, .55);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.lib-search:focus-within .lib-search-icon {
    color: var(--accent);
}

.lib-clear {
    position: absolute;
    right: 10px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--line);
    color: var(--ink-2);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: background-color .2s var(--ease), color .2s var(--ease);
}

.lib-clear:hover {
    background: var(--line-strong);
    color: var(--ink);
}

.lib-total {
    font-size: 12px;
    color: var(--muted);
    letter-spacing: .02em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------- 卡片墙 ---------- */

.doc-index-grid {
    counter-reset: doc;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
}

a.doc-index-item {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 112px;
    padding: 17px 19px 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background-color: var(--surface);
    background-image: linear-gradient(90deg, var(--accent), #7c3aed);
    background-repeat: no-repeat;
    background-size: 0 2px;
    background-position: 0 0;
    overflow: hidden;
    transition: transform .24s var(--ease), border-color .24s var(--ease),
        box-shadow .24s var(--ease), background-size .32s var(--ease),
        background-color .24s var(--ease);
}

/* 右上角序号 */
a.doc-index-item::before {
    counter-increment: doc;
    content: counter(doc, decimal-leading-zero);
    position: absolute;
    top: 14px;
    right: 15px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .06em;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    opacity: .42;
    transition: color .24s var(--ease), opacity .24s var(--ease);
}

/* 右下角跳转箭头 */
a.doc-index-item::after {
    content: "\2197";
    position: absolute;
    right: 16px;
    bottom: 13px;
    font-size: 12px;
    line-height: 1;
    color: var(--accent);
    opacity: .2;
    transition: opacity .24s var(--ease), transform .24s var(--ease);
}

a.doc-index-item:hover {
    transform: translateY(-3px);
    border-color: rgba(37, 99, 235, .3);
    box-shadow: 0 18px 38px -26px rgba(23, 37, 84, .5);
    background-color: var(--accent-soft);
    background-size: 100% 2px;
}

a.doc-index-item:hover::before {
    color: var(--accent);
    opacity: 1;
}

a.doc-index-item:hover::after {
    opacity: 1;
    transform: translate(2px, -2px);
}

a.doc-index-item[hidden] {
    display: none !important;
}

.doc-index-name {
    padding-right: 24px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: -.01em;
    color: var(--ink);
    transition: color .24s var(--ease);
}

a.doc-index-item:hover .doc-index-name {
    color: var(--accent);
}

.doc-index-meta {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 8px;
    padding-right: 4px;
    font-size: 12px;
    line-height: 1.66;
    color: var(--muted);
    overflow-wrap: anywhere;
}

/* ---------- 空态 ---------- */

.lib-empty {
    margin: 34px 0 0;
    padding: 54px 20px;
    border: 1px dashed var(--line-strong);
    border-radius: 16px;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
    background: var(--surface);
}

/* ---------- 页脚说明 ---------- */

.doc-library .lib-note {
    margin-top: clamp(28px, 3.6vw, 42px);
    padding: 13px 17px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--accent-soft);
    font-size: 12px;
    line-height: 1.8;
    color: var(--muted);
}

/* ---------- 响应式 ---------- */

@media (max-width: 1120px) {
    .doc-index-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .doc-index-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .lib-bar {
        flex-wrap: wrap;
        gap: 10px;
    }

    .lib-search {
        max-width: none;
    }
}

@media (max-width: 560px) {
    .wrap-index {
        padding: 0 16px;
    }

    .doc-library .lib-hero h1 {
        font-size: 30px;
    }

    .doc-index-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 9px;
    }

    a.doc-index-item {
        padding: 14px 16px 15px;
    }

    .doc-index-name {
        font-size: 14px;
    }
}

/* 超大屏：放宽容器并加到 5 列，避免两侧留白过多 */
@media (min-width: 1700px) {
    .wrap-index {
        max-width: 1560px;
    }

    .doc-index-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}
