/* 帮助文档与 Markdown 渲染渲染样式 (Markdown Docs View & Markdown Render Styles) */

/* ==========================================================================
   1. Markdown 视图大纲与骨架布局 (Markdown View Layout Framework)
   ========================================================================== */

/* 外层视图：固定高度、内部纵向 flex，阅读区独立滚动（根治覆盖 bug） */
.markdown-docs-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: calc(100vh - var(--top-bar-height) - 24px);
    height: calc(100dvh - var(--top-bar-height) - 24px); /* 移动端动态视口：与 .app 的 100dvh 保持一致 */
    min-height: 0;
    overflow: hidden;
}

/* Hero 卡与目录条固定不压缩，剩余空间全部交给阅读区滚动 */
.markdown-docs-view .notifications-hero-card {
    flex-shrink: 0;
}

/* 视图大标题布局栈 */
.markdown-docs-view .notifications-title-stack {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.markdown-docs-view .markdown-docs-sidebar-title {
    font-weight: 700 !important;
}

.markdown-docs-view .markdown-docs-article-title {
    font-weight: 800 !important;
    margin-bottom: 4px !important;
}

/* ==========================================================================
   2. 顶部固定横向文档目录条 (Top Fixed Horizontal TOC Bar)
   ========================================================================== */

/* 主工作区：包裹「目录条 + 阅读区」的纵向 flex 容器。
   目录条固定（不滚动），阅读区占满剩余高度并独立滚动，
   彻底避免目录条覆盖阅读区的问题 */
.markdown-docs-layout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 9px; /* 目录条与阅读区间距（减半） */
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
}

/* 目录条外壳：固定在布局顶部，不参与滚动 */
.markdown-docs-toc {
    flex-shrink: 0;
    z-index: 5;
}

/* 目录条内层卡片：毛玻璃视觉，内容完全渲染在阅读区之上方 */
.markdown-docs-toc-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 18px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

