/**
 * 时间线功能样式
 * - 前台渲染（.timeline-container）：折叠面板 + 竖向时间轴 + 节点详情弹层
 * - 编辑器弹窗（.timeline-modal）：与 .mindmap-modal / .question-modal 视觉规范一致
 *
 * 主要颜色全部取自个人中心设置的主题色：CSS 变量 --primary（article.php 内联设置）。
 * 通过 color-mix() 由主题色派生浅色/边框/轴线色；不支持 color-mix 的浏览器回退到
 * --primary-light 等基础变量。
 */

/* ============ 前台渲染容器 ============ */
.timeline-container {
    --tl-primary: var(--primary, #1677ff);
    /* color-mix 派生色（前一条为旧浏览器回退值） */
    --tl-soft: var(--primary-light, #e6f0ff);
    --tl-soft: color-mix(in srgb, var(--tl-primary) 13%, transparent);
    --tl-softer: color-mix(in srgb, var(--tl-primary) 6%, transparent);
    --tl-border: color-mix(in srgb, var(--tl-primary) 24%, var(--border, #e8e8e8));
    --tl-axis: color-mix(in srgb, var(--tl-primary) 45%, transparent);

    width: 100%;
    margin: 20px 0;
}

/* 折叠面板 */
.timeline-panel {
    position: relative;
    border: 1px solid var(--tl-border);
    border-radius: 12px;
    background: var(--bg-card, #fff);
    /* 不使用 overflow:hidden，避免裁剪节点详情弹层 */
    overflow: visible;
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.timeline-panel:hover {
    border-color: var(--tl-primary);
    box-shadow: 0 6px 22px rgba(22, 119, 255, 0.08);
    box-shadow: 0 6px 22px color-mix(in srgb, var(--tl-primary) 14%, transparent);
}

/* 面板头部：默认仅显示此行，点击标题展开；右侧为样式切换按钮 */
.timeline-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 12px;
    border-radius: 12px 12px 0 0;
    background: var(--bg-card, #fff);
    overflow: hidden;
}

/* 折叠状态下头部即面板全部内容，四角均需圆角 */
.timeline-panel:not(.is-open) .timeline-panel-header {
    border-radius: 12px;
}

/* 标题区（点击展开/收起） */
.timeline-panel-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
    padding: 13px 4px 13px 16px;
    border: none;
    background: transparent;
    color: var(--text, #1f2937);
    font-family: var(--font-family);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease;
}

.timeline-panel-toggle:hover {
    background: linear-gradient(90deg, var(--tl-softer), transparent 65%);
}

.timeline-panel-toggle:focus-visible {
    outline: 2px solid var(--tl-primary);
    outline-offset: -2px;
}

/* 样式切换按钮（点击循环切换：简约 → 卡片 → 中心轴） */
.timeline-style-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--tl-border);
    border-radius: 14px;
    background: var(--bg-card, #fff);
    color: var(--text-light, #999);
    font-family: var(--font-family);
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.timeline-style-btn:hover {
    color: var(--tl-primary);
    border-color: var(--tl-primary);
    background: var(--tl-soft);
}

.timeline-style-btn:focus-visible {
    outline: 2px solid var(--tl-primary);
    outline-offset: -2px;
}

.timeline-style-btn-label {
    display: inline-block;
}

/* 全部展开/收起按钮（与样式按钮同风格；中心轴样式隐藏） */
.timeline-expand-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--tl-border);
    border-radius: 14px;
    background: var(--bg-card, #fff);
    color: var(--text-light, #999);
    font-family: var(--font-family);
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.timeline-expand-btn:hover {
    color: var(--tl-primary);
    border-color: var(--tl-primary);
    background: var(--tl-soft);
}

.timeline-expand-btn:focus-visible {
    outline: 2px solid var(--tl-primary);
    outline-offset: -2px;
}

/* 中心轴样式：详情为对侧浮层，不提供全部展开 */
.timeline-container.timeline-style-center .timeline-expand-btn {
    display: none;
}

.timeline-panel-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--tl-soft);
    color: var(--tl-primary);
}

.timeline-panel-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-panel-count {
    flex: 0 0 auto;
    margin-left: auto;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--tl-soft);
    color: var(--tl-primary);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
}

.timeline-panel-chevron {
    display: inline-flex;
    flex: 0 0 auto;
    color: var(--text-light, #999);
    transition: transform 0.28s ease;
}

.timeline-panel.is-open .timeline-panel-chevron {
    transform: rotate(180deg);
}

/* 面板主体：默认隐藏，展开时淡入下滑 */
.timeline-panel-body {
    padding: 10px 18px 8px;
    border-top: 1px solid var(--tl-border);
    animation: timelineReveal 0.28s ease;
}

.timeline-panel:not(.is-open) .timeline-panel-body {
    display: none;
}

@keyframes timelineReveal {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- 竖向时间轴 ---- */
.timeline-list,
.markdown-body .timeline-list {
    position: relative;
    list-style: none;
    margin: 0;
    padding: 6px 0;
}

/* 移除列表默认标记与正文列表的实心圆点（global.css 的 .article-content ul>li::before），
   时间轴只保留竖直线上的 .timeline-dot，避免左侧边框/中间出现多余实心圆点 */
.timeline-list > li::marker,
.markdown-body .timeline-list > li::marker,
.article-content .timeline-list > li::marker,
.timeline-list > li::before,
.markdown-body .timeline-list > li::before,
.article-content .timeline-list > li::before {
    content: none;
}

/* 中轴线：顶部实色渐隐至底部透明 */
.timeline-list::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 14px;
    bottom: 14px;
    width: 2px;
    border-radius: 2px;
    background: linear-gradient(180deg,
        var(--tl-primary) 0%,
        var(--tl-axis) 14%,
        var(--tl-axis) 86%,
        transparent 100%);
}

.timeline-node,
.markdown-body .timeline-node {
    position: relative;
    list-style: none;
    margin: 0;
    padding: 0 0 20px 30px;
}

.timeline-node:last-child,
.markdown-body .timeline-node:last-child {
    padding-bottom: 4px;
}

/* 节点圆点：位于竖向轴线上（主题色描边 + 主题色光晕） */
.timeline-dot {
    position: absolute;
    left: 0;
    top: 3px;
    z-index: 1;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--bg-card, #fff);
    border: 3px solid var(--tl-primary);
    box-shadow: 0 0 0 3px var(--tl-soft);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.timeline-node:hover .timeline-dot,
.timeline-node.show-detail .timeline-dot {
    transform: scale(1.15);
    box-shadow: 0 0 0 4px var(--tl-soft);
}

.timeline-node-main {
    position: relative;
    border-radius: 10px;
    transition: transform 0.2s ease;
}

.timeline-node:hover .timeline-node-main {
    transform: translateX(2px);
}

/* 悬停/展开时提升节点自身层级：卡片 hover 的 transform 会形成层叠上下文，
   若只给浮层设 z-index 会被困在卡片内，导致浮层被后续卡片遮挡（中心轴样式对侧浮层必现） */
.timeline-node:hover,
.timeline-node.show-detail {
    z-index: 10;
}

/* 时间标签 */
.timeline-date {
    display: inline-block;
    margin-bottom: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--tl-soft);
    color: var(--tl-primary);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
}

.timeline-node-title {
    color: var(--text, #1f2937);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
}

.timeline-brief {
    margin-top: 3px;
    color: var(--text-light, #999);
    font-size: 13px;
    line-height: 1.6;
}

/* 详情弹层：桌面端 hover 弹出 */
.timeline-popover {
    position: absolute;
    left: 30px;
    right: 0;
    top: 100%;
    z-index: 30;
    margin-top: -8px;
    padding: 12px 14px;
    border: 1px solid var(--tl-border);
    border-left: 3px solid var(--tl-primary);
    border-radius: 10px;
    background: var(--bg-card, #fff);
    box-shadow: var(--shadow-hover, 0 8px 28px rgba(0, 0, 0, 0.14));
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.timeline-node.show-detail .timeline-popover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.timeline-popover-title {
    margin-bottom: 6px;
    color: var(--tl-primary);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
}

/* 详情按 Markdown 渲染（支持图片），故使用常规空白处理 */
.timeline-popover-detail {
    color: var(--text-secondary, #555);
    font-size: 13px;
    line-height: 1.7;
    overflow-wrap: break-word;
}

.timeline-popover-detail p {
    margin: 0 0 8px;
}

.timeline-popover-detail p:last-child {
    margin-bottom: 0;
}

.timeline-popover-detail img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 8px 0 0;
    border-radius: 8px;
}

.timeline-popover-detail img:first-child {
    margin-top: 0;
}

.timeline-popover-detail a {
    color: var(--tl-primary);
}

.timeline-empty {
    list-style: none;
    padding: 6px 0 6px 30px;
    color: var(--text-light, #999);
    font-size: 13px;
}

.timeline-error {
    padding: 14px;
    text-align: center;
    color: var(--text-light, #999);
    font-size: 13px;
}

/* ==================== 样式一：简约（默认） ====================
   细淡轴线 + 时间胶囊 + 更宽松留白，轻量简洁 */
.timeline-container.timeline-style-minimal .timeline-list::before {
    left: 7px;
    width: 1px;
    opacity: 0.5;
}

.timeline-container.timeline-style-minimal .timeline-node {
    padding-bottom: 26px;
}

.timeline-container.timeline-style-minimal .timeline-node:last-child {
    padding-bottom: 6px;
}

.timeline-container.timeline-style-minimal .timeline-node:hover .timeline-node-main {
    transform: none;
}

/* ==================== 样式二：卡片 ====================
   节点为浮起卡片，轴线为虚线轨道；电脑端时间在虚线左侧、卡片之外 */
.timeline-container.timeline-style-card .timeline-list::before {
    background: repeating-linear-gradient(180deg, var(--tl-axis) 0 7px, transparent 7px 14px);
}

.timeline-container.timeline-style-card .timeline-node {
    padding-bottom: 14px;
}

.timeline-container.timeline-style-card .timeline-dot {
    top: 16px;
}

.timeline-container.timeline-style-card .timeline-node-main {
    padding: 12px 14px;
    border: 1px solid var(--tl-border);
    border-radius: 12px;
    background: var(--bg-card, #fff);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.timeline-container.timeline-style-card .timeline-node:hover .timeline-node-main {
    transform: translateY(-2px);
    border-color: var(--tl-primary);
    box-shadow: 0 8px 22px color-mix(in srgb, var(--tl-primary) 16%, transparent);
}

/* 卡片样式：展开详情时隐藏简要信息，避免与详情重复 */
.timeline-container.timeline-style-card .timeline-node.show-detail .timeline-brief {
    display: none;
}

/* 电脑端卡片样式：日期移到竖直虚线左侧的独立栏，卡片内不再显示日期 */
@media (min-width: 769px) {
    .timeline-container.timeline-style-card .timeline-list::before {
        left: 106px;
    }

    .timeline-container.timeline-style-card .timeline-node {
        padding-left: 126px;
    }

    /* 圆点始终落在竖直虚线上（而非容器左侧边框处） */
    .timeline-container.timeline-style-card .timeline-dot {
        left: 100px;
    }

    /* 时间固定在竖直虚线左侧（相对节点定位，不受卡片 hover 位移影响） */
    .timeline-container.timeline-style-card .timeline-date {
        position: absolute;
        top: 15px;
        right: calc(100% - 96px);
        margin: 0;
        white-space: nowrap;
    }
}

/* ==================== 样式三：中心轴（电脑端） ====================
   页面中间一条竖主轴，事件卡片左右交替分布 */
@media (min-width: 769px) {
    /* 中轴位置（0~1）：默认居中；展开某侧节点的详情时，中轴向该侧移动，
       使对侧（详情浮层所在侧）获得更大宽度 */
    .timeline-container.timeline-style-center .timeline-list {
        --axis-frac: 0.5;
        --axis-frac-other: 0.5;
    }

    .timeline-container.timeline-style-center .timeline-list:has(.timeline-node:nth-child(odd).show-detail) {
        --axis-frac: 0.36;
        --axis-frac-other: 0.64;
    }

    .timeline-container.timeline-style-center .timeline-list:has(.timeline-node:nth-child(even).show-detail) {
        --axis-frac: 0.64;
        --axis-frac-other: 0.36;
    }

    .timeline-container.timeline-style-center .timeline-list::before {
        left: calc(var(--axis-frac) * 100%);
        transform: translateX(-1px);
        transition: left 0.3s ease;
    }

    .timeline-container.timeline-style-center .timeline-node {
        padding: 0 0 22px 0;
        box-sizing: border-box;
        transition: width 0.3s ease, margin-left 0.3s ease;
    }

    .timeline-container.timeline-style-center .timeline-node:nth-child(odd) {
        width: calc(var(--axis-frac) * 100%);
    }

    .timeline-container.timeline-style-center .timeline-node:nth-child(even) {
        width: calc(var(--axis-frac-other) * 100%);
        margin-left: calc(var(--axis-frac) * 100%);
    }

    /* 隐藏圆点，节点标记改为在轴侧显示时间胶囊，避免与中轴圆点重叠 */
    .timeline-container.timeline-style-center .timeline-dot {
        display: none;
    }

    /* 时间显示在事件卡片的另一侧、靠近中轴（距轴 8px），位于行首；
       有时间时节点顶部留出该行高度，避免与同层的详情浮层重叠 */
    .timeline-container.timeline-style-center .timeline-node:has(.timeline-date) {
        padding-top: 30px;
    }

    .timeline-container.timeline-style-center .timeline-date {
        position: absolute;
        top: 4px;
        z-index: 2;
        margin: 0;
        white-space: nowrap;
    }

    .timeline-container.timeline-style-center .timeline-node:nth-child(odd) .timeline-date {
        left: calc(100% + 8px);
        right: auto;
    }

    .timeline-container.timeline-style-center .timeline-node:nth-child(even) .timeline-date {
        right: calc(100% + 8px);
        left: auto;
    }

    .timeline-container.timeline-style-center .timeline-node-main {
        padding: 12px 14px;
        border: 1px solid var(--tl-border);
        border-radius: 12px;
        background: var(--bg-card, #fff);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    }

    /* 卡片与中轴留出间距，并绘制水平连接线 */
    .timeline-container.timeline-style-center .timeline-node:nth-child(odd) .timeline-node-main {
        margin-right: 18px;
    }

    .timeline-container.timeline-style-center .timeline-node:nth-child(even) .timeline-node-main {
        margin-left: 18px;
    }

    .timeline-container.timeline-style-center .timeline-node-main::after {
        content: '';
        position: absolute;
        top: 22px;
        width: 18px;
        height: 2px;
        background: var(--tl-axis);
    }

    .timeline-container.timeline-style-center .timeline-node:nth-child(odd) .timeline-node-main::after {
        right: -18px;
    }

    .timeline-container.timeline-style-center .timeline-node:nth-child(even) .timeline-node-main::after {
        left: -18px;
    }

    .timeline-container.timeline-style-center .timeline-node:hover .timeline-node-main {
        transform: translateY(-2px);
        border-color: var(--tl-primary);
        box-shadow: 0 8px 22px color-mix(in srgb, var(--tl-primary) 16%, transparent);
    }

    /* 详情浮层显示在中轴另一侧的对称位置（与卡片镜像），并绘制连到中轴的连接线；
       宽度按分栏比例推算，使浮层始终铺满对侧区域（中轴偏移后自动变宽） */
    .timeline-container.timeline-style-center .timeline-popover {
        top: 0;
        margin-top: 0;
        border-left-width: 1px;
        border-left-color: var(--tl-border);
    }

    .timeline-container.timeline-style-center .timeline-node:nth-child(odd) .timeline-popover {
        left: calc(100% + 36px);
        right: auto;
        width: calc(var(--axis-frac-other) / var(--axis-frac) * (100% + 18px) - 18px);
    }

    .timeline-container.timeline-style-center .timeline-node:nth-child(even) .timeline-popover {
        right: calc(100% + 36px);
        left: auto;
        width: calc(var(--axis-frac) / var(--axis-frac-other) * (100% + 18px) - 18px);
    }

    .timeline-container.timeline-style-center .timeline-popover::before {
        content: '';
        position: absolute;
        top: 24px;
        width: 18px;
        height: 2px;
        background: var(--tl-axis);
    }

    .timeline-container.timeline-style-center .timeline-node:nth-child(odd) .timeline-popover::before {
        left: -18px;
    }

    .timeline-container.timeline-style-center .timeline-node:nth-child(even) .timeline-popover::before {
        right: -18px;
    }
}

/* ==================== 简约 / 卡片：详情内联展开（不用弹层） ====================
   详情默认收起，鼠标悬停（电脑端）或点按（移动端）时在节点内自动展开 */
.timeline-container.timeline-style-minimal .timeline-popover,
.timeline-container.timeline-style-card .timeline-popover {
    position: static;
    display: none;
    margin: 8px 0 0;
    padding: 10px 12px;
    border: none;
    border-left: 3px solid var(--tl-primary);
    border-radius: 0 8px 8px 0;
    background: var(--tl-softer);
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
}

/* 卡片样式：详情位于卡片内容中，不加边框、背景色与阴影，作为纯文本展示 */
.timeline-container.timeline-style-card .timeline-popover {
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.timeline-container.timeline-style-minimal .timeline-node.show-detail .timeline-popover,
.timeline-container.timeline-style-card .timeline-node.show-detail .timeline-popover {
    display: block;
    animation: timelineDetailReveal 0.24s ease;
}

/* 内联展开时节点标题已在上方，详情块内不再重复显示标题 */
.timeline-container.timeline-style-minimal .timeline-popover-title,
.timeline-container.timeline-style-card .timeline-popover-title {
    display: none;
}

/* 全部展开：简约/卡片样式下所有节点详情常显，且悬停移开不自动收起 */
.timeline-container.timeline-expand-all.timeline-style-minimal .timeline-popover,
.timeline-container.timeline-expand-all.timeline-style-card .timeline-popover {
    display: block;
    animation: none;
}

/* 卡片样式：全部展开时与单个展开一致，隐藏简要信息避免与详情重复 */
.timeline-container.timeline-expand-all.timeline-style-card .timeline-node .timeline-brief {
    display: none;
}

@keyframes timelineDetailReveal {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 编辑器预览：详情内联常显，便于作者查看完整内容（边框/底色等由各样式规则决定） */
.timeline-container.timeline-preview .timeline-node .timeline-popover {
    position: static;
    display: block;
    margin: 8px 0 0;
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
    box-shadow: none;
}

/* ============ 移动端适配：详情改为内联展开（触摸） ============ */
@media (max-width: 768px) {
    .timeline-panel-body {
        padding: 8px 14px 4px;
    }

    .timeline-node,
    .markdown-body .timeline-node {
        padding-left: 26px;
    }

    .timeline-popover {
        position: static;
        display: none;
        margin: 8px 0 0;
        left: auto;
        right: auto;
        top: auto;
        opacity: 1;
        visibility: visible;
        transform: none;
        pointer-events: auto;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    }

    .timeline-node.show-detail .timeline-popover {
        display: block;
    }

    /* 触摸设备无 hover，还原 hover 造成的位移与放大 */
    .timeline-node:hover .timeline-node-main,
    .timeline-container.timeline-style-card .timeline-node:hover .timeline-node-main {
        transform: none;
    }

    .timeline-node:hover .timeline-dot {
        transform: none;
        box-shadow: 0 0 0 3px var(--tl-soft);
    }

    /* 中心轴样式仅用于电脑端：移动端回退为卡片+单侧轴线 */
    .timeline-container.timeline-style-center .timeline-list::before {
        left: 6px;
        transform: none;
        background: repeating-linear-gradient(180deg, var(--tl-axis) 0 7px, transparent 7px 14px);
    }

    .timeline-container.timeline-style-center .timeline-node {
        width: auto;
        margin-left: 0;
        padding: 0 0 14px 26px;
    }

    .timeline-container.timeline-style-center .timeline-node-main {
        padding: 12px 14px;
        border: 1px solid var(--tl-border);
        border-radius: 12px;
        background: var(--bg-card, #fff);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    }

    .timeline-container.timeline-style-center .timeline-node-main::after {
        display: none;
    }

    .timeline-container.timeline-style-center .timeline-popover {
        left: 30px;
    }
}

/* 窄屏：样式切换按钮仅显示图标、隐藏节点计数，节省标题区空间 */
@media (max-width: 480px) {
    .timeline-style-btn-label {
        display: none;
    }

    .timeline-style-btn {
        padding: 0 8px;
    }

    .timeline-panel-count {
        display: none;
    }
}

/* ============ 编辑器弹窗 ============ */
.timeline-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.timeline-modal.show {
    display: block;
}

.timeline-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.timeline-modal-content {
    position: relative;
    width: 92%;
    max-width: 960px;
    margin: 40px auto 0;
    background: var(--bg-card, #fff);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.timeline-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border, #e8e8e8);
}

.timeline-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text, #333);
}

.timeline-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--text-light, #999);
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.2s;
}

.timeline-modal-close:hover {
    color: var(--text, #333);
}

.timeline-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.timeline-editor-layout {
    display: flex;
    gap: 16px;
    min-height: 360px;
}

.timeline-editor-input,
.timeline-editor-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.timeline-editor-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text, #333);
    margin-bottom: 6px;
}

.timeline-editor-hint {
    font-size: 12px;
    color: var(--text-light, #999);
    margin-bottom: 8px;
    line-height: 1.7;
}

.timeline-editor-hint code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--bg-gray, #f5f5f5);
    color: var(--primary, #1677ff);
    font-size: 11px;
}

.timeline-textarea {
    width: 100%;
    flex: 1;
    min-height: 320px;
    padding: 12px;
    border: 1px solid var(--border, #d9d9d9);
    border-radius: 6px;
    font-family: "阿里巴巴普惠体", "Alibaba Sans", Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.7;
    resize: vertical;
    background: var(--bg-card, #fff);
    color: var(--text, #333);
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

.timeline-textarea:focus {
    border-color: var(--primary, #1677ff);
}

.timeline-preview-wrap {
    flex: 1;
    min-height: 320px;
    padding: 12px 14px;
    border: 1px solid var(--border, #d9d9d9);
    border-radius: 6px;
    background: var(--bg-gray, #fafafa);
    overflow: auto;
    position: relative;
}

/* 预览容器内的面板去掉外边距，贴合预览区 */
.timeline-preview-wrap .timeline-container {
    margin: 0;
}

.timeline-preview-loading {
    color: var(--text-light, #999);
    font-size: 13px;
    padding: 20px 0;
    text-align: center;
}

.timeline-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border, #e8e8e8);
}

/* 弹窗移动端适配 */
@media (max-width: 768px) {
    .timeline-modal-content {
        width: 96%;
        margin-top: 20px;
        max-height: calc(100vh - 40px);
    }

    .timeline-editor-layout {
        flex-direction: column;
        min-height: auto;
    }

    .timeline-textarea,
    .timeline-preview-wrap {
        min-height: 220px;
    }
}
