/* ============================================================================
   Autonomy 文档 — 简约清晰主题
   ============================================================================ */

:root {
    /* 与系统架构图一致的色板 */
    --color-layer-label: #1a4d6e;   /* 左侧层级标签深蓝 */
    --color-core: #5a7289;           /* 核心模块灰蓝 */
    --color-core-dark: #4a6278;
    --color-core-bg: #eef1f4;
    --color-app: #2d9294;           /* 应用 / 插件青绿 */
    --color-app-bg: #e0f2f2;
    --color-tasks: #9a3545;         /* Tasks Service 暗红 */
    --color-tasks-bg: #f3e6e8;

    /* 樱草绿侧边栏（导航区统一为绿） */
    --color-nav-bg: #7aa88d;
    --color-nav-bg-dark: #5f8d73;
    --color-nav-surface: #f3faf5;
    --color-nav-text: #31493d;
    --color-nav-text-muted: #698274;
    --color-nav-hover-bg: rgba(122, 168, 141, 0.18);
    --color-nav-accent: #c9889a;  /* 樱花粉作为选中点缀 */
    --color-nav-search-bg: #7aa88d;
    --color-nav-search-bg-dark: #5f8d73;
    --color-nav-search-input-bg: #f6fcf8;
    --color-nav-search-input-border: #b7d3c1;
    --color-nav-search-input-text: #31493d;
    --color-nav-search-placeholder: #7d9988;

    /* 文档全局令牌（界面层统一为樱花粉 / 绿） */
    --color-primary: var(--color-nav-bg);
    --color-primary-dark: var(--color-nav-bg-dark);
    --color-accent: var(--color-nav-search-bg);
    --color-text: #3d3438;
    --color-text-muted: #6d5f66;
    --color-border: #f0e4e8;
    --color-surface: #ffffff;
    --color-surface-2: #fdf8fa;
    --color-code-bg: #f6f8fa;
    --color-code-text: #334155;
    --radius: 8px;
    --shadow-sm: 0 1px 3px rgba(74, 53, 64, 0.06);
    --shadow-md: 0 4px 12px rgba(74, 53, 64, 0.08);
}

/* 中文正文与 § 符号：优先系统中文字体，避免缺字 / 方框 */
.wy-nav-content,
.rst-content {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

/* ----------------------------------------------------------------------------
   页面宽度
   ---------------------------------------------------------------------------- */

.wy-nav-content {
    max-width: 1200px !important;
    padding: 2rem 2.5rem !important;
}

@media screen and (min-width: 1400px) {
    .wy-nav-content {
        max-width: 1320px !important;
    }
}

.wy-body-for-nav {
    max-width: 100%;
}

/* ----------------------------------------------------------------------------
   正文排版
   ---------------------------------------------------------------------------- */

.rst-content {
    color: var(--color-text);
    font-size: 0.95rem;
}

.rst-content p {
    line-height: 1.75;
    margin-bottom: 1rem;
    color: var(--color-text);
}

.rst-content ul,
.rst-content ol {
    margin: 0.75rem 0 1rem;
    padding-left: 1.5rem;
    line-height: 1.75;
}

.rst-content li {
    margin: 0.35rem 0;
}

/* ----------------------------------------------------------------------------
   标题
   ---------------------------------------------------------------------------- */

.rst-content h1 {
    padding-bottom: 0.6rem;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid var(--color-primary);
    color: var(--color-text);
    font-weight: 700;
    font-size: 1.75rem;
}

.rst-content h2 {
    padding-bottom: 0.4rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    font-weight: 600;
    font-size: 1.35rem;
}

.rst-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--color-text);
    font-weight: 600;
    font-size: 1.1rem;
}

.rst-content h4,
.rst-content h5,
.rst-content h6 {
    margin-top: 1.25rem;
    margin-bottom: 0.4rem;
    color: var(--color-text-muted);
    font-weight: 600;
}

/* ----------------------------------------------------------------------------
   链接
   ---------------------------------------------------------------------------- */

.rst-content a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

.rst-content a:hover {
    color: var(--color-nav-search-bg-dark);
    text-decoration: underline;
}

.rst-content a code {
    color: var(--color-accent);
}

/* ----------------------------------------------------------------------------
   代码块
   ---------------------------------------------------------------------------- */

.rst-content .highlight {
    width: 100%;
    margin: 1.25rem 0;
    border-radius: var(--radius);
    border: 1px solid #e6d7df;
    border-left: 3px solid var(--color-accent);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    background-color: var(--color-code-bg);
}

.rst-content .highlight pre {
    margin: 0;
    padding: 1rem 1.25rem;
    background-color: #fbf8fa;
    color: var(--color-code-text);
    border: none;
    border-radius: var(--radius);
    font-size: 0.875em;
    line-height: 1.6;
    overflow-x: auto;
}

.rst-content .highlight pre .linenos {
    padding-right: 1rem;
    color: var(--color-text-muted);
    user-select: none;
}

.rst-content code {
    padding: 0.15em 0.4em;
    background-color: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.875em;
    color: #51695d;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
}

/* ----------------------------------------------------------------------------
   表格
   ---------------------------------------------------------------------------- */

.rst-content table.docutils {
    width: 100%;
    margin: 1.25rem 0;
    border-collapse: collapse;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.rst-content table.docutils thead {
    background: linear-gradient(180deg, #fdf2f6 0%, #f8f5f7 100%);
    color: #4a3540;
}

.rst-content table.docutils thead th {
    padding: 0.75rem 1rem;
    font-weight: 600;
    text-align: left;
    border-bottom: 2px solid #ead7df;
}

.rst-content table.docutils td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.rst-content table.docutils tbody tr:hover {
    background-color: #f4faf6;
}

.rst-content table.docutils tbody tr:last-child td {
    border-bottom: none;
}

/* ----------------------------------------------------------------------------
   提示框
   ---------------------------------------------------------------------------- */

.rst-content .admonition {
    margin: 1.25rem 0;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border-left: 4px solid;
    box-shadow: var(--shadow-sm);
    background-color: var(--color-surface);
    border: 1px solid transparent;
}

.rst-content .admonition.note {
    border-left-color: #94bfa5;
    background-color: #f6fbf8;
    border-color: #d7e9de;
}

.rst-content .admonition.warning {
    border-left-color: #f59e0b;
    background-color: #fffbeb;
}

.rst-content .admonition.danger,
.rst-content .admonition.error {
    border-left-color: #ef4444;
    background-color: #fef2f2;
}

.rst-content .admonition.tip,
.rst-content .admonition.hint {
    border-left-color: var(--color-accent);
    background-color: #eff8f2;
    border-color: #c9dfd1;
}

.rst-content .admonition-title {
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.rst-content .admonition.note .admonition-title {
    color: var(--color-nav-search-bg-dark);
}

.rst-content .admonition.tip .admonition-title,
.rst-content .admonition.hint .admonition-title {
    color: var(--color-nav-search-bg-dark);
}

/* ----------------------------------------------------------------------------
   引用、图片、分隔线
   ---------------------------------------------------------------------------- */

.rst-content .math {
    color: var(--color-layer-label);
}

.rst-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    margin: 1.25rem 0;
}

/* TEB 论文插图：居中 + caption；宽度由 Markdown {width=} 控制，此处做上限兜底 */
.rst-content img[src*="iros2017_fig1"],
.rst-content img[src*="definition_timed_elastic_band"],
.rst-content img[src*="ecmr2013_fig2"],
.rst-content img[src*="ecmr2013_fig3"],
.rst-content img[src*="ecmr2013_fig4"] {
    display: block;
    width: auto;
    height: auto;
    margin: 1.25rem auto 0.5rem;
    object-fit: contain;
}

/* 宽幅示意图（≈2:1 及以上） */
.rst-content img[src*="iros2017_fig1"] {
    max-width: min(76%, 920px);
}

.rst-content img[src*="definition_timed_elastic_band"] {
    max-width: min(72%, 840px);
}

.rst-content img[src*="ecmr2013_fig2"] {
    max-width: min(68%, 800px);
}

.rst-content img[src*="ecmr2013_fig4_system_matrix"] {
    max-width: min(74%, 780px);
}

/* 竖版控制流图（990×1286）：限宽 + 限高，避免占满整页 */
.rst-content img[src*="ecmr2013_fig3_control_flow"] {
    max-width: min(420px, 46%);
    max-height: 540px;
}

.rst-content p:has(> img[src*="iros2017_fig1"]) + p em,
.rst-content p:has(> img[src*="definition_timed_elastic_band"]) + p em,
.rst-content p:has(> img[src*="ecmr2013_fig2"]) + p em,
.rst-content p:has(> img[src*="ecmr2013_fig3"]) + p em,
.rst-content p:has(> img[src*="ecmr2013_fig4"]) + p em {
    display: block;
    max-width: 88%;
    margin: 0 auto 1.5rem;
    padding: 0 0.5rem;
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--color-text-muted);
    text-align: center;
}

.rst-content blockquote {
    margin: 1.25rem 0;
    padding: 0.75rem 1.25rem;
    border-left: 3px solid var(--color-primary);
    background-color: var(--color-surface-2);
    border-radius: 4px;
    color: var(--color-text-muted);
}

.rst-content hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 2rem 0;
}