body.dark-theme .markdown-docs-toc-inner {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* 文档列表区域：始终渲染，通过 max-height + opacity 过渡实现平滑收起/展开。
   收起时高度归零并淡出，展开时恢复完整高度 */
.markdown-docs-toc-body {
    max-height: 260px;
    overflow: hidden;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition:
        max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.24s ease-out,
        visibility 0.32s linear,
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.markdown-docs-toc.is-collapsed .markdown-docs-toc-body {
    max-height: 0;
    opacity: 0;
    visibility: hidden; /* 移出无障碍树与 Tab 序列，避免键盘聚焦到不可见目录项 */
    transform: translateY(-6px);
}

/* 收起时内层卡片的内边距同步收敛，目录条仅保留一行标题的高度 */
.markdown-docs-toc.is-collapsed .markdown-docs-toc-inner {
    gap: 0;
    padding-top: 10px;
    padding-bottom: 10px;
}

/* 目录头部：标题与展开/收起按钮一行排布 */
.markdown-docs-toc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.markdown-docs-toc-head-text {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

.markdown-docs-toc-subtitle {
    opacity: 0.72;
    font-size: 12px !important;
}

/* 展开/收起切换按钮 */
.markdown-docs-toc-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid rgba(103, 80, 164, 0.18);
    background: rgba(103, 80, 164, 0.08);
    color: var(--md-sys-color-primary);
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.18s ease-out, border-color 0.18s ease-out, transform 0.18s ease-out;
}

.markdown-docs-toc-toggle:hover {
    background: rgba(103, 80, 164, 0.16);
    border-color: rgba(103, 80, 164, 0.3);
    transform: translateY(-1px);
}

.markdown-docs-toc-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    /* 箭头方向由 JSX 中的字符（▸/▾）直接表达，不再叠加 CSS 旋转，避免状态不一致 */
}

/* 横向文档列表容器：溢出时横向滚动 */
.markdown-docs-toc-list {
    display: flex;
    align-items: stretch;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 6px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.markdown-docs-toc-list::-webkit-scrollbar {
    height: 6px;
}

/* 单个横向文档项 */
.markdown-docs-toc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    max-width: 300px;
    min-width: 180px;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid rgba(103, 80, 164, 0.12);
    background: rgba(255, 255, 255, 0.56);
    color: var(--md-sys-color-on-surface);
    text-align: left;
    cursor: pointer;
    transition: background-color 0.18s ease-out, border-color 0.18s ease-out, transform 0.18s ease-out, box-shadow 0.18s ease-out;
}

body.dark-theme .markdown-docs-toc-item {
    background: rgba(32, 29, 39, 0.86);
    border-color: rgba(208, 188, 255, 0.12);
}

.markdown-docs-toc-item:hover {
    background: rgba(103, 80, 164, 0.08);
    border-color: rgba(103, 80, 164, 0.24);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(103, 80, 164, 0.08);
}

/* 激活的文档项 */
.markdown-docs-toc-item.is-active {
    background: var(--md-sys-color-primary-container);
    border-color: rgba(103, 80, 164, 0.28);
    color: var(--md-sys-color-on-primary-container);
}

body.dark-theme .markdown-docs-toc-item.is-active {
    background: linear-gradient(135deg, rgba(103, 80, 164, 0.94), rgba(79, 55, 139, 0.94));
    border-color: rgba(208, 188, 255, 0.32);
    color: #F4EEFF;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}

.markdown-docs-toc-item-icon {
    flex-shrink: 0;
}

.markdown-docs-toc-item-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.markdown-docs-toc-item-title {
    font-size: 13px;
    font-weight: 800;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.markdown-docs-toc-item-path {
    opacity: 0.72;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}

.markdown-docs-toc-item.is-active .markdown-docs-toc-item-path {
    opacity: 0.82;
}

/* 目录条加载 / 空状态 */
.markdown-docs-toc-loading,
.markdown-docs-toc-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 0 6px;
}

.markdown-docs-toc-empty-icon {
    font-size: 18px;
}

/* ==========================================================================
   3. 全宽文档阅读区 (Full-Width Document Reader)
   ========================================================================== */
/* 阅读区列容器：占据布局剩余高度，内部独立滚动（根治覆盖 bug） */
.markdown-docs-content-column {
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.markdown-docs-content-column--full {
    width: 100%;
}

/* 阅读卡片：占满列容器高度。
   卡片自身不滚动（视觉面 ::before 背景完整覆盖整个卡片区域），
   滚动发生在内部 .markdown-docs-content-scroll 容器中，
   从而避免 .card::before 绝对定位背景只覆盖可视区域、
   滚动出的内容暴露在透明背景上的问题 */
/* 卡片仅含单一滚动容器子元素，flex gap 无实际间距效果（gap 已由内部滚动容器
   的 flex:1 撑满承担），保留 display:flex 以维持列方向布局 */
.markdown-docs-content-card {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* 卡片内部独立滚动容器：承载全部阅读内容并滚动 */
.markdown-docs-content-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

/* 文章头部区域 */
.markdown-docs-article-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--glass-border);
}

.markdown-docs-article-head .MuiTypography-h5 {
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.markdown-docs-article-path,
.markdown-docs-article-head .mono {
    opacity: 0.72;
    font-size: 12px;
    line-height: 1.35;
}

/* ==========================================================================
   5. Markdown 正文排版与渲染规范 (Markdown Typography Core Styles)
   ========================================================================== */
.markdown-docs-article {
    min-height: 380px;
}

/* 针对非富文本渲染下的普通文本段落展示（支持换行符） */
.markdown-docs-article--plain {
    white-space: pre-wrap;
    line-height: 1.85 !important;
}

.markdown-docs-article.notification-md {
    font-family: 'Outfit', "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Heiti SC", "WenQuanYi Micro Hei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 400;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.notification-md {
    color: var(--md-sys-color-on-surface);
    line-height: 1.82;
    font-size: 0.97rem;
    word-break: break-word;
}

.notification-md > :first-child {
    margin-top: 0;
}

.notification-md > :last-child {
    margin-bottom: 0;
}

/* 正文段落及各块级元素的底部边界空白设定 */
.notification-md p,
.notification-md ul,
.notification-md ol,
.notification-md blockquote,
.notification-md pre,
.notification-md .notification-md-table-wrap,
.notification-md .notification-md-details,
.notification-md .notification-md-mermaid-block {
    margin: 0 0 0.95rem;
}

/* 各级标题样式 */
.notification-md h1,
.notification-md h2,
.notification-md h3,
.notification-md h4,
.notification-md h5,
.notification-md h6 {
    margin: 1.2rem 0 0.72rem;
    color: var(--md-sys-color-on-surface);
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.32;
}

.notification-md h1 {
    font-size: 1.32rem;
    padding-bottom: 0.46rem;
    border-bottom: 1px solid rgba(103, 80, 164, 0.16);
}

.notification-md h2 {
    font-size: 1.18rem;
    padding-left: 0.72rem;
    border-left: 4px solid var(--md-sys-color-primary);
}

.notification-md h3 {
    font-size: 1.05rem;
    color: var(--md-sys-color-primary);
}

.notification-md h4,
.notification-md h5,
.notification-md h6 {
    font-size: 0.98rem;
}

.notification-md p {
    color: var(--md-sys-color-on-surface);
}

.notification-md strong {
    color: var(--md-sys-color-on-surface);
    font-weight: 800;
}

.notification-md em,
.notification-md del {
    color: var(--md-sys-color-on-surface-variant);
}

/* 正文超链接 */
.notification-md a {
    color: var(--md-sys-color-primary);
    text-decoration: none;
    font-weight: 700;
    border-bottom: 1px solid rgba(103, 80, 164, 0.22);
    transition:
        color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification-md a:hover {
    opacity: 0.88;
    border-bottom-color: rgba(103, 80, 164, 0.42);
}

/* 列表缩进 */
.notification-md ul,
.notification-md ol {
    padding-left: 1.35rem;
}

.notification-md li + li {
    margin-top: 0.34rem;
}

.notification-md li::marker {
    color: var(--md-sys-color-primary);
    font-weight: 700;
}

/* 分割线背景渐变 */
.notification-md hr {
    border: 0;
    height: 1px;
    margin: 1rem 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(103, 80, 164, 0.24),
        transparent
    );
}

/* 引用块 (Blockquotes) */
.notification-md blockquote {
    margin-left: 0;
    margin-right: 0;
    padding: 0.9rem 1rem;
    border-left: 4px solid var(--md-sys-color-primary);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    background: linear-gradient(135deg, rgba(103, 80, 164, 0.12), rgba(103, 80, 164, 0.05));
    color: var(--md-sys-color-on-surface);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.notification-md blockquote p {
    margin: 0;
}

/* ==========================================================================
   6. Markdown 警示呼叫盒组件 (Markdown Callouts/Admonitions)
   ========================================================================== */
.notification-md .notification-md-callout {
    position: relative;
    padding: 1rem 1.1rem 1rem 1.15rem;
    border-left-width: 5px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    background: linear-gradient(135deg, rgba(103, 80, 164, 0.08), rgba(103, 80, 164, 0.03));
}

.notification-md .notification-md-callout-header {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.72rem;
    font-weight: 800;
    line-height: 1.2;
}

.notification-md .notification-md-callout-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.2rem;
    font-size: 0.95rem;
}

.notification-md .notification-md-callout-title {
    font-size: 1rem;
    letter-spacing: -0.01em;
}

/* Admonition - Note 提示蓝色 */
.notification-md .notification-md-callout.is-note {
    border-left-color: #2563EB;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(37, 99, 235, 0.04));
}

.notification-md .notification-md-callout.is-note .notification-md-callout-header {
    color: #2563EB;
}

/* Admonition - Tip 建议绿色 */
.notification-md .notification-md-callout.is-tip {
    border-left-color: #0F9D58;
    background: linear-gradient(135deg, rgba(15, 157, 88, 0.12), rgba(15, 157, 88, 0.04));
}

.notification-md .notification-md-callout.is-tip .notification-md-callout-header {
    color: #0F9D58;
}

/* Admonition - Important 重点紫色 */
.notification-md .notification-md-callout.is-important {
    border-left-color: #7C3AED;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.14), rgba(124, 58, 237, 0.05));
}

.notification-md .notification-md-callout.is-important .notification-md-callout-header {
    color: #7C3AED;
}

/* Admonition - Warning 警告橙色 */
.notification-md .notification-md-callout.is-warning {
    border-left-color: #D97706;
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.14), rgba(217, 119, 6, 0.05));
}

.notification-md .notification-md-callout.is-warning .notification-md-callout-header {
    color: #D97706;
}

/* Admonition - Caution 危险红色 */
.notification-md .notification-md-callout.is-caution {
    border-left-color: #DC2626;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.14), rgba(220, 38, 38, 0.05));
}

.notification-md .notification-md-callout.is-caution .notification-md-callout-header {
    color: #DC2626;
}

.notification-md .notification-md-callout > :last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   7. 行内代码与多行代码高亮渲染 (Code Block & Code Highlights)
   ========================================================================== */

/* 行内小代码标签 `code` */
.notification-md :not(pre) > code {
    display: inline-block;
    padding: 0.14rem 0.48rem;
    margin: 0 0.1rem;
    border-radius: 999px;
    border: 1px solid rgba(103, 80, 164, 0.16);
    background: rgba(103, 80, 164, 0.10);
    color: var(--md-sys-color-primary);
    font-family: "Consolas", "SFMono-Regular", monospace;
    font-size: 0.9em;
    font-weight: 700;
    line-height: 1.45;
}

/* 代码高亮块及画板 Mermaid 容器：明暗双主题 VSCode 风格终端底 + 红绿灯标题栏 */
.notification-md-code-block,
.notification-md-mermaid-block {
    margin: 0 0 0.95rem;
    overflow: hidden;
    border-radius: 14px;
    border: 1px solid rgba(103, 80, 164, 0.18);
    background: #faf8f5;
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.10),
        inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

/* 代码头部状态栏（红绿灯 + 语言徽章） */
.notification-md-code-header {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 0 14px;
    border-bottom: 1px solid rgba(103, 80, 164, 0.10);
    background: linear-gradient(180deg, #f0ede8, #e9e5df);
}

/* ===== 暗色主题：代码块切换为 VSCode Dark 终端底，与 Dark Modern token 协调 =====
   统一使用 html.theme-dark 选择器（首屏预挂载，见 index.html 主题拦截器）。
   body.dark-theme 的历史规则见文末，保持值一致，避免级联顺序导致跳变。 */
html.theme-dark .notification-md-code-block,
html.theme-dark .notification-md-mermaid-block {
    border-color: rgba(255, 255, 255, 0.10);
    background: #1e1e1e;
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html.theme-dark .notification-md-code-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, #2d2d30, #252526);
}

html.theme-dark .notification-md-code-lang {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--md-sys-color-primary);
}

html.theme-dark .notification-md pre {
    background: #1e1e1e;
    scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

html.theme-dark .notification-md-traffic-light {
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

html.theme-dark .notification-md pre code {
    color: #D4D4D4; /* VSCode Dark Modern 默认前景色 */
}

/* 红绿灯圆点组（经典 macOS 风格） */
.notification-md-code-traffic-lights {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    line-height: 0;
}

.notification-md-traffic-light {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(0, 0, 0, 0.10);
    transition: filter 0.18s ease-out, transform 0.18s ease-out;
}

.notification-md-traffic-light.is-red { background: #FF5F56; }
.notification-md-traffic-light.is-yellow { background: #FFBD2E; }
.notification-md-traffic-light.is-green { background: #27C93F; }

.notification-md-code-header:hover .notification-md-traffic-light {
    filter: brightness(1.15);
}

/* 代码块语言提示标 (如 "JSON", "PYTHON") */
.notification-md-code-lang {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    margin-left: auto;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(103, 80, 164, 0.14);
    color: var(--md-sys-color-primary);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.notification-md pre {
    overflow-x: auto;
    margin: 0;
    padding: 1rem 1.05rem 1.05rem;
    border: none;
    border-radius: 0 0 14px 14px;
    background: #faf8f5;
    box-shadow: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(103, 80, 164, 0.28) transparent;
}

.notification-md pre code {
    display: block;
    min-width: max-content;
    color: var(--md-sys-color-on-surface);
    font-family: "Consolas", "SFMono-Regular", monospace;
    font-size: 0.92rem;
    line-height: 1.72;
    background: transparent;
}

.notification-md pre code .token {
    font-weight: 400; /* 恢复常规字重，避免 token 全局加粗干扰 Dark Modern 的细腻观感 */
}

/* ===== VSCode Dark Modern 语法高亮配色（暗色主题使用，与 VSCode Dark+ 对齐） ===== */
.notification-md .token-comment  { color: #6A9955; font-style: italic; }
.notification-md .token-keyword  { color: #569CD6; }
.notification-md .token-control  { color: #569CD6; }
.notification-md .token-string   { color: #CE9178; }
.notification-md .token-number   { color: #B5CEA8; }
.notification-md .token-boolean  { color: #569CD6; }
.notification-md .token-function { color: #DCDCAA; }
.notification-md .token-class    { color: #4EC9B0; }
.notification-md .token-type     { color: #4EC9B0; }
.notification-md .token-property { color: #9CDCFE; }
.notification-md .token-key      { color: #9CDCFE; }
.notification-md .token-variable { color: #9CDCFE; }
.notification-md .token-parameter{ color: #9CDCFE; }
.notification-md .token-builtin  { color: #4EC9B0; }
.notification-md .token-constant { color: #4FC1FF; }
.notification-md .token-regex    { color: #D16969; }
.notification-md .token-decorator{ color: #DCDCAA; }
.notification-md .token-atrule   { color: #C586C0; }
.notification-md .token-selector { color: #D7BA7D; }
.notification-md .token-tag      { color: #569CD6; }
.notification-md .token-attribute{ color: #9CDCFE; }
.notification-md .token-punctuation { color: #D4D4D4; }
.notification-md .token-operator { color: #D4D4D4; }
.notification-md .token-command  { color: #DCDCAA; }
.notification-md .token-flag     { color: #C586C0; }
.notification-md .token-unit     { color: #B5CEA8; }
.notification-md .token-cdata    { color: #D4D4D4; }
.notification-md .token-import   { color: #9CDCFE; }
.notification-md .token-value    { color: #9CDCFE; }

/* ===== VSCode Light Modern 语法高亮配色（亮色主题覆盖，与 VSCode Light+ 对齐） =====
   亮色下代码块底色为米白 #faf8f5，token 统一切换为深色系保证对比度与可读性。
   使用 html:not(.theme-dark) 选择器：默认即亮色，即使 data-theme 尚未挂载也生效，避免首屏闪烁。 */
html:not(.theme-dark) .notification-md .token-comment  { color: #008000; font-style: italic; }
html:not(.theme-dark) .notification-md .token-keyword  { color: #0000FF; }
html:not(.theme-dark) .notification-md .token-control  { color: #0000FF; }
html:not(.theme-dark) .notification-md .token-string   { color: #A31515; }
html:not(.theme-dark) .notification-md .token-number   { color: #098658; }
html:not(.theme-dark) .notification-md .token-boolean  { color: #0000FF; }
html:not(.theme-dark) .notification-md .token-function { color: #795E26; }
html:not(.theme-dark) .notification-md .token-class    { color: #267F99; }
html:not(.theme-dark) .notification-md .token-type     { color: #267F99; }
html:not(.theme-dark) .notification-md .token-property { color: #001080; }
html:not(.theme-dark) .notification-md .token-key      { color: #001080; }
html:not(.theme-dark) .notification-md .token-variable { color: #001080; }
html:not(.theme-dark) .notification-md .token-parameter{ color: #001080; }
html:not(.theme-dark) .notification-md .token-builtin  { color: #267F99; }
html:not(.theme-dark) .notification-md .token-constant { color: #0451A5; }
html:not(.theme-dark) .notification-md .token-regex    { color: #811F3F; }
html:not(.theme-dark) .notification-md .token-decorator{ color: #795E26; }
html:not(.theme-dark) .notification-md .token-atrule   { color: #AF00DB; }
html:not(.theme-dark) .notification-md .token-selector { color: #800000; }
html:not(.theme-dark) .notification-md .token-tag      { color: #800000; }
html:not(.theme-dark) .notification-md .token-attribute{ color: #001080; }
html:not(.theme-dark) .notification-md .token-punctuation { color: #383A42; }
html:not(.theme-dark) .notification-md .token-operator { color: #383A42; }
html:not(.theme-dark) .notification-md .token-command  { color: #795E26; }
html:not(.theme-dark) .notification-md .token-flag     { color: #AF00DB; }
html:not(.theme-dark) .notification-md .token-unit     { color: #098658; }
html:not(.theme-dark) .notification-md .token-cdata    { color: #383A42; }
html:not(.theme-dark) .notification-md .token-import   { color: #001080; }
html:not(.theme-dark) .notification-md .token-value    { color: #001080; }

/* ==========================================================================
   8. Markdown 表格渲染及列宽定制 (Markdown Tables Layout)
   ========================================================================== */
.notification-md .notification-md-table-wrap {
    overflow-x: auto;
    border-radius: 16px;
    border: 1px solid rgba(103, 80, 164, 0.12);
    background: rgba(255, 255, 255, 0.34);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.notification-md table {
    width: 100%;
    min-width: 420px;
    border-collapse: collapse;
}

.notification-md th,
.notification-md td {
    padding: 0.72rem 0.85rem;
    border-bottom: 1px solid rgba(103, 80, 164, 0.10);
    vertical-align: top;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.notification-md th {
    background: rgba(103, 80, 164, 0.10);
    color: var(--md-sys-color-primary);
    text-align: left;
}

.notification-md td {
    color: var(--md-sys-color-on-surface);
}

/* 专门针对插件“指令别名”表格的特制等分及对齐格式 */
.notification-md table.notification-md-command-alias-table {
    table-layout: fixed;
}

.notification-md table.notification-md-command-alias-table th:nth-child(1),
.notification-md table.notification-md-command-alias-table td:nth-child(1) {
    width: 58%; /* 指令说明 */
}

.notification-md table.notification-md-command-alias-table th:nth-child(2),
.notification-md table.notification-md-command-alias-table td:nth-child(2) {
    width: 14%; /* 权限级别 */
    text-align: center;
}

.notification-md table.notification-md-command-alias-table th:nth-child(3),
.notification-md table.notification-md-command-alias-table td:nth-child(3) {
    width: 28%; /* 默认别名 */
}

.notification-md table.notification-md-command-alias-table td:nth-child(1) code {
    white-space: normal;
    line-height: 1.55;
}

.notification-md table.notification-md-command-alias-table td:nth-child(2) code {
    white-space: nowrap;
    line-height: 1.55;
}

.notification-md tr:last-child td {
    border-bottom: none;
}

/* 空白占位卡片 */
.markdown-docs-empty-card {
    min-height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.markdown-docs-empty-title {
    font-weight: 700 !important;
    margin-bottom: 8px !important;
}

/* ==========================================================================
   9. HTML 折叠折叠盒组件 (Markdown Details Expanders)
   ========================================================================== */
.notification-md .notification-md-details {
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid rgba(103, 80, 164, 0.16);
    background: linear-gradient(180deg, rgba(103, 80, 164, 0.08), rgba(103, 80, 164, 0.03));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.notification-md .notification-md-summary {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.88rem 1rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
    font-weight: 800;
    color: var(--md-sys-color-on-surface);
}

.notification-md .notification-md-summary::-webkit-details-marker {
    display: none;
}

/* 折叠盒自带旋转小箭头 */
.notification-md .notification-md-summary::before {
    content: '▸';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-primary);
    font-size: 0.92rem;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification-md .notification-md-details[open] > .notification-md-summary::before {
    transform: rotate(90deg); /* 打开时箭头顺时针转90度指向正下方 */
}

.notification-md .notification-md-details > :not(summary) {
    margin-left: 1rem;
    margin-right: 1rem;
}

.notification-md .notification-md-details > :not(summary):last-child {
    margin-bottom: 1rem;
}

.notification-md .notification-md-details > .notification-md-summary + * {
    margin-top: 0.1rem;
}

/* ==========================================================================
   10. Mermaid 流程图/拓扑图平移缩放渲染器 (Mermaid SVG Pan/Zoom Viewport)
   ========================================================================== */
.notification-md-mermaid {
    overflow: hidden;
    padding: 1rem;
    background:
        radial-gradient(circle at top right, rgba(103, 80, 164, 0.08), transparent 34%),
        linear-gradient(180deg, rgba(248, 245, 255, 0.96), rgba(241, 236, 251, 0.96));
    text-align: center;
}

/* 拓扑图顶部操纵按钮工具栏 (包含重置缩放、放大、缩小、还原) */
.notification-md-mermaid-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.7rem 0.9rem 0;
}

.notification-md-mermaid-tool-btn {
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.65rem;
    border: 1px solid rgba(103, 80, 164, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--md-sys-color-primary);
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    transition:
        background-color 0.18s ease-out,
        border-color 0.18s ease-out,
        color 0.18s ease-out,
        transform 0.18s ease-out;
}

.notification-md-mermaid-tool-btn:hover {
    background: rgba(103, 80, 164, 0.12);
    border-color: rgba(103, 80, 164, 0.24);
    transform: translateY(-1px);
}

/* 图表画布视口，拦截移动触控事件实现手势缩放 */
.notification-md-mermaid-viewport {
    position: relative;
    overflow: hidden;
    width: 100%;
    min-height: 240px;
    border-radius: 14px;
    cursor: default;
    touch-action: none; /* 禁用系统自带的多指缩放手势，完全由JS接管 */
}

/* 此时处于可平移拖动状态 */
.notification-md-mermaid-viewport.is-pannable {
    cursor: grab;
}

.notification-md-mermaid-viewport.is-dragging {
    cursor: grabbing;
}

/* 承载缩放平移变形矩阵的主画布，开启硬件加速 */
.notification-md-mermaid-canvas {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100%;
    min-height: 240px;
    transform-origin: center center;
    will-change: transform;
}

.notification-md-mermaid svg {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    user-select: none;
    pointer-events: none; /* 彻底移除SVG标签自身的鼠标事件响应，避免拦截平移 */
}

/* 画布报错信息展示（代码错误时） */
.notification-md-mermaid.is-error {
    text-align: left;
    color: #B3261E;
    white-space: pre-wrap;
    font-family: "Consolas", "SFMono-Regular", monospace;
    font-size: 0.9rem;
    line-height: 1.7;
}

/* ==========================================================================
   11. 深色模式适配 (Dark Theme Adaptive Override)
   ========================================================================== */
body.dark-theme .notification-md h1 {
    border-bottom-color: rgba(208, 188, 255, 0.18);
}

body.dark-theme .notification-md h3,
body.dark-theme .notification-md a,
body.dark-theme .notification-md :not(pre) > code {
    color: var(--md-sys-color-primary);
}

body.dark-theme .notification-md a {
    border-bottom-color: rgba(208, 188, 255, 0.26);
}

body.dark-theme .notification-md a:hover {
    border-bottom-color: rgba(208, 188, 255, 0.42);
}

body.dark-theme .notification-md hr {
    background: linear-gradient(
        90deg,
        transparent,
        rgba(208, 188, 255, 0.26),
        transparent
    );
}

body.dark-theme .notification-md blockquote {
    background: linear-gradient(135deg, rgba(208, 188, 255, 0.14), rgba(79, 55, 139, 0.18));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

body.dark-theme .notification-md .notification-md-callout {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

body.dark-theme .notification-md .notification-md-callout.is-note {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.16), rgba(30, 64, 175, 0.18));
}

body.dark-theme .notification-md .notification-md-callout.is-note .notification-md-callout-header {
    color: #93C5FD;
}

body.dark-theme .notification-md .notification-md-callout.is-tip {
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.16), rgba(21, 128, 61, 0.18));
}

body.dark-theme .notification-md .notification-md-callout.is-tip .notification-md-callout-header {
    color: #86EFAC;
}

body.dark-theme .notification-md .notification-md-callout.is-important {
    background: linear-gradient(135deg, rgba(196, 181, 253, 0.18), rgba(91, 33, 182, 0.20));
}

body.dark-theme .notification-md .notification-md-callout.is-important .notification-md-callout-header {
    color: #D8B4FE;
}

body.dark-theme .notification-md .notification-md-callout.is-warning {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.18), rgba(180, 83, 9, 0.18));
}

body.dark-theme .notification-md .notification-md-callout.is-warning .notification-md-callout-header {
    color: #FCD34D;
}

body.dark-theme .notification-md .notification-md-callout.is-caution {
    background: linear-gradient(135deg, rgba(248, 113, 113, 0.18), rgba(153, 27, 27, 0.18));
}

body.dark-theme .notification-md .notification-md-callout.is-caution .notification-md-callout-header {
    color: #FCA5A5;
}

body.dark-theme .notification-md :not(pre) > code {
    background: rgba(208, 188, 255, 0.12);
    border-color: rgba(208, 188, 255, 0.18);
}

/* 兼容选择器：body.dark-theme 与 html.theme-dark 同时挂载（useThemeSync 同步 toggle），
   此处保持与上方 html.theme-dark 规则完全一致，防止级联顺序导致首屏跳变。 */
body.dark-theme .notification-md-code-block,
body.dark-theme .notification-md-mermaid-block {
    border-color: rgba(255, 255, 255, 0.10);
    background: #1e1e1e;
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body.dark-theme .notification-md-code-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, #2d2d30, #252526);
}

/* 暗色下红绿灯描边微调，保持立体感 */
body.dark-theme .notification-md-traffic-light {
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

body.dark-theme .notification-md-code-lang {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--md-sys-color-primary);
}

body.dark-theme .notification-md pre {
    background: #1e1e1e; /* 与外壳同色，形成一整块终端画布 */
}

body.dark-theme .notification-md pre code {
    color: #D4D4D4; /* VSCode Dark Modern 默认前景色 */
}

body.dark-theme .notification-md .notification-md-table-wrap {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(208, 188, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

body.dark-theme .notification-md .notification-md-details {
    background: linear-gradient(180deg, rgba(208, 188, 255, 0.12), rgba(79, 55, 139, 0.10));
    border-color: rgba(208, 188, 255, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

body.dark-theme .notification-md-mermaid-tool-btn {
    background: rgba(255, 255, 255, 0.08);
}

/* 暗色模式：内层 mermaid 画布容器必须覆盖为深色底。 */
body.dark-theme .notification-md-mermaid {
    background:
        radial-gradient(circle at top right, rgba(208, 188, 255, 0.07), transparent 34%),
        linear-gradient(180deg, rgba(30, 27, 38, 0.98), rgba(20, 18, 24, 0.98));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* 暗色模式：Mermaid 图表的暗色适配由 useMermaidRenderer.js 的
   applyMermaidDarkAdaptation() 统一负责——它以 setProperty(..., 'important')
   写内联样式，优先级高于此处外部样式表的 !important 规则。
   因此节点形状、文字、连线的强制覆盖规则不再在此重复维护（运行时不会生效），
   仅保留 JS 未覆盖的部分：a 链接颜色与边标签背景。 */

/* 暗色模式：锚点/链接文字与背景边框同步浅色化，避免深底上的深色文字看不清 */
body.dark-theme .notification-md-mermaid svg a {
    fill: #D8B4FE;
    stroke: none;
}

/* 边标签背景：JS 暗色适配未覆盖，保持深色半透明底以区分标签与画布 */
body.dark-theme .notification-md-mermaid svg .edgeLabels .edgeLabel {
    background: rgba(30, 27, 38, 0.92);
}

/* ==========================================================================
   12. 响应式断点适配 (Responsive Adaptive)
   ========================================================================== */

/* 平板及移动端视窗（最大宽 920px）：条目宽度自适应收窄 */
@media (max-width: 920px) {
    .markdown-docs-toc-item {
        min-width: 150px;
    }
}

/* 移动端（最大宽 768px）：顶部栏转为静态占位，视图回归正常文档流 */
@media (max-width: 768px) {
    /* 移动端不锁定视图高度，内容自然流动，由页面整体滚动承载 */
    .markdown-docs-view {
        height: auto;
        overflow: visible;
    }

    .markdown-docs-layout {
        gap: 7px;
    }

    /* 移动端阅读卡片与内部滚动容器恢复自然高度，由页面整体滚动承载 */
    .markdown-docs-content-card,
    .markdown-docs-content-scroll {
        overflow: visible;
        flex: none;
    }

    .markdown-docs-toc-head {
        flex-wrap: wrap;
    }

    .markdown-docs-toc-subtitle {
        width: 100%;
    }

    /* 触屏小屏：关闭目录项的悬停位移，仅保留静态反馈。
       变量关闭与 hover 禁用已在 base.css 768px 触屏规则中统一声明，
       此处仅保留尺寸收窄，避免重复维护同值变量 */
    .markdown-docs-toc-item {
        min-width: 140px;
        max-width: 260px;
    }
}
