/* =========================================================
   YunQing Blog 图文模板库样式
   双作用域：前台文章 .prose + 后台预览 .editor-preview
   颜色全部走 tokens.css 变量 / color-mix，深浅主题自动适配
   模板根类：.tpl .tpl-xxx（内部单行 HTML，配合 marked 原生透传）
   ========================================================= */

:is(.prose, .editor-preview) .tpl { margin: 1.8em 0; }
:is(.prose, .editor-preview) .tpl img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    border-radius: 12px;
}
:is(.prose, .editor-preview) .tpl p { margin: 0.4em 0; }
:is(.prose, .editor-preview) .tpl ul,
:is(.prose, .editor-preview) .tpl ol { margin: 0.5em 0; padding-left: 1.4em; }

/* ---------- 开头 ---------- */

/* 头图卡 */
:is(.prose, .editor-preview) .tpl-hero {
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    background: var(--bg-card);
}
:is(.prose, .editor-preview) .tpl-hero .tpl-hero__img { border-radius: 0; }
:is(.prose, .editor-preview) .tpl-hero .tpl-hero__body { padding: 18px 22px 20px; }
:is(.prose, .editor-preview) .tpl-hero .tpl-hero__kicker {
    margin: 0 0 6px;
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent);
    text-transform: uppercase;
}
:is(.prose, .editor-preview) .tpl-hero .tpl-hero__title {
    margin: 0 0 8px;
    font-size: 1.5em;
    line-height: 1.25;
    color: var(--ink);
}
:is(.prose, .editor-preview) .tpl-hero .tpl-hero__desc { margin: 0; color: var(--ink-3); }

/* 头图 + 标题叠加 */
:is(.prose, .editor-preview) .tpl-heroov { position: relative; border-radius: 18px; overflow: hidden; }
:is(.prose, .editor-preview) .tpl-heroov .tpl-heroov__shade {
    position: absolute; inset: 0;
    background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.62) 100%);
}
:is(.prose, .editor-preview) .tpl-heroov img { border-radius: 0; }
:is(.prose, .editor-preview) .tpl-heroov .tpl-heroov__cap {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: 20px 22px 18px;
    color: #fff;
}
:is(.prose, .editor-preview) .tpl-heroov .tpl-heroov__cap strong { display: block; font-size: 1.35em; line-height: 1.3; }
:is(.prose, .editor-preview) .tpl-heroov .tpl-heroov__cap span { font-size: 0.9em; opacity: 0.85; }

/* 导读卡 */
:is(.prose, .editor-preview) .tpl-lead {
    padding: 16px 20px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 12px;
    background: var(--bg-elevated);
}
:is(.prose, .editor-preview) .tpl-lead .tpl-lead__tag {
    display: inline-block;
    margin: 0 0 6px;
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--accent);
}
:is(.prose, .editor-preview) .tpl-lead p { margin: 0; color: var(--ink-2); }

/* 引导语 */
:is(.prose, .editor-preview) .tpl-intro {
    padding-left: 14px;
    border-left: 3px solid var(--accent);
}
:is(.prose, .editor-preview) .tpl-intro p {
    margin: 0.2em 0;
    font-size: 1.12em;
    line-height: 1.8;
    color: var(--ink-2);
}

/* 日期标签行 */
:is(.prose, .editor-preview) .tpl-datetag {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 1.2em 0;
}
:is(.prose, .editor-preview) .tpl-datetag span {
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 0.82em;
    color: var(--ink-3);
    background: var(--hover-bg);
    border: 1px solid var(--line);
}
:is(.prose, .editor-preview) .tpl-datetag span:first-child {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: transparent;
    font-weight: 600;
}

/* ---------- 图文组合 ---------- */

/* 左图右文 / 右图左文（--rev 反转） */
:is(.prose, .editor-preview) .tpl-imgtext {
    display: flex;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
}
:is(.prose, .editor-preview) .tpl-imgtext.tpl-imgtext--rev { flex-direction: row-reverse; }
:is(.prose, .editor-preview) .tpl-imgtext .tpl-imgtext__img { flex: 0 1 42%; min-width: 220px; }
:is(.prose, .editor-preview) .tpl-imgtext .tpl-imgtext__body { flex: 1 1 260px; }
:is(.prose, .editor-preview) .tpl-imgtext .tpl-imgtext__title {
    margin: 0 0 6px;
    font-size: 1.18em;
    color: var(--ink);
}
:is(.prose, .editor-preview) .tpl-imgtext .tpl-imgtext__body p { color: var(--ink-2); }