/* ----------------------------------------------------------------------------
   侧边栏 — 樱花绿导航区
   ---------------------------------------------------------------------------- */

.wy-nav-side {
    background: var(--color-nav-surface);
}

.wy-side-nav-search {
    background: linear-gradient(180deg, var(--color-nav-search-bg) 0%, var(--color-nav-search-bg-dark) 100%);
}

.wy-side-nav-search > a {
    color: #ffffff;
}

.wy-side-nav-search input[type="text"] {
    background: var(--color-nav-search-input-bg);
    color: var(--color-nav-search-input-text);
    border: 1px solid var(--color-nav-search-input-border);
    border-radius: var(--radius);
    padding: 0.45rem 0.65rem;
    box-shadow: inset 0 1px 2px rgba(47, 74, 64, 0.06);
}

.wy-side-nav-search input[type="text"]::placeholder {
    color: var(--color-nav-search-placeholder);
}

.wy-side-nav-search input[type="text"]:focus {
    outline: none;
    border-color: var(--color-nav-bg);
    box-shadow: 0 0 0 2px rgba(201, 136, 154, 0.35);
}

.wy-menu-vertical a {
    color: var(--color-nav-text);
}

.wy-menu-vertical li.current > a,
.wy-menu-vertical li.on a,
.wy-menu-vertical li.current > a:hover {
    color: var(--color-nav-bg-dark);
    font-weight: 600;
    background: var(--color-nav-hover-bg);
    border-left: 3px solid var(--color-nav-accent);
}

.wy-menu-vertical a:hover {
    background-color: var(--color-nav-hover-bg);
    color: var(--color-nav-bg-dark);
}

.wy-menu-vertical li.toctree-l2 > a,
.wy-menu-vertical li.toctree-l3 > a {
    color: var(--color-nav-text-muted);
}

.wy-menu-vertical li.toctree-l2.current > a,
.wy-menu-vertical li.toctree-l3.current > a {
    color: var(--color-nav-bg-dark);
}

.wy-nav-top {
    background: var(--color-nav-search-bg) !important;
}

/* ----------------------------------------------------------------------------
   Mermaid 图表
   ---------------------------------------------------------------------------- */

.rst-content .mermaid-container {
    width: 100%;
    max-width: 100%;
    margin: 2rem 0;
    padding: 1.25rem 1.5rem;
    background-color: #fafbfc;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.rst-content .mermaid-container pre.mermaid {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    font-size: 15px;
    line-height: 1.5;
}

.rst-content .mermaid-container svg {
    display: block;
    margin: 0 auto;
    max-width: none !important;
    width: auto !important;
    min-width: min(100%, 720px);
    height: auto !important;
}

/* rpcs/ 流程图：禁用全局 min-width 拉伸与 JS 注入的 500px 高度 */
.rst-content .rpc-flow-diagram .mermaid-container,
.rst-content .nav-state-diagram .mermaid-container {
    margin: 0 !important;
    overflow-x: auto;
    overflow-y: visible !important;
}

.rst-content .rpc-flow-diagram .mermaid-container svg {
    min-width: 0 !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
}

.rst-content .nav-state-diagram .mermaid-container svg,
.rst-content .nav-state-diagram pre.mermaid > svg {
    min-width: 0 !important;
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 480px !important;
}

/* 时间轴类图表：允许更宽的水平展示 */
.rst-content .mermaid-container:has(svg .timeline) {
    min-height: 200px;
}

.rst-content .mermaid-container:has(svg .timeline) svg {
    min-width: 900px;
}

@media screen and (max-width: 1200px) {
    .rst-content .mermaid-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .rst-content .mermaid-container svg {
        min-width: 800px;
    }

    .rst-content .rpc-flow-diagram .mermaid-container svg,
    .rst-content .nav-state-diagram .mermaid-container svg,
    .rst-content .nav-state-diagram pre.mermaid > svg {
        min-width: 0 !important;
    }
}

/* ----------------------------------------------------------------------------
   Planning Survey：发展时间轴（分阶段卡片网格）
   ---------------------------------------------------------------------------- */

.rst-content .planning-timeline-v2 {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    margin: 1.25rem 0 2rem;
}

.rst-content .timeline-era-block {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e1e4e8;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.rst-content .timeline-era-header {
    padding: 0.7rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}

.rst-content .timeline-era-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 0.7rem;
    padding: 0.9rem 1rem 1.05rem;
    background: #fafbfc;
}

.rst-content .timeline-milestone {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    background: #fff;
    border: 1px solid #e8eaed;
    border-radius: 8px;
    padding: 0.8rem 0.9rem;
    border-left: 4px solid var(--era-accent, var(--color-core));
    min-height: 5.5rem;
}

.rst-content .timeline-milestone-highlight {
    background: var(--color-layer-label);
    border-color: var(--color-core-dark);
    border-left-color: var(--color-app);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.rst-content .timeline-milestone-highlight .timeline-milestone-year,
.rst-content .timeline-milestone-highlight .timeline-milestone-title,
.rst-content .timeline-milestone-highlight .timeline-milestone-desc {
    color: #fff;
}

.rst-content .timeline-milestone-year {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--era-accent, var(--color-core));
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.rst-content .timeline-milestone-title {
    font-weight: 600;
    font-size: 0.98rem;
    color: #263238;
    line-height: 1.35;
}

.rst-content .timeline-milestone-desc {
    font-size: 0.84rem;
    color: #546e7a;
    line-height: 1.5;
    flex: 1;
}

.rst-content .era-foundation { --era-accent: var(--color-layer-label); }
.rst-content .era-foundation .timeline-era-header {
    background: #e4edf3;
    color: var(--color-layer-label);
    border-bottom: 1px solid #b8cdd9;
}

.rst-content .era-reactive { --era-accent: var(--color-core); }
.rst-content .era-reactive .timeline-era-header {
    background: var(--color-core-bg);
    color: var(--color-core-dark);
    border-bottom: 1px solid #b8c4d0;
}

.rst-content .era-sampling { --era-accent: var(--color-app); }
.rst-content .era-sampling .timeline-era-header {
    background: var(--color-app-bg);
    color: #1f6b6d;
    border-bottom: 1px solid #9dd4d5;
}

.rst-content .era-engineering { --era-accent: var(--color-tasks); }
.rst-content .era-engineering .timeline-era-header {
    background: var(--color-tasks-bg);
    color: #7a2a38;
    border-bottom: 1px solid #d4a8b0;
}

/* ----------------------------------------------------------------------------
   Planning Survey：经典三层导航架构（全宽纵向示意图）
   ---------------------------------------------------------------------------- */

.rst-content .nav-stack-diagram {
    margin: 1.25rem 0 1.75rem;
    padding: 1.25rem 1.35rem 1.35rem;
    background: #f8f9fb;
    border: 1px solid #e1e4e8;
    border-radius: 12px;
    width: 100%;
    box-sizing: border-box;
}

.rst-content .nav-stack-wide .nav-stack-inputs-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.rst-content .nav-input-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    padding: 0.7rem 0.9rem;
    background: #fff;
    border: 1px solid #dce3e8;
    border-radius: 8px;
    font-size: 0.86rem;
    line-height: 1.45;
    color: #455a64;
}

.rst-content .nav-input-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
    background: #607d8b;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
}

.rst-content .nav-input-text {
    font-weight: 500;
    color: #37474f;
}

.rst-content .nav-input-arrow {
    color: #90a4ae;
    font-weight: 600;
}

.rst-content .nav-input-target {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82em;
    color: var(--color-core);
    background: var(--color-core-bg);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.rst-content .nav-costmap-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.4rem 0.65rem;
    margin-bottom: 1rem;
    padding: 0.65rem 1rem;
    background: var(--color-core-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.88rem;
    color: var(--color-text-muted);
}

.rst-content .nav-costmap-banner strong {
    color: var(--color-layer-label);
    font-size: 0.95rem;
}

.rst-content .nav-costmap-banner .nav-costmap-detail {
    font-size: 0.82rem;
    color: #546e7a;
}

.rst-content .nav-costmap-arrow {
    margin-left: auto;
    font-size: 0.82rem;
    color: var(--color-app);
    font-weight: 600;
}

.rst-content .nav-stack-pipeline {
    width: 100%;
}

.rst-content .nav-layer-row {
    display: grid;
    grid-template-columns: minmax(130px, 16%) 1fr minmax(180px, 22%);
    gap: 1rem 1.25rem;
    align-items: start;
    padding: 1.1rem 1.2rem;
    border-radius: 10px;
    border: 1px solid;
}

.rst-content .nav-layer-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding-right: 0.5rem;
    border-right: 1px solid rgba(0, 0, 0, 0.07);
}

.rst-content .nav-layer-meta .nav-layer-badge {
    display: inline-block;
    width: fit-content;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    margin-bottom: 0.15rem;
}

.rst-content .nav-layer-meta .nav-layer-title {
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.35;
    margin: 0;
}

.rst-content .nav-layer-meta .nav-layer-sub {
    font-size: 0.84rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    opacity: 0.85;
}

.rst-content .nav-layer-body {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.rst-content .nav-body-block {
    background: rgba(255, 255, 255, 0.45);
    border-radius: 6px;
    padding: 0.55rem 0.7rem;
}

.rst-content .nav-body-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #78909c;
    margin-bottom: 0.35rem;
}

.rst-content .nav-layer-body ul {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.88em;
    line-height: 1.55;
    color: #37474f;
    columns: 1;
}

.rst-content .nav-layer-body ul li {
    margin-bottom: 0.2rem;
}

.rst-content .nav-layer-body ul li:last-child {
    margin-bottom: 0;
}

.rst-content .nav-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.rst-content .nav-chip {
    display: inline-block;
    font-size: 0.8rem;
    padding: 0.2rem 0.55rem;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    color: #455a64;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.rst-content .nav-layer-meta .nav-meta-freq {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: #607d8b;
    padding: 0.2rem 0.45rem;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    width: fit-content;
}

.rst-content .nav-layer-io {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rst-content .nav-io-block {
    background: rgba(255, 255, 255, 0.55);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
}

.rst-content .nav-io-heading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
}

.rst-content .nav-io-in .nav-io-heading {
    color: var(--color-app);
}

.rst-content .nav-io-out .nav-io-heading {
    color: var(--color-tasks);
}

.rst-content .nav-io-list {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.84rem;
    line-height: 1.5;
    color: #455a64;
}

.rst-content .nav-io-list li {
    padding: 0.15rem 0;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.06);
}

.rst-content .nav-io-list li:last-child {
    border-bottom: none;
}

.rst-content .nav-io-list code {
    font-size: 0.92em;
}

.rst-content .nav-layer-behavior {
    background: var(--color-tasks-bg);
    border-color: #d4a8b0;
}
.rst-content .nav-layer-behavior .nav-layer-badge {
    background: var(--color-tasks);
    color: #fff;
}
.rst-content .nav-layer-behavior .nav-layer-title {
    color: #7a2a38;
}
.rst-content .nav-layer-behavior .nav-layer-sub {
    color: var(--color-tasks);
}

.rst-content .nav-layer-global {
    background: var(--color-core-bg);
    border-color: #b8c4d0;
}
.rst-content .nav-layer-global .nav-layer-badge {
    background: var(--color-core);
    color: #fff;
}
.rst-content .nav-layer-global .nav-layer-title {
    color: var(--color-core-dark);
}
.rst-content .nav-layer-global .nav-layer-sub {
    color: var(--color-core);
}

.rst-content .nav-layer-local {
    background: var(--color-core-bg);
    border-color: #b8c4d0;
}
.rst-content .nav-layer-local .nav-layer-badge {
    background: var(--color-layer-label);
    color: #fff;
}
.rst-content .nav-layer-local .nav-layer-title {
    color: var(--color-layer-label);
}
.rst-content .nav-layer-local .nav-layer-sub {
    color: var(--color-core);
}

.rst-content .nav-pipe {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0;
    position: relative;
}

.rst-content .nav-pipe::before {
    content: "";
    position: absolute;
    left: 8%;
    right: 8%;
    top: 50%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #b0bec5 20%, #b0bec5 80%, transparent);
    z-index: 0;
}

.rst-content .nav-pipe-label {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 1rem;
    background: #fff;
    border: 1px solid #cfd8dc;
    border-radius: 999px;
    font-size: 0.82rem;
    color: #546e7a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.rst-content .nav-pipe-label::before {
    content: "↓";
    color: #90a4ae;
    font-weight: 600;
}

.rst-content .nav-robot-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.85rem 1.25rem;
    background: var(--color-surface-2);
    border: 1px solid #b0bec5;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.98rem;
    color: #37474f;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.rst-content .nav-robot-icon {
    font-size: 1.15rem;
    opacity: 0.7;
}