/* 大图 + 图注 */
:is(.prose, .editor-preview) .tpl-figure { margin: 1.8em 0; }
:is(.prose, .editor-preview) .tpl-figure figcaption {
    margin-top: 10px;
    text-align: center;
    font-size: 0.88em;
    color: var(--ink-3);
}

/* 双图对比 */
:is(.prose, .editor-preview) .tpl-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 640px) {
    :is(.prose, .editor-preview) .tpl-compare { grid-template-columns: 1fr; }
}
:is(.prose, .editor-preview) .tpl-compare figure { margin: 0; }
:is(.prose, .editor-preview) .tpl-compare figcaption {
    margin-top: 8px;
    text-align: center;
    font-size: 0.88em;
    font-weight: 600;
    color: var(--ink-2);
}
:is(.prose, .editor-preview) .tpl-compare .is-after figcaption { color: var(--accent); }

/* 三图画廊 / 四宫格 */
:is(.prose, .editor-preview) .tpl-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
:is(.prose, .editor-preview) .tpl-grid4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
:is(.prose, .editor-preview) .tpl-gallery figure,
:is(.prose, .editor-preview) .tpl-grid4 figure { margin: 0; }
:is(.prose, .editor-preview) .tpl-gallery img,
:is(.prose, .editor-preview) .tpl-grid4 img { height: 100%; object-fit: cover; aspect-ratio: 4 / 3; }

/* 通栏图 */
:is(.prose, .editor-preview) .tpl-banner { margin: 2em -8px; }
@media (min-width: 1200px) {
    :is(.prose, .editor-preview) .tpl-banner { margin-inline: -32px; }
}
:is(.prose, .editor-preview) .tpl-banner img { border-radius: 16px; }

/* 图注卡片 */
:is(.prose, .editor-preview) .tpl-imgcard {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--bg-card);
}
:is(.prose, .editor-preview) .tpl-imgcard figcaption {
    margin-top: 10px;
    padding: 0 6px 4px;
    font-size: 0.9em;
    color: var(--ink-3);
}

/* ---------- 强调 ---------- */