/* 宽屏：职责列表双列，更好填充页面 */
@media screen and (min-width: 900px) {
    .rst-content .nav-body-block ul {
        columns: 1;
    }
}

@media screen and (max-width: 768px) {
    .rst-content .nav-stack-wide .nav-stack-inputs-bar {
        grid-template-columns: 1fr;
    }

    .rst-content .nav-layer-row {
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }

    .rst-content .nav-layer-meta {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.35rem 0.65rem;
        padding-right: 0;
        padding-bottom: 0.5rem;
        border-right: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    }

    .rst-content .nav-costmap-arrow {
        margin-left: 0;
        width: 100%;
        text-align: center;
    }
}

/* 兼容旧版窄列布局（若其他页面仍引用） */
.rst-content .nav-stack-column {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    margin: 0;
}

.rst-content .nav-layer-card {
    border-radius: 10px;
    padding: 1rem 1.15rem;
    border: 1px solid;
}

.rst-content .nav-flow-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.45rem 0;
    color: #607d8b;
    font-size: 0.82rem;
    line-height: 1.4;
    text-align: center;
}

.rst-content .nav-robot-target {
    text-align: center;
    margin-top: 0.15rem;
    padding: 0.75rem 1rem;
    background: #eceff1;
    border: 1px solid #cfd8dc;
    border-radius: 10px;
    font-weight: 600;
    color: #37474f;
    font-size: 0.95rem;
}

@media screen and (max-width: 600px) {
    .rst-content .timeline-era-grid {
        grid-template-columns: 1fr;
    }
}

/* ----------------------------------------------------------------------------
   Planning Survey：鱼骨图卡片网格
   ---------------------------------------------------------------------------- */

.rst-content .fishbone-wrap {
    margin: 1.5rem 0 2rem;
}

.rst-content .fishbone-head {
    text-align: center;
    padding: 0.85rem 1.25rem;
    margin-bottom: 1rem;
    background: var(--color-primary-dark);
    color: #fff;
    font-weight: 600;
    font-size: 1.05rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(74, 95, 193, 0.25);
}

.rst-content .fishbone-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.85rem;
}

.rst-content .fishbone-card {
    background: #fafbfc;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    border-top: 3px solid var(--color-core);
}

.rst-content .fishbone-card.fishbone-lower {
    border-top-color: var(--color-app);
}

.rst-content .fishbone-card h4 {
    margin: 0 0 0.5rem;
    padding-bottom: 0.4rem;
    font-size: 0.95rem;
    color: var(--color-layer-label);
    border-bottom: 1px solid var(--color-border);
}

.rst-content .fishbone-card.fishbone-lower h4 {
    color: var(--color-app);
    border-bottom-color: #b8e0e1;
}

.rst-content .fishbone-card ul {
    margin: 0;
    padding-left: 1.15rem;
    font-size: 0.9em;
    line-height: 1.6;
    color: #455a64;
}

.rst-content .fishbone-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #78909c;
    margin: 0.5rem 0 0.35rem;
}

/* 未来路线横向步骤条 */
.rst-content .roadmap-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1.25rem 0 1.5rem;
    align-items: stretch;
}

.rst-content .roadmap-step {
    flex: 1 1 140px;
    min-width: 120px;
    padding: 0.75rem 0.85rem;
    background: #f5f7fa;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    text-align: center;
    line-height: 1.45;
}

.rst-content .roadmap-step strong {
    display: block;
    color: var(--color-layer-label);
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.rst-content .roadmap-step span {
    font-size: 0.85em;
    color: #546e7a;
}

.rst-content .roadmap-step.roadmap-current {
    background: var(--color-layer-label);
    border-color: var(--color-core-dark);
    color: #fff;
}

.rst-content .roadmap-step.roadmap-current strong,
.rst-content .roadmap-step.roadmap-current span {
    color: #fff;
}

@media screen and (max-width: 900px) {
    .rst-content .fishbone-grid {
        grid-template-columns: 1fr;
    }
}

/* ----------------------------------------------------------------------------
   Planning / Communication 模块架构图（plan-arch-* · nav-chip-*）
   Communication：01_architecture.md §1.1–§1.3；设计流程 comm-flow-* §1.4–§12.1
   ---------------------------------------------------------------------------- */

.rst-content .plan-arch-diagram {
    margin: 1.25rem 0 1.75rem;
    padding: 1.25rem 1.35rem;
    background: #f8f9fb;
    border: 1px solid #e1e4e8;
    border-radius: 12px;
    width: 100%;
    box-sizing: border-box;
}

/* Bridge §2 分层图 — 紧凑版，层宽随内容、居中 */
.rst-content .plan-arch-diagram--compact {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    margin: 0.65rem auto 0.85rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
}

.rst-content .plan-arch-diagram--compact .plan-arch-layer {
    width: fit-content;
    max-width: min(100%, 20rem);
    min-width: 12rem;
    padding: 0.4rem 0.75rem;
    box-sizing: border-box;
}

.rst-content .plan-arch-diagram--compact .plan-arch-header {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
    gap: 0.35rem 0.45rem;
    flex-wrap: nowrap;
}

.rst-content .plan-arch-diagram--compact .plan-arch-title {
    font-size: 0.88rem;
    white-space: nowrap;
}

.rst-content .plan-arch-diagram--compact .plan-arch-sub {
    flex: 0 1 auto;
    font-size: 0.75rem;
    white-space: nowrap;
}

.rst-content .plan-arch-diagram--compact .plan-arch-pipe {
    width: 100%;
    max-width: 20rem;
    padding: 0.15rem 0;
}

.rst-content .plan-arch-diagram--compact .plan-arch-pipe span {
    padding: 0.08rem 0.45rem;
    font-size: 0.72rem;
}

/* Bridge §2 数据流 — 各层等宽（plan-arch 版） */
.rst-content .plan-arch-diagram--compact.bridge-arch-flow {
    width: min(100%, 22rem);
}

.rst-content .plan-arch-diagram--compact.bridge-arch-flow .plan-arch-layer,
.rst-content .plan-arch-diagram--compact.bridge-arch-flow .plan-arch-pipe {
    width: 100%;
    max-width: none;
    min-width: 0;
    box-sizing: border-box;
}

.rst-content .plan-arch-diagram--compact.bridge-arch-flow .plan-arch-title {
    white-space: normal;
    text-align: center;
    flex: 1 1 100%;
}

.rst-content .plan-arch-diagram--compact.bridge-arch-flow .plan-arch-header {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
}

/* Bridge §2 数据流 — Mermaid 版居中 */
.rst-content .nav-state-diagram.bridge-arch-flow {
    width: 100%;
    max-width: min(100%, 42rem);
    margin-left: auto;
    margin-right: auto;
}

.rst-content .nav-state-diagram.bridge-arch-flow svg .edgePath .path,
.rst-content .nav-state-diagram.bridge-arch-flow svg .edgePaths path,
.rst-content .nav-state-diagram.bridge-arch-flow svg .transition {
    stroke: #e53935 !important;
    stroke-width: 1.5px;
}

.rst-content .nav-state-diagram.bridge-arch-flow svg marker path {
    fill: #e53935 !important;
    stroke: #e53935 !important;
}

.rst-content .nav-state-diagram.bridge-arch-flow svg .edgeLabel .label {
    font-size: 11px;
}

.rst-content .plan-arch-layer {
    border-radius: 10px;
    border: 1px solid;
    padding: 0.9rem 1.1rem;
    background: #fff;
}

.rst-content .plan-arch-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 0.65rem;
    margin-bottom: 0.65rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

.rst-content .plan-arch-badge {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: #fff;
}

.rst-content .plan-arch-title {
    font-size: 1.02rem;
    font-weight: 600;
    color: #263238;
}

.rst-content .plan-arch-sub {
    flex: 1 1 100%;
    font-size: 0.82rem;
    color: #607d8b;
}

.rst-content .plan-arch-body {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.rst-content .plan-arch-body-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.rst-content .plan-arch-body ul {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.88em;
    line-height: 1.55;
    color: #37474f;
}

.rst-content .plan-arch-pipe {
    display: flex;
    justify-content: center;
    padding: 0.45rem 0;
    position: relative;
}

.rst-content .plan-arch-pipe::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, #b0bec5, #90a4ae);
    transform: translateX(-50%);
    z-index: 0;
}

.rst-content .plan-arch-pipe span {
    position: relative;
    z-index: 1;
    background: #f8f9fb;
    padding: 0.2rem 0.75rem;
    font-size: 0.8rem;
    color: #546e7a;
    border: 1px solid #cfd8dc;
    border-radius: 999px;
}

.rst-content .plan-arch-pipe-out span {
    background: #eceff1;
    font-weight: 600;
    color: #37474f;
}

.rst-content .plan-arch-split {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.65rem;
    align-items: stretch;
}

.rst-content .plan-arch-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0 0.35rem;
    min-width: 3.5rem;
}