/* 金句 */
:is(.prose, .editor-preview) .tpl-quote {
    padding: 26px 30px;
    text-align: center;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
:is(.prose, .editor-preview) .tpl-quote p {
    margin: 0;
    font-size: 1.3em;
    line-height: 1.7;
    font-weight: 600;
    color: var(--ink);
}
:is(.prose, .editor-preview) .tpl-quote .tpl-quote__from {
    margin-top: 10px;
    font-size: 0.85em;
    font-weight: 400;
    color: var(--ink-3);
}

/* 提示框（四色） */
:is(.prose, .editor-preview) .tpl-note {
    padding: 14px 18px;
    border-radius: 12px;
    border-left: 3px solid;
    background: var(--hover-bg);
}
:is(.prose, .editor-preview) .tpl-note .tpl-note__title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 4px;
    font-size: 0.95em;
    font-weight: 700;
}
:is(.prose, .editor-preview) .tpl-note p { margin: 0.2em 0; color: var(--ink-2); }
:is(.prose, .editor-preview) .tpl-note--info { border-color: #3b82f6; background: color-mix(in srgb, #3b82f6 10%, transparent); }
:is(.prose, .editor-preview) .tpl-note--info .tpl-note__title { color: #60a5fa; }
:is(.prose, .editor-preview) .tpl-note--success { border-color: #10b981; background: color-mix(in srgb, #10b981 10%, transparent); }
:is(.prose, .editor-preview) .tpl-note--success .tpl-note__title { color: #34d399; }
:is(.prose, .editor-preview) .tpl-note--warn { border-color: #f59e0b; background: color-mix(in srgb, #f59e0b 12%, transparent); }
:is(.prose, .editor-preview) .tpl-note--warn .tpl-note__title { color: #fbbf24; }
:is(.prose, .editor-preview) .tpl-note--danger { border-color: #ef4444; background: color-mix(in srgb, #ef4444 10%, transparent); }
:is(.prose, .editor-preview) .tpl-note--danger .tpl-note__title { color: #f87171; }

/* 要点总结 */
:is(.prose, .editor-preview) .tpl-summary {
    padding: 18px 22px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--bg-elevated);
}
:is(.prose, .editor-preview) .tpl-summary .tpl-summary__title {
    margin: 0 0 10px;
    font-size: 1.05em;
    color: var(--ink);
}
:is(.prose, .editor-preview) .tpl-summary li { margin: 0.5em 0; color: var(--ink-2); }
:is(.prose, .editor-preview) .tpl-summary li::marker { color: var(--accent); }

/* 数据卡片 */
:is(.prose, .editor-preview) .tpl-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
}
:is(.prose, .editor-preview) .tpl-stats .tpl-stats__item {
    padding: 16px 14px;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--bg-card);
}
:is(.prose, .editor-preview) .tpl-stats strong {
    display: block;
    font-size: 1.55em;
    line-height: 1.2;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}
:is(.prose, .editor-preview) .tpl-stats span { font-size: 0.85em; color: var(--ink-3); }

/* ---------- 结构 ---------- */

/* 分节序号头 */
:is(.prose, .editor-preview) .tpl-part {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 2.4em 0 1.2em;
}
:is(.prose, .editor-preview) .tpl-part .tpl-part__no {
    font-size: 2em;
    font-weight: 800;
    line-height: 1;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}
:is(.prose, .editor-preview) .tpl-part .tpl-part__bar { width: 1px; height: 38px; background: var(--line-strong); }
:is(.prose, .editor-preview) .tpl-part strong { display: block; font-size: 1.2em; color: var(--ink); }
:is(.prose, .editor-preview) .tpl-part span { font-size: 0.85em; color: var(--ink-3); }

/* 步骤流 */
:is(.prose, .editor-preview) .tpl-steps { counter-reset: tplstep; list-style: none; padding-left: 0; }
:is(.prose, .editor-preview) .tpl-steps li {
    counter-increment: tplstep;
    position: relative;
    margin: 0 0 14px;
    padding: 14px 18px 14px 58px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg-card);
    list-style: none;
}
:is(.prose, .editor-preview) .tpl-steps li::before {
    content: counter(tplstep);
    position: absolute;
    left: 16px;
    top: 14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
}
:is(.prose, .editor-preview) .tpl-steps strong { display: block; margin-bottom: 2px; color: var(--ink); }
:is(.prose, .editor-preview) .tpl-steps p { margin: 0; color: var(--ink-2); }

/* 时间线 */
:is(.prose, .editor-preview) .tpl-timeline { list-style: none; padding-left: 0; margin: 1.6em 0; }
:is(.prose, .editor-preview) .tpl-timeline li {
    position: relative;
    margin: 0 0 18px;
    padding: 0 0 0 26px;
    list-style: none;
    border-left: 2px solid var(--line);
}
:is(.prose, .editor-preview) .tpl-timeline li::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
:is(.prose, .editor-preview) .tpl-timeline time { font-size: 0.85em; color: var(--accent); font-weight: 600; }
:is(.prose, .editor-preview) .tpl-timeline strong { display: block; color: var(--ink); }
:is(.prose, .editor-preview) .tpl-timeline p { margin: 0.15em 0 0; color: var(--ink-2); }

/* FAQ 折叠 */
:is(.prose, .editor-preview) .tpl-faq { margin: 1.4em 0; }
:is(.prose, .editor-preview) .tpl-faq details {
    margin: 0 0 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg-card);
    overflow: hidden;
}
:is(.prose, .editor-preview) .tpl-faq summary {
    padding: 13px 18px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
}
:is(.prose, .editor-preview) .tpl-faq summary::marker { color: var(--accent); }
:is(.prose, .editor-preview) .tpl-faq .tpl-faq__a { padding: 0 18px 14px; color: var(--ink-2); }
:is(.prose, .editor-preview) .tpl-faq .tpl-faq__a p { margin: 0; }

/* 目录卡 */
:is(.prose, .editor-preview) .tpl-toc {
    padding: 16px 22px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--bg-elevated);
}
:is(.prose, .editor-preview) .tpl-toc .tpl-toc__title {
    margin: 0 0 8px;
    font-size: 0.85em;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--ink-3);
}
:is(.prose, .editor-preview) .tpl-toc ol { margin: 0; }
:is(.prose, .editor-preview) .tpl-toc li { margin: 0.35em 0; }
:is(.prose, .editor-preview) .tpl-toc a { color: var(--ink-2); text-decoration: none; }
:is(.prose, .editor-preview) .tpl-toc a:hover { color: var(--accent); }

/* 对话气泡 */
:is(.prose, .editor-preview) .tpl-dialog { display: flex; flex-direction: column; gap: 12px; }
:is(.prose, .editor-preview) .tpl-dialog .tpl-dialog__row { display: flex; gap: 10px; }
:is(.prose, .editor-preview) .tpl-dialog .tpl-dialog__row--me { flex-direction: row-reverse; }
:is(.prose, .editor-preview) .tpl-dialog .tpl-dialog__name {
    flex: 0 0 auto;
    align-self: flex-end;
    font-size: 0.8em;
    color: var(--ink-3);
}
:is(.prose, .editor-preview) .tpl-dialog .tpl-dialog__bubble {
    max-width: 78%;
    padding: 10px 16px;
    border-radius: 14px;
    background: var(--hover-bg);
    border: 1px solid var(--line);
    color: var(--ink-2);
}
:is(.prose, .editor-preview) .tpl-dialog .tpl-dialog__row--me .tpl-dialog__bubble {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--ink);
}