.rst-content .plan-arch-link-text {
    font-size: 0.75rem;
    color: #607d8b;
    text-align: center;
    line-height: 1.35;
    font-weight: 600;
}

.rst-content .plan-arch-link-arrow {
    font-size: 0.85rem;
    color: #90a4ae;
}

.rst-content .plan-arch-app {
    background: var(--color-app-bg);
    border-color: #9dd4d5;
}
.rst-content .plan-arch-app .plan-arch-badge {
    background: var(--color-app);
}

.rst-content .plan-arch-server {
    background: var(--color-core-bg);
    border-color: #b8c4d0;
}
.rst-content .plan-arch-server .plan-arch-badge {
    background: var(--color-core);
}

.rst-content .plan-arch-plugin {
    background: var(--color-app-bg);
    border-color: #9dd4d5;
}
.rst-content .plan-arch-plugin .plan-arch-badge {
    background: var(--color-app);
}

.rst-content .plan-arch-map {
    background: var(--color-core-bg);
    border-color: #b8c4d0;
}
.rst-content .plan-arch-map .plan-arch-badge {
    background: var(--color-core);
}

.rst-content .plan-arch-post {
    background: #e4e9ee;
    border-color: #a8b6c4;
}
.rst-content .plan-arch-post .plan-arch-badge {
    background: var(--color-layer-label);
}

/* Bridge §2：分层图防溢出（长类名 / chip） */
.rst-content .plan-arch-layer {
    min-width: 0;
    box-sizing: border-box;
}

.rst-content .plan-arch-title {
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.35;
}

.rst-content .plan-arch-diagram .nav-chip {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
    box-sizing: border-box;
}

.rst-content .plan-arch-split > .plan-arch-layer {
    min-width: 0;
}

.rst-content .plan-arch-body-cols > .nav-body-block {
    min-width: 0;
}

@media screen and (max-width: 768px) {
    .rst-content .plan-arch-split {
        grid-template-columns: 1fr;
    }

    .rst-content .plan-arch-link {
        flex-direction: row;
        padding: 0.35rem 0;
        min-width: unset;
    }

    .rst-content .plan-arch-link-text br {
        display: none;
    }

    .rst-content .plan-arch-body-cols {
        grid-template-columns: 1fr;
    }
}

/* ----------------------------------------------------------------------------
   Communication 设计流程图（comm-flow-* · 各章 §N.1 / §3.7）
   ---------------------------------------------------------------------------- */

.rst-content .comm-flow-diagram {
    margin: 1.25rem 0 1.75rem;
    padding: 1rem 1.25rem 1.1rem;
    background: #f8f9fb;
    border: 1px solid #e1e4e8;
    border-radius: 12px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.rst-content .comm-flow-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 0.65rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid #e1e4e8;
}

.rst-content .comm-flow-badge {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: #fff;
    background: var(--color-core);
    flex-shrink: 0;
}

.rst-content .comm-flow-title {
    font-size: 1rem;
    font-weight: 600;
    color: #263238;
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.rst-content .comm-flow-sub {
    flex: 1 1 100%;
    font-size: 0.82rem;
    color: #607d8b;
    line-height: 1.45;
    margin-top: 0.1rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.rst-content .comm-flow-canvas {
    margin: 0.25rem 0 0.65rem;
    padding: 1rem 1.25rem;
    background: #fff;
    border: 1px solid #eceff1;
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    text-align: center;
}

.rst-content .comm-flow-diagram pre.mermaid {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
    display: inline-block;
    min-width: min(100%, 520px);
    text-align: center;
    font-size: 14px;
    line-height: 1.45;
}

.rst-content .comm-flow-diagram pre.mermaid svg {
    display: block;
    margin: 0 auto;
    max-width: none;
    width: auto !important;
    height: auto !important;
}

.rst-content .comm-flow-foot {
    margin-top: 0;
    padding-top: 0.65rem;
    border-top: 1px dashed #cfd8dc;
    font-size: 0.86rem;
    color: #546e7a;
    line-height: 1.5;
}

.rst-content .comm-flow-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.rst-content .comm-flow-chips .nav-chip {
    font-size: 0.78rem;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

.rst-content .comm-flow-legend {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.rst-content .comm-flow-legend th,
.rst-content .comm-flow-legend td {
    padding: 0.45rem 0.7rem;
    border: 1px solid #e1e4e8;
    text-align: left;
    vertical-align: top;
}

.rst-content .comm-flow-legend th {
    background: #eceff1;
    font-weight: 600;
    color: #37474f;
    width: 22%;
}

.rst-content .comm-flow-legend td {
    background: #fff;
}

.rst-content .comm-flow-diagram .comm-flow-legend + .comm-flow-legend {
    margin-top: 0.55rem;
}

.rst-content .comm-flow-section-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #78909c;
    margin: 0.55rem 0 0.35rem;
    padding-left: 0.1rem;
}

.rst-content .comm-flow-diagram > .comm-flow-section-label:first-of-type {
    margin-top: 0;
}

.rst-content .comm-flow-pipeline--chain .comm-flow-link--labeled .comm-flow-link-label {
    display: inline;
    font-size: 0.65rem;
    max-width: 4.5rem;
}

.rst-content .comm-flow-fork--register .comm-flow-fork-join .comm-flow-step-mid {
    max-width: min(100%, 18rem);
}

.rst-content .comm-flow-fork--interrupt {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem 0.75rem;
    width: 100%;
    margin: 0.25rem 0 0.65rem;
    padding: 0.9rem 1rem;
    background: #fff;
    border: 1px solid #eceff1;
    border-radius: 8px;
    box-sizing: border-box;
}

.rst-content .comm-flow-fork--interrupt .comm-flow-fork-col {
    min-width: 0;
}

.rst-content .comm-flow-fork--interrupt .comm-flow-fork-row .comm-flow-step {
    padding: 0.5rem 0.4rem;
}

.rst-content .comm-flow-fork--interrupt .comm-flow-fork-row .comm-flow-step-title {
    font-size: 0.76rem;
    line-height: 1.3;
}

.rst-content .comm-flow-pipeline--hub .comm-flow-step {
    min-width: 0;
}

.rst-content .comm-flow-pipeline .comm-flow-step .comm-flow-step-sub + .comm-flow-step-sub {
    margin-top: -0.1rem;
}

.rst-content .comm-flow-pipeline .comm-flow-step .comm-flow-step-sub code {
    font-size: 0.7rem;
}

.rst-content .comm-flow-diagram .comm-flow-canvas + .comm-flow-canvas {
    margin-top: 0.5rem;
}

/* 卡片流水线：双端（§6.1）与多步链（§1.4 / §9.1 等） */
.rst-content .comm-flow-pipeline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: stretch;
    gap: 0.5rem 0.65rem;
    width: 100%;
    margin: 0.25rem 0 0.65rem;
    padding: 0.9rem 1rem;
    background: #fff;
    border: 1px solid #eceff1;
    border-radius: 8px;
    box-sizing: border-box;
}

.rst-content .comm-flow-pipeline .comm-flow-link {
    min-width: 0;
    max-width: 5.75rem;
}

.rst-content .comm-flow-pipeline--chain {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: center;
    gap: 0.3rem 0.2rem;
}

.rst-content .comm-flow-pipeline--chain .comm-flow-step {
    flex: 1 1 5rem;
    min-width: 0;
    max-width: 9.5rem;
    padding: 0.6rem 0.55rem;
    box-sizing: border-box;
}

.rst-content .comm-flow-pipeline--chain .comm-flow-step-title {
    font-size: 0.84rem;
}

.rst-content .comm-flow-pipeline--chain .comm-flow-step-sub {
    font-size: 0.72rem;
}

.rst-content .comm-flow-pipeline--chain .comm-flow-link {
    flex: 0 0 auto;
    flex-direction: row;
    min-width: auto;
    padding: 0 0.1rem;
    align-self: center;
}

.rst-content .comm-flow-pipeline--chain .comm-flow-link-label {
    display: none;
}

.rst-content .comm-flow-pipeline--chain .comm-flow-link--labeled {
    flex-direction: column;
    min-width: 3.75rem;
    gap: 0.2rem;
}

.rst-content .comm-flow-pipeline--chain .comm-flow-link--labeled .comm-flow-link-label {
    display: inline;
    font-size: 0.65rem;
    white-space: normal;
    text-align: center;
    line-height: 1.25;
    padding: 0.15rem 0.35rem;
}

.rst-content .comm-flow-merge-row .comm-flow-link {
    flex: 0 0 auto;
    flex-direction: row;
    min-width: auto;
    padding: 0 0.1rem;
    align-self: center;
}

.rst-content .comm-flow-merge-row .comm-flow-link-label {
    display: none;
}

.rst-content .comm-flow-pipeline--hub {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
}

.rst-content .comm-flow-pipeline--hub .comm-flow-step-hub {
    grid-column: 1 / -1;
}

.rst-content .comm-flow-merge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    margin: 0.25rem 0 0.65rem;
    padding: 0.9rem 1rem;
    background: #fff;
    border: 1px solid #eceff1;
    border-radius: 8px;
    box-sizing: border-box;
}

.rst-content .comm-flow-merge-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.25rem 0.2rem;
    width: 100%;
}

.rst-content .comm-flow-merge-row .comm-flow-step {
    flex: 0 1 auto;
    min-width: 5.5rem;
    max-width: 8.5rem;
    padding: 0.6rem 0.65rem;
}

.rst-content .comm-flow-merge-join {
    color: #90a4ae;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.1rem 0;
}

.rst-content .comm-flow-merge .comm-flow-step-out {
    min-width: 8rem;
    max-width: 11rem;
}

/* 双路径汇合（Plugin §7.1） */
.rst-content .comm-flow-fork {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem 0.75rem;
    width: 100%;
    margin: 0.25rem 0 0.65rem;
    padding: 0.9rem 1rem 1rem;
    background: #fff;
    border: 1px solid #eceff1;
    border-radius: 8px;
    box-sizing: border-box;
}

.rst-content .comm-flow-fork-col {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
    background: #fafbfc;
    border: 1px solid #eceff1;
    border-radius: 8px;
    padding: 0.65rem 0.55rem 0.75rem;
}

.rst-content .comm-flow-fork-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #546e7a;
    text-align: center;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #e8eaed;
    margin-bottom: 0;
}

.rst-content .comm-flow-fork-desc {
    font-size: 0.76rem;
    color: #607d8b;
    text-align: center;
    line-height: 1.45;
    padding: 0 0.2rem 0.15rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.rst-content .comm-flow-fork-track {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.2rem 0.12rem;
    flex: 1;
    min-height: 4.5rem;
    align-content: center;
}

.rst-content .comm-flow-fork-track--single {
    justify-content: center;
    align-content: center;
}

.rst-content .comm-flow-fork-track .comm-flow-step {
    flex: 1 1 4.25rem;
    min-width: 3.75rem;
    max-width: 6.5rem;
    padding: 0.6rem 0.5rem;
}

.rst-content .comm-flow-fork-track--dense {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    min-height: auto;
}

.rst-content .comm-flow-fork-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: stretch;
    gap: 0.15rem 0.25rem;
    width: 100%;
}

.rst-content .comm-flow-fork-row .comm-flow-step {
    flex: none;
    max-width: none;
    min-width: 0;
    width: 100%;
    height: 100%;
}

.rst-content .comm-flow-fork-row .comm-flow-link-arrow {
    align-self: center;
}

.rst-content .comm-flow-fork-track--dense .comm-flow-step {
    flex: none;
    min-width: 0;
    max-width: none;
    padding: 0.55rem 0.45rem;
}

.rst-content .comm-flow-fork-track--dense .comm-flow-step-title {
    font-size: 0.8rem;
    line-height: 1.3;
}

.rst-content .comm-flow-fork-track--dense .comm-flow-step-sub {
    font-size: 0.68rem;
    line-height: 1.3;
}

.rst-content .comm-flow-fork-track--single .comm-flow-step {
    flex: 1 1 auto;
    max-width: 100%;
    min-width: 0;
    width: 100%;
    min-height: 4.5rem;
    justify-content: center;
}

.rst-content .comm-flow-fork-track .comm-flow-link-arrow {
    flex: 0 0 auto;
    font-size: 1rem;
    color: #90a4ae;
    line-height: 1;
    padding: 0 0.05rem;
}

.rst-content .comm-flow-fork-join {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding-top: 0.6rem;
    margin-top: 0.2rem;
    border-top: 1px dashed #cfd8dc;
}

.rst-content .comm-flow-fork-join-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #78909c;
    letter-spacing: 0.02em;
    text-align: center;
}

.rst-content .comm-flow-fork-join-arrow {
    color: #90a4ae;
    font-size: 1.1rem;
    line-height: 1;
}

.rst-content .comm-flow-fork-join .comm-flow-step {
    min-width: 0;
    max-width: min(100%, 20rem);
    width: 100%;
    box-sizing: border-box;
}

.rst-content .comm-flow-fork-join .comm-flow-step-sub code {
    font-size: 0.68rem;
}