/* 更新日志条 */
:is(.prose, .editor-preview) .tpl-changelog {
    display: flex;
    gap: 12px;
    align-items: baseline;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg-card);
}
:is(.prose, .editor-preview) .tpl-changelog .tpl-changelog__ver {
    flex: 0 0 auto;
    font-weight: 700;
    font-size: 0.88em;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}
:is(.prose, .editor-preview) .tpl-changelog p { margin: 0; color: var(--ink-2); }

/* ---------- 结尾 ---------- */

/* 行动召唤 CTA */
:is(.prose, .editor-preview) .tpl-cta {
    padding: 24px 26px;
    text-align: center;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--bg-card);
    border: 1px solid var(--line);
}
:is(.prose, .editor-preview) .tpl-cta strong { display: block; font-size: 1.25em; color: var(--ink); }
:is(.prose, .editor-preview) .tpl-cta p { color: var(--ink-3); }
:is(.prose, .editor-preview) .tpl-cta .tpl-cta__btn {
    display: inline-block;
    margin-top: 10px;
    padding: 9px 26px;
    border-radius: 999px;
    font-weight: 600;
    text-decoration: none;
    color: var(--btn-invert-fg);
    background: var(--btn-invert-bg);
}
:is(.prose, .editor-preview) .tpl-cta .tpl-cta__btn:hover { opacity: 0.88; }

/* 结束分隔 */
:is(.prose, .editor-preview) .tpl-end {
    text-align: center;
    margin: 2.4em 0;
    color: var(--ink-4);
    letter-spacing: 6px;
}
:is(.prose, .editor-preview) .tpl-end p { margin: 0.3em 0; font-size: 0.9em; }

/* 往期推荐 */
:is(.prose, .editor-preview) .tpl-prev { display: flex; flex-direction: column; gap: 10px; }
:is(.prose, .editor-preview) .tpl-prev a {
    display: block;
    padding: 12px 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    text-decoration: none;
    background: var(--bg-card);
    color: var(--ink);
}
:is(.prose, .editor-preview) .tpl-prev a:hover { border-color: var(--accent); }
:is(.prose, .editor-preview) .tpl-prev a strong { display: block; font-size: 1em; }
:is(.prose, .editor-preview) .tpl-prev a span { font-size: 0.85em; color: var(--ink-3); }

/* 标签收尾 */
:is(.prose, .editor-preview) .tpl-tags { display: flex; flex-wrap: wrap; gap: 8px; }
:is(.prose, .editor-preview) .tpl-tags span {
    padding: 4px 14px;
    border-radius: 999px;
    font-size: 0.85em;
    color: var(--ink-2);
    background: var(--tag-bg);
    border: 1px solid var(--line);
}

/* 署名卡 */
:is(.prose, .editor-preview) .tpl-sign {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 16px 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--bg-card);
}
:is(.prose, .editor-preview) .tpl-sign img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
}
:is(.prose, .editor-preview) .tpl-sign strong { display: block; color: var(--ink); }
:is(.prose, .editor-preview) .tpl-sign span { font-size: 0.88em; color: var(--ink-3); }