.rst-content .comm-flow-step {
    min-width: 0;
    border-radius: 8px;
    border: 1px solid;
    padding: 0.75rem 0.85rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.3rem;
    box-sizing: border-box;
    overflow-wrap: anywhere;
}

.rst-content .comm-flow-step > * {
    max-width: 100%;
}

.rst-content .comm-flow-step-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #263238;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.rst-content .comm-flow-step-sub {
    font-size: 0.78rem;
    color: #607d8b;
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.rst-content .comm-flow-step-sub code,
.rst-content .comm-flow-fork-desc code {
    font-size: 0.72rem;
    word-break: break-all;
    white-space: normal;
    line-height: 1.35;
}

.rst-content .comm-flow-step-client {
    border-color: #9dd4d5;
    background: var(--color-app-bg);
}

.rst-content .comm-flow-step-mid {
    border-color: #cfd8dc;
    background: #f5f7f8;
}

.rst-content .comm-flow-step-server {
    border-color: #b8c4d0;
    background: var(--color-core-bg);
}

.rst-content .comm-flow-step-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #607d8b;
    overflow-wrap: anywhere;
}

.rst-content .comm-flow-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0 0.35rem;
    min-width: 4.25rem;
    align-self: center;
}

.rst-content .comm-flow-link-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #546e7a;
    white-space: normal;
    text-align: center;
    max-width: 5.5rem;
    overflow-wrap: anywhere;
    background: #f8f9fb;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1px solid #cfd8dc;
    line-height: 1.3;
}

.rst-content .comm-flow-link-arrow {
    font-size: 1.25rem;
    color: #90a4ae;
    line-height: 1;
}

@media screen and (max-width: 768px) {
    .rst-content .comm-flow-diagram {
        padding: 0.85rem 0.9rem 1rem;
    }

    .rst-content .comm-flow-canvas {
        padding: 0.65rem 0.5rem;
    }

    .rst-content .comm-flow-diagram pre.mermaid {
        min-width: 100%;
    }

    .rst-content .comm-flow-pipeline:not(.comm-flow-pipeline--chain) {
        grid-template-columns: 1fr;
        gap: 0.4rem;
        padding: 0.75rem 0.65rem;
    }

    .rst-content .comm-flow-pipeline--chain {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem 0.65rem;
    }

    .rst-content .comm-flow-step {
        width: 100%;
    }

    .rst-content .comm-flow-link {
        flex-direction: row;
        gap: 0.45rem;
        padding: 0.2rem 0;
    }

    .rst-content .comm-flow-pipeline--hub {
        grid-template-columns: 1fr;
    }

    .rst-content .comm-flow-pipeline--hub .comm-flow-step-hub {
        grid-column: auto;
    }

    .rst-content .comm-flow-pipeline--chain .comm-flow-step {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .rst-content .comm-flow-merge-row {
        flex-direction: column;
    }

    .rst-content .comm-flow-merge-row .comm-flow-step {
        max-width: 100%;
        width: 100%;
    }

    .rst-content .comm-flow-fork {
        grid-template-columns: 1fr;
        gap: 0.55rem;
    }

    .rst-content .comm-flow-fork-track--dense .comm-flow-step,
    .rst-content .comm-flow-fork-track .comm-flow-step {
        max-width: 100%;
        flex: 1 1 100%;
    }

    .rst-content .comm-flow-fork-row {
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    }

    .rst-content .comm-flow-fork-track--single .comm-flow-step {
        min-height: auto;
    }

    .rst-content .comm-flow-fork--interrupt {
        grid-template-columns: 1fr;
    }

    .rst-content .comm-flow-fork--interrupt .comm-flow-fork-row {
        flex-direction: column;
    }

    .rst-content .comm-flow-link-arrow {
        transform: rotate(90deg);
    }
}

/* ----------------------------------------------------------------------------
   算法框（控制器 LaTeX 算法描述）
   ---------------------------------------------------------------------------- */

.rst-content .algorithm-box-diagram {
    margin: 1.25rem 0 1.75rem;
    padding: 1.25rem 1.4rem;
    background: #f8f9fb;
    border: 1px solid #e1e4e8;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.rst-content .algorithm-box {
    border-radius: 10px;
    border: 1px solid;
    padding: 1rem 1.25rem 1.15rem;
    background: #fff;
    overflow-x: auto;
    width: 100%;
    box-sizing: border-box;
}

.rst-content .algorithm-box-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.6rem;
    margin-bottom: 0.65rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

.rst-content .algorithm-box-badge {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: #fff;
    flex-shrink: 0;
}

.rst-content .algorithm-box-title {
    font-size: 0.98rem;
    font-weight: 600;
    color: #263238;
}

.rst-content .algorithm-box-sub {
    font-size: 0.84rem;
    color: #607d8b;
    margin-bottom: 0.55rem;
}

.rst-content .algorithm-box-io {
    margin-bottom: 0.65rem;
}

.rst-content .algorithm-box-io table {
    margin: 0 !important;
    font-size: 0.88em;
    width: 100%;
}

.rst-content .algorithm-box-body {
    padding: 1rem 1.35rem;
    background: rgba(255, 255, 255, 0.65);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.rst-content .algorithm-box-body .math {
    overflow-x: auto;
    text-align: left;
    width: 100%;
    margin: 0;
}

.rst-content .algorithm-box-body mjx-container[display="true"] {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    text-align: left !important;
    font-size: 1.08em;
}

.rst-content .algorithm-box-body mjx-mtext {
    font-family: inherit;
    font-size: 0.92em;
}

.rst-content .algorithm-box-subroutine .algorithm-box-body {
    background: rgba(255, 255, 255, 0.85);
}

.rst-content .algorithm-box-footer {
    padding: 0.65rem 0.85rem;
    background: #fff;
    border: 1px dashed #cfd8dc;
    border-radius: 8px;
    font-size: 0.9em;
    color: #455a64;
}

.rst-content .algorithm-box-phase-a {
    border-color: #9dd4d5;
    background: var(--color-app-bg, #f0fafb);
}
.rst-content .algorithm-box-phase-a .algorithm-box-badge {
    background: var(--color-app, #26a69a);
}

.rst-content .algorithm-box-phase-b {
    border-color: #b8c4d0;
    background: var(--color-core-bg, #f5f7fa);
}
.rst-content .algorithm-box-phase-b .algorithm-box-badge {
    background: var(--color-core, #5c6bc0);
}

.rst-content .algorithm-box-phase-c {
    border-color: #c5b3d4;
    background: #faf8fc;
}
.rst-content .algorithm-box-phase-c .algorithm-box-badge {
    background: #7e57c2;
}

.rst-content .plan-arch-diagram .math {
    font-size: 0.95em;
}

.rst-content .plan-arch-diagram mjx-container {
    display: inline !important;
    margin: 0 0.1em !important;
}

/* TEB §2.11.7：紧约束 NLP 对照 — 算法框内块级公式 */
.rst-content .teb-nlp-compare .algorithm-box-body mjx-container[display="true"] {
    display: block !important;
    overflow-x: auto;
    margin: 0.65rem 0 0.85rem !important;
    text-align: left !important;
    max-width: 100%;
}

.rst-content .teb-nlp-compare .algorithm-box-body p {
    margin: 0.5rem 0 0.35rem;
}

.rst-content .teb-nlp-compare .algorithm-box-body strong {
    display: block;
    margin-top: 0.85rem;
    margin-bottom: 0.25rem;
    font-size: 0.92em;
    color: #37474f;
}

.rst-content .teb-nlp-compare .algorithm-box-body strong:first-child {
    margin-top: 0;
}

.rst-content .teb-nlp-compare .nav-chip-list {
    gap: 0.45rem 0.5rem;
}

/* ----------------------------------------------------------------------------
   Bridge RPC · Navigation 示例卡片
   ---------------------------------------------------------------------------- */

.rst-content .nav-card {
    margin: 1rem 0 1.75rem;
    padding: 0.85rem 1rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}

.rst-content .nav-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.55rem;
    margin-bottom: 0.75rem;
    font-size: 0.88em;
    line-height: 1.4;
}

.rst-content .nav-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: #eef2f7;
    color: #455a64;
    white-space: nowrap;
}

.rst-content .nav-chip b {
    font-weight: 600;
    color: #263238;
}

.rst-content .nav-chip-out {
    background: #e8f5e9;
    color: #2e7d32;
}

.rst-content .nav-chip-hint {
    background: transparent;
    padding-left: 0;
    color: #607d8b;
    white-space: normal;
}

.rst-content .nav-demo-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rst-content .nav-demo-panel {
    margin: 0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.rst-content .nav-demo-panel.nav-send {
    background: #eef5fc;
    border-color: #c5d9f0;
    border-left: 4px solid #1565c0;
}

.rst-content .nav-demo-panel.nav-recv {
    background: #eef8f0;
    border-color: #c5e1c8;
    border-left: 4px solid #2e7d32;
}

.rst-content .nav-demo-panel summary {
    cursor: pointer;
    padding: 0.5rem 0.85rem;
    font-size: 0.88em;
    font-weight: 600;
    user-select: none;
    list-style: none;
}

.rst-content .nav-demo-panel summary::-webkit-details-marker {
    display: none;
}

.rst-content .nav-demo-panel summary::before {
    content: "▸ ";
    display: inline-block;
    transition: transform 0.15s ease;
    color: #78909c;
}

.rst-content .nav-demo-panel[open] summary::before {
    transform: rotate(90deg);
}

.rst-content .nav-demo-panel.nav-send summary {
    background: #dceefb;
    color: #0d47a1;
    border-bottom: 1px solid transparent;
}

.rst-content .nav-demo-panel.nav-send[open] summary {
    border-bottom-color: #c5d9f0;
}

.rst-content .nav-demo-panel.nav-recv summary {
    background: #dcedc8;
    color: #1b5e20;
    border-bottom: 1px solid transparent;
}

.rst-content .nav-demo-panel.nav-recv[open] summary {
    border-bottom-color: #c5e1c8;
}

.rst-content .nav-demo-panel .highlight,
.rst-content .nav-demo-panel pre {
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

.rst-content .nav-demo-panel.nav-send .highlight,
.rst-content .nav-demo-panel.nav-send pre {
    background: #f5faff !important;
}

.rst-content .nav-demo-panel.nav-recv .highlight,
.rst-content .nav-demo-panel.nav-recv pre {
    background: #f6fbf7 !important;
}

.rst-content .nav-demo-panel .highlight pre {
    padding: 0.85rem 1rem !important;
    font-size: 0.82em !important;
    max-height: 24rem;
    overflow: auto;
}

/* ----------------------------------------------------------------------------
   Bridge RPC · 流程图（§3.5 时序）
   ---------------------------------------------------------------------------- */

.rst-content .rpc-flow-diagram {
    margin: 0.75rem 0 1.15rem;
}

.rst-content .rpc-flow-diagram .mermaid-container {
    padding: 0.7rem 0.85rem 0.6rem;
    background: linear-gradient(165deg, #f7fafc 0%, #fff 55%, #f8fbff 100%);
    border: 1px solid #d8e2ec;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(21, 101, 192, 0.06);
}

.rst-content .rpc-flow-diagram .mermaid-container pre.mermaid {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    font-size: 12px;
    line-height: 1.4;
}

.rst-content .rpc-flow-diagram .mermaid-container svg {
    display: block;
    margin: 0 auto;
    max-width: 100% !important;
}

.rst-content .rpc-flow-diagram--seq {
    max-width: min(100%, 580px);
}

/* §7.3 NavigationStatus 状态机 — 覆盖 sphinxcontrib-mermaid 注入的 flex/500px 规则 */
.rst-content .nav-state-diagram {
    margin: 0.75rem 0 1rem;
    width: 100%;
    max-width: 100%;
}

.rst-content .nav-state-diagram .mermaid-container {
    display: block !important;
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 !important;
    padding: 0.85rem 1rem 0.9rem;
    background: #fafbfc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: none;
    text-align: center;
    overflow: visible !important;
}

.rst-content .nav-state-diagram > pre.mermaid {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0.85rem 1rem;
    background: #fafbfc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-align: center;
    overflow: visible;
}

.rst-content .nav-state-diagram .mermaid-container pre.mermaid,
.rst-content .nav-state-diagram > pre.mermaid {
    width: 100%;
    max-width: 100%;
    height: auto !important;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    font-size: 13px;
    line-height: 1.4;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 容器全宽；SVG 限高等比缩放并居中（避免 width:100% 把纵向撑过高） */
.rst-content .nav-state-diagram pre.mermaid > svg,
.rst-content .nav-state-diagram .mermaid-container pre.mermaid > svg,
.rst-content .nav-state-diagram .mermaid-container > pre.mermaid > svg,
.rst-content .nav-state-diagram .mermaid-container > pre > svg {
    display: block !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 100% !important;
    max-height: 480px !important;
    margin: 0 auto;
}

/* 连线与标签：中性蓝灰，与 conf.py 全局 Mermaid 主题一致 */
.rst-content .nav-state-diagram svg .edgePaths path,
.rst-content .nav-state-diagram svg .transition {
    stroke: #5a7289 !important;
}

.rst-content .nav-state-diagram svg marker path {
    fill: #5a7289 !important;
    stroke: #5a7289 !important;
}

.rst-content .nav-state-diagram svg .edgeLabel .label {
    fill: #455a64 !important;
    color: #455a64 !important;
}

.rst-content .nav-state-diagram .mermaid-fullscreen-btn {
    position: absolute !important;
    top: 6px !important;
    right: 6px !important;
}

@media screen and (max-width: 768px) {
    .rst-content .rpc-flow-diagram .mermaid-container,
    .rst-content .nav-state-diagram .mermaid-container,
    .rst-content .nav-state-diagram > pre.mermaid {
        padding: 0.65rem 0.5rem;
    }
}

/* ----------------------------------------------------------------------------
   响应式优化
   ---------------------------------------------------------------------------- */

@media screen and (max-width: 768px) {
    .wy-nav-content {
        padding: 1rem !important;
    }
    
    .rst-content .highlight pre {
        padding: 1rem;
        font-size: 0.85em;
    }
    
    .rst-content table.docutils {
        font-size: 0.9em;
    }
    
    .rst-content table.docutils th,
    .rst-content table.docutils td {
        padding: 0.75rem;
    }
}

/* 运行时兜底：sphinxcontrib-mermaid 会在 head 注入 height:500px，此处必须置后 */
.rst-content .nav-state-diagram .mermaid-container > pre > svg,
.rst-content .nav-state-diagram pre.mermaid > svg {
    height: auto !important;
    width: auto !important;
    max-width: 100% !important;
    max-height: 480px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}
